diff --git a/include/constants/event_object_movement.h b/include/constants/event_object_movement.h index 223650081..13e91c415 100755 --- a/include/constants/event_object_movement.h +++ b/include/constants/event_object_movement.h @@ -237,11 +237,12 @@ #define MOVEMENT_ACTION_WALK_RIGHT_AFFINE 0x97 #define MOVEMENT_ACTION_LEVITATE 0x98 #define MOVEMENT_ACTION_STOP_LEVITATE 0x99 -#define MOVEMENT_ACTION_DESTROY_EXTRA_TASK_IF_AT_TOP 0x9A +#define MOVEMENT_ACTION_STOP_LEVITATE_AT_TOP 0x9A #define MOVEMENT_ACTION_FIGURE_8 0x9B #define MOVEMENT_ACTION_FLY_UP 0x9C #define MOVEMENT_ACTION_FLY_DOWN 0x9D #define MOVEMENT_ACTION_STEP_END 0xFE +#define MOVEMENT_ACTION_NONE 0xFF #endif // GUARD_CONSTANTS_EVENT_OBJECT_MOVEMENT_H diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 446d0dd4e..9deacfbb7 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -86,9 +86,9 @@ void LoadPlayerObjectReflectionPalette(u16, u8); void LoadSpecialObjectReflectionPalette(u16, u8); void TryMoveObjectEventToMapCoords(u8, u8, u8, s16, s16); void PatchObjectPalette(u16, u8); -void sub_808E16C(s16, s16); +void SpawnObjectEventsOnReturnToField(s16, s16); void OverrideSecretBaseDecorationSpriteScript(u8 localId, u8 mapNum, u8 mapGroup, u8 decorCat); -void sub_8092FF0(s16, s16, s16 *, s16 *); +void GetMapCoordsFromSpritePos(s16, s16, s16 *, s16 *); u8 GetFaceDirectionAnimNum(u8); void SetSpritePosToOffsetMapCoords(s16 *, s16 *, s16, s16); void ObjectEventClearHeldMovement(struct ObjectEvent *); @@ -110,7 +110,7 @@ void FreeAndReserveObjectSpritePalettes(void); void SetObjectEventSpritePosByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y); void ResetObjectPriority(u8, u8, u8); void SetObjectPriority(u8, u8, u8, u8); -void sub_808E75C(s16, s16); +void AllowObjectAtPosTriggerGroundEffects(s16, s16); void ObjectEventGetLocalIdAndMap(struct ObjectEvent *objectEvent, void *localId, void *mapNum, void *mapGroup); void ShiftObjectEventCoords(struct ObjectEvent *, s16, s16); void MoveObjectEventToMapCoords(struct ObjectEvent *, s16, s16); @@ -175,16 +175,8 @@ bool8 IsZCoordMismatchAt(u8, s16, s16); void UnfreezeObjectEvent(struct ObjectEvent *); u8 FindLockedObjectEventIndex(struct ObjectEvent *); bool8 obj_npc_ministep(struct Sprite *sprite); -bool8 sub_80976EC(struct Sprite *sprite); -void sub_80976DC(struct Sprite *, u8); -void sub_809783C(struct Sprite *, u8, u8, u8); -void DoShadowFieldEffect(struct ObjectEvent *); -u8 sub_809785C(struct Sprite *); -u8 sub_80978E4(struct Sprite *); void SetAndStartSpriteAnim(struct Sprite *, u8, u8); bool8 SpriteAnimEnded(struct Sprite *); -void CreateLevitateMovementTask(struct ObjectEvent *); -void DestroyExtraMovementTask(u8); void UnfreezeObjectEvents(void); void FreezeObjectEventsExceptOne(u8 objectEventId); void TurnObjectEventSprite(u8, u8); @@ -195,7 +187,7 @@ u8 GetMoveDirectionFastAnimNum(u8); u8 GetMoveDirectionFasterAnimNum(u8); u8 GetMoveDirectionFastestAnimNum(u8); u8 GetLedgeJumpDirection(s16, s16, u8); -void CameraObjectSetFollowedObjectId(u8 objectId); +void CameraObjectSetFollowedSpriteId(u8 objectId); u16 GetObjectPaletteTag(u8 palSlot); void UpdateObjectEventSpriteInvisibility(struct Sprite *sprite, bool8 invisible); s16 GetFigure8XOffset(s16 idx); diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index c30ce0b6f..903fe6ef1 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -6,7 +6,7 @@ void ClearPlayerAvatarInfo(void); void SetPlayerAvatarExtraStateTransition(u8, u8); u8 GetPlayerAvatarGenderByGraphicsId(u8); bool8 TestPlayerAvatarFlags(u8); -u8 GetPlayerAvatarObjectId(void); +u8 GetPlayerAvatarSpriteId(void); void PlayerGetDestCoords(s16 *, s16 *); u8 GetPlayerFacingDirection(void); u8 GetPlayerMovementDirection(void); diff --git a/src/data/object_events/movement_action_func_tables.h b/src/data/object_events/movement_action_func_tables.h index 8cf7d1699..295bd51fa 100755 --- a/src/data/object_events/movement_action_func_tables.h +++ b/src/data/object_events/movement_action_func_tables.h @@ -252,7 +252,7 @@ u8 MovementAction_AcroEndWheelieMoveRight_Step0(struct ObjectEvent *, struct Spr u8 MovementAction_AcroEndWheelieMoveRight_Step1(struct ObjectEvent *, struct Sprite *); u8 MovementAction_Levitate_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_StopLevitate_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_DestroyExtraTaskIfAtTop_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_StopLevitateAtTop_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_StoreAndLockAnim_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_Finish(struct ObjectEvent *, struct Sprite *); u8 MovementAction_FreeAndUnlockAnim_Step0(struct ObjectEvent *, struct Sprite *); @@ -416,7 +416,7 @@ u8 (*const gMovementActionFuncs_WalkLeftAffine[])(struct ObjectEvent *, struct S u8 (*const gMovementActionFuncs_WalkRightAffine[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_Levitate[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_StopLevitate[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_DestroyExtraTaskIfAtTop[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_StopLevitateAtTop[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_Figure8[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_FlyUp[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_FlyDown[])(struct ObjectEvent *, struct Sprite *); @@ -576,7 +576,7 @@ u8 (*const *const gMovementActionFuncs[])(struct ObjectEvent *, struct Sprite *) [MOVEMENT_ACTION_WALK_RIGHT_AFFINE] = gMovementActionFuncs_WalkRightAffine, [MOVEMENT_ACTION_LEVITATE] = gMovementActionFuncs_Levitate, [MOVEMENT_ACTION_STOP_LEVITATE] = gMovementActionFuncs_StopLevitate, - [MOVEMENT_ACTION_DESTROY_EXTRA_TASK_IF_AT_TOP] = gMovementActionFuncs_DestroyExtraTaskIfAtTop, + [MOVEMENT_ACTION_STOP_LEVITATE_AT_TOP] = gMovementActionFuncs_StopLevitateAtTop, [MOVEMENT_ACTION_FIGURE_8] = gMovementActionFuncs_Figure8, [MOVEMENT_ACTION_FLY_UP] = gMovementActionFuncs_FlyUp, [MOVEMENT_ACTION_FLY_DOWN] = gMovementActionFuncs_FlyDown, @@ -602,7 +602,7 @@ u8 (*const gMovementActionFuncs_FaceRight[])(struct ObjectEvent *, struct Sprite MovementAction_PauseSpriteAnim, }; -u8 (*const gUnknown_0850DEE8[])(u8) = { +static u8 (*const sDirectionAnimFuncsBySpeed[])(u8) = { GetMoveDirectionAnimNum, GetMoveDirectionFastAnimNum, GetMoveDirectionFastAnimNum, @@ -1507,7 +1507,7 @@ u8 (*const gMovementActionFuncs_StopLevitate[])(struct ObjectEvent *, struct Spr MovementAction_Finish, }; -u8 (*const gMovementActionFuncs_DestroyExtraTaskIfAtTop[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_DestroyExtraTaskIfAtTop_Step0, +u8 (*const gMovementActionFuncs_StopLevitateAtTop[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_StopLevitateAtTop_Step0, MovementAction_Finish, }; diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 746642e15..75e4a5cd8 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -32,31 +32,37 @@ // this file was known as evobjmv.c in Game Freak's original source +// Sprite data used throughout +#define sObjEventId data[0] +#define sTypeFuncId data[1] // Index into corresponding gMovementTypeFuncs_* table +#define sActionFuncId data[2] // Index into corresponding gMovementActionFuncs_* table + + #define movement_type_def(setup, table) \ static u8 setup##_callback(struct ObjectEvent *, struct Sprite *);\ void setup(struct Sprite *sprite)\ {\ - UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->data[0]], sprite, setup##_callback);\ + UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->sObjEventId], sprite, setup##_callback);\ }\ static u8 setup##_callback(struct ObjectEvent *objectEvent, struct Sprite *sprite)\ {\ - return table[sprite->data[1]](objectEvent, sprite);\ + return table[sprite->sTypeFuncId](objectEvent, sprite);\ } #define movement_type_empty_callback(setup) \ static u8 setup##_callback(struct ObjectEvent *, struct Sprite *);\ void setup(struct Sprite *sprite)\ {\ - UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->data[0]], sprite, setup##_callback);\ + UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->sObjEventId], sprite, setup##_callback);\ }\ static u8 setup##_callback(struct ObjectEvent *objectEvent, struct Sprite *sprite)\ {\ return 0;\ } -EWRAM_DATA u8 sCurrentReflectionType = 0; -EWRAM_DATA u16 sCurrentSpecialObjectPaletteTag = 0; -EWRAM_DATA struct LockedAnimObjectEvents *gLockedAnimObjectEvents = {0}; +static EWRAM_DATA u8 sCurrentReflectionType = 0; +static EWRAM_DATA u16 sCurrentSpecialObjectPaletteTag = 0; +static EWRAM_DATA struct LockedAnimObjectEvents *sLockedAnimObjectEvents = {0}; static void MoveCoordsInDirection(u32, s16 *, s16 *, s16, s16); static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *, struct Sprite *); @@ -70,8 +76,8 @@ static void UpdateObjectEventSpriteAnimPause(struct ObjectEvent *, struct Sprite static bool8 IsCoordOutsideObjectEventMovementRange(struct ObjectEvent *, s16, s16); static bool8 IsMetatileDirectionallyImpassable(struct ObjectEvent *, s16, s16, u8); static bool8 DoesObjectCollideWithObjectAt(struct ObjectEvent *, s16, s16); -static void sub_8096530(struct ObjectEvent *, struct Sprite *); -static void UpdateObjEventSpriteVisibility(struct ObjectEvent *, struct Sprite *); +static void UpdateObjectEventOffscreen(struct ObjectEvent *, struct Sprite *); +static void UpdateObjectEventSpriteVisibility(struct ObjectEvent *, struct Sprite *); static void ObjectEventUpdateMetatileBehaviors(struct ObjectEvent*); static void GetGroundEffectFlags_Reflection(struct ObjectEvent*, u32*); static void GetGroundEffectFlags_TallGrassOnSpawn(struct ObjectEvent*, u32*); @@ -115,14 +121,14 @@ static void GetObjectEventMovingCameraOffset(s16 *, s16 *); static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8); static void LoadObjectEventPalette(u16); static void RemoveObjectEventIfOutsideView(struct ObjectEvent *); -static void sub_808E1B8(u8, s16, s16); +static void SpawnObjectEventOnReturnToField(u8, s16, s16); static void SetPlayerAvatarObjectEventIdAndObjectId(u8, u8); -static void sub_808E38C(struct ObjectEvent *); -static u8 sub_808E8F4(const struct SpritePalette *); +static void ResetObjectEventFldEffData(struct ObjectEvent *); +static u8 LoadSpritePaletteIfTagExists(const struct SpritePalette *); static u8 FindObjectEventPaletteIndexByTag(u16); -static void sub_808EAB0(u16, u8); +static void _PatchObjectPalette(u16, u8); static bool8 ObjectEventDoesZCoordMatch(struct ObjectEvent *, u8); -static void ObjectCB_CameraObject(struct Sprite *); +static void SpriteCB_CameraObject(struct Sprite *); static void CameraObject_0(struct Sprite *); static void CameraObject_1(struct Sprite *); static void CameraObject_2(struct Sprite *); @@ -133,14 +139,30 @@ static void oamt_npc_ministep_reset(struct Sprite *, u8, u8); static void InitSpriteForFigure8Anim(struct Sprite *sprite); static bool8 AnimateSpriteInFigure8(struct Sprite *sprite); static void UpdateObjectEventSprite(struct Sprite *); +static void DoShadowFieldEffect(struct ObjectEvent *); +static void SetJumpSpriteData(struct Sprite *, u8, u8, u8); +static void SetWalkSlowSpriteData(struct Sprite *sprite, u8 direction); +static bool8 UpdateWalkSlowAnim(struct Sprite *sprite); +static u8 DoJumpSpriteMovement(struct Sprite *sprite); +static u8 DoJumpSpecialSpriteMovement(struct Sprite *sprite); +static void CreateLevitateMovementTask(struct ObjectEvent *); +static void DestroyLevitateMovementTask(u8); static const struct SpriteFrameImage sPicTable_PechaBerryTree[]; const u8 gReflectionEffectPaletteMap[] = {1, 1, 6, 7, 8, 9, 6, 7, 8, 9, 11, 11, 0, 0, 0, 0}; -const struct SpriteTemplate gCameraSpriteTemplate = {0, 0xFFFF, &gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, ObjectCB_CameraObject}; +static const struct SpriteTemplate sCameraSpriteTemplate = { + .tileTag = 0, + .paletteTag = 0xFFFF, + .oam = &gDummyOamData, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_CameraObject +}; -void (*const gCameraObjectFuncs[])(struct Sprite *) = { +static void (*const sCameraObjectFuncs[])(struct Sprite *) = { CameraObject_0, CameraObject_1, CameraObject_2, @@ -671,13 +693,13 @@ static const u16 *const sObjectPaletteTagSets[] = { #include "data/object_events/berry_tree_graphics_tables.h" #include "data/field_effects/field_effect_objects.h" -const s16 gMovementDelaysMedium[] = {32, 64, 96, 128}; -const s16 gMovementDelaysLong[] = {32, 64, 128, 192}; -const s16 gMovementDelaysShort[] = {32, 48, 64, 80}; +static const s16 sMovementDelaysMedium[] = {32, 64, 96, 128}; +static const s16 sMovementDelaysLong[] = {32, 64, 128, 192}; // Unused +static const s16 sMovementDelaysShort[] = {32, 48, 64, 80}; #include "data/object_events/movement_type_func_tables.h" -const u8 gFaceDirectionAnimNums[] = { +static const u8 sFaceDirectionAnimNums[] = { [DIR_NONE] = 0, [DIR_SOUTH] = 0, [DIR_NORTH] = 1, @@ -688,7 +710,7 @@ const u8 gFaceDirectionAnimNums[] = { [DIR_NORTHWEST] = 1, [DIR_NORTHEAST] = 1, }; -const u8 gMoveDirectionAnimNums[] = { +static const u8 sMoveDirectionAnimNums[] = { [DIR_NONE] = 4, [DIR_SOUTH] = 4, [DIR_NORTH] = 5, @@ -699,7 +721,7 @@ const u8 gMoveDirectionAnimNums[] = { [DIR_NORTHWEST] = 5, [DIR_NORTHEAST] = 5, }; -const u8 gMoveDirectionFastAnimNums[] = { +static const u8 sMoveDirectionFastAnimNums[] = { [DIR_NONE] = 8, [DIR_SOUTH] = 8, [DIR_NORTH] = 9, @@ -710,7 +732,7 @@ const u8 gMoveDirectionFastAnimNums[] = { [DIR_NORTHWEST] = 9, [DIR_NORTHEAST] = 9, }; -const u8 gMoveDirectionFasterAnimNums[] = { +static const u8 sMoveDirectionFasterAnimNums[] = { [DIR_NONE] = 12, [DIR_SOUTH] = 12, [DIR_NORTH] = 13, @@ -721,7 +743,7 @@ const u8 gMoveDirectionFasterAnimNums[] = { [DIR_NORTHWEST] = 13, [DIR_NORTHEAST] = 13, }; -const u8 gMoveDirectionFastestAnimNums[] = { +static const u8 sMoveDirectionFastestAnimNums[] = { [DIR_NONE] = 16, [DIR_SOUTH] = 16, [DIR_NORTH] = 17, @@ -732,7 +754,7 @@ const u8 gMoveDirectionFastestAnimNums[] = { [DIR_NORTHWEST] = 17, [DIR_NORTHEAST] = 17, }; -const u8 gJumpSpecialDirectionAnimNums[] = { // used for jumping onto surf mon +static const u8 sJumpSpecialDirectionAnimNums[] = { // used for jumping onto surf mon [DIR_NONE] = 20, [DIR_SOUTH] = 20, [DIR_NORTH] = 21, @@ -743,7 +765,7 @@ const u8 gJumpSpecialDirectionAnimNums[] = { // used for jumping onto surf mon [DIR_NORTHWEST] = 21, [DIR_NORTHEAST] = 21, }; -const u8 gAcroWheelieDirectionAnimNums[] = { +static const u8 sAcroWheelieDirectionAnimNums[] = { [DIR_NONE] = 20, [DIR_SOUTH] = 20, [DIR_NORTH] = 21, @@ -754,7 +776,7 @@ const u8 gAcroWheelieDirectionAnimNums[] = { [DIR_NORTHWEST] = 21, [DIR_NORTHEAST] = 21, }; -const u8 gUnrefAnimNums_08375633[] = { +static const u8 sAcroUnusedDirectionAnimNums[] = { [DIR_NONE] = 24, [DIR_SOUTH] = 24, [DIR_NORTH] = 25, @@ -765,7 +787,7 @@ const u8 gUnrefAnimNums_08375633[] = { [DIR_NORTHWEST] = 25, [DIR_NORTHEAST] = 25, }; -const u8 gAcroEndWheelieDirectionAnimNums[] = { +static const u8 sAcroEndWheelieDirectionAnimNums[] = { [DIR_NONE] = 28, [DIR_SOUTH] = 28, [DIR_NORTH] = 29, @@ -776,7 +798,7 @@ const u8 gAcroEndWheelieDirectionAnimNums[] = { [DIR_NORTHWEST] = 29, [DIR_NORTHEAST] = 29, }; -const u8 gAcroUnusedActionDirectionAnimNums[] = { +static const u8 sAcroUnusedActionDirectionAnimNums[] = { [DIR_NONE] = 32, [DIR_SOUTH] = 32, [DIR_NORTH] = 33, @@ -787,7 +809,7 @@ const u8 gAcroUnusedActionDirectionAnimNums[] = { [DIR_NORTHWEST] = 33, [DIR_NORTHEAST] = 33, }; -const u8 gAcroWheeliePedalDirectionAnimNums[] = { +static const u8 sAcroWheeliePedalDirectionAnimNums[] = { [DIR_NONE] = 36, [DIR_SOUTH] = 36, [DIR_NORTH] = 37, @@ -798,7 +820,7 @@ const u8 gAcroWheeliePedalDirectionAnimNums[] = { [DIR_NORTHWEST] = 37, [DIR_NORTHEAST] = 37, }; -const u8 gFishingDirectionAnimNums[] = { +static const u8 sFishingDirectionAnimNums[] = { [DIR_NONE] = 0, [DIR_SOUTH] = 0, [DIR_NORTH] = 1, @@ -809,7 +831,7 @@ const u8 gFishingDirectionAnimNums[] = { [DIR_NORTHWEST] = 1, [DIR_NORTHEAST] = 1, }; -const u8 gFishingNoCatchDirectionAnimNums[] = { +static const u8 sFishingNoCatchDirectionAnimNums[] = { [DIR_NONE] = 4, [DIR_SOUTH] = 4, [DIR_NORTH] = 5, @@ -820,7 +842,7 @@ const u8 gFishingNoCatchDirectionAnimNums[] = { [DIR_NORTHWEST] = 5, [DIR_NORTHEAST] = 5, }; -const u8 gFishingBiteDirectionAnimNums[] = { +static const u8 sFishingBiteDirectionAnimNums[] = { [DIR_NONE] = 8, [DIR_SOUTH] = 8, [DIR_NORTH] = 9, @@ -831,7 +853,7 @@ const u8 gFishingBiteDirectionAnimNums[] = { [DIR_NORTHWEST] = 9, [DIR_NORTHEAST] = 9, }; -const u8 gRunningDirectionAnimNums[] = { +static const u8 sRunningDirectionAnimNums[] = { [DIR_NONE] = 20, [DIR_SOUTH] = 20, [DIR_NORTH] = 21, @@ -1071,7 +1093,7 @@ const u8 gAcroEndWheelieMoveDirectionMovementActions[] = { MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_RIGHT, }; -const u8 gOppositeDirections[] = { +static const u8 sOppositeDirections[] = { DIR_NORTH, DIR_SOUTH, DIR_EAST, @@ -1375,7 +1397,7 @@ static u8 TrySetupObjectEventSprite(struct ObjectEventTemplate *objectEventTempl else if (paletteSlot >= 16) { paletteSlot -= 16; - sub_808EAB0(graphicsInfo->paletteTag, paletteSlot); + _PatchObjectPalette(graphicsInfo->paletteTag, paletteSlot); } if (objectEvent->movementType == MOVEMENT_TYPE_INVISIBLE) @@ -1390,14 +1412,14 @@ static u8 TrySetupObjectEventSprite(struct ObjectEventTemplate *objectEventTempl } sprite = &gSprites[spriteId]; - sub_8092FF0(objectEvent->currentCoords.x + cameraX, objectEvent->currentCoords.y + cameraY, &sprite->pos1.x, &sprite->pos1.y); + GetMapCoordsFromSpritePos(objectEvent->currentCoords.x + cameraX, objectEvent->currentCoords.y + cameraY, &sprite->pos1.x, &sprite->pos1.y); sprite->centerToCornerVecX = -(graphicsInfo->width >> 1); sprite->centerToCornerVecY = -(graphicsInfo->height >> 1); sprite->pos1.x += 8; sprite->pos1.y += 16 + sprite->centerToCornerVecY; sprite->oam.paletteNum = paletteSlot; sprite->coordOffsetEnabled = TRUE; - sprite->data[0] = objectEventId; + sprite->sObjEventId = objectEventId; objectEvent->spriteId = spriteId; objectEvent->inanimate = graphicsInfo->inanimate; if (!objectEvent->inanimate) @@ -1524,7 +1546,7 @@ u8 AddPseudoObjectEvent(u16 graphicsId, void (*callback)(struct Sprite *), s16 x // Used to create sprite object events instead of a full object event // Used when resources are limiting, e.g. for the audience in contests or group members in Union Room -u8 CreateObjectSprite(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction) +u8 CreateObjectSprite(u8 graphicsId, u8 objectEventId, s16 x, s16 y, u8 z, u8 direction) { u8 spriteId; struct Sprite *sprite; @@ -1551,7 +1573,7 @@ u8 CreateObjectSprite(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction) sprite->oam.paletteNum -= 16; } sprite->coordOffsetEnabled = TRUE; - sprite->data[0] = a1; + sprite->sObjEventId = objectEventId; sprite->data[1] = z; if (graphicsInfo->paletteSlot == 10) { @@ -1559,7 +1581,7 @@ u8 CreateObjectSprite(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction) } else if (graphicsInfo->paletteSlot >= 16) { - sub_808EAB0(graphicsInfo->paletteTag, graphicsInfo->paletteSlot | 0xf0); + _PatchObjectPalette(graphicsInfo->paletteTag, graphicsInfo->paletteSlot | 0xf0); } if (subspriteTables != NULL) { @@ -1586,17 +1608,11 @@ void TrySpawnObjectEvents(s16 cameraX, s16 cameraY) s16 bottom = gSaveBlock1Ptr->pos.y + 16; if (InBattlePyramid()) - { objectCount = GetNumBattlePyramidObjectEvents(); - } else if (InTrainerHill()) - { objectCount = 2; - } else - { objectCount = gMapHeader.events->objectEventCount; - } for (i = 0; i < objectCount; i++) { @@ -1649,7 +1665,7 @@ static void RemoveObjectEventIfOutsideView(struct ObjectEvent *objectEvent) RemoveObjectEvent(objectEvent); } -void sub_808E16C(s16 x, s16 y) +void SpawnObjectEventsOnReturnToField(s16 x, s16 y) { u8 i; @@ -1657,16 +1673,14 @@ void sub_808E16C(s16 x, s16 y) for (i = 0; i < OBJECT_EVENTS_COUNT; i++) { if (gObjectEvents[i].active) - { - sub_808E1B8(i, x, y); - } + SpawnObjectEventOnReturnToField(i, x, y); } CreateReflectionEffectSprites(); } -static void sub_808E1B8(u8 objectEventId, s16 x, s16 y) +static void SpawnObjectEventOnReturnToField(u8 objectEventId, s16 x, s16 y) { - u8 spriteId; + u8 i; u8 paletteSlot; struct Sprite *sprite; struct ObjectEvent *objectEvent; @@ -1675,15 +1689,11 @@ static void sub_808E1B8(u8 objectEventId, s16 x, s16 y) const struct SubspriteTable *subspriteTables; const struct ObjectEventGraphicsInfo *graphicsInfo; -#define i spriteId for (i = 0; i < ARRAY_COUNT(gLinkPlayerObjectEvents); i++) { if (gLinkPlayerObjectEvents[i].active && objectEventId == gLinkPlayerObjectEvents[i].objEventId) - { return; - } } -#undef i objectEvent = &gObjectEvents[objectEventId]; subspriteTables = NULL; @@ -1691,6 +1701,7 @@ static void sub_808E1B8(u8 objectEventId, s16 x, s16 y) spriteFrameImage.size = graphicsInfo->size; MakeObjectTemplateFromObjectEventGraphicsInfoWithCallbackIndex(objectEvent->graphicsId, objectEvent->movementType, &spriteTemplate, &subspriteTables); spriteTemplate.images = &spriteFrameImage; + *(u16 *)&spriteTemplate.paletteTag = 0xFFFF; paletteSlot = graphicsInfo->paletteSlot; if (paletteSlot == 0) @@ -1704,14 +1715,15 @@ static void sub_808E1B8(u8 objectEventId, s16 x, s16 y) else if (paletteSlot >= 16) { paletteSlot -= 16; - sub_808EAB0(graphicsInfo->paletteTag, paletteSlot); + _PatchObjectPalette(graphicsInfo->paletteTag, paletteSlot); } *(u16 *)&spriteTemplate.paletteTag = 0xFFFF; - spriteId = CreateSprite(&spriteTemplate, 0, 0, 0); - if (spriteId != MAX_SPRITES) + + i = CreateSprite(&spriteTemplate, 0, 0, 0); + if (i != MAX_SPRITES) { - sprite = &gSprites[spriteId]; - sub_8092FF0(x + objectEvent->currentCoords.x, y + objectEvent->currentCoords.y, &sprite->pos1.x, &sprite->pos1.y); + sprite = &gSprites[i]; + GetMapCoordsFromSpritePos(x + objectEvent->currentCoords.x, y + objectEvent->currentCoords.y, &sprite->pos1.x, &sprite->pos1.y); sprite->centerToCornerVecX = -(graphicsInfo->width >> 1); sprite->centerToCornerVecY = -(graphicsInfo->height >> 1); sprite->pos1.x += 8; @@ -1719,27 +1731,25 @@ static void sub_808E1B8(u8 objectEventId, s16 x, s16 y) sprite->images = graphicsInfo->images; if (objectEvent->movementType == MOVEMENT_TYPE_PLAYER) { - SetPlayerAvatarObjectEventIdAndObjectId(objectEventId, spriteId); + SetPlayerAvatarObjectEventIdAndObjectId(objectEventId, i); objectEvent->warpArrowSpriteId = CreateWarpArrowSprite(); } if (subspriteTables != NULL) - { SetSubspriteTables(sprite, subspriteTables); - } + sprite->oam.paletteNum = paletteSlot; sprite->coordOffsetEnabled = TRUE; - sprite->data[0] = objectEventId; - objectEvent->spriteId = spriteId; + sprite->sObjEventId = objectEventId; + objectEvent->spriteId = i; if (!objectEvent->inanimate && objectEvent->movementType != MOVEMENT_TYPE_PLAYER) - { StartSpriteAnim(sprite, GetFaceDirectionAnimNum(objectEvent->facingDirection)); - } - sub_808E38C(objectEvent); + + ResetObjectEventFldEffData(objectEvent); SetObjectSubpriorityByZCoord(objectEvent->previousElevation, sprite, 1); } } -static void sub_808E38C(struct ObjectEvent *objectEvent) +static void ResetObjectEventFldEffData(struct ObjectEvent *objectEvent) { objectEvent->singleMovementActive = FALSE; objectEvent->triggerGroundEffectsOnMove = TRUE; @@ -1780,7 +1790,7 @@ void ObjectEventSetGraphicsId(struct ObjectEvent *objectEvent, u8 graphicsId) else if (paletteSlot >= 16) { paletteSlot -= 16; - sub_808EAB0(graphicsInfo->paletteTag, paletteSlot); + _PatchObjectPalette(graphicsInfo->paletteTag, paletteSlot); } sprite->oam.shape = graphicsInfo->oam->shape; sprite->oam.size = graphicsInfo->oam->size; @@ -1907,7 +1917,7 @@ void ObjectEventGetLocalIdAndMap(struct ObjectEvent *objectEvent, void *localId, *(u8*)(mapGroup) = objectEvent->mapGroup; } -void sub_808E75C(s16 x, s16 y) +void AllowObjectAtPosTriggerGroundEffects(s16 x, s16 y) { u8 objectEventId; struct ObjectEvent *objectEvent; @@ -1972,27 +1982,23 @@ static void LoadObjectEventPalette(u16 paletteTag) u16 i = FindObjectEventPaletteIndexByTag(paletteTag); if (i != OBJ_EVENT_PAL_TAG_NONE) // always true - { - sub_808E8F4(&sObjectEventSpritePalettes[i]); - } + LoadSpritePaletteIfTagExists(&sObjectEventSpritePalettes[i]); } -void Unused_LoadObjectEventPaletteSet(u16 *paletteTags) +// Unused +static void LoadObjectEventPaletteSet(u16 *paletteTags) { u8 i; for (i = 0; paletteTags[i] != OBJ_EVENT_PAL_TAG_NONE; i++) - { LoadObjectEventPalette(paletteTags[i]); - } } -static u8 sub_808E8F4(const struct SpritePalette *spritePalette) +static u8 LoadSpritePaletteIfTagExists(const struct SpritePalette *spritePalette) { if (IndexOfSpritePaletteTag(spritePalette->tag) != 0xFF) - { return 0xFF; - } + return LoadSpritePalette(spritePalette); } @@ -2058,12 +2064,13 @@ void LoadSpecialObjectReflectionPalette(u16 tag, u8 slot) } } -static void sub_808EAB0(u16 tag, u8 slot) +static void _PatchObjectPalette(u16 tag, u8 slot) { PatchObjectPalette(tag, slot); } -void unref_sub_808EAC4(struct ObjectEvent *objectEvent, s16 x, s16 y) +// Unused +static void IncrementObjectEventCoords(struct ObjectEvent *objectEvent, s16 x, s16 y) { objectEvent->previousCoords.x = objectEvent->currentCoords.x; objectEvent->previousCoords.y = objectEvent->currentCoords.y; @@ -2100,7 +2107,7 @@ void MoveObjectEventToMapCoords(struct ObjectEvent *objectEvent, s16 x, s16 y) sprite->centerToCornerVecY = -(graphicsInfo->height >> 1); sprite->pos1.x += 8; sprite->pos1.y += 16 + sprite->centerToCornerVecY; - sub_808E38C(objectEvent); + ResetObjectEventFldEffData(objectEvent); if (objectEvent->trackedByCamera) CameraObjectReset1(); } @@ -2179,36 +2186,39 @@ void UpdateObjectEventsForCameraUpdate(s16 x, s16 y) RemoveObjectEventsOutsideView(); } +#define sLinkedSpriteId data[0] +#define sState data[1] + u8 AddCameraObject(u8 linkedSpriteId) { - u8 spriteId = CreateSprite(&gCameraSpriteTemplate, 0, 0, 4); + u8 spriteId = CreateSprite(&sCameraSpriteTemplate, 0, 0, 4); gSprites[spriteId].invisible = TRUE; - gSprites[spriteId].data[0] = linkedSpriteId; + gSprites[spriteId].sLinkedSpriteId = linkedSpriteId; return spriteId; } -static void ObjectCB_CameraObject(struct Sprite *sprite) +static void SpriteCB_CameraObject(struct Sprite *sprite) { - void (*callbacks[ARRAY_COUNT(gCameraObjectFuncs)])(struct Sprite *); + void (*callbacks[ARRAY_COUNT(sCameraObjectFuncs)])(struct Sprite *); - memcpy(callbacks, gCameraObjectFuncs, sizeof gCameraObjectFuncs); - callbacks[sprite->data[1]](sprite); + memcpy(callbacks, sCameraObjectFuncs, sizeof sCameraObjectFuncs); + callbacks[sprite->sState](sprite); } static void CameraObject_0(struct Sprite *sprite) { - sprite->pos1.x = gSprites[sprite->data[0]].pos1.x; - sprite->pos1.y = gSprites[sprite->data[0]].pos1.y; + sprite->pos1.x = gSprites[sprite->sLinkedSpriteId].pos1.x; + sprite->pos1.y = gSprites[sprite->sLinkedSpriteId].pos1.y; sprite->invisible = TRUE; - sprite->data[1] = 1; + sprite->sState = 1; CameraObject_1(sprite); } static void CameraObject_1(struct Sprite *sprite) { - s16 x = gSprites[sprite->data[0]].pos1.x; - s16 y = gSprites[sprite->data[0]].pos1.y; + s16 x = gSprites[sprite->sLinkedSpriteId].pos1.x; + s16 y = gSprites[sprite->sLinkedSpriteId].pos1.y; sprite->data[2] = x - sprite->pos1.x; sprite->data[3] = y - sprite->pos1.y; @@ -2218,75 +2228,74 @@ static void CameraObject_1(struct Sprite *sprite) static void CameraObject_2(struct Sprite *sprite) { - sprite->pos1.x = gSprites[sprite->data[0]].pos1.x; - sprite->pos1.y = gSprites[sprite->data[0]].pos1.y; + sprite->pos1.x = gSprites[sprite->sLinkedSpriteId].pos1.x; + sprite->pos1.y = gSprites[sprite->sLinkedSpriteId].pos1.y; sprite->data[2] = 0; sprite->data[3] = 0; } -static struct Sprite *FindCameraObject(void) +static struct Sprite *FindCameraSprite(void) { u8 i; for (i = 0; i < MAX_SPRITES; i++) { - if (gSprites[i].inUse && gSprites[i].callback == ObjectCB_CameraObject) - { + if (gSprites[i].inUse && gSprites[i].callback == SpriteCB_CameraObject) return &gSprites[i]; - } } return NULL; } void CameraObjectReset1(void) { - struct Sprite *cameraObject; + struct Sprite *camera; - cameraObject = FindCameraObject(); - if (cameraObject != NULL) + camera = FindCameraSprite(); + if (camera != NULL) { - cameraObject->data[1] = 0; - cameraObject->callback(cameraObject); + camera->sState = 0; + camera->callback(camera); } } -void CameraObjectSetFollowedObjectId(u8 objectId) +void CameraObjectSetFollowedSpriteId(u8 spriteId) { - struct Sprite *cameraObject; + struct Sprite *camera; - cameraObject = FindCameraObject(); - if (cameraObject != NULL) + camera = FindCameraSprite(); + if (camera != NULL) { - cameraObject->data[0] = objectId; + camera->sLinkedSpriteId = spriteId; CameraObjectReset1(); } } -u8 CameraObjectGetFollowedObjectId(void) +// Unused +static u8 CameraObjectGetFollowedSpriteId(void) { - struct Sprite *cameraObject; + struct Sprite *camera; - cameraObject = FindCameraObject(); - if (cameraObject == NULL) + camera = FindCameraSprite(); + if (camera == NULL) { return MAX_SPRITES; } - return cameraObject->data[0]; + return camera->sLinkedSpriteId; } void CameraObjectReset2(void) { // UB: Possible null dereference #ifdef UBFIX - struct Sprite *cameraObject; + struct Sprite *camera; - cameraObject = FindCameraObject(); - if (cameraObject != NULL) + camera = FindCameraSprite(); + if (camera != NULL) { - cameraObject->data[1] = 2; + camera->sState = 2; } #else - FindCameraObject()->data[1] = 2; + FindCameraSprite()->sState = 2; #endif // UBFIX } @@ -2547,14 +2556,14 @@ movement_type_def(MovementType_WanderAround, gMovementTypeFuncs_WanderAround) bool8 MovementType_WanderAround_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_WanderAround_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -2564,8 +2573,8 @@ bool8 MovementType_WanderAround_Step2(struct ObjectEvent *objectEvent, struct Sp { return FALSE; } - SetMovementDelay(sprite, gMovementDelaysMedium[Random() & 3]); - sprite->data[1] = 3; + SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]); + sprite->sTypeFuncId = 3; return TRUE; } @@ -2573,7 +2582,7 @@ bool8 MovementType_WanderAround_Step3(struct ObjectEvent *objectEvent, struct Sp { if (WaitForMovementDelay(sprite)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -2587,9 +2596,9 @@ bool8 MovementType_WanderAround_Step4(struct ObjectEvent *objectEvent, struct Sp memcpy(directions, gStandardDirections, sizeof directions); chosenDirection = directions[Random() & 3]; SetObjectEventDirection(objectEvent, chosenDirection); - sprite->data[1] = 5; + sprite->sTypeFuncId = 5; if (GetCollisionInDirection(objectEvent, chosenDirection)) - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -2598,7 +2607,7 @@ bool8 MovementType_WanderAround_Step5(struct ObjectEvent *objectEvent, struct Sp { ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(objectEvent->movementDirection)); objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 6; + sprite->sTypeFuncId = 6; return TRUE; } @@ -2607,7 +2616,7 @@ bool8 MovementType_WanderAround_Step6(struct ObjectEvent *objectEvent, struct Sp if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; } return FALSE; } @@ -2653,17 +2662,13 @@ u8 GetVectorDirection(s16 dx, s16 dy, s16 absdx, s16 absdy) { direction = DIR_EAST; if (dx < 0) - { direction = DIR_WEST; - } } else { direction = DIR_SOUTH; if (dy < 0) - { direction = DIR_NORTH; - } } return direction; } @@ -2674,9 +2679,7 @@ u8 GetLimitedVectorDirection_SouthNorth(s16 dx, s16 dy, s16 absdx, s16 absdy) direction = DIR_SOUTH; if (dy < 0) - { direction = DIR_NORTH; - } return direction; } @@ -2686,9 +2689,7 @@ u8 GetLimitedVectorDirection_WestEast(s16 dx, s16 dy, s16 absdx, s16 absdy) direction = DIR_EAST; if (dx < 0) - { direction = DIR_WEST; - } return direction; } @@ -2701,17 +2702,13 @@ u8 GetLimitedVectorDirection_WestNorth(s16 dx, s16 dy, s16 absdx, s16 absdy) { direction = GetLimitedVectorDirection_WestEast(dx, dy, absdx, absdy); if (direction == DIR_EAST) - { direction = DIR_NORTH; - } } else if (direction == DIR_EAST) { direction = GetLimitedVectorDirection_SouthNorth(dx, dy, absdx, absdy); if (direction == DIR_SOUTH) - { direction = DIR_NORTH; - } } return direction; } @@ -2725,17 +2722,13 @@ u8 GetLimitedVectorDirection_EastNorth(s16 dx, s16 dy, s16 absdx, s16 absdy) { direction = GetLimitedVectorDirection_WestEast(dx, dy, absdx, absdy); if (direction == DIR_WEST) - { direction = DIR_NORTH; - } } else if (direction == DIR_WEST) { direction = GetLimitedVectorDirection_SouthNorth(dx, dy, absdx, absdy); if (direction == DIR_SOUTH) - { direction = DIR_NORTH; - } } return direction; } @@ -2749,17 +2742,13 @@ u8 GetLimitedVectorDirection_WestSouth(s16 dx, s16 dy, s16 absdx, s16 absdy) { direction = GetLimitedVectorDirection_WestEast(dx, dy, absdx, absdy); if (direction == DIR_EAST) - { direction = DIR_SOUTH; - } } else if (direction == DIR_EAST) { direction = GetLimitedVectorDirection_SouthNorth(dx, dy, absdx, absdy); if (direction == DIR_NORTH) - { direction = DIR_SOUTH; - } } return direction; } @@ -2773,17 +2762,13 @@ u8 GetLimitedVectorDirection_EastSouth(s16 dx, s16 dy, s16 absdx, s16 absdy) { direction = GetLimitedVectorDirection_WestEast(dx, dy, absdx, absdy); if (direction == DIR_WEST) - { direction = DIR_SOUTH; - } } else if (direction == DIR_WEST) { direction = GetLimitedVectorDirection_SouthNorth(dx, dy, absdx, absdy); if (direction == DIR_NORTH) - { direction = DIR_SOUTH; - } } return direction; } @@ -2794,9 +2779,7 @@ u8 GetLimitedVectorDirection_SouthNorthWest(s16 dx, s16 dy, s16 absdx, s16 absdy direction = GetVectorDirection(dx, dy, absdx, absdy); if (direction == DIR_EAST) - { direction = GetLimitedVectorDirection_SouthNorth(dx, dy, absdx, absdy); - } return direction; } @@ -2806,9 +2789,7 @@ u8 GetLimitedVectorDirection_SouthNorthEast(s16 dx, s16 dy, s16 absdx, s16 absdy direction = GetVectorDirection(dx, dy, absdx, absdy); if (direction == DIR_WEST) - { direction = GetLimitedVectorDirection_SouthNorth(dx, dy, absdx, absdy); - } return direction; } @@ -2818,9 +2799,7 @@ u8 GetLimitedVectorDirection_NorthWestEast(s16 dx, s16 dy, s16 absdx, s16 absdy) direction = GetVectorDirection(dx, dy, absdx, absdy); if (direction == DIR_SOUTH) - { direction = GetLimitedVectorDirection_WestEast(dx, dy, absdx, absdy); - } return direction; } @@ -2830,9 +2809,7 @@ u8 GetLimitedVectorDirection_SouthWestEast(s16 dx, s16 dy, s16 absdx, s16 absdy) direction = GetVectorDirection(dx, dy, absdx, absdy); if (direction == DIR_NORTH) - { direction = GetLimitedVectorDirection_WestEast(dx, dy, absdx, absdy); - } return direction; } @@ -2842,22 +2819,19 @@ u8 TryGetTrainerEncounterDirection(struct ObjectEvent *objectEvent, u8 movementT s16 absdx, absdy; if (!ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) - { - return 0; - } + return DIR_NONE; + PlayerGetDestCoords(&dx, &dy); dx -= objectEvent->currentCoords.x; dy -= objectEvent->currentCoords.y; absdx = dx; absdy = dy; + if (absdx < 0) - { absdx = -absdx; - } if (absdy < 0) - { absdy = -absdy; - } + return gGetVectorDirectionFuncs[movementType](dx, dy, absdx, absdy); } @@ -2866,14 +2840,14 @@ movement_type_def(MovementType_LookAround, gMovementTypeFuncs_LookAround) bool8 MovementType_LookAround_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_LookAround_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -2881,9 +2855,9 @@ bool8 MovementType_LookAround_Step2(struct ObjectEvent *objectEvent, struct Spri { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, gMovementDelaysMedium[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]); objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; } return FALSE; } @@ -2892,7 +2866,7 @@ bool8 MovementType_LookAround_Step3(struct ObjectEvent *objectEvent, struct Spri { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -2908,7 +2882,7 @@ bool8 MovementType_LookAround_Step4(struct ObjectEvent *objectEvent, struct Spri direction = directions[Random() & 3]; SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -2917,25 +2891,24 @@ movement_type_def(MovementType_WanderUpAndDown, gMovementTypeFuncs_WanderUpAndDo bool8 MovementType_WanderUpAndDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_WanderUpAndDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } bool8 MovementType_WanderUpAndDown_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (!ObjectEventExecSingleMovementAction(objectEvent, sprite)) - { return FALSE; - } - SetMovementDelay(sprite, gMovementDelaysMedium[Random() & 3]); - sprite->data[1] = 3; + + SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]); + sprite->sTypeFuncId = 3; return TRUE; } @@ -2943,7 +2916,7 @@ bool8 MovementType_WanderUpAndDown_Step3(struct ObjectEvent *objectEvent, struct { if (WaitForMovementDelay(sprite)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -2956,9 +2929,9 @@ bool8 MovementType_WanderUpAndDown_Step4(struct ObjectEvent *objectEvent, struct memcpy(directions, gUpAndDownDirections, sizeof directions); direction = directions[Random() & 1]; SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 5; + sprite->sTypeFuncId = 5; if (GetCollisionInDirection(objectEvent, direction)) - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -2967,7 +2940,7 @@ bool8 MovementType_WanderUpAndDown_Step5(struct ObjectEvent *objectEvent, struct { ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(objectEvent->movementDirection)); objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 6; + sprite->sTypeFuncId = 6; return TRUE; } @@ -2976,7 +2949,7 @@ bool8 MovementType_WanderUpAndDown_Step6(struct ObjectEvent *objectEvent, struct if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; } return FALSE; } @@ -2986,25 +2959,24 @@ movement_type_def(MovementType_WanderLeftAndRight, gMovementTypeFuncs_WanderLeft bool8 MovementType_WanderLeftAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_WanderLeftAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } bool8 MovementType_WanderLeftAndRight_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (!ObjectEventExecSingleMovementAction(objectEvent, sprite)) - { return FALSE; - } - SetMovementDelay(sprite, gMovementDelaysMedium[Random() & 3]); - sprite->data[1] = 3; + + SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]); + sprite->sTypeFuncId = 3; return TRUE; } @@ -3012,7 +2984,7 @@ bool8 MovementType_WanderLeftAndRight_Step3(struct ObjectEvent *objectEvent, str { if (WaitForMovementDelay(sprite)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -3025,9 +2997,9 @@ bool8 MovementType_WanderLeftAndRight_Step4(struct ObjectEvent *objectEvent, str memcpy(directions, gLeftAndRightDirections, sizeof directions); direction = directions[Random() & 1]; SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 5; + sprite->sTypeFuncId = 5; if (GetCollisionInDirection(objectEvent, direction)) - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3036,7 +3008,7 @@ bool8 MovementType_WanderLeftAndRight_Step5(struct ObjectEvent *objectEvent, str { ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(objectEvent->movementDirection)); objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 6; + sprite->sTypeFuncId = 6; return TRUE; } @@ -3045,7 +3017,7 @@ bool8 MovementType_WanderLeftAndRight_Step6(struct ObjectEvent *objectEvent, str if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; } return FALSE; } @@ -3056,7 +3028,7 @@ bool8 MovementType_FaceDirection_Step0(struct ObjectEvent *objectEvent, struct S { ClearObjectEventMovement(objectEvent, sprite); ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3064,7 +3036,7 @@ bool8 MovementType_FaceDirection_Step1(struct ObjectEvent *objectEvent, struct S { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } return FALSE; @@ -3087,8 +3059,6 @@ enum { BERRYTREEFUNC_SPARKLE_END, }; -#define sObjEventId data[0] -#define sFuncId data[1] #define sTimer data[2] #define sBerryTreeFlags data[7] @@ -3110,7 +3080,7 @@ void MovementType_BerryTreeGrowth(struct Sprite *sprite) } static bool8 ObjectEventCB2_BerryTree(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - return gMovementTypeFuncs_BerryTreeGrowth[sprite->sFuncId](objectEvent, sprite); + return gMovementTypeFuncs_BerryTreeGrowth[sprite->sTypeFuncId](objectEvent, sprite); } // BERRYTREEFUNC_NORMAL @@ -3139,12 +3109,12 @@ bool8 MovementType_BerryTreeGrowth_Normal(struct ObjectEvent *objectEvent, struc berryStage--; if (sprite->animNum != berryStage) { - sprite->sFuncId = BERRYTREEFUNC_SPARKLE_START; + sprite->sTypeFuncId = BERRYTREEFUNC_SPARKLE_START; return TRUE; } SetBerryTreeGraphics(objectEvent, sprite); ObjectEventSetSingleMovement(objectEvent, sprite, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION); - sprite->sFuncId = BERRYTREEFUNC_MOVE; + sprite->sTypeFuncId = BERRYTREEFUNC_MOVE; return TRUE; } @@ -3153,7 +3123,7 @@ bool8 MovementType_BerryTreeGrowth_Move(struct ObjectEvent *objectEvent, struct { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - sprite->sFuncId = BERRYTREEFUNC_NORMAL; + sprite->sTypeFuncId = BERRYTREEFUNC_NORMAL; return TRUE; } return FALSE; @@ -3163,7 +3133,7 @@ bool8 MovementType_BerryTreeGrowth_Move(struct ObjectEvent *objectEvent, struct bool8 MovementType_BerryTreeGrowth_SparkleStart(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->singleMovementActive = TRUE; - sprite->sFuncId = BERRYTREEFUNC_SPARKLE; + sprite->sTypeFuncId = BERRYTREEFUNC_SPARKLE; sprite->sTimer = 0; sprite->sBerryTreeFlags |= BERRY_FLAG_SPARKLING; gFieldEffectArguments[0] = objectEvent->currentCoords.x; @@ -3183,7 +3153,7 @@ bool8 MovementType_BerryTreeGrowth_Sparkle(struct ObjectEvent *objectEvent, stru if (sprite->sTimer > 64) { SetBerryTreeGraphics(objectEvent, sprite); - sprite->sFuncId = BERRYTREEFUNC_SPARKLE_END; + sprite->sTypeFuncId = BERRYTREEFUNC_SPARKLE_END; sprite->sTimer = 0; return TRUE; } @@ -3198,7 +3168,7 @@ bool8 MovementType_BerryTreeGrowth_SparkleEnd(struct ObjectEvent *objectEvent, s sprite->animPaused = TRUE; if (sprite->sTimer > 64) { - sprite->sFuncId = BERRYTREEFUNC_NORMAL; + sprite->sTypeFuncId = BERRYTREEFUNC_NORMAL; sprite->sBerryTreeFlags &= ~BERRY_FLAG_SPARKLING; return TRUE; } @@ -3210,14 +3180,14 @@ movement_type_def(MovementType_FaceDownAndUp, gMovementTypeFuncs_FaceDownAndUp) bool8 MovementType_FaceDownAndUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_FaceDownAndUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -3225,9 +3195,9 @@ bool8 MovementType_FaceDownAndUp_Step2(struct ObjectEvent *objectEvent, struct S { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, gMovementDelaysMedium[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]); objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; } return FALSE; } @@ -3236,7 +3206,7 @@ bool8 MovementType_FaceDownAndUp_Step3(struct ObjectEvent *objectEvent, struct S { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -3253,7 +3223,7 @@ bool8 MovementType_FaceDownAndUp_Step4(struct ObjectEvent *objectEvent, struct S direction = directions[Random() & 1]; } SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3262,14 +3232,14 @@ movement_type_def(MovementType_FaceLeftAndRight, gMovementTypeFuncs_FaceLeftAndR bool8 MovementType_FaceLeftAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_FaceLeftAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -3277,9 +3247,9 @@ bool8 MovementType_FaceLeftAndRight_Step2(struct ObjectEvent *objectEvent, struc { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, gMovementDelaysMedium[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]); objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; } return FALSE; } @@ -3288,7 +3258,7 @@ bool8 MovementType_FaceLeftAndRight_Step3(struct ObjectEvent *objectEvent, struc { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -3305,7 +3275,7 @@ bool8 MovementType_FaceLeftAndRight_Step4(struct ObjectEvent *objectEvent, struc direction = directions[Random() & 1]; } SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3314,14 +3284,14 @@ movement_type_def(MovementType_FaceUpAndLeft, gMovementTypeFuncs_FaceUpAndLeft) bool8 MovementType_FaceUpAndLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_FaceUpAndLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -3329,9 +3299,9 @@ bool8 MovementType_FaceUpAndLeft_Step2(struct ObjectEvent *objectEvent, struct S { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; } return FALSE; } @@ -3340,7 +3310,7 @@ bool8 MovementType_FaceUpAndLeft_Step3(struct ObjectEvent *objectEvent, struct S { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -3357,7 +3327,7 @@ bool8 MovementType_FaceUpAndLeft_Step4(struct ObjectEvent *objectEvent, struct S direction = directions[Random() & 1]; } SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3366,14 +3336,14 @@ movement_type_def(MovementType_FaceUpAndRight, gMovementTypeFuncs_FaceUpAndRight bool8 MovementType_FaceUpAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_FaceUpAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -3381,9 +3351,9 @@ bool8 MovementType_FaceUpAndRight_Step2(struct ObjectEvent *objectEvent, struct { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; } return FALSE; } @@ -3392,7 +3362,7 @@ bool8 MovementType_FaceUpAndRight_Step3(struct ObjectEvent *objectEvent, struct { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -3409,7 +3379,7 @@ bool8 MovementType_FaceUpAndRight_Step4(struct ObjectEvent *objectEvent, struct direction = directions[Random() & 1]; } SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3418,14 +3388,14 @@ movement_type_def(MovementType_FaceDownAndLeft, gMovementTypeFuncs_FaceDownAndLe bool8 MovementType_FaceDownAndLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_FaceDownAndLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -3433,9 +3403,9 @@ bool8 MovementType_FaceDownAndLeft_Step2(struct ObjectEvent *objectEvent, struct { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; } return FALSE; } @@ -3444,7 +3414,7 @@ bool8 MovementType_FaceDownAndLeft_Step3(struct ObjectEvent *objectEvent, struct { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -3461,7 +3431,7 @@ bool8 MovementType_FaceDownAndLeft_Step4(struct ObjectEvent *objectEvent, struct direction = directions[Random() & 1]; } SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3470,14 +3440,14 @@ movement_type_def(MovementType_FaceDownAndRight, gMovementTypeFuncs_FaceDownAndR bool8 MovementType_FaceDownAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_FaceDownAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -3485,9 +3455,9 @@ bool8 MovementType_FaceDownAndRight_Step2(struct ObjectEvent *objectEvent, struc { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; } return FALSE; } @@ -3496,7 +3466,7 @@ bool8 MovementType_FaceDownAndRight_Step3(struct ObjectEvent *objectEvent, struc { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -3513,7 +3483,7 @@ bool8 MovementType_FaceDownAndRight_Step4(struct ObjectEvent *objectEvent, struc direction = directions[Random() & 1]; } SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3522,14 +3492,14 @@ movement_type_def(MovementType_FaceDownUpAndLeft, gMovementTypeFuncs_FaceDownUpA bool8 MovementType_FaceDownUpAndLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_FaceDownUpAndLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -3537,9 +3507,9 @@ bool8 MovementType_FaceDownUpAndLeft_Step2(struct ObjectEvent *objectEvent, stru { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; } return FALSE; } @@ -3548,7 +3518,7 @@ bool8 MovementType_FaceDownUpAndLeft_Step3(struct ObjectEvent *objectEvent, stru { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -3565,7 +3535,7 @@ bool8 MovementType_FaceDownUpAndLeft_Step4(struct ObjectEvent *objectEvent, stru direction = directions[Random() & 3]; } SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3574,14 +3544,14 @@ movement_type_def(MovementType_FaceDownUpAndRight, gMovementTypeFuncs_FaceDownUp bool8 MovementType_FaceDownUpAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_FaceDownUpAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -3589,9 +3559,9 @@ bool8 MovementType_FaceDownUpAndRight_Step2(struct ObjectEvent *objectEvent, str { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; } return FALSE; } @@ -3600,7 +3570,7 @@ bool8 MovementType_FaceDownUpAndRight_Step3(struct ObjectEvent *objectEvent, str { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -3617,7 +3587,7 @@ bool8 MovementType_FaceDownUpAndRight_Step4(struct ObjectEvent *objectEvent, str direction = directions[Random() & 3]; } SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3626,14 +3596,14 @@ movement_type_def(MovementType_FaceUpRightAndLeft, gMovementTypeFuncs_FaceUpLeft bool8 MovementType_FaceUpLeftAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_FaceUpLeftAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -3641,9 +3611,9 @@ bool8 MovementType_FaceUpLeftAndRight_Step2(struct ObjectEvent *objectEvent, str { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; } return FALSE; } @@ -3652,7 +3622,7 @@ bool8 MovementType_FaceUpLeftAndRight_Step3(struct ObjectEvent *objectEvent, str { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -3669,7 +3639,7 @@ bool8 MovementType_FaceUpLeftAndRight_Step4(struct ObjectEvent *objectEvent, str direction = directions[Random() & 3]; } SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3678,14 +3648,14 @@ movement_type_def(MovementType_FaceDownRightAndLeft, gMovementTypeFuncs_FaceDown bool8 MovementType_FaceDownLeftAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_FaceDownLeftAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -3693,9 +3663,9 @@ bool8 MovementType_FaceDownLeftAndRight_Step2(struct ObjectEvent *objectEvent, s { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - SetMovementDelay(sprite, gMovementDelaysShort[Random() & 3]); + SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]); objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; } return FALSE; } @@ -3704,7 +3674,7 @@ bool8 MovementType_FaceDownLeftAndRight_Step3(struct ObjectEvent *objectEvent, s { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) { - sprite->data[1] = 4; + sprite->sTypeFuncId = 4; return TRUE; } return FALSE; @@ -3721,7 +3691,7 @@ bool8 MovementType_FaceDownLeftAndRight_Step4(struct ObjectEvent *objectEvent, s direction = directions[Random() & 3]; } SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3731,7 +3701,7 @@ bool8 MovementType_RotateCounterclockwise_Step0(struct ObjectEvent *objectEvent, { ClearObjectEventMovement(objectEvent, sprite); ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3740,7 +3710,7 @@ bool8 MovementType_RotateCounterclockwise_Step1(struct ObjectEvent *objectEvent, if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { SetMovementDelay(sprite, 48); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; } return FALSE; } @@ -3749,7 +3719,7 @@ bool8 MovementType_RotateCounterclockwise_Step2(struct ObjectEvent *objectEvent, { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) { - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; } return FALSE; } @@ -3765,7 +3735,7 @@ bool8 MovementType_RotateCounterclockwise_Step3(struct ObjectEvent *objectEvent, direction = directions[objectEvent->facingDirection]; } SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 0; + sprite->sTypeFuncId = 0; return TRUE; } @@ -3775,7 +3745,7 @@ bool8 MovementType_RotateClockwise_Step0(struct ObjectEvent *objectEvent, struct { ClearObjectEventMovement(objectEvent, sprite); ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3784,7 +3754,7 @@ bool8 MovementType_RotateClockwise_Step1(struct ObjectEvent *objectEvent, struct if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { SetMovementDelay(sprite, 48); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; } return FALSE; } @@ -3793,7 +3763,7 @@ bool8 MovementType_RotateClockwise_Step2(struct ObjectEvent *objectEvent, struct { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) { - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; } return FALSE; } @@ -3809,7 +3779,7 @@ bool8 MovementType_RotateClockwise_Step3(struct ObjectEvent *objectEvent, struct direction = directions[objectEvent->facingDirection]; } SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 0; + sprite->sTypeFuncId = 0; return TRUE; } @@ -3818,7 +3788,7 @@ movement_type_def(MovementType_WalkBackAndForth, gMovementTypeFuncs_WalkBackAndF bool8 MovementType_WalkBackAndForth_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3832,7 +3802,7 @@ bool8 MovementType_WalkBackAndForth_Step1(struct ObjectEvent *objectEvent, struc direction = GetOppositeDirection(direction); } SetObjectEventDirection(objectEvent, direction); - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -3861,7 +3831,7 @@ bool8 MovementType_WalkBackAndForth_Step2(struct ObjectEvent *objectEvent, struc ObjectEventSetSingleMovement(objectEvent, sprite, movementActionId); objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 3; + sprite->sTypeFuncId = 3; return TRUE; } @@ -3870,7 +3840,7 @@ bool8 MovementType_WalkBackAndForth_Step3(struct ObjectEvent *objectEvent, struc if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; } return FALSE; } @@ -3878,7 +3848,7 @@ bool8 MovementType_WalkBackAndForth_Step3(struct ObjectEvent *objectEvent, struc bool8 MovementType_WalkSequence_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -3906,7 +3876,7 @@ bool8 MoveNextDirectionInSequence(struct ObjectEvent *objectEvent, struct Sprite ObjectEventSetSingleMovement(objectEvent, sprite, movementActionId); objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -3915,7 +3885,7 @@ bool8 MovementType_WalkSequence_Step2(struct ObjectEvent *objectEvent, struct Sp if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; } return FALSE; } @@ -4241,7 +4211,7 @@ bool8 MovementType_CopyPlayer_Step0(struct ObjectEvent *objectEvent, struct Spri { objectEvent->directionSequenceIndex = GetPlayerFacingDirection(); } - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -4259,7 +4229,7 @@ bool8 MovementType_CopyPlayer_Step2(struct ObjectEvent *objectEvent, struct Spri if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { objectEvent->singleMovementActive = FALSE; - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; } return FALSE; } @@ -4273,7 +4243,7 @@ bool8 CopyablePlayerMovement_FaceDirection(struct ObjectEvent *objectEvent, stru { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection))); objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -4294,7 +4264,7 @@ bool8 CopyablePlayerMovement_GoSpeed0(struct ObjectEvent *objectEvent, struct Sp ObjectEventMoveDestCoords(objectEvent, direction, &x, &y); ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } } @@ -4309,7 +4279,7 @@ bool8 CopyablePlayerMovement_GoSpeed0(struct ObjectEvent *objectEvent, struct Sp ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); } objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -4328,7 +4298,7 @@ bool8 CopyablePlayerMovement_GoSpeed1(struct ObjectEvent *objectEvent, struct Sp ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); } objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -4347,7 +4317,7 @@ bool8 CopyablePlayerMovement_GoSpeed2(struct ObjectEvent *objectEvent, struct Sp ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); } objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -4366,7 +4336,7 @@ bool8 CopyablePlayerMovement_Slide(struct ObjectEvent *objectEvent, struct Sprit ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); } objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -4378,7 +4348,7 @@ bool8 cph_IM_DIFFERENT(struct ObjectEvent *objectEvent, struct Sprite *sprite, u direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); ObjectEventSetSingleMovement(objectEvent, sprite, GetJumpInPlaceMovementAction(direction)); objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -4397,7 +4367,7 @@ bool8 CopyablePlayerMovement_GoSpeed4(struct ObjectEvent *objectEvent, struct Sp ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); } objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -4418,7 +4388,7 @@ bool8 CopyablePlayerMovement_Jump(struct ObjectEvent *objectEvent, struct Sprite ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); } objectEvent->singleMovementActive = TRUE; - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } @@ -4437,7 +4407,7 @@ void MovementType_TreeDisguise(struct Sprite *sprite) { struct ObjectEvent *objectEvent; - objectEvent = &gObjectEvents[sprite->data[0]]; + objectEvent = &gObjectEvents[sprite->sObjEventId]; if (objectEvent->directionSequenceIndex == 0 || (objectEvent->directionSequenceIndex == 1 && !sprite->data[7])) { ObjectEventGetLocalIdAndMap(objectEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]); @@ -4445,7 +4415,7 @@ void MovementType_TreeDisguise(struct Sprite *sprite) objectEvent->directionSequenceIndex = 1; sprite->data[7]++; } - UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->data[0]], sprite, MovementType_Disguise_Callback); + UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->sObjEventId], sprite, MovementType_Disguise_Callback); } static bool8 MovementType_Disguise_Callback(struct ObjectEvent *objectEvent, struct Sprite *sprite) @@ -4458,7 +4428,7 @@ void MovementType_MountainDisguise(struct Sprite *sprite) { struct ObjectEvent *objectEvent; - objectEvent = &gObjectEvents[sprite->data[0]]; + objectEvent = &gObjectEvents[sprite->sObjEventId]; if (objectEvent->directionSequenceIndex == 0 || (objectEvent->directionSequenceIndex == 1 && !sprite->data[7])) { ObjectEventGetLocalIdAndMap(objectEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]); @@ -4466,24 +4436,24 @@ void MovementType_MountainDisguise(struct Sprite *sprite) objectEvent->directionSequenceIndex = 1; sprite->data[7]++; } - UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->data[0]], sprite, MovementType_Disguise_Callback); + UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->sObjEventId], sprite, MovementType_Disguise_Callback); } void MovementType_Buried(struct Sprite *sprite) { if (!sprite->data[7]) { - gObjectEvents[sprite->data[0]].fixedPriority = TRUE; + gObjectEvents[sprite->sObjEventId].fixedPriority = TRUE; sprite->subspriteMode = SUBSPRITES_IGNORE_PRIORITY; sprite->oam.priority = 3; sprite->data[7]++; } - UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->data[0]], sprite, MovementType_Buried_Callback); + UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->sObjEventId], sprite, MovementType_Buried_Callback); } static bool8 MovementType_Buried_Callback(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - return gMovementTypeFuncs_Buried[sprite->data[1]](objectEvent, sprite); + return gMovementTypeFuncs_Buried[sprite->sTypeFuncId](objectEvent, sprite); } bool8 MovementType_Buried_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) @@ -4496,7 +4466,7 @@ bool8 MovementType_MoveInPlace_Step1(struct ObjectEvent *objectEvent, struct Spr { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - sprite->data[1] = 0; + sprite->sTypeFuncId = 0; } return FALSE; } @@ -4507,7 +4477,7 @@ bool8 MovementType_WalkInPlace_Step0(struct ObjectEvent *objectEvent, struct Spr { ClearObjectEventMovement(objectEvent, sprite); ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceNormalMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -4517,7 +4487,7 @@ bool8 MovementType_WalkSlowlyInPlace_Step0(struct ObjectEvent *objectEvent, stru { ClearObjectEventMovement(objectEvent, sprite); ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceSlowMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -4527,7 +4497,7 @@ bool8 MovementType_JogInPlace_Step0(struct ObjectEvent *objectEvent, struct Spri { ClearObjectEventMovement(objectEvent, sprite); ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceFastMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -4537,7 +4507,7 @@ bool8 MovementType_RunInPlace_Step0(struct ObjectEvent *objectEvent, struct Spri { ClearObjectEventMovement(objectEvent, sprite); ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceFastestMovementAction(objectEvent->facingDirection)); - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } @@ -4548,14 +4518,14 @@ bool8 MovementType_Invisible_Step0(struct ObjectEvent *objectEvent, struct Sprit ClearObjectEventMovement(objectEvent, sprite); ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection)); objectEvent->invisible = TRUE; - sprite->data[1] = 1; + sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_Invisible_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { - sprite->data[1] = 2; + sprite->sTypeFuncId = 2; return TRUE; } return FALSE; @@ -4573,82 +4543,82 @@ static void ClearObjectEventMovement(struct ObjectEvent *objectEvent, struct Spr objectEvent->heldMovementActive = FALSE; objectEvent->heldMovementFinished = FALSE; objectEvent->movementActionId = 0xFF; - sprite->data[1] = 0; + sprite->sTypeFuncId = 0; } u8 GetFaceDirectionAnimNum(u8 direction) { - return gFaceDirectionAnimNums[direction]; + return sFaceDirectionAnimNums[direction]; } u8 GetMoveDirectionAnimNum(u8 direction) { - return gMoveDirectionAnimNums[direction]; + return sMoveDirectionAnimNums[direction]; } u8 GetMoveDirectionFastAnimNum(u8 direction) { - return gMoveDirectionFastAnimNums[direction]; + return sMoveDirectionFastAnimNums[direction]; } u8 GetMoveDirectionFasterAnimNum(u8 direction) { - return gMoveDirectionFasterAnimNums[direction]; + return sMoveDirectionFasterAnimNums[direction]; } u8 GetMoveDirectionFastestAnimNum(u8 direction) { - return gMoveDirectionFastestAnimNums[direction]; + return sMoveDirectionFastestAnimNums[direction]; } u8 GetJumpSpecialDirectionAnimNum(u8 direction) { - return gJumpSpecialDirectionAnimNums[direction]; + return sJumpSpecialDirectionAnimNums[direction]; } u8 GetAcroWheelieDirectionAnimNum(u8 direction) { - return gAcroWheelieDirectionAnimNums[direction]; + return sAcroWheelieDirectionAnimNums[direction]; } -u8 Unref_GetAnimNums_08375633(u8 direction) +u8 GetAcroUnusedDirectionAnimNum(u8 direction) { - return gUnrefAnimNums_08375633[direction]; + return sAcroUnusedDirectionAnimNums[direction]; } u8 GetAcroEndWheelieDirectionAnimNum(u8 direction) { - return gAcroEndWheelieDirectionAnimNums[direction]; + return sAcroEndWheelieDirectionAnimNums[direction]; } u8 GetAcroUnusedActionDirectionAnimNum(u8 direction) { - return gAcroUnusedActionDirectionAnimNums[direction]; + return sAcroUnusedActionDirectionAnimNums[direction]; } u8 GetAcroWheeliePedalDirectionAnimNum(u8 direction) { - return gAcroWheeliePedalDirectionAnimNums[direction]; + return sAcroWheeliePedalDirectionAnimNums[direction]; } u8 GetFishingDirectionAnimNum(u8 direction) { - return gFishingDirectionAnimNums[direction]; + return sFishingDirectionAnimNums[direction]; } u8 GetFishingNoCatchDirectionAnimNum(u8 direction) { - return gFishingNoCatchDirectionAnimNums[direction]; + return sFishingNoCatchDirectionAnimNums[direction]; } u8 GetFishingBiteDirectionAnimNum(u8 direction) { - return gFishingBiteDirectionAnimNums[direction]; + return sFishingBiteDirectionAnimNums[direction]; } u8 GetRunningDirectionAnimNum(u8 direction) { - return gRunningDirectionAnimNums[direction]; + return sRunningDirectionAnimNums[direction]; } static const struct UnkStruct_085094AC *sub_8092A4C(const union AnimCmd *const *anims) @@ -4658,9 +4628,7 @@ static const struct UnkStruct_085094AC *sub_8092A4C(const union AnimCmd *const * for (retval = gUnknown_085094AC; retval->anims != NULL; retval++) { if (retval->anims == anims) - { return retval; - } } return NULL; } @@ -4710,22 +4678,17 @@ void obj_npc_animation_step(struct ObjectEvent *objectEvent, struct Sprite *spri } } -// file boundary? - -u8 GetDirectionToFace(s16 x1, s16 y1, s16 x2, s16 y2) +u8 GetDirectionToFace(s16 x, s16 y, s16 targetX, s16 targetY) { - if (x1 > x2) - { + if (x > targetX) return DIR_WEST; - } - if (x1 < x2) - { + + if (x < targetX) return DIR_EAST; - } - if (y1 > y2) - { + + if (y > targetY) return DIR_NORTH; - } + return DIR_SOUTH; } @@ -4735,7 +4698,7 @@ void SetTrainerMovementType(struct ObjectEvent *objectEvent, u8 movementType) objectEvent->directionSequenceIndex = 0; objectEvent->playerCopyableMovement = 0; gSprites[objectEvent->spriteId].callback = sMovementTypeCallbacks[movementType]; - gSprites[objectEvent->spriteId].data[1] = 0; + gSprites[objectEvent->spriteId].sTypeFuncId = 0; } u8 GetTrainerFacingDirectionMovementType(u8 direction) @@ -4745,10 +4708,8 @@ u8 GetTrainerFacingDirectionMovementType(u8 direction) static u8 GetCollisionInDirection(struct ObjectEvent *objectEvent, u8 direction) { - s16 x; - s16 y; - x = objectEvent->currentCoords.x; - y = objectEvent->currentCoords.y; + s16 x = objectEvent->currentCoords.x; + s16 y = objectEvent->currentCoords.y; MoveCoords(direction, &x, &y); return GetCollisionAtCoords(objectEvent, x, y, direction); } @@ -4795,19 +4756,17 @@ static bool8 IsCoordOutsideObjectEventMovementRange(struct ObjectEvent *objectEv { left = objectEvent->initialCoords.x - objectEvent->rangeX; right = objectEvent->initialCoords.x + objectEvent->rangeX; + if (left > x || right < x) - { return TRUE; - } } if (objectEvent->rangeY != 0) { top = objectEvent->initialCoords.y - objectEvent->rangeY; bottom = objectEvent->initialCoords.y + objectEvent->rangeY; + if (top > y || bottom < y) - { return TRUE; - } } return FALSE; } @@ -4867,13 +4826,17 @@ void SetBerryTreeJustPicked(u8 localId, u8 mapNum, u8 mapGroup) } } +#undef sTimer +#undef sBerryTreeFlags + void MoveCoords(u8 direction, s16 *x, s16 *y) { *x += sDirectionToVectors[direction].x; *y += sDirectionToVectors[direction].y; } -void sub_8092F60(u8 direction, s16 *x, s16 *y) +// Unused +static void MoveCoordsInMapCoordIncrement(u8 direction, s16 *x, s16 *y) { *x += sDirectionToVectors[direction].x << 4; *y += sDirectionToVectors[direction].y << 4; @@ -4894,7 +4857,7 @@ static void MoveCoordsInDirection(u32 dir, s16 *x, s16 *y, s16 deltaX, s16 delta *y -= dy2; } -void sub_8092FF0(s16 x, s16 y, s16 *destX, s16 *destY) +void GetMapCoordsFromSpritePos(s16 x, s16 y, s16 *destX, s16 *destY) { *destX = (x - gSaveBlock1Ptr->pos.x) << 4; *destY = (y - gSaveBlock1Ptr->pos.y) << 4; @@ -4933,22 +4896,18 @@ static void GetObjectEventMovingCameraOffset(s16 *x, s16 *y) { *x = 0; *y = 0; + if (gFieldCamera.x > 0) - { (*x)++; - } + if (gFieldCamera.x < 0) - { - (*x) --; - } + (*x)--; + if (gFieldCamera.y > 0) - { (*y)++; - } + if (gFieldCamera.y < 0) - { - (*y) --; - } + (*y)--; } void ObjectEventMoveDestCoords(struct ObjectEvent *objectEvent, u32 direction, s16 *x, s16 *y) @@ -4984,7 +4943,7 @@ bool8 ObjectEventSetHeldMovement(struct ObjectEvent *objectEvent, u8 movementAct objectEvent->movementActionId = movementActionId; objectEvent->heldMovementActive = TRUE; objectEvent->heldMovementFinished = FALSE; - gSprites[objectEvent->spriteId].data[2] = 0; + gSprites[objectEvent->spriteId].sActionFuncId = 0; return FALSE; } @@ -5005,8 +4964,8 @@ void ObjectEventClearHeldMovement(struct ObjectEvent *objectEvent) objectEvent->movementActionId = 0xFF; objectEvent->heldMovementActive = FALSE; objectEvent->heldMovementFinished = FALSE; - gSprites[objectEvent->spriteId].data[1] = 0; - gSprites[objectEvent->spriteId].data[2] = 0; + gSprites[objectEvent->spriteId].sTypeFuncId = 0; + gSprites[objectEvent->spriteId].sActionFuncId = 0; } u8 ObjectEventCheckHeldMovementStatus(struct ObjectEvent *objectEvent) @@ -5031,7 +4990,7 @@ u8 ObjectEventGetHeldMovementActionId(struct ObjectEvent *objectEvent) if (objectEvent->heldMovementActive) return objectEvent->movementActionId; - return 0xFF; + return MOVEMENT_ACTION_NONE; } void UpdateObjectEventCurrentMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite, bool8 (*callback)(struct ObjectEvent *, struct Sprite *)) @@ -5100,10 +5059,10 @@ dirn_to_anim(GetAcroEndWheelieMoveDirectionMovementAction, gAcroEndWheelieMoveDi u8 GetOppositeDirection(u8 direction) { - u8 directions[sizeof gOppositeDirections]; + u8 directions[sizeof sOppositeDirections]; - memcpy(directions, gOppositeDirections, sizeof gOppositeDirections); - if (direction < 1 || direction > (sizeof gOppositeDirections)) + memcpy(directions, sOppositeDirections, sizeof sOppositeDirections); + if (direction <= DIR_NONE || direction > (sizeof sOppositeDirections)) { return direction; } @@ -5133,7 +5092,7 @@ static u32 state_to_direction(u8 a0, u32 a1, u32 a2) static void ObjectEventExecHeldMovementAction(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (gMovementActionFuncs[objectEvent->movementActionId][sprite->data[2]](objectEvent, sprite)) + if (gMovementActionFuncs[objectEvent->movementActionId][sprite->sActionFuncId](objectEvent, sprite)) { objectEvent->heldMovementFinished = TRUE; } @@ -5141,10 +5100,10 @@ static void ObjectEventExecHeldMovementAction(struct ObjectEvent *objectEvent, s static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (gMovementActionFuncs[objectEvent->movementActionId][sprite->data[2]](objectEvent, sprite)) + if (gMovementActionFuncs[objectEvent->movementActionId][sprite->sActionFuncId](objectEvent, sprite)) { objectEvent->movementActionId = 0xFF; - sprite->data[2] = 0; + sprite->sActionFuncId = 0; return TRUE; } return FALSE; @@ -5153,7 +5112,7 @@ static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *objectEvent static void ObjectEventSetSingleMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 animId) { objectEvent->movementActionId = animId; - sprite->data[2] = 0; + sprite->sActionFuncId = 0; } static void FaceDirection(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) @@ -5162,7 +5121,7 @@ static void FaceDirection(struct ObjectEvent *objectEvent, struct Sprite *sprite ShiftStillObjectEventCoords(objectEvent); obj_npc_animation_step(objectEvent, sprite, GetMoveDirectionAnimNum(objectEvent->facingDirection)); sprite->animPaused = TRUE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; } bool8 MovementAction_FaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) @@ -5201,30 +5160,30 @@ void npc_apply_direction(struct ObjectEvent *objectEvent, struct Sprite *sprite, ShiftObjectEventCoords(objectEvent, x, y); oamt_npc_ministep_reset(sprite, direction, speed); sprite->animPaused = FALSE; - if (gLockedAnimObjectEvents != NULL && FindLockedObjectEventIndex(objectEvent) != OBJECT_EVENTS_COUNT) + if (sLockedAnimObjectEvents != NULL && FindLockedObjectEventIndex(objectEvent) != OBJECT_EVENTS_COUNT) { sprite->animPaused = TRUE; } objectEvent->triggerGroundEffectsOnMove = TRUE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; } -void do_go_anim(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed) +static void InitMovementNormal(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed) { - u8 (*functions[ARRAY_COUNT(gUnknown_0850DEE8)])(u8); + u8 (*functions[ARRAY_COUNT(sDirectionAnimFuncsBySpeed)])(u8); - memcpy(functions, gUnknown_0850DEE8, sizeof gUnknown_0850DEE8); + memcpy(functions, sDirectionAnimFuncsBySpeed, sizeof sDirectionAnimFuncsBySpeed); npc_apply_direction(objectEvent, sprite, direction, speed); npc_apply_anim_looping(objectEvent, sprite, functions[speed](objectEvent->facingDirection)); } -void StartRunningAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) +static void StartRunningAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) { npc_apply_direction(objectEvent, sprite, direction, 1); npc_apply_anim_looping(objectEvent, sprite, GetRunningDirectionAnimNum(objectEvent->facingDirection)); } -bool8 npc_obj_ministep_stop_on_arrival(struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 UpdateMovementNormal(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (obj_npc_ministep(sprite)) { @@ -5236,7 +5195,7 @@ bool8 npc_obj_ministep_stop_on_arrival(struct ObjectEvent *objectEvent, struct S return FALSE; } -void sub_8093AF0(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) +static void InitNpcForWalkSlow(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) { s16 x; s16 y; @@ -5246,21 +5205,21 @@ void sub_8093AF0(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 dire SetObjectEventDirection(objectEvent, direction); MoveCoords(direction, &x, &y); ShiftObjectEventCoords(objectEvent, x, y); - sub_80976DC(sprite, direction); + SetWalkSlowSpriteData(sprite, direction); sprite->animPaused = FALSE; objectEvent->triggerGroundEffectsOnMove = TRUE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; } -void sub_8093B60(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) +static void InitWalkSlow(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) { - sub_8093AF0(objectEvent, sprite, direction); + InitNpcForWalkSlow(objectEvent, sprite, direction); npc_apply_anim_looping(objectEvent, sprite, GetMoveDirectionAnimNum(objectEvent->facingDirection)); } -bool8 an_walk_any_2(struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 UpdateWalkSlow(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80976EC(sprite)) + if (UpdateWalkSlowAnim(sprite)) { ShiftStillObjectEventCoords(objectEvent); objectEvent->triggerGroundEffectsOnStop = TRUE; @@ -5272,15 +5231,15 @@ bool8 an_walk_any_2(struct ObjectEvent *objectEvent, struct Sprite *sprite) bool8 MovementAction_WalkSlowDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8093B60(objectEvent, sprite, DIR_NORTHWEST); + InitWalkSlow(objectEvent, sprite, DIR_NORTHWEST); return MovementAction_WalkSlowDiagonalUpLeft_Step1(objectEvent, sprite); } bool8 MovementAction_WalkSlowDiagonalUpLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (an_walk_any_2(objectEvent, sprite)) + if (UpdateWalkSlow(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5288,15 +5247,15 @@ bool8 MovementAction_WalkSlowDiagonalUpLeft_Step1(struct ObjectEvent *objectEven bool8 MovementAction_WalkSlowDiagonalUpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8093B60(objectEvent, sprite, DIR_NORTHEAST); + InitWalkSlow(objectEvent, sprite, DIR_NORTHEAST); return MovementAction_WalkSlowDiagonalUpRight_Step1(objectEvent, sprite); } bool8 MovementAction_WalkSlowDiagonalUpRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (an_walk_any_2(objectEvent, sprite)) + if (UpdateWalkSlow(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5304,15 +5263,15 @@ bool8 MovementAction_WalkSlowDiagonalUpRight_Step1(struct ObjectEvent *objectEve bool8 MovementAction_WalkSlowDiagonalDownLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8093B60(objectEvent, sprite, DIR_SOUTHWEST); + InitWalkSlow(objectEvent, sprite, DIR_SOUTHWEST); return MovementAction_WalkSlowDiagonalDownLeft_Step1(objectEvent, sprite); } bool8 MovementAction_WalkSlowDiagonalDownLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (an_walk_any_2(objectEvent, sprite)) + if (UpdateWalkSlow(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5320,15 +5279,15 @@ bool8 MovementAction_WalkSlowDiagonalDownLeft_Step1(struct ObjectEvent *objectEv bool8 MovementAction_WalkSlowDiagonalDownRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8093B60(objectEvent, sprite, DIR_SOUTHEAST); + InitWalkSlow(objectEvent, sprite, DIR_SOUTHEAST); return MovementAction_WalkSlowDiagonalDownRight_Step1(objectEvent, sprite); } bool8 MovementAction_WalkSlowDiagonalDownRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (an_walk_any_2(objectEvent, sprite)) + if (UpdateWalkSlow(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5336,15 +5295,15 @@ bool8 MovementAction_WalkSlowDiagonalDownRight_Step1(struct ObjectEvent *objectE bool8 MovementAction_WalkSlowDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8093B60(objectEvent, sprite, DIR_SOUTH); + InitWalkSlow(objectEvent, sprite, DIR_SOUTH); return MovementAction_WalkSlowDown_Step1(objectEvent, sprite); } bool8 MovementAction_WalkSlowDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (an_walk_any_2(objectEvent, sprite)) + if (UpdateWalkSlow(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5352,15 +5311,15 @@ bool8 MovementAction_WalkSlowDown_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkSlowUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8093B60(objectEvent, sprite, DIR_NORTH); + InitWalkSlow(objectEvent, sprite, DIR_NORTH); return MovementAction_WalkSlowUp_Step1(objectEvent, sprite); } bool8 MovementAction_WalkSlowUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (an_walk_any_2(objectEvent, sprite)) + if (UpdateWalkSlow(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5368,15 +5327,15 @@ bool8 MovementAction_WalkSlowUp_Step1(struct ObjectEvent *objectEvent, struct Sp bool8 MovementAction_WalkSlowLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8093B60(objectEvent, sprite, DIR_WEST); + InitWalkSlow(objectEvent, sprite, DIR_WEST); return MovementAction_WalkSlowLeft_Step1(objectEvent, sprite); } bool8 MovementAction_WalkSlowLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (an_walk_any_2(objectEvent, sprite)) + if (UpdateWalkSlow(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5384,15 +5343,15 @@ bool8 MovementAction_WalkSlowLeft_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkSlowRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8093B60(objectEvent, sprite, DIR_EAST); + InitWalkSlow(objectEvent, sprite, DIR_EAST); return MovementAction_WalkSlowRight_Step1(objectEvent, sprite); } bool8 MovementAction_WalkSlowRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (an_walk_any_2(objectEvent, sprite)) + if (UpdateWalkSlow(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5400,15 +5359,15 @@ bool8 MovementAction_WalkSlowRight_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkNormalDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_NORTHWEST, 0); + InitMovementNormal(objectEvent, sprite, DIR_NORTHWEST, 0); return MovementAction_WalkNormalDiagonalUpLeft_Step1(objectEvent, sprite); } bool8 MovementAction_WalkNormalDiagonalUpLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5416,15 +5375,15 @@ bool8 MovementAction_WalkNormalDiagonalUpLeft_Step1(struct ObjectEvent *objectEv bool8 MovementAction_WalkNormalDiagonalUpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_NORTHEAST, 0); + InitMovementNormal(objectEvent, sprite, DIR_NORTHEAST, 0); return MovementAction_WalkNormalDiagonalUpRight_Step1(objectEvent, sprite); } bool8 MovementAction_WalkNormalDiagonalUpRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5432,15 +5391,15 @@ bool8 MovementAction_WalkNormalDiagonalUpRight_Step1(struct ObjectEvent *objectE bool8 MovementAction_WalkNormalDiagonalDownLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_SOUTHWEST, 0); + InitMovementNormal(objectEvent, sprite, DIR_SOUTHWEST, 0); return MovementAction_WalkNormalDiagonalDownLeft_Step1(objectEvent, sprite); } bool8 MovementAction_WalkNormalDiagonalDownLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5448,15 +5407,15 @@ bool8 MovementAction_WalkNormalDiagonalDownLeft_Step1(struct ObjectEvent *object bool8 MovementAction_WalkNormalDiagonalDownRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_SOUTHEAST, 0); + InitMovementNormal(objectEvent, sprite, DIR_SOUTHEAST, 0); return MovementAction_WalkNormalDiagonalDownRight_Step1(objectEvent, sprite); } bool8 MovementAction_WalkNormalDiagonalDownRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5464,15 +5423,15 @@ bool8 MovementAction_WalkNormalDiagonalDownRight_Step1(struct ObjectEvent *objec bool8 MovementAction_WalkNormalDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_SOUTH, 0); + InitMovementNormal(objectEvent, sprite, DIR_SOUTH, 0); return MovementAction_WalkNormalDown_Step1(objectEvent, sprite); } bool8 MovementAction_WalkNormalDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5480,15 +5439,15 @@ bool8 MovementAction_WalkNormalDown_Step1(struct ObjectEvent *objectEvent, struc bool8 MovementAction_WalkNormalUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_NORTH, 0); + InitMovementNormal(objectEvent, sprite, DIR_NORTH, 0); return MovementAction_WalkNormalUp_Step1(objectEvent, sprite); } bool8 MovementAction_WalkNormalUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5496,15 +5455,15 @@ bool8 MovementAction_WalkNormalUp_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkNormalLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_WEST, 0); + InitMovementNormal(objectEvent, sprite, DIR_WEST, 0); return MovementAction_WalkNormalLeft_Step1(objectEvent, sprite); } bool8 MovementAction_WalkNormalLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5512,21 +5471,30 @@ bool8 MovementAction_WalkNormalLeft_Step1(struct ObjectEvent *objectEvent, struc bool8 MovementAction_WalkNormalRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_EAST, 0); + InitMovementNormal(objectEvent, sprite, DIR_EAST, 0); return MovementAction_WalkNormalRight_Step1(objectEvent, sprite); } bool8 MovementAction_WalkNormalRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; } -void sub_8093FC4(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed, u8 a5) +#define JUMP_HALFWAY 1 +#define JUMP_FINISHED ((u8)-1) + +enum { + JUMP_TYPE_HIGH, + JUMP_TYPE_LOW, + JUMP_TYPE_NORMAL, +}; + +static void InitJump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed, u8 type) { s16 displacements[ARRAY_COUNT(gUnknown_0850DFBC)]; s16 x; @@ -5538,21 +5506,21 @@ void sub_8093FC4(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 dire SetObjectEventDirection(objectEvent, direction); MoveCoordsInDirection(direction, &x, &y, displacements[speed], displacements[speed]); ShiftObjectEventCoords(objectEvent, objectEvent->currentCoords.x + x, objectEvent->currentCoords.y + y); - sub_809783C(sprite, direction, speed, a5); - sprite->data[2] = 1; - sprite->animPaused = 0; - objectEvent->triggerGroundEffectsOnMove = 1; - objectEvent->disableCoveringGroundEffects = 1; + SetJumpSpriteData(sprite, direction, speed, type); + sprite->sActionFuncId = 1; + sprite->animPaused = FALSE; + objectEvent->triggerGroundEffectsOnMove = TRUE; + objectEvent->disableCoveringGroundEffects = TRUE; } -void maybe_shadow_1(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed, u8 a4) +static void InitJumpRegular(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed, u8 type) { - sub_8093FC4(objectEvent, sprite, direction, speed, a4); + InitJump(objectEvent, sprite, direction, speed, type); npc_apply_anim_looping(objectEvent, sprite, GetMoveDirectionAnimNum(objectEvent->facingDirection)); DoShadowFieldEffect(objectEvent); } -u8 sub_80940C4(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 callback(struct Sprite *)) +static u8 UpdateJumpAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 callback(struct Sprite *)) { s16 displacements[ARRAY_COUNT(gUnknown_0850DFC2)]; s16 x; @@ -5561,7 +5529,7 @@ u8 sub_80940C4(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 callba memcpy(displacements, gUnknown_0850DFC2, sizeof gUnknown_0850DFC2); result = callback(sprite); - if (result == 1 && displacements[sprite->data[4]] != 0) + if (result == JUMP_HALFWAY && displacements[sprite->data[4]] != 0) { x = 0; y = 0; @@ -5570,7 +5538,7 @@ u8 sub_80940C4(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 callba objectEvent->triggerGroundEffectsOnMove = TRUE; objectEvent->disableCoveringGroundEffects = TRUE; } - else if (result == 0xFF) + else if (result == JUMP_FINISHED) { ShiftStillObjectEventCoords(objectEvent); objectEvent->triggerGroundEffectsOnStop = TRUE; @@ -5580,41 +5548,39 @@ u8 sub_80940C4(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 callba return result; } -u8 sub_8094188(struct ObjectEvent *objectEvent, struct Sprite *sprite) +static u8 DoJumpAnimStep(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - return sub_80940C4(objectEvent, sprite, sub_809785C); + return UpdateJumpAnim(objectEvent, sprite, DoJumpSpriteMovement); } -u8 sub_809419C(struct ObjectEvent *objectEvent, struct Sprite *sprite) +static u8 DoJumpSpecialAnimStep(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - return sub_80940C4(objectEvent, sprite, sub_80978E4); + return UpdateJumpAnim(objectEvent, sprite, DoJumpSpecialSpriteMovement); } -bool8 sub_80941B0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 DoJumpAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_8094188(objectEvent, sprite) == 0xFF) - { + if (DoJumpAnimStep(objectEvent, sprite) == JUMP_FINISHED) return TRUE; - } + return FALSE; } -bool8 sub_80941C8(struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 DoJumpSpecialAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_809419C(objectEvent, sprite) == 0xFF) - { + if (DoJumpSpecialAnimStep(objectEvent, sprite) == JUMP_FINISHED) return TRUE; - } + return FALSE; } -bool8 sub_80941E0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +static bool8 DoJumpInPlaceAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - switch (sub_8094188(objectEvent, sprite)) + switch (DoJumpAnimStep(objectEvent, sprite)) { - case 255: + case JUMP_FINISHED: return TRUE; - case 1: + case JUMP_HALFWAY: SetObjectEventDirection(objectEvent, GetOppositeDirection(objectEvent->movementDirection)); obj_npc_animation_step(objectEvent, sprite, GetMoveDirectionAnimNum(objectEvent->facingDirection)); default: @@ -5624,16 +5590,16 @@ bool8 sub_80941E0(struct ObjectEvent *objectEvent, struct Sprite *sprite) bool8 MovementAction_Jump2Down_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_SOUTH, 2, 0); + InitJumpRegular(objectEvent, sprite, DIR_SOUTH, 2, JUMP_TYPE_HIGH); return MovementAction_Jump2Down_Step1(objectEvent, sprite); } bool8 MovementAction_Jump2Down_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5641,16 +5607,16 @@ bool8 MovementAction_Jump2Down_Step1(struct ObjectEvent *objectEvent, struct Spr bool8 MovementAction_Jump2Up_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_NORTH, 2, 0); + InitJumpRegular(objectEvent, sprite, DIR_NORTH, 2, JUMP_TYPE_HIGH); return MovementAction_Jump2Up_Step1(objectEvent, sprite); } bool8 MovementAction_Jump2Up_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5658,16 +5624,16 @@ bool8 MovementAction_Jump2Up_Step1(struct ObjectEvent *objectEvent, struct Sprit bool8 MovementAction_Jump2Left_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_WEST, 2, 0); + InitJumpRegular(objectEvent, sprite, DIR_WEST, 2, JUMP_TYPE_HIGH); return MovementAction_Jump2Left_Step1(objectEvent, sprite); } bool8 MovementAction_Jump2Left_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5675,33 +5641,32 @@ bool8 MovementAction_Jump2Left_Step1(struct ObjectEvent *objectEvent, struct Spr bool8 MovementAction_Jump2Right_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_EAST, 2, 0); + InitJumpRegular(objectEvent, sprite, DIR_EAST, 2, JUMP_TYPE_HIGH); return MovementAction_Jump2Right_Step1(objectEvent, sprite); } bool8 MovementAction_Jump2Right_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; } - -void sub_8094390(struct Sprite *sprite, u16 duration) +static void InitMovementDelay(struct Sprite *sprite, u16 duration) { - sprite->data[2] = 1; + sprite->sActionFuncId = 1; sprite->data[3] = duration; } bool8 MovementAction_Delay_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (-- sprite->data[3] == 0) + if (--sprite->data[3] == 0) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5709,45 +5674,45 @@ bool8 MovementAction_Delay_Step1(struct ObjectEvent *objectEvent, struct Sprite bool8 MovementAction_Delay1_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094390(sprite, 1); + InitMovementDelay(sprite, 1); return MovementAction_Delay_Step1(objectEvent, sprite); } bool8 MovementAction_Delay2_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094390(sprite, 2); + InitMovementDelay(sprite, 2); return MovementAction_Delay_Step1(objectEvent, sprite); } bool8 MovementAction_Delay4_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094390(sprite, 4); + InitMovementDelay(sprite, 4); return MovementAction_Delay_Step1(objectEvent, sprite); } bool8 MovementAction_Delay8_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094390(sprite, 8); + InitMovementDelay(sprite, 8); return MovementAction_Delay_Step1(objectEvent, sprite); } bool8 MovementAction_Delay16_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094390(sprite, 16); + InitMovementDelay(sprite, 16); return MovementAction_Delay_Step1(objectEvent, sprite); } bool8 MovementAction_WalkFastDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_SOUTH, 1); + InitMovementNormal(objectEvent, sprite, DIR_SOUTH, 1); return MovementAction_WalkFastDown_Step1(objectEvent, sprite); } bool8 MovementAction_WalkFastDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5755,15 +5720,15 @@ bool8 MovementAction_WalkFastDown_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkFastUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_NORTH, 1); + InitMovementNormal(objectEvent, sprite, DIR_NORTH, 1); return MovementAction_WalkFastUp_Step1(objectEvent, sprite); } bool8 MovementAction_WalkFastUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5771,15 +5736,15 @@ bool8 MovementAction_WalkFastUp_Step1(struct ObjectEvent *objectEvent, struct Sp bool8 MovementAction_WalkFastLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_WEST, 1); + InitMovementNormal(objectEvent, sprite, DIR_WEST, 1); return MovementAction_WalkFastLeft_Step1(objectEvent, sprite); } bool8 MovementAction_WalkFastLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5787,27 +5752,27 @@ bool8 MovementAction_WalkFastLeft_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkFastRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_EAST, 1); + InitMovementNormal(objectEvent, sprite, DIR_EAST, 1); return MovementAction_WalkFastRight_Step1(objectEvent, sprite); } bool8 MovementAction_WalkFastRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; } -void sub_8094554(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 animNum, u16 duration) +static void InitMoveInPlace(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 animNum, u16 duration) { SetObjectEventDirection(objectEvent, direction); npc_apply_anim_looping(objectEvent, sprite, animNum); sprite->animPaused = FALSE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; sprite->data[3] = duration; } @@ -5815,7 +5780,7 @@ bool8 MovementAction_WalkInPlace_Step1(struct ObjectEvent *objectEvent, struct S { if (-- sprite->data[3] == 0) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; sprite->animPaused = TRUE; return TRUE; } @@ -5833,111 +5798,111 @@ bool8 MovementAction_WalkInPlaceSlow_Step1(struct ObjectEvent *objectEvent, stru bool8 MovementAction_WalkInPlaceSlowDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_SOUTH, GetMoveDirectionAnimNum(DIR_SOUTH), 32); + InitMoveInPlace(objectEvent, sprite, DIR_SOUTH, GetMoveDirectionAnimNum(DIR_SOUTH), 32); return MovementAction_WalkInPlaceSlow_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceSlowUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_NORTH, GetMoveDirectionAnimNum(DIR_NORTH), 32); + InitMoveInPlace(objectEvent, sprite, DIR_NORTH, GetMoveDirectionAnimNum(DIR_NORTH), 32); return MovementAction_WalkInPlaceSlow_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceSlowLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_WEST, GetMoveDirectionAnimNum(DIR_WEST), 32); + InitMoveInPlace(objectEvent, sprite, DIR_WEST, GetMoveDirectionAnimNum(DIR_WEST), 32); return MovementAction_WalkInPlaceSlow_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceSlowRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_EAST, GetMoveDirectionAnimNum(DIR_EAST), 32); + InitMoveInPlace(objectEvent, sprite, DIR_EAST, GetMoveDirectionAnimNum(DIR_EAST), 32); return MovementAction_WalkInPlaceSlow_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceNormalDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_SOUTH, GetMoveDirectionAnimNum(DIR_SOUTH), 16); + InitMoveInPlace(objectEvent, sprite, DIR_SOUTH, GetMoveDirectionAnimNum(DIR_SOUTH), 16); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceNormalUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_NORTH, GetMoveDirectionAnimNum(DIR_NORTH), 16); + InitMoveInPlace(objectEvent, sprite, DIR_NORTH, GetMoveDirectionAnimNum(DIR_NORTH), 16); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceNormalLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_WEST, GetMoveDirectionAnimNum(DIR_WEST), 16); + InitMoveInPlace(objectEvent, sprite, DIR_WEST, GetMoveDirectionAnimNum(DIR_WEST), 16); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceNormalRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_EAST, GetMoveDirectionAnimNum(DIR_EAST), 16); + InitMoveInPlace(objectEvent, sprite, DIR_EAST, GetMoveDirectionAnimNum(DIR_EAST), 16); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceFastDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_SOUTH, GetMoveDirectionFastAnimNum(DIR_SOUTH), 8); + InitMoveInPlace(objectEvent, sprite, DIR_SOUTH, GetMoveDirectionFastAnimNum(DIR_SOUTH), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceFastUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_NORTH, GetMoveDirectionFastAnimNum(DIR_NORTH), 8); + InitMoveInPlace(objectEvent, sprite, DIR_NORTH, GetMoveDirectionFastAnimNum(DIR_NORTH), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceFastLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_WEST, GetMoveDirectionFastAnimNum(DIR_WEST), 8); + InitMoveInPlace(objectEvent, sprite, DIR_WEST, GetMoveDirectionFastAnimNum(DIR_WEST), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceFastRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_EAST, GetMoveDirectionFastAnimNum(DIR_EAST), 8); + InitMoveInPlace(objectEvent, sprite, DIR_EAST, GetMoveDirectionFastAnimNum(DIR_EAST), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceFastestDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_SOUTH, GetMoveDirectionFasterAnimNum(DIR_SOUTH), 4); + InitMoveInPlace(objectEvent, sprite, DIR_SOUTH, GetMoveDirectionFasterAnimNum(DIR_SOUTH), 4); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceFastestUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_NORTH, GetMoveDirectionFasterAnimNum(DIR_NORTH), 4); + InitMoveInPlace(objectEvent, sprite, DIR_NORTH, GetMoveDirectionFasterAnimNum(DIR_NORTH), 4); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceFastestLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_WEST, GetMoveDirectionFasterAnimNum(DIR_WEST), 4); + InitMoveInPlace(objectEvent, sprite, DIR_WEST, GetMoveDirectionFasterAnimNum(DIR_WEST), 4); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceFastestRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_EAST, GetMoveDirectionFasterAnimNum(DIR_EAST), 4); + InitMoveInPlace(objectEvent, sprite, DIR_EAST, GetMoveDirectionFasterAnimNum(DIR_EAST), 4); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_RideWaterCurrentDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_SOUTH, 2); + InitMovementNormal(objectEvent, sprite, DIR_SOUTH, 2); return MovementAction_RideWaterCurrentDown_Step1(objectEvent, sprite); } bool8 MovementAction_RideWaterCurrentDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5945,15 +5910,15 @@ bool8 MovementAction_RideWaterCurrentDown_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_RideWaterCurrentUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_NORTH, 2); + InitMovementNormal(objectEvent, sprite, DIR_NORTH, 2); return MovementAction_RideWaterCurrentUp_Step1(objectEvent, sprite); } bool8 MovementAction_RideWaterCurrentUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5961,15 +5926,15 @@ bool8 MovementAction_RideWaterCurrentUp_Step1(struct ObjectEvent *objectEvent, s bool8 MovementAction_RideWaterCurrentLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_WEST, 2); + InitMovementNormal(objectEvent, sprite, DIR_WEST, 2); return MovementAction_RideWaterCurrentLeft_Step1(objectEvent, sprite); } bool8 MovementAction_RideWaterCurrentLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5977,15 +5942,15 @@ bool8 MovementAction_RideWaterCurrentLeft_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_RideWaterCurrentRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_EAST, 2); + InitMovementNormal(objectEvent, sprite, DIR_EAST, 2); return MovementAction_RideWaterCurrentRight_Step1(objectEvent, sprite); } bool8 MovementAction_RideWaterCurrentRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -5993,15 +5958,15 @@ bool8 MovementAction_RideWaterCurrentRight_Step1(struct ObjectEvent *objectEvent bool8 MovementAction_WalkFastestDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_SOUTH, 3); + InitMovementNormal(objectEvent, sprite, DIR_SOUTH, 3); return MovementAction_WalkFastestDown_Step1(objectEvent, sprite); } bool8 MovementAction_WalkFastestDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6009,15 +5974,15 @@ bool8 MovementAction_WalkFastestDown_Step1(struct ObjectEvent *objectEvent, stru bool8 MovementAction_WalkFastestUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_NORTH, 3); + InitMovementNormal(objectEvent, sprite, DIR_NORTH, 3); return MovementAction_WalkFastestUp_Step1(objectEvent, sprite); } bool8 MovementAction_WalkFastestUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6025,15 +5990,15 @@ bool8 MovementAction_WalkFastestUp_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkFastestLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_WEST, 3); + InitMovementNormal(objectEvent, sprite, DIR_WEST, 3); return MovementAction_WalkFastestLeft_Step1(objectEvent, sprite); } bool8 MovementAction_WalkFastestLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6041,15 +6006,15 @@ bool8 MovementAction_WalkFastestLeft_Step1(struct ObjectEvent *objectEvent, stru bool8 MovementAction_WalkFastestRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_EAST, 3); + InitMovementNormal(objectEvent, sprite, DIR_EAST, 3); return MovementAction_WalkFastestRight_Step1(objectEvent, sprite); } bool8 MovementAction_WalkFastestRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6057,15 +6022,15 @@ bool8 MovementAction_WalkFastestRight_Step1(struct ObjectEvent *objectEvent, str bool8 MovementAction_SlideDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_SOUTH, 4); + InitMovementNormal(objectEvent, sprite, DIR_SOUTH, 4); return MovementAction_SlideDown_Step1(objectEvent, sprite); } bool8 MovementAction_SlideDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6073,15 +6038,15 @@ bool8 MovementAction_SlideDown_Step1(struct ObjectEvent *objectEvent, struct Spr bool8 MovementAction_SlideUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_NORTH, 4); + InitMovementNormal(objectEvent, sprite, DIR_NORTH, 4); return MovementAction_SlideUp_Step1(objectEvent, sprite); } bool8 MovementAction_SlideUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6089,15 +6054,15 @@ bool8 MovementAction_SlideUp_Step1(struct ObjectEvent *objectEvent, struct Sprit bool8 MovementAction_SlideLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_WEST, 4); + InitMovementNormal(objectEvent, sprite, DIR_WEST, 4); return MovementAction_SlideLeft_Step1(objectEvent, sprite); } bool8 MovementAction_SlideLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6105,15 +6070,15 @@ bool8 MovementAction_SlideLeft_Step1(struct ObjectEvent *objectEvent, struct Spr bool8 MovementAction_SlideRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_EAST, 4); + InitMovementNormal(objectEvent, sprite, DIR_EAST, 4); return MovementAction_SlideRight_Step1(objectEvent, sprite); } bool8 MovementAction_SlideRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6127,9 +6092,9 @@ bool8 MovementAction_PlayerRunDown_Step0(struct ObjectEvent *objectEvent, struct bool8 MovementAction_PlayerRunDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6143,9 +6108,9 @@ bool8 MovementAction_PlayerRunUp_Step0(struct ObjectEvent *objectEvent, struct S bool8 MovementAction_PlayerRunUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6159,9 +6124,9 @@ bool8 MovementAction_PlayerRunLeft_Step0(struct ObjectEvent *objectEvent, struct bool8 MovementAction_PlayerRunLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6175,9 +6140,9 @@ bool8 MovementAction_PlayerRunRight_Step0(struct ObjectEvent *objectEvent, struc bool8 MovementAction_PlayerRunRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6187,7 +6152,7 @@ void StartSpriteAnimInDirection(struct ObjectEvent *objectEvent, struct Sprite * { SetAndStartSpriteAnim(sprite, animNum, 0); SetObjectEventDirection(objectEvent, direction); - sprite->data[2] = 1; + sprite->sActionFuncId = 1; } bool8 MovementAction_StartAnimInDirection_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) @@ -6200,29 +6165,29 @@ bool8 MovementAction_WaitSpriteAnim(struct ObjectEvent *objectEvent, struct Spri { if (SpriteAnimEnded(sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; } -void sub_8094DE4(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) +static void InitJumpSpecial(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) { - sub_8093FC4(objectEvent, sprite, direction, 1, 0); + InitJump(objectEvent, sprite, direction, 1, JUMP_TYPE_HIGH); StartSpriteAnim(sprite, GetJumpSpecialDirectionAnimNum(direction)); } bool8 MovementAction_JumpSpecialDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094DE4(objectEvent, sprite, DIR_SOUTH); + InitJumpSpecial(objectEvent, sprite, DIR_SOUTH); return MovementAction_JumpSpecialDown_Step1(objectEvent, sprite); } bool8 MovementAction_JumpSpecialDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941C8(objectEvent, sprite)) + if (DoJumpSpecialAnim(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; objectEvent->landingJump = FALSE; return TRUE; } @@ -6231,15 +6196,15 @@ bool8 MovementAction_JumpSpecialDown_Step1(struct ObjectEvent *objectEvent, stru bool8 MovementAction_JumpSpecialUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094DE4(objectEvent, sprite, DIR_NORTH); + InitJumpSpecial(objectEvent, sprite, DIR_NORTH); return MovementAction_JumpSpecialUp_Step1(objectEvent, sprite); } bool8 MovementAction_JumpSpecialUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941C8(objectEvent, sprite)) + if (DoJumpSpecialAnim(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; objectEvent->landingJump = FALSE; return TRUE; } @@ -6248,15 +6213,15 @@ bool8 MovementAction_JumpSpecialUp_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_JumpSpecialLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094DE4(objectEvent, sprite, DIR_WEST); + InitJumpSpecial(objectEvent, sprite, DIR_WEST); return MovementAction_JumpSpecialLeft_Step1(objectEvent, sprite); } bool8 MovementAction_JumpSpecialLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941C8(objectEvent, sprite)) + if (DoJumpSpecialAnim(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; objectEvent->landingJump = FALSE; return TRUE; } @@ -6265,15 +6230,15 @@ bool8 MovementAction_JumpSpecialLeft_Step1(struct ObjectEvent *objectEvent, stru bool8 MovementAction_JumpSpecialRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094DE4(objectEvent, sprite, DIR_EAST); + InitJumpSpecial(objectEvent, sprite, DIR_EAST); return MovementAction_JumpSpecialRight_Step1(objectEvent, sprite); } bool8 MovementAction_JumpSpecialRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941C8(objectEvent, sprite)) + if (DoJumpSpecialAnim(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; objectEvent->landingJump = FALSE; return TRUE; } @@ -6288,7 +6253,7 @@ bool8 MovementAction_FacePlayer_Step0(struct ObjectEvent *objectEvent, struct Sp { FaceDirection(objectEvent, sprite, GetDirectionToFace(objectEvent->currentCoords.x, objectEvent->currentCoords.y, gObjectEvents[playerObjectId].currentCoords.x, gObjectEvents[playerObjectId].currentCoords.y)); } - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } @@ -6300,36 +6265,36 @@ bool8 MovementAction_FaceAwayPlayer_Step0(struct ObjectEvent *objectEvent, struc { FaceDirection(objectEvent, sprite, GetOppositeDirection(GetDirectionToFace(objectEvent->currentCoords.x, objectEvent->currentCoords.y, gObjectEvents[playerObjectId].currentCoords.x, gObjectEvents[playerObjectId].currentCoords.y))); } - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } bool8 MovementAction_LockFacingDirection_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->facingDirectionLocked = TRUE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } bool8 MovementAction_UnlockFacingDirection_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->facingDirectionLocked = FALSE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } bool8 MovementAction_JumpDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_SOUTH, 1, 2); + InitJumpRegular(objectEvent, sprite, DIR_SOUTH, 1, JUMP_TYPE_NORMAL); return MovementAction_JumpDown_Step1(objectEvent, sprite); } bool8 MovementAction_JumpDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = 0; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6337,16 +6302,16 @@ bool8 MovementAction_JumpDown_Step1(struct ObjectEvent *objectEvent, struct Spri bool8 MovementAction_JumpUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_NORTH, 1, 2); + InitJumpRegular(objectEvent, sprite, DIR_NORTH, 1, JUMP_TYPE_NORMAL); return MovementAction_JumpUp_Step1(objectEvent, sprite); } bool8 MovementAction_JumpUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = 0; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6354,16 +6319,16 @@ bool8 MovementAction_JumpUp_Step1(struct ObjectEvent *objectEvent, struct Sprite bool8 MovementAction_JumpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_WEST, 1, 2); + InitJumpRegular(objectEvent, sprite, DIR_WEST, 1, JUMP_TYPE_NORMAL); return MovementAction_JumpLeft_Step1(objectEvent, sprite); } bool8 MovementAction_JumpLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = 0; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6371,16 +6336,16 @@ bool8 MovementAction_JumpLeft_Step1(struct ObjectEvent *objectEvent, struct Spri bool8 MovementAction_JumpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_EAST, 1, 2); + InitJumpRegular(objectEvent, sprite, DIR_EAST, 1, JUMP_TYPE_NORMAL); return MovementAction_JumpRight_Step1(objectEvent, sprite); } bool8 MovementAction_JumpRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = 0; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6388,16 +6353,16 @@ bool8 MovementAction_JumpRight_Step1(struct ObjectEvent *objectEvent, struct Spr bool8 MovementAction_JumpInPlaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_SOUTH, 0, 0); + InitJumpRegular(objectEvent, sprite, DIR_SOUTH, 0, JUMP_TYPE_HIGH); return MovementAction_JumpInPlaceDown_Step1(objectEvent, sprite); } bool8 MovementAction_JumpInPlaceDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = 0; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6405,16 +6370,16 @@ bool8 MovementAction_JumpInPlaceDown_Step1(struct ObjectEvent *objectEvent, stru bool8 MovementAction_JumpInPlaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_NORTH, 0, 0); + InitJumpRegular(objectEvent, sprite, DIR_NORTH, 0, JUMP_TYPE_HIGH); return MovementAction_JumpInPlaceUp_Step1(objectEvent, sprite); } bool8 MovementAction_JumpInPlaceUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = 0; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6422,16 +6387,16 @@ bool8 MovementAction_JumpInPlaceUp_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_JumpInPlaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_WEST, 0, 0); + InitJumpRegular(objectEvent, sprite, DIR_WEST, 0, JUMP_TYPE_HIGH); return MovementAction_JumpInPlaceLeft_Step1(objectEvent, sprite); } bool8 MovementAction_JumpInPlaceLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = 0; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6439,16 +6404,16 @@ bool8 MovementAction_JumpInPlaceLeft_Step1(struct ObjectEvent *objectEvent, stru bool8 MovementAction_JumpInPlaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_EAST, 0, 0); + InitJumpRegular(objectEvent, sprite, DIR_EAST, 0, JUMP_TYPE_HIGH); return MovementAction_JumpInPlaceRight_Step1(objectEvent, sprite); } bool8 MovementAction_JumpInPlaceRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = 0; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6456,16 +6421,16 @@ bool8 MovementAction_JumpInPlaceRight_Step1(struct ObjectEvent *objectEvent, str bool8 MovementAction_JumpInPlaceDownUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_SOUTH, 0, 2); + InitJumpRegular(objectEvent, sprite, DIR_SOUTH, 0, JUMP_TYPE_NORMAL); return MovementAction_JumpInPlaceDownUp_Step1(objectEvent, sprite); } bool8 MovementAction_JumpInPlaceDownUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941E0(objectEvent, sprite)) + if (DoJumpInPlaceAnim(objectEvent, sprite)) { objectEvent->hasShadow = 0; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6473,16 +6438,16 @@ bool8 MovementAction_JumpInPlaceDownUp_Step1(struct ObjectEvent *objectEvent, st bool8 MovementAction_JumpInPlaceUpDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_NORTH, 0, 2); + InitJumpRegular(objectEvent, sprite, DIR_NORTH, 0, JUMP_TYPE_NORMAL); return MovementAction_JumpInPlaceUpDown_Step1(objectEvent, sprite); } bool8 MovementAction_JumpInPlaceUpDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941E0(objectEvent, sprite)) + if (DoJumpInPlaceAnim(objectEvent, sprite)) { objectEvent->hasShadow = 0; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6490,16 +6455,16 @@ bool8 MovementAction_JumpInPlaceUpDown_Step1(struct ObjectEvent *objectEvent, st bool8 MovementAction_JumpInPlaceLeftRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_WEST, 0, 2); + InitJumpRegular(objectEvent, sprite, DIR_WEST, 0, JUMP_TYPE_NORMAL); return MovementAction_JumpInPlaceLeftRight_Step1(objectEvent, sprite); } bool8 MovementAction_JumpInPlaceLeftRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941E0(objectEvent, sprite)) + if (DoJumpInPlaceAnim(objectEvent, sprite)) { objectEvent->hasShadow = 0; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6507,16 +6472,16 @@ bool8 MovementAction_JumpInPlaceLeftRight_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_JumpInPlaceRightLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - maybe_shadow_1(objectEvent, sprite, DIR_EAST, 0, 2); + InitJumpRegular(objectEvent, sprite, DIR_EAST, 0, JUMP_TYPE_NORMAL); return MovementAction_JumpInPlaceRightLeft_Step1(objectEvent, sprite); } bool8 MovementAction_JumpInPlaceRightLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941E0(objectEvent, sprite)) + if (DoJumpInPlaceAnim(objectEvent, sprite)) { objectEvent->hasShadow = 0; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6537,42 +6502,42 @@ bool8 MovementAction_NurseJoyBowDown_Step0(struct ObjectEvent *objectEvent, stru bool8 MovementAction_EnableJumpLandingGroundEffect_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->disableJumpLandingGroundEffect = FALSE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } bool8 MovementAction_DisableJumpLandingGroundEffect_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->disableJumpLandingGroundEffect = TRUE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } bool8 MovementAction_DisableAnimation_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->inanimate = TRUE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } bool8 MovementAction_RestoreAnimation_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->inanimate = GetObjectEventGraphicsInfo(objectEvent->graphicsId)->inanimate; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } bool8 MovementAction_SetInvisible_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->invisible = TRUE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } bool8 MovementAction_SetVisible_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->invisible = FALSE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } @@ -6580,7 +6545,7 @@ bool8 MovementAction_EmoteExclamationMark_Step0(struct ObjectEvent *objectEvent, { ObjectEventGetLocalIdAndMap(objectEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]); FieldEffectStart(FLDEFF_EXCLAMATION_MARK_ICON); - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } @@ -6588,7 +6553,7 @@ bool8 MovementAction_EmoteQuestionMark_Step0(struct ObjectEvent *objectEvent, st { ObjectEventGetLocalIdAndMap(objectEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]); FieldEffectStart(FLDEFF_QUESTION_MARK_ICON); - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } @@ -6596,7 +6561,7 @@ bool8 MovementAction_EmoteHeart_Step0(struct ObjectEvent *objectEvent, struct Sp { ObjectEventGetLocalIdAndMap(objectEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]); FieldEffectStart(FLDEFF_HEART_ICON); - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } @@ -6609,11 +6574,11 @@ bool8 MovementAction_RevealTrainer_Step0(struct ObjectEvent *objectEvent, struct } if (objectEvent->movementType != MOVEMENT_TYPE_TREE_DISGUISE && objectEvent->movementType != MOVEMENT_TYPE_MOUNTAIN_DISGUISE) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } sub_8155D78(objectEvent); - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return MovementAction_RevealTrainer_Step1(objectEvent, sprite); } @@ -6621,7 +6586,7 @@ bool8 MovementAction_RevealTrainer_Step1(struct ObjectEvent *objectEvent, struct { if (sub_8155DA0(objectEvent)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6630,7 +6595,7 @@ bool8 MovementAction_RevealTrainer_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_RockSmashBreak_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { SetAndStartSpriteAnim(sprite, 1, 0); - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return FALSE; } @@ -6639,7 +6604,7 @@ bool8 MovementAction_RockSmashBreak_Step1(struct ObjectEvent *objectEvent, struc if (SpriteAnimEnded(sprite)) { SetMovementDelay(sprite, 32); - sprite->data[2] = 2; + sprite->sActionFuncId = 2; } return FALSE; } @@ -6650,7 +6615,7 @@ bool8 MovementAction_RockSmashBreak_Step2(struct ObjectEvent *objectEvent, struc if (WaitForMovementDelay(sprite)) { objectEvent->invisible = TRUE; - sprite->data[2] = 3; + sprite->sActionFuncId = 3; } return FALSE; } @@ -6658,7 +6623,7 @@ bool8 MovementAction_RockSmashBreak_Step2(struct ObjectEvent *objectEvent, struc bool8 MovementAction_CutTree_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { SetAndStartSpriteAnim(sprite, 1, 0); - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return FALSE; } @@ -6667,7 +6632,7 @@ bool8 MovementAction_CutTree_Step1(struct ObjectEvent *objectEvent, struct Sprit if (SpriteAnimEnded(sprite)) { SetMovementDelay(sprite, 32); - sprite->data[2] = 2; + sprite->sActionFuncId = 2; } return FALSE; } @@ -6678,7 +6643,7 @@ bool8 MovementAction_CutTree_Step2(struct ObjectEvent *objectEvent, struct Sprit if (WaitForMovementDelay(sprite)) { objectEvent->invisible = TRUE; - sprite->data[2] = 3; + sprite->sActionFuncId = 3; } return FALSE; } @@ -6686,14 +6651,14 @@ bool8 MovementAction_CutTree_Step2(struct ObjectEvent *objectEvent, struct Sprit bool8 MovementAction_SetFixedPriority_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->fixedPriority = TRUE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } bool8 MovementAction_ClearFixedPriority_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->fixedPriority = FALSE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } @@ -6728,7 +6693,7 @@ bool8 MovementAction_ShowReflection_Step0(struct ObjectEvent *objectEvent, struc bool8 MovementAction_WalkDownStartAffine_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8093B60(objectEvent, sprite, DIR_SOUTH); + InitWalkSlow(objectEvent, sprite, DIR_SOUTH); sprite->affineAnimPaused = FALSE; StartSpriteAffineAnimIfDifferent(sprite, 0); return MovementAction_WalkDownStartAffine_Step1(objectEvent, sprite); @@ -6736,10 +6701,10 @@ bool8 MovementAction_WalkDownStartAffine_Step0(struct ObjectEvent *objectEvent, bool8 MovementAction_WalkDownStartAffine_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (an_walk_any_2(objectEvent, sprite)) + if (UpdateWalkSlow(objectEvent, sprite)) { sprite->affineAnimPaused = TRUE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6747,7 +6712,7 @@ bool8 MovementAction_WalkDownStartAffine_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_WalkDownAffine_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8093B60(objectEvent, sprite, DIR_SOUTH); + InitWalkSlow(objectEvent, sprite, DIR_SOUTH); sprite->affineAnimPaused = FALSE; ChangeSpriteAffineAnimIfDifferent(sprite, 1); return MovementAction_WalkDownAffine_Step1(objectEvent, sprite); @@ -6755,10 +6720,10 @@ bool8 MovementAction_WalkDownAffine_Step0(struct ObjectEvent *objectEvent, struc bool8 MovementAction_WalkDownAffine_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (an_walk_any_2(objectEvent, sprite)) + if (UpdateWalkSlow(objectEvent, sprite)) { sprite->affineAnimPaused = TRUE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6766,7 +6731,7 @@ bool8 MovementAction_WalkDownAffine_Step1(struct ObjectEvent *objectEvent, struc bool8 MovementAction_WalkLeftAffine_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_WEST, 1); + InitMovementNormal(objectEvent, sprite, DIR_WEST, 1); sprite->affineAnimPaused = FALSE; ChangeSpriteAffineAnimIfDifferent(sprite, 2); return MovementAction_WalkLeftAffine_Step1(objectEvent, sprite); @@ -6774,10 +6739,10 @@ bool8 MovementAction_WalkLeftAffine_Step0(struct ObjectEvent *objectEvent, struc bool8 MovementAction_WalkLeftAffine_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { sprite->affineAnimPaused = TRUE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6785,7 +6750,7 @@ bool8 MovementAction_WalkLeftAffine_Step1(struct ObjectEvent *objectEvent, struc bool8 MovementAction_WalkRightAffine_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_EAST, 1); + InitMovementNormal(objectEvent, sprite, DIR_EAST, 1); sprite->affineAnimPaused = FALSE; ChangeSpriteAffineAnimIfDifferent(sprite, 3); return MovementAction_WalkRightAffine_Step1(objectEvent, sprite); @@ -6793,45 +6758,45 @@ bool8 MovementAction_WalkRightAffine_Step0(struct ObjectEvent *objectEvent, stru bool8 MovementAction_WalkRightAffine_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { sprite->affineAnimPaused = TRUE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; } -static void sub_80958C0(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) +static void AcroWheelieFaceDirection(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) { SetObjectEventDirection(objectEvent, direction); ShiftStillObjectEventCoords(objectEvent); obj_npc_animation_step(objectEvent, sprite, GetAcroWheeliePedalDirectionAnimNum(direction)); sprite->animPaused = TRUE; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; } bool8 MovementAction_AcroWheelieFaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80958C0(objectEvent, sprite, DIR_SOUTH); + AcroWheelieFaceDirection(objectEvent, sprite, DIR_SOUTH); return TRUE; } bool8 MovementAction_AcroWheelieFaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80958C0(objectEvent, sprite, DIR_NORTH); + AcroWheelieFaceDirection(objectEvent, sprite, DIR_NORTH); return TRUE; } bool8 MovementAction_AcroWheelieFaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80958C0(objectEvent, sprite, DIR_WEST); + AcroWheelieFaceDirection(objectEvent, sprite, DIR_WEST); return TRUE; } bool8 MovementAction_AcroWheelieFaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80958C0(objectEvent, sprite, DIR_EAST); + AcroWheelieFaceDirection(objectEvent, sprite, DIR_EAST); return TRUE; } @@ -6928,7 +6893,7 @@ bool8 DoFigure8Anim(struct ObjectEvent *objectEvent, struct Sprite *sprite) bool8 MovementAction_Figure8_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { InitFigure8Anim(objectEvent, sprite); - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return MovementAction_Figure8_Step1(objectEvent, sprite); } @@ -6936,31 +6901,31 @@ bool8 MovementAction_Figure8_Step1(struct ObjectEvent *objectEvent, struct Sprit { if (DoFigure8Anim(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; } -void sub_8095B84(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed, u8 a4) +static void InitAcroWheelieJump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed, u8 type) { - sub_8093FC4(objectEvent, sprite, direction, speed, a4); + InitJump(objectEvent, sprite, direction, speed, type); StartSpriteAnimIfDifferent(sprite, GetAcroWheelieDirectionAnimNum(direction)); DoShadowFieldEffect(objectEvent); } bool8 MovementAction_AcroWheelieHopFaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_SOUTH, 0, 1); + InitAcroWheelieJump(objectEvent, sprite, DIR_SOUTH, 0, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopFaceDown_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieHopFaceDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6968,16 +6933,16 @@ bool8 MovementAction_AcroWheelieHopFaceDown_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroWheelieHopFaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_NORTH, 0, 1); + InitAcroWheelieJump(objectEvent, sprite, DIR_NORTH, 0, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopFaceUp_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieHopFaceUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -6985,16 +6950,16 @@ bool8 MovementAction_AcroWheelieHopFaceUp_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieHopFaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_WEST, 0, 1); + InitAcroWheelieJump(objectEvent, sprite, DIR_WEST, 0, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopFaceLeft_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieHopFaceLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7002,16 +6967,16 @@ bool8 MovementAction_AcroWheelieHopFaceLeft_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroWheelieHopFaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_EAST, 0, 1); + InitAcroWheelieJump(objectEvent, sprite, DIR_EAST, 0, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopFaceRight_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieHopFaceRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7019,16 +6984,16 @@ bool8 MovementAction_AcroWheelieHopFaceRight_Step1(struct ObjectEvent *objectEve bool8 MovementAction_AcroWheelieHopDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_SOUTH, 1, 1); + InitAcroWheelieJump(objectEvent, sprite, DIR_SOUTH, 1, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopDown_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieHopDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7036,16 +7001,16 @@ bool8 MovementAction_AcroWheelieHopDown_Step1(struct ObjectEvent *objectEvent, s bool8 MovementAction_AcroWheelieHopUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_NORTH, 1, 1); + InitAcroWheelieJump(objectEvent, sprite, DIR_NORTH, 1, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopUp_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieHopUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7053,16 +7018,16 @@ bool8 MovementAction_AcroWheelieHopUp_Step1(struct ObjectEvent *objectEvent, str bool8 MovementAction_AcroWheelieHopLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_WEST, 1, 1); + InitAcroWheelieJump(objectEvent, sprite, DIR_WEST, 1, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopLeft_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieHopLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7070,16 +7035,16 @@ bool8 MovementAction_AcroWheelieHopLeft_Step1(struct ObjectEvent *objectEvent, s bool8 MovementAction_AcroWheelieHopRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_EAST, 1, 1); + InitAcroWheelieJump(objectEvent, sprite, DIR_EAST, 1, JUMP_TYPE_LOW); return MovementAction_AcroWheelieHopRight_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieHopRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7087,16 +7052,16 @@ bool8 MovementAction_AcroWheelieHopRight_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieJumpDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_SOUTH, 2, 0); + InitAcroWheelieJump(objectEvent, sprite, DIR_SOUTH, 2, JUMP_TYPE_HIGH); return MovementAction_AcroWheelieJumpDown_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieJumpDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7104,16 +7069,16 @@ bool8 MovementAction_AcroWheelieJumpDown_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieJumpUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_NORTH, 2, 0); + InitAcroWheelieJump(objectEvent, sprite, DIR_NORTH, 2, JUMP_TYPE_HIGH); return MovementAction_AcroWheelieJumpUp_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieJumpUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7121,16 +7086,16 @@ bool8 MovementAction_AcroWheelieJumpUp_Step1(struct ObjectEvent *objectEvent, st bool8 MovementAction_AcroWheelieJumpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_WEST, 2, 0); + InitAcroWheelieJump(objectEvent, sprite, DIR_WEST, 2, JUMP_TYPE_HIGH); return MovementAction_AcroWheelieJumpLeft_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieJumpLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7138,16 +7103,16 @@ bool8 MovementAction_AcroWheelieJumpLeft_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieJumpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_EAST, 2, 0); + InitAcroWheelieJump(objectEvent, sprite, DIR_EAST, 2, JUMP_TYPE_HIGH); return MovementAction_AcroWheelieJumpRight_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieJumpRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (sub_80941B0(objectEvent, sprite)) + if (DoJumpAnim(objectEvent, sprite)) { objectEvent->hasShadow = FALSE; - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7155,29 +7120,29 @@ bool8 MovementAction_AcroWheelieJumpRight_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieInPlaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_SOUTH, GetAcroWheeliePedalDirectionAnimNum(DIR_SOUTH), 8); + InitMoveInPlace(objectEvent, sprite, DIR_SOUTH, GetAcroWheeliePedalDirectionAnimNum(DIR_SOUTH), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieInPlaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_NORTH, GetAcroWheeliePedalDirectionAnimNum(DIR_NORTH), 8); + InitMoveInPlace(objectEvent, sprite, DIR_NORTH, GetAcroWheeliePedalDirectionAnimNum(DIR_NORTH), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieInPlaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_WEST, GetAcroWheeliePedalDirectionAnimNum(DIR_WEST), 8); + InitMoveInPlace(objectEvent, sprite, DIR_WEST, GetAcroWheeliePedalDirectionAnimNum(DIR_WEST), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieInPlaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_EAST, GetAcroWheeliePedalDirectionAnimNum(DIR_EAST), 8); + InitMoveInPlace(objectEvent, sprite, DIR_EAST, GetAcroWheeliePedalDirectionAnimNum(DIR_EAST), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } -void sub_80960C8(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed) +static void InitAcroPopWheelie(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed) { npc_apply_direction(objectEvent, sprite, direction, speed); StartSpriteAnim(sprite, GetAcroWheelieDirectionAnimNum(objectEvent->facingDirection)); @@ -7186,15 +7151,15 @@ void sub_80960C8(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 dire bool8 MovementAction_AcroPopWheelieMoveDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80960C8(objectEvent, sprite, DIR_SOUTH, 1); + InitAcroPopWheelie(objectEvent, sprite, DIR_SOUTH, 1); return MovementAction_AcroPopWheelieMoveDown_Step1(objectEvent, sprite); } bool8 MovementAction_AcroPopWheelieMoveDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7202,15 +7167,15 @@ bool8 MovementAction_AcroPopWheelieMoveDown_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroPopWheelieMoveUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80960C8(objectEvent, sprite, DIR_NORTH, 1); + InitAcroPopWheelie(objectEvent, sprite, DIR_NORTH, 1); return MovementAction_AcroPopWheelieMoveUp_Step1(objectEvent, sprite); } bool8 MovementAction_AcroPopWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7218,15 +7183,15 @@ bool8 MovementAction_AcroPopWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroPopWheelieMoveLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80960C8(objectEvent, sprite, DIR_WEST, 1); + InitAcroPopWheelie(objectEvent, sprite, DIR_WEST, 1); return MovementAction_AcroPopWheelieMoveLeft_Step1(objectEvent, sprite); } bool8 MovementAction_AcroPopWheelieMoveLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7234,21 +7199,21 @@ bool8 MovementAction_AcroPopWheelieMoveLeft_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroPopWheelieMoveRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80960C8(objectEvent, sprite, DIR_EAST, 1); + InitAcroPopWheelie(objectEvent, sprite, DIR_EAST, 1); return MovementAction_AcroPopWheelieMoveRight_Step1(objectEvent, sprite); } bool8 MovementAction_AcroPopWheelieMoveRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; } -void sub_8096200(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed) +static void InitAcroWheelieMove(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed) { npc_apply_direction(objectEvent, sprite, direction, speed); npc_apply_anim_looping(objectEvent, sprite, GetAcroWheeliePedalDirectionAnimNum(objectEvent->facingDirection)); @@ -7256,15 +7221,15 @@ void sub_8096200(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 dire bool8 MovementAction_AcroWheelieMoveDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096200(objectEvent, sprite, DIR_SOUTH, 1); + InitAcroWheelieMove(objectEvent, sprite, DIR_SOUTH, 1); return MovementAction_AcroWheelieMoveDown_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieMoveDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7272,15 +7237,15 @@ bool8 MovementAction_AcroWheelieMoveDown_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieMoveUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096200(objectEvent, sprite, DIR_NORTH, 1); + InitAcroWheelieMove(objectEvent, sprite, DIR_NORTH, 1); return MovementAction_AcroWheelieMoveUp_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7288,15 +7253,15 @@ bool8 MovementAction_AcroWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, st bool8 MovementAction_AcroWheelieMoveLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096200(objectEvent, sprite, DIR_WEST, 1); + InitAcroWheelieMove(objectEvent, sprite, DIR_WEST, 1); return MovementAction_AcroWheelieMoveLeft_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieMoveLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7304,21 +7269,21 @@ bool8 MovementAction_AcroWheelieMoveLeft_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieMoveRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096200(objectEvent, sprite, DIR_EAST, 1); + InitAcroWheelieMove(objectEvent, sprite, DIR_EAST, 1); return MovementAction_AcroWheelieMoveRight_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieMoveRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; } -void sub_8096330(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed) +static void InitAcroEndWheelie(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed) { npc_apply_direction(objectEvent, sprite, direction, speed); StartSpriteAnim(sprite, GetAcroEndWheelieDirectionAnimNum(objectEvent->facingDirection)); @@ -7327,15 +7292,15 @@ void sub_8096330(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 dire bool8 MovementAction_AcroEndWheelieMoveDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096330(objectEvent, sprite, DIR_SOUTH, 1); + InitAcroEndWheelie(objectEvent, sprite, DIR_SOUTH, 1); return MovementAction_AcroEndWheelieMoveDown_Step1(objectEvent, sprite); } bool8 MovementAction_AcroEndWheelieMoveDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7343,15 +7308,15 @@ bool8 MovementAction_AcroEndWheelieMoveDown_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroEndWheelieMoveUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096330(objectEvent, sprite, DIR_NORTH, 1); + InitAcroEndWheelie(objectEvent, sprite, DIR_NORTH, 1); return MovementAction_AcroEndWheelieMoveUp_Step1(objectEvent, sprite); } bool8 MovementAction_AcroEndWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7359,15 +7324,15 @@ bool8 MovementAction_AcroEndWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroEndWheelieMoveLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096330(objectEvent, sprite, DIR_WEST, 1); + InitAcroEndWheelie(objectEvent, sprite, DIR_WEST, 1); return MovementAction_AcroEndWheelieMoveLeft_Step1(objectEvent, sprite); } bool8 MovementAction_AcroEndWheelieMoveLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7375,15 +7340,15 @@ bool8 MovementAction_AcroEndWheelieMoveLeft_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroEndWheelieMoveRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096330(objectEvent, sprite, DIR_EAST, 1); + InitAcroEndWheelie(objectEvent, sprite, DIR_EAST, 1); return MovementAction_AcroEndWheelieMoveRight_Step1(objectEvent, sprite); } bool8 MovementAction_AcroEndWheelieMoveRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + if (UpdateMovementNormal(objectEvent, sprite)) { - sprite->data[2] = 2; + sprite->sActionFuncId = 2; return TRUE; } return FALSE; @@ -7392,24 +7357,24 @@ bool8 MovementAction_AcroEndWheelieMoveRight_Step1(struct ObjectEvent *objectEve bool8 MovementAction_Levitate_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { CreateLevitateMovementTask(objectEvent); - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } bool8 MovementAction_StopLevitate_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - DestroyExtraMovementTask(objectEvent->warpArrowSpriteId); + DestroyLevitateMovementTask(objectEvent->warpArrowSpriteId); sprite->pos2.y = 0; - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } -bool8 MovementAction_DestroyExtraTaskIfAtTop_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 MovementAction_StopLevitateAtTop_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (sprite->pos2.y == 0) { - DestroyExtraMovementTask(objectEvent->warpArrowSpriteId); - sprite->data[2] = 1; + DestroyLevitateMovementTask(objectEvent->warpArrowSpriteId); + sprite->sActionFuncId = 1; return TRUE; } return FALSE; @@ -7446,17 +7411,18 @@ static void TryEnableObjectEventAnim(struct ObjectEvent *objectEvent, struct Spr static void UpdateObjectEventVisibility(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096530(objectEvent, sprite); - UpdateObjEventSpriteVisibility(objectEvent, sprite); + UpdateObjectEventOffscreen(objectEvent, sprite); + UpdateObjectEventSpriteVisibility(objectEvent, sprite); } -static void sub_8096530(struct ObjectEvent *objectEvent, struct Sprite *sprite) +static void UpdateObjectEventOffscreen(struct ObjectEvent *objectEvent, struct Sprite *sprite) { u16 x, y; u16 x2, y2; const struct ObjectEventGraphicsInfo *graphicsInfo; objectEvent->offScreen = FALSE; + graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); if (sprite->coordOffsetEnabled) { @@ -7472,23 +7438,19 @@ static void sub_8096530(struct ObjectEvent *objectEvent, struct Sprite *sprite) x2 += x; y2 = y; y2 += graphicsInfo->height; - if ((s16)x >= 0x100 || (s16)x2 < -0x10) - { + + if ((s16)x >= DISPLAY_WIDTH + 16 || (s16)x2 < -16) objectEvent->offScreen = TRUE; - } - if ((s16)y >= 0xB0 || (s16)y2 < -0x10) - { + + if ((s16)y >= DISPLAY_HEIGHT + 16 || (s16)y2 < -16) objectEvent->offScreen = TRUE; - } } -static void UpdateObjEventSpriteVisibility(struct ObjectEvent *objectEvent, struct Sprite *sprite) +static void UpdateObjectEventSpriteVisibility(struct ObjectEvent *objectEvent, struct Sprite *sprite) { sprite->invisible = FALSE; if (objectEvent->invisible || objectEvent->offScreen) - { sprite->invisible = TRUE; - } } static void GetAllGroundEffectFlags_OnSpawn(struct ObjectEvent *objEvent, u32 *flags) @@ -7772,30 +7734,30 @@ static u8 GetReflectionTypeByMetatileBehavior(u32 behavior) return REFL_TYPE_NONE; } -u8 GetLedgeJumpDirection(s16 x, s16 y, u8 z) +u8 GetLedgeJumpDirection(s16 x, s16 y, u8 direction) { - static bool8 (*const unknown_08376040[])(u8) = { - MetatileBehavior_IsJumpSouth, - MetatileBehavior_IsJumpNorth, - MetatileBehavior_IsJumpWest, - MetatileBehavior_IsJumpEast, + static bool8 (*const ledgeBehaviorFuncs[])(u8) = { + [DIR_SOUTH - 1] = MetatileBehavior_IsJumpSouth, + [DIR_NORTH - 1] = MetatileBehavior_IsJumpNorth, + [DIR_WEST - 1] = MetatileBehavior_IsJumpWest, + [DIR_EAST - 1] = MetatileBehavior_IsJumpEast, }; - u8 b; - u8 index = z; + u8 behavior; + u8 index = direction; - if (index == 0) - return 0; - else if (index > 4) - index -= 4; + if (index == DIR_NONE) + return DIR_NONE; + else if (index > DIR_EAST) + index -= DIR_EAST; index--; - b = MapGridGetMetatileBehaviorAt(x, y); + behavior = MapGridGetMetatileBehaviorAt(x, y); - if (unknown_08376040[index](b) == 1) + if (ledgeBehaviorFuncs[index](behavior) == TRUE) return index + 1; - return 0; + return DIR_NONE; } static void SetObjectEventSpriteOamTableForLongGrass(struct ObjectEvent *objEvent, struct Sprite *sprite) @@ -7824,7 +7786,7 @@ bool8 IsZCoordMismatchAt(u8 z, s16 x, s16 y) mapZ = MapGridGetZCoordAt(x, y); - if (mapZ == 0 || mapZ == 0xF) + if (mapZ == 0 || mapZ == 15) return FALSE; if (mapZ != z) @@ -7833,21 +7795,15 @@ bool8 IsZCoordMismatchAt(u8 z, s16 x, s16 y) return FALSE; } -static const u8 sUnknown_08376050[] = { - 0x73, 0x73, 0x53, 0x73, 0x53, 0x73, 0x53, 0x73, 0x53, 0x73, 0x53, 0x73, 0x53, 0x00, 0x00, 0x73 +static const u8 sElevationToSubpriority[] = { + 115, 115, 83, 115, 83, 115, 83, 115, 83, 115, 83, 115, 83, 0, 0, 115 }; -// Each byte corresponds to a sprite priority for an object event. -// This is directly the inverse of gObjectEventPriorities_08376070. -static const u8 sObjectEventPriorities_08376060[] = { +static const u8 sElevationToPriority[] = { 2, 2, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0, 0, 2 }; -// Each byte corresponds to a sprite priority for an object event. -// This is the inverse of gObjectEventPriorities_08376060. -// 1 = Above player sprite -// 2 = Below player sprite -static const u8 sObjectEventPriorities_08376070[] = { +static const u8 sElevationToSubspriteTableNum[] = { 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 0, 1, }; @@ -7858,19 +7814,19 @@ void UpdateObjectEventZCoordAndPriority(struct ObjectEvent *objEvent, struct Spr ObjectEventUpdateZCoord(objEvent); - sprite->subspriteTableNum = sObjectEventPriorities_08376070[objEvent->previousElevation]; - sprite->oam.priority = sObjectEventPriorities_08376060[objEvent->previousElevation]; + sprite->subspriteTableNum = sElevationToSubspriteTableNum[objEvent->previousElevation]; + sprite->oam.priority = sElevationToPriority[objEvent->previousElevation]; } static void InitObjectPriorityByZCoord(struct Sprite *sprite, u8 z) { - sprite->subspriteTableNum = sObjectEventPriorities_08376070[z]; - sprite->oam.priority = sObjectEventPriorities_08376060[z]; + sprite->subspriteTableNum = sElevationToSubspriteTableNum[z]; + sprite->oam.priority = sElevationToPriority[z]; } u8 ZCoordToPriority(u8 z) { - return sObjectEventPriorities_08376060[z]; + return sElevationToPriority[z]; } void ObjectEventUpdateZCoord(struct ObjectEvent *objEvent) @@ -7887,14 +7843,14 @@ void ObjectEventUpdateZCoord(struct ObjectEvent *objEvent) objEvent->previousElevation = z; } -void SetObjectSubpriorityByZCoord(u8 a, struct Sprite *sprite, u8 b) +void SetObjectSubpriorityByZCoord(u8 elevation, struct Sprite *sprite, u8 subpriority) { s32 tmp = sprite->centerToCornerVecY; u32 tmpa = *(u16 *)&sprite->pos1.y; u32 tmpb = *(u16 *)&gSpriteCoordOffsetY; s32 tmp2 = (tmpa - tmp) + tmpb; - u16 tmp3 = (0x10 - ((((u32)tmp2 + 8) & 0xFF) >> 4)) * 2; - sprite->subpriority = tmp3 + sUnknown_08376050[a] + b; + u16 tmp3 = (16 - ((((u32)tmp2 + 8) & 0xFF) >> 4)) * 2; + sprite->subpriority = tmp3 + sElevationToSubpriority[elevation] + subpriority; } static void ObjectEventUpdateSubpriority(struct ObjectEvent *objEvent, struct Sprite *sprite) @@ -8412,29 +8368,37 @@ bool8 obj_npc_ministep(struct Sprite *sprite) return TRUE; } -void sub_80976DC(struct Sprite *sprite, u8 direction) +#define sDirection data[3] +#define sTimer data[4] +#define sNumSteps data[5] + +static void SetWalkSlowSpriteData(struct Sprite *sprite, u8 direction) { - sprite->data[3] = direction; - sprite->data[4] = 0; - sprite->data[5] = 0; + sprite->sDirection = direction; + sprite->sTimer = 0; + sprite->sNumSteps = 0; } -bool8 sub_80976EC(struct Sprite *sprite) +static bool8 UpdateWalkSlowAnim(struct Sprite *sprite) { - if (!(sprite->data[4] & 1)) + if (!(sprite->sTimer & 1)) { - Step1(sprite, sprite->data[3]); - sprite->data[5]++; + Step1(sprite, sprite->sDirection); + sprite->sNumSteps++; } - sprite->data[4]++; + sprite->sTimer++; - if (sprite->data[5] > 15) + if (sprite->sNumSteps > 15) return TRUE; else return FALSE; } +#undef sDirection +#undef sTimer +#undef sNumSteps + static const s8 sFigure8XOffsets[FIGURE_8_LENGTH] = { 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, @@ -8512,87 +8476,100 @@ static bool8 AnimateSpriteInFigure8(struct Sprite *sprite) return finished; } -static const s8 gUnknown_0850E802[] = { - -4, -6, -8, -10, -11, -12, -12, -12, -11, -10, -9, -8, -6, -4, 0, 0 +static const s8 sJumpY_High[] = { + -4, -6, -8, -10, -11, -12, -12, -12, + -11, -10, -9, -8, -6, -4, 0, 0 }; -static const s8 gUnknown_0850E812[] = { - 0, -2, -3, -4, -5, -6, -6, -6, -5, -5, -4, -3, -2, 0, 0, 0 +static const s8 sJumpY_Low[] = { + 0, -2, -3, -4, -5, -6, -6, -6, + -5, -5, -4, -3, -2, 0, 0, 0 }; -static const s8 gUnknown_0850E822[] = { - -2, -4, -6, -8, -9, -10, -10, -10, -9, -8, -6, -5, -3, -2, 0, 0 +static const s8 sJumpY_Normal[] = { + -2, -4, -6, -8, -9, -10, -10, -10, + -9, -8, -6, -5, -3, -2, 0, 0 }; -static const s8 *const gUnknown_0850E834[] = { - gUnknown_0850E802, - gUnknown_0850E812, - gUnknown_0850E822 +static const s8 *const sJumpYTable[] = { + [JUMP_TYPE_HIGH] = sJumpY_High, + [JUMP_TYPE_LOW] = sJumpY_Low, + [JUMP_TYPE_NORMAL] = sJumpY_Normal }; -s16 sub_8097820(s16 a1, u8 a2) +static s16 GetJumpY(s16 i, u8 type) { - return gUnknown_0850E834[a2][a1]; + return sJumpYTable[type][i]; } -void sub_809783C(struct Sprite *sprite, u8 a2, u8 a3, u8 a4) +#define sDirection data[3] +#define sSpeed data[4] +#define sJumpType data[5] +#define sTimer data[6] + +static void SetJumpSpriteData(struct Sprite *sprite, u8 direction, u8 speed, u8 type) { - sprite->data[3] = a2; - sprite->data[4] = a3; - sprite->data[5] = a4; - sprite->data[6] = 0; + sprite->sDirection = direction; + sprite->sSpeed = speed; + sprite->sJumpType = type; + sprite->sTimer = 0; } -u8 sub_809785C(struct Sprite *sprite) +static u8 DoJumpSpriteMovement(struct Sprite *sprite) { - s16 v5[] = {16, 16, 32}; - u8 v6[] = {0, 0, 1}; - u8 v2 = 0; + s16 speedToTime[] = {16, 16, 32}; + u8 speedToShift[] = {0, 0, 1}; + u8 result = 0; - if (sprite->data[4]) - Step1(sprite, sprite->data[3]); + if (sprite->sSpeed) + Step1(sprite, sprite->sDirection); - sprite->pos2.y = sub_8097820(sprite->data[6] >> v6[sprite->data[4]], sprite->data[5]); + sprite->pos2.y = GetJumpY(sprite->sTimer >> speedToShift[sprite->sSpeed], sprite->sJumpType); - sprite->data[6]++; + sprite->sTimer++; - if (sprite->data[6] == (v5[sprite->data[4]] >> 1)) - v2 = 1; + if (sprite->sTimer == speedToTime[sprite->sSpeed] >> 1) + result = JUMP_HALFWAY; - if (sprite->data[6] >= v5[sprite->data[4]]) + if (sprite->sTimer >= speedToTime[sprite->sSpeed]) { sprite->pos2.y = 0; - v2 = -1; + result = JUMP_FINISHED; } - return v2; + return result; } -u8 sub_80978E4(struct Sprite *sprite) +static u8 DoJumpSpecialSpriteMovement(struct Sprite *sprite) { - s16 v5[] = {32, 32, 64}; - u8 v6[] = {1, 1, 2}; - u8 v2 = 0; + s16 speedToTime[] = {32, 32, 64}; + u8 speedToShift[] = {1, 1, 2}; + u8 result = 0; - if (sprite->data[4] && !(sprite->data[6] & 1)) - Step1(sprite, sprite->data[3]); + if (sprite->sSpeed && !(sprite->sTimer & 1)) + Step1(sprite, sprite->sDirection); - sprite->pos2.y = sub_8097820(sprite->data[6] >> v6[sprite->data[4]], sprite->data[5]); + sprite->pos2.y = GetJumpY(sprite->sTimer >> speedToShift[sprite->sSpeed], sprite->sJumpType); - sprite->data[6]++; + sprite->sTimer++; - if (sprite->data[6] == (v5[sprite->data[4]] >> 1)) - v2 = 1; + if (sprite->sTimer == speedToTime[sprite->sSpeed] >> 1) + result = JUMP_HALFWAY; - if (sprite->data[6] >= v5[sprite->data[4]]) + if (sprite->sTimer >= speedToTime[sprite->sSpeed]) { sprite->pos2.y = 0; - v2 = -1; + result = JUMP_FINISHED; } - return v2; + return result; } +#undef sDirection +#undef sSpeed +#undef sJumpType +#undef sTimer + static void SetMovementDelay(struct Sprite *sprite, s16 timer) { sprite->data[3] = timer; @@ -8600,9 +8577,7 @@ static void SetMovementDelay(struct Sprite *sprite, s16 timer) static bool8 WaitForMovementDelay(struct Sprite *sprite) { - sprite->data[3]--; - - if (sprite->data[3] == 0) + if (--sprite->data[3] == 0) return TRUE; else return FALSE; @@ -8650,15 +8625,15 @@ void UpdateObjectEventSpriteInvisibility(struct Sprite *sprite, bool8 invisible) sprite->invisible = TRUE; } -#define tInvisible data[2] -#define tAnimNum data[3] -#define tAnimState data[4] +#define sInvisible data[2] +#define sAnimNum data[3] +#define sAnimState data[4] static void UpdateObjectEventSprite(struct Sprite *sprite) { UpdateObjectEventSpritePosition(sprite); SetObjectSubpriorityByZCoord(sprite->data[1], sprite, 1); - UpdateObjectEventSpriteInvisibility(sprite, sprite->tInvisible); + UpdateObjectEventSpriteInvisibility(sprite, sprite->sInvisible); } // Unused @@ -8681,7 +8656,7 @@ static int GetObjectEventSpriteId(u8 objectEventId) // this should return a u8, for (i = 0; i < MAX_SPRITES; i++) { struct Sprite *sprite = &gSprites[i]; - if (sprite->inUse && sprite->callback == UpdateObjectEventSprite && (u8)sprite->data[0] == objectEventId) + if (sprite->inUse && sprite->callback == UpdateObjectEventSprite && (u8)sprite->sObjEventId == objectEventId) return i; } return MAX_SPRITES; @@ -8733,9 +8708,9 @@ void SetObjectEventSpriteInvisibility(u8 objectEventId, bool32 invisible) return; if (invisible) - gSprites[spriteId].tInvisible = TRUE; + gSprites[spriteId].sInvisible = TRUE; else - gSprites[spriteId].tInvisible = FALSE; + gSprites[spriteId].sInvisible = FALSE; } bool32 IsObjectEventSpriteInvisible(u8 objectEventId) @@ -8745,7 +8720,7 @@ bool32 IsObjectEventSpriteInvisible(u8 objectEventId) if (spriteId == MAX_SPRITES) return FALSE; - return (gSprites[spriteId].tInvisible == TRUE); + return (gSprites[spriteId].sInvisible == TRUE); } void SetObjectEventSpriteAnim(u8 objectEventId, u8 animNum) @@ -8754,50 +8729,50 @@ void SetObjectEventSpriteAnim(u8 objectEventId, u8 animNum) if (spriteId != MAX_SPRITES) { - gSprites[spriteId].tAnimNum = animNum; - gSprites[spriteId].tAnimState = 0; + gSprites[spriteId].sAnimNum = animNum; + gSprites[spriteId].sAnimState = 0; } } static void MoveUnionRoomObjectUp(struct Sprite *sprite) { - switch(sprite->tAnimState) + switch(sprite->sAnimState) { case 0: sprite->pos2.y = 0; - sprite->tAnimState++; + sprite->sAnimState++; case 1: sprite->pos2.y -= 8; - if (sprite->pos2.y == -160) + if (sprite->pos2.y == -DISPLAY_HEIGHT) { sprite->pos2.y = 0; - sprite->tInvisible = TRUE; - sprite->tAnimNum = 0; - sprite->tAnimState = 0; + sprite->sInvisible = TRUE; + sprite->sAnimNum = 0; + sprite->sAnimState = 0; } } } static void MoveUnionRoomObjectDown(struct Sprite *sprite) { - switch(sprite->tAnimState) + switch(sprite->sAnimState) { case 0: - sprite->pos2.y = -160; - sprite->tAnimState++; + sprite->pos2.y = -DISPLAY_HEIGHT; + sprite->sAnimState++; case 1: sprite->pos2.y += 8; if(sprite->pos2.y == 0) { - sprite->tAnimNum = 0; - sprite->tAnimState = 0; + sprite->sAnimNum = 0; + sprite->sAnimState = 0; } } } static void UpdateObjectEventSpritePosition(struct Sprite *sprite) { - switch(sprite->tAnimNum) + switch(sprite->sAnimNum) { case UNION_ROOM_SPAWN_IN: MoveUnionRoomObjectDown(sprite); @@ -8808,7 +8783,7 @@ static void UpdateObjectEventSpritePosition(struct Sprite *sprite) case 0: break; default: - sprite->tAnimNum = 0; + sprite->sAnimNum = 0; break; } } @@ -8820,7 +8795,7 @@ bool32 IsObjectEventSpriteAnimating(u8 objectEventId) if (spriteId == MAX_SPRITES) return FALSE; - if (gSprites[spriteId].tAnimNum != 0) + if (gSprites[spriteId].sAnimNum != 0) return TRUE; return FALSE; @@ -8832,11 +8807,11 @@ u32 StartFieldEffectForObjectEvent(u8 fieldEffectId, struct ObjectEvent *objectE return FieldEffectStart(fieldEffectId); } -void DoShadowFieldEffect(struct ObjectEvent *objectEvent) +static void DoShadowFieldEffect(struct ObjectEvent *objectEvent) { if (!objectEvent->hasShadow) { - objectEvent->hasShadow = 1; + objectEvent->hasShadow = TRUE; StartFieldEffectForObjectEvent(FLDEFF_SHADOW, objectEvent); } } @@ -8876,11 +8851,11 @@ u8 (*const gMovementActionFuncs_FlyDown[])(struct ObjectEvent *, struct Sprite * u8 MovementAction_StoreAndLockAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { bool32 ableToStore = FALSE; - if (gLockedAnimObjectEvents == NULL) + if (sLockedAnimObjectEvents == NULL) { - gLockedAnimObjectEvents = AllocZeroed(sizeof(struct LockedAnimObjectEvents)); - gLockedAnimObjectEvents->objectEventIds[0] = objectEvent->localId; - gLockedAnimObjectEvents->count = 1; + sLockedAnimObjectEvents = AllocZeroed(sizeof(struct LockedAnimObjectEvents)); + sLockedAnimObjectEvents->objectEventIds[0] = objectEvent->localId; + sLockedAnimObjectEvents->count = 1; ableToStore = TRUE; } else @@ -8890,10 +8865,10 @@ u8 MovementAction_StoreAndLockAnim_Step0(struct ObjectEvent *objectEvent, struct bool32 found; for (firstFreeSlot = 16, found = FALSE, i = 0; i < 16; i++) { - if (firstFreeSlot == 16 && gLockedAnimObjectEvents->objectEventIds[i] == 0) + if (firstFreeSlot == 16 && sLockedAnimObjectEvents->objectEventIds[i] == 0) firstFreeSlot = i; - if (gLockedAnimObjectEvents->objectEventIds[i] == objectEvent->localId) + if (sLockedAnimObjectEvents->objectEventIds[i] == objectEvent->localId) { found = TRUE; break; @@ -8902,8 +8877,8 @@ u8 MovementAction_StoreAndLockAnim_Step0(struct ObjectEvent *objectEvent, struct if (!found && firstFreeSlot != 16) { - gLockedAnimObjectEvents->objectEventIds[firstFreeSlot] = objectEvent->localId; - gLockedAnimObjectEvents->count++; + sLockedAnimObjectEvents->objectEventIds[firstFreeSlot] = objectEvent->localId; + sLockedAnimObjectEvents->count++; ableToStore = TRUE; } } @@ -8914,7 +8889,7 @@ u8 MovementAction_StoreAndLockAnim_Step0(struct ObjectEvent *objectEvent, struct objectEvent->facingDirectionLocked = TRUE; } - sprite->data[2] = 1; + sprite->sActionFuncId = 1; return TRUE; } @@ -8923,19 +8898,19 @@ u8 MovementAction_FreeAndUnlockAnim_Step0(struct ObjectEvent *objectEvent, struc bool32 ableToStore; u8 index; - sprite->data[2] = 1; - if (gLockedAnimObjectEvents != NULL) + sprite->sActionFuncId = 1; + if (sLockedAnimObjectEvents != NULL) { ableToStore = FALSE; index = FindLockedObjectEventIndex(objectEvent); if (index != 16) { - gLockedAnimObjectEvents->objectEventIds[index] = 0; - gLockedAnimObjectEvents->count--; + sLockedAnimObjectEvents->objectEventIds[index] = 0; + sLockedAnimObjectEvents->count--; ableToStore = TRUE; } - if (gLockedAnimObjectEvents->count == 0) - FREE_AND_SET_NULL(gLockedAnimObjectEvents); + if (sLockedAnimObjectEvents->count == 0) + FREE_AND_SET_NULL(sLockedAnimObjectEvents); if (ableToStore == TRUE) { objectEvent->inanimate = GetObjectEventGraphicsInfo(objectEvent->graphicsId)->inanimate; @@ -8953,13 +8928,13 @@ u8 FindLockedObjectEventIndex(struct ObjectEvent *objectEvent) for (i = 0; i < OBJECT_EVENTS_COUNT; i++) { - if (gLockedAnimObjectEvents->objectEventIds[i] == objectEvent->localId) + if (sLockedAnimObjectEvents->objectEventIds[i] == objectEvent->localId) return i; } return OBJECT_EVENTS_COUNT; } -void CreateLevitateMovementTask(struct ObjectEvent *objectEvent) +static void CreateLevitateMovementTask(struct ObjectEvent *objectEvent) { u8 taskId = CreateTask(ApplyLevitateMovement, 0xFF); struct Task *task = &gTasks[taskId]; @@ -8978,16 +8953,16 @@ static void ApplyLevitateMovement(u8 taskId) LoadWordFromTwoHalfwords(&task->data[0], (u32 *)&objectEvent); // load the map object pointer. sprite = &gSprites[objectEvent->spriteId]; - if(!(task->data[2] & 0x3)) + if(!(task->data[2] & 3)) sprite->pos2.y += task->data[3]; - if(!(task->data[2] & 0xF)) + if(!(task->data[2] & 15)) task->data[3] = -task->data[3]; task->data[2]++; } -void DestroyExtraMovementTask(u8 taskId) +static void DestroyLevitateMovementTask(u8 taskId) { struct ObjectEvent *objectEvent; struct Task *task = &gTasks[taskId]; @@ -9012,7 +8987,7 @@ void FreezeObjectEventsExceptTwo(u8 objectEventId1, u8 objectEventId2) u8 MovementAction_FlyUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { sprite->pos2.y = 0; - sprite->data[2]++; + sprite->sActionFuncId++; return FALSE; } @@ -9020,15 +8995,15 @@ u8 MovementAction_FlyUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sp { sprite->pos2.y -= 8; - if(sprite->pos2.y == -160) - sprite->data[2]++; + if(sprite->pos2.y == -DISPLAY_HEIGHT) + sprite->sActionFuncId++; return FALSE; } u8 MovementAction_FlyDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sprite->pos2.y = -160; - sprite->data[2]++; + sprite->pos2.y = -DISPLAY_HEIGHT; + sprite->sActionFuncId++; return FALSE; } @@ -9037,7 +9012,7 @@ u8 MovementAction_FlyDown_Step1(struct ObjectEvent *objectEvent, struct Sprite * sprite->pos2.y += 8; if(!sprite->pos2.y) - sprite->data[2]++; + sprite->sActionFuncId++; return FALSE; } diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index 49116b5d3..30eeaadfa 100755 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -1678,18 +1678,27 @@ static void UpdateGrassFieldEffectSubpriority(struct Sprite *sprite, u8 z, u8 of } } -// Unused data. Feel free to remove. -static const u8 sUnusedData[] = -{ - 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, - 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 1, 2, - 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, - 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, - 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, - 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -1, 0, 0, -1, 0, 0, -1, 0, -1, -1, 0, -1, - -1, 0, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0 +// Unused, duplicates of data in event_object_movement.c +static const s8 sFigure8XOffsets[FIGURE_8_LENGTH] = { + 1, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 1, 2, 2, 1, 2, + 2, 1, 2, 2, 1, 2, 1, 1, + 2, 1, 1, 2, 1, 1, 2, 1, + 1, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 0, 1, 1, 0, + 1, 0, 1, 0, 1, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, +}; + +static const s8 sFigure8YOffsets[FIGURE_8_LENGTH] = { + 0, 0, 1, 0, 0, 1, 0, 0, + 1, 0, 1, 1, 0, 1, 1, 0, + 1, 1, 0, 1, 1, 0, 1, 1, + 0, 0, 1, 0, 0, 1, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -1, 0, 0, -1, 0, 0, + -1, 0, -1, -1, 0, -1, -1, 0, + -1, -1, -1, -1, -1, -1, -1, -2, }; diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 94325bf34..9b1f4ceb6 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -722,9 +722,9 @@ static bool8 CanStopSurfing(s16 x, s16 y, u8 direction) } } -static bool8 ShouldJumpLedge(s16 x, s16 y, u8 z) +static bool8 ShouldJumpLedge(s16 x, s16 y, u8 direction) { - if (GetLedgeJumpDirection(x, y, z) != 0) + if (GetLedgeJumpDirection(x, y, direction) != DIR_NONE) return TRUE; else return FALSE; @@ -1192,7 +1192,7 @@ u8 GetPlayerAvatarFlags(void) return gPlayerAvatar.flags; } -u8 GetPlayerAvatarObjectId(void) +u8 GetPlayerAvatarSpriteId(void) { return gPlayerAvatar.spriteId; } diff --git a/src/field_specials.c b/src/field_specials.c index 30503ed8d..df16583ed 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1301,12 +1301,12 @@ void SpawnCameraObject(void) { u8 obj = SpawnSpecialObjectEventParameterized(OBJ_EVENT_GFX_BOY_1, MOVEMENT_TYPE_FACE_DOWN, OBJ_EVENT_ID_CAMERA, gSaveBlock1Ptr->pos.x + 7, gSaveBlock1Ptr->pos.y + 7, 3); gObjectEvents[obj].invisible = TRUE; - CameraObjectSetFollowedObjectId(gObjectEvents[obj].spriteId); + CameraObjectSetFollowedSpriteId(gObjectEvents[obj].spriteId); } void RemoveCameraObject(void) { - CameraObjectSetFollowedObjectId(GetPlayerAvatarObjectId()); + CameraObjectSetFollowedSpriteId(GetPlayerAvatarSpriteId()); RemoveObjectEventByLocalIdAndMap(OBJ_EVENT_ID_CAMERA, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); } diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c index 446633a53..044e25a8f 100644 --- a/src/fldeff_cut.c +++ b/src/fldeff_cut.c @@ -326,7 +326,7 @@ bool8 FldEff_CutGrass(void) y = yAdd + gPlayerFacingPosition.y; SetCutGrassMetatile(x, y); - sub_808E75C(x, y); + AllowObjectAtPosTriggerGroundEffects(x, y); } } diff --git a/src/fldeff_misc.c b/src/fldeff_misc.c index b320f3eb0..914ba2880 100644 --- a/src/fldeff_misc.c +++ b/src/fldeff_misc.c @@ -1298,7 +1298,7 @@ u8 CreateRecordMixingLights(void) else { struct Sprite *sprite = &gSprites[spriteId]; - sub_8092FF0(16, 13, &sprite->pos1.x, &sprite->pos1.y); + GetMapCoordsFromSpritePos(16, 13, &sprite->pos1.x, &sprite->pos1.y); sprite->coordOffsetEnabled = TRUE; sprite->pos1.x += 16; sprite->pos1.y += 2; diff --git a/src/fldeff_sweetscent.c b/src/fldeff_sweetscent.c index 55463440c..e34d19504 100644 --- a/src/fldeff_sweetscent.c +++ b/src/fldeff_sweetscent.c @@ -54,7 +54,7 @@ static void StartSweetScentFieldEffect(void) PlaySE(SE_M_SWEET_SCENT); CpuFastSet(gPlttBufferUnfaded, gPaletteDecompressionBuffer, 0x100); CpuFastSet(gPlttBufferFaded, gPlttBufferUnfaded, 0x100); - BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 0, 8, RGB_RED); + BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarSpriteId()].oam.paletteNum + 16)), 4, 0, 8, RGB_RED); taskId = CreateTask(TrySweetScentEncounter, 0); gTasks[taskId].data[0] = 0; FieldEffectActiveListRemove(FLDEFF_SWEET_SCENT); @@ -76,7 +76,7 @@ static void TrySweetScentEncounter(u8 taskId) else { gTasks[taskId].func = FailSweetScentEncounter; - BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarObjectId()].oam.paletteNum + 16)), 4, 8, 0, RGB_RED); + BeginNormalPaletteFade(~(1 << (gSprites[GetPlayerAvatarSpriteId()].oam.paletteNum + 16)), 4, 8, 0, RGB_RED); TryStartMirageTowerPulseBlendEffect(); } } diff --git a/src/overworld.c b/src/overworld.c index 3dda9b665..f2ed5952c 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -111,7 +111,7 @@ static void SpawnLinkPlayers(void); static void SetCameraToTrackGuestPlayer(void); static void ResumeMap(bool32 arg0); static void SetCameraToTrackPlayer(void); -static void sub_8086A68(void); +static void InitObjectEventsReturnToField(void); static void InitViewGraphics(void); static void SetCameraToTrackGuestPlayer_2(void); static void CreateLinkPlayerSprites(void); @@ -1946,7 +1946,7 @@ static bool32 ReturnToFieldLocal(u8 *state) ResetMirageTowerAndSaveBlockPtrs(); sub_80867D8(); ResumeMap(FALSE); - sub_8086A68(); + InitObjectEventsReturnToField(); SetCameraToTrackPlayer(); (*state)++; break; @@ -1982,7 +1982,7 @@ static bool32 ReturnToFieldLink(u8 *state) break; case 2: CreateLinkPlayerSprites(); - sub_8086A68(); + InitObjectEventsReturnToField(); SetCameraToTrackGuestPlayer_2(); (*state)++; break; @@ -2157,9 +2157,9 @@ static void InitObjectEventsLocal(void) TryRunOnWarpIntoMapScript(); } -static void sub_8086A68(void) +static void InitObjectEventsReturnToField(void) { - sub_808E16C(0, 0); + SpawnObjectEventsOnReturnToField(0, 0); RotatingGate_InitPuzzleAndGraphics(); RunOnReturnToFieldMapScript(); } diff --git a/src/rotating_gate.c b/src/rotating_gate.c index 162eb3e6d..22a0b0bdf 100644 --- a/src/rotating_gate.c +++ b/src/rotating_gate.c @@ -754,7 +754,7 @@ static u8 RotatingGate_CreateGate(u8 gateId, s16 deltaX, s16 deltaY) sprite->data[0] = gateId; sprite->coordOffsetEnabled = 1; - sub_8092FF0(x + deltaX, y + deltaY, &sprite->pos1.x, &sprite->pos1.y); + GetMapCoordsFromSpritePos(x + deltaX, y + deltaY, &sprite->pos1.x, &sprite->pos1.y); RotatingGate_HideGatesOutsideViewport(sprite); StartSpriteAffineAnim(sprite, RotatingGate_GetGateOrientation(gateId));