the beam took.
In mons_cast_noise(), if the spell's target isn't a dead-on hit for anything, then fire a tracer to figure out who it looks like the spell is aimed at.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8074 c06c8d41-db1a-0410-9941-cceddc491573
LCDK2CK4O2RBLF2MAX75S2Q6ZKAX46WD6GOQDVIXUGHHXXZXMHRQC
YZDUBIAT6TBWILPMUACASUTVW3CKHPNZ6LJQGJGEE7RLXWXCZOGQC
ZEFGFQHN6J2S6EIPX7EPDG22C5YXTI6DMKQHHRCLWN5MQC44KY3AC
JWJGOMVBPZRSP2VSHLFFFDIF2CS6UPBA6AHL7DAJWGBCHAV3PJDQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
AJHVP42Y67SB4NKFMZB24524PGX2XA5WLFNEFV52MIGTS47ALMVQC
CDFS7Z74W5HKPQIHQICOG442KQFXUSBGGLDDQLE3MG74T44YU6AQC
SNSU5AMDAZNG55NQ4JDHU2YBK62MXPIE2QTSYS7PGV7Y2N3VJBFQC
AYU5OVG2HZO46KDAPKUWAVHS5HTYFKUWIMIRMTHAXVVFEDJE7YPAC
// Monster might be aiming past the real target, or maybe some fuzz has
// been applied because the monster can't see the target.
if (target == "something" && targeted)
{
bolt tracer = pbolt;
fire_tracer(monster, tracer);
const std::vector<coord_def> &path = tracer.path_taken;
bool mons_targ_aligned = false;
for (unsigned int i = 0; i < path.size(); i++)
{
const coord_def pos = path[i];
if (pos == monster->pos())
continue;
const int midx = mgrd(pos);
if (pos == you.pos())
{
// Be egotistical and assume that the monster is aiming at
// the player, rather than the player being in the path of
// a beam aimed at an ally.
if (!mons_wont_attack(monster))
{
target = "you";
break;
}
// If the ally is confused or aiming at an invisible enemy,
// with the player in the path, act like it's targeted at
// the player if there isn't any visible target earlier
// in the path.
else if (target == "something")
{
target = "you";
mons_targ_aligned = true;
}
}
else if (visible_beam && midx != NON_MONSTER
&& you.can_see(&menv[midx]))
{
bool is_aligned = mons_aligned(midx, monster->mindex());
std::string name = menv[midx].name(DESC_NOCAP_THE);
if (target == "something")
{
mons_targ_aligned = is_aligned;
target = name;
}
// If the first target was aligned with the beam source then
// the first subsequent non-aligned monster in the path will
// take it's place.
else if (mons_targ_aligned && !is_aligned)
{
mons_targ_aligned = false;
target = name;
}
}
}
}