diff options
author | Adam Borowski <kilobyte@angband.pl> | 2009-11-11 20:38:24 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2009-11-12 00:58:17 +0100 |
commit | b104d76e5151eecedaefd142870b46691ef966b3 (patch) | |
tree | 85c94a345930b3bc8805dee6fb0517324a51ad5f /crawl-ref/source/item_use.cc | |
parent | 12bb914d94f41de46d8d84b532fe99c0c2e7b9fc (diff) | |
download | crawl-ref-b104d76e5151eecedaefd142870b46691ef966b3.tar.gz crawl-ref-b104d76e5151eecedaefd142870b46691ef966b3.zip |
Electricity discharge through water when hit by a charged projectile.
This also makes the order of hit_funcs vs range_funcs consistent. The latter
were usually called first, but not always -- contrary to what one would expect.
I made hit_funcs go first in all cases.
Diffstat (limited to 'crawl-ref/source/item_use.cc')
-rw-r--r-- | crawl-ref/source/item_use.cc | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 6d132baa5c..d0644d47ce 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -1898,6 +1898,19 @@ static bool _dispersal_hit_victim(bolt& beam, actor* victim, int dmg, return (true); } +static bool _electricity_water_explosion(const bolt &beam, const actor *victim, + int &used) +{ + used = 1000; + + ASSERT(!beam.is_tracer); + if (you.can_see(victim)) + mpr("Electricity arcs through the water!"); + conduct_electricity(victim->pos(), beam.agent()); + + return (true); +} + static bool _charged_hit_victim(bolt &beam, actor* victim, int &dmg, std::string &dmg_msg) { @@ -1906,12 +1919,20 @@ static bool _charged_hit_victim(bolt &beam, actor* victim, int &dmg, dmg += 10 + random2(15); - if (!beam.is_tracer && you.can_see(victim)) + if (beam.is_tracer) + return (false); + + if (you.can_see(victim)) if (victim->atype() == ACT_PLAYER) dmg_msg = "You are electrocuted!"; else dmg_msg = "There is a sudden explosion of sparks!"; - // TODO: lightning discharge into water + + if (feat_is_water(grd(victim->pos()))) + { + beam.range_funcs.insert(beam.range_funcs.begin(), + _electricity_water_explosion); + } return (false); } |