summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-20 22:53:13 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-20 22:53:13 +0000
commit8e6aed77dcf612ec06f14c8ad8f79d83d813ac5b (patch)
tree46b6b0d5cc01cc5e17bd77e47addf3508432855c /crawl-ref/source
parent28b0d8ccf5840100bb223502ae19951c859d84b6 (diff)
downloadcrawl-ref-8e6aed77dcf612ec06f14c8ad8f79d83d813ac5b.tar.gz
crawl-ref-8e6aed77dcf612ec06f14c8ad8f79d83d813ac5b.zip
Clean up rotting in melee attacks to not kill the target directly and to
use special_damage_msg, as with draining. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8636 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/externs.h7
-rw-r--r--crawl-ref/source/fight.cc19
-rw-r--r--crawl-ref/source/fight.h1
-rw-r--r--crawl-ref/source/mon-util.cc21
-rw-r--r--crawl-ref/source/player.cc6
5 files changed, 38 insertions, 16 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index f0195f1f04..d5e3f7e8a6 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -336,7 +336,8 @@ public:
virtual bool can_bleed() const = 0;
virtual bool mutate() = 0;
virtual bool drain_exp(actor *agent, bool quiet = false) = 0;
- virtual void rot(actor *agent, int amount, int immediate = 0) = 0;
+ virtual bool rot(actor *agent, int amount, int immediate = 0,
+ bool quiet = false) = 0;
virtual int hurt(const actor *attacker, int amount,
beam_type flavour = BEAM_MISSILE,
bool cleanup_dead = true) = 0;
@@ -1074,7 +1075,7 @@ public:
void confuse(actor *, int strength);
void heal(int amount, bool max_too = false);
bool drain_exp(actor *, bool quiet = false);
- void rot(actor *, int amount, int immediate = 0);
+ bool rot(actor *, int amount, int immediate = 0, bool quiet = false);
int hurt(const actor *attacker, int amount,
beam_type flavour = BEAM_MISSILE,
bool cleanup_dead = true);
@@ -1506,7 +1507,7 @@ public:
void slow_down(actor *, int str);
void confuse(actor *, int strength);
bool drain_exp(actor *, bool quiet = false);
- void rot(actor *, int amount, int immediate = 0);
+ bool rot(actor *, int amount, int immediate = 0, bool quiet = false);
int hurt(const actor *attacker, int amount,
beam_type flavour = BEAM_MISSILE,
bool cleanup_dead = true);
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index cf96b82527..d1556307a8 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -2082,6 +2082,21 @@ void melee_attack::drain_defender()
}
}
+void melee_attack::rot_defender(int amount, int immediate)
+{
+ if (defender->rot(attacker, amount, immediate, true))
+ {
+ if (defender->atype() == ACT_MONSTER && defender_visible)
+ {
+ special_damage_message =
+ make_stringf(
+ "%s %s!",
+ def_name(DESC_CAP_THE).c_str(),
+ amount > 0 ? "rots" : "looks less resilient");
+ }
+ }
+}
+
bool melee_attack::distortion_affects_defender()
{
//jmf: blink frogs *like* distortion
@@ -4298,7 +4313,7 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk)
case AF_ROT:
if (one_chance_in(20) || (damage_done > 2 && one_chance_in(3)))
- defender->rot(attacker, 2 + random2(3), damage_done > 5 ? 1 : 0);
+ rot_defender(2 + random2(3), damage_done > 5 ? 1 : 0);
break;
case AF_DISEASE:
@@ -4401,7 +4416,7 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk)
{
if (defender->atype() == ACT_PLAYER)
mprf("You feel less resilient.");
- defender->rot(attacker, 0, coinflip() ? 2 : 1);
+ rot_defender(0, coinflip() ? 2 : 1);
}
}
break;
diff --git a/crawl-ref/source/fight.h b/crawl-ref/source/fight.h
index 9ae999e89d..731430e2f5 100644
--- a/crawl-ref/source/fight.h
+++ b/crawl-ref/source/fight.h
@@ -202,6 +202,7 @@ private:
int fire_res_apply_cerebov_downgrade(int res);
bool defender_is_unholy();
void drain_defender();
+ void rot_defender(int amount, int immediate = 0);
void check_defender_train_armour();
void check_defender_train_dodging();
void splash_defender_with_acid(int strength);
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index b9c61d5881..ddceae874b 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -5924,22 +5924,23 @@ bool monsters::drain_exp(actor *agent, bool quiet)
return (true);
}
-void monsters::rot(actor *agent, int amount, int immediate)
+bool monsters::rot(actor *agent, int amount, int immediate, bool quiet)
{
if (res_rotting() > 0 || amount <= 0)
- return;
+ return (false);
+
+ if (!quiet && mons_near(this) && player_monster_visible(this))
+ {
+ mprf("%s %s!", name(DESC_CAP_THE).c_str(),
+ amount > 0 ? "rots" : "looks less resilient");
+ }
// Apply immediate damage because we can't handle rotting for
// monsters yet.
if (immediate > 0)
{
- if (mons_near(this) && player_monster_visible(this))
- {
- mprf("%s %s!", name(DESC_CAP_THE).c_str(),
- amount > 0 ? "rots" : "looks less resilient");
- }
-
- hurt(agent, immediate);
+ // If quiet, don't clean up the monster in order to credit properly.
+ hurt(agent, immediate, BEAM_MISSILE, !quiet);
if (alive())
{
@@ -5950,6 +5951,8 @@ void monsters::rot(actor *agent, int amount, int immediate)
add_ench(mon_enchant(ENCH_ROT, std::min(amount, 4),
agent->kill_alignment()));
+
+ return (true);
}
int monsters::hurt(const actor *agent, int amount, beam_type flavour,
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 71635c8c13..086782330c 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -6995,10 +6995,10 @@ void player::drain_stat(int stat, int amount, actor *attacker)
lose_stat(stat, amount, false, "");
}
-void player::rot(actor *who, int amount, int immediate)
+bool player::rot(actor *who, int amount, int immediate, bool quiet)
{
if (res_rotting() > 0 || amount <= 0)
- return;
+ return (false);
if (immediate > 0)
rot_hp(immediate);
@@ -7007,6 +7007,8 @@ void player::rot(actor *who, int amount, int immediate)
if (one_chance_in(4))
disease_player(50 + random2(100));
+
+ return (true);
}
bool player::drain_exp(actor *who, bool quiet)