-
Notifications
You must be signed in to change notification settings - Fork 1
/
daemons.c
254 lines (230 loc) · 4.2 KB
/
daemons.c
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/*
* All the daemon and fuse functions are in here
*
* @(#)daemons.c 9.0 (rdk) 7/17/84
*
* Super-Rogue
* Copyright (C) 1984 Robert D. Kindelberger
* All rights reserved.
*
* Based on "Rogue: Exploring the Dungeons of Doom"
* Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
* All rights reserved.
*
* See the file LICENSE.TXT for full copyright and licensing information.
*/
#include "rogue.h"
#include "rogue.ext"
int between = 0;
/*
* doctor:
* A healing daemon that restores hit points after rest
*/
doctor(fromfuse)
int fromfuse;
{
reg int *thp, lv, ohp, ccon;
lv = him->s_lvl;
thp = &him->s_hpt;
ohp = *thp;
quiet += 1;
ccon = him->s_ef.a_con;
if (ccon > 16 && !isfight)
*thp += rnd(ccon - 15);
if (lv < 8) {
if (quiet > 20 - lv * 2)
*thp += 1;
}
else {
if (quiet >= 3)
*thp += rnd(lv - 7) + 1;
}
if (isring(LEFT, R_REGEN))
*thp += 1;
if (isring(RIGHT, R_REGEN))
*thp += 1;
if (pl_on(ISREGEN))
*thp += 1;
if (ohp != *thp) {
nochange = FALSE;
if (*thp > him->s_maxhp)
*thp = him->s_maxhp;
quiet = 0;
}
}
/*
* Swander:
* Called when it is time to start rolling for wandering monsters
*/
swander(fromfuse)
int fromfuse;
{
daemon(rollwand, TRUE, BEFORE);
}
/*
* rollwand:
* Called to roll to see if a wandering monster starts up
*/
rollwand(fromfuse)
int fromfuse;
{
if (++between >= 4) {
if (roll(1, 6) == 4) {
if (levtype != POSTLEV) /* no monsters for posts */
wanderer();
extinguish(rollwand);
fuse(swander, TRUE, WANDERTIME);
}
between = 0;
}
}
/*
* unconfuse:
* Release the poor player from his confusion
*/
unconfuse(fromfuse)
int fromfuse;
{
if (pl_on(ISHUH))
msg("You feel less confused now.");
player.t_flags &= ~ISHUH;
}
/*
* unsee:
* He lost his see invisible power
*/
unsee(fromfuse)
int fromfuse;
{
player.t_flags &= ~CANSEE;
}
/*
* sight:
* He gets his sight back
*/
sight(fromfuse)
int fromfuse;
{
if (pl_on(ISBLIND))
msg("The veil of darkness lifts.");
player.t_flags &= ~ISBLIND;
light(&hero);
}
/*
* nohaste:
* End the hasting
*/
nohaste(fromfuse)
int fromfuse;
{
if (pl_on(ISHASTE))
msg("You feel yourself slowing down.");
player.t_flags &= ~ISHASTE;
}
/*
* stomach:
* Digest the hero's food
*/
stomach(fromfuse)
int fromfuse;
{
reg int oldfood, old_hunger;
old_hunger = hungry_state;
if (food_left <= 0) { /* the hero is fainting */
if (--food_left == -150) {
msg("Your stomach writhes with hunger pains.");
}
else if (food_left < -350) {
msg("You starve to death !!");
msg(" ");
death(K_STARVE);
}
if (player.t_nocmd > 0 || rnd(100) > 20)
return;
player.t_nocmd = rnd(8)+4;
msg("You faint.");
running = FALSE;
count = 0;
hungry_state = F_FAINT;
}
else {
oldfood = food_left;
food_left -= ringfood + foodlev - amulet;
if (player.t_nocmd > 0) /* wait till he can move */
return;
if (food_left < WEAKTIME && oldfood >= WEAKTIME) {
msg("You are starting to feel weak.");
hungry_state = F_WEAK;
}
else if(food_left < HUNGTIME && oldfood >= HUNGTIME) {
msg("Getting hungry.");
hungry_state = F_HUNGRY;
}
}
if (old_hunger != hungry_state)
updpack(); /* new pack weight */
wghtchk(FALSE);
}
/*
* noteth:
* Hero is no longer etherereal
*/
noteth(fromfuse)
int fromfuse;
{
int ch;
if (pl_on(ISETHER)) {
msg("You begin to feel more corporeal.");
ch = player.t_oldch;
if (dead_end(ch)) {
msg("You materialize in %s.",identify(ch));
msg(" ");
death(K_STONE); /* can't materialize in walls */
}
}
player.t_flags &= ~ISETHER;
}
/*
* sapem:
* Sap the hero's life away
*/
sapem(fromfuse)
int fromfuse;
{
chg_abil(rnd(4) + 1, -1, TRUE);
fuse(sapem, TRUE, 150);
nochange = FALSE;
}
/*
* notslow:
* Restore the hero's normal speed
*/
notslow(fromfuse)
int fromfuse;
{
if (pl_on(ISSLOW))
msg("You no longer feel hindered.");
player.t_flags &= ~ISSLOW;
}
/*
* notregen:
* Hero is no longer regenerative
*/
notregen(fromfuse)
int fromfuse;
{
if (pl_on(ISREGEN))
msg("You no longer feel bolstered.");
player.t_flags &= ~ISREGEN;
}
/*
* notinvinc:
* Hero not invincible any more
*/
notinvinc(fromfuse)
int fromfuse;
{
if (pl_on(ISINVINC))
msg("You no longer feel invincible.");
player.t_flags &= ~ISINVINC;
}