39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
#include "libtcod.hpp"
|
|
#include "Confuser.h"
|
|
#include "Engine.h"
|
|
#include "Gui.h"
|
|
#include "Ai.h"
|
|
#include "Actor.h"
|
|
|
|
|
|
Confuser::Confuser(int nbTurns, float range)
|
|
: nbTurns(nbTurns), range(range) {
|
|
}
|
|
bool Confuser::use(Actor* owner, Actor* wearer) {
|
|
engine->gui->message(engine->gui->lightBlue, "Left-click an enemy to confuse it,\nor right-click to cancel.");
|
|
int x, y;
|
|
if (!engine->pickATile(&x, &y, range)) {
|
|
return false;
|
|
}
|
|
Actor* actor = engine->getActor(x, y);
|
|
if (!actor) {
|
|
return false;
|
|
}
|
|
// confuse the monster for <nbTurns> turns
|
|
Ai* confusedAi = new ConfusedMonsterAi(nbTurns, actor->ai);
|
|
actor->ai = confusedAi;
|
|
engine->gui->message(engine->gui->lightGreen, "The eyes of the %s look vacant,\nas he starts to stumble around!",
|
|
actor->name.c_str());
|
|
return Pickable::use(owner, wearer);
|
|
}
|
|
|
|
void Confuser::load(TCODZip& zip) {
|
|
nbTurns = zip.getInt();
|
|
range = zip.getFloat();
|
|
}
|
|
|
|
void Confuser::save(TCODZip& zip) {
|
|
zip.putInt(CONFUSER);
|
|
zip.putInt(nbTurns);
|
|
zip.putFloat(range);
|
|
} |