Added A_Wander Flags.

- WF_NORANDOMTURN and WF_DONTANGLE do the same as their CHF_ counterparts for A_Wander.
This commit is contained in:
MajorCooke 2015-11-05 15:33:56 -06:00
parent f357a36c5c
commit da9c3ff9d2
4 changed files with 42 additions and 13 deletions

View file

@ -1799,7 +1799,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look)
} }
else else
{ {
CALL_ACTION(A_Wander, self); A_Wander(self);
} }
} }
else else
@ -1957,7 +1957,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx)
} }
else else
{ {
CALL_ACTION(A_Wander, self); A_Wander(self);
} }
} }
} }
@ -2054,7 +2054,27 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ClearLastHeard)
// A_Wander // A_Wander
// //
//========================================================================== //==========================================================================
DEFINE_ACTION_FUNCTION(AActor, A_Wander) enum WFFlags
{
WF_NORANDOMTURN = 1,
WF_DONTANGLE = 2,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Wander)
{
ACTION_PARAM_START(1);
ACTION_PARAM_INT(flags, 0);
A_Wander(self, flags);
}
// [MC] I had to move this out from within A_Wander in order to allow flags to
// pass into it. That meant replacing the CALL_ACTION(A_Wander) functions with
// just straight up defining A_Wander in order to compile. Looking around though,
// actors from the games themselves just do a straight A_Chase call itself so
// I saw no harm in it.
void A_Wander(AActor *self, int flags)
{ {
// [RH] Strife probably clears this flag somewhere, but I couldn't find where. // [RH] Strife probably clears this flag somewhere, but I couldn't find where.
// This seems as good a place as any. // This seems as good a place as any.
@ -2073,7 +2093,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Wander)
} }
// turn towards movement direction if not there yet // turn towards movement direction if not there yet
if (self->movedir < DI_NODIR) if (!(flags & WF_DONTANGLE) && (self->movedir < DI_NODIR))
{ {
self->angle &= (angle_t)(7 << 29); self->angle &= (angle_t)(7 << 29);
int delta = self->angle - (self->movedir << 29); int delta = self->angle - (self->movedir << 29);
@ -2087,14 +2107,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_Wander)
} }
} }
if (--self->movecount < 0 || !P_Move (self)) if (self->movecount >= 0)
self->movecount--;
if ((!(flags & WF_NORANDOMTURN) && self->movecount < 0) || !P_Move(self))
{ {
P_RandomChaseDir(self); P_RandomChaseDir(self);
self->movecount += 5; self->movecount += 5;
} }
} }
//========================================================================== //==========================================================================
// //
// A_Look2 // A_Look2
@ -2309,7 +2331,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
//CALL_ACTION(A_Look, actor); //CALL_ACTION(A_Look, actor);
if (actor->target == NULL) if (actor->target == NULL)
{ {
if (!dontmove) CALL_ACTION(A_Wander, actor); if (!dontmove) A_Wander(actor);
actor->flags &= ~MF_INCHASE; actor->flags &= ~MF_INCHASE;
return; return;
} }

View file

@ -61,7 +61,6 @@ void A_Weave(AActor *self, int xyspeed, int zspeed, fixed_t xydist, fixed_t zdis
void A_Unblock(AActor *self, bool drop); void A_Unblock(AActor *self, bool drop);
DECLARE_ACTION(A_Look) DECLARE_ACTION(A_Look)
DECLARE_ACTION(A_Wander)
DECLARE_ACTION(A_BossDeath) DECLARE_ACTION(A_BossDeath)
DECLARE_ACTION(A_Pain) DECLARE_ACTION(A_Pain)
DECLARE_ACTION(A_MonsterRail) DECLARE_ACTION(A_MonsterRail)
@ -72,6 +71,7 @@ DECLARE_ACTION(A_FreezeDeathChunks)
DECLARE_ACTION(A_BossDeath) DECLARE_ACTION(A_BossDeath)
void A_Chase(AActor *self); void A_Chase(AActor *self);
void A_Wander(AActor *self, int flags = 0);
void A_FaceTarget(AActor *actor, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270, angle_t ang_offset = 0, angle_t pitch_offset = 0, int flags = 0); void A_FaceTarget(AActor *actor, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270, angle_t ang_offset = 0, angle_t pitch_offset = 0, int flags = 0);
void A_Face(AActor *self, AActor *other, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270, angle_t ang_offset = 0, angle_t pitch_offset = 0, int flags = 0); void A_Face(AActor *self, AActor *other, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270, angle_t ang_offset = 0, angle_t pitch_offset = 0, int flags = 0);

View file

@ -176,7 +176,7 @@ ACTOR Actor native //: Thinker
action native A_SkullPop(class<Actor> skulltype = "BloodySkull"); action native A_SkullPop(class<Actor> skulltype = "BloodySkull");
action native A_CheckPlayerDone(); action native A_CheckPlayerDone();
action native A_Wander(); action native A_Wander(int flags = 0);
action native A_Look2(); action native A_Look2();
action native A_TossGib(); action native A_TossGib();
action native A_SentinelBob(); action native A_SentinelBob();

View file

@ -513,6 +513,13 @@ enum
CBF_SETONPTR = 1 << 4, //Sets the pointer change on the actor doing the checking instead of self. CBF_SETONPTR = 1 << 4, //Sets the pointer change on the actor doing the checking instead of self.
}; };
// Wander Flags
enum
{
WF_NORANDOMTURN = 1,
WF_DONTANGLE = 2,
};
// This is only here to provide one global variable for testing. // This is only here to provide one global variable for testing.
native int testglobalvar; native int testglobalvar;