Skip to content

Commit

Permalink
Added a function for triggering use/push specials for usage in custom…
Browse files Browse the repository at this point in the history
… monster AI.
  • Loading branch information
Doom2fan committed Dec 8, 2018
1 parent ad71834 commit 90bb9eb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/scripting/vmthunks_actors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,35 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, LookForPlayers, P_LookForPlayers)
ACTION_RETURN_BOOL(P_LookForPlayers(self, allaround, params));
}

static int CheckMonsterUseSpecials(AActor *self)
{
spechit_t spec;
int good = 0;

if (!(self->flags6 & MF6_NOTRIGGER))
{
while (spechit.Pop (spec))
{
// [RH] let monsters push lines, as well as use them
if (((self->flags4 & MF4_CANUSEWALLS) && P_ActivateLine (spec.line, self, 0, SPAC_Use)) ||
((self->flags2 & MF2_PUSHWALL) && P_ActivateLine (spec.line, self, 0, SPAC_Push)))
{
good |= spec.line == self->BlockingLine ? 1 : 2;
}
}
}
else spechit.Clear();

return good;
}

DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckMonsterUseSpecials, CheckMonsterUseSpecials)
{
PARAM_SELF_PROLOGUE(AActor);

ACTION_RETURN_INT(CheckMonsterUseSpecials(self));
}

DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_Wander, A_Wander)
{
PARAM_SELF_PROLOGUE(AActor);
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/zscript/actor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ class Actor : Thinker native
native void CheckFakeFloorTriggers (double oldz, bool oldz_has_viewheight = false);
native bool CheckFor3DFloorHit(double z, bool trigger);
native bool CheckFor3DCeilingHit(double z, bool trigger);
native int CheckMonsterUseSpecials();

native bool CheckMissileSpawn(double maxdist);
native bool CheckPosition(Vector2 pos, bool actorsonly = false, FCheckPosition tm = null);
Expand Down

0 comments on commit 90bb9eb

Please sign in to comment.