Skip to content

Commit

Permalink
Added GoalReached(Actor oldgoal) function to actors.
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorCooke committed Nov 20, 2024
1 parent ebc3665 commit 895462c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/playsim/p_enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2371,6 +2371,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look2)
return 0;
}

void GoalReached(AActor* self, AActor* oldgoal)
{
if (self && self->Level)
self->Level->localEventManager->WorldThingGoalReached(self, oldgoal);
}

DEFINE_ACTION_FUNCTION(AActor, GoalReached)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(oldgoal, AActor);
GoalReached(self, oldgoal);
return 0;
}

//=============================================================================
//
// A_Chase
Expand Down Expand Up @@ -2594,8 +2608,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi
}
actor->flags7 &= ~MF7_INCHASE;
actor->goal = newgoal;
if (actor->goal != savedgoal)
actor->Level->localEventManager->WorldThingGoalReached(actor, savedgoal);
GoalReached(actor, savedgoal);
return;
}
if (actor->goal == actor->target) goto nomissile;
Expand Down
3 changes: 3 additions & 0 deletions wadsrc/static/zscript/actors/actor.zs
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,9 @@ class Actor : Thinker native
movecount = random[TryWalk](0, 15);
return true;
}

// Calls WorldThingGoalReached.
native void GoalReached(Actor oldgoal);

native bool TryMove(vector2 newpos, int dropoff, bool missilecheck = false, FCheckPosition tm = null);
native bool CheckMove(vector2 newpos, int flags = 0, FCheckPosition tm = null);
Expand Down

0 comments on commit 895462c

Please sign in to comment.