Fixed script release breaking followers when called mid-movement.

This commit is contained in:
Ariel A 2022-03-15 19:20:13 -04:00
parent c78736c94f
commit 570b5927c2

View file

@ -1032,7 +1032,15 @@ bool8 ScrCmd_applymovement_at(struct ScriptContext *ctx)
static bool8 WaitForMovementFinish(void)
{
return ScriptMovement_IsObjectMovementFinished(sMovingNpcId, sMovingNpcMapNum, sMovingNpcMapGroup);
if (ScriptMovement_IsObjectMovementFinished(sMovingNpcId, sMovingNpcMapNum, sMovingNpcMapGroup)) {
struct ObjectEvent *objEvent = GetFollowerObject();
// If the follower is still entering the pokeball, wait for it to finish too
// This prevents a `release` after this script command from getting the follower stuck in an intermediate state
if (sMovingNpcId != OBJ_EVENT_ID_FOLLOWER && objEvent && ObjectEventGetHeldMovementActionId(objEvent) == MOVEMENT_ACTION_ENTER_POKEBALL)
return ScriptMovement_IsObjectMovementFinished(objEvent->localId, objEvent->mapNum, objEvent->mapGroup);
return TRUE;
}
return FALSE;
}
bool8 ScrCmd_waitmovement(struct ScriptContext *ctx)