summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-08 22:37:22 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-08 22:37:22 +0000
commit0d3cdb013523051328e5885d8aedad80338b01f4 (patch)
treecbfcef8b7a045c6844e619e7c3372fd2589dcda8
parentf55a8b913e4fb43166f6a3cbd083a4a0f5154358 (diff)
downloadcrawl-ref-0d3cdb013523051328e5885d8aedad80338b01f4.tar.gz
crawl-ref-0d3cdb013523051328e5885d8aedad80338b01f4.zip
Fix [2484631]: Move all monster-based experience-draining effects other
than the setting of special_damage from mons_apply_attack_flavour() to mons_perform_attack_rounds(), after the check for chaos effects' banishing the defender. Without this, the latter check, which only determines if a monster is alive, can succeed on mortally draining a monster as well as banishing it, and the drained monster's death event will never be triggered. Among other things, the check is based on the assumption that all attack flavors only set special_damage instead of directly damaging and possibly killing the monster. With this, the assumption is now true. The change in r8336 to allow cleanup of the dead in monsters::hurt() even for already dead monsters is necessary for this, as well, since draining can still kill the monster via monsters::hurt() before special_damage does. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8338 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/fight.cc25
1 files changed, 16 insertions, 9 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index dedc2c494a..b106f8c4f1 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -2058,15 +2058,6 @@ void melee_attack::drain_monster()
def_name(DESC_NOCAP_THE).c_str());
}
- if (one_chance_in(5))
- {
- def->hit_dice--;
- def->experience = 0;
- }
-
- def->max_hit_points -= 2 + random2(3);
- def->hurt(attacker, 2 + random2(3), BEAM_NEG, false);
-
special_damage = 1 + (random2(damage_done) / 2);
attacker->god_conduct(DID_NECROMANCY, 2);
}
@@ -4553,6 +4544,10 @@ void melee_attack::mons_perform_attack_rounds()
mons_set_weapon(attk);
to_hit = mons_to_hit();
+ const bool draining_attack = damage_brand == SPWPN_DRAINING
+ || (attk.flavour == AF_DRAIN_XP
+ && attacker != defender);
+
const bool chaos_attack = damage_brand == SPWPN_CHAOS
|| (attk.flavour == AF_CHAOS
&& attacker != defender);
@@ -4661,6 +4656,18 @@ void melee_attack::mons_perform_attack_rounds()
break;
}
+ if (draining_attack && defender->atype() == ACT_MONSTER)
+ {
+ if (one_chance_in(5))
+ {
+ def->hit_dice--;
+ def->experience = 0;
+ }
+
+ def->max_hit_points -= 2 + random2(3);
+ def->hurt(attacker, 2 + random2(3), BEAM_NEG, false);
+ }
+
defender->hurt(attacker, damage_done + special_damage);
if (!defender->alive())