summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spells2.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-08 19:13:50 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-08 19:13:50 +0000
commit99e98160d304efc49fcf48f905bbe3fa5c56c990 (patch)
tree87cdec98b7bb052183f651ebbb90c88d2d4ec552 /crawl-ref/source/spells2.cc
parent56a71346d6b688e17d98b70cf10461e87810e648 (diff)
downloadcrawl-ref-99e98160d304efc49fcf48f905bbe3fa5c56c990.tar.gz
crawl-ref-99e98160d304efc49fcf48f905bbe3fa5c56c990.zip
Count using vampiric draining on a friendly monster as an attack.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7190 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spells2.cc')
-rw-r--r--crawl-ref/source/spells2.cc65
1 files changed, 36 insertions, 29 deletions
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index f9a2adc796..d8264d3d2c 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -776,46 +776,53 @@ bool vampiric_drain(int pow, const dist &vmove)
monsters *monster = &menv[mgr];
- if (mons_is_unholy(monster))
- {
- mpr("Aaaarggghhhhh!");
- dec_hp(random2avg(39, 2) + 10, false, "vampiric drain backlash");
- return (false);
- }
+ god_conduct_trigger conducts[3];
+ disable_attack_conducts(conducts);
- if (mons_res_negative_energy(monster))
+ const bool success = !stop_attack_prompt(monster, false, false);
+
+ if (success)
{
- canned_msg(MSG_NOTHING_HAPPENS);
- return (false);
- }
+ set_attack_conducts(conducts, monster);
- // The practical maximum of this is about 25 (pow @ 100). -- bwr
- int inflicted = 3 + random2avg( 9, 2 ) + random2(pow) / 7;
+ if (mons_is_unholy(monster))
+ {
+ mpr("Aaaarggghhhhh!");
+ dec_hp(random2avg(39, 2) + 10, false, "vampiric drain backlash");
+ return (false);
+ }
- if (inflicted >= monster->hit_points)
- inflicted = monster->hit_points;
+ if (mons_res_negative_energy(monster))
+ {
+ canned_msg(MSG_NOTHING_HAPPENS);
+ return (false);
+ }
- if (inflicted >= you.hp_max - you.hp)
- inflicted = you.hp_max - you.hp;
+ // The practical maximum of this is about 25 (pow @ 100). -- bwr
+ int inflicted = 3 + random2avg(9, 2) + random2(pow) / 7;
- if (inflicted == 0)
- {
- canned_msg(MSG_NOTHING_HAPPENS);
- return (false);
- }
+ inflicted = std::min(monster->hit_points, inflicted);
+ inflicted = std::min(you.hp_max - you.hp, inflicted);
+
+ if (inflicted == 0)
+ {
+ canned_msg(MSG_NOTHING_HAPPENS);
+ return (false);
+ }
- mprf("You feel life coursing from %s into your body!",
- monster->name(DESC_NOCAP_THE).c_str());
+ mprf("You feel life coursing from %s into your body!",
+ monster->name(DESC_NOCAP_THE).c_str());
- behaviour_event(monster, ME_WHACK, MHITYOU, you.pos());
- monster->hurt(&you, inflicted);
+ behaviour_event(monster, ME_ANNOY, MHITYOU, you.pos());
+ monster->hurt(&you, inflicted);
- if (monster->alive())
- print_wounds(monster);
+ if (monster->alive())
+ print_wounds(monster);
- inc_hp(inflicted / 2, false);
+ inc_hp(inflicted / 2, false);
+ }
- return (true);
+ return (success);
}
bool burn_freeze(int pow, beam_type flavour, int targetmon)