-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathdestroy_action.cpp
133 lines (119 loc) · 3.57 KB
/
destroy_action.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include "stdafx.h"
#include "destroy_action.h"
#include "sound.h"
#include "creature.h"
#include "creature_attributes.h"
SERIALIZE_DEF(DestroyAction, type)
SERIALIZATION_CONSTRUCTOR_IMPL(DestroyAction)
DestroyAction::DestroyAction(Type t) : type(t) {
}
TStringId DestroyAction::getTaskDescription() const {
switch (type) {
case Type::CUT: return TStringId("CUT_TREE_TASK");
case Type::DIG: return TStringId("DIG_TASK");
case Type::FILL: return TStringId("FILL_TASK");
default:
return TStringId("DESTROY_TASK");
}
}
TStringId DestroyAction::getVerbSecondPerson() const {
switch (type) {
case Type::BASH: return TStringId("YOU_BASH_FURNITURE");
case Type::BOULDER: return TStringId("YOU_DESTROY_FURNITURE");
case Type::CUT: return TStringId("YOU_CUT_FURNITURE");
case Type::HOSTILE_DIG:
case Type::DIG: return TStringId("YOU_DIG_INTO_FURNITURE");
case Type::FILL: return TStringId("YOU_FILL_FURNITURE");
}
}
TStringId DestroyAction::getVerbThirdPerson() const {
switch (type) {
case Type::BASH: return TStringId("BASHES_FURNITURE");
case Type::BOULDER: return TStringId("DESTROYS_FURNITURE");
case Type::CUT: return TStringId("CUTS_FURNITURE");
case Type::HOSTILE_DIG:
case Type::DIG: return TStringId("DIGS_INTO_FURNITURE");
case Type::FILL: return TStringId("FILLS_FURNITURE");
}
}
TStringId DestroyAction::getIsDestroyed() const {
switch (type) {
case Type::BASH:
case Type::BOULDER: return TStringId("FURNITURE_IS_DESTROYED");
case Type::CUT: return TStringId("FURNITURE_FALLS");
case Type::HOSTILE_DIG:
case Type::DIG: return TStringId("FURNITURE_IS_DUG_OUT");
case Type::FILL: return TStringId("FURNITURE_IS_FILLED");;
}
}
optional<TStringId> DestroyAction::getSoundText() const {
switch (type) {
case Type::BASH: return TStringId("FURNITURE_BANG");
case Type::BOULDER:
case Type::CUT: return TStringId("FURNITURE_CRASH");;
case Type::HOSTILE_DIG:
case Type::FILL:
case Type::DIG: return none;
}
}
optional<Sound> DestroyAction::getSound() const {
switch (type) {
case Type::FILL: return none;
case Type::BASH:
case Type::BOULDER: return Sound(SoundId("BANG_DOOR"));
case Type::CUT: return Sound(SoundId("TREE_CUTTING"));
case Type::HOSTILE_DIG:
case Type::DIG: return Sound(SoundId("DIGGING"));
}
}
DestroyAction::Type DestroyAction::getType() const {
return type;
}
bool DestroyAction::canDestroyFriendly() const {
switch (type) {
case Type::BASH:
case Type::HOSTILE_DIG:
return false;
default:
return true;
}
}
bool DestroyAction::destroyAnimation() const {
switch (type) {
case Type::FILL: return false;
default: return true;
}
}
bool DestroyAction::canNavigate(const Creature* c) const {
switch (type) {
case Type::HOSTILE_DIG:
return !isOneOf(c->getTribeId(), TribeId::getDarkKeeper(), TribeId::getWhiteKeeper(),
TribeId::getRetiredKeeper());
case Type::BASH:
return true;
default:
return false;
}
}
MinionActivity DestroyAction::getMinionActivity() const {
switch (type) {
case Type::DIG:
return MinionActivity::DIGGING;
default:
return MinionActivity::WORKING;
}
}
double DestroyAction::getDamage(Creature* c) const {
PROFILE;
switch (type) {
case Type::BASH:
case Type::BOULDER:
case Type::CUT:
return max(c->getAttr(AttrType("DAMAGE")), 15);
case Type::HOSTILE_DIG:
return max(c->getAttr(AttrType("DIGGING")), 15) / 5.0;
case Type::DIG:
case Type::FILL:
return c->getAttr(AttrType("DIGGING")) / 5.0;
}
}