Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -2110,7 +2110,7 @@ E boolean FDECL(attack_checks, (struct monst *,struct obj *));
E void FDECL(check_caitiff, (struct monst *));
E schar FDECL(find_roll_to_hit, (struct monst *));
E boolean FDECL(attack, (struct monst *));
E boolean FDECL(hmon, (struct monst *,struct obj *,int));
E boolean FDECL(hmon, (struct monst *,struct obj *,int,int));
E int FDECL(damageum, (struct monst *,struct attack *));
E void FDECL(missum, (struct monst *,struct attack *));
E int FDECL(passive, (struct monst *,BOOLEAN_P,int,UCHAR_P));
Expand Down
5 changes: 3 additions & 2 deletions src/ball.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,12 @@ boolean allow_drag;
You("are jerked back by the iron ball!");
if ((victim = m_at(uchain->ox, uchain->oy)) != 0) {
int tmp;
int dieroll = rnd(20);

tmp = -2 + Luck + find_mac(victim);
tmp += omon_adj(victim, uball, TRUE);
if (tmp >= rnd(20))
(void) hmon(victim,uball,1);
if (tmp >= dieroll)
(void) hmon(victim,uball,1,dieroll);
else
miss(xname(uball), victim);

Expand Down
3 changes: 2 additions & 1 deletion src/do.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ const char *verb;
if (mtmp) {
if (!passes_walls(mtmp->data) &&
!throws_rocks(mtmp->data)) {
if (hmon(mtmp, obj, TRUE) && !is_whirly(mtmp->data))
int dieroll = rnd(20);
if (hmon(mtmp, obj, TRUE, dieroll) && !is_whirly(mtmp->data))
return FALSE; /* still alive */
}
mtmp->mtrapped = 0;
Expand Down
16 changes: 9 additions & 7 deletions src/dothrow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,7 @@ register struct obj *obj;
register int disttmp; /* distance modifier */
int otyp = obj->otyp;
boolean guaranteed_hit = (u.uswallow && mon == u.ustuck);
int dieroll;

/* Differences from melee weapons:
*
Expand Down Expand Up @@ -1282,6 +1283,7 @@ register struct obj *obj;
return(0);
}

dieroll = rnd(20);
if (obj->oclass == WEAPON_CLASS || is_weptool(obj) ||
obj->oclass == GEM_CLASS) {
if (is_ammo(obj)) {
Expand Down Expand Up @@ -1318,8 +1320,8 @@ register struct obj *obj;
tmp += weapon_hit_bonus(obj);
}

if (tmp >= rnd(20)) {
if (hmon(mon,obj,1)) { /* mon still alive */
if (tmp >= dieroll) {
if (hmon(mon,obj,1,dieroll)) { /* mon still alive */
cutworm(mon, bhitpos.x, bhitpos.y, obj);
}
exercise(A_DEX, TRUE);
Expand Down Expand Up @@ -1355,11 +1357,11 @@ register struct obj *obj;

} 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,1)) { /* mon killed */
if (!hmon(mon,obj,1,dieroll)) { /* mon killed */
if (was_swallowed && !u.uswallow && obj == uball)
return 1; /* already did placebc() */
}
Expand All @@ -1369,17 +1371,17 @@ register struct obj *obj;

} else if (otyp == BOULDER) {
exercise(A_STR, TRUE);
if (tmp >= rnd(20)) {
if (tmp >= dieroll) {
exercise(A_DEX, TRUE);
(void) hmon(mon,obj,1);
(void) hmon(mon,obj,1,dieroll);
} else {
tmiss(obj, mon);
}

} else if ((otyp == EGG || otyp == CREAM_PIE ||
otyp == BLINDING_VENOM || otyp == ACID_VENOM) &&
(guaranteed_hit || ACURR(A_DEX) > rnd(25))) {
(void) hmon(mon, obj, 1);
(void) hmon(mon, obj, 1, dieroll);
return 1; /* hmon used it up */

} else if (obj->oclass == POTION_CLASS &&
Expand Down
32 changes: 18 additions & 14 deletions src/uhitm.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#include "hack.h"

STATIC_DCL boolean FDECL(known_hitum, (struct monst *,int *,struct attack *));
STATIC_DCL boolean FDECL(known_hitum, (struct monst *,int *,struct attack *,int));
STATIC_DCL void FDECL(steal_it, (struct monst *, struct attack *));
STATIC_DCL boolean FDECL(hitum, (struct monst *,int,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));
#ifdef STEED
STATIC_DCL int FDECL(joust, (struct monst *,struct obj *));
#endif
Expand All @@ -22,8 +22,7 @@ STATIC_DCL void FDECL(nohandglow, (struct monst *));
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;

Expand Down Expand Up @@ -427,10 +426,11 @@ register struct monst *mtmp;
}

STATIC_OVL boolean
known_hitum(mon, mhit, uattk) /* returns TRUE if monster still lives */
known_hitum(mon, mhit, uattk, dieroll) /* returns TRUE if monster still lives */
register struct monst *mon;
register int *mhit;
struct attack *uattk;
int dieroll;
{
register boolean malive = TRUE;

Expand All @@ -453,11 +453,11 @@ struct attack *uattk;
/* 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, uwep, 0);
malive = hmon(mon, uwep, 0, dieroll);
/* this assumes that Stormbringer was uwep not uswapwep */
if (malive && u.twoweap && !override_confirmation &&
m_at(x, y) == mon)
malive = hmon(mon, uswapwep, 0);
malive = hmon(mon, uswapwep, 0, dieroll);
if (malive) {
/* monster still alive */
if(!rn2(25) && mon->mhp < mon->mhpmax/2
Expand Down Expand Up @@ -493,38 +493,41 @@ int tmp;
struct attack *uattk;
{
boolean malive;
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, &mhit, uattk);
malive = known_hitum(mon, &mhit, uattk, dieroll);
(void) passive(mon, mhit, malive, AT_WEAP);
return(malive);
}

boolean /* general "damage monster" routine */
hmon(mon, obj, thrown) /* return TRUE if mon still alive */
hmon(mon, obj, thrown, dieroll) /* return TRUE if mon still alive */
struct monst *mon;
struct obj *obj;
int thrown;
int dieroll;
{
boolean result, anger_guards;

anger_guards = (mon->mpeaceful &&
(mon->ispriest || mon->isshk ||
mon->data == &mons[PM_WATCHMAN] ||
mon->data == &mons[PM_WATCH_CAPTAIN]));
result = hmon_hitmon(mon, obj, thrown);
result = hmon_hitmon(mon, obj, thrown, dieroll);
if (mon->ispriest && !rn2(2)) ghod_hitsu(mon);
if (anger_guards) (void)angry_guards(!flags.soundok);
return result;
}

/* 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;
int dieroll;
{
int tmp;
struct permonst *mdat = mon->data;
Expand Down Expand Up @@ -1955,6 +1958,7 @@ register int tmp;
int i, sum[NATTK], hittmp = 0;
int nsum = 0;
int dhit = 0;
int dieroll;

for(i = 0; i < NATTK; i++) {

Expand All @@ -1981,7 +1985,7 @@ register int tmp;
/* KMH -- Don't accumulate to-hit bonuses */
if (uwep) tmp -= hittmp;
/* Enemy dead, before any special abilities used */
if (!known_hitum(mon,&dhit,mattk)) {
if (!known_hitum(mon,&dhit,mattk,dieroll)) {
sum[i] = 2;
break;
} else sum[i] = dhit;
Expand Down Expand Up @@ -2010,7 +2014,7 @@ register int tmp;
case AT_BUTT:
case AT_TENT:
if (i==0 && uwep && (youmonst.data->mlet==S_LICH)) goto use_weapon;
if ((dhit = (tmp > rnd(20) || u.uswallow)) != 0) {
if ((dhit = (tmp > (dieroll = rnd(20)) || u.uswallow)) != 0) {
int compat;

if (!u.uswallow &&
Expand Down