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 7, 2018
1 parent 13de44f commit ebcd6e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/p_enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,30 @@ int P_Move (AActor *actor)
return true;
}

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

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();

ACTION_RETURN_INT(good);
}

//=============================================================================
//
// TryWalk
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 ebcd6e8

Please sign in to comment.