Clear the path instead of advancing the node when crossing portals.

- If an actor crosses back over a portal because they're blocked, it will result in false positives.
- Fixed nodes not being targeted for aim direction.
This commit is contained in:
Major Cooke 2024-02-24 19:44:57 -06:00 committed by Rachael Alexanderson
commit d71af3683a
3 changed files with 32 additions and 17 deletions

View file

@ -951,13 +951,13 @@ void P_DoNewChaseDir (AActor *actor, double deltax, double deltay)
//
//=============================================================================
void P_NewChaseDir(AActor * actor)
void DoNewChaseDir(AActor * actor, bool node)
{
DVector2 delta;
actor->strafecount = 0;
if ((actor->flags5&MF5_CHASEGOAL || actor->goal == actor->target) && actor->goal!=NULL)
if ((node || actor->flags5&MF5_CHASEGOAL || actor->goal == actor->target) && actor->goal != nullptr)
{
delta = actor->Vec2To(actor->goal);
}
@ -1096,6 +1096,11 @@ void P_NewChaseDir(AActor * actor)
}
void P_NewChaseDir(AActor* actor)
{
DoNewChaseDir(actor, false);
}
//=============================================================================
//
// P_RandomChaseDir
@ -2579,7 +2584,11 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
}
// [RH] Don't attack if just moving toward goal
if (actor->target == actor->goal || (actor->flags5&MF5_CHASEGOAL && actor->goal != nullptr))
static const PClass* nodeCls = PClass::FindClass(NAME_PathNode);
bool pnode = (actor->goal && nodeCls->IsAncestorOf(actor->goal->GetClass()));
if (!pnode &&
(actor->target == actor->goal || (actor->flags5&MF5_CHASEGOAL && actor->goal)))
{
AActor * savedtarget = actor->target;
actor->target = actor->goal;
@ -2727,8 +2736,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
if (sight == 0)
{
static const PClass* nodeCls = PClass::FindClass(NAME_PathNode);
if (actor->goal && !(actor->goal->flags & MF_AMBUSH) && nodeCls->IsAncestorOf(actor->goal->GetClass()))
if (pnode && !(actor->goal->flags & MF_AMBUSH))
{
AActor* temp = actor->target;
actor->target = actor->goal;
@ -2766,7 +2774,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
// chase towards player
if ((--actor->movecount < 0 && !(flags & CHF_NORANDOMTURN)) || (!P_SmartMove(actor) && !(flags & CHF_STOPIFBLOCKED)))
{
P_NewChaseDir(actor);
DoNewChaseDir(actor, pnode);
}
// if the move was illegal, reset it
// (copied from A_SerpentChase - it applies to everything with CANTLEAVEFLOORPIC!)
@ -2782,7 +2790,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
}
}
if (!(flags & CHF_STOPIFBLOCKED))
P_NewChaseDir(actor);
DoNewChaseDir(actor, pnode);
}
}
else if (dontmove && actor->movecount > 0) actor->movecount--;