Try a bit harder to avoid using "nothing" as the target of the spell.
Set the target to "DEAD FOE" or "NON-EXISTANT FOE" if the monster is attempting to cast a spell at a dead or non-existant foe.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8376 c06c8d41-db1a-0410-9941-cceddc491573
RB27VEL4Q3D7FEATFRMZVHS4N2ZTWCZ4LQUK3QLAUKQVXNIZNPBAC // Monsters should only use targeted spells while foe == MHITNOT// if they're targeting themselves.else if (monster->foe == MHITNOT && !monster->confused())target = "NONEXISTANT FOE";else if (!invalid_monster_index(monster->foe)&& menv[monster->foe].type == -1){target = "DEAD FOE";}
// If the monster gestures to create an invisible beam then// assume that anything close to the beam is the intended target.// Also, if the monster gestures to create a visible beam but it// misses still say that the monster gestured "at" the target,// rather than "past".if (gestured || target == "nothing")targ_prep = "at";
const actor* foe = monster->get_foe();const monsters* m_foe = (foe && foe->atype() == ACT_MONSTER) ?dynamic_cast<const monsters*>(foe) : NULL;// If we still can't find what appears to be the target, and the// monster isn't just throwing the spell in a random direction,// we should be able to tell what the monster was aiming for if// we can see the monster's foe and the beam (or the beam path// implied by gesturing). But only if the beam didn't actually hit// anything (but if it did hit something, why didn't that monster// show up in the beam's path?)if (targeted && target == "nothing" && foe != NULL&& (tracer.foe_info.count + tracer.friend_info.count) == 0&& (you.can_see(foe) || foe == &you) && !monster->confused()&& (visible_beam || gestured)){if (foe == &you)target = "you";elsetarget = m_foe->name(DESC_NOCAP_THE);if (pbolt.aimed_at_spot)targ_prep = "next to";elsetarg_prep = "past";}
// If the monster gestures to create an invisible beam then// assume that anything close to the beam is the intended target.// Also, if the monster gestures to create a visible beam but it// misses still say that the monster gestured "at" the target,// rather than "past".if (gestured || target == "nothing")targ_prep = "at";