Skip to content

Commit 035f9ac

Browse files
Refactor resists_sick to allow checking racial data
Draugr player monsters weren't resisting sickness because their data corresponds with their role monster. This cannot be circumvented with r_data because one role monster (convict) resists sickness itself. So, make resists_sick() act on the full monst struct instead of just the data pointer.
1 parent ebf0eaa commit 035f9ac

13 files changed

+28
-24
lines changed

doc/evilhack-changelog.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3441,4 +3441,4 @@ The following changes to date are:
34413441
- Merge & use racial_zombie when applicable
34423442
- Fix: makedefs.c merge from last commit
34433443
- Refactor diseasemu() to allow use of racial_zombie()
3444-
3444+
- Refactor resists_sick to allow checking racial data

include/mondata.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#define has_free_action(mon) \
4848
((mon_resistancebits(mon) & MR2_FREE_ACTION) != 0)
4949

50-
#define resists_sick(ptr) \
50+
#define ptr_resists_sick(ptr) \
5151
((ptr)->mlet == S_FUNGUS || nonliving(ptr) \
5252
|| is_angel(ptr) || is_demon(ptr) || is_rider(ptr) \
5353
|| (ptr) == &mons[PM_BABY_GREEN_DRAGON] || (ptr) == &mons[PM_GREEN_DRAGON] \
@@ -57,6 +57,10 @@
5757
|| (ptr) == &mons[PM_AIR_ELEMENTAL] || (ptr) == &mons[PM_EARTH_ELEMENTAL] \
5858
|| (ptr) == &mons[PM_FIRE_ELEMENTAL] || (ptr) == &mons[PM_WATER_ELEMENTAL])
5959

60+
#define resists_sick(mon) \
61+
(ptr_resists_sick((mon)->data) \
62+
|| (has_erac(mon) ? ptr_resists_sick(&mons[ERAC(mon)->rmnum]) : 0))
63+
6064
#define resists_stun(ptr) \
6165
((ptr) == &mons[PM_BABY_SHIMMERING_DRAGON] \
6266
|| (ptr) == &mons[PM_SHIMMERING_DRAGON])

src/artifact.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ struct monst *mtmp;
12921292
: (resists_acid(mtmp) || mon_underwater(mtmp)));
12931293
break;
12941294
case AD_DISE:
1295-
applies += !(yours ? Sick_resistance : resists_sick(ptr));
1295+
applies += !(yours ? Sick_resistance : resists_sick(mtmp));
12961296
break;
12971297
case AD_DETH:
12981298
applies += !(yours ? Death_resistance : immune_death_magic(ptr));
@@ -1375,7 +1375,7 @@ int tmp;
13751375
&& ((yours) ? !(Acid_resistance || Underwater)
13761376
: !(resists_acid(mon) || defended(mon, AD_ACID) || mon_underwater(mon))))
13771377
|| (attacks(adtype = AD_DISE, otmp)
1378-
&& ((yours) ? (!Sick_resistance) : !(resists_sick(mon->data) || defended(mon, AD_DISE))))
1378+
&& ((yours) ? (!Sick_resistance) : !(resists_sick(mon) || defended(mon, AD_DISE))))
13791379
|| (attacks(adtype = AD_DETH, otmp)
13801380
&& ((yours) ? (!Death_resistance) : (!immune_death_magic(mon->data))))
13811381
|| (attacks(adtype = AD_DISN, otmp)
@@ -1408,7 +1408,7 @@ int tmp;
14081408
spec_dbon_applies = FALSE;
14091409
else if ((otmp->oartifact == ART_GRIMTOOTH
14101410
&& !(yours ? Sick_resistance
1411-
: (resists_sick(mon->data) || defended(mon, AD_DISE))))
1411+
: (resists_sick(mon) || defended(mon, AD_DISE))))
14121412
|| otmp->oartifact == ART_VORPAL_BLADE
14131413
|| (otmp->oartifact == ART_ANGELSLAYER
14141414
&& !(yours ? is_demon(raceptr(&youmonst)) : is_demon(mon->data)))
@@ -2180,7 +2180,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */
21802180
Race_if(PM_DROW))
21812181
: racial_drow(mdef);
21822182
boolean no_sick = youdefend ? Sick_resistance
2183-
: (resists_sick(mdef->data)
2183+
: (resists_sick(mdef)
21842184
|| defended(mdef, AD_DISE));
21852185

21862186
if (Role_if(PM_SAMURAI)) {

src/dog.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ register struct obj *obj;
10161016
|| defended(mon, AD_ACID)))
10171017
|| (poisonous(fptr) && !(resists_poison(mon)
10181018
|| defended(mon, AD_DRST)))
1019-
|| (obj->zombie_corpse && !(resists_sick(mptr)
1019+
|| (obj->zombie_corpse && !(resists_sick(mon)
10201020
|| defended(mon, AD_DISE)))
10211021
|| (touch_petrifies(&mons[obj->corpsenm])
10221022
&& !(resists_ston(mon) || defended(mon, AD_STON))))

src/dogmove.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ boolean ranged;
12911291
|| (!ranged && touch_petrifies(mtmp2->data)
12921292
&& !(resists_ston(mtmp) || defended(mtmp, AD_STON)))
12931293
|| (!ranged && mtmp2->data == &mons[PM_GRAY_FUNGUS]
1294-
&& !(resists_sick(mtmp->data) || defended(mtmp, AD_DISE)))
1294+
&& !(resists_sick(mtmp) || defended(mtmp, AD_DISE)))
12951295
|| (!ranged && (mtmp2->data == &mons[PM_BLACK_DRAGON]
12961296
|| mtmp2->data == &mons[PM_ANTIMATTER_VORTEX])
12971297
&& !(resists_disint(mtmp) || defended(mtmp, AD_DISN))));

