From 4c7d126606f79fe3fdb2e5abbfe62ded63d9845c Mon Sep 17 00:00:00 2001 From: Erik Lunna Date: Mon, 2 Oct 2023 07:30:19 +0200 Subject: [PATCH] Being underwater gives you (and monsters) temporary sonic resistance while submerged. --- include/mondata.h | 3 ++- include/youprop.h | 4 +++- src/cmd.c | 8 ++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/mondata.h b/include/mondata.h index a43efcf37..8b1f3016f 100644 --- a/include/mondata.h +++ b/include/mondata.h @@ -28,7 +28,8 @@ #define resists_elec(mon) ((mon_resistancebits(mon) & MR_ELEC) != 0) #define resists_poison(mon) ((mon_resistancebits(mon) & MR_POISON) != 0) #define resists_acid(mon) ((mon_resistancebits(mon) & MR_ACID) != 0) -#define resists_sonic(mon) ((mon_resistancebits(mon) & MR_SONIC) != 0) +#define resists_sonic(mon) ((mon_resistancebits(mon) & MR_SONIC) != 0 \ + || mon_underwater(mon)) #define resists_ston(mon) ((mon_resistancebits(mon) & MR_STONE) != 0) #define resists_psychic(mon) ((mon_resistancebits(mon) & MR_PSYCHIC) != 0) #define resists_clob(mon) ((mon_resistancebits(mon) & MR_CLOB) != 0) diff --git a/include/youprop.h b/include/youprop.h index 2cc6342d2..effb1b814 100644 --- a/include/youprop.h +++ b/include/youprop.h @@ -103,7 +103,9 @@ #define HSonic_resistance u.uprops[SONIC_RES].intrinsic #define ESonic_resistance u.uprops[SONIC_RES].extrinsic -#define Sonic_resistance (HSonic_resistance || ESonic_resistance) +/* Anytime we are underwater we are effectively sonic resistant */ +#define WSonic_resistance Underwater +#define Sonic_resistance (HSonic_resistance || ESonic_resistance || WSonic_resistance) #define HStone_resistance u.uprops[STONE_RES].intrinsic #define EStone_resistance u.uprops[STONE_RES].extrinsic diff --git a/src/cmd.c b/src/cmd.c index c04e71f3c..62ff8b0eb 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -3364,8 +3364,12 @@ int final; from_what(AD_ACID)); if (Psychic_resistance) you_are("psionic resistant", from_what(PSYCHIC_RES)); - if (Sonic_resistance) - you_are("sonic resistant", from_what(SONIC_RES)); + if (Sonic_resistance) { + if (!WSonic_resistance) + you_are("sonic resistant", from_what(SONIC_RES)); + else + you_are("sonic resistant", " (from being underwater)"); + } if (ESonic_resistance) enl_msg("Your items ", "are", "were", " protected from sonic", from_what(AD_LOUD));