forked from Whales/Cataclysm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mondeath.cpp
221 lines (204 loc) · 5.92 KB
/
mondeath.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
#include "mondeath.h"
#include "monster.h"
#include "game.h"
#include "rng.h"
#include "line.h"
#include <sstream>
void mdeath::normal(game *g, monster *z)
{
int junk;
if (g->u_see(z, junk))
g->add_msg("It dies!");
if (z->made_of(FLESH) && z->has_flag(MF_WARM)) {
if (g->m.field_at(z->posx, z->posy).type == fd_blood &&
g->m.field_at(z->posx, z->posy).density < 3)
g->m.field_at(z->posx, z->posy).density++;
else
g->m.add_field(g, z->posx, z->posy, fd_blood, 1);
}
// Drop a dang ol' corpse
// If their hp is less than -50, we destroyed them so badly no corpse was left
if ((z->hp >= -50 || z->hp >= 0 - 2 * z->type->hp) &&
(z->made_of(FLESH) || z->made_of(VEGGY))) {
item tmp;
tmp.make_corpse(g->itypes[itm_corpse], z->type, g->turn);
g->m.add_item(z->posx, z->posy, tmp);
}
}
void mdeath::acid(game *g, monster *z)
{
int tmp;
if (g->u_see(z, tmp))
g->add_msg("The %s's corpse melts into a pool of acid.", z->name().c_str());
g->m.add_field(g, z->posx, z->posy, fd_acid, 3);
}
void mdeath::boomer(game *g, monster *z)
{
std::string tmp;
g->sound(z->posx, z->posy, 24, "a boomer explode!");
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
g->m.bash(z->posx + i, z->posy + j, 10, tmp);
if (g->m.field_at(z->posx + i, z->posy + j).type == fd_bile &&
g->m.field_at(z->posx + i, z->posy + j).density < 3)
g->m.field_at(z->posx + i, z->posy + j).density++;
else
g->m.add_field(g, z->posx + i, z->posy + j, fd_bile, 1);
int mondex = g->mon_at(z->posx + i, z->posy +j);
if (mondex != -1) {
g->z[mondex].stumble(g, false);
g->z[mondex].moves -= 250;
}
}
}
if (abs(z->posx - g->u.posx) <= 1 && abs(z->posy - g->u.posy) <= 1)
g->u.infect(DI_BOOMERED, bp_eyes, 2, 24, g);
}
void mdeath::fungus(game *g, monster *z)
{
monster spore(g->mtypes[mon_spore]);
int sporex, sporey;
g->sound(z->posx, z->posy, 10, "Pouf!");
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
sporex = z->posx + i;
sporey = z->posy + j;
if (g->m.move_cost(sporex, sporey) > 0 && one_in(5)) {
if (g->mon_at(sporex, sporey) >= 0) { // Spores hit a monster
if (g->u_see(sporex, sporey, j))
g->add_msg("The %s is covered in tiny spores!",
g->z[g->mon_at(sporex, sporey)].name().c_str());
if (!g->z[g->mon_at(sporex, sporey)].make_fungus(g))
g->kill_mon(g->mon_at(sporex, sporey));
} else if (g->u.posx == sporex && g->u.posy == sporey)
g->u.infect(DI_SPORES, bp_mouth, 4, 30, g);
else {
spore.spawn(sporex, sporey);
g->z.push_back(spore);
}
}
}
}
}
void mdeath::fungusawake(game *g, monster *z)
{
monster newfung(g->mtypes[mon_fungaloid]);
newfung.spawn(z->posx, z->posy);
g->z.push_back(newfung);
}
void mdeath::disintegrate(game *g, monster *z)
{
int junk;
if (g->u_see(z, junk))
g->add_msg("It disintegrates!");
}
void mdeath::worm(game *g, monster *z)
{
int j;
if (g->u_see(z, j))
g->add_msg("The %s splits in two!", z->name().c_str());
std::vector <point> wormspots;
int wormx, wormy;
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
wormx = z->posx + i;
wormy = z->posy + i;
if (g->m.has_flag(diggable, wormx, wormy) && g->mon_at(wormx, wormy) == -1 &&
!(g->u.posx == wormx && g->u.posy == wormy)) {
wormspots.push_back(point(wormx, wormy));
}
}
}
int rn;
monster worm(g->mtypes[mon_halfworm]);
for (int worms = 0; worms < 2 && wormspots.size() > 0; worms++) {
rn = rng(0, wormspots.size() - 1);
worm.spawn(wormspots[rn].x, wormspots[rn].y);
g->z.push_back(worm);
wormspots.erase(wormspots.begin() + rn);
}
}
void mdeath::disappear(game *g, monster *z)
{
g->add_msg("The %s disappears! Was it in your head?", z->name().c_str());
}
void mdeath::guilt(game *g, monster *z)
{
if (g->u.has_trait(PF_HEARTLESS))
return; // We don't give a shit!
if (rl_dist(z->posx, z->posy, g->u.posx, g->u.posy) > 1)
return; // Too far away, we can deal with it
g->add_msg("You feel terrible for killing %s!", z->name().c_str());
g->u.add_morale(MORALE_KILLED_MONSTER, -50, -250);
}
void mdeath::blobsplit(game *g, monster *z)
{
int j;
int speed = z->speed - rng(30, 50);
if (speed <= 0) {
if (g->u_see(z, j))
g->add_msg("The %s splatters into tiny, dead pieces.", z->name().c_str());
return;
}
monster blob(g->mtypes[(speed < 50 ? mon_blob_small : mon_blob)]);
blob.speed = speed;
blob.friendly = z->friendly; // If we're tame, our kids are too
if (g->u_see(z, j))
g->add_msg("The %s splits!", z->name().c_str());
blob.hp = blob.speed;
std::vector <point> valid;
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
if (g->m.move_cost(z->posx+i, z->posy+j) > 0 &&
g->mon_at(z->posx+i, z->posy+j) == -1 &&
(g->u.posx != z->posx+i || g->u.posy != z->posy + j))
valid.push_back(point(z->posx+i, z->posy+j));
}
}
int rn;
for (int s = 0; s < 2 && valid.size() > 0; s++) {
rn = rng(0, valid.size() - 1);
blob.spawn(valid[rn].x, valid[rn].y);
g->z.push_back(blob);
valid.erase(valid.begin() + rn);
}
}
void mdeath::melt(game *g, monster *z)
{
int j;
if (g->u_see(z, j))
g->add_msg("The %s melts away!", z->name().c_str());
}
void mdeath::amigara(game *g, monster *z)
{
if (g->u.has_disease(DI_AMIGARA)) {
int count = 0;
for (int i = 0; i < g->z.size(); i++) {
if (g->z[i].type->id == mon_amigara_horror)
count++;
}
if (count <= 1) { // We're the last!
g->u.rem_disease(DI_AMIGARA);
g->add_msg("Your obsession with the fault fades away...");
}
}
normal(g, z);
}
void mdeath::thing(game *g, monster *z)
{
monster thing(g->mtypes[mon_thing]);
thing.spawn(z->posx, z->posy);
g->z.push_back(thing);
}
void mdeath::explode(game *g, monster *z)
{
int size;
switch (z->type->size) {
case MS_TINY: size = 4; break;
case MS_SMALL: size = 8; break;
case MS_MEDIUM: size = 14; break;
case MS_LARGE: size = 20; break;
case MS_HUGE: size = 26; break;
}
g->explosion(z->posx, z->posy, size, 0, false);
}