forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bodypart.cpp
236 lines (222 loc) · 5.33 KB
/
bodypart.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#include "bodypart.h"
#include "translations.h"
#include "rng.h"
std::map<std::string, body_part> body_parts;
std::string body_part_name (body_part bp)
{
switch (bp) {
case bp_head:
return _("head");
case bp_eyes:
return _("eyes");
case bp_mouth:
return _("mouth");
case bp_torso:
return _("torso");
case bp_arm_l:
return _("left arm");
case bp_arm_r:
return _("right arm");
case bp_hand_l:
return _("left hand");
case bp_hand_r:
return _("right hand");
case bp_leg_l:
return _("left leg");
case bp_leg_r:
return _("right leg");
case bp_foot_l:
return _("left foot");
case bp_foot_r:
return _("right foot");
default:
return _("appendix");
}
}
std::string body_part_name_accusative (body_part bp)
{
switch (bp) {
case bp_head:
return pgettext("bodypart_accusative", "head");
case bp_eyes:
return pgettext("bodypart_accusative", "eyes");
case bp_mouth:
return pgettext("bodypart_accusative", "mouth");
case bp_torso:
return pgettext("bodypart_accusative", "torso");
case bp_arm_l:
return pgettext("bodypart_accusative", "left arm");
case bp_arm_r:
return pgettext("bodypart_accusative", "right arm");
case bp_hand_l:
return pgettext("bodypart_accusative", "left hand");
case bp_hand_r:
return pgettext("bodypart_accusative", "right hand");
case bp_leg_l:
return pgettext("bodypart_accusative", "left leg");
case bp_leg_r:
return pgettext("bodypart_accusative", "right leg");
case bp_foot_l:
return pgettext("bodypart_accusative", "left foot");
case bp_foot_r:
return pgettext("bodypart_accusative", "right foot");
default:
return pgettext("bodypart_accusative", "appendix");
}
}
std::string encumb_text(body_part bp)
{
switch (bp) {
case bp_head:
return "";
case bp_eyes:
return _("Ranged combat is hampered.");
case bp_mouth:
return _("Running is slowed.");
case bp_torso:
return _("Dodging and melee is hampered.");
case bp_arm_l:
case bp_arm_r:
return _("Melee and ranged combat is hampered.");
case bp_hand_l:
case bp_hand_r:
return _("Manual tasks are slowed.");
case bp_leg_l:
case bp_leg_r:
return _("Running and swimming are slowed.");
case bp_foot_l:
case bp_foot_r:
return _("Running is slowed.");
default:
return _("It's inflamed.");
}
}
body_part random_body_part(bool main_parts_only)
{
int rn = rng(0, 100);
if (!main_parts_only) {
if (rn == 0) {
return bp_eyes;
}
if (rn <= 1) {
return bp_mouth;
}
if (rn <= 7) {
return bp_head;
}
if (rn <= 16) {
return bp_leg_l;
}
if (rn <= 25) {
return bp_leg_r;
}
if (rn <= 28) {
return bp_foot_l;
}
if (rn <= 31) {
return bp_foot_r;
}
if (rn <= 40) {
return bp_arm_l;
}
if (rn <= 49) {
return bp_arm_r;
}
if (rn <= 52) {
return bp_hand_l;
}
if (rn <= 55) {
return bp_hand_r;
}
return bp_torso;
} else {
if (rn <= 7) {
return bp_head;
}
if (rn <= 19) {
return bp_leg_l;
}
if (rn <= 31) {
return bp_leg_r;
}
if (rn <= 43) {
return bp_arm_l;
}
if (rn <= 55) {
return bp_arm_r;
}
return bp_torso;
}
}
body_part mutate_to_main_part(body_part bp)
{
switch (bp) {
case bp_torso:
return bp_torso;
case bp_head:
case bp_eyes:
case bp_mouth:
return bp_head;
case bp_arm_l:
case bp_hand_l:
return bp_arm_l;
case bp_arm_r:
case bp_hand_r:
return bp_arm_r;
case bp_leg_l:
case bp_foot_l:
return bp_leg_l;
case bp_leg_r:
case bp_foot_r:
return bp_leg_r;
default:
return num_bp;
}
}
void init_body_parts()
{
body_parts["TORSO"] = bp_torso;
body_parts["HEAD"] = bp_head;
body_parts["EYES"] = bp_eyes;
body_parts["MOUTH"] = bp_mouth;
body_parts["ARM_L"] = bp_arm_l;
body_parts["ARM_R"] = bp_arm_r;
body_parts["HAND_L"] = bp_hand_l;
body_parts["HAND_R"] = bp_hand_r;
body_parts["LEG_L"] = bp_leg_l;
body_parts["LEG_R"] = bp_leg_r;
body_parts["FOOT_L"] = bp_foot_l;
body_parts["FOOT_R"] = bp_foot_r;
body_parts["NUM_BP"] = num_bp;
}
std::string get_body_part_id(body_part bp)
{
switch (bp) {
case bp_head:
return "HEAD";
case bp_eyes:
return "EYES";
case bp_mouth:
return "MOUTH";
case bp_torso:
return "TORSO";
case bp_arm_l:
return "ARM_L";
case bp_arm_r:
return "ARM_R";
case bp_hand_l:
return "HAND_L";
case bp_hand_r:
return "HAND_R";
case bp_leg_l:
return "LEG_L";
case bp_leg_r:
return "LEG_R";
case bp_foot_l:
return "FOOT_L";
case bp_foot_r:
return "FOOT_R";
default:
throw std::string("bad body part: %d", bp);
}
}