fix resistance breakage

The Mitre of Holiness commit broke resistance handling.  This seems
to work correctly.
This commit is contained in:
PatR
2025-02-03 23:20:07 -08:00
parent a311f4b467
commit b44a547153
2 changed files with 22 additions and 23 deletions

View File

@@ -268,14 +268,14 @@ struct monst {
#endif
#define mon_resistancebits(mon) \
((mon)->data->mresists | (mon)->mextrinsics | (mon)->mintrinsics)
#define resists_fire(mon) Resists_Elem(mon, MR_FIRE)
#define resists_cold(mon) Resists_Elem(mon, MR_COLD)
#define resists_sleep(mon) Resists_Elem(mon, MR_SLEEP)
#define resists_disint(mon) Resists_Elem(mon, MR_DISINT)
#define resists_elec(mon) Resists_Elem(mon, MR_ELEC)
#define resists_poison(mon) Resists_Elem(mon, MR_POISON)
#define resists_acid(mon) Resists_Elem(mon, MR_ACID)
#define resists_ston(mon) Resists_Elem(mon, MR_STONE)
#define resists_fire(mon) Resists_Elem(mon, FIRE_RES)
#define resists_cold(mon) Resists_Elem(mon, COLD_RES)
#define resists_sleep(mon) Resists_Elem(mon, SLEEP_RES)
#define resists_disint(mon) Resists_Elem(mon, DISINT_RES)
#define resists_elec(mon) Resists_Elem(mon, SHOCK_RES)
#define resists_poison(mon) Resists_Elem(mon, POISON_RES)
#define resists_acid(mon) Resists_Elem(mon, ACID_RES)
#define resists_ston(mon) Resists_Elem(mon, STONE_RES)
#define is_lminion(mon) \
(is_minion((mon)->data) && mon_aligntyp(mon) == A_LAWFUL)

View File

@@ -126,24 +126,24 @@ defended(struct monst *mon, int adtyp)
/* returns True if monster resists particular elemental damage; mostly used
in order to check effects of carried artifacts */
boolean
Resists_Elem(struct monst *mon, int restyp)
Resists_Elem(struct monst *mon, int proptyp)
{
struct obj *o;
long slotmask;
boolean is_you = (mon == &gy.youmonst);
int u_resist, dmgtyp = 0, proptyp = 0;
int u_resist = 0, dmgtyp = 0, restyp = 0;
switch (restyp) {
case MR_FIRE:
case MR_COLD:
case MR_SLEEP:
case MR_DISINT:
case MR_ELEC:
case MR_POISON:
case MR_ACID:
case MR_STONE:
dmgtyp = restyp;
proptyp = dmgtyp - 1; /* valid for dmgtyp|restyp 2..9 */
switch (proptyp) {
case FIRE_RES:
case COLD_RES:
case SLEEP_RES:
case DISINT_RES:
case SHOCK_RES:
case POISON_RES:
case ACID_RES:
case STONE_RES:
dmgtyp = restyp = proptyp + 1; /* valid for dmgtyp|restyp 2..9 */
u_resist = u.uprops[proptyp].intrinsic || u.uprops[proptyp].extrinsic;
break;
/* accept these, but we expect callers to use their routines directly */
@@ -155,10 +155,9 @@ Resists_Elem(struct monst *mon, int restyp)
return resists_blnd(mon);
default:
impossible("Resists_Elem(%d), unexpected resistance type", restyp);
impossible("Resists_Elem(%d), unexpected property type", proptyp);
return FALSE;
}
u_resist = u.uprops[restyp].intrinsic || u.uprops[restyp].extrinsic;
if (is_you ? u_resist : ((mon_resistancebits(mon) & restyp) != 0))
return TRUE;