From f4d4ac1f080ca982d29bd8881215408c6d830f87 Mon Sep 17 00:00:00 2001 From: k21971 Date: Sat, 17 Aug 2024 03:12:47 +0000 Subject: [PATCH] Fix: digesting rings of fire/cold/shock/poison resistance would not confer any resistance. This bug has most likely existed since the very beginning of EvilHack development when partial resistances were ported over from SporkHack (and this bug exists there as well). Was noticed recently during a game of Hack'EM, which shares a lot of EvilHack code. A fix was made for that variant; the fix here is similar, but not exactly the same. It was pointed out by terrapin that a more elegant fix would be to change a bit in how_resistant() in potion.c from u.uprops[which].intrinsic & (FROMEXPER | FROMRACE | FROMFORM) to u.uprops[which].intrinsic & INTRINSIC, but doing so would break a lot of the functionality of ice traps. So we've made specific cases for each of the rings affected instead. Eating any of these rings has a chance to grant 50% resistance for that type of ring (one third of that for fire res if Draugr race). --- doc/evilhack-changelog.md | 2 ++ src/eat.c | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/doc/evilhack-changelog.md b/doc/evilhack-changelog.md index f5536ae91..f42e47684 100644 --- a/doc/evilhack-changelog.md +++ b/doc/evilhack-changelog.md @@ -3601,4 +3601,6 @@ The following changes to date are: - Fix: feedback when having to drop a worn shield vs worn bracers - Fix: Tortle archeologists could never throw Xiuhcoatl - Fix: Possible crash when saving bones after second death +- Fix: digesting rings of fire/cold/shock/poison resistance would not + confer any resistance diff --git a/src/eat.c b/src/eat.c index 4f1b2a6d6..d25aae08b 100644 --- a/src/eat.c +++ b/src/eat.c @@ -2339,6 +2339,56 @@ struct obj *otmp; } incr_resistance(&HSleep_resistance, 100); break; + case RIN_FIRE_RESISTANCE: + /* Due to their undead nature, Draugr only gain intrinsic + fire resistance a third as much as other races per source, + and is capped at 50% resistance (see how_resistant() in + potion.c) */ + if ((HFire_resistance & (TIMEOUT | FROMRACE | FROMEXPER)) < 100) { + accessory_has_effect(otmp); + incr_resistance(&HFire_resistance, + (Race_if(PM_DRAUGR) ? (50 / 3) : 50)); + if ((HFire_resistance & TIMEOUT) == 100) + You_feel(Hallucination ? "like... so chill." + : "completely chilled."); + else if (Race_if(PM_DRAUGR) && (HFire_resistance & TIMEOUT) >= 50) + ; /* no feedback */ + else + You_feel("%s more chill.", + Race_if(PM_DRAUGR) ? "considerably" : "much"); + } + break; + case RIN_COLD_RESISTANCE: + if ((HCold_resistance & (TIMEOUT | FROMRACE | FROMEXPER)) < 100) { + accessory_has_effect(otmp); + incr_resistance(&HCold_resistance, 50); + if ((HCold_resistance & TIMEOUT) == 100) + You_feel("full of hot air."); + else + You_feel("much warmer."); + } + break; + case RIN_SHOCK_RESISTANCE: + if ((HShock_resistance & (TIMEOUT | FROMRACE | FROMEXPER)) < 100) { + accessory_has_effect(otmp); + incr_resistance(&HShock_resistance, 50); + if ((HShock_resistance & TIMEOUT) == 100) + pline(Hallucination ? "You feel grounded in reality." + : "Your health feels completely amplified!"); + else + Your("health is much more amplified!"); + } + break; + case RIN_POISON_RESISTANCE: + if ((HPoison_resistance & (TIMEOUT | FROMRACE | FROMEXPER)) < 100) { + accessory_has_effect(otmp); + incr_resistance(&HPoison_resistance, 50); + if ((HPoison_resistance & TIMEOUT) == 100) + You_feel("completely healthy."); + else + You_feel("much healthier."); + } + break; case AMULET_OF_CHANGE: accessory_has_effect(otmp); makeknown(typ);