-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVat.cpp
164 lines (152 loc) · 4.63 KB
/
Vat.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
/********************************
Quaffing from Vats
********************************/
#include "Global.h"
#include "Util.h"
#include "Object.h"
#include "Hero.h"
#include "Interface.h"
/* Produces random vats for matter compiler. */
shFeature *
shFeature::newVat ()
{
shFeature *vat = new shFeature ();
vat->mType = shFeature::kVat;
vat->mVat.mHealthy = RNG (-2, 2);
vat->mVat.mRadioactive = RNG (10) > 0;
vat->mVat.mAnalyzed = RNG (2);
return vat;
}
/* Creates random vats for hero to find on map. */
void
shMapLevel::addVat (int x, int y)
{
shFeature *vat = shFeature::newVat ();
vat->mX = x;
vat->mY = y;
/* Vats on map usually are unhealthy. */
if (RNG (7)) vat->mVat.mHealthy = 0;
vat->mVat.mAnalyzed = 0;
mFeatures.add (vat);
}
void
shHero::quaffFromVat (shFeature *vat)
{
assert (vat->mX == Hero.mX and vat->mY == Hero.mY);
int dryup = 3;
int result;
if (isInShop ()) {
quaffFromOwnedVat (vat);
}
if (vat->mVat.mHealthy <= -3) {
/* You need to pour some nasty stuff in to achieve this. */
result = -2;
} else if (vat->mVat.mRadioactive and !RNG (10 + vat->mVat.mHealthy)) {
result = -1;
} else if (RNG (2) < vat->mVat.mHealthy) {
/* Healthy vats are quite likely to give a good effect, and they're
the only way to get the gain ability effect. */
result = RNG (0, 6);
} else if (vat->mVat.mHealthy < 0) {
/* Extraordinarily unhealthy vats may poison. */
result = RNG (1, 10);
} else {
result = RNG (1, 9);
}
switch (result) {
case -2:
I->p ("Arrgghh!! You vomit.");
if (sufferDamage (kAttVatPlague)) {
shCreature::die (kKilled, "a filthy sludge vat");
}
vat->mVat.mAnalyzed = 1;
break;
case -1:
mRad += RNG (1, 100);
I->p ("Ick! That had a toxic taste!");
break;
case 0:
Hero.gainAbility (false, 1);
vat->mVat.mAnalyzed = 1;
break;
case 1:
if (vat->mVat.mRadioactive) {
getMutantPower ();
dryup = 2;
break;
} /* else fall through... */
case 2:
mRad -= RNG (1, 200);
mRad = maxi (0, mRad);
if (!mRad)
I->p ("You feel purified!");
else
I->p ("You feel less contaminated.");
break;
case 3:
mHP += NDX (4, 6);
mHP = mini (mHP, mMaxHP);
I->p ("You feel better!");
break;
case 4:
{
int amt = RNG (1, 6);
Hero.mPsiDrain -= amt;
Hero.mAbil.mPsi += amt;
I->p ("You feel invigorated!");
break;
}
case 5:
I->p ("Mmmm... bouncy bubbly beverage!");
if (Hero.getStoryFlag ("impregnation")) {
abortion (1); /* Here message given is slightly different. */
I->p ("You feel the alien embryo inside you die.");
}
break;
case 6:
I->p ("Mmmm... hot fun!");
if (Hero.needsRestoration ())
Hero.restoration (RNG (2) + mini (3, vat->mVat.mHealthy));
break;
case 7:
I->p ("Oops! You fall in! You are covered in slime!");
damageEquipment (kAttVatCorrosion, kCorrosive);
I->p ("You climb out of the vat.");
break;
case 8:
{
int x = mX;
int y = mY;
shMonster *monster = new shMonster (kMonVatSlime);
if (0 != Level->findNearbyUnoccupiedSquare (&x, &y) or
0 != Level->putCreature (monster, x, y))
{
I->p ("The sludge gurgles!");
} else {
I->p ("It's alive!");
}
break;
}
case 9:
I->p ("You are jolted by an electric shock!");
if (sufferDamage (kAttVatShock)) {
shCreature::die (kKilled, "an improperly grounded sludge vat");
}
dryup = 2;
break;
case 10:
I->p ("This stuff is poisonous!");
Hero.abortion ();
if (sufferDamage (kAttVatPoison)) {
shCreature::die (kKilled, "drinking some unhealthy sludge");
}
dryup = 2;
vat->mVat.mAnalyzed = 1;
break;
}
if (!RNG (dryup)) {
I->p ("The vat dries up!");
Level->forgetFeature (vat->mX, vat->mY);
Level->removeFeature (vat);
}
}