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 | |
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')
-rw-r--r-- | crawl-ref/source/beam.cc | 17 | ||||
-rw-r--r-- | crawl-ref/source/item_use.cc | 25 |
2 files changed, 31 insertions, 11 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 265732b9d3..e07caf2742 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -3634,9 +3634,8 @@ void bolt::tracer_affect_player() for (unsigned int i = 0; i < messages.size(); ++i) mpr(messages[i].c_str(), MSGCH_WARN); - range_used += range_used_on_hit(&you); - apply_hit_funcs(&you, 0); + range_used += range_used_on_hit(&you); } bool bolt::misses_player() @@ -4020,11 +4019,11 @@ void bolt::affect_player_enchantment() } } + apply_hit_funcs(&you, 0); + // Regardless of effect, we need to know if this is a stopper // or not - it seems all of the above are. range_used += range_used_on_hit(&you); - - apply_hit_funcs(&you, 0); } @@ -4291,8 +4290,8 @@ void bolt::tracer_enchantment_affect_monster(monsters* mon) handle_stop_attack_prompt(mon); if (!beam_cancelled) { - range_used += range_used_on_hit(mon); apply_hit_funcs(mon, 0); + range_used += range_used_on_hit(mon); } } @@ -4451,9 +4450,10 @@ void bolt::tracer_nonenchantment_affect_monster(monsters* mon) mpr(messages[i].c_str(), MSGCH_MONSTER_DAMAGE); } + apply_hit_funcs(mon, final); + // Either way, we could hit this monster, so update range used. range_used += range_used_on_hit(mon); - apply_hit_funcs(mon, final); } void bolt::tracer_affect_monster(monsters* mon) @@ -4552,8 +4552,8 @@ void bolt::enchantment_affect_monster(monsters* mon) beogh_follower_convert(mon, true); } - range_used += range_used_on_hit(mon); apply_hit_funcs(mon, 0); + range_used += range_used_on_hit(mon); } void bolt::monster_post_hit(monsters* mon, int dmg) @@ -4947,9 +4947,8 @@ void bolt::affect_monster(monsters* mon) mon = &orig; } - range_used += range_used_on_hit(mon); - apply_hit_funcs(mon, final, corpse); + range_used += range_used_on_hit(mon); } bool bolt::has_saving_throw() const 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); } |