fix github issue #745 - two-weapon paralysis

Issue #745 by k2:  when using two-weapon combat, the second attack
would still take place even if the first attack caused the hero to
become paralyzed (hitting a floating eye or g.cube).

Cleaver's up-to-three attacks had the same problem but did stop if
the hero underwent life-saving after some fatally damaging counter-
attack.  Two-weapons didn't.  Make them both stop early if either
paralysis or life-save occurs.

Multiple attacking monster against monster and against poly'd hero
already deal with paralysis; life-saving doesn't apply.

Fixes #745
This commit is contained in:
PatR
2022-04-26 02:02:31 -07:00
parent f10cdc2d9c
commit 36af5a9a63
2 changed files with 18 additions and 11 deletions
+3 -1
View File
@@ -1,4 +1,4 @@
HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.891 $ $NHDT-Date: 1650838834 2022/04/24 22:20:34 $ HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.892 $ $NHDT-Date: 1650963745 2022/04/26 09:02:25 $
General Fixes and Modified Features General Fixes and Modified Features
----------------------------------- -----------------------------------
@@ -892,6 +892,8 @@ inventory #adjust for !fixinv, after picking 'from' slot the prompt for 'to'
slot was supposed to include the next letter beyond those in use as slot was supposed to include the next letter beyond those in use as
a candidate for destination but an off by 1 error only showed a-x a candidate for destination but an off by 1 error only showed a-x
where x is last letter used (despite that, y could still be picked) where x is last letter used (despite that, y could still be picked)
with two-weapon combat or Cleaver attacking multiple targets, hero kept going
with next attack after being paralyzed by passive counter-attack
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
+15 -10
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 uhitm.c $NHDT-Date: 1646652773 2022/03/07 11:32:53 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.344 $ */ /* NetHack 3.7 uhitm.c $NHDT-Date: 1650963745 2022/04/26 09:02:25 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.348 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -656,9 +656,9 @@ hitum_cleave(
uattk, dieroll); uattk, dieroll);
(void) passive(mtmp, uwep, mhit, !DEADMONSTER(mtmp), AT_WEAP, !uwep); (void) passive(mtmp, uwep, mhit, !DEADMONSTER(mtmp), AT_WEAP, !uwep);
/* stop attacking if weapon is gone or hero got killed and /* stop attacking if weapon is gone or hero got paralyzed or
life-saved after passive counter-attack */ killed (and then life-saved) by passive counter-attack */
if (!uwep || u.umortality > umort) if (!uwep || g.multi < 0 || u.umortality > umort)
break; break;
} }
/* set up for next time */ /* set up for next time */
@@ -679,10 +679,11 @@ hitum(struct monst *mon, struct attack *uattk)
struct obj *wepbefore = uwep; struct obj *wepbefore = uwep;
int armorpenalty, attknum = 0, int armorpenalty, attknum = 0,
x = u.ux + u.dx, y = u.uy + u.dy, x = u.ux + u.dx, y = u.uy + u.dy,
oldumort = u.umortality,
tmp = find_roll_to_hit(mon, uattk->aatyp, uwep, tmp = find_roll_to_hit(mon, uattk->aatyp, uwep,
&attknum, &armorpenalty); &attknum, &armorpenalty),
int dieroll = rnd(20); dieroll = rnd(20),
int mhit = (tmp > dieroll || u.uswallow); mhit = (tmp > dieroll || u.uswallow);
mon_maybe_wakeup_on_hit(mon); mon_maybe_wakeup_on_hit(mon);
@@ -702,9 +703,13 @@ hitum(struct monst *mon, struct attack *uattk)
(void) passive(mon, uwep, mhit, malive, AT_WEAP, wep_was_destroyed); (void) passive(mon, uwep, mhit, malive, AT_WEAP, wep_was_destroyed);
/* second attack for two-weapon combat; won't occur if Stormbringer /* second attack for two-weapon combat; won't occur if Stormbringer
overrode confirmation (assumes Stormbringer is primary weapon) overrode confirmation (assumes Stormbringer is primary weapon),
or if the monster was killed or knocked to different location */ or if hero became paralyzed by passive counter-attack, or if hero
if (u.twoweap && !g.override_confirmation && malive && m_at(x, y) == mon) { was killed by passive counter-attack and got life-saved, or if
monster was killed or knocked to different location */
if (u.twoweap && !(g.override_confirmation
|| g.multi < 0 || u.umortality > oldumort
|| !malive || m_at(x, y) != mon)) {
tmp = find_roll_to_hit(mon, uattk->aatyp, uswapwep, &attknum, tmp = find_roll_to_hit(mon, uattk->aatyp, uswapwep, &attknum,
&armorpenalty); &armorpenalty);
mon_maybe_wakeup_on_hit(mon); mon_maybe_wakeup_on_hit(mon);