diff options
author | abrahamwl <abrahamwl@gmail.com> | 2009-10-27 22:04:57 -0700 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2009-10-28 14:54:38 +0100 |
commit | 1cd5f5996970da48788b3bdc615652ed66763b70 (patch) | |
tree | 29022993b49c92c1c5070b4f9ecc02331f3688c3 /crawl-ref/source/effects.cc | |
parent | 67ab2ff904da3b6a3f426ee6d6a6b8e4116f199a (diff) | |
download | crawl-ref-1cd5f5996970da48788b3bdc615652ed66763b70.tar.gz crawl-ref-1cd5f5996970da48788b3bdc615652ed66763b70.zip |
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?
Diffstat (limited to 'crawl-ref/source/effects.cc')
-rw-r--r-- | crawl-ref/source/effects.cc | 59 |
1 files changed, 59 insertions, 0 deletions
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) { |