forked from Davidslv/rogue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
daemons.c
288 lines (263 loc) · 5 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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/*
* All the daemon and fuse functions are in here
*
* @(#)daemons.c 4.24 (Berkeley) 02/05/99
*
* Rogue: Exploring the Dungeons of Doom
* Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman
* All rights reserved.
*
* See the file LICENSE.TXT for full copyright and licensing information.
*/
#include <curses.h>
#include "rogue.h"
/*
* doctor:
* A healing daemon that restors hit points after rest
*/
void
doctor()
{
register int lv, ohp;
lv = pstats.s_lvl;
ohp = pstats.s_hpt;
quiet++;
if (lv < 8)
{
if (quiet + (lv << 1) > 20)
pstats.s_hpt++;
}
else
if (quiet >= 3)
pstats.s_hpt += rnd(lv - 7) + 1;
if (ISRING(LEFT, R_REGEN))
pstats.s_hpt++;
if (ISRING(RIGHT, R_REGEN))
pstats.s_hpt++;
if (ohp != pstats.s_hpt)
{
if (pstats.s_hpt > max_hp)
pstats.s_hpt = max_hp;
quiet = 0;
}
}
/*
* Swander:
* Called when it is time to start rolling for wandering monsters
*/
void
swander()
{
start_daemon(rollwand, 0, BEFORE);
}
/*
* rollwand:
* Called to roll to see if a wandering monster starts up
*/
int between = 0;
void
rollwand()
{
if (++between >= 4)
{
if (roll(1, 6) == 4)
{
wanderer();
kill_daemon(rollwand);
fuse(swander, 0, WANDERTIME, BEFORE);
}
between = 0;
}
}
/*
* unconfuse:
* Release the poor player from his confusion
*/
void
unconfuse()
{
player.t_flags &= ~ISHUH;
msg("Shaı %s súq da.", choose_str("saıbıao", "bıao"));
}
/*
* unsee:
* Turn off the ability to see invisible
*/
void
unsee()
{
register THING *th;
for (th = mlist; th != NULL; th = next(th))
if (on(*th, ISINVIS) && see_monst(th))
mvaddch(th->t_pos.y, th->t_pos.x, th->t_oldch);
player.t_flags &= ~CANSEE;
}
/*
* sight:
* He gets his sight back
*/
void
sight()
{
if (on(player, ISBLIND))
{
extinguish(sight);
player.t_flags &= ~ISBLIND;
if (!(proom->r_flags & ISGONE))
enter_room(&hero);
msg(choose_str("Obe! Rıu ruajua tú raı da.",
"Rıu deq kaqgaı súq da."));
}
}
/*
* nohaste:
* End the hasting
*/
void
nohaste()
{
player.t_flags &= ~ISHASTE;
msg("Gaı súq, ꝡä dıa deq suaı súq da.");
}
/*
* stomach:
* Digest the hero's food
*/
void
stomach()
{
register int oldfood;
int orig_hungry = hungry_state;
if (food_left <= 0)
{
if (food_left-- < -STARVETIME)
death('s');
/*
* the hero is fainting
*/
if (no_command || rnd(5) != 0)
return;
no_command += rnd(8) + 4;
hungry_state = 3;
if (!terse)
addmsg("Chuqkuaı súq câbıaq, ꝡä rue túaı suqbo da. ");
msg("Sho sısıa súq da.");
}
else
{
oldfood = food_left;
food_left -= ring_eat(LEFT) + ring_eat(RIGHT) + 1 - amulet;
if (food_left < MORETIME && oldfood >= MORETIME)
{
hungry_state = 2;
msg("Chum ceo tuaırue súq da.");
}
else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME)
{
hungry_state = 1;
msg("Chum ceo chuqkuaı súq da.");
}
}
if (hungry_state != orig_hungry) {
player.t_flags &= ~ISRUN;
running = FALSE;
to_death = FALSE;
count = 0;
}
}
/*
* come_down:
* Take the hero down off her acid trip.
*/
void
come_down()
{
register THING *tp;
register bool seemonst;
if (!on(player, ISHALU))
return;
kill_daemon(visuals);
player.t_flags &= ~ISHALU;
if (on(player, ISBLIND))
return;
/*
* undo the things
*/
for (tp = lvl_obj; tp != NULL; tp = next(tp))
if (cansee(tp->o_pos.y, tp->o_pos.x))
mvaddch(tp->o_pos.y, tp->o_pos.x, tp->o_type);
/*
* undo the monsters
*/
seemonst = on(player, SEEMONST);
for (tp = mlist; tp != NULL; tp = next(tp))
{
move(tp->t_pos.y, tp->t_pos.x);
if (cansee(tp->t_pos.y, tp->t_pos.x))
if (!on(*tp, ISINVIS) || on(player, CANSEE))
addch(tp->t_disguise);
else
addch(chat(tp->t_pos.y, tp->t_pos.x));
else if (seemonst)
{
standout();
addch(tp->t_type);
standend();
}
}
msg("Rıu *jaqbeı* foıca tú kaqge da.");
}
/*
* visuals:
* change the characters for the player
*/
void
visuals()
{
register THING *tp;
register bool seemonst;
if (!after || (running && jump))
return;
/*
* change the things
*/
for (tp = lvl_obj; tp != NULL; tp = next(tp))
if (cansee(tp->o_pos.y, tp->o_pos.x))
mvaddch(tp->o_pos.y, tp->o_pos.x, rnd_thing());
/*
* change the stairs
*/
if (!seenstairs && cansee(stairs.y, stairs.x))
mvaddch(stairs.y, stairs.x, rnd_thing());
/*
* change the monsters
*/
seemonst = on(player, SEEMONST);
for (tp = mlist; tp != NULL; tp = next(tp))
{
move(tp->t_pos.y, tp->t_pos.x);
if (see_monst(tp))
{
if (tp->t_type == 'X' && tp->t_disguise != 'X')
addch(rnd_thing());
else
addch(rnd(26) + 'A');
}
else if (seemonst)
{
standout();
addch(rnd(26) + 'A');
standend();
}
}
}
/*
* land:
* Land from a levitation potion
*/
void
land()
{
player.t_flags &= ~ISLEVIT;
msg("Nhea shua súq déaq da.");
}