diff options
author | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-08 23:01:33 +0000 |
---|---|---|
committer | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-08 23:01:33 +0000 |
commit | 65fe4389269de4c14c9b9adbc6ef0308f2059dbd (patch) | |
tree | afc6825c365eb96aa931ded0bc1840ff34d7d169 /crawl-ref | |
parent | 92250a09d1024580b40b197b69462d8f1ede94ef (diff) | |
download | crawl-ref-65fe4389269de4c14c9b9adbc6ef0308f2059dbd.tar.gz crawl-ref-65fe4389269de4c14c9b9adbc6ef0308f2059dbd.zip |
Clean up the rotting routines a bit.
For the record, rotting attacks from monsters currently have the same
problem that draining attacks used to, due to monsters::rot()'s directly
modifying the monster's max HP, as well as its directly calling
monsters::hurt().
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8340 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/externs.h | 12 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 63 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 2 |
3 files changed, 40 insertions, 37 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 86d93be0d4..ea5e82a2e2 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -334,9 +334,10 @@ public: virtual bool can_mutate() const = 0; virtual bool can_safely_mutate() const = 0; virtual bool mutate() = 0; - virtual int hurt(const actor *attacker, int amount, - beam_type flavour = BEAM_MISSILE, - bool cleanup_dead = true) = 0; + virtual void rot(actor *attacker, int rotlevel, int immed_rot) = 0; + virtual int hurt(const actor *attacker, int amount, + beam_type flavour = BEAM_MISSILE, + bool cleanup_dead = true) = 0; virtual void heal(int amount, bool max_too = false) = 0; virtual void banish(const std::string &who = "") = 0; virtual void blink(bool allow_partial_control = true) = 0; @@ -347,7 +348,6 @@ public: virtual void petrify(actor *attacker, int strength) = 0; virtual void slow_down(actor *attacker, int strength) = 0; virtual void confuse(actor *attacker, int strength) = 0; - virtual void rot(actor *attacker, int rotlevel, int immediate_rot) = 0; virtual void expose_to_element(beam_type element, int strength = 0) = 0; virtual void drain_stat(int stat, int amount, actor* attacker) { } virtual void put_to_sleep(int power = 0) { }; @@ -1070,8 +1070,8 @@ public: void petrify(actor *, int str); void slow_down(actor *, int str); void confuse(actor *, int strength); - void rot(actor *agent, int rotlevel, int immed_rot); void heal(int amount, bool max_too = false); + void rot(actor *attacker, int rotlevel, int immed_rot); int hurt(const actor *attacker, int amount, beam_type flavour = BEAM_MISSILE, bool cleanup_dead = true); @@ -1499,7 +1499,7 @@ public: void petrify(actor *, int str); void slow_down(actor *, int str); void confuse(actor *, int strength); - void rot(actor *agent, int rotlevel, int immed_rot); + void rot(actor *, int rotlevel, int immed_rot); int hurt(const actor *attacker, int amount, beam_type flavour = BEAM_MISSILE, bool cleanup_dead = true); diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index d8a849d0f2..cc6270add5 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -5788,6 +5788,39 @@ god_type monsters::deity() const return (god); } +void monsters::rot(actor *atk, int rotlevel, int immed_rot) +{ + if (res_rotting() > 0) + return; + + // Apply immediate damage because we can't handle rotting for + // monsters yet. + const int damage = immed_rot; + if (damage > 0) + { + if (mons_near(this) && player_monster_visible(this)) + { + mprf("%s %s!", name(DESC_CAP_THE).c_str(), + rotlevel == 0 ? "looks less resilient" : "rots"); + } + + hurt(atk, damage); + + if (alive()) + { + max_hit_points -= immed_rot * 2; + if (hit_points > max_hit_points) + hit_points = max_hit_points; + } + } + + if (rotlevel > 0) + { + add_ench(mon_enchant(ENCH_ROT, std::min(rotlevel, 4), + atk->kill_alignment())); + } +} + int monsters::hurt(const actor *agent, int amount, beam_type flavour, bool cleanup_dead) { @@ -5830,36 +5863,6 @@ int monsters::hurt(const actor *agent, int amount, beam_type flavour, return (amount); } -void monsters::rot(actor *agent, int rotlevel, int immed_rot) -{ - if (res_rotting() > 0) - return; - - // Apply immediate damage because we can't handle rotting for monsters yet. - const int damage = immed_rot; - if (damage > 0) - { - if (mons_near(this) && player_monster_visible(this)) - { - mprf("%s %s!", name(DESC_CAP_THE).c_str(), - rotlevel == 0? "looks less resilient" : "rots"); - } - hurt(agent, damage); - if (alive()) - { - max_hit_points -= immed_rot * 2; - if (hit_points > max_hit_points) - hit_points = max_hit_points; - } - } - - if (rotlevel > 0) - { - add_ench(mon_enchant(ENCH_ROT, std::min(rotlevel, 4), - agent->kill_alignment())); - } -} - void monsters::confuse(actor *atk, int strength) { enchant_monster_with_flavour(this, atk, BEAM_CONFUSION, strength); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 2f44984916..866da1261e 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -6883,7 +6883,7 @@ void player::rot(actor *who, int rotlevel, int immed_rot) rot_hp(immed_rot); if (rotlevel && one_chance_in(4)) - disease_player( 50 + random2(100) ); + disease_player(50 + random2(100)); } void player::confuse(actor *who, int str) |