Skip to content

Commit

Permalink
Refactored sickness resistance into an MR_SICK flag for monsters.
Browse files Browse the repository at this point in the history
Side note: This also removed sickness resistance for vampires. The vampiric race starts without sickness resistance, so this makes it a bit more fair to the players' side. High level vampires like Vlad or the Nosferatu will still have sickness immunity though.
  • Loading branch information
elunna committed Oct 8, 2023
1 parent 9fcff5a commit 55c2404
Show file tree
Hide file tree
Showing 13 changed files with 296 additions and 255 deletions.
20 changes: 1 addition & 19 deletions include/mondata.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#define resists_psychic(mon) ((mon_resistancebits(mon) & MR_PSYCHIC) != 0)
#define resists_clob(mon) ((mon_resistancebits(mon) & MR_CLOB) != 0)
#define resists_drain(mon) ((mon_resistancebits(mon) & MR_DRAIN) != 0)
#define resists_sick(mon) ((mon_resistancebits(mon) & MR_SICK) != 0)

#define has_telepathy(mon) \
(telepathic(r_data(mon)) \
Expand All @@ -51,25 +52,6 @@
#define has_free_action(mon) \
((mon_resistancebits(mon) & MR2_FREE_ACTION) != 0)

#define resists_sick(ptr) \
((ptr)->mlet == S_FUNGUS \
|| nonliving(ptr) \
|| is_angel(ptr) \
|| is_demon(ptr) \
|| is_rider(ptr) \
|| is_elemental(ptr) \
|| (ptr) == &mons[PM_BABY_GOLD_DRAGON] \
|| (ptr) == &mons[PM_CONVICT] \
|| (ptr) == &mons[PM_GIANT_LEECH] \
|| (ptr) == &mons[PM_GIANT_COCKROACH]\
|| (ptr) == &mons[PM_GOLD_DRAGON] \
|| (ptr) == &mons[PM_GRAY_FUNGUS] \
|| (ptr) == &mons[PM_GRAY_MOLDIER] \
|| (ptr) == &mons[PM_JUGGERNAUT] \
|| (ptr) == &mons[PM_LOCUST] \
|| (ptr) == &mons[PM_GRUND_THE_ORC_KING] \
|| (ptr) == &mons[PM_MARRASHI])

#define resists_slow(ptr) \
((ptr) == &mons[PM_BABY_BLUE_DRAGON] \
|| (ptr) == &mons[PM_BLUE_DRAGON])
Expand Down
23 changes: 12 additions & 11 deletions include/monflag.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,23 @@
#define MR_CLOB 0x00000200L /* resists knockback */
#define MR_SONIC 0x00000400L /* resists sonic */
#define MR_DRAIN 0x00000800L /* resists life-drain */
#define MR_SICK 0x00001000L /* resists sickness */

/* other resistances: magic, sickness */
/* other conveyances: teleport, teleport control, telepathy */

/* individual resistances */
#define MR2_SEE_INVIS 0x00001000L /* see invisible */
#define MR2_LEVITATE 0x00002000L /* levitation */
#define MR2_WATERWALK 0x00004000L /* water walking */
#define MR2_MAGBREATH 0x00008000L /* magical breathing */
#define MR2_DISPLACED 0x00010000L /* displaced */
#define MR2_STRENGTH 0x00020000L /* gauntlets of power */
#define MR2_FUMBLING 0x00040000L /* clumsy */
#define MR2_TELEPATHY 0x00080000L /* telepathic */
#define MR2_JUMPING 0x00100000L /* can jump */
#define MR2_REFLECTION 0x00200000L /* has reflection */
#define MR2_FREE_ACTION 0x00400000L /* has free action */
#define MR2_SEE_INVIS 0x00002000L/* see invisible */
#define MR2_LEVITATE 0x00004000L /* levitation */
#define MR2_WATERWALK 0x00008000L /* water walking */
#define MR2_MAGBREATH 0x00010000L /* magical breathing */
#define MR2_DISPLACED 0x00020000L /* displaced */
#define MR2_STRENGTH 0x00040000L /* gauntlets of power */
#define MR2_FUMBLING 0x00080000L /* clumsy */
#define MR2_TELEPATHY 0x00100000L /* telepathic */
#define MR2_JUMPING 0x00200000L /* can jump */
#define MR2_REFLECTION 0x00400000L /* has reflection */
#define MR2_FREE_ACTION 0x00800000L /* has free action */

#define M1_FLY 0x00000001L /* can fly or float */
#define M1_SWIM 0x00000002L /* can traverse water */
Expand Down
8 changes: 4 additions & 4 deletions src/artifact.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ struct monst *mtmp;
case AD_WIND:
return !(yours ? (Stable && bigmonst(youmonst.data) ) : !bigmonst(mtmp->data));
case AD_DISE:
return !(yours ? Sick_resistance : resists_sick(ptr));
return !(yours ? Sick_resistance : resists_sick(mtmp));
case AD_DETH:
return !(yours ? Death_resistance : immune_death_magic(ptr));
case AD_DISN:
Expand Down Expand Up @@ -1407,7 +1407,7 @@ int tmp;
|| (attacks(adtype = AD_LOUD, otmp)
&& ((yours) ? (!Sonic_resistance) : (!resists_sonic(mon))))
|| (attacks(adtype = AD_DISE, otmp)
&& ((yours) ? (!Sick_resistance) : (!resists_sick(mon->data))))
&& ((yours) ? (!Sick_resistance) : (!resists_sick(mon))))
|| (attacks(adtype = AD_DETH, otmp)
&& ((yours) ? (!Death_resistance) : (!immune_death_magic(mon->data))))
|| (attacks(adtype = AD_DISN, otmp)
Expand Down Expand Up @@ -1438,7 +1438,7 @@ int tmp;
&& weap->attk.damn == 0 && weap->attk.damd == 0))
spec_dbon_applies = FALSE;
else if ((otmp->oartifact == ART_GRIMTOOTH
&& !(yours ? Sick_resistance : resists_sick(mon->data)))
&& !(yours ? Sick_resistance : resists_sick(mon)))
|| otmp->oartifact == ART_VORPAL_BLADE
|| otmp->oartifact == ART_MASTER_SWORD
|| otmp->oartifact == ART_STAKE_OF_VAN_HELSING
Expand Down Expand Up @@ -2252,7 +2252,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */
Race_if(PM_ELF))
: racial_elf(mdef);
boolean no_sick = youdefend ? Sick_resistance
: (resists_sick(mdef->data)
: (resists_sick(mdef)
|| defended(mdef, AD_DISE));

if (Role_if(PM_SAMURAI)) {
Expand Down
2 changes: 1 addition & 1 deletion src/dog.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ register struct obj *obj;
|| defended(mon, AD_ACID)))
|| (poisonous(fptr) && !(resists_poison(mon)
|| defended(mon, AD_DRST)))
|| (obj->zombie_corpse && !(resists_sick(mptr)
|| (obj->zombie_corpse && !(resists_sick(mon)
|| defended(mon, AD_DISE)))
|| (touch_petrifies(&mons[obj->corpsenm])
&& !(resists_ston(mon) || defended(mon, AD_STON))))
Expand Down
2 changes: 1 addition & 1 deletion src/dogmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ boolean ranged;
&& !(resists_ston(mtmp) || defended(mtmp, AD_STON)))
|| (!ranged && (mtmp2->data == &mons[PM_GRAY_FUNGUS]
|| mtmp2->data == &mons[PM_GRAY_MOLDIER])
&& !(resists_sick(mtmp->data) || defended(mtmp, AD_DISE))));
&& !(resists_sick(mtmp) || defended(mtmp, AD_DISE))));
}


