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