Merge branch 'followers' into followers-expanded-id
This commit is contained in:
commit
42d9b284b9
3 changed files with 27 additions and 8 deletions
|
@ -1,3 +1,6 @@
|
|||
@ Starting from here, these movements are considered
|
||||
@ 'safe' (won't put follower into a Pokeball)
|
||||
Common_Movement_FollowerSafeStart::
|
||||
Common_Movement_QuestionMark:
|
||||
emote_question_mark
|
||||
step_end
|
||||
|
@ -68,6 +71,10 @@ Common_Movement_WalkInPlaceRight:
|
|||
walk_in_place_right
|
||||
step_end
|
||||
|
||||
@ End of follower-safe movements
|
||||
Common_Movement_FollowerSafeEnd::
|
||||
step_end
|
||||
|
||||
Common_Movement_WalkUp6:
|
||||
walk_up
|
||||
walk_up
|
||||
|
|
|
@ -639,4 +639,7 @@ extern const u8 EventScript_TradeCenter_Chair0[];
|
|||
extern const u8 EventScript_ConfirmLeaveCableClubRoom[];
|
||||
extern const u8 EventScript_TerminateLink[];
|
||||
|
||||
extern const u8 Common_Movement_FollowerSafeStart[];
|
||||
extern const u8 Common_Movement_FollowerSafeEnd[];
|
||||
|
||||
#endif // GUARD_EVENT_SCRIPTS_H
|
||||
|
|
25
src/scrcmd.c
25
src/scrcmd.c
|
@ -1000,23 +1000,26 @@ bool8 ScrCmd_fadeinbgm(struct ScriptContext *ctx)
|
|||
bool8 ScrCmd_applymovement(struct ScriptContext *ctx)
|
||||
{
|
||||
u16 localId = VarGet(ScriptReadHalfword(ctx));
|
||||
const void *movementScript = (const void *)ScriptReadWord(ctx);
|
||||
const u8 *movementScript = (const u8 *)ScriptReadWord(ctx);
|
||||
struct ObjectEvent *objEvent;
|
||||
|
||||
// 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)) {
|
||||
objEvent = GetFollowerObject();
|
||||
// return early if no follower or in shadowing state
|
||||
if (objEvent == NULL || gSprites[objEvent->spriteId].data[1] == 0)
|
||||
return FALSE;
|
||||
if (localId != OBJ_EVENT_ID_FOLLOWER
|
||||
&& !FlagGet(FLAG_SAFE_FOLLOWER_MOVEMENT)
|
||||
&& (movementScript < Common_Movement_FollowerSafeStart || movementScript > Common_Movement_FollowerSafeEnd)
|
||||
&& (objEvent = GetFollowerObject())
|
||||
&& !objEvent->invisible)
|
||||
{
|
||||
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;
|
||||
|
@ -1243,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)
|
||||
{
|
||||
|
@ -1253,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…
Reference in a new issue