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:
6YSFIRQ6JNNS2VEAPMCZQGOULJHI2KO53KQM3B2JGNJ75DADVIAAC
555G3RUJXRR3AUJBVQJFUIOCI26ZSPTHU6XPAOT3C2YOMBUQHELAC
V633AMMPMHJB5ZLP5IHFXCT6FCENVTPX25TY7T5MF2QZLDDN24HAC
CPNHNCRBZMUV7CYPWFKICGRW57LDRGJPCMFSJV6NB72YBGR67BNQC
MVZIJGT5LJCX7SSVWP6ODXUHMFCSVUWWYCARDOTVREB6PXRZG4XQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
SVY2PTCLXR3KNPQAWXVXTTGCC5DR334HOAKHYO3VDDRWM2BWMALAC
SOCJXX6MMOXLBEWBID4QN5FW2YNYULNNN7K3IRL7RSWK5EUNAZLQC
JYEEOUYQ7ZPKOGWUV7VCORBVSOLF2UCBFBH3TR75RGOSS6PNKYUAC
R22TTMI6WXWULC7ODKFF3QCB7MOTETQQ6IR4BUCUPOCQKQNCTT5AC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
ILADK4YNPQVYLZYDMGGBYN2EBBCIPCDNUCWZH27DQTKOMVUDLVMAC
ACKNLTFL2RI3PMRWLNRVLRWGQAMLRFKNGNS5LED6NFE5GVGFIHFAC
FWR2SQFT5VG5BG7DJQQ7NKT2O5OMS3ID2OKLSR4L2CSZUL3RJJYQC
QDTVLBRGHDTRUVT7I3O72K6TMOYAUSAJBZUHGOEFU2RKJNUPWZSQC
ZNBSMRH6K5SUITIIOYG4NT6ZW63LDTT6ZPT6BLS7T3FS6KMKNNSQC
UADYVV3UD5ERJTZZJGY4EUQ4NJ2JSBG7YYUJ75ZRBIXRQXQKOJPAC
// Effects that occur after all other effects, even if the monster is dead.
// For example, explosions that would hit other creatures, but we want
// to deal with only one creature at a time, so that's handled last.
// You probably want to call player_monattk_hit_effects instead, as that
// function calls this one.
bool melee_attack::player_monattk_final_hit_effects(bool mondied)
{
for (unsigned int i = 0; i < final_effects.size(); ++i)
{
switch (final_effects[i].flavor)
{
case FINEFF_LIGHTNING_DISCHARGE:
if (see_cell(final_effects[i].location))
mpr("Electricity arcs through the water!");
conduct_electricity(final_effects[i].location, attacker);
break;
}
}
return mondied;
}
// Returns true if the combat round should end here.
// Check for arcing in water, and add the final effect.
const coord_def& pos = defender->pos();
// We know the defender is neither airborne nor electricity
// resistant, from above, but is it on water?
if (feat_is_water(grd(pos)))
{
attack_final_effect effect;
effect.flavor = FINEFF_LIGHTNING_DISCHARGE;
effect.location = pos;
final_effects.push_back(effect);
}
}
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;
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);
}
// 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));
}