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/effects.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'crawl-ref/source/effects.cc') diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index a73b69d800..6dc8b2dbcf 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -382,6 +382,65 @@ void immolation(int pow, int caster, coord_def where, bool known, beam.explode(); } +static bool _conduct_electricity_hit(bolt& beam, actor* victim, int dmg, int corpse) +{ + if (!victim->alive() || victim->res_elec() > 0 || victim->airborne()) + return (false); + + return (true); +} + +static bool _conduct_electricity_damage(bolt &beam, actor* victim, + int &dmg, std::string &dmg_msg) +{ + dmg = (10 + random2(15)) / 2; + + return false; +} + +static bool _conduct_electricity_aoe(bolt& beam, const coord_def& target) +{ + if (feat_is_water(grd(target))) + return true; + + return false; +} + +void conduct_electricity(coord_def where, actor *attacker) +{ + const char *aux = "arcing electricity"; + + bolt beam; + + beam.flavour = BEAM_ELECTRICITY; + beam.type = dchar_glyph(DCHAR_FIRED_BURST); + beam.damage = dice_def(1, 15); + beam.target = where; + beam.name = "electric current"; + beam.colour = LIGHTCYAN; + beam.aux_source = aux; + beam.ex_size = 1; + beam.is_explosion = true; + beam.effect_known = true; + beam.affects_items = false; + beam.aoe_funcs.push_back(_conduct_electricity_aoe); + beam.hit_funcs.push_back(_conduct_electricity_hit); + beam.damage_funcs.push_back(_conduct_electricity_damage); + + if (attacker == &you) + { + beam.thrower = KILL_YOU; + beam.beam_source = NON_MONSTER; + } + else + { + beam.thrower = KILL_MON; + beam.beam_source = attacker->mindex(); + } + + beam.explode(false, true); +} + void cleansing_flame(int pow, int caster, coord_def where, actor *attacker) { -- cgit v1.2.3-54-g00ecf