From f357a36c5cef92dd39ce7d389cdb9fcd8c33cb57 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 5 Nov 2015 13:01:44 -0600 Subject: [PATCH] - New A_Chase flags. - CHF_NORANDOMTURN: Actor will not randomly turn during chasing to pursue its target. It will only turn if it cannot keep moving forward. - CHF_DONTANGLE: Actor does not adjust its angle to match the movement direction. - CHF_NOPOSTATTACKTURN: Actor will not make its first turn after exiting its attacks. --- src/p_enemy.cpp | 43 +++++++++++++++++------------- wadsrc/static/actors/constants.txt | 3 +++ 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 5291101a5..669a9fbb6 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2163,7 +2163,19 @@ nosee: //============================================================================= #define CLASS_BOSS_STRAFE_RANGE 64*10*FRACUNIT -void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove) +enum ChaseFlags +{ + CHF_FASTCHASE = 1, + CHF_NOPLAYACTIVE = 2, + CHF_NIGHTMAREFAST = 4, + CHF_RESURRECT = 8, + CHF_DONTMOVE = 16, + CHF_NORANDOMTURN = 32, + CHF_DONTANGLE = 64, + CHF_NOPOSTATTACKTURN = 128, +}; + +void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove, int flags) { int delta; @@ -2225,7 +2237,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi { A_FaceTarget(actor); } - else if (actor->movedir < 8) + else if (!(flags & CHF_DONTANGLE) && actor->movedir < 8) { actor->angle &= (angle_t)(7<<29); delta = actor->angle - (actor->movedir << 29); @@ -2315,7 +2327,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi if (actor->flags & MF_JUSTATTACKED) { actor->flags &= ~MF_JUSTATTACKED; - if (!actor->isFast() && !dontmove) + if (!actor->isFast() && !dontmove && !(flags & CHF_NOPOSTATTACKTURN)) { P_NewChaseDir (actor); } @@ -2485,7 +2497,9 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi FTextureID oldFloor = actor->floorpic; // chase towards player - if (--actor->movecount < 0 || !P_Move (actor)) + if (actor->movecount >= 0) + actor->movecount--; + if (((!(flags & CHF_NORANDOMTURN)) && (actor->movecount < 0)) || !P_Move(actor)) { P_NewChaseDir (actor); } @@ -2662,15 +2676,6 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) // //========================================================================== -enum ChaseFlags -{ - CHF_FASTCHASE = 1, - CHF_NOPLAYACTIVE = 2, - CHF_NIGHTMAREFAST = 4, - CHF_RESURRECT = 8, - CHF_DONTMOVE = 16, -}; - DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Chase) { ACTION_PARAM_START(3); @@ -2683,23 +2688,23 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Chase) if (flags & CHF_RESURRECT && P_CheckForResurrection(self, false)) return; A_DoChase(self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE), - !!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE)); + !!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE), flags); } else // this is the old default A_Chase { - A_DoChase (self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false); + A_DoChase (self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, flags); } } DEFINE_ACTION_FUNCTION(AActor, A_FastChase) { - A_DoChase (self, true, self->MeleeState, self->MissileState, true, true, false); + A_DoChase (self, true, self->MeleeState, self->MissileState, true, true, false, 0); } DEFINE_ACTION_FUNCTION(AActor, A_VileChase) { if (!P_CheckForResurrection(self, true)) - A_DoChase (self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false); + A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0); } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ExtChase) @@ -2713,13 +2718,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ExtChase) // Now that A_Chase can handle state label parameters, this function has become rather useless... A_DoChase(self, false, domelee ? self->MeleeState:NULL, domissile ? self->MissileState:NULL, - playactive, nightmarefast, false); + playactive, nightmarefast, false, 0); } // for internal use void A_Chase(AActor *self) { - A_DoChase (self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false); + A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0); } //============================================================================= diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 213e2109d..01d92c103 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -84,6 +84,9 @@ 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; // Flags for A_LookEx const int LOF_NOSIGHTCHECK = 1;