Skip to content

Commit

Permalink
Fix: Clashes with acid/sonic resistance and vulnerability to those re…
Browse files Browse the repository at this point in the history
…sistances.

I found it was possible to have acid resistance and vulnerability to acid, but not take any acid damage at all. I think this goes against the purpose of the vulnerability mechanic so I updated all the Acid/Sonic resistance checks with how_resistant - using 50 as the baseline. These resistances are not partial, so we can only really use 50 anyway. If a player has acid resistance and is vulnerable, their "effective" resistance is 50.

This commit may require a followup to make sure any updates have corresponding resist_reduce usage to prevent full blast where perhaps 50% is warranted.
  • Loading branch information
elunna committed Oct 6, 2023
1 parent 59a6f33 commit 7a6a648
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/artifact.c
Original file line number Diff line number Diff line change
Expand Up @@ -2308,7 +2308,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */
}
/* Eighth basic attack - disintegration */
if (attacks(AD_DISN, otmp)) {
boolean resistant = youdefend ? how_resistant(DISINT_RES) >= 50
boolean resistant = youdefend ? how_resistant(DISINT_RES) > 50
: (resists_disint(mdef)
|| defended(mdef, AD_DISN));
if (!rn2(12) && !resistant) {
Expand Down
4 changes: 4 additions & 0 deletions src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3332,24 +3332,28 @@ int final;
if (EFire_resistance)
enl_msg("Your items ", "are", "were", " protected from fire",
from_what(AD_FIRE));

Sprintf(buf, "%d%% cold resistant", how_resistant(COLD_RES));
if (Cold_resistance)
you_are(buf, "");
if (ECold_resistance)
enl_msg("Your items ", "are", "were", " protected from cold",
from_what(AD_COLD));

Sprintf(buf, "%d%% sleep resistant", how_resistant(SLEEP_RES));
if (Sleep_resistance)
you_are(buf, "");
Sprintf(buf, "%d%% disintegration resistant", how_resistant(DISINT_RES));
if (Disint_resistance)
you_are(buf, "");

Sprintf(buf, "%d%% shock resistant", how_resistant(SHOCK_RES));
if (Shock_resistance)
you_are(buf, "");
if (EShock_resistance)
enl_msg("Your items ", "are", "were", " protected from shock",
from_what(AD_ELEC));

Sprintf(buf, "%d%% poison resistant", how_resistant(POISON_RES));
if (Poison_resistance)
you_are(buf, "");
Expand Down
2 changes: 1 addition & 1 deletion src/dokick.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ xchar x, y;
if (Role_if(PM_MONK)
&& (Race_if(PM_CENTAUR) || Race_if(PM_TORTLE))
&& (touch_petrifies(mon->data)
|| (how_resistant(DISINT_RES) <= 49
|| (how_resistant(DISINT_RES) < 50
&& (mon->data == &mons[PM_BLACK_DRAGON]
|| mon->data == &mons[PM_ANTIMATTER_VORTEX]))))
return;
Expand Down
4 changes: 2 additions & 2 deletions src/eat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ struct obj *otmp;
} else if (youmonst.data == &mons[PM_GHOUL] || youmonst.data == &mons[PM_GHAST]) {
pline ("This corpse is too fresh!");
return 3;
} else if (acidic(&mons[mnum]) && !Acid_resistance) {
} else if (acidic(&mons[mnum]) && how_resistant(ACID_RES) < 50) {
tp++;
You("have a very bad case of stomach acid."); /* not body_part() */
losehp(rnd(15), !glob ? "acidic corpse" : "acidic glob",
Expand Down Expand Up @@ -2986,7 +2986,7 @@ struct obj *otmp;
else
return 2;
}
if (cadaver && acidic(&mons[mnum]) && !Acid_resistance) {
if (cadaver && acidic(&mons[mnum]) && how_resistant(ACID_RES) < 50) {
Sprintf(buf, "%s rather acidic. %s", foodsmell, eat_it_anyway);
if (yn_function(buf, ynchars, 'n') == 'n')
return 1;
Expand Down
4 changes: 2 additions & 2 deletions src/explode.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ int expltype;
explmask[i][j] = (how_resistant(POISON_RES) > 50);
break;
case AD_ACID:
explmask[i][j] = !!Acid_resistance;
explmask[i][j] = (how_resistant(ACID_RES) > 50);
physical_dmg = TRUE;
break;
case AD_LOUD:
explmask[i][j] = !!Sonic_resistance;
explmask[i][j] = (how_resistant(SONIC_RES) > 50);
physical_dmg = TRUE;
break;
default:
Expand Down
32 changes: 17 additions & 15 deletions src/mhitu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2435,7 +2435,7 @@ register struct attack *mattk;
case AD_ACID:
hitmsg(mtmp, mattk);
if (!mtmp->mcan && !rn2(3))
if (Acid_resistance || Underwater) {
if (how_resistant(ACID_RES) > 50 || Underwater) {
pline("You're covered in %s, but it seems harmless.",
hliquid("acid"));
monstseesu(M_SEEN_ACID);
Expand Down Expand Up @@ -3061,7 +3061,7 @@ struct attack *mattk;
water_damage_chain(invent, FALSE, rnd(3), FALSE, u.ux, u.uy);
break;
case AD_ACID:
if (Acid_resistance) {
if (how_resistant(ACID_RES) > 50) {
You("are covered with a seemingly harmless goo.");
monstseesu(M_SEEN_ACID);
tmp = 0;
Expand Down Expand Up @@ -3173,7 +3173,7 @@ struct attack *mattk;
You_feel("mildly tickled.");
tmp = 0;
break;
} else if (how_resistant(DISINT_RES) >= 50) {
} else if (how_resistant(DISINT_RES) > 50) {
You("aren't disintegrated, but that hurts!");
tmp = resist_reduce(tmp, DISINT_RES);
if (tmp)
Expand Down Expand Up @@ -3431,7 +3431,7 @@ struct attack *mattk;
if (u.usleep)
unmul("You are frightened awake!");
}
if (Sonic_resistance)
if (how_resistant(SONIC_RES) > 50)
break; /* No inventory damage! */
if (!Stun_resistance) {
if (!Stunned)
Expand All @@ -3445,6 +3445,8 @@ struct attack *mattk;

/* being deaf won't protect objects in inventory,
or being made of glass */
if (ESonic_resistance)
break;
if (!rn2(6))
erode_armor(&youmonst, ERODE_FRACTURE);
if (!rn2(5))
Expand Down Expand Up @@ -3479,7 +3481,7 @@ struct attack *mattk;
if (u.usleep && m_canseeu(mtmp)) {
unmul("What a horrible nightmare! You wake up!");
}
if (Sonic_resistance)
if (how_resistant(SONIC_RES) > 50)
break;
if (Fearless) {
You("are not afraid.");
Expand All @@ -3501,7 +3503,7 @@ struct attack *mattk;
if (u.usleep)
unmul("You are frightened awake!");
}
if (Sonic_resistance)
if (how_resistant(SONIC_RES) > 50)
break; /* No inventory damage! */
Your("mind reels from the noise!");
make_stunned((HStun & TIMEOUT) + (long) (dmg / 2), TRUE);
Expand All @@ -3516,7 +3518,7 @@ struct attack *mattk;
else
You("dream of singing angels...");

if (Sonic_resistance)
if (how_resistant(SONIC_RES) > 50)
break; /* No inventory damage! */
/* Copied from AD_PLYS code */
if (multi >= 0 && !rn2(3)) {
Expand Down Expand Up @@ -3553,7 +3555,7 @@ struct attack *mattk;
if (m_canseeu(mtmp))
pline("%s utters a ghastly howl!", Monnam(mtmp));
wakeup = TRUE;
if (Sonic_resistance)
if (how_resistant(SONIC_RES) > 50)
break;
if (!Confusion)
You("suddenly feel %s.",
Expand All @@ -3566,7 +3568,7 @@ struct attack *mattk;
case 16: /* Cause Stunning */
if (m_canseeu(mtmp))
pline("%s emits a series of clicks!", Monnam(mtmp));
if (Sonic_resistance)
if (how_resistant(SONIC_RES) > 50)
break;
make_stunned((HStun & TIMEOUT) + lcount, TRUE);
break;
Expand All @@ -3576,7 +3578,7 @@ struct attack *mattk;
case 20: /* Cause hallucination */
if (m_canseeu(mtmp))
pline("%s bays insane chattering noises!", Monnam(mtmp));
if (Sonic_resistance)
if (how_resistant(SONIC_RES) > 50)
break;
(void) make_hallucinated((HHallucination & TIMEOUT) + lcount,
TRUE, 0L);
Expand All @@ -3588,7 +3590,7 @@ struct attack *mattk;
if (m_canseeu(mtmp))
pline("%s ululates in your direction!", Monnam(mtmp));
wakeup = TRUE;
if (Sonic_resistance)
if (how_resistant(SONIC_RES) > 50)
break;
HFumbling |= FROMOUTSIDE;
HFumbling &= ~TIMEOUT;
Expand All @@ -3601,15 +3603,15 @@ struct attack *mattk;
if (m_canseeu(mtmp))
pline("%s shrieks wildly!", Monnam(mtmp));
wakeup = TRUE;
if (Sonic_resistance)
if (how_resistant(SONIC_RES) > 50)
break;
make_blinded((Blinded & TIMEOUT) + lcount, TRUE);
break;
case 29: /* Cause vomiting */
if (m_canseeu(mtmp))
pline("%s shrills a resonant tone!", Monnam(mtmp));
wakeup = TRUE;
if (Sonic_resistance)
if (how_resistant(SONIC_RES) > 50)
break;
if (Vomiting)
vomit();
Expand All @@ -3620,7 +3622,7 @@ struct attack *mattk;
if (m_canseeu(mtmp))
pline("%s beats it's chest and howls!", Monnam(mtmp));
wakeup = TRUE;
if (Sonic_resistance)
if (how_resistant(SONIC_RES) > 50)
break;

make_deaf((HDeaf & TIMEOUT) + lcount, TRUE);
Expand All @@ -3634,7 +3636,7 @@ struct attack *mattk;
break;
}

if (Sonic_resistance && can_hear) {
if (how_resistant(SONIC_RES) > 50 && can_hear) {
pline_The("noise doesn't seem to bother you.");
monstseesu(M_SEEN_LOUD);
return FALSE;
Expand Down
4 changes: 2 additions & 2 deletions src/mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -5094,7 +5094,7 @@ struct monst *mtmp;
pline("%s bellows soundlessly!", Monnam(mtmp));
}
wake_nearto(mtmp->mx, mtmp->my, 5 * 5);
if ((canseemon(mtmp) || (!Deaf && !Sonic_resistance))
if ((canseemon(mtmp) || (!Deaf && how_resistant(SONIC_RES) < 50))
&& !Underwater && !Confusion
&& !Role_if(PM_KNIGHT)
&& !wielding_artifact(ART_DRAGONBANE)) {
Expand Down Expand Up @@ -7073,7 +7073,7 @@ struct monst *mtmp;
unmul("You are frightened awake!");
}

if (Sonic_resistance) {
if (how_resistant(SONIC_RES) > 50) {
You("are unaffected by the noise.");
monstseesu(M_SEEN_LOUD);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/monmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ register struct monst *mtmp;
from you from having cast dozens of sticks-to-snakes
or similar spells by the time you reach it */
if (!mtmp->mspec_used
&& dist2(mtmp->mx, mtmp->my, u.ux, u.uy) <= 49) {
&& dist2(mtmp->mx, mtmp->my, u.ux, u.uy) < 50) {
struct attack *mattk, *a;
mattk = has_erac(mtmp) ? ERAC(mtmp)->mattk: mdat->mattk;

Expand Down
2 changes: 1 addition & 1 deletion src/mthrowu.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const char *name; /* if null, then format `*objp' */
if (ammo_stack)
ammo_stack->oprops_known |= obj->oprops_known;

if (is_acid && Acid_resistance) {
if (is_acid && how_resistant(ACID_RES) > 50) {
pline("It doesn't seem to hurt you.");
monstseesu(M_SEEN_ACID);
} else if (obj && obj->oclass == POTION_CLASS) {
Expand Down
12 changes: 6 additions & 6 deletions src/potion.c
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@ register struct obj *otmp;
break;
}
case POT_ACID:
if (Acid_resistance) {
if (how_resistant(ACID_RES) > 50) {
/* Not necessarily a creature who _likes_ acid */
pline("This tastes %s.", Hallucination ? "tangy" : "sour");
monstseesu(M_SEEN_ACID);
Expand Down Expand Up @@ -1925,7 +1925,7 @@ int how;
polyself(0);
break;
case POT_ACID:
if (!Acid_resistance) {
if (how_resistant(ACID_RES) < 50) {
int dmg;

pline("This burns%s!",
Expand Down Expand Up @@ -2334,7 +2334,7 @@ register struct obj *obj;

if (!breathe) {
/* currently only acid affects eyes */
if (eyes && obj->otyp == POT_ACID && !Acid_resistance) {
if (eyes && obj->otyp == POT_ACID && how_resistant(ACID_RES) < 50) {
pline_The("fumes sting your %s.", eyestr);
}
else {
Expand Down Expand Up @@ -2598,7 +2598,7 @@ register struct obj *obj;
unambiguous = TRUE;
break;
case POT_ACID:
if (Acid_resistance) {
if (how_resistant(ACID_RES) > 50) {
if (cansmell) {
pline("It smells %s.", Hallucination ? "tangy" : "sour");
unambiguous = TRUE;
Expand Down Expand Up @@ -2993,7 +2993,7 @@ boolean ourfault;
if (targobj->otyp == POT_ACID) {
pline("It boils vigorously!");
You("are caught in the explosion!");
losehp(Acid_resistance ? rnd(5) : rnd(10),
losehp(how_resistant(ACID_RES) > 50 ? rnd(5) : rnd(10),
"elementary chemistry", KILLED_BY);

You_feel("a momentary lapse of reason!");
Expand Down Expand Up @@ -3677,7 +3677,7 @@ dodip()
useup(singlepotion);
/* MRKR: an alchemy smock ought to be */
/* some protection against this: */
losehp(Acid_resistance ? rnd(5) : rnd(10), "alchemic blast", KILLED_BY_AN);
losehp(how_resistant(ACID_RES) > 50 ? rnd(5) : rnd(10), "alchemic blast", KILLED_BY_AN);

return 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4389,7 +4389,7 @@ xchar x, y;
delobj(obj);

/* Deals damage similar to an alchemy blast */
dmg = (6 + rnd(10)) * (Acid_resistance ? 1 : 2);
dmg = (6 + rnd(10)) * (how_resistant(ACID_RES) > 50 ? 1 : 2);
exercise(A_STR, FALSE);
losehp(dmg, /* not physical damage */
"alchemic blast", KILLED_BY_AN);
Expand Down Expand Up @@ -6510,7 +6510,7 @@ in_hell_effects()
usurvive = how_resistant(FIRE_RES) == 100 || (dmg < u.uhp);

if (how_resistant(FIRE_RES) < 100) {
if (how_resistant(FIRE_RES) >= 50) {
if (how_resistant(FIRE_RES) > 50) {
if (rn2(3))
pline_The("flames of hell are slowly %s you alive!",
rn2(2) ? "roasting" : "burning");
Expand Down
Loading

0 comments on commit 7a6a648

Please sign in to comment.