Fixed follower script release bug.

This commit is contained in:
Ariel A 2021-12-19 22:27:39 -05:00
parent bdcbb5c700
commit 29150322ce
3 changed files with 10 additions and 28 deletions

View file

@ -92,6 +92,7 @@ void OverrideSecretBaseDecorationSpriteScript(u8 localId, u8 mapNum, u8 mapGroup
void GetMapCoordsFromSpritePos(s16, s16, s16 *, s16 *);
u8 GetFaceDirectionAnimNum(u8);
void SetSpritePosToOffsetMapCoords(s16 *, s16 *, s16, s16);
void ClearObjectEventMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite);
void ObjectEventClearHeldMovement(struct ObjectEvent *);
void ObjectEventClearHeldMovementIfActive(struct ObjectEvent *);
struct Pokemon * GetFirstLiveMon(void);

View file

@ -157,7 +157,6 @@ static void CameraObject_0(struct Sprite *);
static void CameraObject_1(struct Sprite *);
static void CameraObject_2(struct Sprite *);
static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8 localId, struct ObjectEventTemplate *templates, u8 count);
static void ClearObjectEventMovement(struct ObjectEvent *, struct Sprite *);
static void ObjectEventSetSingleMovement(struct ObjectEvent *, struct Sprite *, u8);
static void SetSpriteDataForNormalStep(struct Sprite *, u8, u8);
static void InitSpriteForFigure8Anim(struct Sprite *sprite);
@ -5105,7 +5104,7 @@ bool8 MovementType_Invisible_Step2(struct ObjectEvent *objectEvent, struct Sprit
return FALSE;
}
static void ClearObjectEventMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite)
void ClearObjectEventMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite)
{
objectEvent->singleMovementActive = FALSE;
objectEvent->heldMovementActive = FALSE;

View file

@ -1011,14 +1011,8 @@ bool8 ScrCmd_applymovement(struct ScriptContext *ctx)
if (objEvent == NULL || gSprites[objEvent->spriteId].data[1] == 0) {
return FALSE;
}
// ClearEventObjectMovement(
objEvent->singleMovementActive = 0;
objEvent->heldMovementActive = FALSE;
objEvent->heldMovementFinished = FALSE;
objEvent->movementActionId = 0xFF;
gSprites[objEvent->spriteId].data[1] = 0;
// )
gSprites[objEvent->spriteId].animCmdIndex = 0; // Needed because of weird animCmdIndex stuff
ClearObjectEventMovement(objEvent, &gSprites[objEvent->spriteId]);
gSprites[objEvent->spriteId].animCmdIndex = 0; // Needed to set start frame of animation
ScriptMovement_StartObjectMovementScript(OBJ_EVENT_ID_FOLLOWER, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, EnterPokeballMovement);
}
return FALSE;
@ -1268,15 +1262,9 @@ bool8 ScrCmd_releaseall(struct ScriptContext *ctx)
{
u8 playerObjectId;
struct ObjectEvent *followerObject = GetFollowerObject();
if (followerObject) { // Release follower from movement
// ObjectEventClearHeldMovement( TODO: Change the way data[1] determines state
followerObject->singleMovementActive = FALSE;
followerObject->movementActionId = 0xFF;
followerObject->heldMovementActive = FALSE;
followerObject->heldMovementFinished = FALSE;
gSprites[followerObject->spriteId].data[2] = 0;
// )
}
// 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]);
HideFieldMessageBox();
playerObjectId = GetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0);
@ -1290,15 +1278,9 @@ bool8 ScrCmd_release(struct ScriptContext *ctx)
{
u8 playerObjectId;
struct ObjectEvent *followerObject = GetFollowerObject();
if (followerObject) { // Release follower from movement
// ObjectEventClearHeldMovement(
followerObject->singleMovementActive = FALSE;
followerObject->movementActionId = 0xFF;
followerObject->heldMovementActive = FALSE;
followerObject->heldMovementFinished = FALSE;
gSprites[followerObject->spriteId].data[2] = 0;
// )
}
// 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]);
HideFieldMessageBox();
if (gObjectEvents[gSelectedObjectEvent].active)