]> granicus.if.org Git - nethack/commitdiff
flavor enhance zap downwards/upwards when hiding
authornhmall <mjnh@persona.ca>
Sat, 28 Mar 2015 15:20:44 +0000 (11:20 -0400)
committernhmall <mjnh@persona.ca>
Sat, 28 Mar 2015 15:20:44 +0000 (11:20 -0400)
 Changes to be committed:
modified:   doc/fixes35.0
modified:   include/extern.h
modified:   src/apply.c
modified:   src/zap.c

    On 3/23/2015 6:41 PM, a bug reporter wrote:
    > When you're hiding under an item (e.g. via garter snake polyform), and
    > that item gets polyshuddered into nonexistence, you continue hiding
    > (under nothing).
    This was addressed previously.

    > (Incidentally, it's a bit weird that you use > to aim at items that are
    > flavorwise above you at the time.)

    This addresses the flavorwise concern.

doc/fixes35.0
include/extern.h
src/apply.c
src/zap.c

index e6d5e13686761e3af7d12af29d397b89246a8d82..2db942ec51d508f413c2be16735c585f3dd0fe55 100644 (file)
@@ -1100,6 +1100,8 @@ pressing # when cursor positioning toggles automatic description of features
        under the cursor
 cursor positioning ignores uninteresting dungeon features
 allow reading many more items
+when you're hiding under something a zap downward should not hit that
+       something, while a zap upward should
 
 
 Platform- and/or Interface-Specific New Features
index 1cee0f651dfd9c63ab068b1e67bea8b0cb9f8a3f..38e751018472916c6025ac19b533e53472c3916b 100644 (file)
@@ -2629,7 +2629,7 @@ E boolean FDECL(obj_resists, (struct obj *,int,int));
 E boolean FDECL(obj_shudders, (struct obj *));
 E void FDECL(do_osshock, (struct obj *));
 E int FDECL(bhito, (struct obj *,struct obj *));
-E int FDECL(bhitpile, (struct obj *,int (*)(OBJ_P,OBJ_P),int,int));
+E int FDECL(bhitpile, (struct obj *,int (*)(OBJ_P,OBJ_P),int,int,SCHAR_P));
 E int FDECL(zappable, (struct obj *));
 E void FDECL(zapnodir, (struct obj *));
 E int NDECL(dozap);
index ae7565f17b9b6ff61b8c226e542bb2a3b422066c..2265ab51946af359bafe77587abed5eeb262e4eb 100644 (file)
@@ -3037,7 +3037,7 @@ do_break_wand(obj)
             /* if (context.botl) bot(); */
            }
            if (affects_objects && level.objects[x][y]) {
-               (void) bhitpile(obj, bhito, x, y);
+               (void) bhitpile(obj, bhito, x, y, 0);
                if (context.botl) bot();                /* potion effects */
            }
        } else {
@@ -3054,7 +3054,7 @@ do_break_wand(obj)
             * since it's also used by retouch_equipment() for polyself.)
             */
            if (affects_objects && level.objects[x][y]) {
-               (void) bhitpile(obj, bhito, x, y);
+               (void) bhitpile(obj, bhito, x, y, 0);
                if (context.botl) bot();                /* potion effects */
            }
            damage = zapyourself(obj, FALSE);
index fcf0047bfb309b4d4e63d1cca12968aaffc7277f..3674e5a4a041d38538dab9fa5139e913c4463e70 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1750,9 +1750,9 @@ struct obj *obj, *otmp;
                if (Is_box(obj)) (void) boxlock(obj, otmp);
 
                if (obj_shudders(obj)) {
-                   boolean cover = ((obj->ox == u.ux && obj->oy == u.uy) &&
-                                       u.uundetected &&
-                                       hides_under(youmonst.data));
+                   boolean cover = ((obj == level.objects[u.ux][u.uy]) &&
+                                    u.uundetected &&
+                                    hides_under(youmonst.data));
 
                    if (cansee(obj->ox, obj->oy)) learn_it = TRUE;
                    do_osshock(obj);
@@ -1892,10 +1892,11 @@ struct obj *obj, *otmp;
 
 /* returns nonzero if something was hit */
 int
-bhitpile(obj,fhito,tx,ty)
+bhitpile(obj,fhito,tx,ty,zdir)
     struct obj *obj;
     int FDECL((*fhito), (OBJ_P,OBJ_P));
     int tx, ty;
+    schar zdir;
 {
     int hitanything = 0;
     register struct obj *otmp, *next_obj;
@@ -1917,7 +1918,14 @@ bhitpile(obj,fhito,tx,ty)
     for(otmp = level.objects[tx][ty]; otmp; otmp = next_obj) {
        /* Fix for polymorph bug, Tim Wright */
        next_obj = otmp->nexthere;
-       hitanything += (*fhito)(otmp, obj);
+       /*
+        * game flavor: if you are hiding under something, 
+        * a zap downwards shouldn't hit that obj, so honor that.
+        */
+       if (!(u.uundetected && (zdir > 0) &&
+             (otmp == level.objects[u.ux][u.uy]) &&
+             hides_under(youmonst.data)))
+           hitanything += (*fhito)(otmp, obj);
     }
     if(poly_zapped >= 0)
        create_polymon(level.objects[tx][ty], poly_zapped);
@@ -2568,7 +2576,7 @@ struct obj *obj;  /* wand or spell */
            if (u.dz < 0) {
                You("probe towards the %s.", ceiling(x,y));
            } else {
-               ptmp += bhitpile(obj, bhito, x, y);
+               ptmp += bhitpile(obj, bhito, x, y, u.dz);
                You("probe beneath the %s.", surface(x,y));
                ptmp += display_binventory(x, y, TRUE);
            }
@@ -2688,7 +2696,7 @@ struct obj *obj;  /* wand or spell */
 
        if (u.dz > 0) {
            /* zapping downward */
-           (void) bhitpile(obj, bhito, x, y);
+           (void) bhitpile(obj, bhito, x, y, u.dz);
 
            /* subset of engraving effects; none sets `disclose' */
            if ((e = engr_at(x, y)) != 0 && e->engr_type != HEADSTONE) {
@@ -2724,6 +2732,22 @@ struct obj *obj; /* wand or spell */
                    break;
                }
            }
+       } else if (u.dz < 0) {
+           /* zapping upward */
+
+           /* game flavor: if you're hiding under "something"
+            * a zap upward should hit that "something".
+            */
+           if (u.uundetected && hides_under(youmonst.data)) {
+               int hitit = 0;
+               otmp = level.objects[u.ux][u.uy];
+
+               if (otmp) hitit = bhito(otmp, obj);
+               if (hitit) {
+                   (void) hideunder(&youmonst);
+                   disclose = TRUE;
+               }
+           }
        }
 
        return disclose;
@@ -3095,7 +3119,7 @@ struct obj **pobj;                        /* object tossed/used, set to NULL
                }
            }
            if(fhito) {
-               if(bhitpile(obj,fhito,bhitpos.x,bhitpos.y))
+               if(bhitpile(obj,fhito,bhitpos.x,bhitpos.y,0))
                    range--;
            } else {
                if(weapon == KICKED_WEAPON &&