Mercurial > hg > early-roguelike
comparison xrogue/potions.c @ 133:e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
author | John "Elwin" Edwards |
---|---|
date | Tue, 21 Apr 2015 08:55:20 -0400 |
parents | |
children | ce0cf824c192 |
comparison
equal
deleted
inserted
replaced
124:d10fc4a065ac | 133:e6179860cb76 |
---|---|
1 /* | |
2 potions.c - Functions for dealing with potions | |
3 | |
4 XRogue: Expeditions into the Dungeons of Doom | |
5 Copyright (C) 1991 Robert Pietkivitch | |
6 All rights reserved. | |
7 | |
8 Based on "Advanced Rogue" | |
9 Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T | |
10 All rights reserved. | |
11 | |
12 Based on "Rogue: Exploring the Dungeons of Doom" | |
13 Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
14 All rights reserved. | |
15 | |
16 See the file LICENSE.TXT for full copyright and licensing information. | |
17 */ | |
18 | |
19 #include <curses.h> | |
20 #include "rogue.h" | |
21 | |
22 /* | |
23 * add_abil is an array of functions used to change attributes. It must be | |
24 * ordered according to the attribute definitions in rogue.h. | |
25 */ | |
26 | |
27 int (*add_abil[NUMABILITIES])() = { | |
28 add_intelligence, add_strength, add_wisdom, add_dexterity, | |
29 add_constitution, add_charisma | |
30 }; | |
31 | |
32 /* | |
33 * res_abil is an array of functions used to change attributes. It must be | |
34 * ordered according to the attribute definitions in rogue.h. | |
35 */ | |
36 | |
37 int (*res_abil[NUMABILITIES])() = { | |
38 res_intelligence, res_strength, res_wisdom, res_dexterity, | |
39 res_constitution, res_charisma | |
40 }; | |
41 | |
42 /* | |
43 * Increase player's constitution | |
44 */ | |
45 | |
46 int | |
47 add_constitution(change) | |
48 int change; | |
49 { | |
50 /* Do the potion */ | |
51 if (change < 0) { | |
52 msg("You feel less healthy now."); | |
53 pstats.s_const += change; | |
54 if (pstats.s_const < 1) { | |
55 pstats.s_hpt = -1; | |
56 msg("You collapse! --More--"); | |
57 wait_for(' '); | |
58 death(D_CONSTITUTION); | |
59 } | |
60 } | |
61 else { | |
62 msg("You feel healthier now."); | |
63 pstats.s_const = min(pstats.s_const + change, MAXATT); | |
64 } | |
65 | |
66 /* Adjust the maximum */ | |
67 if (max_stats.s_const < pstats.s_const) | |
68 max_stats.s_const = pstats.s_const; | |
69 | |
70 return(0); | |
71 } | |
72 | |
73 /* | |
74 * Increase player's charisma | |
75 */ | |
76 | |
77 int | |
78 add_charisma(change) | |
79 int change; | |
80 { | |
81 /* Do the potion */ | |
82 if (change < 0) msg("You feel less attractive now."); | |
83 else msg("You feel more attractive now."); | |
84 | |
85 pstats.s_charisma += change; | |
86 if (pstats.s_charisma > MAXATT) pstats.s_charisma = MAXATT; | |
87 else if (pstats.s_charisma < 3) pstats.s_charisma = 3; | |
88 | |
89 /* Adjust the maximum */ | |
90 if (max_stats.s_charisma < pstats.s_charisma) | |
91 max_stats.s_charisma = pstats.s_charisma; | |
92 | |
93 return(0); | |
94 } | |
95 | |
96 /* | |
97 * Increase player's dexterity | |
98 */ | |
99 | |
100 int | |
101 add_dexterity(change) | |
102 int change; | |
103 { | |
104 int ring_str; /* Value of ring strengths */ | |
105 | |
106 /* Undo any ring changes */ | |
107 ring_str = ring_value(R_ADDHIT); | |
108 pstats.s_dext -= ring_str; | |
109 | |
110 /* Now do the potion */ | |
111 if (change < 0) msg("You feel less dextrous now."); | |
112 else msg("You feel more dextrous now. Watch those hands!"); | |
113 | |
114 pstats.s_dext += change; | |
115 if (pstats.s_dext > MAXATT) pstats.s_dext = MAXATT; | |
116 else if (pstats.s_dext < 3) pstats.s_dext = 3; | |
117 | |
118 /* Adjust the maximum */ | |
119 if (max_stats.s_dext < pstats.s_dext) | |
120 max_stats.s_dext = pstats.s_dext; | |
121 | |
122 /* Now put back the ring changes */ | |
123 if (ring_str) | |
124 pstats.s_dext += ring_str; | |
125 | |
126 return(0); | |
127 } | |
128 | |
129 /* | |
130 * add_haste: | |
131 * add a haste to the player | |
132 */ | |
133 | |
134 add_haste(blessed) | |
135 bool blessed; | |
136 { | |
137 int hasttime; | |
138 | |
139 if (player.t_ctype == C_MONK) { /* monks cannot be slowed or hasted */ | |
140 msg(nothing); | |
141 return; | |
142 } | |
143 | |
144 if (blessed) hasttime = HASTETIME*2; | |
145 else hasttime = HASTETIME; | |
146 | |
147 if (on(player, ISSLOW)) { /* Is person slow? */ | |
148 extinguish(noslow); | |
149 noslow(); | |
150 | |
151 if (blessed) hasttime = HASTETIME/2; | |
152 else return; | |
153 } | |
154 | |
155 if (on(player, ISHASTE)) { | |
156 msg("You faint from exhaustion."); | |
157 player.t_no_move += movement(&player) * rnd(hasttime); | |
158 player.t_action = A_FREEZE; | |
159 lengthen(nohaste, roll(hasttime,hasttime)); | |
160 } | |
161 else { | |
162 msg("You feel yourself moving %sfaster.", blessed ? "much " : ""); | |
163 turn_on(player, ISHASTE); | |
164 fuse(nohaste, (VOID *)NULL, roll(hasttime, hasttime), AFTER); | |
165 } | |
166 } | |
167 | |
168 /* | |
169 * Increase player's intelligence | |
170 */ | |
171 | |
172 int | |
173 add_intelligence(change) | |
174 int change; | |
175 { | |
176 int ring_str; /* Value of ring strengths */ | |
177 | |
178 /* Undo any ring changes */ | |
179 ring_str = ring_value(R_ADDINTEL); | |
180 pstats.s_intel -= ring_str; | |
181 | |
182 /* Now do the potion */ | |
183 if (change < 0) msg("You feel slightly less intelligent now."); | |
184 else msg("You feel more intelligent now. What a mind!"); | |
185 | |
186 pstats.s_intel += change; | |
187 if (pstats.s_intel > MAXATT) pstats.s_intel = MAXATT; | |
188 else if (pstats.s_intel < 3) pstats.s_intel = 3; | |
189 | |
190 /* Adjust the maximum */ | |
191 if (max_stats.s_intel < pstats.s_intel) | |
192 max_stats.s_intel = pstats.s_intel; | |
193 | |
194 /* Now put back the ring changes */ | |
195 if (ring_str) | |
196 pstats.s_intel += ring_str; | |
197 | |
198 return(0); | |
199 } | |
200 | |
201 /* | |
202 * this routine makes the hero move slower | |
203 */ | |
204 | |
205 add_slow() | |
206 { | |
207 /* monks cannot be slowed or hasted */ | |
208 if (player.t_ctype == C_MONK || ISWEARING(R_FREEDOM)) { | |
209 msg(nothing); | |
210 return; | |
211 } | |
212 | |
213 if (on(player, ISHASTE)) { /* Already sped up */ | |
214 extinguish(nohaste); | |
215 nohaste(); | |
216 } | |
217 else { | |
218 msg("You feel yourself moving %sslower.", | |
219 on(player, ISSLOW) ? "even " : ""); | |
220 if (on(player, ISSLOW)) | |
221 lengthen(noslow, roll(HASTETIME,HASTETIME)); | |
222 else { | |
223 turn_on(player, ISSLOW); | |
224 fuse(noslow, (VOID *)NULL, roll(HASTETIME,HASTETIME), AFTER); | |
225 } | |
226 } | |
227 } | |
228 | |
229 /* | |
230 * Increase player's strength | |
231 */ | |
232 | |
233 int | |
234 add_strength(change) | |
235 int change; | |
236 { | |
237 | |
238 if (change < 0) { | |
239 msg("You feel slightly weaker now."); | |
240 chg_str(change); | |
241 } | |
242 else { | |
243 msg("You feel stronger now. What bulging muscles!"); | |
244 chg_str(change); | |
245 } | |
246 return(0); | |
247 } | |
248 | |
249 /* | |
250 * Increase player's wisdom | |
251 */ | |
252 | |
253 int | |
254 add_wisdom(change) | |
255 int change; | |
256 { | |
257 int ring_str; /* Value of ring strengths */ | |
258 | |
259 /* Undo any ring changes */ | |
260 ring_str = ring_value(R_ADDWISDOM); | |
261 pstats.s_wisdom -= ring_str; | |
262 | |
263 /* Now do the potion */ | |
264 if (change < 0) msg("You feel slightly less wise now."); | |
265 else msg("You feel wiser now. What a sage!"); | |
266 | |
267 pstats.s_wisdom += change; | |
268 if (pstats.s_wisdom > MAXATT) pstats.s_wisdom = MAXATT; | |
269 else if (pstats.s_wisdom < 3) pstats.s_wisdom = 3; | |
270 | |
271 /* Adjust the maximum */ | |
272 if (max_stats.s_wisdom < pstats.s_wisdom) | |
273 max_stats.s_wisdom = pstats.s_wisdom; | |
274 | |
275 /* Now put back the ring changes */ | |
276 if (ring_str) | |
277 pstats.s_wisdom += ring_str; | |
278 | |
279 return(0); | |
280 } | |
281 | |
282 quaff(which, kind, flags, is_potion) | |
283 int which; | |
284 int kind; | |
285 int flags; | |
286 bool is_potion; | |
287 { | |
288 register struct object *obj; | |
289 register struct linked_list *item, *titem; | |
290 register struct thing *th; | |
291 bool cursed, blessed; | |
292 | |
293 blessed = FALSE; | |
294 cursed = FALSE; | |
295 item = NULL; | |
296 | |
297 if (which < 0) { /* figure out which ourselves */ | |
298 /* This is a potion. */ | |
299 if (player.t_action != C_QUAFF) { | |
300 int units; | |
301 | |
302 item = get_item(pack, "quaff", QUAFFABLE, FALSE, FALSE); | |
303 | |
304 /* | |
305 * Make certain that it is somethings that we want to drink | |
306 */ | |
307 if (item == NULL) | |
308 return; | |
309 | |
310 /* How long does it take to quaff? */ | |
311 units = usage_time(item); | |
312 if (units < 0) return; | |
313 | |
314 player.t_using = item; /* Remember what it is */ | |
315 player.t_no_move = units * movement(&player); | |
316 if ((OBJPTR(item))->o_type == POTION) player.t_action = C_QUAFF; | |
317 else player.t_action = C_USE; | |
318 return; | |
319 } | |
320 | |
321 /* We have waited our time, let's quaff the potion */ | |
322 item = player.t_using; | |
323 player.t_using = NULL; | |
324 player.t_action = A_NIL; | |
325 | |
326 obj = OBJPTR(item); | |
327 /* remove it from the pack */ | |
328 inpack--; | |
329 detach(pack, item); | |
330 | |
331 flags = obj->o_flags; | |
332 which = obj->o_which; | |
333 kind = obj->o_kind; | |
334 } | |
335 cursed = flags & ISCURSED; | |
336 blessed = flags & ISBLESSED; | |
337 | |
338 switch(which) { | |
339 case P_CLEAR: | |
340 if (cursed) { | |
341 confus_player(); | |
342 } | |
343 else { | |
344 if (blessed) { /* Make player immune for the whole game */ | |
345 extinguish(unclrhead); /* If we have a fuse, put it out */ | |
346 msg("A strong blue aura surrounds your head."); | |
347 } | |
348 else { /* Just light a fuse for how long player is safe */ | |
349 if (off(player, ISCLEAR)) { | |
350 fuse(unclrhead, (VOID *)NULL, CLRDURATION, AFTER); | |
351 msg("A faint blue aura surrounds your head."); | |
352 } | |
353 else { /* If we have a fuse lengthen it, else we | |
354 * are permanently clear. | |
355 */ | |
356 if (find_slot(unclrhead) == 0) | |
357 msg("Your blue aura continues to glow strongly."); | |
358 else { | |
359 lengthen(unclrhead, CLRDURATION); | |
360 msg("Your blue aura brightens for a moment."); | |
361 } | |
362 } | |
363 } | |
364 turn_on(player, ISCLEAR); | |
365 /* If player is confused, unconfuse him */ | |
366 if (on(player, ISHUH)) { | |
367 extinguish(unconfuse); | |
368 unconfuse(); | |
369 } | |
370 } | |
371 when P_HEALING: | |
372 if (cursed) { | |
373 msg("You feel worse now."); | |
374 pstats.s_hpt -= roll(pstats.s_lvl, char_class[player.t_ctype].hit_pts); | |
375 if (pstats.s_hpt < 1) { | |
376 pstats.s_hpt = -1; | |
377 msg("You're life passes before your eyes.. --More--"); | |
378 wait_for(' '); | |
379 death(D_POTION); | |
380 } | |
381 } | |
382 else { | |
383 if (blessed) { | |
384 pstats.s_hpt += roll(pstats.s_lvl+1, char_class[player.t_ctype].hit_pts); | |
385 if (pstats.s_hpt > max_stats.s_hpt) { | |
386 pstats.s_hpt = ++max_stats.s_hpt; | |
387 pstats.s_hpt = ++max_stats.s_hpt; | |
388 } | |
389 if (on(player, ISHUH)) { | |
390 extinguish(unconfuse); | |
391 unconfuse(); | |
392 } | |
393 } | |
394 else { | |
395 pstats.s_hpt += roll(pstats.s_lvl+1, char_class[player.t_ctype].hit_pts/2); | |
396 if (pstats.s_hpt > max_stats.s_hpt) | |
397 pstats.s_hpt = ++max_stats.s_hpt; | |
398 } | |
399 msg("You begin to feel %sbetter.", | |
400 blessed ? "much " : ""); | |
401 sight(); | |
402 if (is_potion) p_know[P_HEALING] = TRUE; | |
403 } | |
404 when P_ABIL: | |
405 /* If it is cursed, we take a point away */ | |
406 if (cursed) { | |
407 if (ISWEARING(R_SUSABILITY)) { | |
408 msg(nothing); | |
409 break; | |
410 } | |
411 else (*add_abil[kind])(-1); | |
412 } | |
413 | |
414 /* Otherwise we add points */ | |
415 else (*add_abil[kind])(blessed ? 3 : 1); | |
416 | |
417 if (is_potion) p_know[P_ABIL] = TRUE; | |
418 when P_MFIND: | |
419 /* | |
420 * Potion of monster detection, if there are monters, detect them | |
421 */ | |
422 if (mlist != NULL) | |
423 { | |
424 register struct thing *tp; | |
425 register struct linked_list *item; | |
426 | |
427 wclear(hw); | |
428 for (item=mlist; item!=NULL; item=next(item)) { | |
429 tp = THINGPTR(item); | |
430 if (on(*tp, NODETECT)) | |
431 continue; | |
432 if (off(*tp, ISRUN))/* turn off only on sleeping ones */ | |
433 turn_off(*tp, CANSURPRISE); | |
434 mvwaddch(hw, tp->t_pos.y, tp->t_pos.x, | |
435 monsters[tp->t_index].m_appear); | |
436 } | |
437 rmmsg(); | |
438 overlay(hw,cw); | |
439 draw(cw); | |
440 msg("You begin to sense the presence of monsters."); | |
441 if (is_potion) p_know[P_MFIND] = TRUE; | |
442 } | |
443 else | |
444 msg("You have a strange feeling for a moment, then it passes."); | |
445 when P_TFIND: | |
446 /* | |
447 * Potion of magic detection. Show the potions and scrolls | |
448 */ | |
449 { | |
450 register struct linked_list *mobj; | |
451 register struct object *tp; | |
452 bool show; | |
453 | |
454 show = FALSE; | |
455 wclear(hw); | |
456 for (mobj = lvl_obj; mobj != NULL; mobj = next(mobj)) { | |
457 tp = OBJPTR(mobj); | |
458 if (is_magic(tp)) { | |
459 char mag_type=MAGIC; | |
460 | |
461 /* Mark cursed items or bad weapons */ | |
462 if ((tp->o_flags & ISCURSED) || | |
463 (tp->o_type == WEAPON && | |
464 (tp->o_hplus < 0 || tp->o_dplus < 0))) | |
465 mag_type = CMAGIC; | |
466 else if ((tp->o_flags & ISBLESSED) || | |
467 (tp->o_type == WEAPON && | |
468 (tp->o_hplus > 0 || tp->o_dplus > 0))) | |
469 mag_type = BMAGIC; | |
470 show = TRUE; | |
471 mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, mag_type); | |
472 } | |
473 } | |
474 for (titem = mlist; titem != NULL; titem = next(titem)) { | |
475 register struct linked_list *pitem; | |
476 | |
477 th = THINGPTR(titem); | |
478 if (on(*th, NODETECT)) continue; | |
479 for(pitem = th->t_pack; pitem != NULL; pitem = next(pitem)){ | |
480 tp = OBJPTR(pitem); | |
481 if (is_magic(tp)) { | |
482 char mag_type=MAGIC; | |
483 | |
484 /* Mark cursed items or bad weapons */ | |
485 if ((tp->o_flags & ISCURSED) || | |
486 (tp->o_type == WEAPON && | |
487 (tp->o_hplus < 0 || tp->o_dplus < 0))) | |
488 mag_type = CMAGIC; | |
489 else if ((tp->o_flags & ISBLESSED) || | |
490 (tp->o_type == WEAPON && | |
491 (tp->o_hplus > 0 || tp->o_dplus > 0))) | |
492 mag_type = BMAGIC; | |
493 show = TRUE; | |
494 mvwaddch(hw, th->t_pos.y, th->t_pos.x, mag_type); | |
495 } | |
496 } | |
497 } | |
498 if (show) { | |
499 if (is_potion) p_know[P_TFIND] = TRUE; | |
500 rmmsg(); | |
501 overlay(hw,cw); | |
502 draw(cw); | |
503 msg("You sense the presence of magic on this level."); | |
504 break; | |
505 } | |
506 else | |
507 msg("You have a strange feeling for a moment, then it passes."); | |
508 } | |
509 when P_SEEINVIS: | |
510 if (cursed) { | |
511 if (!find_slot(sight)) | |
512 { | |
513 msg("A cloak of darkness falls around you."); | |
514 turn_on(player, ISBLIND); | |
515 fuse(sight, (VOID *)NULL, SEEDURATION, AFTER); | |
516 light(&hero); | |
517 } | |
518 else | |
519 msg("The darkness around you thickens. "); | |
520 lengthen(sight, SEEDURATION); | |
521 } | |
522 else { | |
523 if (off(player, CANSEE)) { | |
524 turn_on(player, CANSEE); | |
525 msg("Your eyes begin to tingle."); | |
526 fuse(unsee, (VOID *)NULL, blessed ? SEEDURATION*3 :SEEDURATION, AFTER); | |
527 light(&hero); | |
528 } | |
529 else if (find_slot(unsee) != 0) { | |
530 msg("You eyes continue to tingle."); | |
531 lengthen(unsee, blessed ? SEEDURATION*3 : SEEDURATION); | |
532 } | |
533 sight(); | |
534 } | |
535 when P_PHASE: | |
536 if (cursed) { | |
537 msg("You can't move."); | |
538 player.t_no_move = movement(&player) * FREEZETIME; | |
539 player.t_action = A_FREEZE; | |
540 } | |
541 else { | |
542 int duration; | |
543 | |
544 if (blessed) duration = 3; | |
545 else duration = 1; | |
546 | |
547 if (on(player, CANINWALL)) | |
548 lengthen(unphase, duration*PHASEDURATION); | |
549 else { | |
550 fuse(unphase, (VOID *)NULL, duration*PHASEDURATION, AFTER); | |
551 turn_on(player, CANINWALL); | |
552 } | |
553 msg("You feel %slight-headed!", | |
554 blessed ? "very " : ""); | |
555 } | |
556 when P_FLY: { | |
557 int duration; | |
558 bool say_message; | |
559 | |
560 say_message = TRUE; | |
561 | |
562 if (blessed) duration = 3; | |
563 else duration = 1; | |
564 | |
565 if (on(player, ISFLY)) { | |
566 if (find_slot(land)) | |
567 lengthen(land, duration*FLYTIME); | |
568 else { | |
569 msg("Nothing happens."); /* Flying by cloak */ | |
570 say_message = FALSE; | |
571 } | |
572 } | |
573 else { | |
574 fuse(land, (VOID *)NULL, duration*FLYTIME, AFTER); | |
575 turn_on(player, ISFLY); | |
576 } | |
577 if (say_message) { | |
578 if (is_potion) p_know[P_FLY] = TRUE; | |
579 msg("You feel %slighter than air!", blessed ? "much " : ""); | |
580 } | |
581 } | |
582 when P_RAISE: | |
583 if (cursed) lower_level(D_POTION); | |
584 else { | |
585 msg("You suddenly feel %smore skillful", | |
586 blessed ? "much " : ""); | |
587 p_know[P_RAISE] = TRUE; | |
588 raise_level(); | |
589 do_panic(NULL); /* this startles them */ | |
590 if (blessed) raise_level(); | |
591 } | |
592 when P_HASTE: | |
593 if (cursed) { /* Slow player down */ | |
594 add_slow(); | |
595 } | |
596 else { | |
597 add_haste(blessed); | |
598 if (is_potion) p_know[P_HASTE] = TRUE; | |
599 } | |
600 when P_RESTORE: { | |
601 register int i, howmuch, strength_tally; | |
602 | |
603 msg("Hey, this tastes great. It make you feel %swarm all over.", | |
604 blessed ? "really " : ""); | |
605 howmuch = blessed ? 3 : 1; | |
606 | |
607 for (i=0; i<NUMABILITIES; i++) { | |
608 if (i == A_STRENGTH) { | |
609 if (lost_str) { | |
610 if (lost_str > howmuch) { | |
611 lost_str -= howmuch; | |
612 | |
613 /* | |
614 * Save the lost strength. We have to set | |
615 * temporarilty set it to 0 so that res_strength | |
616 * will not restore it. | |
617 */ | |
618 strength_tally = lost_str; | |
619 lost_str = 0; | |
620 res_strength(howmuch); | |
621 lost_str = strength_tally; | |
622 } | |
623 else { | |
624 lost_str = 0; | |
625 extinguish(res_strength); | |
626 res_strength(howmuch); | |
627 } | |
628 } | |
629 else res_strength(howmuch); | |
630 } | |
631 else (*res_abil[i])(howmuch); | |
632 } | |
633 } | |
634 when P_INVIS: | |
635 if (off(player, ISINVIS)) { | |
636 turn_on(player, ISINVIS); | |
637 msg("You have a tingling feeling all over your body"); | |
638 fuse(appear, (VOID *)NULL, blessed ? GONETIME*3 : GONETIME, AFTER); | |
639 PLAYER = IPLAYER; | |
640 light(&hero); | |
641 } | |
642 else { | |
643 if (find_slot(appear)) { | |
644 msg("Your tingling feeling surges."); | |
645 lengthen(appear, blessed ? GONETIME*3 : GONETIME); | |
646 } | |
647 else msg("Nothing happens."); /* Using cloak */ | |
648 } | |
649 | |
650 when P_FFIND: | |
651 { | |
652 register struct linked_list *nitem; | |
653 register struct object *nobj; | |
654 bool show; | |
655 | |
656 show = FALSE; | |
657 wclear(hw); | |
658 for (nitem = lvl_obj; nitem != NULL; nitem = next(nitem)) { | |
659 nobj = OBJPTR(nitem); | |
660 if (nobj->o_type == FOOD) { | |
661 show = TRUE; | |
662 mvwaddch(hw, nobj->o_pos.y, nobj->o_pos.x, FOOD); | |
663 } | |
664 } | |
665 for (nitem = mlist; nitem != NULL; nitem = next(nitem)) { | |
666 register struct linked_list *pitem; | |
667 register struct thing *th; | |
668 | |
669 th = THINGPTR(nitem); | |
670 if (on(*th, NODETECT)) continue; | |
671 for(pitem = th->t_pack; pitem != NULL; pitem = next(pitem)){ | |
672 nobj = OBJPTR(pitem); | |
673 if (nobj->o_type == FOOD) { | |
674 show = TRUE; | |
675 mvwaddch(hw, th->t_pos.y, th->t_pos.x, FOOD); | |
676 } | |
677 } | |
678 } | |
679 if (is_potion) p_know[P_FFIND] = TRUE; | |
680 if (show) { | |
681 rmmsg(); | |
682 msg("Your nose tingles."); | |
683 rmmsg(); | |
684 overlay(hw,cw); | |
685 draw(cw); | |
686 msg("You sense the presence of food on this level."); | |
687 } | |
688 else | |
689 msg("You have a strange feeling for a moment, then it passes."); | |
690 } | |
691 | |
692 when P_SKILL: | |
693 if (cursed) { | |
694 msg("You feel less skillful."); | |
695 | |
696 /* Does he currently have an artifical skill? */ | |
697 if (!find_slot(unskill)) { /* No skill */ | |
698 pstats.s_lvladj = -2; | |
699 pstats.s_lvl += pstats.s_lvladj; | |
700 fuse(unskill, (VOID *)NULL, SKILLDURATION, AFTER); | |
701 } | |
702 else { /* Has an artifical skill */ | |
703 /* Is the skill beneficial? */ | |
704 if (pstats.s_lvladj > 0) { | |
705 /* Decrease the previous skill advantage */ | |
706 pstats.s_lvl -= 2; | |
707 pstats.s_lvladj -= 2; | |
708 | |
709 /* If there is now a negative skill, lengthen time */ | |
710 if (pstats.s_lvladj < 0) | |
711 lengthen(unskill, SKILLDURATION); | |
712 | |
713 /* If there is no skill advantage, unfuse us */ | |
714 else if (pstats.s_lvladj == 0) extinguish(unskill); | |
715 } | |
716 else { /* Already bad */ | |
717 /* Make it a little worse, and lengthen it */ | |
718 pstats.s_lvl--; | |
719 pstats.s_lvladj--; | |
720 lengthen(unskill, SKILLDURATION); | |
721 } | |
722 } | |
723 | |
724 /* Is our level too low now? */ | |
725 if (pstats.s_lvl < 1) { | |
726 pstats.s_hpt = -1; | |
727 msg("You cough, choke, and finally die. --More--"); | |
728 wait_for(' '); | |
729 death(D_POTION); | |
730 } | |
731 } | |
732 else { | |
733 int adjust; | |
734 | |
735 msg("You feel more skillful."); | |
736 max_stats.s_hpt++; | |
737 pstats.s_hpt++; | |
738 | |
739 /* Get the adjustment */ | |
740 if (blessed) | |
741 adjust = rnd(4) + 2; | |
742 else | |
743 adjust = rnd(2) + 1; | |
744 | |
745 /* The Fighter likes this */ | |
746 if (player.t_ctype == C_FIGHTER) { | |
747 max_stats.s_hpt++; | |
748 pstats.s_hpt++; | |
749 adjust = rnd(2) + 1; | |
750 } | |
751 | |
752 /* Does he currently have an artifical skill? */ | |
753 if (!find_slot(unskill)) { | |
754 pstats.s_lvladj = adjust; | |
755 pstats.s_lvl += pstats.s_lvladj; | |
756 fuse(unskill, (VOID *)NULL, | |
757 blessed ? SKILLDURATION*2 : SKILLDURATION, AFTER); | |
758 } | |
759 else { /* Has an artifical skill */ | |
760 /* Is the skill detrimental? */ | |
761 if (pstats.s_lvladj < 0) { | |
762 /* Decrease the previous skill advantage */ | |
763 pstats.s_lvl += adjust; | |
764 pstats.s_lvladj += adjust; | |
765 | |
766 /* If there is now a positive skill, lengthen time */ | |
767 if (pstats.s_lvladj < 0) | |
768 lengthen(unskill, SKILLDURATION); | |
769 | |
770 /* If there is no skill advantage, unfuse us */ | |
771 else if (pstats.s_lvladj == 0) extinguish(unskill); | |
772 } | |
773 else { /* Already good */ | |
774 /* | |
775 * Make the skill the maximum of the current good | |
776 * skill and what the adjust would give him. | |
777 */ | |
778 pstats.s_lvl -= pstats.s_lvladj; | |
779 pstats.s_lvladj = max(pstats.s_lvladj, adjust); | |
780 pstats.s_lvl += pstats.s_lvladj; | |
781 lengthen(unskill, | |
782 blessed ? SKILLDURATION*2 : SKILLDURATION); | |
783 } | |
784 } | |
785 } | |
786 | |
787 when P_FIRE: { | |
788 int duration; | |
789 bool say_message; | |
790 | |
791 say_message = TRUE; | |
792 | |
793 if (blessed) duration = 8; | |
794 else duration = 3; | |
795 | |
796 if (on(player, NOFIRE)) { | |
797 if (cursed) { | |
798 msg("You quench your thirst. "); | |
799 say_message = FALSE; | |
800 } | |
801 else if (find_slot(nofire)) { | |
802 lengthen(nofire, duration*FIRETIME); | |
803 msg("Your feeling of fire resistance increases. "); | |
804 say_message = FALSE; | |
805 } | |
806 else { | |
807 msg("You experience heat waves. "); /* has on a ring */ | |
808 say_message = FALSE; | |
809 } | |
810 } | |
811 else if (cursed) { | |
812 msg("You quench your thirst. "); | |
813 say_message = FALSE; | |
814 } | |
815 else { | |
816 fuse(nofire, (VOID *)NULL, duration*FIRETIME, AFTER); | |
817 turn_on(player, NOFIRE); | |
818 } | |
819 if (say_message) { | |
820 if (is_potion) p_know[P_FIRE] = TRUE; | |
821 msg("You feel %sfire resistant", blessed ? "very " : ""); | |
822 } | |
823 } | |
824 when P_COLD: { | |
825 int duration; | |
826 bool say_message; | |
827 | |
828 say_message = TRUE; | |
829 | |
830 if (blessed) duration = 8; | |
831 else duration = 3; | |
832 | |
833 if (on(player, NOCOLD)) { | |
834 if (cursed) { | |
835 msg("You quench your thirst. "); | |
836 say_message = FALSE; | |
837 } | |
838 else if (find_slot(nocold)) { | |
839 lengthen(nocold, duration*COLDTIME); | |
840 msg("Your feeling of cold resistance increases. "); | |
841 say_message = FALSE; | |
842 } | |
843 else { | |
844 msg("You feel a cold chill. "); /* has on a ring */ | |
845 say_message = FALSE; | |
846 } | |
847 } | |
848 else if (cursed) { | |
849 msg("You quench your thirst. "); | |
850 say_message = FALSE; | |
851 } | |
852 else { | |
853 fuse(nocold, (VOID *)NULL, duration*COLDTIME, AFTER); | |
854 turn_on(player, NOCOLD); | |
855 } | |
856 if (say_message) { | |
857 if (is_potion) p_know[P_COLD] = TRUE; | |
858 msg("You feel %scold resistant", blessed ? "very " : ""); | |
859 } | |
860 } | |
861 when P_LIGHTNING: { | |
862 int duration; | |
863 bool say_message; | |
864 | |
865 say_message = TRUE; | |
866 | |
867 if (blessed) duration = 8; | |
868 else duration = 3; | |
869 | |
870 if (on(player, NOBOLT)) { | |
871 if (cursed) { | |
872 msg("You quench your thirst. "); | |
873 say_message = FALSE; | |
874 } | |
875 else if (find_slot(nobolt)) { | |
876 lengthen(nobolt, duration*BOLTTIME); | |
877 msg("Your blue skin deepens in hue. "); | |
878 say_message = FALSE; | |
879 } | |
880 else msg(nothing); | |
881 } | |
882 else if (cursed) { | |
883 msg("You quench your thirst. "); | |
884 say_message = FALSE; | |
885 } | |
886 else { | |
887 fuse(nobolt, (VOID *)NULL, duration*BOLTTIME, AFTER); | |
888 turn_on(player, NOBOLT); | |
889 } | |
890 if (say_message) { | |
891 if (is_potion) p_know[P_LIGHTNING] = TRUE; | |
892 msg("Your skin turns %sblue!", blessed ? "very " : ""); | |
893 } | |
894 } | |
895 when P_POISON: | |
896 if (!save(VS_POISON, &player, -2)) { | |
897 msg("You feel very sick now."); | |
898 pstats.s_hpt /= 2; | |
899 if (!ISWEARING(R_SUSABILITY)) | |
900 pstats.s_const--; | |
901 } | |
902 else { | |
903 msg("You feel sick now."); | |
904 pstats.s_hpt -= (pstats.s_hpt / 3); | |
905 } | |
906 if (pstats.s_const < 1 || pstats.s_hpt < 1) { | |
907 pstats.s_hpt = -1; | |
908 msg("You didn't survive! --More--"); | |
909 wait_for(' '); | |
910 death(D_POISON); | |
911 } | |
912 otherwise: | |
913 msg("What an odd tasting potion!"); | |
914 return; | |
915 } | |
916 status(FALSE); | |
917 if (is_potion && item && p_know[which] && p_guess[which]) | |
918 { | |
919 free(p_guess[which]); | |
920 p_guess[which] = NULL; | |
921 } | |
922 else if (is_potion && | |
923 !p_know[which] && | |
924 item && | |
925 askme && | |
926 (flags & ISKNOW) == 0 && | |
927 (flags & ISPOST) == 0 && | |
928 p_guess[which] == NULL) { | |
929 nameitem(item, FALSE); | |
930 } | |
931 if (item != NULL) o_discard(item); | |
932 updpack(TRUE, &player); | |
933 } | |
934 | |
935 | |
936 /* | |
937 * res_dexterity: | |
938 * Restore player's dexterity | |
939 * if called with zero the restore fully | |
940 */ | |
941 | |
942 int | |
943 res_dexterity(howmuch) | |
944 int howmuch; | |
945 { | |
946 short save_max; | |
947 int ring_str; | |
948 | |
949 if (howmuch < 0) return(0); | |
950 | |
951 /* Discount the ring value */ | |
952 ring_str = ring_value(R_ADDHIT); | |
953 pstats.s_dext -= ring_str; | |
954 | |
955 if (pstats.s_dext < max_stats.s_dext ) { | |
956 if (howmuch == 0) | |
957 pstats.s_dext = max_stats.s_dext; | |
958 else | |
959 pstats.s_dext = min(pstats.s_dext+howmuch, max_stats.s_dext); | |
960 } | |
961 | |
962 /* Redo the rings */ | |
963 if (ring_str) { | |
964 save_max = max_stats.s_dext; | |
965 pstats.s_dext += ring_str; | |
966 max_stats.s_dext = save_max; | |
967 } | |
968 return(0); | |
969 } | |
970 | |
971 /* | |
972 * res_intelligence: | |
973 * Restore player's intelligence | |
974 */ | |
975 | |
976 int | |
977 res_intelligence(howmuch) | |
978 int howmuch; | |
979 { | |
980 short save_max; | |
981 int ring_str; | |
982 | |
983 if (howmuch <= 0) return(0); | |
984 | |
985 /* Discount the ring value */ | |
986 ring_str = ring_value(R_ADDINTEL); | |
987 pstats.s_intel -= ring_str; | |
988 | |
989 pstats.s_intel = min(pstats.s_intel + howmuch, max_stats.s_intel); | |
990 | |
991 /* Redo the rings */ | |
992 if (ring_str) { | |
993 save_max = max_stats.s_intel; | |
994 pstats.s_intel += ring_str; | |
995 max_stats.s_intel = save_max; | |
996 } | |
997 return(0); | |
998 } | |
999 | |
1000 /* | |
1001 * res_wisdom: | |
1002 * Restore player's wisdom | |
1003 */ | |
1004 | |
1005 int | |
1006 res_wisdom(howmuch) | |
1007 int howmuch; | |
1008 { | |
1009 short save_max; | |
1010 int ring_str; | |
1011 | |
1012 if (howmuch <= 0) return(0); | |
1013 | |
1014 /* Discount the ring value */ | |
1015 ring_str = ring_value(R_ADDWISDOM); | |
1016 pstats.s_wisdom -= ring_str; | |
1017 | |
1018 pstats.s_wisdom = min(pstats.s_wisdom + howmuch, max_stats.s_wisdom); | |
1019 | |
1020 /* Redo the rings */ | |
1021 if (ring_str) { | |
1022 save_max = max_stats.s_wisdom; | |
1023 pstats.s_wisdom += ring_str; | |
1024 max_stats.s_wisdom = save_max; | |
1025 } | |
1026 return(0); | |
1027 } | |
1028 | |
1029 /* | |
1030 * res_constitution: | |
1031 * Restore the players constitution. | |
1032 */ | |
1033 | |
1034 int | |
1035 res_constitution(howmuch) | |
1036 int howmuch; | |
1037 { | |
1038 if (howmuch > 0) | |
1039 pstats.s_const = min(pstats.s_const + howmuch, max_stats.s_const); | |
1040 | |
1041 return(0); | |
1042 } | |
1043 | |
1044 /* | |
1045 * res_charisma: | |
1046 * Restore the players charisma. | |
1047 */ | |
1048 | |
1049 int | |
1050 res_charisma(howmuch) | |
1051 int howmuch; | |
1052 { | |
1053 if (howmuch > 0) | |
1054 pstats.s_charisma = | |
1055 min(pstats.s_charisma + howmuch, max_stats.s_charisma); | |
1056 | |
1057 return(0); | |
1058 } |