confirmation for polearm attacks (trunk only)

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.
This commit is contained in:
nethack.rankin
2007-05-28 00:20:43 +00:00
parent 2b29d99315
commit bb5ade4293
4 changed files with 27 additions and 20 deletions
+2 -1
View 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 shouldn't move monsters through walls
kick evasion and jousting/staggering blows shouldn't move grid bugs diagonally kick evasion and jousting/staggering blows shouldn't move grid bugs diagonally
#untrap didn't check whether hero could reach the ground #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 Platform- and/or Interface-Specific Fixes
+12 -8
View File
@@ -2606,17 +2606,10 @@ use_pole(obj)
/* Attack the monster there */ /* Attack the monster there */
if ((mtmp = m_at(cc.x, cc.y)) != (struct monst *)0) { if ((mtmp = m_at(cc.x, cc.y)) != (struct monst *)0) {
int oldhp = mtmp->mhp;
bhitpos = cc; bhitpos = cc;
if (attack_checks(mtmp, uwep)) return res;
check_caitiff(mtmp); check_caitiff(mtmp);
(void) thitmonst(mtmp, uwep); (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 } else
/* Now you know that nothing is there... */ /* Now you know that nothing is there... */
pline(nothing_happens); pline(nothing_happens);
@@ -2667,6 +2660,7 @@ use_grapple (obj)
struct obj *obj; struct obj *obj;
{ {
int res = 0, typ, max_range = 4, tohit; int res = 0, typ, max_range = 4, tohit;
boolean save_confirm;
coord cc; coord cc;
struct monst *mtmp; struct monst *mtmp;
struct obj *otmp; struct obj *otmp;
@@ -2751,15 +2745,25 @@ use_grapple (obj)
} }
break; break;
case 2: /* Monster */ case 2: /* Monster */
bhitpos = cc;
if ((mtmp = m_at(cc.x, cc.y)) == (struct monst *)0) break; if ((mtmp = m_at(cc.x, cc.y)) == (struct monst *)0) break;
save_confirm = flags.confirm;
if (verysmall(mtmp->data) && !rn2(4) && if (verysmall(mtmp->data) && !rn2(4) &&
enexto(&cc, u.ux, u.uy, (struct permonst *)0)) { 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)); You("pull in %s!", mon_nam(mtmp));
mtmp->mundetected = 0; mtmp->mundetected = 0;
rloc_to(mtmp, cc.x, cc.y); rloc_to(mtmp, cc.x, cc.y);
return (1); return (1);
} else if ((!bigmonst(mtmp->data) && !strongmonst(mtmp->data)) || } else if ((!bigmonst(mtmp->data) && !strongmonst(mtmp->data)) ||
rn2(4)) { rn2(4)) {
flags.confirm = FALSE;
(void) attack_checks(mtmp, uwep);
flags.confirm = save_confirm;
check_caitiff(mtmp);
(void) thitmonst(mtmp, uwep); (void) thitmonst(mtmp, uwep);
return (1); return (1);
} }
+2
View File
@@ -1397,6 +1397,7 @@ register struct obj *obj; /* thrownobj or kickobj or uwep */
} }
if (tmp >= rnd(20)) { if (tmp >= rnd(20)) {
if (hmode == HMON_APPLIED) u.uconduct.weaphit++;
if (hmon(mon, obj, hmode)) { /* mon still alive */ if (hmon(mon, obj, hmode)) { /* mon still alive */
cutworm(mon, bhitpos.x, bhitpos.y, obj); 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); passive_obj(mon, obj, (struct attack *)0);
} else { } else {
tmiss(obj, mon, TRUE); tmiss(obj, mon, TRUE);
if (hmode == HMON_APPLIED) wakeup(mon);
} }
} else if (otyp == HEAVY_IRON_BALL) { } else if (otyp == HEAVY_IRON_BALL) {
+11 -11
View 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 /* if it was an invisible mimic, treat it as if we stumbled
* onto a visible mimic * 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)) if(!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data,AD_STCK))
u.ustuck = mtmp; u.ustuck = mtmp;
} }
@@ -220,12 +222,17 @@ void
check_caitiff(mtmp) check_caitiff(mtmp)
struct monst *mtmp; struct monst *mtmp;
{ {
if (u.ualign.record <= -10) return;
if (Role_if(PM_KNIGHT) && u.ualign.type == A_LAWFUL && if (Role_if(PM_KNIGHT) && u.ualign.type == A_LAWFUL &&
(!mtmp->mcanmove || mtmp->msleeping || (!mtmp->mcanmove || mtmp->msleeping ||
(mtmp->mflee && !mtmp->mavenge)) && (mtmp->mflee && !mtmp->mavenge))) {
u.ualign.record > -10) {
You("caitiff!"); You("caitiff!");
adjalign(-1); 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 */ /* some actions should occur only once during multiple attacks */
if (!(*attk_count)++) { if (!(*attk_count)++) {
/* knight's chivalry */ /* knight's chivalry or samurai's giri */
check_caitiff(mtmp); 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 */ /* adjust vs. (and possibly modify) monster state */