src/eat.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,10 @@ int *dmg_p; /* for dishing out extra damage in lieu of Int loss */
675675
s_suffix(Monnam(mdef)));
676676
if (*dmg_p < mdef->mhp && racial_zombie(magr)) {
677677
if (visflag && canspotmon(mdef)
678-
&& !(resists_sick(pd) || defended(mdef, AD_DISE)))
678+
&& !(resists_sick(mdef) || defended(mdef, AD_DISE)))
679679
pline("%s looks %s.", Monnam(mdef),
680680
mdef->msick ? "much worse" : "rather ill");
681-
if (resists_sick(pd) || defended(mdef, AD_DISE))
681+
if (resists_sick(mdef) || defended(mdef, AD_DISE))
682682
return MM_MISS;
683683
mdef->msick = (can_become_zombie(r_data(mdef))) ? 3 : 1;
684684
}

src/mhitm.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -2294,7 +2294,7 @@ struct obj **ootmp; /* to return worn armor for caller to disintegrate */
22942294
}
22952295
break;
22962296
case AD_DISE:
2297-
if (resists_sick(pd) || defended(mdef, AD_DISE)) {
2297+
if (resists_sick(mdef) || defended(mdef, AD_DISE)) {
22982298
if (vis && canseemon(mdef))
22992299
pline("%s resists infection.", Monnam(mdef));
23002300
tmp = 0;
@@ -2329,7 +2329,7 @@ struct obj **ootmp; /* to return worn armor for caller to disintegrate */
23292329
break;
23302330
}
23312331
if (racial_zombie(magr) && rn2(5)) {
2332-
if (!(resists_sick(pd) || defended(mdef, AD_DISE))) {
2332+
if (!(resists_sick(mdef) || defended(mdef, AD_DISE))) {
23332333
if (vis && canspotmon(mdef))
23342334
pline("%s looks %s.", Monnam(mdef),
23352335
mdef->msick ? "much worse" : "rather ill");
@@ -2410,7 +2410,7 @@ struct obj **ootmp; /* to return worn armor for caller to disintegrate */
24102410
case AD_PEST:
24112411
Strcpy(buf, mon_nam(mdef));
24122412
if (vis) {
2413-
if (resists_sick(pd) || defended(mdef, AD_DISE)) {
2413+
if (resists_sick(mdef) || defended(mdef, AD_DISE)) {
24142414
if (canseemon(mdef))
24152415
pline("%s reaches out, but %s looks unaffected.",
24162416
Monnam(magr), buf);
@@ -2426,7 +2426,7 @@ struct obj **ootmp; /* to return worn armor for caller to disintegrate */
24262426
if (mdef->mhp > mdef->mhpmax)
24272427
mdef->mhp = mdef->mhpmax;
24282428
msickness:
2429-
if (resists_sick(pd) || defended(mdef, AD_DISE))
2429+
if (resists_sick(mdef) || defended(mdef, AD_DISE))
24302430
break;
24312431
if (mdef->msicktime)
24322432
mdef->msicktime -= rnd(3);
@@ -3451,7 +3451,7 @@ struct obj *mwep;
34513451
pline("%s is suddenly very hot!", Monnam(magr));
34523452
break;
34533453
case AD_DISE:
3454-
if (resists_sick(madat) || defended(magr, AD_DISE)) {
3454+
if (resists_sick(magr) || defended(magr, AD_DISE)) {
34553455
if (canseemon(magr))
34563456
pline("%s resists infection.", Monnam(magr));
34573457
tmp = 0;

src/mhitu.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4726,7 +4726,7 @@ struct attack *mattk;
47264726
tmp = 0;
47274727
break;
47284728
case AD_DISE: /* gray fungus */
4729-
if (resists_sick(mtmp->data) || defended(mtmp, AD_DISE)) {
4729+
if (resists_sick(mtmp) || defended(mtmp, AD_DISE)) {
47304730
if (canseemon(mtmp))
47314731
pline("%s resists infection.", Monnam(mtmp));
47324732
tmp = 0;

src/mon.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ mcalcdistress()
11841184

11851185
/* sick monsters can die from their illness */
11861186
if (mtmp->msick && mtmp->msicktime <= 1) {
1187-
if (resists_sick(mtmp->data) || defended(mtmp, AD_DISE)) {
1187+
if (resists_sick(mtmp) || defended(mtmp, AD_DISE)) {
11881188
mtmp->msick = 0;
11891189
} else {
11901190
if (canseemon(mtmp))
@@ -1214,7 +1214,7 @@ mcalcdistress()
12141214

12151215
/* diseased monsters can die as well... */
12161216
if (mtmp->mdiseased && mtmp->mdiseasetime <= 1) {
1217-
if (resists_sick(mtmp->data) || defended(mtmp, AD_DISE)) {
1217+
if (resists_sick(mtmp) || defended(mtmp, AD_DISE)) {
12181218
mtmp->mdiseased = 0;
12191219
} else {
12201220
if (canseemon(mtmp))

src/pager.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ struct permonst * pm;
874874
ADDRESIST(pm_resistance(pm, MR_STONE), "petrification");
875875
ADDRESIST(pm_resistance(pm, MR_PSYCHIC), "psionic attacks");
876876
ADDRESIST(resists_drain(pm), "life-drain");
877-
ADDRESIST(resists_sick(pm), "sickness");
877+
ADDRESIST(ptr_resists_sick(pm), "sickness");
878878
ADDRESIST(resists_mgc(pm), "magic");
879879
ADDRESIST(resists_stun(pm), "stun");
880880
ADDRESIST(resists_slow(pm), "slow");

src/polyself.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ set_uasmon()
7373
PROPSET(VULN_ACID, vulnerable_to(&youmonst, AD_ACID));
7474

7575
PROPSET(ANTIMAGIC, resists_mgc(mdat));
76-
PROPSET(SICK_RES, resists_sick(mdat));
76+
PROPSET(SICK_RES, ptr_resists_sick(mdat));
7777
PROPSET(DEATH_RES, immune_death_magic(racedat));
7878

7979
PROPSET(STUNNED, (mdat == &mons[PM_STALKER] || is_bat(mdat)));

src/read.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3331,12 +3331,12 @@ struct _create_particular_data *d;
33313331
unblock_point(mx, my);
33323332
}
33333333
if (d->sick
3334-
&& !(resists_sick(mtmp->data) || defended(mtmp, AD_DISE))) {
3334+
&& !(resists_sick(mtmp) || defended(mtmp, AD_DISE))) {
33353335
mtmp->msick = 1;
33363336
mtmp->msicktime = rn1(9, 6);
33373337
}
33383338
if (d->diseased
3339-
&& !(resists_sick(mtmp->data) || defended(mtmp, AD_DISE))) {
3339+
&& !(resists_sick(mtmp) || defended(mtmp, AD_DISE))) {
33403340
mtmp->mdiseased = 1;
33413341
mtmp->mdiseasetime = rn1(9, 6);
33423342
}

src/uhitm.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3236,7 +3236,7 @@ int specialdmg; /* blessed and/or silver bonus against various things */
32363236
}
32373237
break;
32383238
case AD_DISE:
3239-
if (!(resists_sick(pd) || defended(mdef, AD_DISE))) {
3239+
if (!(resists_sick(mdef) || defended(mdef, AD_DISE))) {
32403240
if (mdef->mdiseasetime)
32413241
mdef->mdiseasetime -= rnd(3);
32423242
else
@@ -3254,7 +3254,7 @@ int specialdmg; /* blessed and/or silver bonus against various things */
32543254

32553255
if (((!Upolyd && Race_if(PM_DRAUGR))
32563256
|| is_zombie(youmonst.data)) && rn2(5)) {
3257-
if (!(resists_sick(pd) || defended(mdef, AD_DISE))) {
3257+
if (!(resists_sick(mdef) || defended(mdef, AD_DISE))) {
32583258
if (mdef->msicktime)
32593259
mdef->msicktime -= rnd(3);
32603260
else

0 commit comments

Comments
 (0)