Merge pull request #1737 from GriffinRichards/lock-unlock

Clean up lock/unlock anim movement
This commit is contained in:
GriffinR 2022-08-22 01:30:33 -04:00 committed by GitHub
commit 898ec580ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 37 deletions

View File

@ -152,8 +152,8 @@
create_movement_action walk_slow_diag_northeast, MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_UP_RIGHT
create_movement_action walk_slow_diag_southwest, MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_LEFT
create_movement_action walk_slow_diag_southeast, MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_RIGHT
create_movement_action store_lock_anim, MOVEMENT_ACTION_STORE_AND_LOCK_ANIM
create_movement_action free_unlock_anim, MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM
create_movement_action lock_anim, MOVEMENT_ACTION_LOCK_ANIM
create_movement_action unlock_anim, MOVEMENT_ACTION_UNLOCK_ANIM
create_movement_action walk_left_affine, MOVEMENT_ACTION_WALK_LEFT_AFFINE
create_movement_action walk_right_affine, MOVEMENT_ACTION_WALK_RIGHT_AFFINE
create_movement_action levitate, MOVEMENT_ACTION_LEVITATE

View File

@ -144,7 +144,7 @@ Route111_EventScript_RootFossilDisappeared::
@ Unused
Route111_Movement_PlayerFall::
store_lock_anim
lock_anim
walk_fast_down
walk_fast_down
walk_fast_down

View File

@ -232,8 +232,8 @@
#define MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_UP_RIGHT 0x91
#define MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_LEFT 0x92
#define MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_RIGHT 0x93
#define MOVEMENT_ACTION_STORE_AND_LOCK_ANIM 0x94
#define MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM 0x95
#define MOVEMENT_ACTION_LOCK_ANIM 0x94
#define MOVEMENT_ACTION_UNLOCK_ANIM 0x95
#define MOVEMENT_ACTION_WALK_LEFT_AFFINE 0x96
#define MOVEMENT_ACTION_WALK_RIGHT_AFFINE 0x97
#define MOVEMENT_ACTION_LEVITATE 0x98

View File

@ -63,7 +63,7 @@ struct PairedPalettes
struct LockedAnimObjectEvents
{
u8 objectEventIds[OBJECT_EVENTS_COUNT];
u8 localIds[OBJECT_EVENTS_COUNT];
u8 count;
};

View File

