Document some event object movement

This commit is contained in:
GriffinR 2021-04-06 05:05:33 -04:00
parent 802d2b2f0f
commit 756fad0e61
13 changed files with 921 additions and 944 deletions

View File

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

View File

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

View File

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

View File

@ -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,
};

File diff suppressed because it is too large Load Diff

View File

@ -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,
};

View File

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

View File

@ -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);
}

View File

@ -326,7 +326,7 @@ bool8 FldEff_CutGrass(void)
y = yAdd + gPlayerFacingPosition.y;
SetCutGrassMetatile(x, y);
sub_808E75C(x, y);
AllowObjectAtPosTriggerGroundEffects(x, y);
}
}

View File

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

View File

@ -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();
}
}

View File

@ -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();
}

View File

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