From f081ef1850e56de9505cef64d12f320ac446c90a Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sat, 9 Mar 2024 13:02:35 -0600 Subject: [PATCH] Enhanced pathing for floaters Their checks are now 2D instead of 3D. --- src/playsim/p_enemy.cpp | 14 ++++++++++++-- wadsrc/static/zscript/actors/actor.zs | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/playsim/p_enemy.cpp b/src/playsim/p_enemy.cpp index 0dc3fd0ef..aa2b40b99 100644 --- a/src/playsim/p_enemy.cpp +++ b/src/playsim/p_enemy.cpp @@ -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) diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 1c4ea98c8..f3482864f 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -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.