fix: Made Common_Movement_* 'safe' for followers

fixed #31
This commit is contained in:
Ariel A 2022-03-15 19:58:48 -04:00
parent ad839d0333
commit d7a021a914
3 changed files with 15 additions and 2 deletions

View file

@ -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

View file

@ -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

View file

@ -1000,7 +1000,7 @@ 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
@ -1011,7 +1011,10 @@ bool8 ScrCmd_applymovement(struct ScriptContext *ctx)
ScriptMovement_StartObjectMovementScript(localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, movementScript);
sMovingNpcId = localId;
// Force follower into pokeball
if (localId != OBJ_EVENT_ID_FOLLOWER && !FlagGet(FLAG_SAFE_FOLLOWER_MOVEMENT)) {
if (localId != OBJ_EVENT_ID_FOLLOWER
&& !FlagGet(FLAG_SAFE_FOLLOWER_MOVEMENT)
&& (movementScript < Common_Movement_FollowerSafeStart || movementScript > Common_Movement_FollowerSafeEnd))
{
objEvent = GetFollowerObject();
// return early if no follower or in shadowing state
if (objEvent == NULL || gSprites[objEvent->spriteId].data[1] == 0)