From d06e1d4af6d099458914f967b0f6298a815d6084 Mon Sep 17 00:00:00 2001 From: Ariel A <24759293+aarant@users.noreply.github.com> Date: Wed, 29 Dec 2021 20:22:13 -0500 Subject: [PATCH] Added flag for safe follower movement. --- include/constants/flags.h | 1 + src/scrcmd.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/constants/flags.h b/include/constants/flags.h index 793fe11354..f76e7b232f 100644 --- a/include/constants/flags.h +++ b/include/constants/flags.h @@ -1641,6 +1641,7 @@ #define FLAG_ENABLE_MULTI_CORRIDOR_DOOR (SPECIAL_FLAGS_START + 0x2) #define FLAG_SPECIAL_FLAG_UNUSED_0x4003 (SPECIAL_FLAGS_START + 0x3) // Unused Flag #define FLAG_STORING_ITEMS_IN_PYRAMID_BAG (SPECIAL_FLAGS_START + 0x4) +#define FLAG_SAFE_FOLLOWER_MOVEMENT (SPECIAL_FLAGS_START + 0x5) // When set, applymovement does not put the follower inside a pokeball // FLAG_SPECIAL_FLAG_0x4005 - 0x407F also exist and are unused #define SPECIAL_FLAGS_END (SPECIAL_FLAGS_START + 0x7F) diff --git a/src/scrcmd.c b/src/scrcmd.c index 572fb7a601..6ec06cced9 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1005,7 +1005,7 @@ bool8 ScrCmd_applymovement(struct ScriptContext *ctx) ScriptMovement_StartObjectMovementScript(localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, movementScript); sMovingNpcId = localId; - if (localId != OBJ_EVENT_ID_FOLLOWER) { // Force follower into pokeball + if (localId != OBJ_EVENT_ID_FOLLOWER && !FlagGet(FLAG_SAFE_FOLLOWER_MOVEMENT)) { // Force follower into pokeball objEvent = GetFollowerObject(); // return early if no follower or in shadowing state if (objEvent == NULL || gSprites[objEvent->spriteId].data[1] == 0) { @@ -1262,6 +1262,7 @@ bool8 ScrCmd_releaseall(struct ScriptContext *ctx) { u8 playerObjectId; struct ObjectEvent *followerObject = GetFollowerObject(); + FlagClear(FLAG_SAFE_FOLLOWER_MOVEMENT); // Release follower from movement iff it exists and is in the shadowing state if (followerObject && gSprites[followerObject->spriteId].data[1] == 0) ClearObjectEventMovement(followerObject, &gSprites[followerObject->spriteId]); @@ -1278,6 +1279,7 @@ bool8 ScrCmd_release(struct ScriptContext *ctx) { u8 playerObjectId; struct ObjectEvent *followerObject = GetFollowerObject(); + FlagClear(FLAG_SAFE_FOLLOWER_MOVEMENT); // Release follower from movement iff it exists and is in the shadowing state if (followerObject && gSprites[followerObject->spriteId].data[1] == 0) ClearObjectEventMovement(followerObject, &gSprites[followerObject->spriteId]);