weird stuff with source and target. Make setup_mons_cast() deal with it for monster spells which the monster aims at itself.
Force range to 0 when source == target.
In mons_cast() assert that targeted spells have an in-bounds target and that harmful spells are only aimed at the caster when the caster is confused.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8000 c06c8d41-db1a-0410-9941-cceddc491573
AMNWAYRX7CBFRYF3DNCHWIMVXLLVISWGJKYYCFN4MUZN7M3XP2KQC
N7KLZSYDHJYZ6UYV6YSXCO53NLWOFWJF43IOKZHDLFLR67B2USPAC
BTHEX36BHZOAGTT5SNO6OPWDAZJQSUUNDXSJ77FBEFZE3NGJ7CAQC
NEBHNUSRRR2MFLAJNV4YH34TCSWHBXMHB3VYXMQQPTTECDZK3DYQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
UADYVV3UD5ERJTZZJGY4EUQ4NJ2JSBG7YYUJ75ZRBIXRQXQKOJPAC
AJHVP42Y67SB4NKFMZB24524PGX2XA5WLFNEFV52MIGTS47ALMVQC
SNSU5AMDAZNG55NQ4JDHU2YBK62MXPIE2QTSYS7PGV7Y2N3VJBFQC
#ifdef DEBUG
const unsigned int flags = get_spell_flags(spell_cast);
ASSERT(!(flags & (SPFLAG_TESTING | SPFLAG_MAPPING)));
// Targeted spells need a valid target.
ASSERT(!(flags & SPFLAG_TARGETING_MASK) || in_bounds(pbolt.target));
// Don't target harmful spells at self unless confused.
ASSERT(monster->pos() != pbolt.target || monster->confused()
|| (flags & (SPFLAG_HELPFUL | SPFLAG_ESCAPE | SPFLAG_RECOVERY)));
#endif