Skip to content

Commit

Permalink
barthouse dieroll fix from 3.6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
NHTangles committed Sep 27, 2017
1 parent 3451f08 commit 0f79621
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion include/extern.h
Expand Up @@ -2120,7 +2120,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
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
Expand Up @@ -157,7 +157,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
Expand Up @@ -1287,6 +1287,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 @@ -1380,6 +1381,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 @@ -1416,8 +1418,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 @@ -1453,11 +1455,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 @@ -1467,17 +1469,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
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));
STATIC_DCL void FDECL(noisy_hit,(struct monst*,struct obj*,int));
#ifdef STEED
STATIC_DCL int FDECL(joust, (struct monst *,struct obj *));
Expand All @@ -23,8 +23,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 @@ -436,10 +435,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 @@ -462,11 +462,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 @@ -502,19 +502,21 @@ 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;

Expand All @@ -527,7 +529,7 @@ int thrown;
noisy_hit(mon,obj,thrown);

/* go ahead and 'hit' the monster */
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);
Expand All @@ -537,10 +539,11 @@ int thrown;

/* 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 @@ -2088,6 +2091,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 @@ -2112,7 +2116,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 @@ -2141,7 +2145,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

0 comments on commit 0f79621

Please sign in to comment.