and add some explanatory comments.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7446 c06c8d41-db1a-0410-9941-cceddc491573
43JVVA7TDO34AZTBX4Y6VLCNRP2BHC4OAUGYNWLVYGUIL6HGESPQC
// The monster is moving in your direction, to attack or protect you.
if (newpos == you.pos() && mons_intel(monster) >= I_ANIMAL
// If the monster is moving in your direction, whether to attack or protect
// you, or towards a monster it intends to attack, check whether we first
// need to take a step to the side to make sure the reinforcement can
// follow through.
// First, check whether the monster is smart enough to consider this.
if ((newpos == you.pos()
|| mgrd(newpos) != NON_MONSTER && monster->foe == mgrd(newpos))
&& mons_intel(monster) >= I_ANIMAL
// If the monster is moving parallel to the x or y axis, check
// whether
// a) the neighbouring grids are blocked
// b) there are other unblocked grids adjacent to the target
// c) there's at least one allied monster waiting behind us.
// (For really smart monsters, also check whether there's a monster
// farther back in the corridor that has some kind of ranged attack.)