From 3d1ddbc80e2a0f19b1c9764218bde98779853fca Mon Sep 17 00:00:00 2001 From: inkoalawetrust <56005600+inkoalawetrust@users.noreply.github.com> Date: Fri, 8 Apr 2022 06:32:16 +0300 Subject: [PATCH] Toggleable player following. (#1583) * Added MF8_DONTFOLLOWPLAYERS. Added the MF8_DONTFOLLOWPLAYERS flag, which allows friendly monsters to not follow their FriendPlayer when they have no target or goal left to head to. * Changed the order that the DONTFOLLOWPLAYERS check runs in. This is done to not produce unnecessary overhead on hostile monsters. --- src/playsim/actor.h | 1 + src/playsim/p_enemy.cpp | 2 +- src/scripting/thingdef_data.cpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/playsim/actor.h b/src/playsim/actor.h index 70f2c60b3f..cbb98f69ce 100644 --- a/src/playsim/actor.h +++ b/src/playsim/actor.h @@ -423,6 +423,7 @@ enum ActorFlag8 MF8_MAP07BOSS2 = 0x00800000, // MBF21 boss death. MF8_AVOIDHAZARDS = 0x01000000, // MBF AI enhancement. MF8_STAYONLIFT = 0x02000000, // MBF AI enhancement. + MF8_DONTFOLLOWPLAYERS = 0x04000000, // [inkoalwetrust] Friendly monster will not follow players. }; // --- mobj.renderflags --- diff --git a/src/playsim/p_enemy.cpp b/src/playsim/p_enemy.cpp index 207f9aaf0d..24c0909817 100644 --- a/src/playsim/p_enemy.cpp +++ b/src/playsim/p_enemy.cpp @@ -1092,7 +1092,7 @@ void P_RandomChaseDir (AActor *actor) int turndir; // Friendly monsters like to head toward a player - if (actor->flags & MF_FRIENDLY) + if (actor->flags & MF_FRIENDLY && !(actor->flags8 & MF8_DONTFOLLOWPLAYERS)) { AActor *player; DVector2 delta; diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index f3e1c910f8..eeee67547a 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -338,6 +338,7 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(MF8, MAP07BOSS2, AActor, flags8), DEFINE_FLAG(MF8, AVOIDHAZARDS, AActor, flags8), DEFINE_FLAG(MF8, STAYONLIFT, AActor, flags8), + DEFINE_FLAG(MF8, DONTFOLLOWPLAYERS, AActor, flags8), // Effect flags DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects),