forked from miki151/keeperrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonster.cpp
93 lines (82 loc) · 4.81 KB
/
monster.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "stdafx.h"
#include "monster.h"
using namespace std;
Monster::Monster(Creature* c, MonsterAIFactory f) :
creature(c), actor(f.getMonsterAI(c)) {}
ControllerFactory Monster::getFactory(MonsterAIFactory f) {
return ControllerFactory([=](Creature* c) { return new Monster(c, f);});
}
void Monster::makeMove() {
actor->makeMove();
}
static string addName(const string& s, const string& n) {
if (n.size() > 0)
return s + " " + n;
else
return s;
}
bool Monster::isPlayer() const {
return false;
}
const MapMemory& Monster::getMemory(const Level* l) const {
return MapMemory::empty();
}
void Monster::onBump(Creature* c) {
if (c->isEnemy(creature))
c->attack(creature, false);
else if (c->canMove(creature->getPosition() - c->getPosition()))
c->move(creature->getPosition() - c->getPosition());
}
void Monster::you(MsgType type, const string& param) const {
string msg, msgNoSee;
switch (type) {
case MsgType::ARE: msg = creature->getTheName() + " is " + param; break;
case MsgType::YOUR: msg = creature->getTheName() + "'s " + param; break;
case MsgType::FEEL: msg = creature->getTheName() + " looks " + param; break;
case MsgType::FALL_ASLEEP: msg = (creature->getTheName() + " falls asleep") + (param.size() > 0 ? " on the " + param : ".");
msgNoSee = "You hear snoring."; break;
case MsgType::WAKE_UP: msg = creature->getTheName() + " wakes up."; break;
case MsgType::DIE: msg = creature->getTheName() + " is killed!"; break;
case MsgType::TELE_APPEAR: msg = creature->getTheName() + " appears out of nowhere!"; break;
case MsgType::TELE_DISAPPEAR: msg = creature->getTheName() + " suddenly disappears!"; break;
case MsgType::BLEEDING_STOPS: msg = creature->getTheName() + "'s bleeding stops."; break;
case MsgType::DIE_OF: msg = creature->getTheName() +
" dies" + (param.empty() ? string(".") : " of " + param); break;
case MsgType::FALL_APART: msg = creature->getTheName() + " falls apart."; break;
case MsgType::MISS_ATTACK: msg = creature->getTheName() + addName(" misses", param); break;
case MsgType::MISS_THROWN_ATTACK: msg = param + " misses " + creature->getTheName(); break;
case MsgType::HIT_THROWN_ITEM: msg = param + " hits " + creature->getTheName(); break;
case MsgType::CRASH_THROWN_ITEM: msg = param + " crashes on " + creature->getTheName() + "'s head"; break;
case MsgType::GET_HIT_NODAMAGE: msg = "The " + param + " is harmless."; break;
case MsgType::COLLAPSE: msg = creature->getTheName() + " collapses."; break;
case MsgType::FALL: msg = creature->getTheName() + " falls on the " + param; break;
case MsgType::TRIGGER_TRAP: msg = creature->getTheName() + " triggers something."; break;
case MsgType::PANIC: msg = creature->getTheName() + " panics."; break;
case MsgType::RAGE: msg = creature->getTheName() + " is enraged."; break;
case MsgType::SWING_WEAPON: msg = creature->getTheName() + " swings his " + param; break;
case MsgType::THRUST_WEAPON: msg = creature->getTheName() + " thrusts his " + param; break;
case MsgType::KICK: msg = creature->getTheName() + addName(" kicks", param); break;
case MsgType::BITE: msg = creature->getTheName() + addName(" bites", param); break;
case MsgType::PUNCH: msg = creature->getTheName() + addName(" punches", param); break;
case MsgType::CRAWL: msg = creature->getTheName() + " is crawling"; break;
case MsgType::STAND_UP: msg = creature->getTheName() + " is back on his feet"; break;
case MsgType::TURN_INVISIBLE: msg = creature->getTheName() + " disappears!"; break;
case MsgType::TURN_VISIBLE: msg = creature->getTheName() + " appears out of nowhere!"; break;
case MsgType::DROP_WEAPON: msg = creature->getTheName() + " drops his " + param; break;
case MsgType::ITEM_CRASHES: msg = param + " crashes on " + creature->getTheName(); break;
case MsgType::ENTER_PORTAL: msg = creature->getTheName() + " disappears in the portal."; break;
case MsgType::HAPPENS_TO: msg = param + " " + creature->getTheName(); break;
case MsgType::BURN: msg = creature->getTheName() + " burns in the " + param; msgNoSee = "You hear a horrible shriek"; break;
case MsgType::DROWN: msg = creature->getTheName() + " drowns in the " + param; msgNoSee = "You hear a loud splash" ;break;
case MsgType::SET_UP_TRAP: msg = "You set up the trap"; break;
case MsgType::KILLED_BY: msg = creature->getTheName() + " is killed by " + param; break;
case MsgType::TURN: msg = creature->getTheName() + " turns into " + param; break;
case MsgType::HIT: msg = creature->getTheName() + addName(" hits", param); break;
default: break;
}
if (!msg.empty())
creature->globalMessage(msg, msgNoSee);
}
void Monster::you(const string& param) const {
creature->globalMessage(creature->getTheName() + " " + param);
}