Mercurial > hg > early-roguelike
comparison arogue7/potions.c @ 238:e1cd27c5464f
arogue7, xrogue: improve the handling of the arguments to fuses.
fuse() now expects a pointer as the argument to a fuse function. If
this is one of the functions that takes int, fuse() follows the pointer
and stores that value in the f_list slot, in the integer field of the
argument union. When the fuse goes off, do_fuses() recognizes the
function and passes it the integer field instead of the pointer.
This has the disadvantage of hard-coding the functions that require int
in daemon.c, but since the int is copied into f_list, it no longer has
to be in static or global memory, which simplifies several files.
| author | John "Elwin" Edwards |
|---|---|
| date | Fri, 11 Mar 2016 17:40:00 -0500 |
| parents | f9ef86cf22b2 |
| children |
comparison
equal
deleted
inserted
replaced
| 237:2236ef808bcb | 238:e1cd27c5464f |
|---|---|
| 148 lengthen(nohaste, roll(hasttime,hasttime)); | 148 lengthen(nohaste, roll(hasttime,hasttime)); |
| 149 } | 149 } |
| 150 else { | 150 else { |
| 151 msg("You feel yourself moving %sfaster.", blessed ? "much " : ""); | 151 msg("You feel yourself moving %sfaster.", blessed ? "much " : ""); |
| 152 turn_on(player, ISHASTE); | 152 turn_on(player, ISHASTE); |
| 153 fuse(nohaste, 0, roll(hasttime, hasttime), AFTER); | 153 fuse(nohaste, NULL, roll(hasttime, hasttime), AFTER); |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| 157 /* | 157 /* |
| 158 * Increase player's intelligence | 158 * Increase player's intelligence |
| 204 on(player, ISSLOW) ? "even " : ""); | 204 on(player, ISSLOW) ? "even " : ""); |
| 205 if (on(player, ISSLOW)) | 205 if (on(player, ISSLOW)) |
| 206 lengthen(noslow, roll(HASTETIME,HASTETIME)); | 206 lengthen(noslow, roll(HASTETIME,HASTETIME)); |
| 207 else { | 207 else { |
| 208 turn_on(player, ISSLOW); | 208 turn_on(player, ISSLOW); |
| 209 fuse(noslow, 0, roll(HASTETIME,HASTETIME), AFTER); | 209 fuse(noslow, NULL, roll(HASTETIME,HASTETIME), AFTER); |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 /* | 214 /* |
| 322 extinguish(unclrhead); /* If we have a fuse, put it out */ | 322 extinguish(unclrhead); /* If we have a fuse, put it out */ |
| 323 msg("A strong blue aura surrounds your head."); | 323 msg("A strong blue aura surrounds your head."); |
| 324 } | 324 } |
| 325 else { /* Just light a fuse for how long player is safe */ | 325 else { /* Just light a fuse for how long player is safe */ |
| 326 if (off(player, ISCLEAR)) { | 326 if (off(player, ISCLEAR)) { |
| 327 fuse(unclrhead, 0, CLRDURATION, AFTER); | 327 fuse(unclrhead, NULL, CLRDURATION, AFTER); |
| 328 msg("A faint blue aura surrounds your head."); | 328 msg("A faint blue aura surrounds your head."); |
| 329 } | 329 } |
| 330 else { /* If we have a fuse lengthen it, else we | 330 else { /* If we have a fuse lengthen it, else we |
| 331 * are permanently clear. | 331 * are permanently clear. |
| 332 */ | 332 */ |
| 489 if (cursed) { | 489 if (cursed) { |
| 490 if (!find_slot(sight)) | 490 if (!find_slot(sight)) |
| 491 { | 491 { |
| 492 msg("A cloak of darkness falls around you."); | 492 msg("A cloak of darkness falls around you."); |
| 493 turn_on(player, ISBLIND); | 493 turn_on(player, ISBLIND); |
| 494 fuse(sight, 0, SEEDURATION, AFTER); | 494 fuse(sight, NULL, SEEDURATION, AFTER); |
| 495 light(&hero); | 495 light(&hero); |
| 496 } | 496 } |
| 497 else | 497 else |
| 498 lengthen(sight, SEEDURATION); | 498 lengthen(sight, SEEDURATION); |
| 499 } | 499 } |
| 500 else { | 500 else { |
| 501 if (off(player, CANSEE)) { | 501 if (off(player, CANSEE)) { |
| 502 turn_on(player, CANSEE); | 502 turn_on(player, CANSEE); |
| 503 msg("Your eyes begin to tingle."); | 503 msg("Your eyes begin to tingle."); |
| 504 fuse(unsee, 0, blessed ? SEEDURATION*3 :SEEDURATION, AFTER); | 504 fuse(unsee, NULL, blessed ? SEEDURATION*3 :SEEDURATION, AFTER); |
| 505 light(&hero); | 505 light(&hero); |
| 506 } | 506 } |
| 507 else if (find_slot(unsee) != 0) | 507 else if (find_slot(unsee) != 0) |
| 508 lengthen(unsee, blessed ? SEEDURATION*3 : SEEDURATION); | 508 lengthen(unsee, blessed ? SEEDURATION*3 : SEEDURATION); |
| 509 sight(); | 509 sight(); |
| 521 else duration = 1; | 521 else duration = 1; |
| 522 | 522 |
| 523 if (on(player, CANINWALL)) | 523 if (on(player, CANINWALL)) |
| 524 lengthen(unphase, duration*PHASEDURATION); | 524 lengthen(unphase, duration*PHASEDURATION); |
| 525 else { | 525 else { |
| 526 fuse(unphase, 0, duration*PHASEDURATION, AFTER); | 526 fuse(unphase, NULL, duration*PHASEDURATION, AFTER); |
| 527 turn_on(player, CANINWALL); | 527 turn_on(player, CANINWALL); |
| 528 } | 528 } |
| 529 msg("You feel %slight-headed!", | 529 msg("You feel %slight-headed!", |
| 530 blessed ? "very " : ""); | 530 blessed ? "very " : ""); |
| 531 } | 531 } |
| 545 msg("Nothing happens."); /* Flying by cloak */ | 545 msg("Nothing happens."); /* Flying by cloak */ |
| 546 say_message = FALSE; | 546 say_message = FALSE; |
| 547 } | 547 } |
| 548 } | 548 } |
| 549 else { | 549 else { |
| 550 fuse(land, 0, duration*FLYTIME, AFTER); | 550 fuse(land, NULL, duration*FLYTIME, AFTER); |
| 551 turn_on(player, ISFLY); | 551 turn_on(player, ISFLY); |
| 552 } | 552 } |
| 553 if (say_message) { | 553 if (say_message) { |
| 554 if (is_potion) p_know[P_FLY] = TRUE; | 554 if (is_potion) p_know[P_FLY] = TRUE; |
| 555 msg("You feel %slighter than air!", blessed ? "much " : ""); | 555 msg("You feel %slighter than air!", blessed ? "much " : ""); |
| 608 } | 608 } |
| 609 when P_INVIS: | 609 when P_INVIS: |
| 610 if (off(player, ISINVIS)) { | 610 if (off(player, ISINVIS)) { |
| 611 turn_on(player, ISINVIS); | 611 turn_on(player, ISINVIS); |
| 612 msg("You have a tingling feeling all over your body"); | 612 msg("You have a tingling feeling all over your body"); |
| 613 fuse(appear, 0, blessed ? GONETIME*3 : GONETIME, AFTER); | 613 fuse(appear, NULL, blessed ? GONETIME*3 : GONETIME, AFTER); |
| 614 PLAYER = IPLAYER; | 614 PLAYER = IPLAYER; |
| 615 light(&hero); | 615 light(&hero); |
| 616 } | 616 } |
| 617 else { | 617 else { |
| 618 if (find_slot(appear)) { | 618 if (find_slot(appear)) { |
| 673 | 673 |
| 674 /* Does he currently have an artifical skill? */ | 674 /* Does he currently have an artifical skill? */ |
| 675 if (!find_slot(unskill)) { /* No skill */ | 675 if (!find_slot(unskill)) { /* No skill */ |
| 676 pstats.s_lvladj = -2; | 676 pstats.s_lvladj = -2; |
| 677 pstats.s_lvl += pstats.s_lvladj; | 677 pstats.s_lvl += pstats.s_lvladj; |
| 678 fuse(unskill, 0, SKILLDURATION, AFTER); | 678 fuse(unskill, NULL, SKILLDURATION, AFTER); |
| 679 } | 679 } |
| 680 else { /* Has an artifical skill */ | 680 else { /* Has an artifical skill */ |
| 681 /* Is the skill beneficial? */ | 681 /* Is the skill beneficial? */ |
| 682 if (pstats.s_lvladj > 0) { | 682 if (pstats.s_lvladj > 0) { |
| 683 /* Decrease the previous skill advantage */ | 683 /* Decrease the previous skill advantage */ |
| 712 | 712 |
| 713 /* Does he currently have an artifical skill? */ | 713 /* Does he currently have an artifical skill? */ |
| 714 if (!find_slot(unskill)) { | 714 if (!find_slot(unskill)) { |
| 715 pstats.s_lvladj = adjust; | 715 pstats.s_lvladj = adjust; |
| 716 pstats.s_lvl += pstats.s_lvladj; | 716 pstats.s_lvl += pstats.s_lvladj; |
| 717 fuse(unskill, 0, | 717 fuse(unskill, NULL, |
| 718 blessed ? SKILLDURATION*2 : SKILLDURATION, AFTER); | 718 blessed ? SKILLDURATION*2 : SKILLDURATION, AFTER); |
| 719 } | 719 } |
| 720 else { /* Has an artifical skill */ | 720 else { /* Has an artifical skill */ |
| 721 /* Is the skill detrimental? */ | 721 /* Is the skill detrimental? */ |
| 722 if (pstats.s_lvladj < 0) { | 722 if (pstats.s_lvladj < 0) { |
| 761 msg("Nothing happens."); /* has on a ring */ | 761 msg("Nothing happens."); /* has on a ring */ |
| 762 say_message = FALSE; | 762 say_message = FALSE; |
| 763 } | 763 } |
| 764 } | 764 } |
| 765 else { | 765 else { |
| 766 fuse(nofire, 0, duration*FIRETIME, AFTER); | 766 fuse(nofire, NULL, duration*FIRETIME, AFTER); |
| 767 turn_on(player, NOFIRE); | 767 turn_on(player, NOFIRE); |
| 768 } | 768 } |
| 769 if (say_message) { | 769 if (say_message) { |
| 770 if (is_potion) p_know[P_FIRE] = TRUE; | 770 if (is_potion) p_know[P_FIRE] = TRUE; |
| 771 msg("You feel %sfire resistant", blessed ? "very " : ""); | 771 msg("You feel %sfire resistant", blessed ? "very " : ""); |
| 787 msg("Nothing happens."); /* has on a ring */ | 787 msg("Nothing happens."); /* has on a ring */ |
| 788 say_message = FALSE; | 788 say_message = FALSE; |
| 789 } | 789 } |
| 790 } | 790 } |
| 791 else { | 791 else { |
| 792 fuse(nocold, 0, duration*COLDTIME, AFTER); | 792 fuse(nocold, NULL, duration*COLDTIME, AFTER); |
| 793 turn_on(player, NOCOLD); | 793 turn_on(player, NOCOLD); |
| 794 } | 794 } |
| 795 if (say_message) { | 795 if (say_message) { |
| 796 if (is_potion) p_know[P_COLD] = TRUE; | 796 if (is_potion) p_know[P_COLD] = TRUE; |
| 797 msg("You feel %scold resistant", blessed ? "very " : ""); | 797 msg("You feel %scold resistant", blessed ? "very " : ""); |
| 809 if (on(player, NOBOLT)) { | 809 if (on(player, NOBOLT)) { |
| 810 if (find_slot(nobolt)) | 810 if (find_slot(nobolt)) |
| 811 lengthen(nobolt, duration*BOLTTIME); | 811 lengthen(nobolt, duration*BOLTTIME); |
| 812 } | 812 } |
| 813 else { | 813 else { |
| 814 fuse(nobolt, 0, duration*BOLTTIME, AFTER); | 814 fuse(nobolt, NULL, duration*BOLTTIME, AFTER); |
| 815 turn_on(player, NOBOLT); | 815 turn_on(player, NOBOLT); |
| 816 } | 816 } |
| 817 if (say_message) | 817 if (say_message) |
| 818 msg("Your skin turns %sblue!", blessed ? "very " : ""); | 818 msg("Your skin turns %sblue!", blessed ? "very " : ""); |
| 819 } | 819 } |
