Refactor disease to be a standard duration
authorKate <601195+semitonal@users.noreply.github.com>
Sat, 24 Apr 2021 20:15:39 +0000 (21:15 +0100)
committerKate <601195+semitonal@users.noreply.github.com>
Mon, 26 Apr 2021 01:30:25 +0000 (02:30 +0100)
Disease is no longer a widespread status effect and only shows up in the
Abyss from ancient zymes, so doesn't need so much special handling. Turn it
into a normal duration (with recovery rate no longer affected by the
player's regeneration rate), and make it dispellable instead of being
healable with potions of curing.

20 files changed:
crawl-ref/source/ability.cc
crawl-ref/source/dat/descript/ability.txt
crawl-ref/source/dat/descript/items.txt
crawl-ref/source/dat/descript/status.txt
crawl-ref/source/duration-data.h
crawl-ref/source/duration-type.h
crawl-ref/source/god-abil.cc
crawl-ref/source/l-you.cc
crawl-ref/source/mon-act.cc
crawl-ref/source/monster.cc
crawl-ref/source/nearby-danger.cc
crawl-ref/source/player-reacts.cc
crawl-ref/source/player.cc
crawl-ref/source/player.h
crawl-ref/source/potion.cc
crawl-ref/source/spl-goditem.h
crawl-ref/source/status.cc
crawl-ref/source/tag-version.h
crawl-ref/source/tags.cc
crawl-ref/source/wiz-you.cc

index 1ab3b8c..f37c5f3 100644 (file)
@@ -1534,7 +1534,8 @@ static bool _check_ability_possible(const ability_def& abil, bool quiet = false)
         return true;
 
     case ABIL_ELYVILON_PURIFICATION:
-        if (!you.disease && !you.duration[DUR_POISONING]
+        if (!you.duration[DUR_SICKNESS]
+            && !you.duration[DUR_POISONING]
             && !you.duration[DUR_CONF] && !you.duration[DUR_SLOW]
             && !you.petrifying()
             && you.strength(false) == you.max_strength()
index c5a21e3..25d3367 100644 (file)
@@ -342,9 +342,9 @@ Heals a small amount of health, depending on Invocations skill.
 %%%%
 Purification ability
 
-Purges your body of negative effects such as poison, confusion, slowness,
-petrification, and sickness, and fully restores any lost strength, dexterity or
-intelligence.
+Purges your body of poison, confusion, slowness, petrification, weakness, and
+sickness. Any drained strength, dexterity or intelligence will also be fully
+restored, along with any drained maximum health.
 %%%%
 Heal Other ability
 
index f340c9a..4d4b4c0 100644 (file)
@@ -632,7 +632,8 @@ it. It also reduces magical contamination.
 %%%%
 potion of curing
 
-A potion which heals some wounds, clears the mind and cures poison and disease.
+A potion which restores a small amount of health, and cures poison and
+confusion.
 %%%%
 potion of degeneration
 
index 4f1d4dd..861d269 100644 (file)
@@ -173,8 +173,7 @@ without taking damage.
 %%%%
 Sick status
 
-You have been sickened, and your health will no longer regenerate. Sickness can
-be cured immediately by potions of curing.
+You have been sickened, and your health will no longer regenerate.
 %%%%
 Vertigo status
 
index 02ee395..eaa5a13 100644 (file)
@@ -591,7 +591,9 @@ static const duration_def duration_data[] =
     { DUR_SICKENING, 0, "", "", "sickening", "", D_NO_FLAGS, {{""}}},
     { DUR_WATER_HOLD, 0, "", "", "drowning", "", D_NO_FLAGS},
     { DUR_SLEEP_IMMUNITY, 0, "", "", "sleep immunity", "", D_NO_FLAGS, {{""}}},
-    { DUR_TROGS_HAND, 0, "", "", "trogs hand", "", D_NO_FLAGS,
+    // Regeneration information handled separately.
+    { DUR_TROGS_HAND, 0, "", "strong-willed", "trogs hand",
+      "Your willpower is greatly increased.", D_EXPIRES,
         {{"", trog_remove_trogs_hand},
           {"You feel the effects of Trog's Hand fading.", 1}}, 6},
     { DUR_GOZAG_GOLD_AURA, 0, "", "gold aura", "", "", D_NO_FLAGS,
@@ -614,6 +616,8 @@ static const duration_def duration_data[] =
     { DUR_HEAVENLY_STORM, 0, "", "in a heavenly storm", "heavenly storm",
       "Heavenly clouds are increasing your accuracy and damage.", D_NO_FLAGS,
       {{ "", wu_jian_decrement_heavenly_storm }}},
+    { DUR_SICKNESS, 0, "", "", "sickness", "", D_DISPELLABLE,
+      {{ "You feel your health improve." }}},
 
 
 #if TAG_MAJOR_VERSION == 34
index 5cd705a..17f099f 100644 (file)
@@ -219,5 +219,6 @@ enum duration_type
     DUR_ATTRACTIVE,
     DUR_LOCKED_DOWN,
     DUR_WORD_OF_CHAOS_COOLDOWN,
+    DUR_SICKNESS,
     NUM_DURATIONS
 };
index 169c91a..645998c 100644 (file)
@@ -1321,7 +1321,7 @@ void elyvilon_purification()
 {
     mpr("You feel purified!");
 
-    you.disease = 0;
+    you.duration[DUR_SICKNESS] = 0;
     you.duration[DUR_POISONING] = 0;
     you.duration[DUR_CONF] = 0;
     you.duration[DUR_SLOW] = 0;
index e7fb8db..ec77e14 100644 (file)
@@ -418,7 +418,7 @@ LUARET1(you_silenced, boolean, silenced(you.pos()))
  * @treturn boolean
  * @function sick
  */
-LUARET1(you_sick, boolean, you.disease)
+LUARET1(you_sick, boolean, you.duration[DUR_SICKNESS])
 /*** Are you contaminated?
  * @treturn number
  * @function contaminated
index 96f68f3..0a8f817 100644 (file)
@@ -2107,7 +2107,7 @@ static void _ancient_zyme_sicken(monster* mons)
         && !you.duration[DUR_DIVINE_STAMINA]
         && cell_see_cell(you.pos(), mons->pos(), LOS_SOLID_SEE))
     {
-        if (!you.disease)
+        if (!you.duration[DUR_SICKNESS])
         {
             if (!you.duration[DUR_SICKENING])
             {
index a242acd..4d1767d 100644 (file)
@@ -5804,7 +5804,6 @@ bool monster::should_drink_potion(potion_type ptype) const
     case POT_CURING:
         return hit_points <= max_hit_points / 2
                || has_ench(ENCH_POISON)
-               || has_ench(ENCH_SICK)
                || has_ench(ENCH_CONFUSION);
     case POT_HEAL_WOUNDS:
         return hit_points <= max_hit_points / 2;
@@ -5846,7 +5845,7 @@ bool monster::drink_potion_effect(potion_type pot_eff, bool card)
 
         static const enchant_type cured_enchants[] =
         {
-            ENCH_POISON, ENCH_SICK, ENCH_CONFUSION
+            ENCH_POISON, ENCH_CONFUSION
         };
 
         for (enchant_type cured : cured_enchants)
index 4a27d84..54806ea 100644 (file)
@@ -440,7 +440,6 @@ void revive()
     // doesn't matter here.
     you.attribute[ATTR_LIFE_GAINED] = 0;
 
-    you.disease = 0;
     you.magic_contamination = 0;
     restore_stat(STAT_ALL, 0, true);
 
index 2373810..df1062e 100644 (file)
@@ -1017,7 +1017,6 @@ void player_reacts()
 
     _regenerate_hp_and_mp(you.time_taken);
 
-    dec_disease_player(you.time_taken);
     if (you.duration[DUR_POISONING])
         handle_player_poison(you.time_taken);
 
index c16bb62..1792365 100644 (file)
@@ -1172,8 +1172,12 @@ int player_regen()
     if (you.duration[DUR_COLLAPSE])
         rr /= 4;
 
-    if (you.disease || regeneration_is_inhibited() || !player_regenerates_hp())
+    if (you.duration[DUR_SICKNESS]
+        || regeneration_is_inhibited()
+        || !player_regenerates_hp())
+    {
         rr = 0;
+    }
 
     // Trog's Hand. This circumvents sickness or inhibited regeneration.
     if (you.duration[DUR_TROGS_HAND])
@@ -4558,32 +4562,6 @@ void dec_haste_player(int delay)
     }
 }
 
-void dec_disease_player(int delay)
-{
-    if (you.disease)
-    {
-        int rr = 50;
-
-        // Extra regeneration means faster recovery from disease.
-        // But not if not actually regenerating!
-        if (player_regenerates_hp())
-            rr += _player_bonus_regen();
-
-        // Trog's Hand.
-        if (you.duration[DUR_TROGS_HAND])
-            rr += 100;
-
-        rr = div_rand_round(rr * delay, 50);
-
-        you.disease -= rr;
-        if (you.disease < 0)
-            you.disease = 0;
-
-        if (you.disease == 0)
-            mprf(MSGCH_RECOVERY, "You feel your health improve.");
-    }
-}
-
 void dec_elixir_player(int delay)
 {
     if (!you.duration[DUR_ELIXIR])
@@ -4912,7 +4890,6 @@ player::player()
     stat_loss.init(0);
     base_stats.init(0);
 
-    disease         = 0;
     max_level       = 1;
     hit_points_regeneration   = 0;
     magic_points_regeneration = 0;
@@ -6913,10 +6890,7 @@ bool player::sicken(int amount)
     }
 
     mpr("You feel ill.");
-
-    disease += amount * BASELINE_DELAY;
-    if (disease > 210 * BASELINE_DELAY)
-        disease = 210 * BASELINE_DELAY;
+    increase_duration(DUR_SICKNESS, amount, 210);
 
     return true;
 }
index 4c8518e..d4ab36e 100644 (file)
@@ -147,7 +147,6 @@ public:
     FixedVector<int8_t, NUM_STATS> stat_loss;
     FixedVector<int8_t, NUM_STATS> base_stats;
 
-    int disease;
     uint8_t max_level;
     int hit_points_regeneration;
     int magic_points_regeneration;
@@ -1155,7 +1154,6 @@ bool land_player(bool quiet = false);
 void player_open_door(coord_def doorpos);
 void player_close_door(coord_def doorpos);
 
-void dec_disease_player(int delay);
 void player_end_berserk();
 
 void handle_player_drowning(int delay);
index da21823..c9fc5d8 100644 (file)
@@ -79,8 +79,7 @@ public:
     {
         // cure status effects
         if (you.duration[DUR_CONF]
-            || you.duration[DUR_POISONING]
-            || you.disease)
+            || you.duration[DUR_POISONING])
         {
             return true;
         }
@@ -129,7 +128,6 @@ public:
         if (you.duration[DUR_POISONING])
             you.redraw_hit_points = true;
         you.duration[DUR_POISONING] = 0;
-        you.disease = 0;
         you.duration[DUR_CONF] = 0;
         return true;
     }
index 82bc9e4..743f204 100644 (file)
@@ -27,6 +27,7 @@ const enchant_type dispellable_enchantments[] =
     ENCH_STICKY_FLAME,
     ENCH_CHARM,
     ENCH_PARALYSIS,
+    ENCH_SICK,
     ENCH_PETRIFYING,
     ENCH_PETRIFIED,
     ENCH_REGENERATION,
index 8b009d6..e2f051b 100644 (file)
@@ -780,36 +780,19 @@ static void _describe_glow(status_info& inf)
 
 static void _describe_regen(status_info& inf)
 {
-    const bool trogs_hand = you.duration[DUR_TROGS_HAND] > 0;
-    const bool no_heal = !player_regenerates_hp();
-
-    if (trogs_hand)
+    if (you.duration[DUR_TROGS_HAND])
     {
         inf.light_colour = _dur_colour(BLUE, dur_expiring(DUR_TROGS_HAND));
-        inf.light_text   = "Regen";
-        inf.light_text += " Will++";
-    }
-
-    if (no_heal || (you.disease && !trogs_hand))
-       inf.short_text = "non-regenerating";
-    else if (trogs_hand)
-    {
-        if (you.disease)
-        {
-            inf.short_text = "recuperating";
-            inf.long_text  = "You are recuperating from your illness.";
-        }
-        else
-        {
-            inf.short_text = "regenerating";
-            inf.long_text  = "You are regenerating.";
-        }
+        inf.light_text = "Regen Will++";
+        inf.short_text = "regenerating";
+        inf.long_text  = "You are regenerating.";
         _mark_expiring(inf, dur_expiring(DUR_TROGS_HAND));
     }
-    else if (you.has_mutation(MUT_VAMPIRISM) && you.vampire_alive)
+    else if (you.has_mutation(MUT_VAMPIRISM)
+             && you.vampire_alive
+             && !you.duration[DUR_SICKNESS])
     {
-        inf.short_text = you.disease ? "recuperating" : "regenerating";
-        inf.short_text += " quickly";
+        inf.short_text = "healing quickly";
     }
 }
 
@@ -879,17 +862,18 @@ static void _describe_airborne(status_info& inf)
 
 static void _describe_sickness(status_info& inf)
 {
-    if (you.disease)
+    if (you.duration[DUR_SICKNESS])
     {
         const int high = 120 * BASELINE_DELAY;
         const int low  =  40 * BASELINE_DELAY;
 
-        inf.light_colour   = _bad_ench_colour(you.disease, low, high);
+        inf.light_colour   = _bad_ench_colour(you.duration[DUR_SICKNESS],
+                                              low, high);
         inf.light_text     = "Sick";
 
-        string mod = (you.disease > high) ? "badly "  :
-                     (you.disease >  low) ? ""
-                                          : "mildly ";
+        string mod = (you.duration[DUR_SICKNESS] > high) ? "badly "  :
+                     (you.duration[DUR_SICKNESS] >  low) ? ""
+                                                         : "mildly ";
 
         inf.short_text = mod + "diseased";
         inf.long_text  = "You are " + mod + "diseased.";
index c2c4c99..46dc053 100644 (file)
@@ -259,6 +259,7 @@ enum tag_minor_version
     TAG_MINOR_NEW_ASHENZARI,       // New Ashenzari
     TAG_MINOR_COMPRESS_BADMUTS,    // Reduce some mutations to 2 levels
     TAG_MINOR_NEW_TREES,           // New tree types
+    TAG_MINOR_DISEASE,             // Turn disease into a normal duration
 #endif
     NUM_TAG_MINORS,
     TAG_MINOR_VERSION = NUM_TAG_MINORS - 1
index 8e5a6d9..4391918 100644 (file)
@@ -1409,7 +1409,6 @@ static void _tag_construct_you(writer &th)
     marshallByte(th, you.berserk_penalty);
     marshallInt(th, you.abyss_speed);
 
-    marshallInt(th, you.disease);
     ASSERT(you.hp > 0 || you.pending_revival);
     marshallShort(th, you.pending_revival ? 0 : you.hp);
 
@@ -2564,7 +2563,11 @@ static void _tag_read_you(reader &th)
 
     you.abyss_speed = unmarshallInt(th);
 
-    you.disease         = unmarshallInt(th);
+#if TAG_MAJOR_VERSION == 34
+    // was you.disease
+    if (th.getMinorVersion() < TAG_MINOR_DISEASE)
+        unmarshallInt(th);
+#endif
     you.hp              = unmarshallShort(th);
 #if TAG_MAJOR_VERSION == 34
     // was you.hunger
index a6191ff..82c11d3 100644 (file)
@@ -221,7 +221,7 @@ void wizard_heal(bool super_heal)
         mpr("Healing.");
 
     // Clear most status ailments.
-    you.disease = 0;
+    you.duration[DUR_SICKNESS]  = 0;
     you.duration[DUR_CONF]      = 0;
     you.duration[DUR_POISONING] = 0;
     you.duration[DUR_EXHAUSTED] = 0;