]> granicus.if.org Git - nethack/commitdiff
followup to fix for M63 - magic lamp wishes
authornethack.rankin <nethack.rankin>
Thu, 28 Apr 2005 04:45:20 +0000 (04:45 +0000)
committernethack.rankin <nethack.rankin>
Thu, 28 Apr 2005 04:45:20 +0000 (04:45 +0000)
     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.

doc/fixes34.4
include/extern.h
src/fountain.c
src/potion.c

index 153b420437fe13467162199df23ceea50072e4ed..c8da32f45081ea60c595a42278946f8de721ecc5 100644 (file)
@@ -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
index 9132614eccb87fac08f91c79e6e8a52a07c5f83e..4b1e0fd3912dd75dc8acd29e407016cdb022130f 100644 (file)
@@ -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);
index 886eb64891e89bb2e4aec4d1a2d58c1e154191fe..7326bc7ae363a3104febea48220a3ad5bac9d0f2 100644 (file)
@@ -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);
        }
index 1fada4b2940eba9b951a51188c530bdb80c403b2..35552a837f5f307d55c63d9a4b97a6ded1591e37 100644 (file)
@@ -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);