Skip to content

Commit

Permalink
Enhanced pathing for floaters
Browse files Browse the repository at this point in the history
Their checks are now 2D instead of 3D.
  • Loading branch information
MajorCooke authored and madame-rachelle committed Mar 12, 2024
1 parent 0d9855c commit f081ef1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/playsim/p_enemy.cpp
Expand Up @@ -2733,14 +2733,24 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
sight = P_CheckSight(actor, actor->target, SF_SEEPASTBLOCKEVERYTHING);
}
else sight = 0;


// Out of sight, so keep pathfinding
if (sight == 0)
{
if (pnode && !(actor->goal->flags & MF_AMBUSH))
{
AActor* temp = actor->target;
actor->target = actor->goal;
bool reached = (P_CheckMeleeRange(actor));
bool reached = false;
// 2D checks for floaters, 3D otherwise
if (actor->flags & MF_FLOAT)
{
bool vrange = !!(actor->flags5 & MF5_NOVERTICALMELEERANGE);
actor->flags5 |= MF5_NOVERTICALMELEERANGE;
P_CheckMeleeRange(actor);
if (!vrange) actor->flags5 &= ~(MF5_NOVERTICALMELEERANGE);
}
else reached = (P_CheckMeleeRange(actor));
actor->target = temp;

if (reached)
Expand Down
14 changes: 14 additions & 0 deletions wadsrc/static/zscript/actors/actor.zs
Expand Up @@ -829,6 +829,20 @@ class Actor : Thinker native
if (!next || next == node)
continue;

// 2D checks for floaters, 3D for ground
Actor tar = target;
bool vrange = bNOVERTICALMELEERANGE;
bNOVERTICALMELEERANGE = bFLOAT;
target = next;

bool inrange = CheckMeleeRange();

target = tar;
bNOVERTICALMELEERANGE = vrange;

if (inrange)
continue;

// Monsters will never 'reach' AMBUSH flagged nodes. Instead, the engine
// indicates they're reached the moment they tele/portal.

Expand Down

0 comments on commit f081ef1

Please sign in to comment.