Expand Down
4 changes: 2 additions & 2 deletions src/eat.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,10 @@ int *dmg_p; /* for dishing out extra damage in lieu of Int loss */
s_suffix(Monnam(mdef)));
if (*dmg_p < mdef->mhp && is_zombie(magr->data)) {
if (visflag && canspotmon(mdef)
&& !(resists_sick(pd) || defended(mdef, AD_DISE)))
&& !(resists_sick(mdef) || defended(mdef, AD_DISE)))
pline("%s looks %s.", Monnam(mdef),
mdef->msick ? "much worse" : "rather ill");
if (resists_sick(pd) || defended(mdef, AD_DISE))
if (resists_sick(mdef) || defended(mdef, AD_DISE))
return MM_MISS;
mdef->msick = (can_become_zombie(r_data(mdef))) ? 3 : 1;
}
Expand Down
10 changes: 5 additions & 5 deletions src/mhitm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2366,7 +2366,7 @@ struct obj **ootmp; /* to return worn armor for caller to disintegrate */
}
break;
case AD_DISE:
if (resists_sick(pd) || defended(mdef, AD_DISE)) {
if (resists_sick(mdef) || defended(mdef, AD_DISE)) {
if (vis && canseemon(mdef))
pline("%s resists infection.", Monnam(mdef));
tmp = 0;
Expand Down Expand Up @@ -2405,7 +2405,7 @@ struct obj **ootmp; /* to return worn armor for caller to disintegrate */
break;
}
if (is_zombie(pa) && rn2(5)) {
if (!(resists_sick(pd) || defended(mdef, AD_DISE))) {
if (!(resists_sick(mdef) || defended(mdef, AD_DISE))) {
if (vis && canspotmon(mdef))
pline("%s looks %s.", Monnam(mdef),
mdef->msick ? "much worse" : "rather ill");
Expand Down Expand Up @@ -2479,7 +2479,7 @@ struct obj **ootmp; /* to return worn armor for caller to disintegrate */
case AD_PEST:
Strcpy(buf, mon_nam(mdef));
if (vis) {
if (resists_sick(pd) || defended(mdef, AD_DISE)) {
if (resists_sick(mdef) || defended(mdef, AD_DISE)) {
if (canseemon(mdef))
pline("%s reaches out, but %s looks unaffected.",
Monnam(magr), buf);
Expand All @@ -2495,7 +2495,7 @@ struct obj **ootmp; /* to return worn armor for caller to disintegrate */
if (mdef->mhp > mdef->mhpmax)
mdef->mhp = mdef->mhpmax;
msickness:
if (resists_sick(pd) || defended(mdef, AD_DISE))
if (resists_sick(mdef) || defended(mdef, AD_DISE))
break;
if (mdef->msicktime)
mdef->msicktime -= rnd(3);
Expand Down Expand Up @@ -3661,7 +3661,7 @@ struct obj *mwep;
pline("%s is suddenly very hot!", Monnam(magr));
break;
case AD_DISE:
if (resists_sick(madat) || defended(magr, AD_DISE)) {
if (resists_sick(magr) || defended(magr, AD_DISE)) {
if (canseemon(magr))
pline("%s resists infection.", Monnam(magr));
tmp = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ mcalcdistress()

/* sick monsters can die from their illness */
if (mtmp->msick && mtmp->msicktime <= 1) {
if (resists_sick(mtmp->data) || defended(mtmp, AD_DISE)) {
if (resists_sick(mtmp) || defended(mtmp, AD_DISE)) {
mtmp->msick = 0;
} else {
if (canseemon(mtmp))
Expand Down Expand Up @@ -1408,7 +1408,7 @@ mcalcdistress()

/* diseased monsters can die as well... */
if (mtmp->mdiseased && mtmp->mdiseasetime <= 1) {
if (resists_sick(mtmp->data) || defended(mtmp, AD_DISE)) {
if (resists_sick(mtmp) || defended(mtmp, AD_DISE)) {
mtmp->mdiseased = 0;
} else {
if (canseemon(mtmp))
Expand Down
Loading

0 comments on commit 55c2404

Please sign in to comment.