-/* NetHack 3.6 uhitm.c $NHDT-Date: 1548209742 2019/01/23 02:15:42 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.203 $ */
+/* NetHack 3.6 uhitm.c $NHDT-Date: 1553644725 2019/03/26 23:58:45 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.206 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
if (!*mhit) {
missum(mon, uattk, (rollneeded + armorpenalty > dieroll));
} else {
- int oldhp = mon->mhp, x = u.ux + u.dx, y = u.uy + u.dy;
+ int oldhp = mon->mhp;
long oldweaphit = u.uconduct.weaphit;
/* KMH, conduct */
/* we hit the monster; be careful: it might die or
be knocked into a different location */
- notonhead = (mon->mx != x || mon->my != y);
+ notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y);
malive = hmon(mon, weapon, HMON_MELEE, dieroll);
if (malive) {
/* monster still alive */
u.uconduct.weaphit = oldweaphit;
}
if (mon->wormno && *mhit)
- cutworm(mon, x, y, slice_or_chop);
+ cutworm(mon, bhitpos.x, bhitpos.y, slice_or_chop);
}
}
return malive;
simulation attempt a bit */
static boolean clockwise = FALSE;
unsigned i;
+ coord save_bhitpos;
int count, umort, x = u.ux, y = u.uy;
/* find the direction toward primary target */
to primary target */
i = (i + (clockwise ? 6 : 2)) % 8;
umort = u.umortality; /* used to detect life-saving */
+ save_bhitpos = bhitpos;
/*
* Three attacks: adjacent to primary, primary, adjacent on other
&attknum, &armorpenalty);
dieroll = rnd(20);
mhit = (tmp > dieroll);
+ bhitpos.x = tx, bhitpos.y = ty; /* normally set up by attack() */
(void) known_hitum(mtmp, uwep, &mhit, tmp, armorpenalty,
uattk, dieroll);
(void) passive(mtmp, uwep, mhit, !DEADMONSTER(mtmp), AT_WEAP, !uwep);
}
/* set up for next time */
clockwise = !clockwise; /* alternate */
+ bhitpos = save_bhitpos; /* in case somebody relies on bhitpos
+ * designating the primary target */
/* return False if primary target died, True otherwise; note: if 'target'
was nonNull upon entry then it's still nonNull even if *target died */
if (tmp > dieroll)
exercise(A_DEX, TRUE);
+ /* bhitpos is set up by caller */
malive = known_hitum(mon, uwep, &mhit, tmp, armorpenalty, uattk, dieroll);
if (wepbefore && !uwep)
wep_was_destroyed = TRUE;
struct attack *mattk, alt_attk;
struct obj *weapon, **originalweapon;
boolean altwep = FALSE, weapon_used = FALSE, odd_claw = TRUE;
- int i, tmp, armorpenalty, sum[NATTK] = { 0 }, nsum = 0, dhit = 0, attknum = 0;
+ int i, tmp, armorpenalty, sum[NATTK], nsum = 0, dhit = 0, attknum = 0;
int dieroll, multi_claw = 0;
/* with just one touch/claw/weapon attack, both rings matter;
with more than one, alternate right and left when checking
whether silver ring causes successful hit */
for (i = 0; i < NATTK; i++) {
+ sum[i] = 0;
mattk = getmattk(&youmonst, mon, i, sum, &alt_attk);
if (mattk->aatyp == AT_WEAP
|| mattk->aatyp == AT_CLAW || mattk->aatyp == AT_TUCH)
multi_claw = (multi_claw > 1); /* switch from count to yes/no */
for (i = 0; i < NATTK; i++) {
- sum[i] = 0;
+ /* sum[i] = 0; -- now done above */
mattk = getmattk(&youmonst, mon, i, sum, &alt_attk);
weapon = 0;
switch (mattk->aatyp) {
&armorpenalty);
dieroll = rnd(20);
dhit = (tmp > dieroll || u.uswallow);
+ /* caller must set bhitpos */
if (!known_hitum(mon, weapon, &dhit, tmp,
armorpenalty, mattk, dieroll)) {
/* enemy dead, before any special abilities used */