summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/fight.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-18 21:31:22 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-18 21:31:22 +0000
commita6d89fbabb631ecbdcbb86c59aa70c28fd7da696 (patch)
treedeea069713bf8cbaf641f4804ff2024674c3b1a3 /crawl-ref/source/fight.cc
parentcff1172ef03ea196d3bf59557e983bd0ad6cb7cc (diff)
downloadcrawl-ref-a6d89fbabb631ecbdcbb86c59aa70c28fd7da696.tar.gz
crawl-ref-a6d89fbabb631ecbdcbb86c59aa70c28fd7da696.zip
Consolidate the player and monster draining functions in fight.cc, make
monster draining take multiple levels of negative energy resistance into account, and only set the necromancy conduct if draining actually took place, as with draining beams. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8551 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/fight.cc')
-rw-r--r--crawl-ref/source/fight.cc34
1 files changed, 10 insertions, 24 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 289bf5e9f0..5847e8fd4e 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -2050,34 +2050,20 @@ int melee_attack::fire_res_apply_cerebov_downgrade(int res)
void melee_attack::drain_defender()
{
- // What to do, they're different...
- if (defender->atype() == ACT_PLAYER)
- {
- drain_player();
- obvious_effect = true;
- }
- else
- drain_monster();
-}
-
-void melee_attack::drain_player()
-{
- defender->drain_exp(attacker);
-
- special_damage = random2(damage_done) /
- (2 + defender->res_negative_energy()) + 1;
-}
-
-void melee_attack::drain_monster()
-{
- if (defender->res_negative_energy() > 0 || one_chance_in(3))
+ if (defender->atype() == ACT_MONSTER && one_chance_in(3))
return;
- defender->drain_exp(attacker);
+ const int rn = defender->res_negative_energy();
- special_damage = 1 + (random2(damage_done) / 2);
+ if (defender->drain_exp(attacker))
+ {
+ if (defender->atype() == ACT_PLAYER)
+ obvious_effect = true;
+
+ attacker->god_conduct(DID_NECROMANCY, 2);
+ }
- attacker->god_conduct(DID_NECROMANCY, 2);
+ special_damage = 1 + random2(damage_done) / (2 + rn);
}
bool melee_attack::distortion_affects_defender()