From 1cd5f5996970da48788b3bdc615652ed66763b70 Mon Sep 17 00:00:00 2001 From: abrahamwl Date: Tue, 27 Oct 2009 22:04:57 -0700 Subject: Electrocution discharge in water ala FR 1637214 Weapons of electrocution now discharge in water, if the target is touching the water and not rElec, hitting all adjacent water-touching non-rElec creatures for about half the normal electrocution damage. Particularly notable new code is the implementation of an area-of-effect callback for beams, as well as a function and structure for weapon effects that should only happen after the target would have died, if it was going to die, and therefore cannot safely make use of its data. Issues that still need to be decided: - How doe Xom feel about this? (eg. If creatures hurt themselves this way.) - Should it ask you if you want to attack when you know the discharge will hit yourself? --- crawl-ref/source/beam.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/beam.cc') diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 89b038d6dd..9e2153d18c 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -5661,8 +5661,15 @@ void bolt::determine_affected_cells(explosion_map& m, const coord_def& delta, if (feat_is_solid(dngn_feat) && !feat_is_wall(dngn_feat) && stop_at_statues) return; - // Hmm, I think we're OK. - m(delta + centre) = std::min(count, m(delta + centre)); + // Check if it passes the callback functions. + bool hits = true; + for (unsigned int i = 0; i < aoe_funcs.size(); ++i) + hits = (*aoe_funcs[i])(*this, loc) && hits; + + if (hits) { + // Hmm, I think we're OK. + m(delta + centre) = std::min(count, m(delta + centre)); + } // Now recurse in every direction. for (int i = 0; i < 8; ++i) @@ -5785,7 +5792,7 @@ bolt::bolt() : range(-2), type('*'), is_explosion(false), is_big_cloud(false), aimed_at_spot(false), aux_source(), affects_nothing(false), affects_items(true), effect_known(true), draw_delay(15), special_explosion(NULL), - range_funcs(), damage_funcs(), hit_funcs(), + range_funcs(), damage_funcs(), hit_funcs(), aoe_funcs(), obvious_effect(false), seen(false), path_taken(), range_used(0), is_tracer(false), aimed_at_feet(false), msg_generated(false), passed_target(false), in_explosion_phase(false), -- cgit v1.2.3-54-g00ecf