@ -253,9 +253,9 @@ u8 MovementAction_AcroEndWheelieMoveRight_Step1(struct ObjectEvent *, struct Spr
u8 MovementAction_Levitate_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementAction_StopLevitate_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementAction_StopLevitateAtTop_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementAction_StoreAndLockAnim_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementAction_LockAnim_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementAction_Finish(struct ObjectEvent *, struct Sprite *);
u8 MovementAction_FreeAndUnlockAnim_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementAction_UnlockAnim_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementAction_FlyUp_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementAction_FlyUp_Step1(struct ObjectEvent *, struct Sprite *);
u8 MovementAction_Fly_Finish(struct ObjectEvent *, struct Sprite *);
@ -410,8 +410,8 @@ u8 (*const gMovementActionFuncs_WalkSlowDiagonalUpLeft[])(struct ObjectEvent *,
u8 (*const gMovementActionFuncs_WalkSlowDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *);
u8 (*const gMovementActionFuncs_WalkSlowDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *);
u8 (*const gMovementActionFuncs_WalkSlowDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *);
u8 (*const gMovementActionFuncs_StoreAndLockAnim[])(struct ObjectEvent *, struct Sprite *);
u8 (*const gMovementActionFuncs_FreeAndUnlockAnim[])(struct ObjectEvent *, struct Sprite *);
u8 (*const gMovementActionFuncs_LockAnim[])(struct ObjectEvent *, struct Sprite *);
u8 (*const gMovementActionFuncs_UnlockAnim[])(struct ObjectEvent *, struct Sprite *);
u8 (*const gMovementActionFuncs_WalkLeftAffine[])(struct ObjectEvent *, struct Sprite *);
u8 (*const gMovementActionFuncs_WalkRightAffine[])(struct ObjectEvent *, struct Sprite *);
u8 (*const gMovementActionFuncs_Levitate[])(struct ObjectEvent *, struct Sprite *);
@ -570,8 +570,8 @@ u8 (*const *const gMovementActionFuncs[])(struct ObjectEvent *, struct Sprite *)
[MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_UP_RIGHT] = gMovementActionFuncs_WalkSlowDiagonalUpRight,
[MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_LEFT] = gMovementActionFuncs_WalkSlowDiagonalDownLeft,
[MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_RIGHT] = gMovementActionFuncs_WalkSlowDiagonalDownRight,
[MOVEMENT_ACTION_STORE_AND_LOCK_ANIM] = gMovementActionFuncs_StoreAndLockAnim,
[MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM] = gMovementActionFuncs_FreeAndUnlockAnim,
[MOVEMENT_ACTION_LOCK_ANIM] = gMovementActionFuncs_LockAnim,
[MOVEMENT_ACTION_UNLOCK_ANIM] = gMovementActionFuncs_UnlockAnim,
[MOVEMENT_ACTION_WALK_LEFT_AFFINE] = gMovementActionFuncs_WalkLeftAffine,
[MOVEMENT_ACTION_WALK_RIGHT_AFFINE] = gMovementActionFuncs_WalkRightAffine,
[MOVEMENT_ACTION_LEVITATE] = gMovementActionFuncs_Levitate,

View File

@ -8746,13 +8746,13 @@ static void DoRippleFieldEffect(struct ObjectEvent *objectEvent, struct Sprite *
FieldEffectStart(FLDEFF_RIPPLE);
}
u8 (*const gMovementActionFuncs_StoreAndLockAnim[])(struct ObjectEvent *, struct Sprite *) = {
MovementAction_StoreAndLockAnim_Step0,
u8 (*const gMovementActionFuncs_LockAnim[])(struct ObjectEvent *, struct Sprite *) = {
MovementAction_LockAnim_Step0,
MovementAction_Finish,
};
u8 (*const gMovementActionFuncs_FreeAndUnlockAnim[])(struct ObjectEvent *, struct Sprite *) = {
MovementAction_FreeAndUnlockAnim_Step0,
u8 (*const gMovementActionFuncs_UnlockAnim[])(struct ObjectEvent *, struct Sprite *) = {
MovementAction_UnlockAnim_Step0,
MovementAction_Finish,
};
@ -8768,36 +8768,36 @@ u8 (*const gMovementActionFuncs_FlyDown[])(struct ObjectEvent *, struct Sprite *
MovementAction_Fly_Finish,
};
u8 MovementAction_StoreAndLockAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
u8 MovementAction_LockAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
{
bool32 ableToStore = FALSE;
if (sLockedAnimObjectEvents == NULL)
{
sLockedAnimObjectEvents = AllocZeroed(sizeof(struct LockedAnimObjectEvents));
sLockedAnimObjectEvents->objectEventIds[0] = objectEvent->localId;
sLockedAnimObjectEvents->localIds[0] = objectEvent->localId;
sLockedAnimObjectEvents->count = 1;
ableToStore = TRUE;
}
else
{
u8 i;
u8 firstFreeSlot;
bool32 found;
for (firstFreeSlot = 16, found = FALSE, i = 0; i < 16; i++)
u8 firstFreeSlot = OBJECT_EVENTS_COUNT;
bool32 found = FALSE;
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
{
if (firstFreeSlot == 16 && sLockedAnimObjectEvents->objectEventIds[i] == 0)
if (firstFreeSlot == OBJECT_EVENTS_COUNT && sLockedAnimObjectEvents->localIds[i] == 0)
firstFreeSlot = i;
if (sLockedAnimObjectEvents->objectEventIds[i] == objectEvent->localId)
if (sLockedAnimObjectEvents->localIds[i] == objectEvent->localId)
{
found = TRUE;
break;
}
}
if (!found && firstFreeSlot != 16)
if (!found && firstFreeSlot != OBJECT_EVENTS_COUNT)
{
sLockedAnimObjectEvents->objectEventIds[firstFreeSlot] = objectEvent->localId;
sLockedAnimObjectEvents->localIds[firstFreeSlot] = objectEvent->localId;
sLockedAnimObjectEvents->count++;
ableToStore = TRUE;
}
@ -8813,7 +8813,7 @@ u8 MovementAction_StoreAndLockAnim_Step0(struct ObjectEvent *objectEvent, struct
return TRUE;
}
u8 MovementAction_FreeAndUnlockAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
u8 MovementAction_UnlockAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
{
bool32 ableToStore;
u8 index;
@ -8823,9 +8823,9 @@ u8 MovementAction_FreeAndUnlockAnim_Step0(struct ObjectEvent *objectEvent, struc
{
ableToStore = FALSE;
index = FindLockedObjectEventIndex(objectEvent);
if (index != 16)
if (index != OBJECT_EVENTS_COUNT)
{
sLockedAnimObjectEvents->objectEventIds[index] = 0;
sLockedAnimObjectEvents->localIds[index] = 0;
sLockedAnimObjectEvents->count--;
ableToStore = TRUE;
}
@ -8848,7 +8848,7 @@ u8 FindLockedObjectEventIndex(struct ObjectEvent *objectEvent)
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
{
if (sLockedAnimObjectEvents->objectEventIds[i] == objectEvent->localId)
if (sLockedAnimObjectEvents->localIds[i] == objectEvent->localId)
return i;
}
return OBJECT_EVENTS_COUNT;

View File

@ -27,33 +27,33 @@ struct RotatingTilePuzzle
static const u8 sMovement_ShiftRight[] =
{
MOVEMENT_ACTION_STORE_AND_LOCK_ANIM,
MOVEMENT_ACTION_LOCK_ANIM,
MOVEMENT_ACTION_WALK_NORMAL_RIGHT,
MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM,
MOVEMENT_ACTION_UNLOCK_ANIM,
MOVEMENT_ACTION_STEP_END
};
static const u8 sMovement_ShiftDown[] =
{
MOVEMENT_ACTION_STORE_AND_LOCK_ANIM,
MOVEMENT_ACTION_LOCK_ANIM,
MOVEMENT_ACTION_WALK_NORMAL_DOWN,
MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM,
MOVEMENT_ACTION_UNLOCK_ANIM,
MOVEMENT_ACTION_STEP_END
};
static const u8 sMovement_ShiftLeft[] =
{
MOVEMENT_ACTION_STORE_AND_LOCK_ANIM,
MOVEMENT_ACTION_LOCK_ANIM,
MOVEMENT_ACTION_WALK_NORMAL_LEFT,
MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM,
MOVEMENT_ACTION_UNLOCK_ANIM,
MOVEMENT_ACTION_STEP_END
};
static const u8 sMovement_ShiftUp[] =
{
MOVEMENT_ACTION_STORE_AND_LOCK_ANIM,
MOVEMENT_ACTION_LOCK_ANIM,
MOVEMENT_ACTION_WALK_NORMAL_UP,
MOVEMENT_ACTION_FREE_AND_UNLOCK_ANIM,
MOVEMENT_ACTION_UNLOCK_ANIM,
MOVEMENT_ACTION_STEP_END
};