fix: improved follower pokemon lock and applymovement code
fixed #30, fixed #32
This commit is contained in:
parent
d7a021a914
commit
dbc11ad3d2
20
src/scrcmd.c
20
src/scrcmd.c
@ -1006,20 +1006,20 @@ bool8 ScrCmd_applymovement(struct ScriptContext *ctx)
|
||||
// When applying script movements to follower, it may have frozen animation that must be cleared
|
||||
if (localId == OBJ_EVENT_ID_FOLLOWER && (objEvent = GetFollowerObject()) && objEvent->frozen) {
|
||||
ClearObjectEventMovement(objEvent, &gSprites[objEvent->spriteId]);
|
||||
gSprites[objEvent->spriteId].animCmdIndex = 0; // Needed to set start frame of animation
|
||||
gSprites[objEvent->spriteId].animCmdIndex = 0; // Reset start frame of animation
|
||||
}
|
||||
ScriptMovement_StartObjectMovementScript(localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, movementScript);
|
||||
sMovingNpcId = localId;
|
||||
objEvent = GetFollowerObject();
|
||||
// Force follower into pokeball
|
||||
if (localId != OBJ_EVENT_ID_FOLLOWER
|
||||
&& !FlagGet(FLAG_SAFE_FOLLOWER_MOVEMENT)
|
||||
&& (movementScript < Common_Movement_FollowerSafeStart || movementScript > Common_Movement_FollowerSafeEnd))
|
||||
&& (movementScript < Common_Movement_FollowerSafeStart || movementScript > Common_Movement_FollowerSafeEnd)
|
||||
&& (objEvent = GetFollowerObject())
|
||||
&& !objEvent->invisible)
|
||||
{
|
||||
objEvent = GetFollowerObject();
|
||||
// return early if no follower or in shadowing state
|
||||
if (objEvent == NULL || gSprites[objEvent->spriteId].data[1] == 0)
|
||||
return FALSE;
|
||||
ClearObjectEventMovement(objEvent, &gSprites[objEvent->spriteId]);
|
||||
gSprites[objEvent->spriteId].animCmdIndex = 0; // Reset start frame of animation
|
||||
ScriptMovement_StartObjectMovementScript(OBJ_EVENT_ID_FOLLOWER, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, EnterPokeballMovement);
|
||||
}
|
||||
return FALSE;
|
||||
@ -1246,7 +1246,7 @@ bool8 ScrCmd_lockall(struct ScriptContext *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// lock freezes all object events except the player and the selected object immediately.
|
||||
// lock freezes all object events except the player, follower, and the selected object immediately.
|
||||
// The player and selected object are frozen after waiting for their current movement to finish.
|
||||
bool8 ScrCmd_lock(struct ScriptContext *ctx)
|
||||
{
|
||||
@ -1256,16 +1256,22 @@ bool8 ScrCmd_lock(struct ScriptContext *ctx)
|
||||
}
|
||||
else
|
||||
{
|
||||
struct ObjectEvent *followerObj = GetFollowerObject();
|
||||
if (gObjectEvents[gSelectedObjectEvent].active)
|
||||
{
|
||||
FreezeObjects_WaitForPlayerAndSelected();
|
||||
SetupNativeScript(ctx, IsFreezeSelectedObjectAndPlayerFinished);
|
||||
// follower is being talked to; keep it frozen
|
||||
if (gObjectEvents[gSelectedObjectEvent].localId == OBJ_EVENT_ID_FOLLOWER)
|
||||
followerObj = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
FreezeObjects_WaitForPlayer();
|
||||
SetupNativeScript(ctx, IsFreezePlayerFinished);
|
||||
}
|
||||
if (followerObj) // Unfreeze follower object
|
||||
UnfreezeObjectEvent(followerObj);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user