diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-02 21:57:41 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-02 21:57:41 +0000 |
commit | a3a8c0f837972ec556dc6a89b411603953344da0 (patch) | |
tree | e18e7c5d0b60b01a49e48bb6ffe959db21d07c69 | |
parent | 72760b7751173d389735f6f129f92ef5963b1adc (diff) | |
download | crawl-ref-a3a8c0f837972ec556dc6a89b411603953344da0.tar.gz crawl-ref-a3a8c0f837972ec556dc6a89b411603953344da0.zip |
Add res_rotting() method to the actor class so that the "are you the right
type of undead to resist rotting" logic can be in just one place instead
of duplicated every time the check is made.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6354 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/externs.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 18 | ||||
-rw-r--r-- | crawl-ref/source/spl-cast.cc | 5 |
4 files changed, 22 insertions, 11 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 1344136775..0fb8794be9 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -194,6 +194,7 @@ public: virtual int res_elec() const = 0; virtual int res_poison() const = 0; virtual int res_negative_energy() const = 0; + virtual int res_rotting() const = 0; virtual flight_type flight_mode() const = 0; virtual bool is_levitating() const = 0; @@ -876,6 +877,7 @@ public: int res_elec() const; int res_poison() const; int res_negative_energy() const; + int res_rotting() const; bool confusable() const; bool slowable() const; @@ -1212,6 +1214,7 @@ public: int res_elec() const; int res_poison() const; int res_negative_energy() const; + int res_rotting() const; flight_type flight_mode() const; bool is_levitating() const; diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index d5f1a9ad71..5f4748cb0d 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -4548,6 +4548,11 @@ int monsters::res_negative_energy() const return (mons_res_negative_energy(this)); } +int monsters::res_rotting() const +{ + return (mons_holiness(this) == MH_NATURAL ? 0 : 1); +} + flight_type monsters::flight_mode() const { return (mons_flies(this)); @@ -4634,7 +4639,7 @@ int monsters::hurt(const actor *agent, int amount) void monsters::rot(actor *agent, int rotlevel, int immed_rot) { - if (mons_holiness(this) != MH_NATURAL) + if (res_rotting() > 0) return; // Apply immediate damage because we can't handle rotting for monsters yet. diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index eb8662b5bc..3057aedbbf 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -5189,8 +5189,7 @@ bool rot_player( int amount ) if (amount <= 0) return (false); - if (you.is_undead - && (you.is_undead != US_SEMI_UNDEAD || you.hunger_state < HS_SATIATED)) + if (you.res_rotting() > 0) { mpr( "You feel terrible." ); return (false); @@ -6279,6 +6278,16 @@ int player::res_negative_energy() const return (player_prot_life()); } +int player::res_rotting() const +{ + if (you.is_undead + && (you.is_undead != US_SEMI_UNDEAD || you.hunger_state < HS_SATIATED)) + { + return 1; + } + return 0; +} + bool player::confusable() const { return (player_mental_clarity() == 0); @@ -6411,11 +6420,8 @@ void player::drain_stat(int stat, int amount, actor* attacker) void player::rot(actor *who, int rotlevel, int immed_rot) { - if (you.is_undead - && (you.is_undead != US_SEMI_UNDEAD || you.hunger_state < HS_SATIATED)) - { + if (res_rotting() > 0) return; - } if (rotlevel) rot_player(rotlevel); diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 72fc1c163b..0e552e784c 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -2961,10 +2961,7 @@ static void _miscast_necromancy(int severity, const char* cause) break; case 2: // josh declares mummies cannot smell {dlb} - if (player_can_smell() - && !(you.is_undead - && (you.is_undead != US_SEMI_UNDEAD - || you.hunger_state < HS_SATIATED) )) + if (player_can_smell() && you.res_rotting() == 0) { mpr("You smell decay."); // identical to a harmless message you.rotting++; |