]> granicus.if.org Git - nethack/commitdiff
confirmation for polearm attacks (trunk only)
authornethack.rankin <nethack.rankin>
Mon, 28 May 2007 00:20:43 +0000 (00:20 +0000)
committernethack.rankin <nethack.rankin>
Mon, 28 May 2007 00:20:43 +0000 (00:20 +0000)
     From a bug report, 2005:  applying a
polearm towards a monster ignores the `confirm' option.  It's a wielded
weapon attack but is handled internally as a throw since it's also a
ranged attack.  The report included a small patch for use_pole() but I'm
calling the regular attack confirmation routine instead.

     Also, move the penalty for samurai attacking peaceful monsters into
the same routine that handles knight attacking defenseless monsters so
that they're more consistent.

doc/fixes35.0
src/apply.c
src/dothrow.c
src/uhitm.c

index 7ed56302badfc033cda3f7fe04fa9989562e4536..1d29c402ebad52a60fd2ddc48ed8989ac49a9e66 100644 (file)
@@ -234,7 +234,8 @@ re-adjust gem generation probabilities when revisiting existing dungeon levels
 kick evasion shouldn't move monsters through walls
 kick evasion and jousting/staggering blows shouldn't move grid bugs diagonally
 #untrap didn't check whether hero could reach the ground
-digging/chopping a closed drawbridge message mentioned diggin a "wall"
+digging/chopping a closed drawbridge message mentioned digging a "wall"
+attacking via applied polearm now honors the "confirm" option
 
 
 Platform- and/or Interface-Specific Fixes
index df8f2b65259f0fa62373773bff52b1af2075bddf..f889fb265aa1c81dce37a0e573d5140a8564868a 100644 (file)
@@ -2606,17 +2606,10 @@ use_pole(obj)
 
        /* Attack the monster there */
        if ((mtmp = m_at(cc.x, cc.y)) != (struct monst *)0) {
-           int oldhp = mtmp->mhp;
-
            bhitpos = cc;
+           if (attack_checks(mtmp, uwep)) return res;
            check_caitiff(mtmp);
            (void) thitmonst(mtmp, uwep);
-           /* check the monster's HP because thitmonst() doesn't return
-            * an indication of whether it hit.  Not perfect (what if it's a
-            * non-silver weapon on a shade?)
-            */
-           if (mtmp->mhp < oldhp)
-               u.uconduct.weaphit++;
        } else
            /* Now you know that nothing is there... */
            pline(nothing_happens);
@@ -2667,6 +2660,7 @@ use_grapple (obj)
        struct obj *obj;
 {
        int res = 0, typ, max_range = 4, tohit;
+       boolean save_confirm;
        coord cc;
        struct monst *mtmp;
        struct obj *otmp;
@@ -2751,15 +2745,25 @@ use_grapple (obj)
            }
            break;
        case 2: /* Monster */
+           bhitpos = cc;
            if ((mtmp = m_at(cc.x, cc.y)) == (struct monst *)0) break;
+           save_confirm = flags.confirm;
            if (verysmall(mtmp->data) && !rn2(4) &&
                        enexto(&cc, u.ux, u.uy, (struct permonst *)0)) {
+               flags.confirm = FALSE;
+               (void) attack_checks(mtmp, uwep);
+               flags.confirm = save_confirm;
+               check_caitiff(mtmp);    /* despite fact there's no damage */
                You("pull in %s!", mon_nam(mtmp));
                mtmp->mundetected = 0;
                rloc_to(mtmp, cc.x, cc.y);
                return (1);
            } else if ((!bigmonst(mtmp->data) && !strongmonst(mtmp->data)) ||
                       rn2(4)) {
+               flags.confirm = FALSE;
+               (void) attack_checks(mtmp, uwep);
+               flags.confirm = save_confirm;
+               check_caitiff(mtmp);
                (void) thitmonst(mtmp, uwep);
                return (1);
            }
index 3941e218e7f9932c3ffac54975b61ef5914c7623..26be01f61ea6dcf1e130cc8b7eac2d4b2765fccd 100644 (file)
@@ -1397,6 +1397,7 @@ register struct obj *obj; /* thrownobj or kickobj or uwep */
            }
 
            if (tmp >= rnd(20)) {
+               if (hmode == HMON_APPLIED) u.uconduct.weaphit++;
                if (hmon(mon, obj, hmode)) {    /* mon still alive */
                    cutworm(mon, bhitpos.x, bhitpos.y, obj);
                }
@@ -1429,6 +1430,7 @@ register struct obj *obj; /* thrownobj or kickobj or uwep */
                passive_obj(mon, obj, (struct attack *)0);
            } else {
                tmiss(obj, mon, TRUE);
+               if (hmode == HMON_APPLIED) wakeup(mon);
            }
 
        } else if (otyp == HEAVY_IRON_BALL) {
index 72823bad8ed9640debca96b2169a20abdfea07ad..1c6b55653cdaa285c36c7f3743ae6c168666d638 100644 (file)
@@ -140,7 +140,9 @@ struct obj *wep;    /* uwep for attack(), null for kick_monster() */
                /* if it was an invisible mimic, treat it as if we stumbled
                 * onto a visible mimic
                 */
-               if(mtmp->m_ap_type && !Protection_from_shape_changers) {
+               if (mtmp->m_ap_type && !Protection_from_shape_changers &&
+                       /* applied pole-arm attack is too far to get stuck */
+                       distu(mtmp->mx, mtmp->my) <= 2) {
                    if(!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data,AD_STCK))
                        u.ustuck = mtmp;
                }
@@ -220,12 +222,17 @@ void
 check_caitiff(mtmp)
 struct monst *mtmp;
 {
+       if (u.ualign.record <= -10) return;
+
        if (Role_if(PM_KNIGHT) && u.ualign.type == A_LAWFUL &&
            (!mtmp->mcanmove || mtmp->msleeping ||
-            (mtmp->mflee && !mtmp->mavenge)) &&
-           u.ualign.record > -10) {
+            (mtmp->mflee && !mtmp->mavenge))) {
            You("caitiff!");
            adjalign(-1);
+       } else if (Role_if(PM_SAMURAI) && mtmp->mpeaceful) {
+           /* attacking peaceful creatures is bad for the samurai's giri */
+           You("dishonorably attack the innocent!");
+           adjalign(-1);
        }
 }
 
@@ -245,15 +252,8 @@ int *attk_count, *role_roll_penalty;
 
        /* some actions should occur only once during multiple attacks */
        if (!(*attk_count)++) {
-           /* knight's chivalry */
+           /* knight's chivalry or samurai's giri */
            check_caitiff(mtmp);
-
-           /* attacking peaceful creatures is bad for the samurai's giri */
-           if (Role_if(PM_SAMURAI) && mtmp->mpeaceful &&
-                   u.ualign.record > -10) {
-               You("dishonorably attack the innocent!");
-               adjalign(-1);
-           }
        }
 
        /* adjust vs. (and possibly modify) monster state */