Skip to content

Commit

Permalink
Export A_DoChase to zscript and make A_Chase a direct native function
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoLuis0 committed Mar 12, 2024
1 parent 730ef1a commit d77c3b1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
39 changes: 32 additions & 7 deletions src/playsim/p_enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3018,21 +3018,16 @@ void A_Chase(AActor *self)
A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0);
}

DEFINE_ACTION_FUNCTION(AActor, A_Chase)
void A_ChaseNative(AActor * self, int meleelabel, int missilelabel, int flags)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_STATELABEL(meleelabel);
PARAM_STATELABEL(missilelabel);
PARAM_INT(flags);

FName meleename = ENamedName(meleelabel - 0x10000000);
FName missilename = ENamedName(missilelabel - 0x10000000);
if (meleename != NAME__a_chase_default || missilename != NAME__a_chase_default)
{
FState *melee = StateLabels.GetState(meleelabel, self->GetClass());
FState *missile = StateLabels.GetState(missilelabel, self->GetClass());
if ((flags & CHF_RESURRECT) && P_CheckForResurrection(self, false))
return 0;
return;

A_DoChase(self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE),
!!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE), flags & 0x3fffffff);
Expand All @@ -3041,6 +3036,36 @@ DEFINE_ACTION_FUNCTION(AActor, A_Chase)
{
A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0);
}
}

DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_Chase, A_ChaseNative)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_STATELABEL(meleelabel);
PARAM_STATELABEL(missilelabel);
PARAM_INT(flags);

A_ChaseNative(self, meleelabel, missilelabel, flags);

return 0;
}

void A_DoChaseNative(AActor * self, FState *melee, FState *missile, int flags)
{
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 & 0x3fffffff);
}

DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_DoChase, A_DoChaseNative)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_STATE(melee);
PARAM_STATE(missile);
PARAM_INT(flags);

A_DoChaseNative(self, melee, missile, flags);

return 0;
}

Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/actors/actor.zs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,7 @@ class Actor : Thinker native
void A_Fall() { A_NoBlocking(); }
native void A_Look();
native void A_Chase(statelabel melee = '_a_chase_default', statelabel missile = '_a_chase_default', int flags = 0);
native void A_DoChase(State melee, State missile, int flags = 0);
native void A_VileChase();
native bool A_CheckForResurrection(State state = null, Sound snd = 0);
native void A_BossDeath();
Expand Down

0 comments on commit d77c3b1

Please sign in to comment.