Addressing bug with the use of static dieroll in uhitm.c.

This commit is contained in:
Bart House
2017-09-24 23:24:36 -07:00
committed by Pasi Kallinen
parent d51f74a507
commit 78756c9bd6
5 changed files with 43 additions and 27 deletions

View File

@@ -1386,6 +1386,7 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */
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
@@ -1493,6 +1494,8 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */
return 0;
}
dieroll = rnd(20);
if (obj->oclass == WEAPON_CLASS || is_weptool(obj)
|| obj->oclass == GEM_CLASS) {
if (hmode == HMON_KICKED) {
@@ -1533,13 +1536,13 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */
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);
@@ -1585,11 +1588,11 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */
} 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() */
}
@@ -1599,9 +1602,9 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */
} 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);
}
@@ -1609,7 +1612,7 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */
} 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