From: nethack.rankin Date: Thu, 28 Apr 2005 04:45:20 +0000 (+0000) Subject: followup to fix for M63 - magic lamp wishes X-Git-Tag: MOVE2GIT~1276 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=632afa4979b76855a03efd43a297bad1cdaf62ff;p=nethack followup to fix for M63 - magic lamp wishes This uses Michael's suggestion for keeping the display up to date when removing a djinni or water demon in advance of granting a wish (so that it won't be present in a bones file if the wish is fatal--problem with earlier fix was that player could notice monster was already gone while responding to the wish prompt). It's not quite as straightforward as I was hoping for and would get a lot messier if it needed to cope with Warning & Warn_of_mon. --- diff --git a/doc/fixes34.4 b/doc/fixes34.4 index 153b42043..c8da32f45 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -119,6 +119,7 @@ reanimating a statue containing gold produced double gold probing the resulting double-gold monster caused "static object freed" panic cursed wand might explode if used to engrave fatal wish from magic lamp left functional magic lamp in bones data +fatal wish granted by monster left that monster in bones data Platform- and/or Interface-Specific Fixes diff --git a/include/extern.h b/include/extern.h index 9132614ec..4b1e0fd39 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1625,6 +1625,7 @@ E void FDECL(potionhit, (struct monst *,struct obj *,BOOLEAN_P)); E void FDECL(potionbreathe, (struct obj *)); E boolean FDECL(get_wet, (struct obj *)); E int NDECL(dodip); +E void FDECL(mongrantswish, (struct monst **)); E void FDECL(djinni_from_bottle, (struct obj *)); E struct monst *FDECL(split_mon, (struct monst *,struct monst *)); E const char *NDECL(bottlename); diff --git a/src/fountain.c b/src/fountain.c index 886eb6489..7326bc7ae 100644 --- a/src/fountain.c +++ b/src/fountain.c @@ -56,10 +56,8 @@ dowaterdemon() /* Water demon */ if (rnd(100) > (80 + level_difficulty())) { pline("Grateful for %s release, %s grants you a wish!", mhis(mtmp), mhe(mtmp)); - /* bones prep: remove demon first in case the wish - turns out to be fatal (artifact blast) */ - mongone(mtmp); - makewish(); + /* give a wish and discard the monster (mtmp set to null) */ + mongrantswish(&mtmp); } else if (t_at(mtmp->mx, mtmp->my)) (void) mintrap(mtmp); } diff --git a/src/potion.c b/src/potion.c index 1fada4b29..35552a837 100644 --- a/src/potion.c +++ b/src/potion.c @@ -2042,6 +2042,34 @@ dodip() return(1); } +/* *monp grants a wish and then leaves the game */ +void +mongrantswish(monp) +struct monst **monp; +{ + /* note: `mon' is still valid after mongone() (til next dmonsfree()) + but it's no longer on the map--affects coordinates and visibility */ + struct monst *mon = *monp; + int mx = mon->mx, my = mon->my; + boolean monspotted = canspotmon(mon), + /* no need to handle Warning since monster is peaceful */ + disp_hackery = monspotted || Detect_monsters; + + /* remove the monster first in case wish proves to be fatal + (blasted by artifact), to keep it out of resulting bones file */ + mongone(mon); + *monp = 0; /* inform caller than monster is gone */ + /* hide that removal from the player--map is visible during wish prompt */ + if (disp_hackery) { + tmp_at(DISP_ALWAYS, + monspotted ? mon_to_glyph(mon) : detected_mon_to_glyph(mon)); + tmp_at(mx, my); + } + /* grant the wish */ + makewish(); + /* clean up */ + if (disp_hackery) tmp_at(DISP_END, 0); +} void djinni_from_bottle(obj) @@ -2070,10 +2098,8 @@ register struct obj *obj; switch (chance) { case 0 : verbalize("I am in your debt. I will grant one wish!"); - /* bones prep: remove djinni first in case the wish - turns out to be fatal (artifact blast) */ - mongone(mtmp); - makewish(); + /* give a wish and discard the monster (mtmp set to null) */ + mongrantswish(&mtmp); break; case 1 : verbalize("Thank you for freeing me!"); (void) tamedog(mtmp, (struct obj *)0);