Mercurial > hg > early-roguelike
comparison arogue5/potions.c @ 63:0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
author | elwin |
---|---|
date | Thu, 09 Aug 2012 22:58:48 +0000 |
parents | |
children | c49f7927b0fa |
comparison
equal
deleted
inserted
replaced
62:0ef99244acb8 | 63:0ed67132cf10 |
---|---|
1 /* | |
2 * Function(s) for dealing with potions | |
3 * | |
4 * Advanced Rogue | |
5 * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T | |
6 * All rights reserved. | |
7 * | |
8 * Based on "Rogue: Exploring the Dungeons of Doom" | |
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
10 * All rights reserved. | |
11 * | |
12 * See the file LICENSE.TXT for full copyright and licensing information. | |
13 */ | |
14 | |
15 #include "curses.h" | |
16 #include "rogue.h" | |
17 | |
18 | |
19 | |
20 /* | |
21 * Increase player's constitution | |
22 */ | |
23 | |
24 add_const(cursed) | |
25 bool cursed; | |
26 { | |
27 /* Do the potion */ | |
28 if (cursed) { | |
29 msg("You feel less healthy now."); | |
30 pstats.s_const--; | |
31 if (pstats.s_const <= 0) | |
32 death(D_CONSTITUTION); | |
33 } | |
34 else { | |
35 msg("You feel healthier now."); | |
36 pstats.s_const = min(pstats.s_const + 1, 25); | |
37 } | |
38 | |
39 /* Adjust the maximum */ | |
40 if (max_stats.s_const < pstats.s_const) | |
41 max_stats.s_const = pstats.s_const; | |
42 } | |
43 | |
44 /* | |
45 * Increase player's dexterity | |
46 */ | |
47 | |
48 add_dexterity(cursed) | |
49 bool cursed; | |
50 { | |
51 int ring_str; /* Value of ring strengths */ | |
52 | |
53 /* Undo any ring changes */ | |
54 ring_str = ring_value(R_ADDHIT); | |
55 pstats.s_dext -= ring_str; | |
56 | |
57 /* Now do the potion */ | |
58 if (cursed) { | |
59 msg("You feel less dextrous now."); | |
60 pstats.s_dext--; | |
61 } | |
62 else { | |
63 msg("You feel more dextrous now. Watch those hands!"); | |
64 pstats.s_dext = min(pstats.s_dext + 1, 25); | |
65 } | |
66 | |
67 /* Adjust the maximum */ | |
68 if (max_stats.s_dext < pstats.s_dext) | |
69 max_stats.s_dext = pstats.s_dext; | |
70 | |
71 /* Now put back the ring changes */ | |
72 if (ring_str) | |
73 pstats.s_dext += ring_str; | |
74 } | |
75 | |
76 /* | |
77 * add_haste: | |
78 * add a haste to the player | |
79 */ | |
80 | |
81 add_haste(blessed) | |
82 bool blessed; | |
83 { | |
84 int hasttime; | |
85 | |
86 if (blessed) hasttime = HASTETIME*2; | |
87 else hasttime = HASTETIME; | |
88 | |
89 if (on(player, ISSLOW)) { /* Is person slow? */ | |
90 extinguish(noslow); | |
91 noslow(); | |
92 | |
93 if (blessed) hasttime = HASTETIME/2; | |
94 else return; | |
95 } | |
96 | |
97 if (on(player, ISHASTE)) { | |
98 msg("You faint from exhaustion."); | |
99 no_command += rnd(hasttime); | |
100 lengthen(nohaste, roll(hasttime,hasttime)); | |
101 } | |
102 else { | |
103 turn_on(player, ISHASTE); | |
104 fuse(nohaste, 0, roll(hasttime, hasttime), AFTER); | |
105 } | |
106 } | |
107 | |
108 /* | |
109 * Increase player's intelligence | |
110 */ | |
111 add_intelligence(cursed) | |
112 bool cursed; | |
113 { | |
114 int ring_str; /* Value of ring strengths */ | |
115 | |
116 /* Undo any ring changes */ | |
117 ring_str = ring_value(R_ADDINTEL); | |
118 pstats.s_intel -= ring_str; | |
119 | |
120 /* Now do the potion */ | |
121 if (cursed) { | |
122 msg("You feel slightly less intelligent now."); | |
123 pstats.s_intel--; | |
124 } | |
125 else { | |
126 msg("You feel more intelligent now. What a mind!"); | |
127 pstats.s_intel = min(pstats.s_intel + 1, 25); | |
128 } | |
129 | |
130 /* Adjust the maximum */ | |
131 if (max_stats.s_intel < pstats.s_intel) | |
132 max_stats.s_intel = pstats.s_intel; | |
133 | |
134 /* Now put back the ring changes */ | |
135 if (ring_str) | |
136 pstats.s_intel += ring_str; | |
137 } | |
138 | |
139 /* | |
140 * this routine makes the hero move slower | |
141 */ | |
142 add_slow() | |
143 { | |
144 if (on(player, ISHASTE)) { /* Already sped up */ | |
145 extinguish(nohaste); | |
146 nohaste(); | |
147 } | |
148 else { | |
149 msg("You feel yourself moving %sslower.", | |
150 on(player, ISSLOW) ? "even " : ""); | |
151 if (on(player, ISSLOW)) | |
152 lengthen(noslow, roll(HASTETIME,HASTETIME)); | |
153 else { | |
154 turn_on(player, ISSLOW); | |
155 player.t_turn = TRUE; | |
156 fuse(noslow, 0, roll(HASTETIME,HASTETIME), AFTER); | |
157 } | |
158 } | |
159 } | |
160 | |
161 /* | |
162 * Increase player's strength | |
163 */ | |
164 | |
165 add_strength(cursed) | |
166 bool cursed; | |
167 { | |
168 | |
169 if (cursed) { | |
170 msg("You feel slightly weaker now."); | |
171 chg_str(-1); | |
172 } | |
173 else { | |
174 msg("You feel stronger now. What bulging muscles!"); | |
175 chg_str(1); | |
176 } | |
177 } | |
178 | |
179 /* | |
180 * Increase player's wisdom | |
181 */ | |
182 | |
183 add_wisdom(cursed) | |
184 bool cursed; | |
185 { | |
186 int ring_str; /* Value of ring strengths */ | |
187 | |
188 /* Undo any ring changes */ | |
189 ring_str = ring_value(R_ADDWISDOM); | |
190 pstats.s_wisdom -= ring_str; | |
191 | |
192 /* Now do the potion */ | |
193 if (cursed) { | |
194 msg("You feel slightly less wise now."); | |
195 pstats.s_wisdom--; | |
196 } | |
197 else { | |
198 msg("You feel wiser now. What a sage!"); | |
199 pstats.s_wisdom = min(pstats.s_wisdom + 1, 25); | |
200 } | |
201 | |
202 /* Adjust the maximum */ | |
203 if (max_stats.s_wisdom < pstats.s_wisdom) | |
204 max_stats.s_wisdom = pstats.s_wisdom; | |
205 | |
206 /* Now put back the ring changes */ | |
207 if (ring_str) | |
208 pstats.s_wisdom += ring_str; | |
209 } | |
210 | |
211 | |
212 /* | |
213 * Lower a level of experience | |
214 */ | |
215 | |
216 lower_level(who) | |
217 short who; | |
218 { | |
219 int fewer, nsides = 0; | |
220 | |
221 if (--pstats.s_lvl == 0) | |
222 death(who); /* All levels gone */ | |
223 msg("You suddenly feel less skillful."); | |
224 pstats.s_exp /= 2; | |
225 switch (player.t_ctype) { | |
226 case C_FIGHTER: nsides = HIT_FIGHTER; | |
227 when C_MAGICIAN:nsides = HIT_MAGICIAN; | |
228 when C_CLERIC: nsides = HIT_CLERIC; | |
229 when C_THIEF: nsides = HIT_THIEF; | |
230 } | |
231 fewer = max(1, roll(1,nsides) + const_bonus()); | |
232 pstats.s_hpt -= fewer; | |
233 max_stats.s_hpt -= fewer; | |
234 if (pstats.s_hpt < 1) | |
235 pstats.s_hpt = 1; | |
236 if (max_stats.s_hpt < 1) | |
237 death(who); | |
238 } | |
239 | |
240 quaff(which, flag, is_potion) | |
241 int which; | |
242 int flag; | |
243 bool is_potion; | |
244 { | |
245 register struct object *obj = NULL; | |
246 register struct linked_list *item, *titem; | |
247 register struct thing *th; | |
248 bool cursed, blessed; | |
249 char buf[LINELEN]; | |
250 | |
251 blessed = FALSE; | |
252 cursed = FALSE; | |
253 item = NULL; | |
254 | |
255 if (which < 0) { /* figure out which ourselves */ | |
256 item = get_item(pack, "quaff", POTION); | |
257 /* | |
258 * Make certain that it is somethings that we want to drink | |
259 */ | |
260 if (item == NULL) | |
261 return; | |
262 | |
263 obj = OBJPTR(item); | |
264 /* remove it from the pack */ | |
265 inpack--; | |
266 detach(pack, item); | |
267 | |
268 /* | |
269 * Calculate the effect it has on the poor guy. | |
270 */ | |
271 cursed = (obj->o_flags & ISCURSED) != 0; | |
272 blessed = (obj->o_flags & ISBLESSED) != 0; | |
273 | |
274 which = obj->o_which; | |
275 } | |
276 else { | |
277 cursed = flag & ISCURSED; | |
278 blessed = flag & ISBLESSED; | |
279 } | |
280 | |
281 switch(which) | |
282 { | |
283 case P_CLEAR: | |
284 if (cursed) { | |
285 if (off(player, ISCLEAR)) | |
286 { | |
287 msg("Wait, what's going on here. Huh? What? Who?"); | |
288 if (find_slot(unconfuse)) | |
289 lengthen(unconfuse, rnd(8)+HUHDURATION); | |
290 else | |
291 fuse(unconfuse, 0, rnd(8)+HUHDURATION, AFTER); | |
292 turn_on(player, ISHUH); | |
293 } | |
294 else msg("You feel dizzy for a moment, but it quickly passes."); | |
295 } | |
296 else { | |
297 if (blessed) { /* Make player immune for the whole game */ | |
298 extinguish(unclrhead); /* If we have a fuse, put it out */ | |
299 msg("A strong blue aura surrounds your head."); | |
300 } | |
301 else { /* Just light a fuse for how long player is safe */ | |
302 if (off(player, ISCLEAR)) { | |
303 fuse(unclrhead, 0, CLRDURATION, AFTER); | |
304 msg("A faint blue aura surrounds your head."); | |
305 } | |
306 else { /* If we have a fuse lengthen it, else we | |
307 * are permanently clear. | |
308 */ | |
309 if (find_slot(unclrhead) == FALSE) | |
310 msg("Your blue aura continues to glow strongly."); | |
311 else { | |
312 lengthen(unclrhead, CLRDURATION); | |
313 msg("Your blue aura brightens for a moment."); | |
314 } | |
315 } | |
316 } | |
317 turn_on(player, ISCLEAR); | |
318 /* If player is confused, unconfuse him */ | |
319 if (on(player, ISHUH)) { | |
320 extinguish(unconfuse); | |
321 unconfuse(); | |
322 } | |
323 } | |
324 when P_HEALING: | |
325 if (cursed) { | |
326 if (!save(VS_POISON, &player, 0)) { | |
327 msg("You feel very sick now."); | |
328 pstats.s_hpt /= 2; | |
329 pstats.s_const--; | |
330 if (pstats.s_const <= 0 || pstats.s_hpt <= 0) | |
331 death(D_POISON); | |
332 } | |
333 else msg("You feel momentarily sick."); | |
334 } | |
335 else { | |
336 if (blessed) { | |
337 if ((pstats.s_hpt += roll(pstats.s_lvl, 8)) > max_stats.s_hpt) | |
338 pstats.s_hpt = ++max_stats.s_hpt; | |
339 if (on(player, ISHUH)) { | |
340 extinguish(unconfuse); | |
341 unconfuse(); | |
342 } | |
343 } | |
344 else { | |
345 if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_stats.s_hpt) | |
346 pstats.s_hpt = ++max_stats.s_hpt; | |
347 } | |
348 msg("You begin to feel %sbetter.", | |
349 blessed ? "much " : ""); | |
350 sight(); | |
351 if (is_potion) p_know[P_HEALING] = TRUE; | |
352 } | |
353 when P_ABIL: | |
354 { | |
355 int ctype; | |
356 | |
357 /* | |
358 * if blessed then fix all attributes | |
359 */ | |
360 if (blessed) { | |
361 add_intelligence(FALSE); | |
362 add_dexterity(FALSE); | |
363 add_strength(FALSE); | |
364 add_wisdom(FALSE); | |
365 add_const(FALSE); | |
366 } | |
367 /* probably will be own ability */ | |
368 else { | |
369 if (rnd(100) < 70) | |
370 ctype = player.t_ctype; | |
371 else do { | |
372 ctype = rnd(4); | |
373 } while (ctype == player.t_ctype); | |
374 | |
375 /* Small chance of doing constitution instead */ | |
376 if (rnd(100) < 10) | |
377 add_const(cursed); | |
378 else switch (ctype) { | |
379 case C_FIGHTER: add_strength(cursed); | |
380 when C_MAGICIAN: add_intelligence(cursed); | |
381 when C_CLERIC: add_wisdom(cursed); | |
382 when C_THIEF: add_dexterity(cursed); | |
383 otherwise: msg("You're a strange type!"); | |