From e2e53f867209b1ae9d9923b9e042796d91677363 Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Sun, 15 Nov 2009 19:00:18 -0500 Subject: Delay adjustment for sickness Store total time to recovery instead of turns in you.disease, change you.disease to an integer, update tags and bump TAG_MINOR_VERSION accordingly. --- crawl-ref/source/main.cc | 2 +- crawl-ref/source/output.cc | 9 ++++++--- crawl-ref/source/player.cc | 23 ++++++++++++++--------- crawl-ref/source/player.h | 4 ++-- crawl-ref/source/tags.cc | 9 +++++++-- crawl-ref/source/tags.h | 4 +++- 6 files changed, 33 insertions(+), 18 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc index d19c6967eb..688e327891 100644 --- a/crawl-ref/source/main.cc +++ b/crawl-ref/source/main.cc @@ -2641,7 +2641,7 @@ static void _decrement_durations() } } - dec_disease_player(); + dec_disease_player(delay); dec_poison_player(); diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index 82e4fbaecc..d498d043ef 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -744,7 +744,8 @@ static void _get_status_lights(std::vector& out) if (you.disease) { - int color = _bad_ench_colour( you.disease, 40, 120 ); + int color = _bad_ench_colour( you.disease, 40 * BASELINE_DELAY, + 120 * BASELINE_DELAY); out.push_back(status_light(color, "Sick")); } @@ -2204,8 +2205,10 @@ std::string _status_mut_abilities() if (you.disease) { - std::string help = (you.disease > 120) ? "badly " : - (you.disease > 40) ? "" + int high = 120 * BASELINE_DELAY; + int low = 40 * BASELINE_DELAY; + std::string help = (you.disease > high) ? "badly " : + (you.disease > low) ? "" : "mildly "; help += "diseased"; diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 1fcafdd60f..6593e683ef 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -3684,9 +3684,11 @@ void display_char_status() if (you.disease) { + int high = 120 * BASELINE_DELAY; + int low = 40 * BASELINE_DELAY; mprf("You are %sdiseased.", - (you.disease > 120) ? "badly " : - (you.disease > 40) ? "" + (you.disease > high) ? "badly " : + (you.disease > low) ? "" : "mildly "); } @@ -5070,7 +5072,7 @@ bool disease_player(int amount) return you.sicken(amount); } -void dec_disease_player() +void dec_disease_player(int delay) { if (you.disease > 0) { @@ -5083,15 +5085,17 @@ void dec_disease_player() return; } - you.disease--; + you.disease -= delay; + if(you.disease < 0) + you.disease = 0; // kobolds and regenerators recuperate quickly - if (you.disease > 5 + if (you.disease > 5 * BASELINE_DELAY && (you.species == SP_KOBOLD || you.duration[DUR_REGENERATION] || player_mutation_level(MUT_REGENERATION) == 3)) { - you.disease -= 2; + you.disease -= 2 * BASELINE_DELAY; } if (you.disease == 0) @@ -6799,10 +6803,11 @@ bool player::sicken(int amount) mpr( "You feel ill." ); - const int tmp = disease + amount; - disease = (tmp > 210) ? 210 : tmp; - learned_something_new(TUT_YOU_SICK); + disease += amount * BASELINE_DELAY; + if(disease > 210 * BASELINE_DELAY) + disease = 210 * BASELINE_DELAY; + learned_something_new(TUT_YOU_SICK); return (true); } diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 9725ba39b5..432a104731 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -59,7 +59,7 @@ public: unsigned char synch_time; // amount to wait before calling handle_time() - unsigned char disease; + int disease; char max_level; @@ -757,7 +757,7 @@ void haste_player(int turns); void dec_haste_player(int delay); bool disease_player(int amount); -void dec_disease_player(); +void dec_disease_player(int delay); bool player_weapon_wielded(); diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 72c792dbbb..4e1e75c8a1 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -965,7 +965,8 @@ static void tag_construct_you(writer &th) marshallByte(th, you.entry_cause); marshallByte(th, you.entry_cause_god); marshallByte(th, you.synch_time); - marshallByte(th, you.disease); + + marshallLong(th, you.disease); marshallByte(th, you.species); marshallShort(th, you.hp); @@ -1391,7 +1392,11 @@ static void tag_read_you(reader &th, char minorVersion) you.entry_cause = static_cast( unmarshallByte(th) ); you.entry_cause_god = static_cast( unmarshallByte(th) ); you.synch_time = unmarshallByte(th); - you.disease = unmarshallByte(th); + if (minorVersion >= TAG_MINOR_DISEASE) + you.disease = unmarshallLong(th); + else + you.disease = unmarshallByte(th); + you.species = static_cast(unmarshallByte(th)); you.hp = unmarshallShort(th); you.hunger = unmarshallShort(th); diff --git a/crawl-ref/source/tags.h b/crawl-ref/source/tags.h index 493e85493b..0b7bbdc4d4 100644 --- a/crawl-ref/source/tags.h +++ b/crawl-ref/source/tags.h @@ -49,7 +49,9 @@ enum tag_major_version // the dungeon Lua changes. enum tag_minor_version { - TAG_MINOR_VERSION = 0 // Current version. (Keep equal to max.) + TAG_MINOR_RESET = 0, // Minor tags were reset + TAG_MINOR_DISEASE = 1, // you.disease changed to an integer + TAG_MINOR_VERSION = 1 // Current version. (Keep equal to max.) }; struct enum_info -- cgit v1.2.3-54-g00ecf