register int disttmp; /* distance modifier */
int otyp = obj->otyp, hmode;
boolean guaranteed_hit = (u.uswallow && mon == u.ustuck);
+ int dieroll;
hmode = (obj == uwep) ? HMON_APPLIED
: (obj == kickedobj) ? HMON_KICKED
return 0;
}
+ dieroll = rnd(20);
+
if (obj->oclass == WEAPON_CLASS || is_weptool(obj)
|| obj->oclass == GEM_CLASS) {
if (hmode == HMON_KICKED) {
tmp += weapon_hit_bonus(obj);
}
- if (tmp >= rnd(20)) {
+ if (tmp >= dieroll) {
boolean wasthrown = (thrownobj != 0);
/* attack hits mon */
if (hmode == HMON_APPLIED)
u.uconduct.weaphit++;
- if (hmon(mon, obj, hmode)) { /* mon still alive */
+ if (hmon(mon, obj, hmode, dieroll)) { /* mon still alive */
cutworm(mon, bhitpos.x, bhitpos.y, obj);
}
exercise(A_DEX, TRUE);
} else if (otyp == HEAVY_IRON_BALL) {
exercise(A_STR, TRUE);
- if (tmp >= rnd(20)) {
+ if (tmp >= dieroll) {
int was_swallowed = guaranteed_hit;
exercise(A_DEX, TRUE);
- if (!hmon(mon, obj, hmode)) { /* mon killed */
+ if (!hmon(mon, obj, hmode, dieroll)) { /* mon killed */
if (was_swallowed && !u.uswallow && obj == uball)
return 1; /* already did placebc() */
}
} else if (otyp == BOULDER) {
exercise(A_STR, TRUE);
- if (tmp >= rnd(20)) {
+ if (tmp >= dieroll) {
exercise(A_DEX, TRUE);
- (void) hmon(mon, obj, hmode);
+ (void) hmon(mon, obj, hmode, dieroll);
} else {
tmiss(obj, mon, TRUE);
}
} else if ((otyp == EGG || otyp == CREAM_PIE || otyp == BLINDING_VENOM
|| otyp == ACID_VENOM)
&& (guaranteed_hit || ACURR(A_DEX) > rnd(25))) {
- (void) hmon(mon, obj, hmode);
+ (void) hmon(mon, obj, hmode, dieroll);
return 1; /* hmon used it up */
} else if (obj->oclass == POTION_CLASS
#include "hack.h"
STATIC_DCL boolean FDECL(known_hitum, (struct monst *, struct obj *, int *,
- int, int, struct attack *));
+ int, int, struct attack *, int));
STATIC_DCL boolean FDECL(theft_petrifies, (struct obj *));
STATIC_DCL void FDECL(steal_it, (struct monst *, struct attack *));
STATIC_DCL boolean FDECL(hitum, (struct monst *, struct attack *));
-STATIC_DCL boolean FDECL(hmon_hitmon, (struct monst *, struct obj *, int));
+STATIC_DCL boolean FDECL(hmon_hitmon, (struct monst *, struct obj *, int,
+ int));
STATIC_DCL int FDECL(joust, (struct monst *, struct obj *));
STATIC_DCL void NDECL(demonpet);
STATIC_DCL boolean FDECL(m_slips_free, (struct monst * mtmp,
STATIC_DCL boolean FDECL(shade_aware, (struct obj *));
extern boolean notonhead; /* for long worms */
-/* The below might become a parameter instead if we use it a lot */
-static int dieroll;
+
/* Used to flag attacks caused by Stormbringer's maliciousness. */
static boolean override_confirmation = FALSE;
/* really hit target monster; returns TRUE if it still lives */
STATIC_OVL boolean
-known_hitum(mon, weapon, mhit, rollneeded, armorpenalty, uattk)
+known_hitum(mon, weapon, mhit, rollneeded, armorpenalty, uattk, dieroll)
register struct monst *mon;
struct obj *weapon;
int *mhit;
int rollneeded, armorpenalty; /* for monks */
struct attack *uattk;
+int dieroll;
{
register boolean malive = TRUE;
/* we hit the monster; be careful: it might die or
be knocked into a different location */
notonhead = (mon->mx != x || mon->my != y);
- malive = hmon(mon, weapon, HMON_MELEE);
+ malive = hmon(mon, weapon, HMON_MELEE, dieroll);
if (malive) {
/* monster still alive */
if (!rn2(25) && mon->mhp < mon->mhpmax / 2
int armorpenalty, attknum = 0, x = u.ux + u.dx, y = u.uy + u.dy,
tmp = find_roll_to_hit(mon, uattk->aatyp, uwep,
&attknum, &armorpenalty);
- int mhit = (tmp > (dieroll = rnd(20)) || u.uswallow);
+ int dieroll = rnd(20);
+ int mhit = (tmp > dieroll || u.uswallow);
if (tmp > dieroll)
exercise(A_DEX, TRUE);
- malive = known_hitum(mon, uwep, &mhit, tmp, armorpenalty, uattk);
+ malive = known_hitum(mon, uwep, &mhit, tmp, armorpenalty, uattk, dieroll);
/* second attack for two-weapon combat; won't occur if Stormbringer
overrode confirmation (assumes Stormbringer is primary weapon)
or if the monster was killed or knocked to different location */
if (u.twoweap && !override_confirmation && malive && m_at(x, y) == mon) {
tmp = find_roll_to_hit(mon, uattk->aatyp, uswapwep, &attknum,
&armorpenalty);
- mhit = (tmp > (dieroll = rnd(20)) || u.uswallow);
- malive = known_hitum(mon, uswapwep, &mhit, tmp, armorpenalty, uattk);
+ dieroll = rnd(20);
+ mhit = (tmp > dieroll || u.uswallow);
+ malive = known_hitum(mon, uswapwep, &mhit, tmp, armorpenalty, uattk,
+ dieroll);
}
if (wepbefore && !uwep)
wep_was_destroyed = TRUE;
/* general "damage monster" routine; return True if mon still alive */
boolean
-hmon(mon, obj, thrown)
+hmon(mon, obj, thrown, dieroll)
struct monst *mon;
struct obj *obj;
int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */
+int dieroll;
{
boolean result, anger_guards;
anger_guards = (mon->mpeaceful
&& (mon->ispriest || mon->isshk || is_watch(mon->data)));
- result = hmon_hitmon(mon, obj, thrown);
+ result = hmon_hitmon(mon, obj, thrown, dieroll);
if (mon->ispriest && !rn2(2))
ghod_hitsu(mon);
if (anger_guards)
/* guts of hmon() */
STATIC_OVL boolean
-hmon_hitmon(mon, obj, thrown)
+hmon_hitmon(mon, obj, thrown, dieroll)
struct monst *mon;
struct obj *obj;
int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */
+int dieroll;
{
int tmp;
struct permonst *mdat = mon->data;
struct obj *weapon;
boolean altwep = FALSE, weapon_used = FALSE;
int i, tmp, armorpenalty, sum[NATTK], nsum = 0, dhit = 0, attknum = 0;
+ int dieroll;
for (i = 0; i < NATTK; i++) {
sum[i] = 0;
altwep = !altwep; /* toggle for next attack */
tmp = find_roll_to_hit(mon, AT_WEAP, weapon, &attknum,
&armorpenalty);
- dhit = (tmp > (dieroll = rnd(20)) || u.uswallow);
+ dieroll = rnd(20);
+ dhit = (tmp > dieroll || u.uswallow);
/* Enemy dead, before any special abilities used */
- if (!known_hitum(mon, weapon, &dhit, tmp, armorpenalty, mattk)) {
+ if (!known_hitum(mon, weapon, &dhit, tmp, armorpenalty, mattk,
+ dieroll)) {
sum[i] = 2;
break;
} else
case AT_TENT:
tmp = find_roll_to_hit(mon, mattk->aatyp, (struct obj *) 0,
&attknum, &armorpenalty);
- dhit = (tmp > (dieroll = rnd(20)) || u.uswallow);
+ dieroll = rnd(20);
+ dhit = (tmp > dieroll || u.uswallow);
if (dhit) {
int compat;