- Added CHF_STOPIFBLOCKED and CHF_DONTTURN macro.

- CHF_STOPIFBLOCKED simply prevents the actor from changing directions for movement.
- CHF_DONTTURN implies NORANDOMTURN, NOPOSTATTACKTURN and STOPIFBLOCKED.
This commit is contained in:
MajorCooke 2016-01-07 19:20:02 -06:00
parent da9c3ff9d2
commit bfd9e2bc1c
2 changed files with 28 additions and 13 deletions

View file

@ -2195,6 +2195,7 @@ enum ChaseFlags
CHF_NORANDOMTURN = 32,
CHF_DONTANGLE = 64,
CHF_NOPOSTATTACKTURN = 128,
CHF_STOPIFBLOCKED = 256,
};
void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove, int flags)
@ -2349,10 +2350,15 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
if (actor->flags & MF_JUSTATTACKED)
{
actor->flags &= ~MF_JUSTATTACKED;
if (!actor->isFast() && !dontmove && !(flags & CHF_NOPOSTATTACKTURN))
if (!actor->isFast() && !dontmove && !(flags & CHF_NOPOSTATTACKTURN) && !(flags & CHF_STOPIFBLOCKED))
{
P_NewChaseDir (actor);
}
//Because P_TryWalk would never be reached if the actor is stopped by a blocking object,
//need to make sure the movecount is reset, otherwise they will just keep attacking
//over and over again.
if (flags & CHF_STOPIFBLOCKED)
actor->movecount = pr_trywalk() & 15;
actor->flags &= ~MF_INCHASE;
return;
}
@ -2510,6 +2516,8 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
if (actor->strafecount)
actor->strafecount--;
bool movecheck = P_Move(actor);
// class bosses don't do this when strafing
if ((!fastchase || !actor->FastChaseStrafeCount) && !dontmove)
{
@ -2521,24 +2529,25 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
// chase towards player
if (actor->movecount >= 0)
actor->movecount--;
if (((!(flags & CHF_NORANDOMTURN)) && (actor->movecount < 0)) || !P_Move(actor))
if (!(flags & CHF_STOPIFBLOCKED))
{
P_NewChaseDir (actor);
if ((!(flags & CHF_NORANDOMTURN) && (actor->movecount < 0)) || !movecheck)
P_NewChaseDir(actor);
}
// if the move was illegal, reset it
// (copied from A_SerpentChase - it applies to everything with CANTLEAVEFLOORPIC!)
if (actor->flags2&MF2_CANTLEAVEFLOORPIC && actor->floorpic != oldFloor )
{
if (P_TryMove (actor, oldX, oldY, false))
if (!(flags & CHF_STOPIFBLOCKED) && P_TryMove(actor, oldX, oldY, false))
{
if (nomonsterinterpolation)
{
actor->PrevX = oldX;
actor->PrevY = oldY;
}
P_NewChaseDir(actor);
}
P_NewChaseDir (actor);
}
}
else if (dontmove && actor->movecount > 0) actor->movecount--;

View file

@ -79,14 +79,20 @@ const int SXF_ISMASTER = 1 << 27;
const int SXF_ISTRACER = 1 << 28;
// Flags for A_Chase
const int CHF_FASTCHASE = 1;
const int CHF_NOPLAYACTIVE = 2;
const int CHF_NIGHTMAREFAST = 4;
const int CHF_RESURRECT = 8;
const int CHF_DONTMOVE = 16;
const int CHF_NORANDOMTURN = 32;
const int CHF_DONTANGLE = 64;
const int CHF_NOPOSTATTACKTURN = 128;
enum
{
CHF_FASTCHASE = 1,
CHF_NOPLAYACTIVE = 2,
CHF_NIGHTMAREFAST = 4,
CHF_RESURRECT = 8,
CHF_DONTMOVE = 16,
CHF_NORANDOMTURN = 32,
CHF_DONTANGLE = 64,
CHF_NOPOSTATTACKTURN = 128,
CHF_STOPIFBLOCKED = 256,
CHF_DONTTURN = CHF_NORANDOMTURN|CHF_NOPOSTATTACKTURN|CHF_STOPIFBLOCKED,
};
// Flags for A_LookEx
const int LOF_NOSIGHTCHECK = 1;