×void CWraithWing::Process(
//Process a wraithwing for movement.
//
//Params:
const int /*nLastCommand*/, //(in) Last swordsman command.
CCueEvents &CueEvents) //(in/out) Accepts pointer to an IDList object that will be populated
//with codes indicating events that happened that may correspond to
//sound or graphical effects.
{
int dxFirst, dyFirst, dx, dy;
//Find where to move to.
UINT wX, wY;
if (!GetTarget(wX,wY))
return;
const int distance = nDist(this->wX, this->wY, wX, wY);
// Get directed movement toward player
if (!GetDirectMovement(wX, wY, dxFirst, dyFirst, dx, dy))
return;
//Wraithwings are cowards and only attack in numbers.
if (distance <= 5)
{
// Let's look for another wraithwing, ready to pounce.
bool runaway = true;
for (CMonster *pSeek = this->pCurrentGame->pRoom->pFirstMonster;
pSeek != NULL; pSeek = pSeek->pNext)
{
if (pSeek->wType != M_WWING ||
(pSeek->wX == this->wX && pSeek->wY == this->wY))
continue;
const int dist2 = nDist(pSeek->wX, pSeek->wY, wX, wY);
// We want a wraithwing who is within 2 of the same
// distance we are from the player, but who is at least
// 3 away from us. (Based on old code.)
if (abs (dist2 - distance) <= 2 &&
nDist(pSeek->wX, pSeek->wY, this->wX, this->wY) >= 3)
{
// Another wraithwing is able to collaborate
runaway = false;
break;
}
}
if (runaway)
{
if (distance == 5)
dx = dy = 0; // Don't get involved
else
{
// Flee!
dxFirst = dx = -dxFirst;
dyFirst = dy = -dyFirst;
GetBestMove(dx, dy);
}
}
}
//Move wraithwing to new destination square.
MakeStandardMove(CueEvents,dx,dy);
SetOrientation(dxFirst, dyFirst);
}
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.