2017-09-06 14:35:16 +02:00
|
|
|
#include "global.h"
|
2019-09-09 03:07:54 +02:00
|
|
|
#include "malloc.h"
|
2019-02-08 00:41:44 +01:00
|
|
|
#include "battle_pyramid.h"
|
2017-09-08 20:05:45 +02:00
|
|
|
#include "berry.h"
|
2018-06-12 01:17:31 +02:00
|
|
|
#include "decoration.h"
|
|
|
|
#include "event_data.h"
|
2018-06-14 00:51:26 +02:00
|
|
|
#include "event_object_movement.h"
|
2018-06-12 01:17:31 +02:00
|
|
|
#include "event_scripts.h"
|
2019-03-22 20:16:26 +01:00
|
|
|
#include "faraway_island.h"
|
2018-06-12 01:17:31 +02:00
|
|
|
#include "field_camera.h"
|
|
|
|
#include "field_effect.h"
|
|
|
|
#include "field_effect_helpers.h"
|
2017-09-06 15:29:59 +02:00
|
|
|
#include "field_player_avatar.h"
|
2017-09-16 19:54:33 +02:00
|
|
|
#include "fieldmap.h"
|
2017-09-08 20:16:44 +02:00
|
|
|
#include "mauville_old_man.h"
|
2017-09-16 22:40:00 +02:00
|
|
|
#include "metatile_behavior.h"
|
2018-06-12 01:17:31 +02:00
|
|
|
#include "overworld.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "random.h"
|
|
|
|
#include "sprite.h"
|
2018-11-13 15:19:04 +01:00
|
|
|
#include "task.h"
|
2018-06-12 01:17:31 +02:00
|
|
|
#include "trainer_see.h"
|
2019-01-13 20:58:42 +01:00
|
|
|
#include "trainer_hill.h"
|
2018-06-11 17:34:51 +02:00
|
|
|
#include "util.h"
|
2019-11-21 20:03:35 +01:00
|
|
|
#include "constants/event_object_movement.h"
|
2018-06-12 02:11:48 +02:00
|
|
|
#include "constants/event_objects.h"
|
2018-11-13 15:19:04 +01:00
|
|
|
#include "constants/field_effects.h"
|
2019-04-14 13:22:37 +02:00
|
|
|
#include "constants/items.h"
|
2019-10-20 22:11:07 +02:00
|
|
|
#include "constants/mauville_old_man.h"
|
2020-04-21 21:53:48 +02:00
|
|
|
#include "constants/trainer_types.h"
|
2020-06-01 16:23:12 +02:00
|
|
|
#include "constants/union_room.h"
|
2017-09-06 14:35:16 +02:00
|
|
|
|
2018-06-12 01:17:31 +02:00
|
|
|
// this file was known as evobjmv.c in Game Freak's original source
|
2017-09-06 14:35:16 +02:00
|
|
|
|
2021-11-02 19:56:23 +01:00
|
|
|
enum {
|
|
|
|
MOVE_SPEED_NORMAL, // walking
|
|
|
|
MOVE_SPEED_FAST_1, // running / surfing / sliding (ice tile)
|
|
|
|
MOVE_SPEED_FAST_2, // water current / acro bike
|
|
|
|
MOVE_SPEED_FASTER, // mach bike's max speed
|
|
|
|
MOVE_SPEED_FASTEST,
|
|
|
|
};
|
|
|
|
|
2021-11-28 04:56:26 +01:00
|
|
|
enum {
|
|
|
|
JUMP_DISTANCE_IN_PLACE,
|
|
|
|
JUMP_DISTANCE_NORMAL,
|
|
|
|
JUMP_DISTANCE_FAR,
|
|
|
|
};
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
// 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
|
2021-04-06 23:55:29 +02:00
|
|
|
#define sDirection data[3]
|
2021-04-06 11:05:33 +02:00
|
|
|
|
|
|
|
|
2018-12-02 18:58:33 +01:00
|
|
|
#define movement_type_def(setup, table) \
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 setup##_callback(struct ObjectEvent *, struct Sprite *);\
|
2018-12-02 18:58:33 +01:00
|
|
|
void setup(struct Sprite *sprite)\
|
|
|
|
{\
|
2021-04-06 11:05:33 +02:00
|
|
|
UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->sObjEventId], sprite, setup##_callback);\
|
2018-12-02 18:58:33 +01:00
|
|
|
}\
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 setup##_callback(struct ObjectEvent *objectEvent, struct Sprite *sprite)\
|
2018-12-02 18:58:33 +01:00
|
|
|
{\
|
2021-04-06 11:05:33 +02:00
|
|
|
return table[sprite->sTypeFuncId](objectEvent, sprite);\
|
2018-12-02 18:58:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define movement_type_empty_callback(setup) \
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 setup##_callback(struct ObjectEvent *, struct Sprite *);\
|
2018-12-02 18:58:33 +01:00
|
|
|
void setup(struct Sprite *sprite)\
|
|
|
|
{\
|
2021-04-06 11:05:33 +02:00
|
|
|
UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->sObjEventId], sprite, setup##_callback);\
|
2018-12-02 18:58:33 +01:00
|
|
|
}\
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 setup##_callback(struct ObjectEvent *objectEvent, struct Sprite *sprite)\
|
2018-12-02 18:58:33 +01:00
|
|
|
{\
|
|
|
|
return 0;\
|
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static EWRAM_DATA u8 sCurrentReflectionType = 0;
|
|
|
|
static EWRAM_DATA u16 sCurrentSpecialObjectPaletteTag = 0;
|
|
|
|
static EWRAM_DATA struct LockedAnimObjectEvents *sLockedAnimObjectEvents = {0};
|
2017-09-08 23:58:41 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
static void MoveCoordsInDirection(u32, s16 *, s16 *, s16, s16);
|
2019-11-21 04:55:44 +01:00
|
|
|
static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *, struct Sprite *);
|
2018-06-14 00:51:26 +02:00
|
|
|
static void SetMovementDelay(struct Sprite *, s16);
|
|
|
|
static bool8 WaitForMovementDelay(struct Sprite *);
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 GetCollisionInDirection(struct ObjectEvent *, u8);
|
2021-11-01 23:06:15 +01:00
|
|
|
static u32 GetCopyDirection(u8, u32, u32);
|
2019-11-21 04:55:44 +01:00
|
|
|
static void TryEnableObjectEventAnim(struct ObjectEvent *, struct Sprite *);
|
|
|
|
static void ObjectEventExecHeldMovementAction(struct ObjectEvent *, struct Sprite *);
|
|
|
|
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);
|
2021-04-06 11:05:33 +02:00
|
|
|
static void UpdateObjectEventOffscreen(struct ObjectEvent *, struct Sprite *);
|
|
|
|
static void UpdateObjectEventSpriteVisibility(struct ObjectEvent *, struct Sprite *);
|
2022-07-29 17:15:33 +02:00
|
|
|
static void ObjectEventUpdateMetatileBehaviors(struct ObjectEvent *);
|
|
|
|
static void GetGroundEffectFlags_Reflection(struct ObjectEvent *, u32 *);
|
|
|
|
static void GetGroundEffectFlags_TallGrassOnSpawn(struct ObjectEvent *, u32 *);
|
|
|
|
static void GetGroundEffectFlags_LongGrassOnSpawn(struct ObjectEvent *, u32 *);
|
|
|
|
static void GetGroundEffectFlags_SandHeap(struct ObjectEvent *, u32 *);
|
|
|
|
static void GetGroundEffectFlags_ShallowFlowingWater(struct ObjectEvent *, u32 *);
|
|
|
|
static void GetGroundEffectFlags_ShortGrass(struct ObjectEvent *, u32 *);
|
|
|
|
static void GetGroundEffectFlags_HotSprings(struct ObjectEvent *, u32 *);
|
|
|
|
static void GetGroundEffectFlags_TallGrassOnBeginStep(struct ObjectEvent *, u32 *);
|
|
|
|
static void GetGroundEffectFlags_LongGrassOnBeginStep(struct ObjectEvent *, u32 *);
|
|
|
|
static void GetGroundEffectFlags_Tracks(struct ObjectEvent *, u32 *);
|
|
|
|
static void GetGroundEffectFlags_Puddle(struct ObjectEvent *, u32 *);
|
|
|
|
static void GetGroundEffectFlags_Ripple(struct ObjectEvent *, u32 *);
|
|
|
|
static void GetGroundEffectFlags_Seaweed(struct ObjectEvent *, u32 *);
|
|
|
|
static void GetGroundEffectFlags_JumpLanding(struct ObjectEvent *, u32 *);
|
|
|
|
static u8 ObjectEventGetNearbyReflectionType(struct ObjectEvent *);
|
2018-06-11 17:23:14 +02:00
|
|
|
static u8 GetReflectionTypeByMetatileBehavior(u32);
|
2022-01-21 18:48:19 +01:00
|
|
|
static void InitObjectPriorityByElevation(struct Sprite *, u8);
|
2022-07-29 17:15:33 +02:00
|
|
|
static void ObjectEventUpdateSubpriority(struct ObjectEvent *, struct Sprite *);
|
|
|
|
static void DoTracksGroundEffect_None(struct ObjectEvent *, struct Sprite *, u8);
|
|
|
|
static void DoTracksGroundEffect_Footprints(struct ObjectEvent *, struct Sprite *, u8);
|
|
|
|
static void DoTracksGroundEffect_BikeTireTracks(struct ObjectEvent *, struct Sprite *, u8);
|
|
|
|
static void DoRippleFieldEffect(struct ObjectEvent *, struct Sprite *);
|
|
|
|
static void DoGroundEffects_OnSpawn(struct ObjectEvent *, struct Sprite *);
|
|
|
|
static void DoGroundEffects_OnBeginStep(struct ObjectEvent *, struct Sprite *);
|
|
|
|
static void DoGroundEffects_OnFinishStep(struct ObjectEvent *, struct Sprite *);
|
|
|
|
static void VirtualObject_UpdateAnim(struct Sprite *);
|
2018-06-14 00:51:26 +02:00
|
|
|
static void ApplyLevitateMovement(u8);
|
2019-11-21 04:55:44 +01:00
|
|
|
static bool8 MovementType_Disguise_Callback(struct ObjectEvent *, struct Sprite *);
|
2021-02-14 20:25:23 +01:00
|
|
|
static bool8 MovementType_Buried_Callback(struct ObjectEvent *, struct Sprite *);
|
2018-10-17 02:11:44 +02:00
|
|
|
static void CreateReflectionEffectSprites(void);
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 GetObjectEventIdByLocalId(u8);
|
|
|
|
static u8 GetObjectEventIdByLocalIdAndMapInternal(u8, u8, u8);
|
|
|
|
static bool8 GetAvailableObjectEventId(u16, u8, u8, u8 *);
|
|
|
|
static void SetObjectEventDynamicGraphicsId(struct ObjectEvent *);
|
|
|
|
static void RemoveObjectEventInternal(struct ObjectEvent *);
|
|
|
|
static u16 GetObjectEventFlagIdByObjectEventId(u8);
|
|
|
|
static void UpdateObjectEventVisibility(struct ObjectEvent *, struct Sprite *);
|
2021-11-18 05:28:43 +01:00
|
|
|
static void MakeSpriteTemplateFromObjectEventTemplate(struct ObjectEventTemplate *, struct SpriteTemplate *, const struct SubspriteTable **);
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetObjectEventMovingCameraOffset(s16 *, s16 *);
|
|
|
|
static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8);
|
|
|
|
static void LoadObjectEventPalette(u16);
|
|
|
|
static void RemoveObjectEventIfOutsideView(struct ObjectEvent *);
|
2021-04-06 11:05:33 +02:00
|
|
|
static void SpawnObjectEventOnReturnToField(u8, s16, s16);
|
2019-11-21 04:55:44 +01:00
|
|
|
static void SetPlayerAvatarObjectEventIdAndObjectId(u8, u8);
|
2021-04-06 11:05:33 +02:00
|
|
|
static void ResetObjectEventFldEffData(struct ObjectEvent *);
|
|
|
|
static u8 LoadSpritePaletteIfTagExists(const struct SpritePalette *);
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 FindObjectEventPaletteIndexByTag(u16);
|
2021-04-06 11:05:33 +02:00
|
|
|
static void _PatchObjectPalette(u16, u8);
|
2022-01-21 18:48:19 +01:00
|
|
|
static bool8 ObjectEventDoesElevationMatch(struct ObjectEvent *, u8);
|
2021-04-06 11:05:33 +02:00
|
|
|
static void SpriteCB_CameraObject(struct Sprite *);
|
2018-06-14 00:51:26 +02:00
|
|
|
static void CameraObject_0(struct Sprite *);
|
|
|
|
static void CameraObject_1(struct Sprite *);
|
|
|
|
static void CameraObject_2(struct Sprite *);
|
2022-01-21 18:48:19 +01:00
|
|
|
static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8, struct ObjectEventTemplate *, u8);
|
2019-11-21 04:55:44 +01:00
|
|
|
static void ClearObjectEventMovement(struct ObjectEvent *, struct Sprite *);
|
|
|
|
static void ObjectEventSetSingleMovement(struct ObjectEvent *, struct Sprite *, u8);
|
2021-04-06 23:55:29 +02:00
|
|
|
static void SetSpriteDataForNormalStep(struct Sprite *, u8, u8);
|
2022-01-21 18:48:19 +01:00
|
|
|
static void InitSpriteForFigure8Anim(struct Sprite *);
|
|
|
|
static bool8 AnimateSpriteInFigure8(struct Sprite *);
|
2021-11-18 05:28:43 +01:00
|
|
|
static void SpriteCB_VirtualObject(struct Sprite *);
|
2021-04-06 11:05:33 +02:00
|
|
|
static void DoShadowFieldEffect(struct ObjectEvent *);
|
|
|
|
static void SetJumpSpriteData(struct Sprite *, u8, u8, u8);
|
2022-01-21 18:48:19 +01:00
|
|
|
static void SetWalkSlowSpriteData(struct Sprite *, u8);
|
|
|
|
static bool8 UpdateWalkSlowAnim(struct Sprite *);
|
|
|
|
static u8 DoJumpSpriteMovement(struct Sprite *);
|
|
|
|
static u8 DoJumpSpecialSpriteMovement(struct Sprite *);
|
2021-04-06 11:05:33 +02:00
|
|
|
static void CreateLevitateMovementTask(struct ObjectEvent *);
|
|
|
|
static void DestroyLevitateMovementTask(u8);
|
2022-01-21 18:48:19 +01:00
|
|
|
static bool8 NpcTakeStep(struct Sprite *);
|
|
|
|
static bool8 IsElevationMismatchAt(u8, s16, s16);
|
2022-06-01 18:41:57 +02:00
|
|
|
static bool8 AreElevationsCompatible(u8, u8);
|
2018-06-11 15:34:19 +02:00
|
|
|
|
2021-04-06 01:52:35 +02:00
|
|
|
static const struct SpriteFrameImage sPicTable_PechaBerryTree[];
|
|
|
|
|
2022-09-28 02:16:48 +02:00
|
|
|
const u8 gReflectionEffectPaletteMap[16] = {
|
|
|
|
[PALSLOT_PLAYER] = PALSLOT_PLAYER_REFLECTION,
|
|
|
|
[PALSLOT_PLAYER_REFLECTION] = PALSLOT_PLAYER_REFLECTION,
|
|
|
|
[PALSLOT_NPC_1] = PALSLOT_NPC_1_REFLECTION,
|
|
|
|
[PALSLOT_NPC_2] = PALSLOT_NPC_2_REFLECTION,
|
|
|
|
[PALSLOT_NPC_3] = PALSLOT_NPC_3_REFLECTION,
|
|
|
|
[PALSLOT_NPC_4] = PALSLOT_NPC_4_REFLECTION,
|
|
|
|
[PALSLOT_NPC_1_REFLECTION] = PALSLOT_NPC_1_REFLECTION,
|
|
|
|
[PALSLOT_NPC_2_REFLECTION] = PALSLOT_NPC_2_REFLECTION,
|
|
|
|
[PALSLOT_NPC_3_REFLECTION] = PALSLOT_NPC_3_REFLECTION,
|
|
|
|
[PALSLOT_NPC_4_REFLECTION] = PALSLOT_NPC_4_REFLECTION,
|
|
|
|
[PALSLOT_NPC_SPECIAL] = PALSLOT_NPC_SPECIAL_REFLECTION,
|
|
|
|
[PALSLOT_NPC_SPECIAL_REFLECTION] = PALSLOT_NPC_SPECIAL_REFLECTION
|
|
|
|
};
|
2018-06-12 00:33:50 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static const struct SpriteTemplate sCameraSpriteTemplate = {
|
|
|
|
.tileTag = 0,
|
2021-09-14 19:14:14 +02:00
|
|
|
.paletteTag = TAG_NONE,
|
2021-04-06 11:05:33 +02:00
|
|
|
.oam = &gDummyOamData,
|
|
|
|
.anims = gDummySpriteAnimTable,
|
|
|
|
.images = NULL,
|
|
|
|
.affineAnims = gDummySpriteAffineAnimTable,
|
|
|
|
.callback = SpriteCB_CameraObject
|
|
|
|
};
|
2018-06-12 00:33:50 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void (*const sCameraObjectFuncs[])(struct Sprite *) = {
|
2018-06-12 00:33:50 +02:00
|
|
|
CameraObject_0,
|
|
|
|
CameraObject_1,
|
|
|
|
CameraObject_2,
|
|
|
|
};
|
|
|
|
|
2020-02-13 00:32:51 +01:00
|
|
|
#include "data/object_events/object_event_graphics.h"
|
2018-06-12 00:33:50 +02:00
|
|
|
|
|
|
|
// movement type callbacks
|
2018-06-14 00:51:26 +02:00
|
|
|
static void (*const sMovementTypeCallbacks[])(struct Sprite *) =
|
|
|
|
{
|
2018-12-05 15:31:01 +01:00
|
|
|
[MOVEMENT_TYPE_NONE] = MovementType_None,
|
|
|
|
[MOVEMENT_TYPE_LOOK_AROUND] = MovementType_LookAround,
|
|
|
|
[MOVEMENT_TYPE_WANDER_AROUND] = MovementType_WanderAround,
|
|
|
|
[MOVEMENT_TYPE_WANDER_UP_AND_DOWN] = MovementType_WanderUpAndDown,
|
|
|
|
[MOVEMENT_TYPE_WANDER_DOWN_AND_UP] = MovementType_WanderUpAndDown,
|
|
|
|
[MOVEMENT_TYPE_WANDER_LEFT_AND_RIGHT] = MovementType_WanderLeftAndRight,
|
|
|
|
[MOVEMENT_TYPE_WANDER_RIGHT_AND_LEFT] = MovementType_WanderLeftAndRight,
|
|
|
|
[MOVEMENT_TYPE_FACE_UP] = MovementType_FaceDirection,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN] = MovementType_FaceDirection,
|
|
|
|
[MOVEMENT_TYPE_FACE_LEFT] = MovementType_FaceDirection,
|
|
|
|
[MOVEMENT_TYPE_FACE_RIGHT] = MovementType_FaceDirection,
|
|
|
|
[MOVEMENT_TYPE_PLAYER] = MovementType_Player,
|
|
|
|
[MOVEMENT_TYPE_BERRY_TREE_GROWTH] = MovementType_BerryTreeGrowth,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN_AND_UP] = MovementType_FaceDownAndUp,
|
|
|
|
[MOVEMENT_TYPE_FACE_LEFT_AND_RIGHT] = MovementType_FaceLeftAndRight,
|
|
|
|
[MOVEMENT_TYPE_FACE_UP_AND_LEFT] = MovementType_FaceUpAndLeft,
|
|
|
|
[MOVEMENT_TYPE_FACE_UP_AND_RIGHT] = MovementType_FaceUpAndRight,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN_AND_LEFT] = MovementType_FaceDownAndLeft,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN_AND_RIGHT] = MovementType_FaceDownAndRight,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN_UP_AND_LEFT] = MovementType_FaceDownUpAndLeft,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN_UP_AND_RIGHT] = MovementType_FaceDownUpAndRight,
|
|
|
|
[MOVEMENT_TYPE_FACE_UP_LEFT_AND_RIGHT] = MovementType_FaceUpRightAndLeft,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN_LEFT_AND_RIGHT] = MovementType_FaceDownRightAndLeft,
|
|
|
|
[MOVEMENT_TYPE_ROTATE_COUNTERCLOCKWISE] = MovementType_RotateCounterclockwise,
|
|
|
|
[MOVEMENT_TYPE_ROTATE_CLOCKWISE] = MovementType_RotateClockwise,
|
|
|
|
[MOVEMENT_TYPE_WALK_UP_AND_DOWN] = MovementType_WalkBackAndForth,
|
|
|
|
[MOVEMENT_TYPE_WALK_DOWN_AND_UP] = MovementType_WalkBackAndForth,
|
|
|
|
[MOVEMENT_TYPE_WALK_LEFT_AND_RIGHT] = MovementType_WalkBackAndForth,
|
|
|
|
[MOVEMENT_TYPE_WALK_RIGHT_AND_LEFT] = MovementType_WalkBackAndForth,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_RIGHT_LEFT_DOWN] = MovementType_WalkSequenceUpRightLeftDown,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_LEFT_DOWN_UP] = MovementType_WalkSequenceRightLeftDownUp,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_UP_RIGHT_LEFT] = MovementType_WalkSequenceDownUpRightLeft,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_DOWN_UP_RIGHT] = MovementType_WalkSequenceLeftDownUpRight,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_LEFT_RIGHT_DOWN] = MovementType_WalkSequenceUpLeftRightDown,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_RIGHT_DOWN_UP] = MovementType_WalkSequenceLeftRightDownUp,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_UP_LEFT_RIGHT] = MovementType_WalkSequenceDownUpLeftRight,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_DOWN_UP_LEFT] = MovementType_WalkSequenceRightDownUpLeft,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_UP_DOWN_RIGHT] = MovementType_WalkSequenceLeftUpDownRight,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_DOWN_RIGHT_LEFT] = MovementType_WalkSequenceUpDownRightLeft,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_LEFT_UP_DOWN] = MovementType_WalkSequenceRightLeftUpDown,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_RIGHT_LEFT_UP] = MovementType_WalkSequenceDownRightLeftUp,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_UP_DOWN_LEFT] = MovementType_WalkSequenceRightUpDownLeft,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_DOWN_LEFT_RIGHT] = MovementType_WalkSequenceUpDownLeftRight,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_RIGHT_UP_DOWN] = MovementType_WalkSequenceLeftRightUpDown,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_LEFT_RIGHT_UP] = MovementType_WalkSequenceDownLeftRightUp,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_LEFT_DOWN_RIGHT] = MovementType_WalkSequenceUpLeftDownRight,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_RIGHT_UP_LEFT] = MovementType_WalkSequenceDownRightUpLeft,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_DOWN_RIGHT_UP] = MovementType_WalkSequenceLeftDownRightUp,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_UP_LEFT_DOWN] = MovementType_WalkSequenceRightUpLeftDown,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_RIGHT_DOWN_LEFT] = MovementType_WalkSequenceUpRightDownLeft,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_LEFT_UP_RIGHT] = MovementType_WalkSequenceDownLeftUpRight,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_UP_RIGHT_DOWN] = MovementType_WalkSequenceLeftUpRightDown,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_DOWN_LEFT_UP] = MovementType_WalkSequenceRightDownLeftUp,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER] = MovementType_CopyPlayer,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_OPPOSITE] = MovementType_CopyPlayer,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_COUNTERCLOCKWISE] = MovementType_CopyPlayer,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_CLOCKWISE] = MovementType_CopyPlayer,
|
|
|
|
[MOVEMENT_TYPE_TREE_DISGUISE] = MovementType_TreeDisguise,
|
|
|
|
[MOVEMENT_TYPE_MOUNTAIN_DISGUISE] = MovementType_MountainDisguise,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_IN_GRASS] = MovementType_CopyPlayerInGrass,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_OPPOSITE_IN_GRASS] = MovementType_CopyPlayerInGrass,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_COUNTERCLOCKWISE_IN_GRASS] = MovementType_CopyPlayerInGrass,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_CLOCKWISE_IN_GRASS] = MovementType_CopyPlayerInGrass,
|
2021-02-14 20:25:23 +01:00
|
|
|
[MOVEMENT_TYPE_BURIED] = MovementType_Buried,
|
2018-12-05 15:31:01 +01:00
|
|
|
[MOVEMENT_TYPE_WALK_IN_PLACE_DOWN] = MovementType_WalkInPlace,
|
|
|
|
[MOVEMENT_TYPE_WALK_IN_PLACE_UP] = MovementType_WalkInPlace,
|
|
|
|
[MOVEMENT_TYPE_WALK_IN_PLACE_LEFT] = MovementType_WalkInPlace,
|
|
|
|
[MOVEMENT_TYPE_WALK_IN_PLACE_RIGHT] = MovementType_WalkInPlace,
|
|
|
|
[MOVEMENT_TYPE_JOG_IN_PLACE_DOWN] = MovementType_JogInPlace,
|
|
|
|
[MOVEMENT_TYPE_JOG_IN_PLACE_UP] = MovementType_JogInPlace,
|
|
|
|
[MOVEMENT_TYPE_JOG_IN_PLACE_LEFT] = MovementType_JogInPlace,
|
|
|
|
[MOVEMENT_TYPE_JOG_IN_PLACE_RIGHT] = MovementType_JogInPlace,
|
|
|
|
[MOVEMENT_TYPE_RUN_IN_PLACE_DOWN] = MovementType_RunInPlace,
|
|
|
|
[MOVEMENT_TYPE_RUN_IN_PLACE_UP] = MovementType_RunInPlace,
|
|
|
|
[MOVEMENT_TYPE_RUN_IN_PLACE_LEFT] = MovementType_RunInPlace,
|
|
|
|
[MOVEMENT_TYPE_RUN_IN_PLACE_RIGHT] = MovementType_RunInPlace,
|
|
|
|
[MOVEMENT_TYPE_INVISIBLE] = MovementType_Invisible,
|
|
|
|
[MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_DOWN] = MovementType_WalkSlowlyInPlace,
|
|
|
|
[MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_UP] = MovementType_WalkSlowlyInPlace,
|
|
|
|
[MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_LEFT] = MovementType_WalkSlowlyInPlace,
|
|
|
|
[MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_RIGHT] = MovementType_WalkSlowlyInPlace,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
static const bool8 sMovementTypeHasRange[NUM_MOVEMENT_TYPES] = {
|
|
|
|
[MOVEMENT_TYPE_WANDER_AROUND] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WANDER_UP_AND_DOWN] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WANDER_DOWN_AND_UP] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WANDER_LEFT_AND_RIGHT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WANDER_RIGHT_AND_LEFT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_UP_AND_DOWN] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_DOWN_AND_UP] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_LEFT_AND_RIGHT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_RIGHT_AND_LEFT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_RIGHT_LEFT_DOWN] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_LEFT_DOWN_UP] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_UP_RIGHT_LEFT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_DOWN_UP_RIGHT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_LEFT_RIGHT_DOWN] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_RIGHT_DOWN_UP] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_UP_LEFT_RIGHT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_DOWN_UP_LEFT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_UP_DOWN_RIGHT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_DOWN_RIGHT_LEFT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_LEFT_UP_DOWN] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_RIGHT_LEFT_UP] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_UP_DOWN_LEFT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_DOWN_LEFT_RIGHT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_RIGHT_UP_DOWN] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_LEFT_RIGHT_UP] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_LEFT_DOWN_RIGHT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_RIGHT_UP_LEFT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_DOWN_RIGHT_UP] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_UP_LEFT_DOWN] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_RIGHT_DOWN_LEFT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_LEFT_UP_RIGHT] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_UP_RIGHT_DOWN] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_DOWN_LEFT_UP] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_OPPOSITE] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_COUNTERCLOCKWISE] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_CLOCKWISE] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_IN_GRASS] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_OPPOSITE_IN_GRASS] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_COUNTERCLOCKWISE_IN_GRASS] = TRUE,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_CLOCKWISE_IN_GRASS] = TRUE,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const u8 gInitialMovementTypeFacingDirections[] = {
|
2018-12-05 15:31:01 +01:00
|
|
|
[MOVEMENT_TYPE_NONE] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_LOOK_AROUND] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WANDER_AROUND] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WANDER_UP_AND_DOWN] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_WANDER_DOWN_AND_UP] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WANDER_LEFT_AND_RIGHT] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_WANDER_RIGHT_AND_LEFT] = DIR_EAST,
|
|
|
|
[MOVEMENT_TYPE_FACE_UP] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_FACE_LEFT] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_FACE_RIGHT] = DIR_EAST,
|
|
|
|
[MOVEMENT_TYPE_PLAYER] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_BERRY_TREE_GROWTH] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN_AND_UP] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_FACE_LEFT_AND_RIGHT] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_FACE_UP_AND_LEFT] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_FACE_UP_AND_RIGHT] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN_AND_LEFT] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN_AND_RIGHT] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN_UP_AND_LEFT] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN_UP_AND_RIGHT] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_FACE_UP_LEFT_AND_RIGHT] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_FACE_DOWN_LEFT_AND_RIGHT] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_ROTATE_COUNTERCLOCKWISE] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_ROTATE_CLOCKWISE] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_UP_AND_DOWN] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_DOWN_AND_UP] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_LEFT_AND_RIGHT] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_WALK_RIGHT_AND_LEFT] = DIR_EAST,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_RIGHT_LEFT_DOWN] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_LEFT_DOWN_UP] = DIR_EAST,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_UP_RIGHT_LEFT] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_DOWN_UP_RIGHT] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_LEFT_RIGHT_DOWN] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_RIGHT_DOWN_UP] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_UP_LEFT_RIGHT] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_DOWN_UP_LEFT] = DIR_EAST,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_UP_DOWN_RIGHT] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_DOWN_RIGHT_LEFT] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_LEFT_UP_DOWN] = DIR_EAST,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_RIGHT_LEFT_UP] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_UP_DOWN_LEFT] = DIR_EAST,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_DOWN_LEFT_RIGHT] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_RIGHT_UP_DOWN] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_LEFT_RIGHT_UP] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_LEFT_DOWN_RIGHT] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_RIGHT_UP_LEFT] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_DOWN_RIGHT_UP] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_UP_LEFT_DOWN] = DIR_EAST,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_UP_RIGHT_DOWN_LEFT] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_LEFT_UP_RIGHT] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_UP_RIGHT_DOWN] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_DOWN_LEFT_UP] = DIR_EAST,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_OPPOSITE] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_COUNTERCLOCKWISE] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_CLOCKWISE] = DIR_EAST,
|
|
|
|
[MOVEMENT_TYPE_TREE_DISGUISE] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_MOUNTAIN_DISGUISE] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_IN_GRASS] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_OPPOSITE_IN_GRASS] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_COUNTERCLOCKWISE_IN_GRASS] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_COPY_PLAYER_CLOCKWISE_IN_GRASS] = DIR_EAST,
|
2021-02-14 20:25:23 +01:00
|
|
|
[MOVEMENT_TYPE_BURIED] = DIR_SOUTH,
|
2018-12-05 15:31:01 +01:00
|
|
|
[MOVEMENT_TYPE_WALK_IN_PLACE_DOWN] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_IN_PLACE_UP] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_IN_PLACE_LEFT] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_WALK_IN_PLACE_RIGHT] = DIR_EAST,
|
|
|
|
[MOVEMENT_TYPE_JOG_IN_PLACE_DOWN] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_JOG_IN_PLACE_UP] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_JOG_IN_PLACE_LEFT] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_JOG_IN_PLACE_RIGHT] = DIR_EAST,
|
|
|
|
[MOVEMENT_TYPE_RUN_IN_PLACE_DOWN] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_RUN_IN_PLACE_UP] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_RUN_IN_PLACE_LEFT] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_RUN_IN_PLACE_RIGHT] = DIR_EAST,
|
|
|
|
[MOVEMENT_TYPE_INVISIBLE] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_DOWN] = DIR_SOUTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_UP] = DIR_NORTH,
|
|
|
|
[MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_LEFT] = DIR_WEST,
|
|
|
|
[MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_RIGHT] = DIR_EAST,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
#define OBJ_EVENT_PAL_TAG_BRENDAN 0x1100
|
|
|
|
#define OBJ_EVENT_PAL_TAG_BRENDAN_REFLECTION 0x1101
|
|
|
|
#define OBJ_EVENT_PAL_TAG_BRIDGE_REFLECTION 0x1102
|
|
|
|
#define OBJ_EVENT_PAL_TAG_NPC_1 0x1103
|
|
|
|
#define OBJ_EVENT_PAL_TAG_NPC_2 0x1104
|
|
|
|
#define OBJ_EVENT_PAL_TAG_NPC_3 0x1105
|
|
|
|
#define OBJ_EVENT_PAL_TAG_NPC_4 0x1106
|
|
|
|
#define OBJ_EVENT_PAL_TAG_NPC_1_REFLECTION 0x1107
|
|
|
|
#define OBJ_EVENT_PAL_TAG_NPC_2_REFLECTION 0x1108
|
|
|
|
#define OBJ_EVENT_PAL_TAG_NPC_3_REFLECTION 0x1109
|
|
|
|
#define OBJ_EVENT_PAL_TAG_NPC_4_REFLECTION 0x110A
|
|
|
|
#define OBJ_EVENT_PAL_TAG_QUINTY_PLUMP 0x110B
|
|
|
|
#define OBJ_EVENT_PAL_TAG_QUINTY_PLUMP_REFLECTION 0x110C
|
|
|
|
#define OBJ_EVENT_PAL_TAG_TRUCK 0x110D
|
|
|
|
#define OBJ_EVENT_PAL_TAG_VIGOROTH 0x110E
|
|
|
|
#define OBJ_EVENT_PAL_TAG_ZIGZAGOON 0x110F
|
|
|
|
#define OBJ_EVENT_PAL_TAG_MAY 0x1110
|
|
|
|
#define OBJ_EVENT_PAL_TAG_MAY_REFLECTION 0x1111
|
|
|
|
#define OBJ_EVENT_PAL_TAG_MOVING_BOX 0x1112
|
|
|
|
#define OBJ_EVENT_PAL_TAG_CABLE_CAR 0x1113
|
|
|
|
#define OBJ_EVENT_PAL_TAG_SSTIDAL 0x1114
|
|
|
|
#define OBJ_EVENT_PAL_TAG_PLAYER_UNDERWATER 0x1115
|
|
|
|
#define OBJ_EVENT_PAL_TAG_KYOGRE 0x1116
|
|
|
|
#define OBJ_EVENT_PAL_TAG_KYOGRE_REFLECTION 0x1117
|
|
|
|
#define OBJ_EVENT_PAL_TAG_GROUDON 0x1118
|
|
|
|
#define OBJ_EVENT_PAL_TAG_GROUDON_REFLECTION 0x1119
|
|
|
|
#define OBJ_EVENT_PAL_TAG_UNUSED 0x111A
|
|
|
|
#define OBJ_EVENT_PAL_TAG_SUBMARINE_SHADOW 0x111B
|
|
|
|
#define OBJ_EVENT_PAL_TAG_POOCHYENA 0x111C
|
|
|
|
#define OBJ_EVENT_PAL_TAG_RED_LEAF 0x111D
|
|
|
|
#define OBJ_EVENT_PAL_TAG_DEOXYS 0x111E
|
|
|
|
#define OBJ_EVENT_PAL_TAG_BIRTH_ISLAND_STONE 0x111F
|
|
|
|
#define OBJ_EVENT_PAL_TAG_HO_OH 0x1120
|
|
|
|
#define OBJ_EVENT_PAL_TAG_LUGIA 0x1121
|
|
|
|
#define OBJ_EVENT_PAL_TAG_RS_BRENDAN 0x1122
|
|
|
|
#define OBJ_EVENT_PAL_TAG_RS_MAY 0x1123
|
|
|
|
#define OBJ_EVENT_PAL_TAG_NONE 0x11FF
|
2018-09-08 06:52:11 +02:00
|
|
|
|
2020-02-13 00:32:51 +01:00
|
|
|
#include "data/object_events/object_event_graphics_info_pointers.h"
|
|
|
|
#include "data/field_effects/field_effect_object_template_pointers.h"
|
|
|
|
#include "data/object_events/object_event_pic_tables.h"
|
|
|
|
#include "data/object_events/object_event_anims.h"
|
|
|
|
#include "data/object_events/base_oam.h"
|
|
|
|
#include "data/object_events/object_event_subsprites.h"
|
|
|
|
#include "data/object_events/object_event_graphics_info.h"
|
2019-11-21 04:55:44 +01:00
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const struct SpritePalette sObjectEventSpritePalettes[] = {
|
|
|
|
{gObjectEventPal_Npc1, OBJ_EVENT_PAL_TAG_NPC_1},
|
|
|
|
{gObjectEventPal_Npc2, OBJ_EVENT_PAL_TAG_NPC_2},
|
|
|
|
{gObjectEventPal_Npc3, OBJ_EVENT_PAL_TAG_NPC_3},
|
|
|
|
{gObjectEventPal_Npc4, OBJ_EVENT_PAL_TAG_NPC_4},
|
|
|
|
{gObjectEventPal_Npc1Reflection, OBJ_EVENT_PAL_TAG_NPC_1_REFLECTION},
|
|
|
|
{gObjectEventPal_Npc2Reflection, OBJ_EVENT_PAL_TAG_NPC_2_REFLECTION},
|
|
|
|
{gObjectEventPal_Npc3Reflection, OBJ_EVENT_PAL_TAG_NPC_3_REFLECTION},
|
|
|
|
{gObjectEventPal_Npc4Reflection, OBJ_EVENT_PAL_TAG_NPC_4_REFLECTION},
|
|
|
|
{gObjectEventPal_Brendan, OBJ_EVENT_PAL_TAG_BRENDAN},
|
|
|
|
{gObjectEventPal_BrendanReflection, OBJ_EVENT_PAL_TAG_BRENDAN_REFLECTION},
|
|
|
|
{gObjectEventPal_BridgeReflection, OBJ_EVENT_PAL_TAG_BRIDGE_REFLECTION},
|
|
|
|
{gObjectEventPal_PlayerUnderwater, OBJ_EVENT_PAL_TAG_PLAYER_UNDERWATER},
|
|
|
|
{gObjectEventPal_QuintyPlump, OBJ_EVENT_PAL_TAG_QUINTY_PLUMP},
|
|
|
|
{gObjectEventPal_QuintyPlumpReflection, OBJ_EVENT_PAL_TAG_QUINTY_PLUMP_REFLECTION},
|
|
|
|
{gObjectEventPal_Truck, OBJ_EVENT_PAL_TAG_TRUCK},
|
|
|
|
{gObjectEventPal_Vigoroth, OBJ_EVENT_PAL_TAG_VIGOROTH},
|
|
|
|
{gObjectEventPal_EnemyZigzagoon, OBJ_EVENT_PAL_TAG_ZIGZAGOON},
|
|
|
|
{gObjectEventPal_May, OBJ_EVENT_PAL_TAG_MAY},
|
|
|
|
{gObjectEventPal_MayReflection, OBJ_EVENT_PAL_TAG_MAY_REFLECTION},
|
|
|
|
{gObjectEventPal_MovingBox, OBJ_EVENT_PAL_TAG_MOVING_BOX},
|
|
|
|
{gObjectEventPal_CableCar, OBJ_EVENT_PAL_TAG_CABLE_CAR},
|
|
|
|
{gObjectEventPal_SSTidal, OBJ_EVENT_PAL_TAG_SSTIDAL},
|
|
|
|
{gObjectEventPal_Kyogre, OBJ_EVENT_PAL_TAG_KYOGRE},
|
|
|
|
{gObjectEventPal_KyogreReflection, OBJ_EVENT_PAL_TAG_KYOGRE_REFLECTION},
|
|
|
|
{gObjectEventPal_Groudon, OBJ_EVENT_PAL_TAG_GROUDON},
|
|
|
|
{gObjectEventPal_GroudonReflection, OBJ_EVENT_PAL_TAG_GROUDON_REFLECTION},
|
|
|
|
{gObjectEventPal_SubmarineShadow, OBJ_EVENT_PAL_TAG_SUBMARINE_SHADOW},
|
|
|
|
{gObjectEventPal_Poochyena, OBJ_EVENT_PAL_TAG_POOCHYENA},
|
|
|
|
{gObjectEventPal_RedLeaf, OBJ_EVENT_PAL_TAG_RED_LEAF},
|
|
|
|
{gObjectEventPal_Deoxys, OBJ_EVENT_PAL_TAG_DEOXYS},
|
|
|
|
{gObjectEventPal_BirthIslandStone, OBJ_EVENT_PAL_TAG_BIRTH_ISLAND_STONE},
|
|
|
|
{gObjectEventPal_HoOh, OBJ_EVENT_PAL_TAG_HO_OH},
|
|
|
|
{gObjectEventPal_Lugia, OBJ_EVENT_PAL_TAG_LUGIA},
|
|
|
|
{gObjectEventPal_RubySapphireBrendan, OBJ_EVENT_PAL_TAG_RS_BRENDAN},
|
|
|
|
{gObjectEventPal_RubySapphireMay, OBJ_EVENT_PAL_TAG_RS_MAY},
|
2022-11-07 12:09:21 +01:00
|
|
|
#ifdef BUGFIX
|
|
|
|
{NULL, OBJ_EVENT_PAL_TAG_NONE},
|
|
|
|
#else
|
|
|
|
{}, // BUG: FindObjectEventPaletteIndexByTag looks for OBJ_EVENT_PAL_TAG_NONE and not 0x0.
|
|
|
|
// If it's looking for a tag that isn't in this table, the game locks in an infinite loop.
|
|
|
|
#endif
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_Brendan[] = {
|
|
|
|
OBJ_EVENT_PAL_TAG_BRENDAN_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_BRENDAN_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_BRENDAN_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_BRENDAN_REFLECTION,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_May[] = {
|
|
|
|
OBJ_EVENT_PAL_TAG_MAY_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_MAY_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_MAY_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_MAY_REFLECTION,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_PlayerUnderwater[] = {
|
|
|
|
OBJ_EVENT_PAL_TAG_PLAYER_UNDERWATER,
|
|
|
|
OBJ_EVENT_PAL_TAG_PLAYER_UNDERWATER,
|
|
|
|
OBJ_EVENT_PAL_TAG_PLAYER_UNDERWATER,
|
|
|
|
OBJ_EVENT_PAL_TAG_PLAYER_UNDERWATER,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const struct PairedPalettes sPlayerReflectionPaletteSets[] = {
|
|
|
|
{OBJ_EVENT_PAL_TAG_BRENDAN, sReflectionPaletteTags_Brendan},
|
|
|
|
{OBJ_EVENT_PAL_TAG_MAY, sReflectionPaletteTags_May},
|
|
|
|
{OBJ_EVENT_PAL_TAG_PLAYER_UNDERWATER, sReflectionPaletteTags_PlayerUnderwater},
|
|
|
|
{OBJ_EVENT_PAL_TAG_NONE, NULL},
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_QuintyPlump[] = {
|
|
|
|
OBJ_EVENT_PAL_TAG_QUINTY_PLUMP_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_QUINTY_PLUMP_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_QUINTY_PLUMP_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_QUINTY_PLUMP_REFLECTION,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_Truck[] = {
|
|
|
|
OBJ_EVENT_PAL_TAG_TRUCK,
|
|
|
|
OBJ_EVENT_PAL_TAG_TRUCK,
|
|
|
|
OBJ_EVENT_PAL_TAG_TRUCK,
|
|
|
|
OBJ_EVENT_PAL_TAG_TRUCK,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_VigorothMover[] = {
|
|
|
|
OBJ_EVENT_PAL_TAG_VIGOROTH,
|
|
|
|
OBJ_EVENT_PAL_TAG_VIGOROTH,
|
|
|
|
OBJ_EVENT_PAL_TAG_VIGOROTH,
|
|
|
|
OBJ_EVENT_PAL_TAG_VIGOROTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_MovingBox[] = {
|
|
|
|
OBJ_EVENT_PAL_TAG_MOVING_BOX,
|
|
|
|
OBJ_EVENT_PAL_TAG_MOVING_BOX,
|
|
|
|
OBJ_EVENT_PAL_TAG_MOVING_BOX,
|
|
|
|
OBJ_EVENT_PAL_TAG_MOVING_BOX,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_CableCar[] = {
|
|
|
|
OBJ_EVENT_PAL_TAG_CABLE_CAR,
|
|
|
|
OBJ_EVENT_PAL_TAG_CABLE_CAR,
|
|
|
|
OBJ_EVENT_PAL_TAG_CABLE_CAR,
|
|
|
|
OBJ_EVENT_PAL_TAG_CABLE_CAR,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_SSTidal[] = {
|
|
|
|
OBJ_EVENT_PAL_TAG_SSTIDAL,
|
|
|
|
OBJ_EVENT_PAL_TAG_SSTIDAL,
|
|
|
|
OBJ_EVENT_PAL_TAG_SSTIDAL,
|
|
|
|
OBJ_EVENT_PAL_TAG_SSTIDAL,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_SubmarineShadow[] = {
|
|
|
|
OBJ_EVENT_PAL_TAG_SUBMARINE_SHADOW,
|
|
|
|
OBJ_EVENT_PAL_TAG_SUBMARINE_SHADOW,
|
|
|
|
OBJ_EVENT_PAL_TAG_SUBMARINE_SHADOW,
|
|
|
|
OBJ_EVENT_PAL_TAG_SUBMARINE_SHADOW,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_Kyogre[] = {
|
|
|
|
OBJ_EVENT_PAL_TAG_KYOGRE_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_KYOGRE_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_KYOGRE_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_KYOGRE_REFLECTION,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_Groudon[] = {
|
|
|
|
OBJ_EVENT_PAL_TAG_GROUDON_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_GROUDON_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_GROUDON_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_GROUDON_REFLECTION,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_Npc3[] = { // Only used by the Route 120 bridge Kecleon
|
|
|
|
OBJ_EVENT_PAL_TAG_NPC_3_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_NPC_3_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_NPC_3_REFLECTION,
|
|
|
|
OBJ_EVENT_PAL_TAG_NPC_3_REFLECTION,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sReflectionPaletteTags_RedLeaf[] = {
|
|
|
|
OBJ_EVENT_PAL_TAG_RED_LEAF,
|
|
|
|
OBJ_EVENT_PAL_TAG_RED_LEAF,
|
|
|
|
OBJ_EVENT_PAL_TAG_RED_LEAF,
|
|
|
|
OBJ_EVENT_PAL_TAG_RED_LEAF,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const struct PairedPalettes sSpecialObjectReflectionPaletteSets[] = {
|
|
|
|
{OBJ_EVENT_PAL_TAG_BRENDAN, sReflectionPaletteTags_Brendan},
|
|
|
|
{OBJ_EVENT_PAL_TAG_MAY, sReflectionPaletteTags_May},
|
|
|
|
{OBJ_EVENT_PAL_TAG_QUINTY_PLUMP, sReflectionPaletteTags_QuintyPlump},
|
|
|
|
{OBJ_EVENT_PAL_TAG_TRUCK, sReflectionPaletteTags_Truck},
|
|
|
|
{OBJ_EVENT_PAL_TAG_VIGOROTH, sReflectionPaletteTags_VigorothMover},
|
|
|
|
{OBJ_EVENT_PAL_TAG_MOVING_BOX, sReflectionPaletteTags_MovingBox},
|
|
|
|
{OBJ_EVENT_PAL_TAG_CABLE_CAR, sReflectionPaletteTags_CableCar},
|
|
|
|
{OBJ_EVENT_PAL_TAG_SSTIDAL, sReflectionPaletteTags_SSTidal},
|
|
|
|
{OBJ_EVENT_PAL_TAG_KYOGRE, sReflectionPaletteTags_Kyogre},
|
|
|
|
{OBJ_EVENT_PAL_TAG_GROUDON, sReflectionPaletteTags_Groudon},
|
|
|
|
{OBJ_EVENT_PAL_TAG_NPC_3, sReflectionPaletteTags_Npc3},
|
|
|
|
{OBJ_EVENT_PAL_TAG_SUBMARINE_SHADOW, sReflectionPaletteTags_SubmarineShadow},
|
|
|
|
{OBJ_EVENT_PAL_TAG_RED_LEAF, sReflectionPaletteTags_RedLeaf},
|
|
|
|
{OBJ_EVENT_PAL_TAG_NONE, NULL},
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sObjectPaletteTags0[] = {
|
2022-09-28 02:16:48 +02:00
|
|
|
[PALSLOT_PLAYER] = OBJ_EVENT_PAL_TAG_BRENDAN,
|
|
|
|
[PALSLOT_PLAYER_REFLECTION] = OBJ_EVENT_PAL_TAG_BRENDAN_REFLECTION,
|
|
|
|
[PALSLOT_NPC_1] = OBJ_EVENT_PAL_TAG_NPC_1,
|
|
|
|
[PALSLOT_NPC_2] = OBJ_EVENT_PAL_TAG_NPC_2,
|
|
|
|
[PALSLOT_NPC_3] = OBJ_EVENT_PAL_TAG_NPC_3,
|
|
|
|
[PALSLOT_NPC_4] = OBJ_EVENT_PAL_TAG_NPC_4,
|
|
|
|
[PALSLOT_NPC_1_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_1_REFLECTION,
|
|
|
|
[PALSLOT_NPC_2_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_2_REFLECTION,
|
|
|
|
[PALSLOT_NPC_3_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_3_REFLECTION,
|
|
|
|
[PALSLOT_NPC_4_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_4_REFLECTION,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sObjectPaletteTags1[] = {
|
2022-09-28 02:16:48 +02:00
|
|
|
[PALSLOT_PLAYER] = OBJ_EVENT_PAL_TAG_BRENDAN,
|
|
|
|
[PALSLOT_PLAYER_REFLECTION] = OBJ_EVENT_PAL_TAG_BRENDAN_REFLECTION,
|
|
|
|
[PALSLOT_NPC_1] = OBJ_EVENT_PAL_TAG_NPC_1,
|
|
|
|
[PALSLOT_NPC_2] = OBJ_EVENT_PAL_TAG_NPC_2,
|
|
|
|
[PALSLOT_NPC_3] = OBJ_EVENT_PAL_TAG_NPC_3,
|
|
|
|
[PALSLOT_NPC_4] = OBJ_EVENT_PAL_TAG_NPC_4,
|
|
|
|
[PALSLOT_NPC_1_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_1_REFLECTION,
|
|
|
|
[PALSLOT_NPC_2_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_2_REFLECTION,
|
|
|
|
[PALSLOT_NPC_3_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_3_REFLECTION,
|
|
|
|
[PALSLOT_NPC_4_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_4_REFLECTION,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sObjectPaletteTags2[] = {
|
2022-09-28 02:16:48 +02:00
|
|
|
[PALSLOT_PLAYER] = OBJ_EVENT_PAL_TAG_BRENDAN,
|
|
|
|
[PALSLOT_PLAYER_REFLECTION] = OBJ_EVENT_PAL_TAG_BRENDAN_REFLECTION,
|
|
|
|
[PALSLOT_NPC_1] = OBJ_EVENT_PAL_TAG_NPC_1,
|
|
|
|
[PALSLOT_NPC_2] = OBJ_EVENT_PAL_TAG_NPC_2,
|
|
|
|
[PALSLOT_NPC_3] = OBJ_EVENT_PAL_TAG_NPC_3,
|
|
|
|
[PALSLOT_NPC_4] = OBJ_EVENT_PAL_TAG_NPC_4,
|
|
|
|
[PALSLOT_NPC_1_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_1_REFLECTION,
|
|
|
|
[PALSLOT_NPC_2_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_2_REFLECTION,
|
|
|
|
[PALSLOT_NPC_3_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_3_REFLECTION,
|
|
|
|
[PALSLOT_NPC_4_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_4_REFLECTION,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 sObjectPaletteTags3[] = {
|
2022-09-28 02:16:48 +02:00
|
|
|
[PALSLOT_PLAYER] = OBJ_EVENT_PAL_TAG_BRENDAN,
|
|
|
|
[PALSLOT_PLAYER_REFLECTION] = OBJ_EVENT_PAL_TAG_BRENDAN_REFLECTION,
|
|
|
|
[PALSLOT_NPC_1] = OBJ_EVENT_PAL_TAG_NPC_1,
|
|
|
|
[PALSLOT_NPC_2] = OBJ_EVENT_PAL_TAG_NPC_2,
|
|
|
|
[PALSLOT_NPC_3] = OBJ_EVENT_PAL_TAG_NPC_3,
|
|
|
|
[PALSLOT_NPC_4] = OBJ_EVENT_PAL_TAG_NPC_4,
|
|
|
|
[PALSLOT_NPC_1_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_1_REFLECTION,
|
|
|
|
[PALSLOT_NPC_2_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_2_REFLECTION,
|
|
|
|
[PALSLOT_NPC_3_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_3_REFLECTION,
|
|
|
|
[PALSLOT_NPC_4_REFLECTION] = OBJ_EVENT_PAL_TAG_NPC_4_REFLECTION,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
static const u16 *const sObjectPaletteTagSets[] = {
|
|
|
|
sObjectPaletteTags0,
|
|
|
|
sObjectPaletteTags1,
|
|
|
|
sObjectPaletteTags2,
|
|
|
|
sObjectPaletteTags3,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-02-13 00:32:51 +01:00
|
|
|
#include "data/object_events/berry_tree_graphics_tables.h"
|
|
|
|
#include "data/field_effects/field_effect_objects.h"
|
2018-06-12 00:33:50 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
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};
|
2018-06-12 00:33:50 +02:00
|
|
|
|
2020-02-13 00:32:51 +01:00
|
|
|
#include "data/object_events/movement_type_func_tables.h"
|
2018-06-12 00:33:50 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sFaceDirectionAnimNums[] = {
|
2021-10-29 19:37:49 +02:00
|
|
|
[DIR_NONE] = ANIM_STD_FACE_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_STD_FACE_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_STD_FACE_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_STD_FACE_WEST,
|
|
|
|
[DIR_EAST] = ANIM_STD_FACE_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_STD_FACE_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_STD_FACE_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_STD_FACE_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_STD_FACE_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sMoveDirectionAnimNums[] = {
|
2021-10-29 19:37:49 +02:00
|
|
|
[DIR_NONE] = ANIM_STD_GO_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_STD_GO_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_STD_GO_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_STD_GO_WEST,
|
|
|
|
[DIR_EAST] = ANIM_STD_GO_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_STD_GO_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_STD_GO_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_STD_GO_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_STD_GO_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sMoveDirectionFastAnimNums[] = {
|
2021-10-29 19:37:49 +02:00
|
|
|
[DIR_NONE] = ANIM_STD_GO_FAST_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_STD_GO_FAST_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_STD_GO_FAST_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_STD_GO_FAST_WEST,
|
|
|
|
[DIR_EAST] = ANIM_STD_GO_FAST_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_STD_GO_FAST_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_STD_GO_FAST_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_STD_GO_FAST_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_STD_GO_FAST_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sMoveDirectionFasterAnimNums[] = {
|
2021-10-29 19:37:49 +02:00
|
|
|
[DIR_NONE] = ANIM_STD_GO_FASTER_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_STD_GO_FASTER_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_STD_GO_FASTER_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_STD_GO_FASTER_WEST,
|
|
|
|
[DIR_EAST] = ANIM_STD_GO_FASTER_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_STD_GO_FASTER_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_STD_GO_FASTER_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_STD_GO_FASTER_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_STD_GO_FASTER_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sMoveDirectionFastestAnimNums[] = {
|
2021-10-29 19:37:49 +02:00
|
|
|
[DIR_NONE] = ANIM_STD_GO_FASTEST_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_STD_GO_FASTEST_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_STD_GO_FASTEST_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_STD_GO_FASTEST_WEST,
|
|
|
|
[DIR_EAST] = ANIM_STD_GO_FASTEST_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_STD_GO_FASTEST_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_STD_GO_FASTEST_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_STD_GO_FASTEST_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_STD_GO_FASTEST_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sJumpSpecialDirectionAnimNums[] = { // used for jumping onto surf mon
|
2021-10-29 19:37:49 +02:00
|
|
|
[DIR_NONE] = ANIM_GET_ON_OFF_POKEMON_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_GET_ON_OFF_POKEMON_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_GET_ON_OFF_POKEMON_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_GET_ON_OFF_POKEMON_WEST,
|
|
|
|
[DIR_EAST] = ANIM_GET_ON_OFF_POKEMON_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_GET_ON_OFF_POKEMON_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_GET_ON_OFF_POKEMON_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_GET_ON_OFF_POKEMON_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_GET_ON_OFF_POKEMON_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sAcroWheelieDirectionAnimNums[] = {
|
2022-02-28 19:34:39 +01:00
|
|
|
[DIR_NONE] = ANIM_BUNNY_HOP_BACK_WHEEL_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_BUNNY_HOP_BACK_WHEEL_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_BUNNY_HOP_BACK_WHEEL_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_BUNNY_HOP_BACK_WHEEL_WEST,
|
|
|
|
[DIR_EAST] = ANIM_BUNNY_HOP_BACK_WHEEL_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_BUNNY_HOP_BACK_WHEEL_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_BUNNY_HOP_BACK_WHEEL_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_BUNNY_HOP_BACK_WHEEL_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_BUNNY_HOP_BACK_WHEEL_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sAcroUnusedDirectionAnimNums[] = {
|
2022-02-28 19:34:39 +01:00
|
|
|
[DIR_NONE] = ANIM_BUNNY_HOP_FRONT_WHEEL_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_BUNNY_HOP_FRONT_WHEEL_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_BUNNY_HOP_FRONT_WHEEL_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_BUNNY_HOP_FRONT_WHEEL_WEST,
|
|
|
|
[DIR_EAST] = ANIM_BUNNY_HOP_FRONT_WHEEL_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_BUNNY_HOP_FRONT_WHEEL_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_BUNNY_HOP_FRONT_WHEEL_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_BUNNY_HOP_FRONT_WHEEL_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_BUNNY_HOP_FRONT_WHEEL_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sAcroEndWheelieDirectionAnimNums[] = {
|
2021-10-29 19:37:49 +02:00
|
|
|
[DIR_NONE] = ANIM_STANDING_WHEELIE_BACK_WHEEL_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_STANDING_WHEELIE_BACK_WHEEL_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_STANDING_WHEELIE_BACK_WHEEL_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_STANDING_WHEELIE_BACK_WHEEL_WEST,
|
|
|
|
[DIR_EAST] = ANIM_STANDING_WHEELIE_BACK_WHEEL_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_STANDING_WHEELIE_BACK_WHEEL_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_STANDING_WHEELIE_BACK_WHEEL_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_STANDING_WHEELIE_BACK_WHEEL_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_STANDING_WHEELIE_BACK_WHEEL_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sAcroUnusedActionDirectionAnimNums[] = {
|
2021-10-29 19:37:49 +02:00
|
|
|
[DIR_NONE] = ANIM_STANDING_WHEELIE_FRONT_WHEEL_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_STANDING_WHEELIE_FRONT_WHEEL_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_STANDING_WHEELIE_FRONT_WHEEL_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_STANDING_WHEELIE_FRONT_WHEEL_WEST,
|
|
|
|
[DIR_EAST] = ANIM_STANDING_WHEELIE_FRONT_WHEEL_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_STANDING_WHEELIE_FRONT_WHEEL_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_STANDING_WHEELIE_FRONT_WHEEL_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_STANDING_WHEELIE_FRONT_WHEEL_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_STANDING_WHEELIE_FRONT_WHEEL_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sAcroWheeliePedalDirectionAnimNums[] = {
|
2021-10-29 19:37:49 +02:00
|
|
|
[DIR_NONE] = ANIM_MOVING_WHEELIE_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_MOVING_WHEELIE_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_MOVING_WHEELIE_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_MOVING_WHEELIE_WEST,
|
|
|
|
[DIR_EAST] = ANIM_MOVING_WHEELIE_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_MOVING_WHEELIE_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_MOVING_WHEELIE_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_MOVING_WHEELIE_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_MOVING_WHEELIE_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sFishingDirectionAnimNums[] = {
|
2021-10-29 19:37:49 +02:00
|
|
|
[DIR_NONE] = ANIM_TAKE_OUT_ROD_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_TAKE_OUT_ROD_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_TAKE_OUT_ROD_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_TAKE_OUT_ROD_WEST,
|
|
|
|
[DIR_EAST] = ANIM_TAKE_OUT_ROD_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_TAKE_OUT_ROD_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_TAKE_OUT_ROD_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_TAKE_OUT_ROD_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_TAKE_OUT_ROD_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sFishingNoCatchDirectionAnimNums[] = {
|
2021-10-29 19:37:49 +02:00
|
|
|
[DIR_NONE] = ANIM_PUT_AWAY_ROD_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_PUT_AWAY_ROD_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_PUT_AWAY_ROD_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_PUT_AWAY_ROD_WEST,
|
|
|
|
[DIR_EAST] = ANIM_PUT_AWAY_ROD_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_PUT_AWAY_ROD_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_PUT_AWAY_ROD_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_PUT_AWAY_ROD_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_PUT_AWAY_ROD_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sFishingBiteDirectionAnimNums[] = {
|
2021-10-29 19:37:49 +02:00
|
|
|
[DIR_NONE] = ANIM_HOOKED_POKEMON_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_HOOKED_POKEMON_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_HOOKED_POKEMON_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_HOOKED_POKEMON_WEST,
|
|
|
|
[DIR_EAST] = ANIM_HOOKED_POKEMON_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_HOOKED_POKEMON_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_HOOKED_POKEMON_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_HOOKED_POKEMON_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_HOOKED_POKEMON_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sRunningDirectionAnimNums[] = {
|
2021-10-29 19:37:49 +02:00
|
|
|
[DIR_NONE] = ANIM_RUN_SOUTH,
|
|
|
|
[DIR_SOUTH] = ANIM_RUN_SOUTH,
|
|
|
|
[DIR_NORTH] = ANIM_RUN_NORTH,
|
|
|
|
[DIR_WEST] = ANIM_RUN_WEST,
|
|
|
|
[DIR_EAST] = ANIM_RUN_EAST,
|
|
|
|
[DIR_SOUTHWEST] = ANIM_RUN_SOUTH,
|
|
|
|
[DIR_SOUTHEAST] = ANIM_RUN_SOUTH,
|
|
|
|
[DIR_NORTHWEST] = ANIM_RUN_NORTH,
|
|
|
|
[DIR_NORTHEAST] = ANIM_RUN_NORTH,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gTrainerFacingDirectionMovementTypes[] = {
|
2018-12-05 15:31:01 +01:00
|
|
|
[DIR_NONE] = MOVEMENT_TYPE_FACE_DOWN,
|
|
|
|
[DIR_SOUTH] = MOVEMENT_TYPE_FACE_DOWN,
|
|
|
|
[DIR_NORTH] = MOVEMENT_TYPE_FACE_UP,
|
|
|
|
[DIR_WEST] = MOVEMENT_TYPE_FACE_LEFT,
|
|
|
|
[DIR_EAST] = MOVEMENT_TYPE_FACE_RIGHT,
|
|
|
|
[DIR_SOUTHWEST] = MOVEMENT_TYPE_FACE_DOWN,
|
|
|
|
[DIR_SOUTHEAST] = MOVEMENT_TYPE_FACE_DOWN,
|
|
|
|
[DIR_NORTHWEST] = MOVEMENT_TYPE_FACE_UP,
|
|
|
|
[DIR_NORTHEAST] = MOVEMENT_TYPE_FACE_UP,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
bool8 (*const gOppositeDirectionBlockedMetatileFuncs[])(u8) = {
|
|
|
|
MetatileBehavior_IsSouthBlocked,
|
|
|
|
MetatileBehavior_IsNorthBlocked,
|
|
|
|
MetatileBehavior_IsWestBlocked,
|
|
|
|
MetatileBehavior_IsEastBlocked
|
|
|
|
};
|
|
|
|
|
|
|
|
bool8 (*const gDirectionBlockedMetatileFuncs[])(u8) = {
|
|
|
|
MetatileBehavior_IsNorthBlocked,
|
|
|
|
MetatileBehavior_IsSouthBlocked,
|
|
|
|
MetatileBehavior_IsEastBlocked,
|
|
|
|
MetatileBehavior_IsWestBlocked
|
|
|
|
};
|
|
|
|
|
2018-09-05 00:31:37 +02:00
|
|
|
static const struct Coords16 sDirectionToVectors[] = {
|
2018-06-12 00:33:50 +02:00
|
|
|
{ 0, 0},
|
|
|
|
{ 0, 1},
|
|
|
|
{ 0, -1},
|
|
|
|
{-1, 0},
|
|
|
|
{ 1, 0},
|
|
|
|
{-1, 1},
|
|
|
|
{ 1, 1},
|
|
|
|
{-1, -1},
|
|
|
|
{ 1, -1}
|
|
|
|
};
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gFaceDirectionMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_FACE_DOWN,
|
|
|
|
MOVEMENT_ACTION_FACE_DOWN,
|
|
|
|
MOVEMENT_ACTION_FACE_UP,
|
|
|
|
MOVEMENT_ACTION_FACE_LEFT,
|
|
|
|
MOVEMENT_ACTION_FACE_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gWalkSlowMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_WALK_SLOW_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_SLOW_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_SLOW_UP,
|
|
|
|
MOVEMENT_ACTION_WALK_SLOW_LEFT,
|
|
|
|
MOVEMENT_ACTION_WALK_SLOW_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gWalkNormalMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_WALK_NORMAL_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_NORMAL_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_NORMAL_UP,
|
|
|
|
MOVEMENT_ACTION_WALK_NORMAL_LEFT,
|
|
|
|
MOVEMENT_ACTION_WALK_NORMAL_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gWalkFastMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_WALK_FAST_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_FAST_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_FAST_UP,
|
|
|
|
MOVEMENT_ACTION_WALK_FAST_LEFT,
|
|
|
|
MOVEMENT_ACTION_WALK_FAST_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gRideWaterCurrentMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN,
|
|
|
|
MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN,
|
|
|
|
MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP,
|
|
|
|
MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT,
|
|
|
|
MOVEMENT_ACTION_RIDE_WATER_CURRENT_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-11-02 18:01:07 +01:00
|
|
|
const u8 gWalkFasterMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_WALK_FASTER_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_FASTER_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_FASTER_UP,
|
|
|
|
MOVEMENT_ACTION_WALK_FASTER_LEFT,
|
|
|
|
MOVEMENT_ACTION_WALK_FASTER_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gSlideMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_SLIDE_DOWN,
|
|
|
|
MOVEMENT_ACTION_SLIDE_DOWN,
|
|
|
|
MOVEMENT_ACTION_SLIDE_UP,
|
|
|
|
MOVEMENT_ACTION_SLIDE_LEFT,
|
|
|
|
MOVEMENT_ACTION_SLIDE_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gPlayerRunMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_PLAYER_RUN_DOWN,
|
|
|
|
MOVEMENT_ACTION_PLAYER_RUN_DOWN,
|
|
|
|
MOVEMENT_ACTION_PLAYER_RUN_UP,
|
|
|
|
MOVEMENT_ACTION_PLAYER_RUN_LEFT,
|
|
|
|
MOVEMENT_ACTION_PLAYER_RUN_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gJump2MovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_JUMP_2_DOWN,
|
|
|
|
MOVEMENT_ACTION_JUMP_2_DOWN,
|
|
|
|
MOVEMENT_ACTION_JUMP_2_UP,
|
|
|
|
MOVEMENT_ACTION_JUMP_2_LEFT,
|
|
|
|
MOVEMENT_ACTION_JUMP_2_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gJumpInPlaceMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_JUMP_IN_PLACE_DOWN,
|
|
|
|
MOVEMENT_ACTION_JUMP_IN_PLACE_DOWN,
|
|
|
|
MOVEMENT_ACTION_JUMP_IN_PLACE_UP,
|
|
|
|
MOVEMENT_ACTION_JUMP_IN_PLACE_LEFT,
|
|
|
|
MOVEMENT_ACTION_JUMP_IN_PLACE_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gJumpInPlaceTurnAroundMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_JUMP_IN_PLACE_UP_DOWN,
|
|
|
|
MOVEMENT_ACTION_JUMP_IN_PLACE_UP_DOWN,
|
|
|
|
MOVEMENT_ACTION_JUMP_IN_PLACE_DOWN_UP,
|
|
|
|
MOVEMENT_ACTION_JUMP_IN_PLACE_RIGHT_LEFT,
|
|
|
|
MOVEMENT_ACTION_JUMP_IN_PLACE_LEFT_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gJumpMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_JUMP_DOWN,
|
|
|
|
MOVEMENT_ACTION_JUMP_DOWN,
|
|
|
|
MOVEMENT_ACTION_JUMP_UP,
|
|
|
|
MOVEMENT_ACTION_JUMP_LEFT,
|
|
|
|
MOVEMENT_ACTION_JUMP_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gJumpSpecialMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_JUMP_SPECIAL_DOWN,
|
|
|
|
MOVEMENT_ACTION_JUMP_SPECIAL_DOWN,
|
|
|
|
MOVEMENT_ACTION_JUMP_SPECIAL_UP,
|
|
|
|
MOVEMENT_ACTION_JUMP_SPECIAL_LEFT,
|
|
|
|
MOVEMENT_ACTION_JUMP_SPECIAL_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gWalkInPlaceSlowMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_UP,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_LEFT,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gWalkInPlaceNormalMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_UP,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_LEFT,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gWalkInPlaceFastMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_FAST_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_FAST_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_FAST_UP,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_FAST_LEFT,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_FAST_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2021-11-04 18:54:34 +01:00
|
|
|
const u8 gWalkInPlaceFasterMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_DOWN,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_UP,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_LEFT,
|
|
|
|
MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gAcroWheelieFaceDirectionMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_FACE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_FACE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_FACE_UP,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_FACE_LEFT,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_FACE_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gAcroPopWheelieFaceDirectionMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_ACRO_POP_WHEELIE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_POP_WHEELIE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_POP_WHEELIE_UP,
|
|
|
|
MOVEMENT_ACTION_ACRO_POP_WHEELIE_LEFT,
|
|
|
|
MOVEMENT_ACTION_ACRO_POP_WHEELIE_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gAcroEndWheelieFaceDirectionMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_UP,
|
|
|
|
MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_LEFT,
|
|
|
|
MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gAcroWheelieHopFaceDirectionMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_UP,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_LEFT,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gAcroWheelieHopDirectionMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_HOP_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_HOP_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_HOP_UP,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_HOP_LEFT,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_HOP_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gAcroWheelieJumpDirectionMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_UP,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_LEFT,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gAcroWheelieInPlaceDirectionMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_UP,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_LEFT,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gAcroPopWheelieMoveDirectionMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_UP,
|
|
|
|
MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_LEFT,
|
|
|
|
MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gAcroWheelieMoveDirectionMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_UP,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_LEFT,
|
|
|
|
MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
2018-06-14 00:51:26 +02:00
|
|
|
const u8 gAcroEndWheelieMoveDirectionMovementActions[] = {
|
|
|
|
MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_DOWN,
|
|
|
|
MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_UP,
|
|
|
|
MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_LEFT,
|
|
|
|
MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_RIGHT,
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sOppositeDirections[] = {
|
2018-06-12 00:33:50 +02:00
|
|
|
DIR_NORTH,
|
|
|
|
DIR_SOUTH,
|
|
|
|
DIR_EAST,
|
|
|
|
DIR_WEST,
|
|
|
|
DIR_NORTHEAST,
|
|
|
|
DIR_NORTHWEST,
|
|
|
|
DIR_SOUTHEAST,
|
|
|
|
DIR_SOUTHWEST,
|
|
|
|
};
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
// Takes the player's original and current facing direction to get the direction that should be considered to copy.
|
|
|
|
// Note that this means an NPC who copies the player's movement changes how they copy them based on how
|
|
|
|
// the player entered the area. For instance an NPC who does the same movements as the player when they
|
|
|
|
// entered the area facing South will do the opposite movements as the player if they enter facing North.
|
|
|
|
static const u8 sPlayerDirectionsForCopy[][4] = {
|
|
|
|
[DIR_SOUTH - 1] = {
|
|
|
|
[DIR_SOUTH - 1] = DIR_NORTH,
|
|
|
|
[DIR_NORTH - 1] = DIR_SOUTH,
|
|
|
|
[DIR_WEST - 1] = DIR_EAST,
|
|
|
|
[DIR_EAST - 1] = DIR_WEST
|
|
|
|
},
|
|
|
|
[DIR_NORTH - 1] = {
|
|
|
|
[DIR_SOUTH - 1] = DIR_SOUTH,
|
|
|
|
[DIR_NORTH - 1] = DIR_NORTH,
|
|
|
|
[DIR_WEST - 1] = DIR_WEST,
|
|
|
|
[DIR_EAST - 1] = DIR_EAST
|
|
|
|
},
|
|
|
|
[DIR_WEST - 1] = {
|
|
|
|
[DIR_SOUTH - 1] = DIR_WEST,
|
|
|
|
[DIR_NORTH - 1] = DIR_EAST,
|
|
|
|
[DIR_WEST - 1] = DIR_NORTH,
|
|
|
|
[DIR_EAST - 1] = DIR_SOUTH
|
|
|
|
},
|
|
|
|
[DIR_EAST - 1] = {
|
|
|
|
[DIR_SOUTH - 1] = DIR_EAST,
|
|
|
|
[DIR_NORTH - 1] = DIR_WEST,
|
|
|
|
[DIR_WEST - 1] = DIR_SOUTH,
|
|
|
|
[DIR_EAST - 1] = DIR_NORTH
|
|
|
|
}
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
// Indexed first with the NPC's initial facing direction based on movement type, and secondly with the player direction to copy.
|
|
|
|
// Returns the direction the copy NPC should travel in.
|
|
|
|
static const u8 sPlayerDirectionToCopyDirection[][4] = {
|
|
|
|
[DIR_SOUTH - 1] = { // MOVEMENT_TYPE_COPY_PLAYER_OPPOSITE(_IN_GRASS)
|
|
|
|
[DIR_SOUTH - 1] = DIR_NORTH,
|
|
|
|
[DIR_NORTH - 1] = DIR_SOUTH,
|
|
|
|
[DIR_WEST - 1] = DIR_EAST,
|
|
|
|
[DIR_EAST - 1] = DIR_WEST
|
|
|
|
},
|
|
|
|
[DIR_NORTH - 1] = { // MOVEMENT_TYPE_COPY_PLAYER(_IN_GRASS)
|
|
|
|
[DIR_SOUTH - 1] = DIR_SOUTH,
|
|
|
|
[DIR_NORTH - 1] = DIR_NORTH,
|
|
|
|
[DIR_WEST - 1] = DIR_WEST,
|
|
|
|
[DIR_EAST - 1] = DIR_EAST
|
|
|
|
},
|
|
|
|
[DIR_WEST - 1] = { // MOVEMENT_TYPE_COPY_PLAYER_COUNTERCLOCKWISE(_IN_GRASS)
|
|
|
|
[DIR_SOUTH - 1] = DIR_EAST,
|
|
|
|
[DIR_NORTH - 1] = DIR_WEST,
|
|
|
|
[DIR_WEST - 1] = DIR_SOUTH,
|
|
|
|
[DIR_EAST - 1] = DIR_NORTH
|
|
|
|
},
|
|
|
|
[DIR_EAST - 1] = { // MOVEMENT_TYPE_COPY_PLAYER_CLOCKWISE(_IN_GRASS)
|
|
|
|
[DIR_SOUTH - 1] = DIR_WEST,
|
|
|
|
[DIR_NORTH - 1] = DIR_EAST,
|
|
|
|
[DIR_WEST - 1] = DIR_NORTH,
|
|
|
|
[DIR_EAST - 1] = DIR_SOUTH
|
|
|
|
}
|
2018-06-12 00:33:50 +02:00
|
|
|
};
|
|
|
|
|
2020-02-13 00:32:51 +01:00
|
|
|
#include "data/object_events/movement_action_func_tables.h"
|
2018-06-11 15:34:19 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void ClearObjectEvent(struct ObjectEvent *objectEvent)
|
2017-09-06 14:46:47 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
*objectEvent = (struct ObjectEvent){};
|
2021-11-15 16:57:22 +01:00
|
|
|
objectEvent->localId = OBJ_EVENT_ID_PLAYER;
|
2021-11-01 23:06:15 +01:00
|
|
|
objectEvent->mapNum = MAP_NUM(UNDEFINED);
|
|
|
|
objectEvent->mapGroup = MAP_GROUP(UNDEFINED);
|
|
|
|
objectEvent->movementActionId = MOVEMENT_ACTION_NONE;
|
2017-09-06 14:46:47 +02:00
|
|
|
}
|
2017-09-06 15:25:16 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void ClearAllObjectEvents(void)
|
2017-09-06 15:25:16 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2017-09-06 15:42:10 +02:00
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEvent(&gObjectEvents[i]);
|
2017-09-06 15:25:16 +02:00
|
|
|
}
|
2017-09-06 15:29:59 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void ResetObjectEvents(void)
|
2017-09-06 15:29:59 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearLinkPlayerObjectEvents();
|
|
|
|
ClearAllObjectEvents();
|
2017-09-06 15:29:59 +02:00
|
|
|
ClearPlayerAvatarInfo();
|
2018-10-17 02:11:44 +02:00
|
|
|
CreateReflectionEffectSprites();
|
2017-09-06 15:29:59 +02:00
|
|
|
}
|
2017-09-06 15:38:38 +02:00
|
|
|
|
2018-10-17 02:11:44 +02:00
|
|
|
static void CreateReflectionEffectSprites(void)
|
2017-09-06 15:38:38 +02:00
|
|
|
{
|
2020-06-20 01:58:56 +02:00
|
|
|
u8 spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_REFLECTION_DISTORTION], 0, 0, 31);
|
2019-12-05 03:00:45 +01:00
|
|
|
gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
|
2018-06-14 00:51:26 +02:00
|
|
|
InitSpriteAffineAnim(&gSprites[spriteId]);
|
|
|
|
StartSpriteAffineAnim(&gSprites[spriteId], 0);
|
2018-09-10 17:25:58 +02:00
|
|
|
gSprites[spriteId].invisible = TRUE;
|
2017-09-06 15:38:38 +02:00
|
|
|
|
2020-06-20 01:58:56 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_REFLECTION_DISTORTION], 0, 0, 31);
|
2019-12-05 03:00:45 +01:00
|
|
|
gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL;
|
2018-06-14 00:51:26 +02:00
|
|
|
InitSpriteAffineAnim(&gSprites[spriteId]);
|
|
|
|
StartSpriteAffineAnim(&gSprites[spriteId], 1);
|
2018-09-10 17:25:58 +02:00
|
|
|
gSprites[spriteId].invisible = TRUE;
|
2017-09-06 15:38:38 +02:00
|
|
|
}
|
2017-09-06 15:42:10 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 GetFirstInactiveObjectEventId(void)
|
2017-09-06 15:42:10 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2017-09-06 15:42:10 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!gObjectEvents[i].active)
|
2017-09-06 15:42:10 +02:00
|
|
|
break;
|
|
|
|
}
|
2018-06-14 00:51:26 +02:00
|
|
|
|
2017-09-06 15:42:10 +02:00
|
|
|
return i;
|
|
|
|
}
|
2017-09-06 15:49:51 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 GetObjectEventIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroupId)
|
2017-09-06 15:49:51 +02:00
|
|
|
{
|
2019-11-21 05:12:51 +01:00
|
|
|
if (localId < OBJ_EVENT_ID_PLAYER)
|
2019-11-21 04:55:44 +01:00
|
|
|
return GetObjectEventIdByLocalIdAndMapInternal(localId, mapNum, mapGroupId);
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return GetObjectEventIdByLocalId(localId);
|
2017-09-06 15:49:51 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 TryGetObjectEventIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroupId, u8 *objectEventId)
|
2017-09-06 15:49:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
*objectEventId = GetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroupId);
|
2019-11-21 05:12:51 +01:00
|
|
|
if (*objectEventId == OBJECT_EVENTS_COUNT)
|
2017-09-06 15:49:51 +02:00
|
|
|
return TRUE;
|
2018-06-14 00:51:26 +02:00
|
|
|
else
|
|
|
|
return FALSE;
|
2017-09-06 15:49:51 +02:00
|
|
|
}
|
2017-09-06 15:52:31 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 GetObjectEventIdByXY(s16 x, s16 y)
|
2017-09-06 15:52:31 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2017-09-06 15:52:31 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gObjectEvents[i].active && gObjectEvents[i].currentCoords.x == x && gObjectEvents[i].currentCoords.y == y)
|
2017-09-06 15:52:31 +02:00
|
|
|
break;
|
|
|
|
}
|
2018-06-14 00:51:26 +02:00
|
|
|
|
2017-09-06 15:52:31 +02:00
|
|
|
return i;
|
|
|
|
}
|
2017-09-06 16:48:51 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 GetObjectEventIdByLocalIdAndMapInternal(u8 localId, u8 mapNum, u8 mapGroupId)
|
2017-09-06 16:48:51 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2017-09-06 16:48:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gObjectEvents[i].active && gObjectEvents[i].localId == localId && gObjectEvents[i].mapNum == mapNum && gObjectEvents[i].mapGroup == mapGroupId)
|
2017-09-06 16:48:51 +02:00
|
|
|
return i;
|
|
|
|
}
|
2018-06-14 00:51:26 +02:00
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
return OBJECT_EVENTS_COUNT;
|
2017-09-06 16:48:51 +02:00
|
|
|
}
|
2017-09-06 20:25:17 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 GetObjectEventIdByLocalId(u8 localId)
|
2017-09-06 20:25:17 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2017-09-06 20:25:17 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gObjectEvents[i].active && gObjectEvents[i].localId == localId)
|
2017-09-06 20:25:17 +02:00
|
|
|
return i;
|
|
|
|
}
|
2018-06-14 00:51:26 +02:00
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
return OBJECT_EVENTS_COUNT;
|
2017-09-06 20:25:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 InitObjectEventStateFromTemplate(struct ObjectEventTemplate *template, u8 mapNum, u8 mapGroup)
|
2017-09-06 20:25:17 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEvent *objectEvent;
|
|
|
|
u8 objectEventId;
|
2017-09-17 17:39:49 +02:00
|
|
|
s16 x;
|
|
|
|
s16 y;
|
2017-09-06 20:25:17 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (GetAvailableObjectEventId(template->localId, mapNum, mapGroup, &objectEventId))
|
2019-11-21 05:12:51 +01:00
|
|
|
return OBJECT_EVENTS_COUNT;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
|
|
|
ClearObjectEvent(objectEvent);
|
2021-10-09 18:12:18 +02:00
|
|
|
x = template->x + MAP_OFFSET;
|
|
|
|
y = template->y + MAP_OFFSET;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->active = TRUE;
|
|
|
|
objectEvent->triggerGroundEffectsOnMove = TRUE;
|
|
|
|
objectEvent->graphicsId = template->graphicsId;
|
|
|
|
objectEvent->movementType = template->movementType;
|
|
|
|
objectEvent->localId = template->localId;
|
|
|
|
objectEvent->mapNum = mapNum;
|
|
|
|
objectEvent->mapGroup = mapGroup;
|
|
|
|
objectEvent->initialCoords.x = x;
|
|
|
|
objectEvent->initialCoords.y = y;
|
|
|
|
objectEvent->currentCoords.x = x;
|
|
|
|
objectEvent->currentCoords.y = y;
|
|
|
|
objectEvent->previousCoords.x = x;
|
|
|
|
objectEvent->previousCoords.y = y;
|
|
|
|
objectEvent->currentElevation = template->elevation;
|
|
|
|
objectEvent->previousElevation = template->elevation;
|
2020-09-18 00:24:11 +02:00
|
|
|
objectEvent->rangeX = template->movementRangeX;
|
|
|
|
objectEvent->rangeY = template->movementRangeY;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->trainerType = template->trainerType;
|
2020-10-19 12:19:21 +02:00
|
|
|
objectEvent->mapNum = mapNum;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->trainerRange_berryTreeId = template->trainerRange_berryTreeId;
|
|
|
|
objectEvent->previousMovementDirection = gInitialMovementTypeFacingDirections[template->movementType];
|
|
|
|
SetObjectEventDirection(objectEvent, objectEvent->previousMovementDirection);
|
|
|
|
SetObjectEventDynamicGraphicsId(objectEvent);
|
2021-11-01 23:06:15 +01:00
|
|
|
if (sMovementTypeHasRange[objectEvent->movementType])
|
2017-09-06 20:25:17 +02:00
|
|
|
{
|
2020-09-18 00:24:11 +02:00
|
|
|
if (objectEvent->rangeX == 0)
|
|
|
|
objectEvent->rangeX++;
|
|
|
|
if (objectEvent->rangeY == 0)
|
|
|
|
objectEvent->rangeY++;
|
2017-09-06 20:25:17 +02:00
|
|
|
}
|
2019-11-21 04:55:44 +01:00
|
|
|
return objectEventId;
|
2017-09-06 20:25:17 +02:00
|
|
|
}
|
2017-09-06 22:14:55 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 Unref_TryInitLocalObjectEvent(u8 localId)
|
2017-09-06 22:14:55 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventCount;
|
|
|
|
struct ObjectEventTemplate *template;
|
2017-09-06 22:14:55 +02:00
|
|
|
|
|
|
|
if (gMapHeader.events != NULL)
|
|
|
|
{
|
|
|
|
if (InBattlePyramid())
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventCount = GetNumBattlePyramidObjectEvents();
|
2017-09-06 22:14:55 +02:00
|
|
|
else if (InTrainerHill())
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventCount = 2;
|
2017-09-06 22:14:55 +02:00
|
|
|
else
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventCount = gMapHeader.events->objectEventCount;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
for (i = 0; i < objectEventCount; i++)
|
2017-09-06 22:14:55 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
template = &gSaveBlock1Ptr->objectEventTemplates[i];
|
2017-09-06 22:14:55 +02:00
|
|
|
if (template->localId == localId && !FlagGet(template->flagId))
|
2019-11-21 04:55:44 +01:00
|
|
|
return InitObjectEventStateFromTemplate(template, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
2017-09-06 22:14:55 +02:00
|
|
|
}
|
|
|
|
}
|
2019-11-21 05:12:51 +01:00
|
|
|
return OBJECT_EVENTS_COUNT;
|
2017-09-06 22:14:55 +02:00
|
|
|
}
|
2017-09-06 23:25:20 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static bool8 GetAvailableObjectEventId(u16 localId, u8 mapNum, u8 mapGroup, u8 *objectEventId)
|
2017-09-06 23:29:13 +02:00
|
|
|
// Looks for an empty slot.
|
|
|
|
// Returns FALSE and the location of the available slot
|
2019-11-21 04:55:44 +01:00
|
|
|
// in *objectEventId.
|
2017-09-06 23:29:13 +02:00
|
|
|
// If no slots are available, or if the object is already
|
|
|
|
// loaded, returns TRUE.
|
2017-09-06 23:25:20 +02:00
|
|
|
{
|
|
|
|
u8 i = 0;
|
|
|
|
|
2020-09-17 01:27:55 +02:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT && gObjectEvents[i].active; i++)
|
2017-09-06 23:25:20 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gObjectEvents[i].localId == localId && gObjectEvents[i].mapNum == mapNum && gObjectEvents[i].mapGroup == mapGroup)
|
2017-09-06 23:25:20 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-11-21 05:12:51 +01:00
|
|
|
if (i >= OBJECT_EVENTS_COUNT)
|
2017-09-06 23:25:20 +02:00
|
|
|
return TRUE;
|
2019-11-21 04:55:44 +01:00
|
|
|
*objectEventId = i;
|
2020-09-17 01:27:55 +02:00
|
|
|
for (; i < OBJECT_EVENTS_COUNT; i++)
|
2017-09-06 23:25:20 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gObjectEvents[i].active && gObjectEvents[i].localId == localId && gObjectEvents[i].mapNum == mapNum && gObjectEvents[i].mapGroup == mapGroup)
|
2017-09-06 23:25:20 +02:00
|
|
|
return TRUE;
|
2020-09-17 01:27:55 +02:00
|
|
|
}
|
2017-09-06 23:25:20 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-06 23:55:36 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void RemoveObjectEvent(struct ObjectEvent *objectEvent)
|
2017-09-06 23:55:36 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->active = FALSE;
|
|
|
|
RemoveObjectEventInternal(objectEvent);
|
2017-09-06 23:55:36 +02:00
|
|
|
}
|
2017-09-07 00:12:44 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void RemoveObjectEventByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
|
2017-09-07 00:12:44 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
2017-09-07 00:12:44 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
FlagSet(GetObjectEventFlagIdByObjectEventId(objectEventId));
|
|
|
|
RemoveObjectEvent(&gObjectEvents[objectEventId]);
|
2017-09-07 00:12:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void RemoveObjectEventInternal(struct ObjectEvent *objectEvent)
|
2017-09-07 00:12:44 +02:00
|
|
|
{
|
|
|
|
struct SpriteFrameImage image;
|
2019-11-21 04:55:44 +01:00
|
|
|
image.size = GetObjectEventGraphicsInfo(objectEvent->graphicsId)->size;
|
|
|
|
gSprites[objectEvent->spriteId].images = ℑ
|
|
|
|
DestroySprite(&gSprites[objectEvent->spriteId]);
|
2017-09-07 00:12:44 +02:00
|
|
|
}
|
2017-09-07 00:26:37 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void RemoveAllObjectEventsExceptPlayer(void)
|
2017-09-07 00:26:37 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2017-09-07 00:26:37 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (i != gPlayerAvatar.objectEventId)
|
|
|
|
RemoveObjectEvent(&gObjectEvents[i]);
|
2017-09-07 00:26:37 +02:00
|
|
|
}
|
|
|
|
}
|
2017-09-07 02:28:36 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 TrySetupObjectEventSprite(struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY)
|
2017-09-07 02:28:36 +02:00
|
|
|
{
|
2018-10-20 22:01:45 +02:00
|
|
|
u8 spriteId;
|
|
|
|
u8 paletteSlot;
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2018-10-20 22:01:45 +02:00
|
|
|
struct Sprite *sprite;
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEvent *objectEvent;
|
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2017-09-07 02:28:36 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventId = InitObjectEventStateFromTemplate(objectEventTemplate, mapNum, mapGroup);
|
2019-11-21 05:12:51 +01:00
|
|
|
if (objectEventId == OBJECT_EVENTS_COUNT)
|
|
|
|
return OBJECT_EVENTS_COUNT;
|
2018-06-14 00:51:26 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId);
|
2017-09-07 02:28:36 +02:00
|
|
|
paletteSlot = graphicsInfo->paletteSlot;
|
2022-09-28 02:16:48 +02:00
|
|
|
if (paletteSlot == PALSLOT_PLAYER)
|
2017-09-07 02:28:36 +02:00
|
|
|
{
|
2022-09-28 02:16:48 +02:00
|
|
|
LoadPlayerObjectReflectionPalette(graphicsInfo->paletteTag, paletteSlot);
|
2017-09-07 02:28:36 +02:00
|
|
|
}
|
2022-09-28 02:16:48 +02:00
|
|
|
else if (paletteSlot == PALSLOT_NPC_SPECIAL)
|
2017-09-07 02:28:36 +02:00
|
|
|
{
|
2022-09-28 02:16:48 +02:00
|
|
|
LoadSpecialObjectReflectionPalette(graphicsInfo->paletteTag, paletteSlot);
|
2017-09-07 02:28:36 +02:00
|
|
|
}
|
|
|
|
else if (paletteSlot >= 16)
|
|
|
|
{
|
|
|
|
paletteSlot -= 16;
|
2021-04-06 11:05:33 +02:00
|
|
|
_PatchObjectPalette(graphicsInfo->paletteTag, paletteSlot);
|
2017-09-07 02:28:36 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->movementType == MOVEMENT_TYPE_INVISIBLE)
|
|
|
|
objectEvent->invisible = TRUE;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2021-09-14 19:14:14 +02:00
|
|
|
*(u16 *)&spriteTemplate->paletteTag = TAG_NONE;
|
2017-09-07 02:28:36 +02:00
|
|
|
spriteId = CreateSprite(spriteTemplate, 0, 0, 0);
|
|
|
|
if (spriteId == MAX_SPRITES)
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gObjectEvents[objectEventId].active = FALSE;
|
2019-11-21 05:12:51 +01:00
|
|
|
return OBJECT_EVENTS_COUNT;
|
2017-09-07 02:28:36 +02:00
|
|
|
}
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2017-09-07 02:28:36 +02:00
|
|
|
sprite = &gSprites[spriteId];
|
2021-07-07 15:11:52 +02:00
|
|
|
GetMapCoordsFromSpritePos(objectEvent->currentCoords.x + cameraX, objectEvent->currentCoords.y + cameraY, &sprite->x, &sprite->y);
|
2017-09-07 02:28:36 +02:00
|
|
|
sprite->centerToCornerVecX = -(graphicsInfo->width >> 1);
|
|
|
|
sprite->centerToCornerVecY = -(graphicsInfo->height >> 1);
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x += 8;
|
|
|
|
sprite->y += 16 + sprite->centerToCornerVecY;
|
2017-09-07 02:28:36 +02:00
|
|
|
sprite->oam.paletteNum = paletteSlot;
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sObjEventId = objectEventId;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->spriteId = spriteId;
|
|
|
|
objectEvent->inanimate = graphicsInfo->inanimate;
|
|
|
|
if (!objectEvent->inanimate)
|
|
|
|
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(objectEvent->facingDirection));
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
SetObjectSubpriorityByElevation(objectEvent->previousElevation, sprite, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
UpdateObjectEventVisibility(objectEvent, sprite);
|
|
|
|
return objectEventId;
|
2017-09-07 02:28:36 +02:00
|
|
|
}
|
2017-09-07 03:46:53 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 TrySpawnObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY)
|
2017-09-07 03:46:53 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2017-09-07 03:46:53 +02:00
|
|
|
struct SpriteTemplate spriteTemplate;
|
|
|
|
struct SpriteFrameImage spriteFrameImage;
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2018-10-20 22:01:45 +02:00
|
|
|
const struct SubspriteTable *subspriteTables = NULL;
|
2017-09-07 03:46:53 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(objectEventTemplate->graphicsId);
|
2021-11-18 05:28:43 +01:00
|
|
|
MakeSpriteTemplateFromObjectEventTemplate(objectEventTemplate, &spriteTemplate, &subspriteTables);
|
2017-09-07 03:46:53 +02:00
|
|
|
spriteFrameImage.size = graphicsInfo->size;
|
|
|
|
spriteTemplate.images = &spriteFrameImage;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventId = TrySetupObjectEventSprite(objectEventTemplate, &spriteTemplate, mapNum, mapGroup, cameraX, cameraY);
|
2019-11-21 05:12:51 +01:00
|
|
|
if (objectEventId == OBJECT_EVENTS_COUNT)
|
|
|
|
return OBJECT_EVENTS_COUNT;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
gSprites[gObjectEvents[objectEventId].spriteId].images = graphicsInfo->images;
|
2019-04-05 23:11:24 +02:00
|
|
|
if (subspriteTables)
|
2019-11-21 04:55:44 +01:00
|
|
|
SetSubspriteTables(&gSprites[gObjectEvents[objectEventId].spriteId], subspriteTables);
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return objectEventId;
|
2017-09-07 03:46:53 +02:00
|
|
|
}
|
2017-09-07 04:00:51 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 SpawnSpecialObjectEvent(struct ObjectEventTemplate *objectEventTemplate)
|
2017-09-07 04:00:51 +02:00
|
|
|
{
|
|
|
|
s16 cameraX;
|
|
|
|
s16 cameraY;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
GetObjectEventMovingCameraOffset(&cameraX, &cameraY);
|
|
|
|
return TrySpawnObjectEventTemplate(objectEventTemplate, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, cameraX, cameraY);
|
2017-09-07 04:00:51 +02:00
|
|
|
}
|
2017-09-07 04:33:11 +02:00
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 localId, s16 x, s16 y, u8 elevation)
|
2017-09-07 04:33:11 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEventTemplate objectEventTemplate;
|
2017-09-07 04:33:11 +02:00
|
|
|
|
2021-10-09 18:12:18 +02:00
|
|
|
x -= MAP_OFFSET;
|
|
|
|
y -= MAP_OFFSET;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventTemplate.localId = localId;
|
|
|
|
objectEventTemplate.graphicsId = graphicsId;
|
2020-05-14 23:11:18 +02:00
|
|
|
objectEventTemplate.inConnection = 0;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventTemplate.x = x;
|
|
|
|
objectEventTemplate.y = y;
|
2022-01-21 18:48:19 +01:00
|
|
|
objectEventTemplate.elevation = elevation;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventTemplate.movementType = movementBehavior;
|
|
|
|
objectEventTemplate.movementRangeX = 0;
|
|
|
|
objectEventTemplate.movementRangeY = 0;
|
2020-04-21 21:53:48 +02:00
|
|
|
objectEventTemplate.trainerType = TRAINER_TYPE_NONE;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventTemplate.trainerRange_berryTreeId = 0;
|
|
|
|
return SpawnSpecialObjectEvent(&objectEventTemplate);
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 TrySpawnObjectEvent(u8 localId, u8 mapNum, u8 mapGroup)
|
|
|
|
{
|
|
|
|
struct ObjectEventTemplate *objectEventTemplate;
|
2019-04-05 23:11:24 +02:00
|
|
|
s16 cameraX, cameraY;
|
2017-09-07 04:33:11 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventTemplate = GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup);
|
|
|
|
if (!objectEventTemplate)
|
2019-11-21 05:12:51 +01:00
|
|
|
return OBJECT_EVENTS_COUNT;
|
2019-04-05 23:11:24 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
GetObjectEventMovingCameraOffset(&cameraX, &cameraY);
|
|
|
|
return TrySpawnObjectEventTemplate(objectEventTemplate, mapNum, mapGroup, cameraX, cameraY);
|
2017-09-07 04:33:11 +02:00
|
|
|
}
|
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
static void CopyObjectGraphicsInfoToSpriteTemplate(u16 graphicsId, void (*callback)(struct Sprite *), struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables)
|
2017-09-07 04:33:11 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(graphicsId);
|
2017-09-07 04:33:11 +02:00
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
spriteTemplate->tileTag = graphicsInfo->tileTag;
|
2020-11-23 20:12:07 +01:00
|
|
|
spriteTemplate->paletteTag = graphicsInfo->paletteTag;
|
2018-10-20 22:01:45 +02:00
|
|
|
spriteTemplate->oam = graphicsInfo->oam;
|
|
|
|
spriteTemplate->anims = graphicsInfo->anims;
|
|
|
|
spriteTemplate->images = graphicsInfo->images;
|
|
|
|
spriteTemplate->affineAnims = graphicsInfo->affineAnims;
|
|
|
|
spriteTemplate->callback = callback;
|
|
|
|
*subspriteTables = graphicsInfo->subspriteTables;
|
2017-09-07 04:33:11 +02:00
|
|
|
}
|
2017-09-07 04:46:44 +02:00
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
static void CopyObjectGraphicsInfoToSpriteTemplate_WithMovementType(u16 graphicsId, u16 movementType, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables)
|
2017-09-07 04:46:44 +02:00
|
|
|
{
|
2021-11-18 05:28:43 +01:00
|
|
|
CopyObjectGraphicsInfoToSpriteTemplate(graphicsId, sMovementTypeCallbacks[movementType], spriteTemplate, subspriteTables);
|
2017-09-07 04:46:44 +02:00
|
|
|
}
|
2017-09-07 20:16:30 +02:00
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
static void MakeSpriteTemplateFromObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables)
|
2017-09-07 20:16:30 +02:00
|
|
|
{
|
2021-11-18 05:28:43 +01:00
|
|
|
CopyObjectGraphicsInfoToSpriteTemplate_WithMovementType(objectEventTemplate->graphicsId, objectEventTemplate->movementType, spriteTemplate, subspriteTables);
|
2017-09-07 20:16:30 +02:00
|
|
|
}
|
2017-09-07 20:31:23 +02:00
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
// Used to create a sprite using a graphicsId associated with object events.
|
|
|
|
u8 CreateObjectGraphicsSprite(u16 graphicsId, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority)
|
2017-09-07 20:31:23 +02:00
|
|
|
{
|
|
|
|
struct SpriteTemplate *spriteTemplate;
|
|
|
|
const struct SubspriteTable *subspriteTables;
|
|
|
|
struct Sprite *sprite;
|
2018-10-20 22:01:45 +02:00
|
|
|
u8 spriteId;
|
2017-09-07 20:31:23 +02:00
|
|
|
|
2022-09-17 01:24:26 +02:00
|
|
|
spriteTemplate = Alloc(sizeof(struct SpriteTemplate));
|
2021-11-18 05:28:43 +01:00
|
|
|
CopyObjectGraphicsInfoToSpriteTemplate(graphicsId, callback, spriteTemplate, &subspriteTables);
|
2021-09-14 19:14:14 +02:00
|
|
|
if (spriteTemplate->paletteTag != TAG_NONE)
|
2019-11-21 04:55:44 +01:00
|
|
|
LoadObjectEventPalette(spriteTemplate->paletteTag);
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
spriteId = CreateSprite(spriteTemplate, x, y, subpriority);
|
2022-09-17 01:36:44 +02:00
|
|
|
Free(spriteTemplate);
|
2017-09-07 20:31:23 +02:00
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
if (spriteId != MAX_SPRITES && subspriteTables != NULL)
|
2017-09-07 20:31:23 +02:00
|
|
|
{
|
2018-10-20 22:01:45 +02:00
|
|
|
sprite = &gSprites[spriteId];
|
2017-09-07 20:31:23 +02:00
|
|
|
SetSubspriteTables(sprite, subspriteTables);
|
2019-12-05 03:00:45 +01:00
|
|
|
sprite->subspriteMode = SUBSPRITES_IGNORE_PRIORITY;
|
2017-09-07 20:31:23 +02:00
|
|
|
}
|
2018-10-20 22:01:45 +02:00
|
|
|
return spriteId;
|
2017-09-07 20:31:23 +02:00
|
|
|
}
|
2017-09-07 21:50:49 +02:00
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
#define sVirtualObjId data[0]
|
|
|
|
#define sVirtualObjElev data[1]
|
|
|
|
|
|
|
|
// "Virtual Objects" are a class of sprites used instead of a full object event.
|
|
|
|
// Used when more objects are needed than the object event limit (for Contest / Battle Dome audiences and group members in Union Room).
|
|
|
|
// A unique id is given as an argument and stored in the sprite data to allow referring back to the same virtual object.
|
|
|
|
// They can be turned (and, in the case of the Union Room, animated teleporting in and out) but do not have movement types
|
|
|
|
// or any of the other data normally associated with object events.
|
2022-01-21 18:48:19 +01:00
|
|
|
u8 CreateVirtualObject(u8 graphicsId, u8 virtualObjId, s16 x, s16 y, u8 elevation, u8 direction)
|
2017-09-07 21:50:49 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
struct Sprite *sprite;
|
2018-10-20 22:01:45 +02:00
|
|
|
struct SpriteTemplate spriteTemplate;
|
|
|
|
const struct SubspriteTable *subspriteTables;
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2017-09-07 21:50:49 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(graphicsId);
|
2021-11-18 05:28:43 +01:00
|
|
|
CopyObjectGraphicsInfoToSpriteTemplate(graphicsId, SpriteCB_VirtualObject, &spriteTemplate, &subspriteTables);
|
2021-09-14 19:14:14 +02:00
|
|
|
*(u16 *)&spriteTemplate.paletteTag = TAG_NONE;
|
2021-10-09 18:12:18 +02:00
|
|
|
x += MAP_OFFSET;
|
|
|
|
y += MAP_OFFSET;
|
2020-06-01 16:23:12 +02:00
|
|
|
SetSpritePosToOffsetMapCoords(&x, &y, 8, 16);
|
2017-09-07 21:50:49 +02:00
|
|
|
spriteId = CreateSpriteAtEnd(&spriteTemplate, x, y, 0);
|
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
{
|
|
|
|
sprite = &gSprites[spriteId];
|
|
|
|
sprite->centerToCornerVecX = -(graphicsInfo->width >> 1);
|
|
|
|
sprite->centerToCornerVecY = -(graphicsInfo->height >> 1);
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y += sprite->centerToCornerVecY;
|
2017-09-07 21:50:49 +02:00
|
|
|
sprite->oam.paletteNum = graphicsInfo->paletteSlot;
|
|
|
|
if (sprite->oam.paletteNum >= 16)
|
|
|
|
sprite->oam.paletteNum -= 16;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2017-09-07 21:50:49 +02:00
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
2021-11-18 05:28:43 +01:00
|
|
|
sprite->sVirtualObjId = virtualObjId;
|
2022-01-21 18:48:19 +01:00
|
|
|
sprite->sVirtualObjElev = elevation;
|
2022-09-28 02:16:48 +02:00
|
|
|
if (graphicsInfo->paletteSlot == PALSLOT_NPC_SPECIAL)
|
2020-11-23 20:12:07 +01:00
|
|
|
LoadSpecialObjectReflectionPalette(graphicsInfo->paletteTag, graphicsInfo->paletteSlot);
|
2017-09-07 21:50:49 +02:00
|
|
|
else if (graphicsInfo->paletteSlot >= 16)
|
2021-04-06 11:05:33 +02:00
|
|
|
_PatchObjectPalette(graphicsInfo->paletteTag, graphicsInfo->paletteSlot | 0xf0);
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2017-09-07 21:50:49 +02:00
|
|
|
if (subspriteTables != NULL)
|
|
|
|
{
|
|
|
|
SetSubspriteTables(sprite, subspriteTables);
|
2019-12-05 03:00:45 +01:00
|
|
|
sprite->subspriteMode = SUBSPRITES_IGNORE_PRIORITY;
|
2017-09-07 21:50:49 +02:00
|
|
|
}
|
2022-01-21 18:48:19 +01:00
|
|
|
InitObjectPriorityByElevation(sprite, elevation);
|
|
|
|
SetObjectSubpriorityByElevation(elevation, sprite, 1);
|
2018-06-14 00:51:26 +02:00
|
|
|
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(direction));
|
2017-09-07 21:50:49 +02:00
|
|
|
}
|
|
|
|
return spriteId;
|
|
|
|
}
|
2017-09-07 21:58:38 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void TrySpawnObjectEvents(s16 cameraX, s16 cameraY)
|
2017-09-07 21:58:38 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
u8 objectCount;
|
|
|
|
|
|
|
|
if (gMapHeader.events != NULL)
|
|
|
|
{
|
2018-10-20 22:01:45 +02:00
|
|
|
s16 left = gSaveBlock1Ptr->pos.x - 2;
|
2021-10-09 18:12:18 +02:00
|
|
|
s16 right = gSaveBlock1Ptr->pos.x + MAP_OFFSET_W + 2;
|
2018-10-20 22:01:45 +02:00
|
|
|
s16 top = gSaveBlock1Ptr->pos.y;
|
2021-10-09 18:12:18 +02:00
|
|
|
s16 bottom = gSaveBlock1Ptr->pos.y + MAP_OFFSET_H + 2;
|
2017-09-07 21:58:38 +02:00
|
|
|
|
|
|
|
if (InBattlePyramid())
|
2019-11-21 04:55:44 +01:00
|
|
|
objectCount = GetNumBattlePyramidObjectEvents();
|
2017-09-07 21:58:38 +02:00
|
|
|
else if (InTrainerHill())
|
|
|
|
objectCount = 2;
|
|
|
|
else
|
2019-11-21 04:55:44 +01:00
|
|
|
objectCount = gMapHeader.events->objectEventCount;
|
2017-09-07 21:58:38 +02:00
|
|
|
|
|
|
|
for (i = 0; i < objectCount; i++)
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEventTemplate *template = &gSaveBlock1Ptr->objectEventTemplates[i];
|
2021-10-09 18:12:18 +02:00
|
|
|
s16 npcX = template->x + MAP_OFFSET;
|
|
|
|
s16 npcY = template->y + MAP_OFFSET;
|
2017-09-07 21:58:38 +02:00
|
|
|
|
|
|
|
if (top <= npcY && bottom >= npcY && left <= npcX && right >= npcX
|
|
|
|
&& !FlagGet(template->flagId))
|
2019-11-21 04:55:44 +01:00
|
|
|
TrySpawnObjectEventTemplate(template, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, cameraX, cameraY);
|
2017-09-07 21:58:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-07 22:09:59 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void RemoveObjectEventsOutsideView(void)
|
2017-09-07 22:09:59 +02:00
|
|
|
{
|
2018-10-20 22:01:45 +02:00
|
|
|
u8 i, j;
|
2017-09-07 22:09:59 +02:00
|
|
|
bool8 isActiveLinkPlayer;
|
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2017-09-07 22:09:59 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
for (j = 0, isActiveLinkPlayer = FALSE; j < ARRAY_COUNT(gLinkPlayerObjectEvents); j++)
|
2017-09-07 22:09:59 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gLinkPlayerObjectEvents[j].active && i == gLinkPlayerObjectEvents[j].objEventId)
|
2017-09-07 22:09:59 +02:00
|
|
|
isActiveLinkPlayer = TRUE;
|
|
|
|
}
|
|
|
|
if (!isActiveLinkPlayer)
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEvent *objectEvent = &gObjectEvents[i];
|
2017-09-07 22:09:59 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->active && !objectEvent->isPlayer)
|
|
|
|
RemoveObjectEventIfOutsideView(objectEvent);
|
2017-09-07 22:09:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-07 23:41:56 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void RemoveObjectEventIfOutsideView(struct ObjectEvent *objectEvent)
|
2017-09-07 23:41:56 +02:00
|
|
|
{
|
2018-10-17 14:52:26 +02:00
|
|
|
s16 left = gSaveBlock1Ptr->pos.x - 2;
|
|
|
|
s16 right = gSaveBlock1Ptr->pos.x + 17;
|
|
|
|
s16 top = gSaveBlock1Ptr->pos.y;
|
|
|
|
s16 bottom = gSaveBlock1Ptr->pos.y + 16;
|
2017-09-08 03:17:55 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->currentCoords.x >= left && objectEvent->currentCoords.x <= right
|
|
|
|
&& objectEvent->currentCoords.y >= top && objectEvent->currentCoords.y <= bottom)
|
2017-09-07 23:41:56 +02:00
|
|
|
return;
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->initialCoords.x >= left && objectEvent->initialCoords.x <= right
|
|
|
|
&& objectEvent->initialCoords.y >= top && objectEvent->initialCoords.y <= bottom)
|
2017-09-07 23:41:56 +02:00
|
|
|
return;
|
2019-11-21 04:55:44 +01:00
|
|
|
RemoveObjectEvent(objectEvent);
|
2017-09-07 23:41:56 +02:00
|
|
|
}
|
2017-09-08 00:54:51 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
void SpawnObjectEventsOnReturnToField(s16 x, s16 y)
|
2017-09-08 00:54:51 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
ClearPlayerAvatarInfo();
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2017-09-08 00:54:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gObjectEvents[i].active)
|
2021-04-06 11:05:33 +02:00
|
|
|
SpawnObjectEventOnReturnToField(i, x, y);
|
2017-09-08 00:54:51 +02:00
|
|
|
}
|
2018-10-17 02:11:44 +02:00
|
|
|
CreateReflectionEffectSprites();
|
2017-09-08 00:54:51 +02:00
|
|
|
}
|
2017-09-08 01:28:46 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void SpawnObjectEventOnReturnToField(u8 objectEventId, s16 x, s16 y)
|
2017-09-08 01:28:46 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
u8 i;
|
2017-09-08 01:28:46 +02:00
|
|
|
u8 paletteSlot;
|
2018-10-20 22:01:45 +02:00
|
|
|
struct Sprite *sprite;
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEvent *objectEvent;
|
2018-10-20 22:01:45 +02:00
|
|
|
struct SpriteTemplate spriteTemplate;
|
|
|
|
struct SpriteFrameImage spriteFrameImage;
|
2017-09-08 01:28:46 +02:00
|
|
|
const struct SubspriteTable *subspriteTables;
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2017-09-08 01:28:46 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
for (i = 0; i < ARRAY_COUNT(gLinkPlayerObjectEvents); i++)
|
2017-09-08 01:28:46 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gLinkPlayerObjectEvents[i].active && objectEventId == gLinkPlayerObjectEvents[i].objEventId)
|
2017-09-08 01:28:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
2017-09-08 01:28:46 +02:00
|
|
|
subspriteTables = NULL;
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId);
|
2017-09-08 01:28:46 +02:00
|
|
|
spriteFrameImage.size = graphicsInfo->size;
|
2021-11-18 05:28:43 +01:00
|
|
|
CopyObjectGraphicsInfoToSpriteTemplate_WithMovementType(objectEvent->graphicsId, objectEvent->movementType, &spriteTemplate, &subspriteTables);
|
2017-09-08 01:28:46 +02:00
|
|
|
spriteTemplate.images = &spriteFrameImage;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2021-09-14 19:14:14 +02:00
|
|
|
*(u16 *)&spriteTemplate.paletteTag = TAG_NONE;
|
2017-09-08 01:28:46 +02:00
|
|
|
paletteSlot = graphicsInfo->paletteSlot;
|
2022-09-28 02:16:48 +02:00
|
|
|
if (paletteSlot == PALSLOT_PLAYER)
|
2017-09-08 01:28:46 +02:00
|
|
|
{
|
2020-11-23 20:12:07 +01:00
|
|
|
LoadPlayerObjectReflectionPalette(graphicsInfo->paletteTag, graphicsInfo->paletteSlot);
|
2017-09-08 01:28:46 +02:00
|
|
|
}
|
2022-09-28 02:16:48 +02:00
|
|
|
else if (paletteSlot == PALSLOT_NPC_SPECIAL)
|
2017-09-08 01:28:46 +02:00
|
|
|
{
|
2020-11-23 20:12:07 +01:00
|
|
|
LoadSpecialObjectReflectionPalette(graphicsInfo->paletteTag, graphicsInfo->paletteSlot);
|
2017-09-08 01:28:46 +02:00
|
|
|
}
|
|
|
|
else if (paletteSlot >= 16)
|
|
|
|
{
|
|
|
|
paletteSlot -= 16;
|
2021-04-06 11:05:33 +02:00
|
|
|
_PatchObjectPalette(graphicsInfo->paletteTag, paletteSlot);
|
2017-09-08 01:28:46 +02:00
|
|
|
}
|
2021-09-14 19:14:14 +02:00
|
|
|
*(u16 *)&spriteTemplate.paletteTag = TAG_NONE;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
|
|
|
i = CreateSprite(&spriteTemplate, 0, 0, 0);
|
|
|
|
if (i != MAX_SPRITES)
|
2017-09-08 01:28:46 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite = &gSprites[i];
|
2021-07-07 15:11:52 +02:00
|
|
|
GetMapCoordsFromSpritePos(x + objectEvent->currentCoords.x, y + objectEvent->currentCoords.y, &sprite->x, &sprite->y);
|
2017-09-08 01:28:46 +02:00
|
|
|
sprite->centerToCornerVecX = -(graphicsInfo->width >> 1);
|
|
|
|
sprite->centerToCornerVecY = -(graphicsInfo->height >> 1);
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x += 8;
|
|
|
|
sprite->y += 16 + sprite->centerToCornerVecY;
|
2017-09-08 01:28:46 +02:00
|
|
|
sprite->images = graphicsInfo->images;
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->movementType == MOVEMENT_TYPE_PLAYER)
|
2017-09-08 01:28:46 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
SetPlayerAvatarObjectEventIdAndObjectId(objectEventId, i);
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->warpArrowSpriteId = CreateWarpArrowSprite();
|
2017-09-08 01:28:46 +02:00
|
|
|
}
|
|
|
|
if (subspriteTables != NULL)
|
|
|
|
SetSubspriteTables(sprite, subspriteTables);
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2017-09-08 01:28:46 +02:00
|
|
|
sprite->oam.paletteNum = paletteSlot;
|
|
|
|
sprite->coordOffsetEnabled = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sObjEventId = objectEventId;
|
|
|
|
objectEvent->spriteId = i;
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!objectEvent->inanimate && objectEvent->movementType != MOVEMENT_TYPE_PLAYER)
|
|
|
|
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
|
|
|
|
ResetObjectEventFldEffData(objectEvent);
|
2022-01-21 18:48:19 +01:00
|
|
|
SetObjectSubpriorityByElevation(objectEvent->previousElevation, sprite, 1);
|
2017-09-08 01:28:46 +02:00
|
|
|
}
|
|
|
|
}
|
2017-09-08 01:45:30 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void ResetObjectEventFldEffData(struct ObjectEvent *objectEvent)
|
2017-09-08 01:45:30 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
|
|
|
objectEvent->triggerGroundEffectsOnMove = TRUE;
|
|
|
|
objectEvent->hasShadow = FALSE;
|
|
|
|
objectEvent->hasReflection = FALSE;
|
|
|
|
objectEvent->inShortGrass = FALSE;
|
|
|
|
objectEvent->inShallowFlowingWater = FALSE;
|
|
|
|
objectEvent->inSandPile = FALSE;
|
|
|
|
objectEvent->inHotSprings = FALSE;
|
|
|
|
ObjectEventClearHeldMovement(objectEvent);
|
2017-09-08 01:45:30 +02:00
|
|
|
}
|
2017-09-08 02:04:59 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void SetPlayerAvatarObjectEventIdAndObjectId(u8 objectEventId, u8 spriteId)
|
2017-09-08 02:04:59 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gPlayerAvatar.objectEventId = objectEventId;
|
2017-09-08 02:04:59 +02:00
|
|
|
gPlayerAvatar.spriteId = spriteId;
|
2019-11-21 04:55:44 +01:00
|
|
|
gPlayerAvatar.gender = GetPlayerAvatarGenderByGraphicsId(gObjectEvents[objectEventId].graphicsId);
|
2021-10-26 19:27:20 +02:00
|
|
|
SetPlayerAvatarExtraStateTransition(gObjectEvents[objectEventId].graphicsId, PLAYER_AVATAR_FLAG_CONTROLLABLE);
|
2017-09-08 02:04:59 +02:00
|
|
|
}
|
2017-09-08 03:04:32 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void ObjectEventSetGraphicsId(struct ObjectEvent *objectEvent, u8 graphicsId)
|
2017-09-08 03:04:32 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2017-09-08 03:04:32 +02:00
|
|
|
struct Sprite *sprite;
|
|
|
|
u8 paletteSlot;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(graphicsId);
|
|
|
|
sprite = &gSprites[objectEvent->spriteId];
|
2017-09-08 03:04:32 +02:00
|
|
|
paletteSlot = graphicsInfo->paletteSlot;
|
2022-09-28 02:16:48 +02:00
|
|
|
if (paletteSlot == PALSLOT_PLAYER)
|
2017-09-08 03:04:32 +02:00
|
|
|
{
|
2020-11-23 20:12:07 +01:00
|
|
|
PatchObjectPalette(graphicsInfo->paletteTag, graphicsInfo->paletteSlot);
|
2017-09-08 03:04:32 +02:00
|
|
|
}
|
2022-09-28 02:16:48 +02:00
|
|
|
else if (paletteSlot == PALSLOT_NPC_SPECIAL)
|
2017-09-08 03:04:32 +02:00
|
|
|
{
|
2020-11-23 20:12:07 +01:00
|
|
|
LoadSpecialObjectReflectionPalette(graphicsInfo->paletteTag, graphicsInfo->paletteSlot);
|
2017-09-08 03:04:32 +02:00
|
|
|
}
|
|
|
|
else if (paletteSlot >= 16)
|
|
|
|
{
|
|
|
|
paletteSlot -= 16;
|
2021-04-06 11:05:33 +02:00
|
|
|
_PatchObjectPalette(graphicsInfo->paletteTag, paletteSlot);
|
2017-09-08 03:04:32 +02:00
|
|
|
}
|
|
|
|
sprite->oam.shape = graphicsInfo->oam->shape;
|
|
|
|
sprite->oam.size = graphicsInfo->oam->size;
|
|
|
|
sprite->images = graphicsInfo->images;
|
|
|
|
sprite->anims = graphicsInfo->anims;
|
|
|
|
sprite->subspriteTables = graphicsInfo->subspriteTables;
|
|
|
|
sprite->oam.paletteNum = paletteSlot;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->inanimate = graphicsInfo->inanimate;
|
|
|
|
objectEvent->graphicsId = graphicsId;
|
2021-07-07 15:11:52 +02:00
|
|
|
SetSpritePosToMapCoords(objectEvent->currentCoords.x, objectEvent->currentCoords.y, &sprite->x, &sprite->y);
|
2017-09-08 03:04:32 +02:00
|
|
|
sprite->centerToCornerVecX = -(graphicsInfo->width >> 1);
|
|
|
|
sprite->centerToCornerVecY = -(graphicsInfo->height >> 1);
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x += 8;
|
|
|
|
sprite->y += 16 + sprite->centerToCornerVecY;
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->trackedByCamera)
|
2017-09-08 03:04:32 +02:00
|
|
|
CameraObjectReset1();
|
|
|
|
}
|
2017-09-08 03:17:55 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void ObjectEventSetGraphicsIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, u8 graphicsId)
|
2017-09-08 03:17:55 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2017-09-08 03:17:55 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
|
|
|
ObjectEventSetGraphicsId(&gObjectEvents[objectEventId], graphicsId);
|
2017-09-08 03:17:55 +02:00
|
|
|
}
|
2017-09-08 19:41:55 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void ObjectEventTurn(struct ObjectEvent *objectEvent, u8 direction)
|
2017-09-08 19:41:55 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
|
|
|
if (!objectEvent->inanimate)
|
2017-09-08 19:41:55 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnim(&gSprites[objectEvent->spriteId], GetFaceDirectionAnimNum(objectEvent->facingDirection));
|
|
|
|
SeekSpriteAnim(&gSprites[objectEvent->spriteId], 0);
|
2017-09-08 19:41:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void ObjectEventTurnByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, u8 direction)
|
2017-09-08 19:41:55 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2017-09-08 19:41:55 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
|
|
|
ObjectEventTurn(&gObjectEvents[objectEventId], direction);
|
2017-09-08 19:41:55 +02:00
|
|
|
}
|
2017-09-08 19:46:21 +02:00
|
|
|
|
|
|
|
void PlayerObjectTurn(struct PlayerAvatar *playerAvatar, u8 direction)
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventTurn(&gObjectEvents[playerAvatar->objectEventId], direction);
|
2017-09-08 19:46:21 +02:00
|
|
|
}
|
2017-09-08 20:05:45 +02:00
|
|
|
|
2021-01-26 11:16:01 +01:00
|
|
|
static void SetBerryTreeGraphics(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-08 20:05:45 +02:00
|
|
|
{
|
|
|
|
u8 berryStage;
|
|
|
|
u8 berryId;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->invisible = TRUE;
|
2017-09-08 20:05:45 +02:00
|
|
|
sprite->invisible = TRUE;
|
2019-11-21 04:55:44 +01:00
|
|
|
berryStage = GetStageByBerryTreeId(objectEvent->trainerRange_berryTreeId);
|
2021-01-26 11:16:01 +01:00
|
|
|
if (berryStage != BERRY_STAGE_NO_BERRY)
|
2017-09-08 20:05:45 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->invisible = FALSE;
|
2017-09-08 20:05:45 +02:00
|
|
|
sprite->invisible = FALSE;
|
2019-11-21 04:55:44 +01:00
|
|
|
berryId = GetBerryTypeByBerryTreeId(objectEvent->trainerRange_berryTreeId) - 1;
|
2018-10-20 22:01:45 +02:00
|
|
|
berryStage--;
|
2019-04-14 13:22:37 +02:00
|
|
|
if (berryId > ITEM_TO_BERRY(LAST_BERRY_INDEX))
|
2017-09-08 20:05:45 +02:00
|
|
|
berryId = 0;
|
2019-04-14 13:22:37 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetGraphicsId(objectEvent, gBerryTreeObjectEventGraphicsIdTablePointers[berryId][berryStage]);
|
2017-09-08 20:05:45 +02:00
|
|
|
sprite->images = gBerryTreePicTablePointers[berryId];
|
|
|
|
sprite->oam.paletteNum = gBerryTreePaletteSlotTablePointers[berryId][berryStage];
|
|
|
|
StartSpriteAnim(sprite, berryStage);
|
|
|
|
}
|
|
|
|
}
|
2017-09-08 20:16:44 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *GetObjectEventGraphicsInfo(u8 graphicsId)
|
2017-09-08 20:16:44 +02:00
|
|
|
{
|
|
|
|
u8 bard;
|
|
|
|
|
2020-01-18 00:34:37 +01:00
|
|
|
if (graphicsId >= OBJ_EVENT_GFX_VARS)
|
2020-01-20 02:21:53 +01:00
|
|
|
graphicsId = VarGetObjectEventGraphicsId(graphicsId - OBJ_EVENT_GFX_VARS);
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
if (graphicsId == OBJ_EVENT_GFX_BARD)
|
2017-09-08 20:16:44 +02:00
|
|
|
{
|
2018-05-08 00:11:20 +02:00
|
|
|
bard = GetCurrentMauvilleOldMan();
|
2017-09-08 20:16:44 +02:00
|
|
|
return gMauvilleOldManGraphicsInfoPointers[bard];
|
|
|
|
}
|
2020-01-18 00:34:37 +01:00
|
|
|
|
|
|
|
if (graphicsId >= NUM_OBJ_EVENT_GFX)
|
2019-11-21 05:12:51 +01:00
|
|
|
graphicsId = OBJ_EVENT_GFX_NINJA_BOY;
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return gObjectEventGraphicsInfoPointers[graphicsId];
|
2017-09-08 20:16:44 +02:00
|
|
|
}
|
2017-09-08 20:20:13 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void SetObjectEventDynamicGraphicsId(struct ObjectEvent *objectEvent)
|
2017-09-08 20:20:13 +02:00
|
|
|
{
|
2020-01-20 02:21:53 +01:00
|
|
|
if (objectEvent->graphicsId >= OBJ_EVENT_GFX_VARS)
|
|
|
|
objectEvent->graphicsId = VarGetObjectEventGraphicsId(objectEvent->graphicsId - OBJ_EVENT_GFX_VARS);
|
2017-09-08 20:20:13 +02:00
|
|
|
}
|
2017-09-08 20:36:58 +02:00
|
|
|
|
2021-01-26 08:16:26 +01:00
|
|
|
void SetObjectInvisibility(u8 localId, u8 mapNum, u8 mapGroup, bool8 invisible)
|
2017-09-08 20:36:58 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2017-09-08 20:36:58 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
2021-01-26 08:16:26 +01:00
|
|
|
gObjectEvents[objectEventId].invisible = invisible;
|
2017-09-08 20:36:58 +02:00
|
|
|
}
|
2017-09-08 20:40:34 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void ObjectEventGetLocalIdAndMap(struct ObjectEvent *objectEvent, void *localId, void *mapNum, void *mapGroup)
|
2017-09-08 20:40:34 +02:00
|
|
|
{
|
2022-07-29 16:17:58 +02:00
|
|
|
*(u8 *)(localId) = objectEvent->localId;
|
|
|
|
*(u8 *)(mapNum) = objectEvent->mapNum;
|
|
|
|
*(u8 *)(mapGroup) = objectEvent->mapGroup;
|
2017-09-08 20:40:34 +02:00
|
|
|
}
|
2017-09-08 20:53:00 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
void AllowObjectAtPosTriggerGroundEffects(s16 x, s16 y)
|
2017-09-08 20:53:00 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
struct ObjectEvent *objectEvent;
|
2017-09-08 20:53:00 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventId = GetObjectEventIdByXY(x, y);
|
2019-11-21 05:12:51 +01:00
|
|
|
if (objectEventId != OBJECT_EVENTS_COUNT)
|
2017-09-08 20:53:00 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
|
|
|
objectEvent->triggerGroundEffectsOnMove = TRUE;
|
2017-09-08 20:53:00 +02:00
|
|
|
}
|
|
|
|
}
|
2017-09-08 20:58:17 +02:00
|
|
|
|
2021-11-17 23:15:45 +01:00
|
|
|
void SetObjectSubpriority(u8 localId, u8 mapNum, u8 mapGroup, u8 subpriority)
|
2017-09-08 20:58:17 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
struct ObjectEvent *objectEvent;
|
2017-09-08 20:58:17 +02:00
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
2017-09-08 20:58:17 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
|
|
|
sprite = &gSprites[objectEvent->spriteId];
|
|
|
|
objectEvent->fixedPriority = TRUE;
|
2017-09-08 20:58:17 +02:00
|
|
|
sprite->subpriority = subpriority;
|
|
|
|
}
|
|
|
|
}
|
2017-09-08 21:05:04 +02:00
|
|
|
|
2021-11-17 23:15:45 +01:00
|
|
|
void ResetObjectSubpriority(u8 localId, u8 mapNum, u8 mapGroup)
|
2017-09-08 21:05:04 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
struct ObjectEvent *objectEvent;
|
2017-09-08 21:05:04 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
2017-09-08 21:05:04 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent = &gObjectEvents[objectEventId];
|
|
|
|
objectEvent->fixedPriority = FALSE;
|
|
|
|
objectEvent->triggerGroundEffectsOnMove = TRUE;
|
2017-09-08 21:05:04 +02:00
|
|
|
}
|
|
|
|
}
|
2017-09-08 21:08:10 +02:00
|
|
|
|
2020-07-02 10:59:52 +02:00
|
|
|
void SetObjectEventSpritePosByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y)
|
2017-09-08 21:08:10 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2017-09-08 21:08:10 +02:00
|
|
|
struct Sprite *sprite;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
2017-09-08 21:08:10 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
sprite = &gSprites[gObjectEvents[objectEventId].spriteId];
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 = x;
|
|
|
|
sprite->y2 = y;
|
2017-09-08 21:08:10 +02:00
|
|
|
}
|
|
|
|
}
|
2017-09-08 21:11:29 +02:00
|
|
|
|
2018-09-03 00:20:45 +02:00
|
|
|
void FreeAndReserveObjectSpritePalettes(void)
|
2017-09-08 21:11:29 +02:00
|
|
|
{
|
|
|
|
FreeAllSpritePalettes();
|
2022-09-28 02:16:48 +02:00
|
|
|
gReservedSpritePaletteCount = OBJ_PALSLOT_COUNT;
|
2017-09-08 21:11:29 +02:00
|
|
|
}
|
2017-09-08 21:18:03 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void LoadObjectEventPalette(u16 paletteTag)
|
2017-09-08 21:18:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u16 i = FindObjectEventPaletteIndexByTag(paletteTag);
|
2017-09-08 21:18:03 +02:00
|
|
|
|
2023-01-18 16:33:39 +01:00
|
|
|
// FindObjectEventPaletteIndexByTag returns 0xFF on failure, not OBJ_EVENT_PAL_TAG_NONE.
|
|
|
|
#ifdef BUGFIX
|
|
|
|
if (i != 0xFF)
|
|
|
|
#else
|
|
|
|
if (i != OBJ_EVENT_PAL_TAG_NONE)
|
|
|
|
#endif
|
2021-04-06 11:05:33 +02:00
|
|
|
LoadSpritePaletteIfTagExists(&sObjectEventSpritePalettes[i]);
|
2017-09-08 21:18:03 +02:00
|
|
|
}
|
2017-09-08 21:21:32 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
// Unused
|
|
|
|
static void LoadObjectEventPaletteSet(u16 *paletteTags)
|
2017-09-08 21:21:32 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; paletteTags[i] != OBJ_EVENT_PAL_TAG_NONE; i++)
|
2019-11-21 04:55:44 +01:00
|
|
|
LoadObjectEventPalette(paletteTags[i]);
|
2017-09-08 21:21:32 +02:00
|
|
|
}
|
2017-09-08 21:27:08 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static u8 LoadSpritePaletteIfTagExists(const struct SpritePalette *spritePalette)
|
2017-09-08 21:27:08 +02:00
|
|
|
{
|
2018-12-05 15:31:01 +01:00
|
|
|
if (IndexOfSpritePaletteTag(spritePalette->tag) != 0xFF)
|
|
|
|
return 0xFF;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2017-09-08 21:27:08 +02:00
|
|
|
return LoadSpritePalette(spritePalette);
|
|
|
|
}
|
2017-09-08 23:17:03 +02:00
|
|
|
|
2018-09-03 00:20:45 +02:00
|
|
|
void PatchObjectPalette(u16 paletteTag, u8 paletteSlot)
|
2017-09-08 23:17:03 +02:00
|
|
|
{
|
2023-01-18 16:33:39 +01:00
|
|
|
// paletteTag is assumed to exist in sObjectEventSpritePalettes
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 paletteIndex = FindObjectEventPaletteIndexByTag(paletteTag);
|
2017-09-08 23:17:03 +02:00
|
|
|
|
2022-08-19 16:29:35 +02:00
|
|
|
LoadPalette(sObjectEventSpritePalettes[paletteIndex].data, OBJ_PLTT_ID(paletteSlot), PLTT_SIZE_4BPP);
|
2017-09-08 23:17:03 +02:00
|
|
|
}
|
2017-09-08 23:21:58 +02:00
|
|
|
|
2018-09-03 00:20:45 +02:00
|
|
|
void PatchObjectPaletteRange(const u16 *paletteTags, u8 minSlot, u8 maxSlot)
|
2017-09-08 23:21:58 +02:00
|
|
|
{
|
|
|
|
while (minSlot < maxSlot)
|
|
|
|
{
|
2018-09-03 00:20:45 +02:00
|
|
|
PatchObjectPalette(*paletteTags, minSlot);
|
2018-06-14 00:51:26 +02:00
|
|
|
paletteTags++;
|
|
|
|
minSlot++;
|
2017-09-08 23:21:58 +02:00
|
|
|
}
|
|
|
|
}
|
2017-09-08 23:34:12 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 FindObjectEventPaletteIndexByTag(u16 tag)
|
2017-09-08 23:34:12 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; sObjectEventSpritePalettes[i].tag != OBJ_EVENT_PAL_TAG_NONE; i++)
|
2017-09-08 23:34:12 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (sObjectEventSpritePalettes[i].tag == tag)
|
2017-09-08 23:34:12 +02:00
|
|
|
return i;
|
|
|
|
}
|
2018-12-05 15:31:01 +01:00
|
|
|
return 0xFF;
|
2017-09-08 23:34:12 +02:00
|
|
|
}
|
2017-09-08 23:58:41 +02:00
|
|
|
|
2018-09-03 00:20:45 +02:00
|
|
|
void LoadPlayerObjectReflectionPalette(u16 tag, u8 slot)
|
2017-09-08 23:58:41 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2018-09-03 00:20:45 +02:00
|
|
|
PatchObjectPalette(tag, slot);
|
2020-11-23 20:12:07 +01:00
|
|
|
for (i = 0; sPlayerReflectionPaletteSets[i].tag != OBJ_EVENT_PAL_TAG_NONE; i++)
|
2017-09-08 23:58:41 +02:00
|
|
|
{
|
2020-11-23 20:12:07 +01:00
|
|
|
if (sPlayerReflectionPaletteSets[i].tag == tag)
|
2017-09-08 23:58:41 +02:00
|
|
|
{
|
2020-11-23 20:12:07 +01:00
|
|
|
PatchObjectPalette(sPlayerReflectionPaletteSets[i].data[sCurrentReflectionType], gReflectionEffectPaletteMap[slot]);
|
2017-09-08 23:58:41 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-09 00:04:23 +02:00
|
|
|
|
2018-09-03 00:20:45 +02:00
|
|
|
void LoadSpecialObjectReflectionPalette(u16 tag, u8 slot)
|
2017-09-09 00:04:23 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2018-09-03 00:20:45 +02:00
|
|
|
sCurrentSpecialObjectPaletteTag = tag;
|
|
|
|
PatchObjectPalette(tag, slot);
|
2020-11-23 20:12:07 +01:00
|
|
|
for (i = 0; sSpecialObjectReflectionPaletteSets[i].tag != OBJ_EVENT_PAL_TAG_NONE; i++)
|
2017-09-09 00:04:23 +02:00
|
|
|
{
|
2020-11-23 20:12:07 +01:00
|
|
|
if (sSpecialObjectReflectionPaletteSets[i].tag == tag)
|
2017-09-09 00:04:23 +02:00
|
|
|
{
|
2020-11-23 20:12:07 +01:00
|
|
|
PatchObjectPalette(sSpecialObjectReflectionPaletteSets[i].data[sCurrentReflectionType], gReflectionEffectPaletteMap[slot]);
|
2017-09-09 00:04:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-09 00:12:27 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void _PatchObjectPalette(u16 tag, u8 slot)
|
2017-09-09 00:12:27 +02:00
|
|
|
{
|
2018-09-03 00:20:45 +02:00
|
|
|
PatchObjectPalette(tag, slot);
|
2017-09-09 00:12:27 +02:00
|
|
|
}
|
2017-09-09 03:25:20 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
// Unused
|
|
|
|
static void IncrementObjectEventCoords(struct ObjectEvent *objectEvent, s16 x, s16 y)
|
2017-09-09 03:25:20 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->previousCoords.x = objectEvent->currentCoords.x;
|
|
|
|
objectEvent->previousCoords.y = objectEvent->currentCoords.y;
|
|
|
|
objectEvent->currentCoords.x += x;
|
|
|
|
objectEvent->currentCoords.y += y;
|
2017-09-09 03:25:20 +02:00
|
|
|
}
|
2017-09-09 03:27:02 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void ShiftObjectEventCoords(struct ObjectEvent *objectEvent, s16 x, s16 y)
|
2017-09-09 03:27:02 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->previousCoords.x = objectEvent->currentCoords.x;
|
|
|
|
objectEvent->previousCoords.y = objectEvent->currentCoords.y;
|
|
|
|
objectEvent->currentCoords.x = x;
|
|
|
|
objectEvent->currentCoords.y = y;
|
2017-09-09 03:27:02 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void SetObjectEventCoords(struct ObjectEvent *objectEvent, s16 x, s16 y)
|
2017-09-09 03:28:22 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->previousCoords.x = x;
|
|
|
|
objectEvent->previousCoords.y = y;
|
|
|
|
objectEvent->currentCoords.x = x;
|
|
|
|
objectEvent->currentCoords.y = y;
|
2017-09-09 03:28:22 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void MoveObjectEventToMapCoords(struct ObjectEvent *objectEvent, s16 x, s16 y)
|
2017-09-09 03:35:46 +02:00
|
|
|
{
|
|
|
|
struct Sprite *sprite;
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2017-09-09 03:35:46 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
sprite = &gSprites[objectEvent->spriteId];
|
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId);
|
|
|
|
SetObjectEventCoords(objectEvent, x, y);
|
2021-07-07 15:11:52 +02:00
|
|
|
SetSpritePosToMapCoords(objectEvent->currentCoords.x, objectEvent->currentCoords.y, &sprite->x, &sprite->y);
|
2017-09-09 03:35:46 +02:00
|
|
|
sprite->centerToCornerVecX = -(graphicsInfo->width >> 1);
|
|
|
|
sprite->centerToCornerVecY = -(graphicsInfo->height >> 1);
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x += 8;
|
|
|
|
sprite->y += 16 + sprite->centerToCornerVecY;
|
2021-04-06 11:05:33 +02:00
|
|
|
ResetObjectEventFldEffData(objectEvent);
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->trackedByCamera)
|
2017-09-09 03:35:46 +02:00
|
|
|
CameraObjectReset1();
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void TryMoveObjectEventToMapCoords(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y)
|
2017-09-10 21:12:48 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
2017-09-10 21:12:48 +02:00
|
|
|
{
|
2021-10-09 18:12:18 +02:00
|
|
|
x += MAP_OFFSET;
|
|
|
|
y += MAP_OFFSET;
|
2019-11-21 04:55:44 +01:00
|
|
|
MoveObjectEventToMapCoords(&gObjectEvents[objectEventId], x, y);
|
2017-09-10 21:12:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void ShiftStillObjectEventCoords(struct ObjectEvent *objectEvent)
|
2017-09-10 21:14:46 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ShiftObjectEventCoords(objectEvent, objectEvent->currentCoords.x, objectEvent->currentCoords.y);
|
2017-09-10 21:14:46 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void UpdateObjectEventCoordsForCameraUpdate(void)
|
2017-09-10 21:35:21 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
s16 dx;
|
|
|
|
s16 dy;
|
|
|
|
|
|
|
|
if (gCamera.active)
|
|
|
|
{
|
|
|
|
dx = gCamera.x;
|
|
|
|
dy = gCamera.y;
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2017-09-10 21:35:21 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gObjectEvents[i].active)
|
2017-09-10 21:35:21 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gObjectEvents[i].initialCoords.x -= dx;
|
|
|
|
gObjectEvents[i].initialCoords.y -= dy;
|
|
|
|
gObjectEvents[i].currentCoords.x -= dx;
|
|
|
|
gObjectEvents[i].currentCoords.y -= dy;
|
|
|
|
gObjectEvents[i].previousCoords.x -= dx;
|
|
|
|
gObjectEvents[i].previousCoords.y -= dy;
|
2017-09-10 21:35:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
u8 GetObjectEventIdByPosition(u16 x, u16 y, u8 elevation)
|
2017-09-10 21:54:41 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2018-10-20 22:01:45 +02:00
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2017-09-10 21:54:41 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gObjectEvents[i].active)
|
2017-09-10 21:54:41 +02:00
|
|
|
{
|
2022-01-21 18:48:19 +01:00
|
|
|
if (gObjectEvents[i].currentCoords.x == x
|
|
|
|
&& gObjectEvents[i].currentCoords.y == y
|
|
|
|
&& ObjectEventDoesElevationMatch(&gObjectEvents[i], elevation))
|
2017-09-10 21:54:41 +02:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
2019-11-21 05:12:51 +01:00
|
|
|
return OBJECT_EVENTS_COUNT;
|
2017-09-10 21:54:41 +02:00
|
|
|
}
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
static bool8 ObjectEventDoesElevationMatch(struct ObjectEvent *objectEvent, u8 elevation)
|
2017-09-10 21:54:41 +02:00
|
|
|
{
|
2022-01-21 18:48:19 +01:00
|
|
|
if (objectEvent->currentElevation != 0 && elevation != 0 && objectEvent->currentElevation != elevation)
|
2017-09-10 21:54:41 +02:00
|
|
|
return FALSE;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2017-09-10 21:54:41 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-10 21:56:03 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void UpdateObjectEventsForCameraUpdate(s16 x, s16 y)
|
2017-09-10 21:56:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
UpdateObjectEventCoordsForCameraUpdate();
|
|
|
|
TrySpawnObjectEvents(x, y);
|
|
|
|
RemoveObjectEventsOutsideView();
|
2017-09-10 21:56:03 +02:00
|
|
|
}
|
2017-09-10 22:02:20 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
#define sLinkedSpriteId data[0]
|
|
|
|
#define sState data[1]
|
|
|
|
|
2017-09-10 22:13:19 +02:00
|
|
|
u8 AddCameraObject(u8 linkedSpriteId)
|
2017-09-10 22:02:20 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
u8 spriteId = CreateSprite(&sCameraSpriteTemplate, 0, 0, 4);
|
2017-09-10 22:02:20 +02:00
|
|
|
|
|
|
|
gSprites[spriteId].invisible = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
gSprites[spriteId].sLinkedSpriteId = linkedSpriteId;
|
2017-09-10 22:02:20 +02:00
|
|
|
return spriteId;
|
|
|
|
}
|
2017-09-10 22:13:19 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void SpriteCB_CameraObject(struct Sprite *sprite)
|
2017-09-10 22:13:19 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
void (*callbacks[ARRAY_COUNT(sCameraObjectFuncs)])(struct Sprite *);
|
2017-09-10 22:13:19 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
memcpy(callbacks, sCameraObjectFuncs, sizeof sCameraObjectFuncs);
|
|
|
|
callbacks[sprite->sState](sprite);
|
2017-09-10 22:13:19 +02:00
|
|
|
}
|
|
|
|
|
2018-06-12 00:33:50 +02:00
|
|
|
static void CameraObject_0(struct Sprite *sprite)
|
2017-09-10 22:13:19 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = gSprites[sprite->sLinkedSpriteId].x;
|
|
|
|
sprite->y = gSprites[sprite->sLinkedSpriteId].y;
|
2017-09-10 22:13:19 +02:00
|
|
|
sprite->invisible = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sState = 1;
|
2017-09-10 22:13:19 +02:00
|
|
|
CameraObject_1(sprite);
|
|
|
|
}
|
|
|
|
|
2018-06-12 00:33:50 +02:00
|
|
|
static void CameraObject_1(struct Sprite *sprite)
|
2017-09-10 22:13:19 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
s16 x = gSprites[sprite->sLinkedSpriteId].x;
|
|
|
|
s16 y = gSprites[sprite->sLinkedSpriteId].y;
|
2017-09-10 22:13:19 +02:00
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->data[2] = x - sprite->x;
|
|
|
|
sprite->data[3] = y - sprite->y;
|
|
|
|
sprite->x = x;
|
|
|
|
sprite->y = y;
|
2017-09-10 22:13:19 +02:00
|
|
|
}
|
|
|
|
|
2018-06-12 00:33:50 +02:00
|
|
|
static void CameraObject_2(struct Sprite *sprite)
|
2017-09-10 22:13:19 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x = gSprites[sprite->sLinkedSpriteId].x;
|
|
|
|
sprite->y = gSprites[sprite->sLinkedSpriteId].y;
|
2017-12-02 21:44:50 +01:00
|
|
|
sprite->data[2] = 0;
|
|
|
|
sprite->data[3] = 0;
|
2017-09-10 22:13:19 +02:00
|
|
|
}
|
2017-09-10 22:32:26 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static struct Sprite *FindCameraSprite(void)
|
2017-09-10 22:32:26 +02:00
|
|
|
{
|
2018-10-20 22:01:45 +02:00
|
|
|
u8 i;
|
2017-09-10 22:32:26 +02:00
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
for (i = 0; i < MAX_SPRITES; i++)
|
2017-09-10 22:32:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (gSprites[i].inUse && gSprites[i].callback == SpriteCB_CameraObject)
|
2018-10-20 22:01:45 +02:00
|
|
|
return &gSprites[i];
|
2017-09-10 22:32:26 +02:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-09-10 22:36:19 +02:00
|
|
|
|
|
|
|
void CameraObjectReset1(void)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
struct Sprite *camera;
|
2017-09-10 22:36:19 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
camera = FindCameraSprite();
|
|
|
|
if (camera != NULL)
|
2017-09-10 22:36:19 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
camera->sState = 0;
|
|
|
|
camera->callback(camera);
|
2017-09-10 22:36:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
void CameraObjectSetFollowedSpriteId(u8 spriteId)
|
2017-09-10 22:36:19 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
struct Sprite *camera;
|
2017-09-10 22:36:19 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
camera = FindCameraSprite();
|
|
|
|
if (camera != NULL)
|
2017-09-10 22:36:19 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
camera->sLinkedSpriteId = spriteId;
|
2017-09-10 22:36:19 +02:00
|
|
|
CameraObjectReset1();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
// Unused
|
|
|
|
static u8 CameraObjectGetFollowedSpriteId(void)
|
2017-09-10 22:36:19 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
struct Sprite *camera;
|
2017-09-10 22:36:19 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
camera = FindCameraSprite();
|
|
|
|
if (camera == NULL)
|
2017-09-10 22:36:19 +02:00
|
|
|
return MAX_SPRITES;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
return camera->sLinkedSpriteId;
|
2017-09-10 22:36:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CameraObjectReset2(void)
|
|
|
|
{
|
2020-12-27 02:23:36 +01:00
|
|
|
// UB: Possible null dereference
|
|
|
|
#ifdef UBFIX
|
2021-11-01 23:06:15 +01:00
|
|
|
struct Sprite *camera = FindCameraSprite();
|
|
|
|
if (camera)
|
2021-04-06 11:05:33 +02:00
|
|
|
camera->sState = 2;
|
2020-12-27 02:23:36 +01:00
|
|
|
#else
|
2021-04-06 11:05:33 +02:00
|
|
|
FindCameraSprite()->sState = 2;
|
2020-12-27 02:23:36 +01:00
|
|
|
#endif // UBFIX
|
2017-09-10 22:36:19 +02:00
|
|
|
}
|
2017-09-10 22:53:08 +02:00
|
|
|
|
|
|
|
u8 CopySprite(struct Sprite *sprite, s16 x, s16 y, u8 subpriority)
|
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
for (i = 0; i < MAX_SPRITES; i++)
|
2017-09-10 22:53:08 +02:00
|
|
|
{
|
|
|
|
if (!gSprites[i].inUse)
|
|
|
|
{
|
|
|
|
gSprites[i] = *sprite;
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[i].x = x;
|
|
|
|
gSprites[i].y = y;
|
2017-09-10 22:53:08 +02:00
|
|
|
gSprites[i].subpriority = subpriority;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
2017-09-10 22:57:08 +02:00
|
|
|
|
2018-09-03 00:20:45 +02:00
|
|
|
u8 CreateCopySpriteAt(struct Sprite *sprite, s16 x, s16 y, u8 subpriority)
|
2017-09-10 22:57:08 +02:00
|
|
|
{
|
|
|
|
s16 i;
|
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
for (i = MAX_SPRITES - 1; i > -1; i--)
|
2017-09-10 22:57:08 +02:00
|
|
|
{
|
|
|
|
if (!gSprites[i].inUse)
|
|
|
|
{
|
|
|
|
gSprites[i] = *sprite;
|
2021-07-07 15:11:52 +02:00
|
|
|
gSprites[i].x = x;
|
|
|
|
gSprites[i].y = y;
|
2017-09-10 22:57:08 +02:00
|
|
|
gSprites[i].subpriority = subpriority;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return MAX_SPRITES;
|
|
|
|
}
|
2017-09-10 23:04:37 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void SetObjectEventDirection(struct ObjectEvent *objectEvent, u8 direction)
|
2017-09-10 23:04:37 +02:00
|
|
|
{
|
|
|
|
s8 d2;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->previousMovementDirection = objectEvent->facingDirection;
|
|
|
|
if (!objectEvent->facingDirectionLocked)
|
2017-09-10 23:04:37 +02:00
|
|
|
{
|
|
|
|
d2 = direction;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->facingDirection = d2;
|
2017-09-10 23:04:37 +02:00
|
|
|
}
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->movementDirection = direction;
|
2017-09-10 23:04:37 +02:00
|
|
|
}
|
2017-09-10 23:11:03 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static const u8 *GetObjectEventScriptPointerByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
|
2017-09-10 23:11:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
return GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup)->script;
|
2017-09-10 23:11:03 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
const u8 *GetObjectEventScriptPointerByObjectEventId(u8 objectEventId)
|
2017-09-10 23:11:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
return GetObjectEventScriptPointerByLocalIdAndMap(gObjectEvents[objectEventId].localId, gObjectEvents[objectEventId].mapNum, gObjectEvents[objectEventId].mapGroup);
|
2017-09-10 23:11:03 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static u16 GetObjectEventFlagIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
|
2017-09-10 23:11:03 +02:00
|
|
|
{
|
2020-08-02 15:04:55 +02:00
|
|
|
struct ObjectEventTemplate *obj = GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup);
|
2020-08-02 15:37:04 +02:00
|
|
|
#ifdef UBFIX
|
2020-08-02 15:04:55 +02:00
|
|
|
// BUG: The function may return NULL, and attempting to read from NULL may freeze the game using modern compilers.
|
|
|
|
if (obj == NULL)
|
|
|
|
return 0;
|
|
|
|
#endif // UBFIX
|
|
|
|
return obj->flagId;
|
2017-09-10 23:11:03 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static u16 GetObjectEventFlagIdByObjectEventId(u8 objectEventId)
|
2017-09-10 23:11:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
return GetObjectEventFlagIdByLocalIdAndMap(gObjectEvents[objectEventId].localId, gObjectEvents[objectEventId].mapNum, gObjectEvents[objectEventId].mapGroup);
|
2017-09-10 23:11:03 +02:00
|
|
|
}
|
2017-09-10 23:47:37 +02:00
|
|
|
|
2020-04-21 21:53:48 +02:00
|
|
|
// Unused
|
|
|
|
static u8 GetObjectTrainerTypeByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
|
2017-09-10 23:47:37 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2017-09-10 23:47:37 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
2018-12-05 15:31:01 +01:00
|
|
|
return 0xFF;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return gObjectEvents[objectEventId].trainerType;
|
2017-09-10 23:47:37 +02:00
|
|
|
}
|
2017-09-11 16:19:03 +02:00
|
|
|
|
2020-04-21 21:53:48 +02:00
|
|
|
// Unused
|
|
|
|
static u8 GetObjectTrainerTypeByObjectEventId(u8 objectEventId)
|
2017-09-11 16:19:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
return gObjectEvents[objectEventId].trainerType;
|
2017-09-11 16:19:03 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
// Unused
|
|
|
|
u8 GetObjectEventBerryTreeIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
|
2017-09-11 16:19:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2017-09-11 16:19:03 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
2018-12-05 15:31:01 +01:00
|
|
|
return 0xFF;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return gObjectEvents[objectEventId].trainerRange_berryTreeId;
|
2017-09-11 16:19:03 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
u8 GetObjectEventBerryTreeId(u8 objectEventId)
|
2017-09-11 16:19:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
return gObjectEvents[objectEventId].trainerRange_berryTreeId;
|
2017-09-11 16:19:03 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
|
2017-09-11 16:29:00 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEventTemplate *templates;
|
2017-09-11 16:29:00 +02:00
|
|
|
const struct MapHeader *mapHeader;
|
|
|
|
u8 count;
|
|
|
|
|
|
|
|
if (gSaveBlock1Ptr->location.mapNum == mapNum && gSaveBlock1Ptr->location.mapGroup == mapGroup)
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
templates = gSaveBlock1Ptr->objectEventTemplates;
|
|
|
|
count = gMapHeader.events->objectEventCount;
|
2017-09-11 16:29:00 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-12 15:01:43 +01:00
|
|
|
mapHeader = Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum);
|
2019-11-21 04:55:44 +01:00
|
|
|
templates = mapHeader->events->objectEvents;
|
|
|
|
count = mapHeader->events->objectEventCount;
|
2017-09-11 16:29:00 +02:00
|
|
|
}
|
2019-11-21 04:55:44 +01:00
|
|
|
return FindObjectEventTemplateByLocalId(localId, templates, count);
|
2017-09-11 16:29:00 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8 localId, struct ObjectEventTemplate *templates, u8 count)
|
2017-09-11 16:31:09 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
for (i = 0; i < count; i++)
|
2017-09-11 16:31:09 +02:00
|
|
|
{
|
|
|
|
if (templates[i].localId == localId)
|
|
|
|
return &templates[i];
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-09-11 16:40:34 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEventTemplate *GetBaseTemplateForObjectEvent(const struct ObjectEvent *objectEvent)
|
2017-09-11 16:40:34 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
if (objectEvent->mapNum != gSaveBlock1Ptr->location.mapNum
|
|
|
|
|| objectEvent->mapGroup != gSaveBlock1Ptr->location.mapGroup)
|
2017-09-11 16:40:34 +02:00
|
|
|
return NULL;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENT_TEMPLATES_COUNT; i++)
|
2017-09-11 16:40:34 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->localId == gSaveBlock1Ptr->objectEventTemplates[i].localId)
|
|
|
|
return &gSaveBlock1Ptr->objectEventTemplates[i];
|
2017-09-11 16:40:34 +02:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2017-09-11 16:46:26 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void OverrideTemplateCoordsForObjectEvent(const struct ObjectEvent *objectEvent)
|
2017-09-11 16:46:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEventTemplate *objectEventTemplate;
|
2017-09-11 16:46:26 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventTemplate = GetBaseTemplateForObjectEvent(objectEvent);
|
|
|
|
if (objectEventTemplate != NULL)
|
2017-09-11 16:46:26 +02:00
|
|
|
{
|
2021-10-09 18:12:18 +02:00
|
|
|
objectEventTemplate->x = objectEvent->currentCoords.x - MAP_OFFSET;
|
|
|
|
objectEventTemplate->y = objectEvent->currentCoords.y - MAP_OFFSET;
|
2017-09-11 16:46:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void OverrideObjectEventTemplateScript(const struct ObjectEvent *objectEvent, const u8 *script)
|
2017-09-11 16:46:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEventTemplate *objectEventTemplate;
|
2017-09-11 16:46:26 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventTemplate = GetBaseTemplateForObjectEvent(objectEvent);
|
|
|
|
if (objectEventTemplate)
|
|
|
|
objectEventTemplate->script = script;
|
2017-09-11 16:46:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void TryOverrideTemplateCoordsForObjectEvent(const struct ObjectEvent *objectEvent, u8 movementType)
|
2017-09-11 16:46:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEventTemplate *objectEventTemplate;
|
2017-09-11 16:46:26 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEventTemplate = GetBaseTemplateForObjectEvent(objectEvent);
|
|
|
|
if (objectEventTemplate != NULL)
|
|
|
|
objectEventTemplate->movementType = movementType;
|
2017-09-11 16:46:26 +02:00
|
|
|
}
|
2017-09-12 22:17:52 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void TryOverrideObjectEventTemplateCoords(u8 localId, u8 mapNum, u8 mapGroup)
|
2017-09-12 22:17:52 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
|
|
|
OverrideTemplateCoordsForObjectEvent(&gObjectEvents[objectEventId]);
|
2017-09-12 22:17:52 +02:00
|
|
|
}
|
2017-09-12 22:47:51 +02:00
|
|
|
|
2019-04-05 23:11:24 +02:00
|
|
|
void OverrideSecretBaseDecorationSpriteScript(u8 localId, u8 mapNum, u8 mapGroup, u8 decorationCategory)
|
2017-09-12 22:47:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
2017-09-12 22:47:51 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
switch (decorationCategory)
|
2017-09-12 22:47:51 +02:00
|
|
|
{
|
2019-04-05 23:11:24 +02:00
|
|
|
case DECORCAT_DOLL:
|
2019-11-21 04:55:44 +01:00
|
|
|
OverrideObjectEventTemplateScript(&gObjectEvents[objectEventId], SecretBase_EventScript_DollInteract);
|
2019-04-05 23:11:24 +02:00
|
|
|
break;
|
|
|
|
case DECORCAT_CUSHION:
|
2019-11-21 04:55:44 +01:00
|
|
|
OverrideObjectEventTemplateScript(&gObjectEvents[objectEventId], SecretBase_EventScript_CushionInteract);
|
2019-04-05 23:11:24 +02:00
|
|
|
break;
|
2017-09-12 22:47:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-28 02:16:48 +02:00
|
|
|
void InitObjectEventPalettes(u8 reflectionType)
|
2017-09-12 22:47:51 +02:00
|
|
|
{
|
2018-09-03 00:20:45 +02:00
|
|
|
FreeAndReserveObjectSpritePalettes();
|
2019-11-21 05:12:51 +01:00
|
|
|
sCurrentSpecialObjectPaletteTag = OBJ_EVENT_PAL_TAG_NONE;
|
2022-09-28 02:16:48 +02:00
|
|
|
sCurrentReflectionType = reflectionType;
|
|
|
|
if (reflectionType == 1)
|
2017-09-12 22:47:51 +02:00
|
|
|
{
|
2022-09-28 02:16:48 +02:00
|
|
|
PatchObjectPaletteRange(sObjectPaletteTagSets[sCurrentReflectionType], PALSLOT_PLAYER, PALSLOT_NPC_4 + 1);
|
2017-09-12 22:47:51 +02:00
|
|
|
gReservedSpritePaletteCount = 8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-28 02:16:48 +02:00
|
|
|
PatchObjectPaletteRange(sObjectPaletteTagSets[sCurrentReflectionType], PALSLOT_PLAYER, PALSLOT_NPC_4_REFLECTION + 1);
|
2017-09-12 22:47:51 +02:00
|
|
|
}
|
|
|
|
}
|
2017-09-12 23:35:08 +02:00
|
|
|
|
2018-09-03 00:20:45 +02:00
|
|
|
u16 GetObjectPaletteTag(u8 palSlot)
|
2017-09-12 23:35:08 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2022-09-28 02:16:48 +02:00
|
|
|
if (palSlot < PALSLOT_NPC_SPECIAL)
|
2020-11-23 20:12:07 +01:00
|
|
|
return sObjectPaletteTagSets[sCurrentReflectionType][palSlot];
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2020-11-23 20:12:07 +01:00
|
|
|
for (i = 0; sSpecialObjectReflectionPaletteSets[i].tag != OBJ_EVENT_PAL_TAG_NONE; i++)
|
2017-09-12 23:35:08 +02:00
|
|
|
{
|
2020-11-23 20:12:07 +01:00
|
|
|
if (sSpecialObjectReflectionPaletteSets[i].tag == sCurrentSpecialObjectPaletteTag)
|
|
|
|
return sSpecialObjectReflectionPaletteSets[i].data[sCurrentReflectionType];
|
2017-09-12 23:35:08 +02:00
|
|
|
}
|
2019-11-21 05:12:51 +01:00
|
|
|
return OBJ_EVENT_PAL_TAG_NONE;
|
2017-09-12 23:35:08 +02:00
|
|
|
}
|
2017-09-13 15:41:11 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_empty_callback(MovementType_None)
|
|
|
|
movement_type_def(MovementType_WanderAround, gMovementTypeFuncs_WanderAround)
|
2017-09-13 15:41:11 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderAround_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-13 16:59:25 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-13 16:59:25 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderAround_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-13 16:59:25 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-13 16:59:25 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderAround_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-13 16:59:25 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-13 16:59:25 +02:00
|
|
|
return FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]);
|
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-13 16:59:25 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderAround_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-13 16:59:25 +02:00
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
if (WaitForMovementDelay(sprite))
|
2017-09-13 16:59:25 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-13 16:59:25 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderAround_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-13 16:59:25 +02:00
|
|
|
{
|
|
|
|
u8 directions[4];
|
|
|
|
u8 chosenDirection;
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
memcpy(directions, gStandardDirections, sizeof directions);
|
|
|
|
chosenDirection = directions[Random() & 3];
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, chosenDirection);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 5;
|
2019-11-21 04:55:44 +01:00
|
|
|
if (GetCollisionInDirection(objectEvent, chosenDirection))
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2019-10-06 22:40:10 +02:00
|
|
|
|
2017-09-13 16:59:25 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderAround_Step5(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-13 16:59:25 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(objectEvent->movementDirection));
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 6;
|
2017-09-13 16:59:25 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderAround_Step6(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-13 16:59:25 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-13 16:59:25 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-13 16:59:25 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-14 01:13:44 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 ObjectEventIsTrainerAndCloseToPlayer(struct ObjectEvent *objectEvent)
|
2017-09-14 01:13:44 +02:00
|
|
|
{
|
|
|
|
s16 playerX;
|
|
|
|
s16 playerY;
|
|
|
|
s16 objX;
|
|
|
|
s16 objY;
|
|
|
|
s16 minX;
|
|
|
|
s16 maxX;
|
|
|
|
s16 minY;
|
|
|
|
s16 maxY;
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH))
|
2017-09-14 01:13:44 +02:00
|
|
|
return FALSE;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2020-04-21 21:53:48 +02:00
|
|
|
if (objectEvent->trainerType != TRAINER_TYPE_NORMAL && objectEvent->trainerType != TRAINER_TYPE_BURIED)
|
2017-09-14 01:13:44 +02:00
|
|
|
return FALSE;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2017-09-14 01:13:44 +02:00
|
|
|
PlayerGetDestCoords(&playerX, &playerY);
|
2019-11-21 04:55:44 +01:00
|
|
|
objX = objectEvent->currentCoords.x;
|
|
|
|
objY = objectEvent->currentCoords.y;
|
|
|
|
minX = objX - objectEvent->trainerRange_berryTreeId;
|
|
|
|
minY = objY - objectEvent->trainerRange_berryTreeId;
|
|
|
|
maxX = objX + objectEvent->trainerRange_berryTreeId;
|
|
|
|
maxY = objY + objectEvent->trainerRange_berryTreeId;
|
2022-09-11 20:14:49 +02:00
|
|
|
if (minX > playerX || maxX < playerX
|
2021-11-01 23:06:15 +01:00
|
|
|
|| minY > playerY || maxY < playerY)
|
2017-09-14 01:13:44 +02:00
|
|
|
return FALSE;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2017-09-14 01:13:44 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-14 01:21:05 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 GetVectorDirection(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
2017-09-14 01:21:05 +02:00
|
|
|
{
|
2017-09-14 01:54:43 +02:00
|
|
|
u8 direction;
|
2017-09-14 01:21:05 +02:00
|
|
|
|
2017-09-14 02:34:25 +02:00
|
|
|
if (absdx > absdy)
|
2017-09-14 01:21:05 +02:00
|
|
|
{
|
2017-09-14 01:54:43 +02:00
|
|
|
direction = DIR_EAST;
|
2017-09-14 02:34:25 +02:00
|
|
|
if (dx < 0)
|
2017-09-14 01:54:43 +02:00
|
|
|
direction = DIR_WEST;
|
2017-09-14 01:21:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-14 01:54:43 +02:00
|
|
|
direction = DIR_SOUTH;
|
2017-09-14 02:34:25 +02:00
|
|
|
if (dy < 0)
|
2017-09-14 01:54:43 +02:00
|
|
|
direction = DIR_NORTH;
|
2017-09-14 01:21:05 +02:00
|
|
|
}
|
2017-09-14 01:54:43 +02:00
|
|
|
return direction;
|
2017-09-14 01:21:05 +02:00
|
|
|
}
|
2017-09-14 01:45:59 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 GetLimitedVectorDirection_SouthNorth(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
2017-09-14 01:45:59 +02:00
|
|
|
{
|
2017-09-14 01:54:43 +02:00
|
|
|
u8 direction;
|
2017-09-14 01:45:59 +02:00
|
|
|
|
2017-09-14 01:54:43 +02:00
|
|
|
direction = DIR_SOUTH;
|
2017-09-14 02:34:25 +02:00
|
|
|
if (dy < 0)
|
2017-09-14 01:54:43 +02:00
|
|
|
direction = DIR_NORTH;
|
|
|
|
return direction;
|
2017-09-14 01:45:59 +02:00
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 GetLimitedVectorDirection_WestEast(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
2017-09-14 01:45:59 +02:00
|
|
|
{
|
2017-09-14 01:54:43 +02:00
|
|
|
u8 direction;
|
2017-09-14 01:45:59 +02:00
|
|
|
|
2017-09-14 01:54:43 +02:00
|
|
|
direction = DIR_EAST;
|
2017-09-14 02:34:25 +02:00
|
|
|
if (dx < 0)
|
2017-09-14 01:54:43 +02:00
|
|
|
direction = DIR_WEST;
|
|
|
|
return direction;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 GetLimitedVectorDirection_WestNorth(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
2017-09-14 01:54:43 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2017-09-15 20:26:01 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetVectorDirection(dx, dy, absdx, absdy);
|
2017-09-14 01:54:43 +02:00
|
|
|
if (direction == DIR_SOUTH)
|
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetLimitedVectorDirection_WestEast(dx, dy, absdx, absdy);
|
2017-09-14 01:54:43 +02:00
|
|
|
if (direction == DIR_EAST)
|
|
|
|
direction = DIR_NORTH;
|
|
|
|
}
|
|
|
|
else if (direction == DIR_EAST)
|
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetLimitedVectorDirection_SouthNorth(dx, dy, absdx, absdy);
|
2017-09-14 01:54:43 +02:00
|
|
|
if (direction == DIR_SOUTH)
|
|
|
|
direction = DIR_NORTH;
|
|
|
|
}
|
|
|
|
return direction;
|
2017-09-14 01:45:59 +02:00
|
|
|
}
|
2017-09-14 02:22:38 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 GetLimitedVectorDirection_EastNorth(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
2017-09-14 02:22:38 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetVectorDirection(dx, dy, absdx, absdy);
|
2017-09-14 02:22:38 +02:00
|
|
|
if (direction == DIR_SOUTH)
|
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetLimitedVectorDirection_WestEast(dx, dy, absdx, absdy);
|
2017-09-14 02:22:38 +02:00
|
|
|
if (direction == DIR_WEST)
|
|
|
|
direction = DIR_NORTH;
|
|
|
|
}
|
|
|
|
else if (direction == DIR_WEST)
|
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetLimitedVectorDirection_SouthNorth(dx, dy, absdx, absdy);
|
2017-09-14 02:22:38 +02:00
|
|
|
if (direction == DIR_SOUTH)
|
|
|
|
direction = DIR_NORTH;
|
|
|
|
}
|
|
|
|
return direction;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 GetLimitedVectorDirection_WestSouth(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
2017-09-14 02:22:38 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetVectorDirection(dx, dy, absdx, absdy);
|
2017-09-14 02:22:38 +02:00
|
|
|
if (direction == DIR_NORTH)
|
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetLimitedVectorDirection_WestEast(dx, dy, absdx, absdy);
|
2017-09-14 02:22:38 +02:00
|
|
|
if (direction == DIR_EAST)
|
|
|
|
direction = DIR_SOUTH;
|
|
|
|
}
|
|
|
|
else if (direction == DIR_EAST)
|
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetLimitedVectorDirection_SouthNorth(dx, dy, absdx, absdy);
|
2017-09-14 02:22:38 +02:00
|
|
|
if (direction == DIR_NORTH)
|
|
|
|
direction = DIR_SOUTH;
|
|
|
|
}
|
|
|
|
return direction;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 GetLimitedVectorDirection_EastSouth(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
2017-09-14 02:22:38 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetVectorDirection(dx, dy, absdx, absdy);
|
2017-09-14 02:22:38 +02:00
|
|
|
if (direction == DIR_NORTH)
|
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetLimitedVectorDirection_WestEast(dx, dy, absdx, absdy);
|
2017-09-14 02:22:38 +02:00
|
|
|
if (direction == DIR_WEST)
|
|
|
|
direction = DIR_SOUTH;
|
|
|
|
}
|
|
|
|
else if (direction == DIR_WEST)
|
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetLimitedVectorDirection_SouthNorth(dx, dy, absdx, absdy);
|
2017-09-14 02:22:38 +02:00
|
|
|
if (direction == DIR_NORTH)
|
|
|
|
direction = DIR_SOUTH;
|
|
|
|
}
|
|
|
|
return direction;
|
|
|
|
}
|
2017-09-14 02:26:08 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 GetLimitedVectorDirection_SouthNorthWest(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
2017-09-14 02:26:08 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetVectorDirection(dx, dy, absdx, absdy);
|
2017-09-14 02:26:08 +02:00
|
|
|
if (direction == DIR_EAST)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetLimitedVectorDirection_SouthNorth(dx, dy, absdx, absdy);
|
2017-09-14 02:26:08 +02:00
|
|
|
return direction;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 GetLimitedVectorDirection_SouthNorthEast(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
2017-09-14 02:26:08 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetVectorDirection(dx, dy, absdx, absdy);
|
2017-09-14 02:26:08 +02:00
|
|
|
if (direction == DIR_WEST)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetLimitedVectorDirection_SouthNorth(dx, dy, absdx, absdy);
|
2017-09-14 02:26:08 +02:00
|
|
|
return direction;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 GetLimitedVectorDirection_NorthWestEast(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
2017-09-14 02:26:08 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetVectorDirection(dx, dy, absdx, absdy);
|
2017-09-14 02:26:08 +02:00
|
|
|
if (direction == DIR_SOUTH)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetLimitedVectorDirection_WestEast(dx, dy, absdx, absdy);
|
2017-09-14 02:26:08 +02:00
|
|
|
return direction;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 GetLimitedVectorDirection_SouthWestEast(s16 dx, s16 dy, s16 absdx, s16 absdy)
|
2017-09-14 02:26:08 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetVectorDirection(dx, dy, absdx, absdy);
|
2017-09-14 02:26:08 +02:00
|
|
|
if (direction == DIR_NORTH)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = GetLimitedVectorDirection_WestEast(dx, dy, absdx, absdy);
|
2017-09-14 02:26:08 +02:00
|
|
|
return direction;
|
|
|
|
}
|
2017-09-14 02:34:25 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 TryGetTrainerEncounterDirection(struct ObjectEvent *objectEvent, u8 movementType)
|
2017-09-14 02:34:25 +02:00
|
|
|
{
|
2018-10-20 22:01:45 +02:00
|
|
|
s16 dx, dy;
|
|
|
|
s16 absdx, absdy;
|
2017-09-14 02:34:25 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2021-04-06 11:05:33 +02:00
|
|
|
return DIR_NONE;
|
|
|
|
|
2017-09-14 02:34:25 +02:00
|
|
|
PlayerGetDestCoords(&dx, &dy);
|
2019-11-21 04:55:44 +01:00
|
|
|
dx -= objectEvent->currentCoords.x;
|
|
|
|
dy -= objectEvent->currentCoords.y;
|
2017-09-14 02:34:25 +02:00
|
|
|
absdx = dx;
|
|
|
|
absdy = dy;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2017-09-14 02:34:25 +02:00
|
|
|
if (absdx < 0)
|
|
|
|
absdx = -absdx;
|
|
|
|
if (absdy < 0)
|
|
|
|
absdy = -absdy;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
return gGetVectorDirectionFuncs[movementType](dx, dy, absdx, absdy);
|
2017-09-14 02:34:25 +02:00
|
|
|
}
|
2017-09-14 02:36:58 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_LookAround, gMovementTypeFuncs_LookAround)
|
2017-09-14 03:11:59 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_LookAround_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-14 03:11:59 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-14 03:11:59 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_LookAround_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-14 03:11:59 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-14 03:11:59 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_LookAround_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-14 03:11:59 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-14 03:11:59 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]);
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-14 03:11:59 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_LookAround_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-14 03:11:59 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2017-09-14 03:11:59 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-14 03:11:59 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_LookAround_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-14 03:11:59 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[4];
|
|
|
|
memcpy(directions, gStandardDirections, sizeof directions);
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_ANY);
|
2018-06-14 00:51:26 +02:00
|
|
|
if (direction == DIR_NONE)
|
|
|
|
direction = directions[Random() & 3];
|
2017-09-14 03:11:59 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-14 03:11:59 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-15 03:22:14 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_WanderUpAndDown, gMovementTypeFuncs_WanderUpAndDown)
|
2017-09-15 03:22:14 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderUpAndDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:22:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 03:22:14 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderUpAndDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:22:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 03:22:14 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderUpAndDown_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:22:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 03:22:14 +02:00
|
|
|
return FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
|
|
|
SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]);
|
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 03:22:14 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderUpAndDown_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:22:14 +02:00
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
if (WaitForMovementDelay(sprite))
|
2017-09-15 03:22:14 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-15 03:22:14 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderUpAndDown_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:22:14 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[2];
|
|
|
|
memcpy(directions, gUpAndDownDirections, sizeof directions);
|
|
|
|
direction = directions[Random() & 1];
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 5;
|
2019-11-21 04:55:44 +01:00
|
|
|
if (GetCollisionInDirection(objectEvent, direction))
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2019-10-06 22:40:10 +02:00
|
|
|
|
2017-09-15 03:22:14 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderUpAndDown_Step5(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:22:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(objectEvent->movementDirection));
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 6;
|
2017-09-15 03:22:14 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderUpAndDown_Step6(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:22:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 03:22:14 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 03:22:14 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-15 03:25:30 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_WanderLeftAndRight, gMovementTypeFuncs_WanderLeftAndRight)
|
2017-09-15 03:25:30 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderLeftAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:25:30 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 03:25:30 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderLeftAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:25:30 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 03:25:30 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderLeftAndRight_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:25:30 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 03:25:30 +02:00
|
|
|
return FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
|
|
|
SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]);
|
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 03:25:30 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderLeftAndRight_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:25:30 +02:00
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
if (WaitForMovementDelay(sprite))
|
2017-09-15 03:25:30 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-15 03:25:30 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderLeftAndRight_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:25:30 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[2];
|
|
|
|
memcpy(directions, gLeftAndRightDirections, sizeof directions);
|
|
|
|
direction = directions[Random() & 1];
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 5;
|
2019-11-21 04:55:44 +01:00
|
|
|
if (GetCollisionInDirection(objectEvent, direction))
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2019-10-06 22:40:10 +02:00
|
|
|
|
2017-09-15 03:25:30 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderLeftAndRight_Step5(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:25:30 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(objectEvent->movementDirection));
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 6;
|
2017-09-15 03:25:30 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WanderLeftAndRight_Step6(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:25:30 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 03:25:30 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 03:25:30 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-15 03:30:14 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_FaceDirection, gMovementTypeFuncs_FaceDirection)
|
2017-09-15 03:30:14 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDirection_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:30:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 03:30:14 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDirection_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:30:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 03:30:14 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 03:30:14 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDirection_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 03:30:14 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2017-09-15 03:30:14 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-15 20:26:01 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static bool8 ObjectEventCB2_BerryTree(struct ObjectEvent *objectEvent, struct Sprite *sprite);
|
|
|
|
extern bool8 (*const gMovementTypeFuncs_BerryTreeGrowth[])(struct ObjectEvent *objectEvent, struct Sprite *sprite);
|
2021-01-26 11:16:01 +01:00
|
|
|
|
|
|
|
enum {
|
|
|
|
BERRYTREEFUNC_NORMAL,
|
|
|
|
BERRYTREEFUNC_MOVE,
|
|
|
|
BERRYTREEFUNC_SPARKLE_START,
|
|
|
|
BERRYTREEFUNC_SPARKLE,
|
|
|
|
BERRYTREEFUNC_SPARKLE_END,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define sTimer data[2]
|
|
|
|
#define sBerryTreeFlags data[7]
|
|
|
|
|
|
|
|
#define BERRY_FLAG_SET_GFX (1 << 0)
|
|
|
|
#define BERRY_FLAG_SPARKLING (1 << 1)
|
|
|
|
#define BERRY_FLAG_JUST_PICKED (1 << 2)
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
void MovementType_BerryTreeGrowth(struct Sprite *sprite)
|
2017-09-15 20:26:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEvent *objectEvent;
|
2017-09-15 20:26:01 +02:00
|
|
|
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent = &gObjectEvents[sprite->sObjEventId];
|
|
|
|
if (!(sprite->sBerryTreeFlags & BERRY_FLAG_SET_GFX))
|
2017-09-15 20:26:01 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
SetBerryTreeGraphics(objectEvent, sprite);
|
|
|
|
sprite->sBerryTreeFlags |= BERRY_FLAG_SET_GFX;
|
2017-09-15 20:26:01 +02:00
|
|
|
}
|
2019-11-21 04:55:44 +01:00
|
|
|
UpdateObjectEventCurrentMovement(objectEvent, sprite, ObjectEventCB2_BerryTree);
|
2017-09-15 20:26:01 +02:00
|
|
|
}
|
2019-11-21 04:55:44 +01:00
|
|
|
static bool8 ObjectEventCB2_BerryTree(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:26:01 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return gMovementTypeFuncs_BerryTreeGrowth[sprite->sTypeFuncId](objectEvent, sprite);
|
2017-09-15 20:26:01 +02:00
|
|
|
}
|
|
|
|
|
2021-01-26 11:16:01 +01:00
|
|
|
// BERRYTREEFUNC_NORMAL
|
|
|
|
bool8 MovementType_BerryTreeGrowth_Normal(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:26:01 +02:00
|
|
|
{
|
|
|
|
u8 berryStage;
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
|
|
|
objectEvent->invisible = TRUE;
|
2017-09-15 20:26:01 +02:00
|
|
|
sprite->invisible = TRUE;
|
2019-11-21 04:55:44 +01:00
|
|
|
berryStage = GetStageByBerryTreeId(objectEvent->trainerRange_berryTreeId);
|
2021-01-26 11:16:01 +01:00
|
|
|
if (berryStage == BERRY_STAGE_NO_BERRY)
|
2017-09-15 20:26:01 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
if (!(sprite->sBerryTreeFlags & BERRY_FLAG_JUST_PICKED) && sprite->animNum == BERRY_STAGE_FLOWERING)
|
2017-09-15 20:26:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objectEvent->currentCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objectEvent->currentCoords.y;
|
2017-10-12 09:06:19 +02:00
|
|
|
gFieldEffectArguments[2] = sprite->subpriority - 1;
|
|
|
|
gFieldEffectArguments[3] = sprite->oam.priority;
|
2017-09-15 20:26:01 +02:00
|
|
|
FieldEffectStart(FLDEFF_BERRY_TREE_GROWTH_SPARKLE);
|
|
|
|
sprite->animNum = berryStage;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->invisible = FALSE;
|
2017-09-15 20:26:01 +02:00
|
|
|
sprite->invisible = FALSE;
|
2021-01-26 11:16:01 +01:00
|
|
|
berryStage--;
|
2017-09-15 20:26:01 +02:00
|
|
|
if (sprite->animNum != berryStage)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = BERRYTREEFUNC_SPARKLE_START;
|
2017-09-15 20:26:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2021-01-26 11:16:01 +01:00
|
|
|
SetBerryTreeGraphics(objectEvent, sprite);
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, MOVEMENT_ACTION_START_ANIM_IN_DIRECTION);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = BERRYTREEFUNC_MOVE;
|
2017-09-15 20:26:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-01-26 11:16:01 +01:00
|
|
|
// BERRYTREEFUNC_MOVE
|
|
|
|
bool8 MovementType_BerryTreeGrowth_Move(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:26:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 20:26:01 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = BERRYTREEFUNC_NORMAL;
|
2017-09-15 20:26:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-01-26 11:16:01 +01:00
|
|
|
// BERRYTREEFUNC_SPARKLE_START
|
|
|
|
bool8 MovementType_BerryTreeGrowth_SparkleStart(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:26:01 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = BERRYTREEFUNC_SPARKLE;
|
2021-01-26 11:16:01 +01:00
|
|
|
sprite->sTimer = 0;
|
|
|
|
sprite->sBerryTreeFlags |= BERRY_FLAG_SPARKLING;
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objectEvent->currentCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objectEvent->currentCoords.y;
|
2017-10-12 09:06:19 +02:00
|
|
|
gFieldEffectArguments[2] = sprite->subpriority - 1;
|
|
|
|
gFieldEffectArguments[3] = sprite->oam.priority;
|
2017-09-15 20:26:01 +02:00
|
|
|
FieldEffectStart(FLDEFF_BERRY_TREE_GROWTH_SPARKLE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-01-26 11:16:01 +01:00
|
|
|
// BERRYTREEFUNC_SPARKLE
|
|
|
|
bool8 MovementType_BerryTreeGrowth_Sparkle(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:26:01 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
sprite->sTimer++;
|
|
|
|
objectEvent->invisible = (sprite->sTimer & 2) >> 1;
|
2017-09-15 20:26:01 +02:00
|
|
|
sprite->animPaused = TRUE;
|
2021-01-26 11:16:01 +01:00
|
|
|
if (sprite->sTimer > 64)
|
2017-09-15 20:26:01 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
SetBerryTreeGraphics(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = BERRYTREEFUNC_SPARKLE_END;
|
2021-01-26 11:16:01 +01:00
|
|
|
sprite->sTimer = 0;
|
2017-09-15 20:26:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-01-26 11:16:01 +01:00
|
|
|
// BERRYTREEFUNC_SPARKLE_END
|
|
|
|
bool8 MovementType_BerryTreeGrowth_SparkleEnd(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:26:01 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
sprite->sTimer++;
|
|
|
|
objectEvent->invisible = (sprite->sTimer & 2) >> 1;
|
2017-09-15 20:26:01 +02:00
|
|
|
sprite->animPaused = TRUE;
|
2021-01-26 11:16:01 +01:00
|
|
|
if (sprite->sTimer > 64)
|
2017-09-15 20:26:01 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = BERRYTREEFUNC_NORMAL;
|
2021-01-26 11:16:01 +01:00
|
|
|
sprite->sBerryTreeFlags &= ~BERRY_FLAG_SPARKLING;
|
2017-09-15 20:26:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-15 20:36:54 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_FaceDownAndUp, gMovementTypeFuncs_FaceDownAndUp)
|
2017-09-15 20:36:54 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:36:54 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 20:36:54 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:36:54 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 20:36:54 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndUp_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:36:54 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 20:36:54 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]);
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 20:36:54 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndUp_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:36:54 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2017-09-15 20:36:54 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-15 20:36:54 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndUp_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:36:54 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[2];
|
|
|
|
memcpy(directions, gUpAndDownDirections, sizeof gUpAndDownDirections);
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_NORTH_SOUTH);
|
2021-11-01 23:06:15 +01:00
|
|
|
if (direction == DIR_NONE)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = directions[Random() & 1];
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 20:36:54 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-15 20:42:54 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_FaceLeftAndRight, gMovementTypeFuncs_FaceLeftAndRight)
|
2017-09-15 20:42:54 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceLeftAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:42:54 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 20:42:54 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceLeftAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:42:54 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 20:42:54 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceLeftAndRight_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:42:54 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 20:42:54 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]);
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 20:42:54 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceLeftAndRight_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:42:54 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2017-09-15 20:42:54 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-15 20:42:54 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceLeftAndRight_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 20:42:54 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[2];
|
|
|
|
memcpy(directions, gLeftAndRightDirections, sizeof gLeftAndRightDirections);
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_EAST_WEST);
|
2021-11-01 23:06:15 +01:00
|
|
|
if (direction == DIR_NONE)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = directions[Random() & 1];
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 20:42:54 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-15 21:26:51 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_FaceUpAndLeft, gMovementTypeFuncs_FaceUpAndLeft)
|
2017-09-15 21:26:51 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpAndLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:26:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 21:26:51 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpAndLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:26:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 21:26:51 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpAndLeft_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:26:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 21:26:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 21:26:51 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpAndLeft_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:26:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2017-09-15 21:26:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-15 21:26:51 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpAndLeft_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:26:51 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[2];
|
|
|
|
memcpy(directions, gUpAndLeftDirections, sizeof gUpAndLeftDirections);
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_NORTH_WEST);
|
2021-11-01 23:06:15 +01:00
|
|
|
if (direction == DIR_NONE)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = directions[Random() & 1];
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 21:53:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_FaceUpAndRight, gMovementTypeFuncs_FaceUpAndRight)
|
2017-09-15 21:53:07 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:53:07 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 21:53:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:53:07 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 21:53:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpAndRight_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:53:07 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 21:53:07 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 21:53:07 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpAndRight_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:53:07 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2017-09-15 21:53:07 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-15 21:53:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpAndRight_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:53:07 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[2];
|
|
|
|
memcpy(directions, gUpAndRightDirections, sizeof gUpAndRightDirections);
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_NORTH_EAST);
|
2021-11-01 23:06:15 +01:00
|
|
|
if (direction == DIR_NONE)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = directions[Random() & 1];
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 21:26:51 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-15 21:57:38 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_FaceDownAndLeft, gMovementTypeFuncs_FaceDownAndLeft)
|
2017-09-15 21:57:38 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:57:38 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 21:57:38 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:57:38 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 21:57:38 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndLeft_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:57:38 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 21:57:38 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 21:57:38 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndLeft_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:57:38 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2017-09-15 21:57:38 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-15 21:57:38 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndLeft_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 21:57:38 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[2];
|
|
|
|
memcpy(directions, gDownAndLeftDirections, sizeof gDownAndLeftDirections);
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_SOUTH_WEST);
|
2021-11-01 23:06:15 +01:00
|
|
|
if (direction == DIR_NONE)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = directions[Random() & 1];
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 21:57:38 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-15 22:00:39 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_FaceDownAndRight, gMovementTypeFuncs_FaceDownAndRight)
|
2017-09-15 22:00:39 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:00:39 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 22:00:39 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:00:39 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 22:00:39 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndRight_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:00:39 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 22:00:39 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 22:00:39 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndRight_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:00:39 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2017-09-15 22:00:39 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-15 22:00:39 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownAndRight_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:00:39 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[2];
|
|
|
|
memcpy(directions, gDownAndRightDirections, sizeof gDownAndRightDirections);
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_SOUTH_EAST);
|
2021-11-01 23:06:15 +01:00
|
|
|
if (direction == DIR_NONE)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = directions[Random() & 1];
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 22:00:39 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-15 22:08:01 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_FaceDownUpAndLeft, gMovementTypeFuncs_FaceDownUpAndLeft)
|
2017-09-15 22:08:01 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownUpAndLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownUpAndLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownUpAndLeft_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 22:08:01 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownUpAndLeft_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownUpAndLeft_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[4];
|
|
|
|
memcpy(directions, gDownUpAndLeftDirections, sizeof gDownUpAndLeftDirections);
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_NORTH_SOUTH_WEST);
|
2021-11-01 23:06:15 +01:00
|
|
|
if (direction == DIR_NONE)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = directions[Random() & 3];
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_FaceDownUpAndRight, gMovementTypeFuncs_FaceDownUpAndRight)
|
2017-09-15 22:08:01 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownUpAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownUpAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownUpAndRight_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 22:08:01 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownUpAndRight_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownUpAndRight_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[4];
|
|
|
|
memcpy(directions, gDownUpAndRightDirections, sizeof gDownUpAndRightDirections);
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_NORTH_SOUTH_EAST);
|
2021-11-01 23:06:15 +01:00
|
|
|
if (direction == DIR_NONE)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = directions[Random() & 3];
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_FaceUpRightAndLeft, gMovementTypeFuncs_FaceUpLeftAndRight)
|
2017-09-15 22:08:01 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpLeftAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpLeftAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpLeftAndRight_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 22:08:01 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpLeftAndRight_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceUpLeftAndRight_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[4];
|
|
|
|
memcpy(directions, gUpLeftAndRightDirections, sizeof gUpLeftAndRightDirections);
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_NORTH_EAST_WEST);
|
2021-11-01 23:06:15 +01:00
|
|
|
if (direction == DIR_NONE)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = directions[Random() & 3];
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_FaceDownRightAndLeft, gMovementTypeFuncs_FaceDownLeftAndRight)
|
2017-09-15 22:08:01 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownLeftAndRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownLeftAndRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownLeftAndRight_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
SetMovementDelay(sprite, sMovementDelaysShort[Random() & 3]);
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 22:08:01 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownLeftAndRight_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 4;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_FaceDownLeftAndRight_Step4(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:08:01 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[4];
|
|
|
|
memcpy(directions, gDownLeftAndRightDirections, sizeof gDownLeftAndRightDirections);
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_SOUTH_EAST_WEST);
|
2021-11-01 23:06:15 +01:00
|
|
|
if (direction == DIR_NONE)
|
2018-06-14 00:51:26 +02:00
|
|
|
direction = directions[Random() & 3];
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 22:08:01 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-15 22:34:03 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_RotateCounterclockwise, gMovementTypeFuncs_RotateCounterclockwise)
|
2017-09-15 22:34:03 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_RotateCounterclockwise_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:34:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 22:34:03 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_RotateCounterclockwise_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:34:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 22:34:03 +02:00
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
SetMovementDelay(sprite, 48);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 22:34:03 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_RotateCounterclockwise_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:34:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 22:34:03 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_RotateCounterclockwise_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:34:03 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[5];
|
|
|
|
memcpy(directions, gCounterclockwiseDirections, sizeof gCounterclockwiseDirections);
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_ANY);
|
2021-11-01 23:06:15 +01:00
|
|
|
if (direction == DIR_NONE)
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = directions[objectEvent->facingDirection];
|
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 0;
|
2017-09-15 22:34:03 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_RotateClockwise, gMovementTypeFuncs_RotateClockwise)
|
2017-09-15 22:34:03 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_RotateClockwise_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:34:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-15 22:34:03 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_RotateClockwise_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:34:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-15 22:34:03 +02:00
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
SetMovementDelay(sprite, 48);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-15 22:34:03 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_RotateClockwise_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:34:03 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent))
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-15 22:34:03 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_RotateClockwise_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-15 22:34:03 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 directions[5];
|
|
|
|
memcpy(directions, gClockwiseDirections, sizeof gClockwiseDirections);
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_ANY);
|
2021-11-01 23:06:15 +01:00
|
|
|
if (direction == DIR_NONE)
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = directions[objectEvent->facingDirection];
|
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 0;
|
2017-09-15 22:34:03 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-16 03:26:56 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_WalkBackAndForth, gMovementTypeFuncs_WalkBackAndForth)
|
2017-09-16 03:26:56 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WalkBackAndForth_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 03:26:56 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-16 03:26:56 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WalkBackAndForth_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 03:26:56 +02:00
|
|
|
{
|
|
|
|
u8 direction;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
direction = gInitialMovementTypeFacingDirections[objectEvent->movementType];
|
|
|
|
if (objectEvent->directionSequenceIndex)
|
2017-09-16 03:26:56 +02:00
|
|
|
direction = GetOppositeDirection(direction);
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-16 03:26:56 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WalkBackAndForth_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 03:26:56 +02:00
|
|
|
{
|
2019-10-06 22:40:10 +02:00
|
|
|
bool8 collision;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 movementActionId;
|
2017-09-16 03:26:56 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex && objectEvent->initialCoords.x == objectEvent->currentCoords.x && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
2017-09-16 03:26:56 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->directionSequenceIndex = 0;
|
|
|
|
SetObjectEventDirection(objectEvent, GetOppositeDirection(objectEvent->movementDirection));
|
2017-09-16 03:26:56 +02:00
|
|
|
}
|
2019-11-21 04:55:44 +01:00
|
|
|
collision = GetCollisionInDirection(objectEvent, objectEvent->movementDirection);
|
|
|
|
movementActionId = GetWalkNormalMovementAction(objectEvent->movementDirection);
|
2019-10-06 22:40:10 +02:00
|
|
|
if (collision == COLLISION_OUTSIDE_RANGE)
|
2017-09-16 03:26:56 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->directionSequenceIndex++;
|
|
|
|
SetObjectEventDirection(objectEvent, GetOppositeDirection(objectEvent->movementDirection));
|
|
|
|
movementActionId = GetWalkNormalMovementAction(objectEvent->movementDirection);
|
|
|
|
collision = GetCollisionInDirection(objectEvent, objectEvent->movementDirection);
|
2017-09-16 03:26:56 +02:00
|
|
|
}
|
2019-10-06 22:40:10 +02:00
|
|
|
|
|
|
|
if (collision)
|
2019-11-21 04:55:44 +01:00
|
|
|
movementActionId = GetWalkInPlaceNormalMovementAction(objectEvent->facingDirection);
|
2019-10-06 22:40:10 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, movementActionId);
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 3;
|
2017-09-16 03:26:56 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WalkBackAndForth_Step3(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 03:26:56 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-16 03:26:56 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-16 03:26:56 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-16 03:39:24 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WalkSequence_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 03:39:24 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-16 03:39:24 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MoveNextDirectionInSequence(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 *route)
|
2017-09-16 03:39:24 +02:00
|
|
|
{
|
2019-10-06 22:40:10 +02:00
|
|
|
u8 collision;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 movementActionId;
|
2017-09-16 03:39:24 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 3 && objectEvent->initialCoords.x == objectEvent->currentCoords.x && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
|
|
|
objectEvent->directionSequenceIndex = 0;
|
2019-10-06 22:40:10 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, route[objectEvent->directionSequenceIndex]);
|
|
|
|
movementActionId = GetWalkNormalMovementAction(objectEvent->movementDirection);
|
|
|
|
collision = GetCollisionInDirection(objectEvent, objectEvent->movementDirection);
|
2019-10-06 22:40:10 +02:00
|
|
|
if (collision == COLLISION_OUTSIDE_RANGE)
|
2017-09-16 03:39:24 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->directionSequenceIndex++;
|
|
|
|
SetObjectEventDirection(objectEvent, route[objectEvent->directionSequenceIndex]);
|
|
|
|
movementActionId = GetWalkNormalMovementAction(objectEvent->movementDirection);
|
|
|
|
collision = GetCollisionInDirection(objectEvent, objectEvent->movementDirection);
|
2017-09-16 03:39:24 +02:00
|
|
|
}
|
2019-10-06 22:40:10 +02:00
|
|
|
|
|
|
|
if (collision)
|
2019-11-21 04:55:44 +01:00
|
|
|
movementActionId = GetWalkInPlaceNormalMovementAction(objectEvent->facingDirection);
|
2019-10-06 22:40:10 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, movementActionId);
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-16 03:39:24 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-16 14:13:37 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WalkSequence_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 14:13:37 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-16 14:13:37 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-16 14:13:37 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-16 14:44:43 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_WalkSequenceUpRightLeftDown, gMovementTypeFuncs_WalkSequenceUpRightLeftDown)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceUpRightLeftDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gUpRightLeftDownDirections)];
|
|
|
|
memcpy(directions, gUpRightLeftDownDirections, sizeof(gUpRightLeftDownDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceRightLeftDownUp, gMovementTypeFuncs_WalkSequenceRightLeftDownUp)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceRightLeftDownUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gRightLeftDownUpDirections)];
|
|
|
|
memcpy(directions, gRightLeftDownUpDirections, sizeof(gRightLeftDownUpDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.x == objectEvent->currentCoords.x)
|
|
|
|
objectEvent->directionSequenceIndex = 2;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceDownUpRightLeft, gMovementTypeFuncs_WalkSequenceDownUpRightLeft)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceDownUpRightLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gDownUpRightLeftDirections)];
|
|
|
|
memcpy(directions, gDownUpRightLeftDirections, sizeof(gDownUpRightLeftDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
|
|
|
objectEvent->directionSequenceIndex = 2;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceLeftDownUpRight, gMovementTypeFuncs_WalkSequenceLeftDownUpRight)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceLeftDownUpRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gLeftDownUpRightDirections)];
|
|
|
|
memcpy(directions, gLeftDownUpRightDirections, sizeof(gLeftDownUpRightDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceUpLeftRightDown, gMovementTypeFuncs_WalkSequenceUpLeftRightDown)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceUpLeftRightDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gUpLeftRightDownDirections)];
|
|
|
|
memcpy(directions, gUpLeftRightDownDirections, sizeof(gUpLeftRightDownDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceLeftRightDownUp, gMovementTypeFuncs_WalkSequenceLeftRightDownUp)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceLeftRightDownUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gLeftRightDownUpDirections)];
|
|
|
|
memcpy(directions, gLeftRightDownUpDirections, sizeof(gLeftRightDownUpDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.x == objectEvent->currentCoords.x)
|
|
|
|
objectEvent->directionSequenceIndex = 2;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceDownUpLeftRight, gMovementTypeFuncs_WalkSequenceDownUpLeftRight)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceDownUpLeftRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gStandardDirections)];
|
|
|
|
memcpy(directions, gStandardDirections, sizeof(gStandardDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
|
|
|
objectEvent->directionSequenceIndex = 2;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceRightDownUpLeft, gMovementTypeFuncs_WalkSequenceRightDownUpLeft)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceRightDownUpLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gRightDownUpLeftDirections)];
|
|
|
|
memcpy(directions, gRightDownUpLeftDirections, sizeof(gRightDownUpLeftDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceLeftUpDownRight, gMovementTypeFuncs_WalkSequenceLeftUpDownRight)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceLeftUpDownRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gLeftUpDownRightDirections)];
|
|
|
|
memcpy(directions, gLeftUpDownRightDirections, sizeof(gLeftUpDownRightDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceUpDownRightLeft, gMovementTypeFuncs_WalkSequenceUpDownRightLeft)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceUpDownRightLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gUpDownRightLeftDirections)];
|
|
|
|
memcpy(directions, gUpDownRightLeftDirections, sizeof(gUpDownRightLeftDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
|
|
|
objectEvent->directionSequenceIndex = 2;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceRightLeftUpDown, gMovementTypeFuncs_WalkSequenceRightLeftUpDown)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceRightLeftUpDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gRightLeftUpDownDirections)];
|
|
|
|
memcpy(directions, gRightLeftUpDownDirections, sizeof(gRightLeftUpDownDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.x == objectEvent->currentCoords.x)
|
|
|
|
objectEvent->directionSequenceIndex = 2;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceDownRightLeftUp, gMovementTypeFuncs_WalkSequenceDownRightLeftUp)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceDownRightLeftUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gDownRightLeftUpDirections)];
|
|
|
|
memcpy(directions, gDownRightLeftUpDirections, sizeof(gDownRightLeftUpDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceRightUpDownLeft, gMovementTypeFuncs_WalkSequenceRightUpDownLeft)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceRightUpDownLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gRightUpDownLeftDirections)];
|
|
|
|
memcpy(directions, gRightUpDownLeftDirections, sizeof(gRightUpDownLeftDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceUpDownLeftRight, gMovementTypeFuncs_WalkSequenceUpDownLeftRight)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceUpDownLeftRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gUpDownLeftRightDirections)];
|
|
|
|
memcpy(directions, gUpDownLeftRightDirections, sizeof(gUpDownLeftRightDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
|
|
|
objectEvent->directionSequenceIndex = 2;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceLeftRightUpDown, gMovementTypeFuncs_WalkSequenceLeftRightUpDown)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceLeftRightUpDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gLeftRightUpDownDirections)];
|
|
|
|
memcpy(directions, gLeftRightUpDownDirections, sizeof(gLeftRightUpDownDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.x == objectEvent->currentCoords.x)
|
|
|
|
objectEvent->directionSequenceIndex = 2;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceDownLeftRightUp, gMovementTypeFuncs_WalkSequenceDownLeftRightUp)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceDownLeftRightUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gDownLeftRightUpDirections)];
|
|
|
|
memcpy(directions, gDownLeftRightUpDirections, sizeof(gDownLeftRightUpDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceUpLeftDownRight, gMovementTypeFuncs_WalkSequenceUpLeftDownRight)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceUpLeftDownRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gUpLeftDownRightDirections)];
|
|
|
|
memcpy(directions, gUpLeftDownRightDirections, sizeof(gUpLeftDownRightDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceDownRightUpLeft, gMovementTypeFuncs_WalkSequenceDownRightUpLeft)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceDownRightUpLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gDownRightUpLeftDirections)];
|
|
|
|
memcpy(directions, gDownRightUpLeftDirections, sizeof(gDownRightUpLeftDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceLeftDownRightUp, gMovementTypeFuncs_WalkSequenceLeftDownRightUp)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceLeftDownRightUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gLeftDownRightUpDirections)];
|
|
|
|
memcpy(directions, gLeftDownRightUpDirections, sizeof(gLeftDownRightUpDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceRightUpLeftDown, gMovementTypeFuncs_WalkSequenceRightUpLeftDown)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceRightUpLeftDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gRightUpLeftDownDirections)];
|
|
|
|
memcpy(directions, gRightUpLeftDownDirections, sizeof(gRightUpLeftDownDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceUpRightDownLeft, gMovementTypeFuncs_WalkSequenceUpRightDownLeft)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceUpRightDownLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gUpRightDownLeftDirections)];
|
|
|
|
memcpy(directions, gUpRightDownLeftDirections, sizeof(gUpRightDownLeftDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceDownLeftUpRight, gMovementTypeFuncs_WalkSequenceDownLeftUpRight)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceDownLeftUpRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gDownLeftUpRightDirections)];
|
|
|
|
memcpy(directions, gDownLeftUpRightDirections, sizeof(gDownLeftUpRightDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceLeftUpRightDown, gMovementTypeFuncs_WalkSequenceLeftUpRightDown)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceLeftUpRightDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gLeftUpRightDownDirections)];
|
|
|
|
memcpy(directions, gLeftUpRightDownDirections, sizeof(gLeftUpRightDownDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_WalkSequenceRightDownLeftUp, gMovementTypeFuncs_WalkSequenceRightDownLeftUp)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementType_WalkSequenceRightDownLeftUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 directions[sizeof(gRightDownLeftUpDirections)];
|
|
|
|
memcpy(directions, gRightDownLeftUpDirections, sizeof(gRightDownLeftUpDirections));
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x)
|
|
|
|
objectEvent->directionSequenceIndex = 3;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MoveNextDirectionInSequence(objectEvent, sprite, directions);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
movement_type_def(MovementType_CopyPlayer, gMovementTypeFuncs_CopyPlayer)
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_CopyPlayer_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
|
|
|
if (objectEvent->directionSequenceIndex == 0)
|
|
|
|
objectEvent->directionSequenceIndex = GetPlayerFacingDirection();
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-16 15:43:49 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_CopyPlayer_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 15:43:49 +02:00
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
if (gObjectEvents[gPlayerAvatar.objectEventId].movementActionId == MOVEMENT_ACTION_NONE || gPlayerAvatar.tileTransitionState == T_TILE_CENTER)
|
2017-09-16 15:43:49 +02:00
|
|
|
return FALSE;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return gCopyPlayerMovementFuncs[PlayerGetCopyableMovement()](objectEvent, sprite, GetPlayerMovementDirection(), NULL);
|
2017-09-16 15:43:49 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_CopyPlayer_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 15:43:49 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-16 15:43:49 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-16 15:43:49 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 CopyablePlayerMovement_None(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
2017-09-16 15:43:49 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 CopyablePlayerMovement_FaceDirection(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
2017-09-16 15:43:49 +02:00
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection)));
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-16 15:43:49 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
bool8 CopyablePlayerMovement_WalkNormal(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
2017-09-16 19:54:33 +02:00
|
|
|
{
|
|
|
|
u32 direction;
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
|
|
|
|
direction = playerDirection;
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventIsFarawayIslandMew(objectEvent))
|
2017-09-16 19:54:33 +02:00
|
|
|
{
|
2019-03-31 21:09:40 +02:00
|
|
|
direction = GetMewMoveDirection();
|
|
|
|
if (direction == DIR_NONE)
|
2017-09-16 19:54:33 +02:00
|
|
|
{
|
|
|
|
direction = playerDirection;
|
2021-11-01 23:06:15 +01:00
|
|
|
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-16 19:54:33 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
2017-09-16 19:54:33 +02:00
|
|
|
}
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(direction));
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-16 19:54:33 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
bool8 CopyablePlayerMovement_WalkFast(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
2017-09-16 22:10:55 +02:00
|
|
|
{
|
|
|
|
u32 direction;
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
|
|
|
|
direction = playerDirection;
|
2021-11-01 23:06:15 +01:00
|
|
|
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFastMovementAction(direction));
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-16 22:10:55 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
bool8 CopyablePlayerMovement_WalkFaster(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
2017-09-16 22:10:55 +02:00
|
|
|
{
|
|
|
|
u32 direction;
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
|
|
|
|
direction = playerDirection;
|
2021-11-01 23:06:15 +01:00
|
|
|
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
2021-11-02 18:01:07 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFasterMovementAction(direction));
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-16 22:10:55 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 CopyablePlayerMovement_Slide(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
2017-09-16 22:10:55 +02:00
|
|
|
{
|
|
|
|
u32 direction;
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
|
|
|
|
direction = playerDirection;
|
2021-11-01 23:06:15 +01:00
|
|
|
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetSlideMovementAction(direction));
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-16 22:10:55 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
bool8 CopyablePlayerMovement_JumpInPlace(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
2017-09-16 22:10:55 +02:00
|
|
|
{
|
|
|
|
u32 direction;
|
|
|
|
|
|
|
|
direction = playerDirection;
|
2021-11-01 23:06:15 +01:00
|
|
|
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetJumpInPlaceMovementAction(direction));
|
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-16 22:10:55 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
bool8 CopyablePlayerMovement_Jump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
2017-09-16 22:10:55 +02:00
|
|
|
{
|
|
|
|
u32 direction;
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
|
|
|
|
direction = playerDirection;
|
2021-11-01 23:06:15 +01:00
|
|
|
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetJumpMovementAction(direction));
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-16 22:10:55 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
bool8 CopyablePlayerMovement_Jump2(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
2017-09-16 22:10:55 +02:00
|
|
|
{
|
|
|
|
u32 direction;
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
|
|
|
|
direction = playerDirection;
|
2021-11-01 23:06:15 +01:00
|
|
|
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
2019-11-21 04:55:44 +01:00
|
|
|
x = objectEvent->currentCoords.x;
|
|
|
|
y = objectEvent->currentCoords.y;
|
2018-06-14 00:51:26 +02:00
|
|
|
MoveCoordsInDirection(direction, &x, &y, 2, 2);
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetJump2MovementAction(direction));
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->singleMovementActive = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-16 22:10:55 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_CopyPlayerInGrass, gMovementTypeFuncs_CopyPlayerInGrass)
|
2017-09-16 22:40:00 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_CopyPlayerInGrass_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 22:40:00 +02:00
|
|
|
{
|
2021-04-06 20:51:39 +02:00
|
|
|
if (gObjectEvents[gPlayerAvatar.objectEventId].movementActionId == MOVEMENT_ACTION_NONE || gPlayerAvatar.tileTransitionState == T_TILE_CENTER)
|
2017-09-16 22:40:00 +02:00
|
|
|
return FALSE;
|
2021-04-06 20:51:39 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return gCopyPlayerMovementFuncs[PlayerGetCopyableMovement()](objectEvent, sprite, GetPlayerMovementDirection(), MetatileBehavior_IsPokeGrass);
|
2017-09-16 22:40:00 +02:00
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
void MovementType_TreeDisguise(struct Sprite *sprite)
|
2017-09-16 22:53:55 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEvent *objectEvent;
|
2017-09-16 22:53:55 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
objectEvent = &gObjectEvents[sprite->sObjEventId];
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 0 || (objectEvent->directionSequenceIndex == 1 && !sprite->data[7]))
|
2017-09-16 22:53:55 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventGetLocalIdAndMap(objectEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]);
|
|
|
|
objectEvent->fieldEffectSpriteId = FieldEffectStart(FLDEFF_TREE_DISGUISE);
|
|
|
|
objectEvent->directionSequenceIndex = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->data[7]++;
|
2017-09-16 22:53:55 +02:00
|
|
|
}
|
2021-04-06 11:05:33 +02:00
|
|
|
UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->sObjEventId], sprite, MovementType_Disguise_Callback);
|
2017-09-16 22:53:55 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static bool8 MovementType_Disguise_Callback(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 22:53:55 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2017-09-16 22:53:55 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
void MovementType_MountainDisguise(struct Sprite *sprite)
|
2017-09-16 22:53:55 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEvent *objectEvent;
|
2017-09-16 22:53:55 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
objectEvent = &gObjectEvents[sprite->sObjEventId];
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->directionSequenceIndex == 0 || (objectEvent->directionSequenceIndex == 1 && !sprite->data[7]))
|
2017-09-16 22:53:55 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventGetLocalIdAndMap(objectEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]);
|
|
|
|
objectEvent->fieldEffectSpriteId = FieldEffectStart(FLDEFF_MOUNTAIN_DISGUISE);
|
|
|
|
objectEvent->directionSequenceIndex = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->data[7]++;
|
2017-09-16 22:53:55 +02:00
|
|
|
}
|
2021-04-06 11:05:33 +02:00
|
|
|
UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->sObjEventId], sprite, MovementType_Disguise_Callback);
|
2017-09-16 22:53:55 +02:00
|
|
|
}
|
|
|
|
|
2021-02-14 20:25:23 +01:00
|
|
|
void MovementType_Buried(struct Sprite *sprite)
|
2017-09-16 23:24:26 +02:00
|
|
|
{
|
2017-12-02 21:44:50 +01:00
|
|
|
if (!sprite->data[7])
|
2017-09-16 23:24:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
gObjectEvents[sprite->sObjEventId].fixedPriority = TRUE;
|
2019-12-05 03:00:45 +01:00
|
|
|
sprite->subspriteMode = SUBSPRITES_IGNORE_PRIORITY;
|
2017-09-16 23:24:26 +02:00
|
|
|
sprite->oam.priority = 3;
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->data[7]++;
|
2017-09-16 23:24:26 +02:00
|
|
|
}
|
2021-04-06 11:05:33 +02:00
|
|
|
UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->sObjEventId], sprite, MovementType_Buried_Callback);
|
2017-09-16 23:24:26 +02:00
|
|
|
}
|
|
|
|
|
2021-02-14 20:25:23 +01:00
|
|
|
static bool8 MovementType_Buried_Callback(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 23:24:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return gMovementTypeFuncs_Buried[sprite->sTypeFuncId](objectEvent, sprite);
|
2017-09-16 23:24:26 +02:00
|
|
|
}
|
|
|
|
|
2021-02-14 20:25:23 +01:00
|
|
|
bool8 MovementType_Buried_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 23:24:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2017-09-16 23:24:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2018-06-14 00:51:26 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_MoveInPlace_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 23:24:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 0;
|
2017-09-16 23:24:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_WalkInPlace, gMovementTypeFuncs_WalkInPlace)
|
2017-09-16 23:34:41 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WalkInPlace_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 23:34:41 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceNormalMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-16 23:34:41 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_WalkSlowlyInPlace, gMovementTypeFuncs_WalkSlowlyInPlace)
|
2017-09-16 23:34:41 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_WalkSlowlyInPlace_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 23:34:41 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceSlowMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-16 23:34:41 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_JogInPlace, gMovementTypeFuncs_JogInPlace)
|
2017-09-16 23:34:41 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_JogInPlace_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 23:34:41 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceFastMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-16 23:34:41 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_RunInPlace, gMovementTypeFuncs_RunInPlace)
|
2017-09-16 23:34:41 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_RunInPlace_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 23:34:41 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
2021-11-04 18:54:34 +01:00
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceFasterMovementAction(objectEvent->facingDirection));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-16 23:34:41 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
movement_type_def(MovementType_Invisible, gMovementTypeFuncs_Invisible)
|
2017-09-16 23:34:41 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_Invisible_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 23:34:41 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ClearObjectEventMovement(objectEvent, sprite);
|
|
|
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(objectEvent->facingDirection));
|
|
|
|
objectEvent->invisible = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 1;
|
2017-09-16 23:34:41 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_Invisible_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 23:34:41 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
2017-09-16 23:34:41 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 2;
|
2017-09-16 23:34:41 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementType_Invisible_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 23:34:41 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2017-09-16 23:34:41 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void ClearObjectEventMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-16 23:41:46 +02:00
|
|
|
{
|
2021-01-26 11:16:01 +01:00
|
|
|
objectEvent->singleMovementActive = FALSE;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->heldMovementActive = FALSE;
|
|
|
|
objectEvent->heldMovementFinished = FALSE;
|
2021-11-01 23:06:15 +01:00
|
|
|
objectEvent->movementActionId = MOVEMENT_ACTION_NONE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTypeFuncId = 0;
|
2017-09-16 23:41:46 +02:00
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 GetFaceDirectionAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sFaceDirectionAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetMoveDirectionAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sMoveDirectionAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetMoveDirectionFastAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sMoveDirectionFastAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetMoveDirectionFasterAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sMoveDirectionFasterAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetMoveDirectionFastestAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sMoveDirectionFastestAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetJumpSpecialDirectionAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sJumpSpecialDirectionAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetAcroWheelieDirectionAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sAcroWheelieDirectionAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
u8 GetAcroUnusedDirectionAnimNum(u8 direction)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sAcroUnusedDirectionAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetAcroEndWheelieDirectionAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sAcroEndWheelieDirectionAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetAcroUnusedActionDirectionAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sAcroUnusedActionDirectionAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetAcroWheeliePedalDirectionAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sAcroWheeliePedalDirectionAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetFishingDirectionAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sFishingDirectionAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetFishingNoCatchDirectionAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sFishingNoCatchDirectionAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetFishingBiteDirectionAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sFishingBiteDirectionAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 GetRunningDirectionAnimNum(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sRunningDirectionAnimNums[direction];
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
2017-09-16 23:41:46 +02:00
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
static const struct StepAnimTable *GetStepAnimTable(const union AnimCmd *const *anims)
|
2017-09-17 00:04:26 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
const struct StepAnimTable *stepTable;
|
2017-09-17 00:04:26 +02:00
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
for (stepTable = sStepAnimTables; stepTable->anims != NULL; stepTable++)
|
2017-09-17 00:04:26 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
if (stepTable->anims == anims)
|
|
|
|
return stepTable;
|
2017-09-17 00:04:26 +02:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
void SetStepAnimHandleAlternation(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 animNum)
|
2017-09-17 00:18:34 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
const struct StepAnimTable *stepTable;
|
2017-09-17 00:18:34 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!objectEvent->inanimate)
|
2017-09-17 00:18:34 +02:00
|
|
|
{
|
|
|
|
sprite->animNum = animNum;
|
2021-04-06 23:55:29 +02:00
|
|
|
stepTable = GetStepAnimTable(sprite->anims);
|
|
|
|
if (stepTable != NULL)
|
2017-09-17 00:18:34 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
if (sprite->animCmdIndex == stepTable->animPos[0])
|
|
|
|
sprite->animCmdIndex = stepTable->animPos[3];
|
|
|
|
else if (sprite->animCmdIndex == stepTable->animPos[1])
|
|
|
|
sprite->animCmdIndex = stepTable->animPos[2];
|
2017-09-17 00:18:34 +02:00
|
|
|
}
|
|
|
|
SeekSpriteAnim(sprite, sprite->animCmdIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
void SetStepAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 animNum)
|
2017-09-17 00:18:34 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
const struct StepAnimTable *stepTable;
|
2017-09-17 00:18:34 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!objectEvent->inanimate)
|
2017-09-17 00:18:34 +02:00
|
|
|
{
|
|
|
|
u8 animPos;
|
|
|
|
|
|
|
|
sprite->animNum = animNum;
|
2021-04-06 23:55:29 +02:00
|
|
|
stepTable = GetStepAnimTable(sprite->anims);
|
|
|
|
if (stepTable != NULL)
|
2017-09-17 00:18:34 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
animPos = stepTable->animPos[1];
|
|
|
|
if (sprite->animCmdIndex <= stepTable->animPos[0])
|
|
|
|
animPos = stepTable->animPos[0];
|
|
|
|
|
2017-09-17 00:18:34 +02:00
|
|
|
SeekSpriteAnim(sprite, animPos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
u8 GetDirectionToFace(s16 x, s16 y, s16 targetX, s16 targetY)
|
2017-09-17 00:24:58 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (x > targetX)
|
2017-09-17 00:24:58 +02:00
|
|
|
return DIR_WEST;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
|
|
|
if (x < targetX)
|
2017-09-17 00:24:58 +02:00
|
|
|
return DIR_EAST;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
|
|
|
if (y > targetY)
|
2017-09-17 00:24:58 +02:00
|
|
|
return DIR_NORTH;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2017-09-17 00:24:58 +02:00
|
|
|
return DIR_SOUTH;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void SetTrainerMovementType(struct ObjectEvent *objectEvent, u8 movementType)
|
2017-09-17 00:29:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->movementType = movementType;
|
|
|
|
objectEvent->directionSequenceIndex = 0;
|
|
|
|
objectEvent->playerCopyableMovement = 0;
|
|
|
|
gSprites[objectEvent->spriteId].callback = sMovementTypeCallbacks[movementType];
|
2021-04-06 11:05:33 +02:00
|
|
|
gSprites[objectEvent->spriteId].sTypeFuncId = 0;
|
2017-09-17 00:29:14 +02:00
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 GetTrainerFacingDirectionMovementType(u8 direction)
|
|
|
|
{
|
|
|
|
return gTrainerFacingDirectionMovementTypes[direction];
|
|
|
|
}
|
2017-09-17 00:33:38 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static u8 GetCollisionInDirection(struct ObjectEvent *objectEvent, u8 direction)
|
2017-09-17 00:33:38 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
s16 x = objectEvent->currentCoords.x;
|
|
|
|
s16 y = objectEvent->currentCoords.y;
|
2017-09-17 00:33:38 +02:00
|
|
|
MoveCoords(direction, &x, &y);
|
2019-11-21 04:55:44 +01:00
|
|
|
return GetCollisionAtCoords(objectEvent, x, y, direction);
|
2017-09-17 00:33:38 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir)
|
2017-09-17 00:42:35 +02:00
|
|
|
{
|
2019-10-06 22:40:10 +02:00
|
|
|
u8 direction = dir;
|
2019-11-21 04:55:44 +01:00
|
|
|
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
|
2019-10-06 22:40:10 +02:00
|
|
|
return COLLISION_OUTSIDE_RANGE;
|
2022-08-03 20:21:13 +02:00
|
|
|
else if (MapGridGetCollisionAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction))
|
2019-10-06 22:40:10 +02:00
|
|
|
return COLLISION_IMPASSABLE;
|
2019-11-21 04:55:44 +01:00
|
|
|
else if (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction))
|
2019-10-06 22:40:10 +02:00
|
|
|
return COLLISION_IMPASSABLE;
|
2022-01-21 18:48:19 +01:00
|
|
|
else if (IsElevationMismatchAt(objectEvent->currentElevation, x, y))
|
2019-10-06 22:40:10 +02:00
|
|
|
return COLLISION_ELEVATION_MISMATCH;
|
2019-11-21 04:55:44 +01:00
|
|
|
else if (DoesObjectCollideWithObjectAt(objectEvent, x, y))
|
2019-11-21 05:12:51 +01:00
|
|
|
return COLLISION_OBJECT_EVENT;
|
2019-10-06 22:40:10 +02:00
|
|
|
return COLLISION_NONE;
|
2017-09-17 00:42:35 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 GetCollisionFlagsAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction)
|
2017-09-17 00:52:20 +02:00
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 flags = 0;
|
2017-09-17 00:52:20 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
|
2022-01-30 03:13:46 +01:00
|
|
|
flags |= 1 << (COLLISION_OUTSIDE_RANGE - 1);
|
2022-08-03 20:21:13 +02:00
|
|
|
if (MapGridGetCollisionAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)))
|
2022-01-30 03:13:46 +01:00
|
|
|
flags |= 1 << (COLLISION_IMPASSABLE - 1);
|
2022-01-21 18:48:19 +01:00
|
|
|
if (IsElevationMismatchAt(objectEvent->currentElevation, x, y))
|
2022-01-30 03:13:46 +01:00
|
|
|
flags |= 1 << (COLLISION_ELEVATION_MISMATCH - 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
if (DoesObjectCollideWithObjectAt(objectEvent, x, y))
|
2022-01-30 03:13:46 +01:00
|
|
|
flags |= 1 << (COLLISION_OBJECT_EVENT - 1);
|
2018-06-14 00:51:26 +02:00
|
|
|
return flags;
|
2017-09-17 00:52:20 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static bool8 IsCoordOutsideObjectEventMovementRange(struct ObjectEvent *objectEvent, s16 x, s16 y)
|
2017-09-17 03:04:52 +02:00
|
|
|
{
|
|
|
|
s16 left;
|
|
|
|
s16 right;
|
|
|
|
s16 top;
|
|
|
|
s16 bottom;
|
|
|
|
|
2020-09-18 00:24:11 +02:00
|
|
|
if (objectEvent->rangeX != 0)
|
2017-09-17 03:04:52 +02:00
|
|
|
{
|
2020-09-18 00:24:11 +02:00
|
|
|
left = objectEvent->initialCoords.x - objectEvent->rangeX;
|
|
|
|
right = objectEvent->initialCoords.x + objectEvent->rangeX;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2017-09-17 03:04:52 +02:00
|
|
|
if (left > x || right < x)
|
|
|
|
return TRUE;
|
|
|
|
}
|
2020-09-18 00:24:11 +02:00
|
|
|
if (objectEvent->rangeY != 0)
|
2017-09-17 03:04:52 +02:00
|
|
|
{
|
2020-09-18 00:24:11 +02:00
|
|
|
top = objectEvent->initialCoords.y - objectEvent->rangeY;
|
|
|
|
bottom = objectEvent->initialCoords.y + objectEvent->rangeY;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2017-09-17 03:04:52 +02:00
|
|
|
if (top > y || bottom < y)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static bool8 IsMetatileDirectionallyImpassable(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction)
|
2017-09-17 03:08:44 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gOppositeDirectionBlockedMetatileFuncs[direction - 1](objectEvent->currentMetatileBehavior)
|
2018-06-14 00:51:26 +02:00
|
|
|
|| gDirectionBlockedMetatileFuncs[direction - 1](MapGridGetMetatileBehaviorAt(x, y)))
|
2017-09-17 03:08:44 +02:00
|
|
|
return TRUE;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2017-09-17 03:08:44 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static bool8 DoesObjectCollideWithObjectAt(struct ObjectEvent *objectEvent, s16 x, s16 y)
|
2017-09-17 03:29:04 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEvent *curObject;
|
2017-09-17 03:29:04 +02:00
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2017-09-17 03:29:04 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
curObject = &gObjectEvents[i];
|
|
|
|
if (curObject->active && curObject != objectEvent)
|
2017-09-17 03:29:04 +02:00
|
|
|
{
|
2018-06-11 16:19:17 +02:00
|
|
|
if ((curObject->currentCoords.x == x && curObject->currentCoords.y == y) || (curObject->previousCoords.x == x && curObject->previousCoords.y == y))
|
2017-09-17 03:29:04 +02:00
|
|
|
{
|
2022-01-21 18:48:19 +01:00
|
|
|
if (AreElevationsCompatible(objectEvent->currentElevation, curObject->currentElevation))
|
2017-09-17 03:29:04 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
bool8 IsBerryTreeSparkling(u8 localId, u8 mapNum, u8 mapGroup)
|
2017-09-17 03:31:37 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2017-09-17 03:31:37 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId)
|
2021-01-26 11:16:01 +01:00
|
|
|
&& gSprites[gObjectEvents[objectEventId].spriteId].sBerryTreeFlags & BERRY_FLAG_SPARKLING)
|
2017-09-17 03:31:37 +02:00
|
|
|
return TRUE;
|
2018-06-14 00:51:26 +02:00
|
|
|
|
2017-09-17 03:31:37 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-01-26 11:16:01 +01:00
|
|
|
void SetBerryTreeJustPicked(u8 localId, u8 mapNum, u8 mapGroup)
|
2017-09-17 03:39:29 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 objectEventId;
|
2017-09-17 03:39:29 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId))
|
2021-01-26 11:16:01 +01:00
|
|
|
gSprites[gObjectEvents[objectEventId].spriteId].sBerryTreeFlags |= BERRY_FLAG_JUST_PICKED;
|
2017-09-17 03:39:29 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
#undef sTimer
|
|
|
|
#undef sBerryTreeFlags
|
|
|
|
|
2017-09-17 03:39:29 +02:00
|
|
|
void MoveCoords(u8 direction, s16 *x, s16 *y)
|
|
|
|
{
|
2018-09-05 00:31:37 +02:00
|
|
|
*x += sDirectionToVectors[direction].x;
|
|
|
|
*y += sDirectionToVectors[direction].y;
|
2017-09-17 03:39:29 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
// Unused
|
|
|
|
static void MoveCoordsInMapCoordIncrement(u8 direction, s16 *x, s16 *y)
|
2017-09-17 03:45:18 +02:00
|
|
|
{
|
2018-09-05 00:31:37 +02:00
|
|
|
*x += sDirectionToVectors[direction].x << 4;
|
|
|
|
*y += sDirectionToVectors[direction].y << 4;
|
2017-09-17 03:45:18 +02:00
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
static void MoveCoordsInDirection(u32 dir, s16 *x, s16 *y, s16 deltaX, s16 deltaY)
|
2017-09-17 03:52:55 +02:00
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 direction = dir;
|
|
|
|
s16 dx2 = (u16)deltaX;
|
|
|
|
s16 dy2 = (u16)deltaY;
|
2018-09-05 00:31:37 +02:00
|
|
|
if (sDirectionToVectors[direction].x > 0)
|
2018-06-14 00:51:26 +02:00
|
|
|
*x += dx2;
|
2018-09-05 00:31:37 +02:00
|
|
|
if (sDirectionToVectors[direction].x < 0)
|
2018-06-14 00:51:26 +02:00
|
|
|
*x -= dx2;
|
2018-09-05 00:31:37 +02:00
|
|
|
if (sDirectionToVectors[direction].y > 0)
|
2018-06-14 00:51:26 +02:00
|
|
|
*y += dy2;
|
2018-09-05 00:31:37 +02:00
|
|
|
if (sDirectionToVectors[direction].y < 0)
|
2018-06-14 00:51:26 +02:00
|
|
|
*y -= dy2;
|
2017-09-17 03:52:55 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
void GetMapCoordsFromSpritePos(s16 x, s16 y, s16 *destX, s16 *destY)
|
2017-09-17 03:59:14 +02:00
|
|
|
{
|
2019-04-02 03:04:23 +02:00
|
|
|
*destX = (x - gSaveBlock1Ptr->pos.x) << 4;
|
|
|
|
*destY = (y - gSaveBlock1Ptr->pos.y) << 4;
|
|
|
|
*destX -= gTotalCameraPixelOffsetX;
|
|
|
|
*destY -= gTotalCameraPixelOffsetY;
|
2017-09-17 03:59:14 +02:00
|
|
|
}
|
|
|
|
|
2019-04-02 03:04:23 +02:00
|
|
|
void SetSpritePosToMapCoords(s16 mapX, s16 mapY, s16 *destX, s16 *destY)
|
2017-09-17 04:15:54 +02:00
|
|
|
{
|
2019-04-02 03:04:23 +02:00
|
|
|
s16 dx = -gTotalCameraPixelOffsetX - gFieldCamera.x;
|
|
|
|
s16 dy = -gTotalCameraPixelOffsetY - gFieldCamera.y;
|
2018-10-16 15:55:16 +02:00
|
|
|
if (gFieldCamera.x > 0)
|
2020-06-01 16:23:12 +02:00
|
|
|
dx += 16;
|
2019-04-02 03:04:23 +02:00
|
|
|
|
2018-10-16 15:55:16 +02:00
|
|
|
if (gFieldCamera.x < 0)
|
2020-06-01 16:23:12 +02:00
|
|
|
dx -= 16;
|
2019-04-02 03:04:23 +02:00
|
|
|
|
2018-10-16 15:55:16 +02:00
|
|
|
if (gFieldCamera.y > 0)
|
2020-06-01 16:23:12 +02:00
|
|
|
dy += 16;
|
2019-04-02 03:04:23 +02:00
|
|
|
|
2018-10-16 15:55:16 +02:00
|
|
|
if (gFieldCamera.y < 0)
|
2020-06-01 16:23:12 +02:00
|
|
|
dy -= 16;
|
2019-04-02 03:04:23 +02:00
|
|
|
|
|
|
|
*destX = ((mapX - gSaveBlock1Ptr->pos.x) << 4) + dx;
|
|
|
|
*destY = ((mapY - gSaveBlock1Ptr->pos.y) << 4) + dy;
|
2017-09-17 04:15:54 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
void SetSpritePosToOffsetMapCoords(s16 *x, s16 *y, s16 dx, s16 dy)
|
2017-09-17 04:19:23 +02:00
|
|
|
{
|
2019-04-02 03:04:23 +02:00
|
|
|
SetSpritePosToMapCoords(*x, *y, x, y);
|
2017-09-17 04:19:23 +02:00
|
|
|
*x += dx;
|
|
|
|
*y += dy;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetObjectEventMovingCameraOffset(s16 *x, s16 *y)
|
2017-09-17 04:23:48 +02:00
|
|
|
{
|
|
|
|
*x = 0;
|
|
|
|
*y = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2018-10-16 15:55:16 +02:00
|
|
|
if (gFieldCamera.x > 0)
|
2018-06-14 00:51:26 +02:00
|
|
|
(*x)++;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2018-10-16 15:55:16 +02:00
|
|
|
if (gFieldCamera.x < 0)
|
2021-04-06 11:05:33 +02:00
|
|
|
(*x)--;
|
|
|
|
|
2018-10-16 15:55:16 +02:00
|
|
|
if (gFieldCamera.y > 0)
|
2018-06-14 00:51:26 +02:00
|
|
|
(*y)++;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2018-10-16 15:55:16 +02:00
|
|
|
if (gFieldCamera.y < 0)
|
2021-04-06 11:05:33 +02:00
|
|
|
(*y)--;
|
2017-09-17 04:23:48 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void ObjectEventMoveDestCoords(struct ObjectEvent *objectEvent, u32 direction, s16 *x, s16 *y)
|
2017-09-17 04:27:04 +02:00
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 newDirn = direction;
|
2019-11-21 04:55:44 +01:00
|
|
|
*x = objectEvent->currentCoords.x;
|
|
|
|
*y = objectEvent->currentCoords.y;
|
2018-06-14 00:51:26 +02:00
|
|
|
MoveCoords(newDirn, x, y);
|
2017-09-17 04:27:04 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 ObjectEventIsMovementOverridden(struct ObjectEvent *objectEvent)
|
2017-09-17 04:44:47 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->singleMovementActive || objectEvent->heldMovementActive)
|
2017-09-17 04:44:47 +02:00
|
|
|
return TRUE;
|
2018-06-14 00:51:26 +02:00
|
|
|
|
2017-09-17 04:44:47 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 ObjectEventIsHeldMovementActive(struct ObjectEvent *objectEvent)
|
2017-09-17 04:44:47 +02:00
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
if (objectEvent->heldMovementActive && objectEvent->movementActionId != MOVEMENT_ACTION_NONE)
|
2017-09-17 04:44:47 +02:00
|
|
|
return TRUE;
|
2018-06-14 00:51:26 +02:00
|
|
|
|
2017-09-17 04:44:47 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 ObjectEventSetHeldMovement(struct ObjectEvent *objectEvent, u8 movementActionId)
|
2017-09-17 04:44:47 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventIsMovementOverridden(objectEvent))
|
2017-09-17 04:44:47 +02:00
|
|
|
return TRUE;
|
2018-06-14 00:51:26 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
UnfreezeObjectEvent(objectEvent);
|
|
|
|
objectEvent->movementActionId = movementActionId;
|
|
|
|
objectEvent->heldMovementActive = TRUE;
|
|
|
|
objectEvent->heldMovementFinished = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
gSprites[objectEvent->spriteId].sActionFuncId = 0;
|
2017-09-17 04:44:47 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void ObjectEventForceSetHeldMovement(struct ObjectEvent *objectEvent, u8 movementActionId)
|
2017-09-17 04:44:47 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventClearHeldMovementIfActive(objectEvent);
|
|
|
|
ObjectEventSetHeldMovement(objectEvent, movementActionId);
|
2017-09-17 04:44:47 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void ObjectEventClearHeldMovementIfActive(struct ObjectEvent *objectEvent)
|
2017-09-17 04:44:47 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->heldMovementActive)
|
|
|
|
ObjectEventClearHeldMovement(objectEvent);
|
2017-09-17 04:44:47 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void ObjectEventClearHeldMovement(struct ObjectEvent *objectEvent)
|
2017-09-17 04:44:47 +02:00
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
objectEvent->movementActionId = MOVEMENT_ACTION_NONE;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->heldMovementActive = FALSE;
|
|
|
|
objectEvent->heldMovementFinished = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
gSprites[objectEvent->spriteId].sTypeFuncId = 0;
|
|
|
|
gSprites[objectEvent->spriteId].sActionFuncId = 0;
|
2017-09-17 04:44:47 +02:00
|
|
|
}
|
2017-09-16 15:43:49 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 ObjectEventCheckHeldMovementStatus(struct ObjectEvent *objectEvent)
|
2017-09-16 15:43:49 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->heldMovementActive)
|
|
|
|
return objectEvent->heldMovementFinished;
|
2018-06-14 00:51:26 +02:00
|
|
|
|
|
|
|
return 16;
|
2017-09-16 15:43:49 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 ObjectEventClearHeldMovementIfFinished(struct ObjectEvent *objectEvent)
|
2017-09-16 15:43:49 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 heldMovementStatus = ObjectEventCheckHeldMovementStatus(objectEvent);
|
2018-06-14 00:51:26 +02:00
|
|
|
if (heldMovementStatus != 0 && heldMovementStatus != 16)
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventClearHeldMovementIfActive(objectEvent);
|
2017-09-16 15:43:49 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
return heldMovementStatus;
|
2017-09-16 15:43:49 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 ObjectEventGetHeldMovementActionId(struct ObjectEvent *objectEvent)
|
2017-09-16 15:43:49 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->heldMovementActive)
|
|
|
|
return objectEvent->movementActionId;
|
2018-06-14 00:51:26 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
return MOVEMENT_ACTION_NONE;
|
2017-09-16 15:43:49 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void UpdateObjectEventCurrentMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite, bool8 (*callback)(struct ObjectEvent *, struct Sprite *))
|
2017-09-16 15:43:49 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
DoGroundEffects_OnSpawn(objectEvent, sprite);
|
|
|
|
TryEnableObjectEventAnim(objectEvent, sprite);
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (ObjectEventIsHeldMovementActive(objectEvent))
|
|
|
|
ObjectEventExecHeldMovementAction(objectEvent, sprite);
|
|
|
|
else if (!objectEvent->frozen)
|
|
|
|
while (callback(objectEvent, sprite));
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
DoGroundEffects_OnBeginStep(objectEvent, sprite);
|
|
|
|
DoGroundEffects_OnFinishStep(objectEvent, sprite);
|
|
|
|
UpdateObjectEventSpriteAnimPause(objectEvent, sprite);
|
|
|
|
UpdateObjectEventVisibility(objectEvent, sprite);
|
|
|
|
ObjectEventUpdateSubpriority(objectEvent, sprite);
|
2017-09-16 15:43:49 +02:00
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
#define dirn_to_anim(name, table)\
|
|
|
|
u8 name(u32 idx)\
|
|
|
|
{\
|
|
|
|
u8 direction;\
|
|
|
|
u8 animIds[sizeof(table)];\
|
|
|
|
direction = idx;\
|
|
|
|
memcpy(animIds, (table), sizeof(table));\
|
|
|
|
if (direction > DIR_EAST) direction = 0;\
|
|
|
|
return animIds[direction];\
|
|
|
|
}
|
|
|
|
|
|
|
|
dirn_to_anim(GetFaceDirectionMovementAction, gFaceDirectionMovementActions);
|
|
|
|
dirn_to_anim(GetWalkSlowMovementAction, gWalkSlowMovementActions);
|
|
|
|
dirn_to_anim(GetWalkNormalMovementAction, gWalkNormalMovementActions);
|
|
|
|
dirn_to_anim(GetWalkFastMovementAction, gWalkFastMovementActions);
|
|
|
|
dirn_to_anim(GetRideWaterCurrentMovementAction, gRideWaterCurrentMovementActions);
|
2021-11-02 18:01:07 +01:00
|
|
|
dirn_to_anim(GetWalkFasterMovementAction, gWalkFasterMovementActions);
|
2018-06-14 00:51:26 +02:00
|
|
|
dirn_to_anim(GetSlideMovementAction, gSlideMovementActions);
|
|
|
|
dirn_to_anim(GetPlayerRunMovementAction, gPlayerRunMovementActions);
|
|
|
|
dirn_to_anim(GetJump2MovementAction, gJump2MovementActions);
|
|
|
|
dirn_to_anim(GetJumpInPlaceMovementAction, gJumpInPlaceMovementActions);
|
|
|
|
dirn_to_anim(GetJumpInPlaceTurnAroundMovementAction, gJumpInPlaceTurnAroundMovementActions);
|
|
|
|
dirn_to_anim(GetJumpMovementAction, gJumpMovementActions);
|
|
|
|
dirn_to_anim(GetJumpSpecialMovementAction, gJumpSpecialMovementActions);
|
|
|
|
dirn_to_anim(GetWalkInPlaceSlowMovementAction, gWalkInPlaceSlowMovementActions);
|
|
|
|
dirn_to_anim(GetWalkInPlaceNormalMovementAction, gWalkInPlaceNormalMovementActions);
|
|
|
|
dirn_to_anim(GetWalkInPlaceFastMovementAction, gWalkInPlaceFastMovementActions);
|
2021-11-04 18:54:34 +01:00
|
|
|
dirn_to_anim(GetWalkInPlaceFasterMovementAction, gWalkInPlaceFasterMovementActions);
|
2017-09-17 04:54:15 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 ObjectEventFaceOppositeDirection(struct ObjectEvent *objectEvent, u8 direction)
|
2017-09-17 04:54:15 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
return ObjectEventSetHeldMovement(objectEvent, GetFaceDirectionMovementAction(GetOppositeDirection(direction)));
|
2017-09-17 04:54:15 +02:00
|
|
|
}
|
2017-09-17 04:58:17 +02:00
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
dirn_to_anim(GetAcroWheelieFaceDirectionMovementAction, gAcroWheelieFaceDirectionMovementActions);
|
|
|
|
dirn_to_anim(GetAcroPopWheelieFaceDirectionMovementAction, gAcroPopWheelieFaceDirectionMovementActions);
|
|
|
|
dirn_to_anim(GetAcroEndWheelieFaceDirectionMovementAction, gAcroEndWheelieFaceDirectionMovementActions);
|
|
|
|
dirn_to_anim(GetAcroWheelieHopFaceDirectionMovementAction, gAcroWheelieHopFaceDirectionMovementActions);
|
|
|
|
dirn_to_anim(GetAcroWheelieHopDirectionMovementAction, gAcroWheelieHopDirectionMovementActions);
|
|
|
|
dirn_to_anim(GetAcroWheelieJumpDirectionMovementAction, gAcroWheelieJumpDirectionMovementActions);
|
|
|
|
dirn_to_anim(GetAcroWheelieInPlaceDirectionMovementAction, gAcroWheelieInPlaceDirectionMovementActions);
|
|
|
|
dirn_to_anim(GetAcroPopWheelieMoveDirectionMovementAction, gAcroPopWheelieMoveDirectionMovementActions);
|
|
|
|
dirn_to_anim(GetAcroWheelieMoveDirectionMovementAction, gAcroWheelieMoveDirectionMovementActions);
|
|
|
|
dirn_to_anim(GetAcroEndWheelieMoveDirectionMovementAction, gAcroEndWheelieMoveDirectionMovementActions);
|
2017-09-17 05:03:04 +02:00
|
|
|
|
|
|
|
u8 GetOppositeDirection(u8 direction)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
u8 directions[sizeof sOppositeDirections];
|
2017-09-17 05:03:04 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
memcpy(directions, sOppositeDirections, sizeof sOppositeDirections);
|
|
|
|
if (direction <= DIR_NONE || direction > (sizeof sOppositeDirections))
|
2017-09-17 05:03:04 +02:00
|
|
|
return direction;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2017-09-17 05:03:04 +02:00
|
|
|
return directions[direction - 1];
|
|
|
|
}
|
2017-09-17 05:05:53 +02:00
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
// Takes the player's original and current direction and gives a direction the copy NPC should consider as the player's direction.
|
|
|
|
// See comments at the table's definition.
|
|
|
|
static u32 GetPlayerDirectionForCopy(u8 initDir, u8 moveDir)
|
2017-09-17 05:05:53 +02:00
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
return sPlayerDirectionsForCopy[initDir - 1][moveDir - 1];
|
2017-09-17 05:05:53 +02:00
|
|
|
}
|
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
// copyInitDir is the initial facing direction of the copying NPC.
|
|
|
|
// playerInitDir is the direction the player was facing when the copying NPC was spawned, as set by MovementType_CopyPlayer_Step0.
|
|
|
|
// playerMoveDir is the direction the player is currently moving.
|
|
|
|
static u32 GetCopyDirection(u8 copyInitDir, u32 playerInitDir, u32 playerMoveDir)
|
2017-09-17 05:05:53 +02:00
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
u32 dir;
|
|
|
|
u8 _playerInitDir = playerInitDir;
|
|
|
|
u8 _playerMoveDir = playerMoveDir;
|
|
|
|
if (_playerInitDir == DIR_NONE || _playerMoveDir == DIR_NONE
|
|
|
|
|| _playerInitDir > DIR_EAST || _playerMoveDir > DIR_EAST)
|
|
|
|
return DIR_NONE;
|
2017-09-17 05:11:09 +02:00
|
|
|
|
2021-11-01 23:06:15 +01:00
|
|
|
dir = GetPlayerDirectionForCopy(_playerInitDir, playerMoveDir);
|
|
|
|
return sPlayerDirectionToCopyDirection[copyInitDir - 1][dir - 1];
|
2017-09-17 05:05:53 +02:00
|
|
|
}
|
2017-09-17 05:11:09 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void ObjectEventExecHeldMovementAction(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 05:11:09 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (gMovementActionFuncs[objectEvent->movementActionId][sprite->sActionFuncId](objectEvent, sprite))
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->heldMovementFinished = TRUE;
|
2017-09-17 05:11:09 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 05:11:09 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (gMovementActionFuncs[objectEvent->movementActionId][sprite->sActionFuncId](objectEvent, sprite))
|
2017-09-17 05:11:09 +02:00
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
objectEvent->movementActionId = MOVEMENT_ACTION_NONE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 0;
|
2017-09-17 05:11:09 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-17 05:12:35 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void ObjectEventSetSingleMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 animId)
|
2017-09-17 05:12:35 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->movementActionId = animId;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 0;
|
2017-09-17 05:12:35 +02:00
|
|
|
}
|
2017-09-17 05:20:44 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void FaceDirection(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction)
|
2017-09-17 05:20:44 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
|
|
|
ShiftStillObjectEventCoords(objectEvent);
|
2021-04-06 23:55:29 +02:00
|
|
|
SetStepAnim(objectEvent, sprite, GetMoveDirectionAnimNum(objectEvent->facingDirection));
|
2017-09-17 05:20:44 +02:00
|
|
|
sprite->animPaused = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2017-09-17 05:20:44 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_FaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 05:20:44 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
FaceDirection(objectEvent, sprite, DIR_SOUTH);
|
2017-09-17 05:20:44 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_FaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 05:20:44 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
FaceDirection(objectEvent, sprite, DIR_NORTH);
|
2017-09-17 05:20:44 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_FaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 05:20:44 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
FaceDirection(objectEvent, sprite, DIR_WEST);
|
2017-09-17 05:20:44 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_FaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 05:20:44 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
FaceDirection(objectEvent, sprite, DIR_EAST);
|
2017-09-17 05:20:44 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-17 05:31:43 +02:00
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
void InitNpcForMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed)
|
2017-09-17 05:31:43 +02:00
|
|
|
{
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
x = objectEvent->currentCoords.x;
|
|
|
|
y = objectEvent->currentCoords.y;
|
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2017-09-17 05:31:43 +02:00
|
|
|
MoveCoords(direction, &x, &y);
|
2019-11-21 04:55:44 +01:00
|
|
|
ShiftObjectEventCoords(objectEvent, x, y);
|
2021-04-06 23:55:29 +02:00
|
|
|
SetSpriteDataForNormalStep(sprite, direction, speed);
|
2017-09-17 05:31:43 +02:00
|
|
|
sprite->animPaused = FALSE;
|
2021-04-06 23:55:29 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
if (sLockedAnimObjectEvents != NULL && FindLockedObjectEventIndex(objectEvent) != OBJECT_EVENTS_COUNT)
|
2017-09-17 05:31:43 +02:00
|
|
|
sprite->animPaused = TRUE;
|
2021-04-06 23:55:29 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->triggerGroundEffectsOnMove = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2017-09-17 05:31:43 +02:00
|
|
|
}
|
2017-09-17 05:49:31 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void InitMovementNormal(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed)
|
2017-09-17 05:49:31 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
u8 (*functions[ARRAY_COUNT(sDirectionAnimFuncsBySpeed)])(u8);
|
2017-09-17 05:49:31 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
memcpy(functions, sDirectionAnimFuncsBySpeed, sizeof sDirectionAnimFuncsBySpeed);
|
2021-04-06 23:55:29 +02:00
|
|
|
InitNpcForMovement(objectEvent, sprite, direction, speed);
|
|
|
|
SetStepAnimHandleAlternation(objectEvent, sprite, functions[speed](objectEvent->facingDirection));
|
2017-09-17 05:49:31 +02:00
|
|
|
}
|
2017-09-17 05:52:50 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void StartRunningAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction)
|
2017-09-17 05:52:50 +02:00
|
|
|
{
|
2021-11-03 13:51:41 +01:00
|
|
|
InitNpcForMovement(objectEvent, sprite, direction, MOVE_SPEED_FAST_1);
|
2021-04-06 23:55:29 +02:00
|
|
|
SetStepAnimHandleAlternation(objectEvent, sprite, GetRunningDirectionAnimNum(objectEvent->facingDirection));
|
2017-09-17 05:52:50 +02:00
|
|
|
}
|
2017-09-17 14:05:33 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static bool8 UpdateMovementNormal(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 14:05:33 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
if (NpcTakeStep(sprite))
|
2017-09-17 14:05:33 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ShiftStillObjectEventCoords(objectEvent);
|
|
|
|
objectEvent->triggerGroundEffectsOnStop = TRUE;
|
2017-09-17 14:05:33 +02:00
|
|
|
sprite->animPaused = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-17 14:20:42 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void InitNpcForWalkSlow(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction)
|
2017-09-17 14:20:42 +02:00
|
|
|
{
|
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
x = objectEvent->currentCoords.x;
|
|
|
|
y = objectEvent->currentCoords.y;
|
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2017-09-17 14:20:42 +02:00
|
|
|
MoveCoords(direction, &x, &y);
|
2019-11-21 04:55:44 +01:00
|
|
|
ShiftObjectEventCoords(objectEvent, x, y);
|
2021-04-06 11:05:33 +02:00
|
|
|
SetWalkSlowSpriteData(sprite, direction);
|
2017-09-17 14:20:42 +02:00
|
|
|
sprite->animPaused = FALSE;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->triggerGroundEffectsOnMove = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2017-09-17 14:20:42 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void InitWalkSlow(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction)
|
2017-09-17 14:20:42 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitNpcForWalkSlow(objectEvent, sprite, direction);
|
2021-04-06 23:55:29 +02:00
|
|
|
SetStepAnimHandleAlternation(objectEvent, sprite, GetMoveDirectionAnimNum(objectEvent->facingDirection));
|
2017-09-17 14:20:42 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static bool8 UpdateWalkSlow(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 14:20:42 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateWalkSlowAnim(sprite))
|
2017-09-17 14:20:42 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ShiftStillObjectEventCoords(objectEvent);
|
|
|
|
objectEvent->triggerGroundEffectsOnStop = TRUE;
|
2017-09-17 14:20:42 +02:00
|
|
|
sprite->animPaused = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitWalkSlow(objectEvent, sprite, DIR_NORTHWEST);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkSlowDiagonalUpLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowDiagonalUpLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateWalkSlow(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowDiagonalUpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitWalkSlow(objectEvent, sprite, DIR_NORTHEAST);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkSlowDiagonalUpRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowDiagonalUpRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateWalkSlow(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowDiagonalDownLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitWalkSlow(objectEvent, sprite, DIR_SOUTHWEST);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkSlowDiagonalDownLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowDiagonalDownLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateWalkSlow(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowDiagonalDownRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitWalkSlow(objectEvent, sprite, DIR_SOUTHEAST);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkSlowDiagonalDownRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowDiagonalDownRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateWalkSlow(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitWalkSlow(objectEvent, sprite, DIR_SOUTH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkSlowDown_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateWalkSlow(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitWalkSlow(objectEvent, sprite, DIR_NORTH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkSlowUp_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateWalkSlow(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitWalkSlow(objectEvent, sprite, DIR_WEST);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkSlowLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateWalkSlow(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitWalkSlow(objectEvent, sprite, DIR_EAST);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkSlowRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkSlowRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateWalkSlow(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_NORTHWEST, MOVE_SPEED_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkNormalDiagonalUpLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalDiagonalUpLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalDiagonalUpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_NORTHEAST, MOVE_SPEED_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkNormalDiagonalUpRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalDiagonalUpRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalDiagonalDownLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_SOUTHWEST, MOVE_SPEED_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkNormalDiagonalDownLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalDiagonalDownLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalDiagonalDownRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_SOUTHEAST, MOVE_SPEED_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkNormalDiagonalDownRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalDiagonalDownRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_SOUTH, MOVE_SPEED_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkNormalDown_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_NORTH, MOVE_SPEED_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkNormalUp_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_WEST, MOVE_SPEED_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkNormalLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_EAST, MOVE_SPEED_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkNormalRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkNormalRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-17 14:20:42 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
#define JUMP_HALFWAY 1
|
|
|
|
#define JUMP_FINISHED ((u8)-1)
|
|
|
|
|
|
|
|
enum {
|
|
|
|
JUMP_TYPE_HIGH,
|
|
|
|
JUMP_TYPE_LOW,
|
|
|
|
JUMP_TYPE_NORMAL,
|
|
|
|
};
|
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
static void InitJump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 distance, u8 type)
|
2017-09-17 14:38:00 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
s16 displacements[ARRAY_COUNT(sJumpInitDisplacements)];
|
2017-09-17 14:38:00 +02:00
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
memcpy(displacements, sJumpInitDisplacements, sizeof sJumpInitDisplacements);
|
2017-09-17 14:38:00 +02:00
|
|
|
x = 0;
|
|
|
|
y = 0;
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-11-28 04:35:01 +01:00
|
|
|
MoveCoordsInDirection(direction, &x, &y, displacements[distance], displacements[distance]);
|
2019-11-21 04:55:44 +01:00
|
|
|
ShiftObjectEventCoords(objectEvent, objectEvent->currentCoords.x + x, objectEvent->currentCoords.y + y);
|
2021-11-28 04:35:01 +01:00
|
|
|
SetJumpSpriteData(sprite, direction, distance, type);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
|
|
|
sprite->animPaused = FALSE;
|
|
|
|
objectEvent->triggerGroundEffectsOnMove = TRUE;
|
|
|
|
objectEvent->disableCoveringGroundEffects = TRUE;
|
2017-09-17 14:38:00 +02:00
|
|
|
}
|
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
static void InitJumpRegular(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 distance, u8 type)
|
2017-09-17 14:38:00 +02:00
|
|
|
{
|
2021-11-28 04:35:01 +01:00
|
|
|
InitJump(objectEvent, sprite, direction, distance, type);
|
2021-04-06 23:55:29 +02:00
|
|
|
SetStepAnimHandleAlternation(objectEvent, sprite, GetMoveDirectionAnimNum(objectEvent->facingDirection));
|
2019-11-21 04:55:44 +01:00
|
|
|
DoShadowFieldEffect(objectEvent);
|
2017-09-17 14:38:00 +02:00
|
|
|
}
|
2017-09-17 14:45:24 +02:00
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
#define sDistance data[4]
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static u8 UpdateJumpAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 callback(struct Sprite *))
|
2017-09-17 14:45:24 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
s16 displacements[ARRAY_COUNT(sJumpDisplacements)];
|
2017-09-17 14:45:24 +02:00
|
|
|
s16 x;
|
|
|
|
s16 y;
|
|
|
|
u8 result;
|
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
memcpy(displacements, sJumpDisplacements, sizeof sJumpDisplacements);
|
2017-09-17 14:45:24 +02:00
|
|
|
result = callback(sprite);
|
2021-11-28 04:35:01 +01:00
|
|
|
if (result == JUMP_HALFWAY && displacements[sprite->sDistance] != 0)
|
2017-09-17 14:45:24 +02:00
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
2021-11-28 04:35:01 +01:00
|
|
|
MoveCoordsInDirection(objectEvent->movementDirection, &x, &y, displacements[sprite->sDistance], displacements[sprite->sDistance]);
|
2019-11-21 04:55:44 +01:00
|
|
|
ShiftObjectEventCoords(objectEvent, objectEvent->currentCoords.x + x, objectEvent->currentCoords.y + y);
|
|
|
|
objectEvent->triggerGroundEffectsOnMove = TRUE;
|
|
|
|
objectEvent->disableCoveringGroundEffects = TRUE;
|
2017-09-17 14:45:24 +02:00
|
|
|
}
|
2021-04-06 11:05:33 +02:00
|
|
|
else if (result == JUMP_FINISHED)
|
2017-09-17 14:45:24 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ShiftStillObjectEventCoords(objectEvent);
|
|
|
|
objectEvent->triggerGroundEffectsOnStop = TRUE;
|
|
|
|
objectEvent->landingJump = TRUE;
|
2017-09-17 14:45:24 +02:00
|
|
|
sprite->animPaused = TRUE;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2017-09-17 15:49:50 +02:00
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
#undef sDistance
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static u8 DoJumpAnimStep(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 15:49:50 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return UpdateJumpAnim(objectEvent, sprite, DoJumpSpriteMovement);
|
2017-09-17 15:49:50 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static u8 DoJumpSpecialAnimStep(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 15:49:50 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return UpdateJumpAnim(objectEvent, sprite, DoJumpSpecialSpriteMovement);
|
2017-09-17 15:49:50 +02:00
|
|
|
}
|
2017-09-17 15:52:17 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static bool8 DoJumpAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 15:52:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnimStep(objectEvent, sprite) == JUMP_FINISHED)
|
2017-09-17 15:52:17 +02:00
|
|
|
return TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2017-09-17 15:52:17 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static bool8 DoJumpSpecialAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 15:52:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpSpecialAnimStep(objectEvent, sprite) == JUMP_FINISHED)
|
2017-09-17 15:52:17 +02:00
|
|
|
return TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2017-09-17 15:52:17 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-17 15:55:17 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static bool8 DoJumpInPlaceAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 15:55:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
switch (DoJumpAnimStep(objectEvent, sprite))
|
2017-09-17 15:55:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
case JUMP_FINISHED:
|
2017-09-17 15:55:17 +02:00
|
|
|
return TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
case JUMP_HALFWAY:
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, GetOppositeDirection(objectEvent->movementDirection));
|
2021-04-06 23:55:29 +02:00
|
|
|
SetStepAnim(objectEvent, sprite, GetMoveDirectionAnimNum(objectEvent->facingDirection));
|
2017-09-17 15:55:17 +02:00
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2017-09-17 16:01:27 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Jump2Down_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_Jump2Down_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Jump2Down_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Jump2Up_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_Jump2Up_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Jump2Up_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Jump2Left_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_Jump2Left_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Jump2Left_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Jump2Right_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_Jump2Right_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Jump2Right_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void InitMovementDelay(struct Sprite *sprite, u16 duration)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->data[3] = duration;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Delay_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (--sprite->data[3] == 0)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Delay1_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMovementDelay(sprite, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_Delay_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Delay2_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMovementDelay(sprite, 2);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_Delay_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Delay4_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMovementDelay(sprite, 4);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_Delay_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Delay8_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMovementDelay(sprite, 8);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_Delay_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Delay16_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMovementDelay(sprite, 16);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_Delay_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkFastDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_SOUTH, MOVE_SPEED_FAST_1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkFastDown_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkFastDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkFastUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_NORTH, MOVE_SPEED_FAST_1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkFastUp_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkFastUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkFastLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_WEST, MOVE_SPEED_FAST_1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkFastLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkFastLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkFastRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_EAST, MOVE_SPEED_FAST_1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkFastRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkFastRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void InitMoveInPlace(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 animNum, u16 duration)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 23:55:29 +02:00
|
|
|
SetStepAnimHandleAlternation(objectEvent, sprite, animNum);
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->animPaused = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->data[3] = duration;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlace_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
if (-- sprite->data[3] == 0)
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->animPaused = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceSlow_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
if (sprite->data[3] & 1)
|
|
|
|
sprite->animDelayCounter++;
|
2021-11-01 23:06:15 +01:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceSlowDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_SOUTH, GetMoveDirectionAnimNum(DIR_SOUTH), 32);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlaceSlow_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceSlowUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_NORTH, GetMoveDirectionAnimNum(DIR_NORTH), 32);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlaceSlow_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceSlowLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_WEST, GetMoveDirectionAnimNum(DIR_WEST), 32);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlaceSlow_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceSlowRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_EAST, GetMoveDirectionAnimNum(DIR_EAST), 32);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlaceSlow_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceNormalDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_SOUTH, GetMoveDirectionAnimNum(DIR_SOUTH), 16);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceNormalUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_NORTH, GetMoveDirectionAnimNum(DIR_NORTH), 16);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceNormalLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_WEST, GetMoveDirectionAnimNum(DIR_WEST), 16);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceNormalRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_EAST, GetMoveDirectionAnimNum(DIR_EAST), 16);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceFastDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_SOUTH, GetMoveDirectionFastAnimNum(DIR_SOUTH), 8);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceFastUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_NORTH, GetMoveDirectionFastAnimNum(DIR_NORTH), 8);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceFastLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_WEST, GetMoveDirectionFastAnimNum(DIR_WEST), 8);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceFastRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_EAST, GetMoveDirectionFastAnimNum(DIR_EAST), 8);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2021-11-04 18:54:34 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceFasterDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_SOUTH, GetMoveDirectionFasterAnimNum(DIR_SOUTH), 4);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2021-11-04 18:54:34 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceFasterUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_NORTH, GetMoveDirectionFasterAnimNum(DIR_NORTH), 4);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2021-11-04 18:54:34 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceFasterLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_WEST, GetMoveDirectionFasterAnimNum(DIR_WEST), 4);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2021-11-04 18:54:34 +01:00
|
|
|
bool8 MovementAction_WalkInPlaceFasterRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_EAST, GetMoveDirectionFasterAnimNum(DIR_EAST), 4);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RideWaterCurrentDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_SOUTH, MOVE_SPEED_FAST_2);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_RideWaterCurrentDown_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RideWaterCurrentDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RideWaterCurrentUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_NORTH, MOVE_SPEED_FAST_2);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_RideWaterCurrentUp_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RideWaterCurrentUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RideWaterCurrentLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_WEST, MOVE_SPEED_FAST_2);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_RideWaterCurrentLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RideWaterCurrentLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RideWaterCurrentRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_EAST, MOVE_SPEED_FAST_2);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_RideWaterCurrentRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RideWaterCurrentRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-11-02 18:01:07 +01:00
|
|
|
bool8 MovementAction_WalkFasterDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_SOUTH, MOVE_SPEED_FASTER);
|
2021-11-02 18:01:07 +01:00
|
|
|
return MovementAction_WalkFasterDown_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2021-11-02 18:01:07 +01:00
|
|
|
bool8 MovementAction_WalkFasterDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-11-02 18:01:07 +01:00
|
|
|
bool8 MovementAction_WalkFasterUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_NORTH, MOVE_SPEED_FASTER);
|
2021-11-02 18:01:07 +01:00
|
|
|
return MovementAction_WalkFasterUp_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2021-11-02 18:01:07 +01:00
|
|
|
bool8 MovementAction_WalkFasterUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-11-02 18:01:07 +01:00
|
|
|
bool8 MovementAction_WalkFasterLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_WEST, MOVE_SPEED_FASTER);
|
2021-11-02 18:01:07 +01:00
|
|
|
return MovementAction_WalkFasterLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2021-11-02 18:01:07 +01:00
|
|
|
bool8 MovementAction_WalkFasterLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-11-02 18:01:07 +01:00
|
|
|
bool8 MovementAction_WalkFasterRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_EAST, MOVE_SPEED_FASTER);
|
2021-11-02 18:01:07 +01:00
|
|
|
return MovementAction_WalkFasterRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2021-11-02 18:01:07 +01:00
|
|
|
bool8 MovementAction_WalkFasterRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_SlideDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_SOUTH, MOVE_SPEED_FASTEST);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_SlideDown_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_SlideDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_SlideUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_NORTH, MOVE_SPEED_FASTEST);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_SlideUp_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_SlideUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_SlideLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_WEST, MOVE_SPEED_FASTEST);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_SlideLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_SlideLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_SlideRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_EAST, MOVE_SPEED_FASTEST);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_SlideRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_SlideRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_PlayerRunDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartRunningAnim(objectEvent, sprite, DIR_SOUTH);
|
|
|
|
return MovementAction_PlayerRunDown_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_PlayerRunDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_PlayerRunUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartRunningAnim(objectEvent, sprite, DIR_NORTH);
|
|
|
|
return MovementAction_PlayerRunUp_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_PlayerRunUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_PlayerRunLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartRunningAnim(objectEvent, sprite, DIR_WEST);
|
|
|
|
return MovementAction_PlayerRunLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_PlayerRunLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_PlayerRunRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartRunningAnim(objectEvent, sprite, DIR_EAST);
|
|
|
|
return MovementAction_PlayerRunRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_PlayerRunRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void StartSpriteAnimInDirection(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 animNum)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
SetAndStartSpriteAnim(sprite, animNum, 0);
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_StartAnimInDirection_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, objectEvent->movementDirection, sprite->animNum);
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WaitSpriteAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
if (SpriteAnimEnded(sprite))
|
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void InitJumpSpecial(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJump(objectEvent, sprite, direction, JUMP_DISTANCE_NORMAL, JUMP_TYPE_HIGH);
|
2018-06-14 00:51:26 +02:00
|
|
|
StartSpriteAnim(sprite, GetJumpSpecialDirectionAnimNum(direction));
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpSpecialDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitJumpSpecial(objectEvent, sprite, DIR_SOUTH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpSpecialDown_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpSpecialDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpSpecialAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->landingJump = FALSE;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpSpecialUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitJumpSpecial(objectEvent, sprite, DIR_NORTH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpSpecialUp_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpSpecialUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpSpecialAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->landingJump = FALSE;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpSpecialLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitJumpSpecial(objectEvent, sprite, DIR_WEST);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpSpecialLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpSpecialLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpSpecialAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->landingJump = FALSE;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpSpecialRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitJumpSpecial(objectEvent, sprite, DIR_EAST);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpSpecialRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpSpecialRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpSpecialAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->landingJump = FALSE;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_FacePlayer_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 playerObjectId;
|
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0, &playerObjectId))
|
2021-11-01 23:06:15 +01:00
|
|
|
FaceDirection(objectEvent, sprite, GetDirectionToFace(objectEvent->currentCoords.x,
|
|
|
|
objectEvent->currentCoords.y,
|
|
|
|
gObjectEvents[playerObjectId].currentCoords.x,
|
|
|
|
gObjectEvents[playerObjectId].currentCoords.y));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_FaceAwayPlayer_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
u8 playerObjectId;
|
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
if (!TryGetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0, &playerObjectId))
|
2021-11-01 23:06:15 +01:00
|
|
|
FaceDirection(objectEvent, sprite, GetOppositeDirection(GetDirectionToFace(objectEvent->currentCoords.x,
|
|
|
|
objectEvent->currentCoords.y,
|
|
|
|
gObjectEvents[playerObjectId].currentCoords.x,
|
|
|
|
gObjectEvents[playerObjectId].currentCoords.y)));
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_LockFacingDirection_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->facingDirectionLocked = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_UnlockFacingDirection_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->facingDirectionLocked = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_NORMAL, JUMP_TYPE_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpDown_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_NORMAL, JUMP_TYPE_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpUp_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_NORMAL, JUMP_TYPE_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_NORMAL, JUMP_TYPE_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_HIGH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpInPlaceDown_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_HIGH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpInPlaceUp_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_HIGH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpInPlaceLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_HIGH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpInPlaceRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceDownUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpInPlaceDownUp_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceDownUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpInPlaceAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceUpDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpInPlaceUpDown_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceUpDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpInPlaceAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceLeftRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpInPlaceLeftRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceLeftRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpInPlaceAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceRightLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitJumpRegular(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_NORMAL);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_JumpInPlaceRightLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_JumpInPlaceRightLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpInPlaceAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_FaceOriginalDirection_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
FaceDirection(objectEvent, sprite, gInitialMovementTypeFacingDirections[objectEvent->movementType]);
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_NurseJoyBowDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-10-29 19:37:49 +02:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, DIR_SOUTH, ANIM_NURSE_BOW);
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_EnableJumpLandingGroundEffect_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->disableJumpLandingGroundEffect = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_DisableJumpLandingGroundEffect_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->disableJumpLandingGroundEffect = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_DisableAnimation_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->inanimate = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RestoreAnimation_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->inanimate = GetObjectEventGraphicsInfo(objectEvent->graphicsId)->inanimate;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_SetInvisible_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->invisible = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_SetVisible_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->invisible = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_EmoteExclamationMark_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventGetLocalIdAndMap(objectEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]);
|
2018-06-14 00:51:26 +02:00
|
|
|
FieldEffectStart(FLDEFF_EXCLAMATION_MARK_ICON);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_EmoteQuestionMark_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventGetLocalIdAndMap(objectEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]);
|
2018-06-14 00:51:26 +02:00
|
|
|
FieldEffectStart(FLDEFF_QUESTION_MARK_ICON);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_EmoteHeart_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventGetLocalIdAndMap(objectEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]);
|
2018-06-14 00:51:26 +02:00
|
|
|
FieldEffectStart(FLDEFF_HEART_ICON);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RevealTrainer_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-02-14 20:25:23 +01:00
|
|
|
if (objectEvent->movementType == MOVEMENT_TYPE_BURIED)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-02-14 20:25:23 +01:00
|
|
|
SetBuriedTrainerMovement(objectEvent);
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->movementType != MOVEMENT_TYPE_TREE_DISGUISE && objectEvent->movementType != MOVEMENT_TYPE_MOUNTAIN_DISGUISE)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2021-04-06 20:51:39 +02:00
|
|
|
StartRevealDisguise(objectEvent);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_RevealTrainer_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RevealTrainer_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 20:51:39 +02:00
|
|
|
if (UpdateRevealDisguise(objectEvent))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RockSmashBreak_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-10-29 19:37:49 +02:00
|
|
|
SetAndStartSpriteAnim(sprite, ANIM_REMOVE_OBSTACLE, 0);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RockSmashBreak_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
if (SpriteAnimEnded(sprite))
|
|
|
|
{
|
|
|
|
SetMovementDelay(sprite, 32);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_RockSmashBreak_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->invisible ^= TRUE;
|
2018-06-14 00:51:26 +02:00
|
|
|
if (WaitForMovementDelay(sprite))
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->invisible = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 3;
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_CutTree_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-10-29 19:37:49 +02:00
|
|
|
SetAndStartSpriteAnim(sprite, ANIM_REMOVE_OBSTACLE, 0);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_CutTree_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
if (SpriteAnimEnded(sprite))
|
|
|
|
{
|
|
|
|
SetMovementDelay(sprite, 32);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_CutTree_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->invisible ^= TRUE;
|
2018-06-14 00:51:26 +02:00
|
|
|
if (WaitForMovementDelay(sprite))
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->invisible = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 3;
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_SetFixedPriority_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->fixedPriority = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_ClearFixedPriority_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->fixedPriority = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_InitAffineAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
sprite->oam.affineMode = ST_OAM_AFFINE_DOUBLE;
|
|
|
|
InitSpriteAffineAnim(sprite);
|
|
|
|
sprite->affineAnimPaused = TRUE;
|
2019-12-05 03:00:45 +01:00
|
|
|
sprite->subspriteMode = SUBSPRITES_OFF;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_ClearAffineAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
FreeOamMatrix(sprite->oam.matrixNum);
|
|
|
|
sprite->oam.affineMode = ST_OAM_AFFINE_OFF;
|
|
|
|
CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, sprite->oam.affineMode);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_HideReflection_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hideReflection = TRUE;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_ShowReflection_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hideReflection = FALSE;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkDownStartAffine_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitWalkSlow(objectEvent, sprite, DIR_SOUTH);
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->affineAnimPaused = FALSE;
|
|
|
|
StartSpriteAffineAnimIfDifferent(sprite, 0);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkDownStartAffine_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkDownStartAffine_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateWalkSlow(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
sprite->affineAnimPaused = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkDownAffine_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitWalkSlow(objectEvent, sprite, DIR_SOUTH);
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->affineAnimPaused = FALSE;
|
|
|
|
ChangeSpriteAffineAnimIfDifferent(sprite, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkDownAffine_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkDownAffine_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateWalkSlow(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
sprite->affineAnimPaused = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkLeftAffine_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_WEST, MOVE_SPEED_FAST_1);
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->affineAnimPaused = FALSE;
|
|
|
|
ChangeSpriteAffineAnimIfDifferent(sprite, 2);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkLeftAffine_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkLeftAffine_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
sprite->affineAnimPaused = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkRightAffine_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-02 17:28:49 +01:00
|
|
|
InitMovementNormal(objectEvent, sprite, DIR_EAST, MOVE_SPEED_FAST_1);
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->affineAnimPaused = FALSE;
|
|
|
|
ChangeSpriteAffineAnimIfDifferent(sprite, 3);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkRightAffine_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_WalkRightAffine_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
|
|
|
sprite->affineAnimPaused = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void AcroWheelieFaceDirection(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
SetObjectEventDirection(objectEvent, direction);
|
|
|
|
ShiftStillObjectEventCoords(objectEvent);
|
2021-04-06 23:55:29 +02:00
|
|
|
SetStepAnim(objectEvent, sprite, GetAcroWheeliePedalDirectionAnimNum(direction));
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->animPaused = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieFaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
AcroWheelieFaceDirection(objectEvent, sprite, DIR_SOUTH);
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieFaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
AcroWheelieFaceDirection(objectEvent, sprite, DIR_NORTH);
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieFaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
AcroWheelieFaceDirection(objectEvent, sprite, DIR_WEST);
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieFaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
AcroWheelieFaceDirection(objectEvent, sprite, DIR_EAST);
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroPopWheelieDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, DIR_SOUTH, GetAcroWheelieDirectionAnimNum(DIR_SOUTH));
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroPopWheelieUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, DIR_NORTH, GetAcroWheelieDirectionAnimNum(DIR_NORTH));
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroPopWheelieLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, DIR_WEST, GetAcroWheelieDirectionAnimNum(DIR_WEST));
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroPopWheelieRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, DIR_EAST, GetAcroWheelieDirectionAnimNum(DIR_EAST));
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroEndWheelieFaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, DIR_SOUTH, GetAcroEndWheelieDirectionAnimNum(DIR_SOUTH));
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroEndWheelieFaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, DIR_NORTH, GetAcroEndWheelieDirectionAnimNum(DIR_NORTH));
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroEndWheelieFaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, DIR_WEST, GetAcroEndWheelieDirectionAnimNum(DIR_WEST));
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroEndWheelieFaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, DIR_EAST, GetAcroEndWheelieDirectionAnimNum(DIR_EAST));
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_UnusedAcroActionDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, DIR_SOUTH, GetAcroUnusedActionDirectionAnimNum(DIR_SOUTH));
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_UnusedAcroActionUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, DIR_NORTH, GetAcroUnusedActionDirectionAnimNum(DIR_NORTH));
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_UnusedAcroActionLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, DIR_WEST, GetAcroUnusedActionDirectionAnimNum(DIR_WEST));
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_UnusedAcroActionRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnimInDirection(objectEvent, sprite, DIR_EAST, GetAcroUnusedActionDirectionAnimNum(DIR_EAST));
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
void InitFigure8Anim(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
InitSpriteForFigure8Anim(sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->animPaused = FALSE;
|
|
|
|
}
|
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
bool8 DoFigure8Anim(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
if (AnimateSpriteInFigure8(sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ShiftStillObjectEventCoords(objectEvent);
|
|
|
|
objectEvent->triggerGroundEffectsOnStop = TRUE;
|
2018-06-14 00:51:26 +02:00
|
|
|
sprite->animPaused = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Figure8_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
InitFigure8Anim(objectEvent, sprite);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_Figure8_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Figure8_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
if (DoFigure8Anim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
static void InitAcroWheelieJump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 distance, u8 type)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:35:01 +01:00
|
|
|
InitJump(objectEvent, sprite, direction, distance, type);
|
2018-06-14 00:51:26 +02:00
|
|
|
StartSpriteAnimIfDifferent(sprite, GetAcroWheelieDirectionAnimNum(direction));
|
2019-11-21 04:55:44 +01:00
|
|
|
DoShadowFieldEffect(objectEvent);
|
2017-09-17 16:01:27 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopFaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 16:07:43 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitAcroWheelieJump(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_LOW);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieHopFaceDown_Step1(objectEvent, sprite);
|
2017-09-17 16:07:43 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopFaceDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 16:07:43 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2017-09-17 16:07:43 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2017-09-17 16:07:43 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopFaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 16:23:18 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitAcroWheelieJump(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_LOW);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieHopFaceUp_Step1(objectEvent, sprite);
|
2017-09-17 16:23:18 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopFaceUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 16:23:18 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2017-09-17 16:23:18 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2017-09-17 16:23:18 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopFaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 16:23:18 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitAcroWheelieJump(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_LOW);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieHopFaceLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopFaceLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2017-09-17 16:23:18 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
2017-09-17 16:23:18 +02:00
|
|
|
}
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
2017-09-17 16:23:18 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopFaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitAcroWheelieJump(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_IN_PLACE, JUMP_TYPE_LOW);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieHopFaceRight_Step1(objectEvent, sprite);
|
2017-09-17 16:58:24 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopFaceRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 16:58:24 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-17 16:58:24 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitAcroWheelieJump(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_NORMAL, JUMP_TYPE_LOW);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieHopDown_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 16:58:24 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2017-09-17 16:58:24 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2017-09-17 16:58:24 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-17 18:19:35 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 18:19:35 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitAcroWheelieJump(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_NORMAL, JUMP_TYPE_LOW);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieHopUp_Step1(objectEvent, sprite);
|
2017-09-17 18:19:35 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2017-09-17 18:19:35 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 18:25:27 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitAcroWheelieJump(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_NORMAL, JUMP_TYPE_LOW);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieHopLeft_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
2017-09-17 18:25:27 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2017-09-17 18:25:27 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
2017-09-17 18:25:27 +02:00
|
|
|
}
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
2017-09-17 18:25:27 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 18:25:27 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitAcroWheelieJump(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_NORMAL, JUMP_TYPE_LOW);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieHopRight_Step1(objectEvent, sprite);
|
2018-06-14 00:51:26 +02:00
|
|
|
}
|
2017-09-17 18:25:27 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieHopRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2017-09-17 18:25:27 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
2017-09-17 18:25:27 +02:00
|
|
|
}
|
2018-06-14 00:51:26 +02:00
|
|
|
return FALSE;
|
2017-09-17 18:25:27 +02:00
|
|
|
}
|
2017-09-17 18:57:42 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieJumpDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 18:57:42 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitAcroWheelieJump(objectEvent, sprite, DIR_SOUTH, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieJumpDown_Step1(objectEvent, sprite);
|
2017-09-17 18:57:42 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieJumpDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 18:57:42 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2017-09-17 18:57:42 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieJumpUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:00:43 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitAcroWheelieJump(objectEvent, sprite, DIR_NORTH, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieJumpUp_Step1(objectEvent, sprite);
|
2017-09-17 19:00:43 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieJumpUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:00:43 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-17 19:00:43 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieJumpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:00:43 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitAcroWheelieJump(objectEvent, sprite, DIR_WEST, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieJumpLeft_Step1(objectEvent, sprite);
|
2017-09-17 19:00:43 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieJumpLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:00:43 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2017-09-17 19:00:43 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieJumpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:00:43 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
InitAcroWheelieJump(objectEvent, sprite, DIR_EAST, JUMP_DISTANCE_FAR, JUMP_TYPE_HIGH);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieJumpRight_Step1(objectEvent, sprite);
|
2017-09-17 19:00:43 +02:00
|
|
|
}
|
2017-09-17 19:06:03 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieJumpRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:06:03 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (DoJumpAnim(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->hasShadow = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2017-09-17 19:06:03 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieInPlaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:06:03 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_SOUTH, GetAcroWheeliePedalDirectionAnimNum(DIR_SOUTH), 8);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2017-09-17 19:06:03 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieInPlaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:06:03 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_NORTH, GetAcroWheeliePedalDirectionAnimNum(DIR_NORTH), 8);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2017-09-17 19:06:03 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieInPlaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:06:03 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_WEST, GetAcroWheeliePedalDirectionAnimNum(DIR_WEST), 8);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2017-09-17 19:06:03 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieInPlaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:06:03 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitMoveInPlace(objectEvent, sprite, DIR_EAST, GetAcroWheeliePedalDirectionAnimNum(DIR_EAST), 8);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_WalkInPlace_Step1(objectEvent, sprite);
|
2017-09-17 19:06:03 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void InitAcroPopWheelie(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed)
|
2017-09-17 19:06:03 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
InitNpcForMovement(objectEvent, sprite, direction, speed);
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnim(sprite, GetAcroWheelieDirectionAnimNum(objectEvent->facingDirection));
|
2018-06-14 00:51:26 +02:00
|
|
|
SeekSpriteAnim(sprite, 0);
|
2017-09-17 19:06:03 +02:00
|
|
|
}
|
2017-09-17 19:26:17 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroPopWheelieMoveDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:26:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitAcroPopWheelie(objectEvent, sprite, DIR_SOUTH, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroPopWheelieMoveDown_Step1(objectEvent, sprite);
|
2017-09-17 19:26:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroPopWheelieMoveDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:26:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2017-09-17 19:26:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2017-09-17 19:26:17 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroPopWheelieMoveUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:26:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitAcroPopWheelie(objectEvent, sprite, DIR_NORTH, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroPopWheelieMoveUp_Step1(objectEvent, sprite);
|
2017-09-17 19:26:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroPopWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:26:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2017-09-17 19:26:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
2017-09-17 19:26:17 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroPopWheelieMoveLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:26:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitAcroPopWheelie(objectEvent, sprite, DIR_WEST, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroPopWheelieMoveLeft_Step1(objectEvent, sprite);
|
2017-09-17 19:26:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroPopWheelieMoveLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:26:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2017-09-17 19:26:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
2017-09-17 19:26:17 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroPopWheelieMoveRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:26:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitAcroPopWheelie(objectEvent, sprite, DIR_EAST, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroPopWheelieMoveRight_Step1(objectEvent, sprite);
|
2017-09-17 19:26:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroPopWheelieMoveRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:26:17 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2017-09-17 19:26:17 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void InitAcroWheelieMove(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed)
|
2017-09-17 19:26:17 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
InitNpcForMovement(objectEvent, sprite, direction, speed);
|
|
|
|
SetStepAnimHandleAlternation(objectEvent, sprite, GetAcroWheeliePedalDirectionAnimNum(objectEvent->facingDirection));
|
2017-09-17 19:26:17 +02:00
|
|
|
}
|
2017-09-17 19:59:30 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieMoveDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:59:30 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitAcroWheelieMove(objectEvent, sprite, DIR_SOUTH, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieMoveDown_Step1(objectEvent, sprite);
|
2017-09-17 19:59:30 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieMoveDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:59:30 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2017-09-17 19:59:30 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieMoveUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:59:30 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitAcroWheelieMove(objectEvent, sprite, DIR_NORTH, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieMoveUp_Step1(objectEvent, sprite);
|
2017-09-17 19:59:30 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 19:59:30 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2017-09-17 19:59:30 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieMoveLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 20:02:43 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitAcroWheelieMove(objectEvent, sprite, DIR_WEST, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieMoveLeft_Step1(objectEvent, sprite);
|
2017-09-17 20:02:43 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieMoveLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 20:02:43 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2017-09-17 20:02:43 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieMoveRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 20:02:43 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitAcroWheelieMove(objectEvent, sprite, DIR_EAST, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroWheelieMoveRight_Step1(objectEvent, sprite);
|
2017-09-17 20:02:43 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroWheelieMoveRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 20:02:43 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2017-09-17 20:02:43 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void InitAcroEndWheelie(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed)
|
2017-09-17 20:02:43 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
InitNpcForMovement(objectEvent, sprite, direction, speed);
|
2019-11-21 04:55:44 +01:00
|
|
|
StartSpriteAnim(sprite, GetAcroEndWheelieDirectionAnimNum(objectEvent->facingDirection));
|
2018-06-14 00:51:26 +02:00
|
|
|
SeekSpriteAnim(sprite, 0);
|
2017-09-17 20:02:43 +02:00
|
|
|
}
|
2017-09-17 20:06:43 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroEndWheelieMoveDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 20:12:32 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitAcroEndWheelie(objectEvent, sprite, DIR_SOUTH, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroEndWheelieMoveDown_Step1(objectEvent, sprite);
|
2017-09-17 20:12:32 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroEndWheelieMoveDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 20:12:32 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2017-09-17 20:12:32 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2017-09-17 20:12:32 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroEndWheelieMoveUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 20:12:32 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitAcroEndWheelie(objectEvent, sprite, DIR_NORTH, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroEndWheelieMoveUp_Step1(objectEvent, sprite);
|
2017-09-17 20:12:32 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroEndWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 20:12:32 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2017-09-17 20:12:32 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2017-09-17 20:12:32 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-17 20:51:10 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroEndWheelieMoveLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 20:51:10 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitAcroEndWheelie(objectEvent, sprite, DIR_WEST, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroEndWheelieMoveLeft_Step1(objectEvent, sprite);
|
2017-09-17 20:51:10 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroEndWheelieMoveLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 21:03:47 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2017-09-17 21:03:47 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroEndWheelieMoveRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 21:05:23 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
InitAcroEndWheelie(objectEvent, sprite, DIR_EAST, 1);
|
2019-11-21 04:55:44 +01:00
|
|
|
return MovementAction_AcroEndWheelieMoveRight_Step1(objectEvent, sprite);
|
2017-09-17 21:05:23 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_AcroEndWheelieMoveRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 21:06:45 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (UpdateMovementNormal(objectEvent, sprite))
|
2018-06-14 00:51:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 2;
|
2018-06-14 00:51:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2017-09-17 21:06:45 +02:00
|
|
|
}
|
2017-09-17 21:33:26 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_Levitate_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 21:33:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
CreateLevitateMovementTask(objectEvent);
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2017-09-17 21:33:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_StopLevitate_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 21:33:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
DestroyLevitateMovementTask(objectEvent->warpArrowSpriteId);
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2017-09-17 21:33:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
bool8 MovementAction_StopLevitateAtTop_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 21:33:26 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
if (sprite->y2 == 0)
|
2017-09-17 21:33:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
DestroyLevitateMovementTask(objectEvent->warpArrowSpriteId);
|
|
|
|
sprite->sActionFuncId = 1;
|
2017-09-17 21:33:26 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementAction_Finish(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 21:33:26 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 MovementAction_PauseSpriteAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 21:33:26 +02:00
|
|
|
{
|
|
|
|
sprite->animPaused = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void UpdateObjectEventSpriteAnimPause(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 21:33:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->disableAnim)
|
2017-09-17 21:33:26 +02:00
|
|
|
sprite->animPaused = TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void TryEnableObjectEventAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 21:33:26 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->enableAnim)
|
2017-09-17 21:33:26 +02:00
|
|
|
{
|
|
|
|
sprite->animPaused = FALSE;
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->disableAnim = FALSE;
|
|
|
|
objectEvent->enableAnim = FALSE;
|
2017-09-17 21:33:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void UpdateObjectEventVisibility(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 21:33:26 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
UpdateObjectEventOffscreen(objectEvent, sprite);
|
|
|
|
UpdateObjectEventSpriteVisibility(objectEvent, sprite);
|
2017-09-17 21:33:26 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void UpdateObjectEventOffscreen(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 21:33:26 +02:00
|
|
|
{
|
2018-10-20 22:01:45 +02:00
|
|
|
u16 x, y;
|
|
|
|
u16 x2, y2;
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
2017-09-17 21:33:26 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->offScreen = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId);
|
2017-09-17 21:33:26 +02:00
|
|
|
if (sprite->coordOffsetEnabled)
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
x = sprite->x + sprite->x2 + sprite->centerToCornerVecX + gSpriteCoordOffsetX;
|
|
|
|
y = sprite->y + sprite->y2 + sprite->centerToCornerVecY + gSpriteCoordOffsetY;
|
2017-09-17 21:33:26 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
x = sprite->x + sprite->x2 + sprite->centerToCornerVecX;
|
|
|
|
y = sprite->y + sprite->y2 + sprite->centerToCornerVecY;
|
2017-09-17 21:33:26 +02:00
|
|
|
}
|
|
|
|
x2 = graphicsInfo->width;
|
|
|
|
x2 += x;
|
|
|
|
y2 = y;
|
|
|
|
y2 += graphicsInfo->height;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
|
|
|
if ((s16)x >= DISPLAY_WIDTH + 16 || (s16)x2 < -16)
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->offScreen = TRUE;
|
2021-04-06 11:05:33 +02:00
|
|
|
|
|
|
|
if ((s16)y >= DISPLAY_HEIGHT + 16 || (s16)y2 < -16)
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->offScreen = TRUE;
|
2017-09-17 21:33:26 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void UpdateObjectEventSpriteVisibility(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2017-09-17 21:33:26 +02:00
|
|
|
{
|
|
|
|
sprite->invisible = FALSE;
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->invisible || objectEvent->offScreen)
|
2017-09-17 21:33:26 +02:00
|
|
|
sprite->invisible = TRUE;
|
|
|
|
}
|
2018-06-11 15:34:19 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetAllGroundEffectFlags_OnSpawn(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 15:34:19 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventUpdateMetatileBehaviors(objEvent);
|
|
|
|
GetGroundEffectFlags_Reflection(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_TallGrassOnSpawn(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_LongGrassOnSpawn(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_SandHeap(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_ShallowFlowingWater(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_ShortGrass(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_HotSprings(objEvent, flags);
|
2018-06-11 15:34:19 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetAllGroundEffectFlags_OnBeginStep(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 15:34:19 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventUpdateMetatileBehaviors(objEvent);
|
|
|
|
GetGroundEffectFlags_Reflection(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_TallGrassOnBeginStep(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_LongGrassOnBeginStep(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_Tracks(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_SandHeap(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_ShallowFlowingWater(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_Puddle(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_ShortGrass(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_HotSprings(objEvent, flags);
|
2018-06-11 15:34:19 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetAllGroundEffectFlags_OnFinishStep(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 15:34:19 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventUpdateMetatileBehaviors(objEvent);
|
|
|
|
GetGroundEffectFlags_ShallowFlowingWater(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_SandHeap(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_Puddle(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_Ripple(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_ShortGrass(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_HotSprings(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_Seaweed(objEvent, flags);
|
|
|
|
GetGroundEffectFlags_JumpLanding(objEvent, flags);
|
2018-06-11 15:34:19 +02:00
|
|
|
}
|
2018-06-11 17:23:14 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void ObjectEventUpdateMetatileBehaviors(struct ObjectEvent *objEvent)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objEvent->previousMetatileBehavior = MapGridGetMetatileBehaviorAt(objEvent->previousCoords.x, objEvent->previousCoords.y);
|
|
|
|
objEvent->currentMetatileBehavior = MapGridGetMetatileBehaviorAt(objEvent->currentCoords.x, objEvent->currentCoords.y);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_Reflection(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2021-08-25 00:59:32 +02:00
|
|
|
u32 reflectionFlags[NUM_REFLECTION_TYPES - 1] = {
|
2021-01-20 00:21:50 +01:00
|
|
|
[REFL_TYPE_ICE - 1] = GROUND_EFFECT_FLAG_ICE_REFLECTION,
|
|
|
|
[REFL_TYPE_WATER - 1] = GROUND_EFFECT_FLAG_WATER_REFLECTION
|
|
|
|
};
|
2021-01-20 23:32:04 +01:00
|
|
|
u8 reflType = ObjectEventGetNearbyReflectionType(objEvent);
|
2018-06-11 17:23:14 +02:00
|
|
|
|
2021-01-20 00:21:50 +01:00
|
|
|
if (reflType)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2021-01-20 23:32:04 +01:00
|
|
|
if (objEvent->hasReflection == 0)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2021-01-20 23:32:04 +01:00
|
|
|
objEvent->hasReflection++;
|
2021-01-20 00:21:50 +01:00
|
|
|
*flags |= reflectionFlags[reflType - 1];
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-20 00:21:50 +01:00
|
|
|
objEvent->hasReflection = FALSE;
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_TallGrassOnSpawn(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (MetatileBehavior_IsTallGrass(objEvent->currentMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags |= GROUND_EFFECT_FLAG_TALL_GRASS_ON_SPAWN;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_TallGrassOnBeginStep(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (MetatileBehavior_IsTallGrass(objEvent->currentMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags |= GROUND_EFFECT_FLAG_TALL_GRASS_ON_MOVE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_LongGrassOnSpawn(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (MetatileBehavior_IsLongGrass(objEvent->currentMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags |= GROUND_EFFECT_FLAG_LONG_GRASS_ON_SPAWN;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_LongGrassOnBeginStep(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (MetatileBehavior_IsLongGrass(objEvent->currentMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags |= GROUND_EFFECT_FLAG_LONG_GRASS_ON_MOVE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_Tracks(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (MetatileBehavior_IsDeepSand(objEvent->previousMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags |= GROUND_EFFECT_FLAG_DEEP_SAND;
|
2019-11-21 04:55:44 +01:00
|
|
|
else if (MetatileBehavior_IsSandOrDeepSand(objEvent->previousMetatileBehavior)
|
|
|
|
|| MetatileBehavior_IsFootprints(objEvent->previousMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags |= GROUND_EFFECT_FLAG_SAND;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_SandHeap(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (MetatileBehavior_IsDeepSand(objEvent->currentMetatileBehavior)
|
|
|
|
&& MetatileBehavior_IsDeepSand(objEvent->previousMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!objEvent->inSandPile)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
objEvent->inSandPile = FALSE;
|
|
|
|
objEvent->inSandPile = TRUE;
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags |= GROUND_EFFECT_FLAG_SAND_PILE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
objEvent->inSandPile = FALSE;
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_ShallowFlowingWater(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if ((MetatileBehavior_IsShallowFlowingWater(objEvent->currentMetatileBehavior)
|
|
|
|
&& MetatileBehavior_IsShallowFlowingWater(objEvent->previousMetatileBehavior))
|
|
|
|
|| (MetatileBehavior_IsPacifidlogLog(objEvent->currentMetatileBehavior)
|
|
|
|
&& MetatileBehavior_IsPacifidlogLog(objEvent->previousMetatileBehavior)))
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!objEvent->inShallowFlowingWater)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
objEvent->inShallowFlowingWater = FALSE;
|
|
|
|
objEvent->inShallowFlowingWater = TRUE;
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags |= GROUND_EFFECT_FLAG_SHALLOW_FLOWING_WATER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
objEvent->inShallowFlowingWater = FALSE;
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_Puddle(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (MetatileBehavior_IsPuddle(objEvent->currentMetatileBehavior)
|
|
|
|
&& MetatileBehavior_IsPuddle(objEvent->previousMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags |= GROUND_EFFECT_FLAG_PUDDLE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_Ripple(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (MetatileBehavior_HasRipples(objEvent->currentMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags |= GROUND_EFFECT_FLAG_RIPPLES;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_ShortGrass(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (MetatileBehavior_IsShortGrass(objEvent->currentMetatileBehavior)
|
|
|
|
&& MetatileBehavior_IsShortGrass(objEvent->previousMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!objEvent->inShortGrass)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
objEvent->inShortGrass = FALSE;
|
|
|
|
objEvent->inShortGrass = TRUE;
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags |= GROUND_EFFECT_FLAG_SHORT_GRASS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
objEvent->inShortGrass = FALSE;
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_HotSprings(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (MetatileBehavior_IsHotSprings(objEvent->currentMetatileBehavior)
|
|
|
|
&& MetatileBehavior_IsHotSprings(objEvent->previousMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!objEvent->inHotSprings)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
objEvent->inHotSprings = FALSE;
|
|
|
|
objEvent->inHotSprings = TRUE;
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags |= GROUND_EFFECT_FLAG_HOT_SPRINGS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
objEvent->inHotSprings = FALSE;
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_Seaweed(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (MetatileBehavior_IsSeaweed(objEvent->currentMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags |= GROUND_EFFECT_FLAG_SEAWEED;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void GetGroundEffectFlags_JumpLanding(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
typedef bool8 (*MetatileFunc)(u8);
|
|
|
|
|
|
|
|
static const MetatileFunc metatileFuncs[] = {
|
|
|
|
MetatileBehavior_IsTallGrass,
|
|
|
|
MetatileBehavior_IsLongGrass,
|
|
|
|
MetatileBehavior_IsPuddle,
|
|
|
|
MetatileBehavior_IsSurfableWaterOrUnderwater,
|
|
|
|
MetatileBehavior_IsShallowFlowingWater,
|
|
|
|
MetatileBehavior_IsATile,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u32 jumpLandingFlags[] = {
|
|
|
|
GROUND_EFFECT_FLAG_LAND_IN_TALL_GRASS,
|
|
|
|
GROUND_EFFECT_FLAG_LAND_IN_LONG_GRASS,
|
|
|
|
GROUND_EFFECT_FLAG_LAND_IN_SHALLOW_WATER,
|
|
|
|
GROUND_EFFECT_FLAG_LAND_IN_DEEP_WATER,
|
|
|
|
GROUND_EFFECT_FLAG_LAND_IN_SHALLOW_WATER,
|
|
|
|
GROUND_EFFECT_FLAG_LAND_ON_NORMAL_GROUND,
|
|
|
|
};
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objEvent->landingJump && !objEvent->disableJumpLandingGroundEffect)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_COUNT(metatileFuncs); i++)
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (metatileFuncs[i](objEvent->currentMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
*flags |= jumpLandingFlags[i];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-20 11:34:33 +01:00
|
|
|
#define RETURN_REFLECTION_TYPE_AT(x, y) \
|
|
|
|
b = MapGridGetMetatileBehaviorAt(x, y); \
|
|
|
|
result = GetReflectionTypeByMetatileBehavior(b); \
|
|
|
|
if (result != REFL_TYPE_NONE) \
|
|
|
|
return result;
|
|
|
|
|
2021-01-20 23:32:04 +01:00
|
|
|
static u8 ObjectEventGetNearbyReflectionType(struct ObjectEvent *objEvent)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *info = GetObjectEventGraphicsInfo(objEvent->graphicsId);
|
2018-06-11 17:23:14 +02:00
|
|
|
|
|
|
|
// ceil div by tile width?
|
|
|
|
s16 width = (info->width + 8) >> 4;
|
|
|
|
s16 height = (info->height + 8) >> 4;
|
2021-01-20 23:32:04 +01:00
|
|
|
s16 i, j;
|
|
|
|
u8 result, b; // used by RETURN_REFLECTION_TYPE_AT
|
|
|
|
s16 one = 1;
|
2018-06-11 17:23:14 +02:00
|
|
|
|
2021-01-20 23:32:04 +01:00
|
|
|
for (i = 0; i < height; i++)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
RETURN_REFLECTION_TYPE_AT(objEvent->currentCoords.x, objEvent->currentCoords.y + one + i)
|
|
|
|
RETURN_REFLECTION_TYPE_AT(objEvent->previousCoords.x, objEvent->previousCoords.y + one + i)
|
2018-06-11 17:23:14 +02:00
|
|
|
for (j = 1; j < width; j++)
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
RETURN_REFLECTION_TYPE_AT(objEvent->currentCoords.x + j, objEvent->currentCoords.y + one + i)
|
|
|
|
RETURN_REFLECTION_TYPE_AT(objEvent->currentCoords.x - j, objEvent->currentCoords.y + one + i)
|
|
|
|
RETURN_REFLECTION_TYPE_AT(objEvent->previousCoords.x + j, objEvent->previousCoords.y + one + i)
|
|
|
|
RETURN_REFLECTION_TYPE_AT(objEvent->previousCoords.x - j, objEvent->previousCoords.y + one + i)
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
}
|
2021-08-25 00:59:32 +02:00
|
|
|
|
2021-01-20 11:34:33 +01:00
|
|
|
return REFL_TYPE_NONE;
|
|
|
|
}
|
2018-06-11 17:23:14 +02:00
|
|
|
|
|
|
|
#undef RETURN_REFLECTION_TYPE_AT
|
|
|
|
|
|
|
|
static u8 GetReflectionTypeByMetatileBehavior(u32 behavior)
|
|
|
|
{
|
|
|
|
if (MetatileBehavior_IsIce(behavior))
|
2021-01-20 00:21:50 +01:00
|
|
|
return REFL_TYPE_ICE;
|
2018-06-11 17:23:14 +02:00
|
|
|
else if (MetatileBehavior_IsReflective(behavior))
|
2021-01-20 00:21:50 +01:00
|
|
|
return REFL_TYPE_WATER;
|
2018-06-11 17:23:14 +02:00
|
|
|
else
|
2021-01-20 00:21:50 +01:00
|
|
|
return REFL_TYPE_NONE;
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
u8 GetLedgeJumpDirection(s16 x, s16 y, u8 direction)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
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,
|
2018-06-11 17:23:14 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
u8 behavior;
|
|
|
|
u8 index = direction;
|
2018-06-11 17:23:14 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
if (index == DIR_NONE)
|
|
|
|
return DIR_NONE;
|
|
|
|
else if (index > DIR_EAST)
|
|
|
|
index -= DIR_EAST;
|
2018-06-11 17:23:14 +02:00
|
|
|
|
|
|
|
index--;
|
2021-04-06 11:05:33 +02:00
|
|
|
behavior = MapGridGetMetatileBehaviorAt(x, y);
|
2018-06-11 17:23:14 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
if (ledgeBehaviorFuncs[index](behavior) == TRUE)
|
2018-06-11 17:23:14 +02:00
|
|
|
return index + 1;
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
return DIR_NONE;
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void SetObjectEventSpriteOamTableForLongGrass(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objEvent->disableCoveringGroundEffects)
|
2018-06-11 17:23:14 +02:00
|
|
|
return;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!MetatileBehavior_IsLongGrass(objEvent->currentMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
return;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!MetatileBehavior_IsLongGrass(objEvent->previousMetatileBehavior))
|
2018-06-11 17:23:14 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
sprite->subspriteTableNum = 4;
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
if (ElevationToPriority(objEvent->previousElevation) == 1)
|
2018-06-11 17:23:14 +02:00
|
|
|
sprite->subspriteTableNum = 5;
|
|
|
|
}
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
static bool8 IsElevationMismatchAt(u8 elevation, s16 x, s16 y)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2022-01-21 18:48:19 +01:00
|
|
|
u8 mapElevation;
|
2018-06-11 17:23:14 +02:00
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
if (elevation == 0)
|
2018-06-11 17:23:14 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
mapElevation = MapGridGetElevationAt(x, y);
|
2018-06-11 17:23:14 +02:00
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
if (mapElevation == 0 || mapElevation == 15)
|
2018-06-11 17:23:14 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
if (mapElevation != elevation)
|
2018-06-11 17:23:14 +02:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sElevationToSubpriority[] = {
|
|
|
|
115, 115, 83, 115, 83, 115, 83, 115, 83, 115, 83, 115, 83, 0, 0, 115
|
2018-06-11 17:23:14 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sElevationToPriority[] = {
|
2018-06-11 17:23:14 +02:00
|
|
|
2, 2, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0, 0, 2
|
|
|
|
};
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static const u8 sElevationToSubspriteTableNum[] = {
|
2018-06-11 17:23:14 +02:00
|
|
|
1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 0, 1,
|
|
|
|
};
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
static void UpdateObjectEventElevationAndPriority(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objEvent->fixedPriority)
|
2018-06-11 17:23:14 +02:00
|
|
|
return;
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
ObjectEventUpdateElevation(objEvent);
|
2018-06-11 17:23:14 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->subspriteTableNum = sElevationToSubspriteTableNum[objEvent->previousElevation];
|
|
|
|
sprite->oam.priority = sElevationToPriority[objEvent->previousElevation];
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
static void InitObjectPriorityByElevation(struct Sprite *sprite, u8 elevation)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2022-01-21 18:48:19 +01:00
|
|
|
sprite->subspriteTableNum = sElevationToSubspriteTableNum[elevation];
|
|
|
|
sprite->oam.priority = sElevationToPriority[elevation];
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
u8 ElevationToPriority(u8 elevation)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2022-01-21 18:48:19 +01:00
|
|
|
return sElevationToPriority[elevation];
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
void ObjectEventUpdateElevation(struct ObjectEvent *objEvent)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2022-01-21 18:48:19 +01:00
|
|
|
u8 curElevation = MapGridGetElevationAt(objEvent->currentCoords.x, objEvent->currentCoords.y);
|
|
|
|
u8 prevElevation = MapGridGetElevationAt(objEvent->previousCoords.x, objEvent->previousCoords.y);
|
2018-06-11 17:23:14 +02:00
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
if (curElevation == 15 || prevElevation == 15)
|
2018-06-11 17:23:14 +02:00
|
|
|
return;
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
objEvent->currentElevation = curElevation;
|
2018-06-11 17:23:14 +02:00
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
if (curElevation != 0 && curElevation != 15)
|
|
|
|
objEvent->previousElevation = curElevation;
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
void SetObjectSubpriorityByElevation(u8 elevation, struct Sprite *sprite, u8 subpriority)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
s32 tmp = sprite->centerToCornerVecY;
|
2021-07-07 15:11:52 +02:00
|
|
|
u32 tmpa = *(u16 *)&sprite->y;
|
2018-06-11 17:23:14 +02:00
|
|
|
u32 tmpb = *(u16 *)&gSpriteCoordOffsetY;
|
|
|
|
s32 tmp2 = (tmpa - tmp) + tmpb;
|
2021-04-06 11:05:33 +02:00
|
|
|
u16 tmp3 = (16 - ((((u32)tmp2 + 8) & 0xFF) >> 4)) * 2;
|
|
|
|
sprite->subpriority = tmp3 + sElevationToSubpriority[elevation] + subpriority;
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void ObjectEventUpdateSubpriority(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objEvent->fixedPriority)
|
2018-06-11 17:23:14 +02:00
|
|
|
return;
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
SetObjectSubpriorityByElevation(objEvent->previousElevation, sprite, 1);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2022-01-21 18:48:19 +01:00
|
|
|
static bool8 AreElevationsCompatible(u8 a, u8 b)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
if (a == 0 || b == 0)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (a != b)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_SpawnOnTallGrass(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objEvent->currentCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objEvent->currentCoords.y;
|
|
|
|
gFieldEffectArguments[2] = objEvent->previousElevation;
|
2021-04-04 23:52:07 +02:00
|
|
|
gFieldEffectArguments[3] = 2; // priority
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[4] = objEvent->localId << 8 | objEvent->mapNum;
|
|
|
|
gFieldEffectArguments[5] = objEvent->mapGroup;
|
2018-06-11 17:23:14 +02:00
|
|
|
gFieldEffectArguments[6] = (u8)gSaveBlock1Ptr->location.mapNum << 8 | (u8)gSaveBlock1Ptr->location.mapGroup;
|
2021-04-04 23:52:07 +02:00
|
|
|
gFieldEffectArguments[7] = TRUE; // skip to end of anim
|
2018-06-11 17:23:14 +02:00
|
|
|
FieldEffectStart(FLDEFF_TALL_GRASS);
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_StepOnTallGrass(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objEvent->currentCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objEvent->currentCoords.y;
|
|
|
|
gFieldEffectArguments[2] = objEvent->previousElevation;
|
2021-04-04 23:52:07 +02:00
|
|
|
gFieldEffectArguments[3] = 2; // priority
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[4] = objEvent->localId << 8 | objEvent->mapNum;
|
|
|
|
gFieldEffectArguments[5] = objEvent->mapGroup;
|
2018-06-11 17:23:14 +02:00
|
|
|
gFieldEffectArguments[6] = (u8)gSaveBlock1Ptr->location.mapNum << 8 | (u8)gSaveBlock1Ptr->location.mapGroup;
|
2021-04-04 23:52:07 +02:00
|
|
|
gFieldEffectArguments[7] = FALSE; // don't skip to end of anim
|
2018-06-11 17:23:14 +02:00
|
|
|
FieldEffectStart(FLDEFF_TALL_GRASS);
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_SpawnOnLongGrass(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objEvent->currentCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objEvent->currentCoords.y;
|
|
|
|
gFieldEffectArguments[2] = objEvent->previousElevation;
|
2018-06-11 17:23:14 +02:00
|
|
|
gFieldEffectArguments[3] = 2;
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[4] = objEvent->localId << 8 | objEvent->mapNum;
|
|
|
|
gFieldEffectArguments[5] = objEvent->mapGroup;
|
2018-06-11 17:23:14 +02:00
|
|
|
gFieldEffectArguments[6] = (u8)gSaveBlock1Ptr->location.mapNum << 8 | (u8)gSaveBlock1Ptr->location.mapGroup;
|
|
|
|
gFieldEffectArguments[7] = 1;
|
|
|
|
FieldEffectStart(FLDEFF_LONG_GRASS);
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_StepOnLongGrass(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objEvent->currentCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objEvent->currentCoords.y;
|
|
|
|
gFieldEffectArguments[2] = objEvent->previousElevation;
|
2018-06-11 17:23:14 +02:00
|
|
|
gFieldEffectArguments[3] = 2;
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[4] = (objEvent->localId << 8) | objEvent->mapNum;
|
|
|
|
gFieldEffectArguments[5] = objEvent->mapGroup;
|
2018-06-11 17:23:14 +02:00
|
|
|
gFieldEffectArguments[6] = (u8)gSaveBlock1Ptr->location.mapNum << 8 | (u8)gSaveBlock1Ptr->location.mapGroup;
|
|
|
|
gFieldEffectArguments[7] = 0;
|
|
|
|
FieldEffectStart(FLDEFF_LONG_GRASS);
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_WaterReflection(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2021-01-20 00:35:57 +01:00
|
|
|
SetUpReflection(objEvent, sprite, FALSE);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_IceReflection(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2021-01-20 00:35:57 +01:00
|
|
|
SetUpReflection(objEvent, sprite, TRUE);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_FlowingWater(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartFieldEffectForObjectEvent(FLDEFF_FEET_IN_FLOWING_WATER, objEvent);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2022-06-01 18:41:57 +02:00
|
|
|
static void (*const sGroundEffectTracksFuncs[])(struct ObjectEvent *objEvent, struct Sprite *sprite, bool8 isDeepSand) = {
|
2021-10-09 19:21:14 +02:00
|
|
|
[TRACKS_NONE] = DoTracksGroundEffect_None,
|
|
|
|
[TRACKS_FOOT] = DoTracksGroundEffect_Footprints,
|
|
|
|
[TRACKS_BIKE_TIRE] = DoTracksGroundEffect_BikeTireTracks,
|
2018-06-11 17:23:14 +02:00
|
|
|
};
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_SandTracks(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *info = GetObjectEventGraphicsInfo(objEvent->graphicsId);
|
2022-06-01 18:41:57 +02:00
|
|
|
sGroundEffectTracksFuncs[info->tracks](objEvent, sprite, FALSE);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_DeepSandTracks(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *info = GetObjectEventGraphicsInfo(objEvent->graphicsId);
|
2022-06-01 18:41:57 +02:00
|
|
|
sGroundEffectTracksFuncs[info->tracks](objEvent, sprite, TRUE);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2022-06-01 18:41:57 +02:00
|
|
|
static void DoTracksGroundEffect_None(struct ObjectEvent *objEvent, struct Sprite *sprite, bool8 isDeepSand)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-06-01 18:41:57 +02:00
|
|
|
static void DoTracksGroundEffect_Footprints(struct ObjectEvent *objEvent, struct Sprite *sprite, bool8 isDeepSand)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
// First half-word is a Field Effect script id. (gFieldEffectScriptPointers)
|
|
|
|
u16 sandFootprints_FieldEffectData[2] = {
|
|
|
|
FLDEFF_SAND_FOOTPRINTS,
|
|
|
|
FLDEFF_DEEP_SAND_FOOTPRINTS
|
|
|
|
};
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objEvent->previousCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objEvent->previousCoords.y;
|
2018-06-11 17:23:14 +02:00
|
|
|
gFieldEffectArguments[2] = 149;
|
|
|
|
gFieldEffectArguments[3] = 2;
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[4] = objEvent->facingDirection;
|
2022-06-01 18:41:57 +02:00
|
|
|
FieldEffectStart(sandFootprints_FieldEffectData[isDeepSand]);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2022-06-01 18:41:57 +02:00
|
|
|
static void DoTracksGroundEffect_BikeTireTracks(struct ObjectEvent *objEvent, struct Sprite *sprite, bool8 isDeepSand)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
// Specifies which bike track shape to show next.
|
|
|
|
// For example, when the bike turns from up to right, it will show
|
|
|
|
// a track that curves to the right.
|
|
|
|
// Each 4-byte row corresponds to the initial direction of the bike, and
|
|
|
|
// each byte in that row is for the next direction of the bike in the order
|
|
|
|
// of down, up, left, right.
|
|
|
|
static const u8 bikeTireTracks_Transitions[4][4] = {
|
|
|
|
1, 2, 7, 8,
|
|
|
|
1, 2, 6, 5,
|
|
|
|
5, 8, 3, 4,
|
|
|
|
6, 7, 3, 4,
|
|
|
|
};
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objEvent->currentCoords.x != objEvent->previousCoords.x || objEvent->currentCoords.y != objEvent->previousCoords.y)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objEvent->previousCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objEvent->previousCoords.y;
|
2018-06-11 17:23:14 +02:00
|
|
|
gFieldEffectArguments[2] = 149;
|
|
|
|
gFieldEffectArguments[3] = 2;
|
|
|
|
gFieldEffectArguments[4] =
|
2019-11-21 04:55:44 +01:00
|
|
|
bikeTireTracks_Transitions[objEvent->previousMovementDirection][objEvent->facingDirection - 5];
|
2018-06-11 17:23:14 +02:00
|
|
|
FieldEffectStart(FLDEFF_BIKE_TIRE_TRACKS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_Ripple(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
DoRippleFieldEffect(objEvent, sprite);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_StepOnPuddle(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartFieldEffectForObjectEvent(FLDEFF_SPLASH, objEvent);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_SandHeap(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartFieldEffectForObjectEvent(FLDEFF_SAND_PILE, objEvent);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_JumpOnTallGrass(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
u8 spriteId;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objEvent->currentCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objEvent->currentCoords.y;
|
|
|
|
gFieldEffectArguments[2] = objEvent->previousElevation;
|
2018-06-11 17:23:14 +02:00
|
|
|
gFieldEffectArguments[3] = 2;
|
|
|
|
FieldEffectStart(FLDEFF_JUMP_TALL_GRASS);
|
|
|
|
|
2018-10-15 00:43:40 +02:00
|
|
|
spriteId = FindTallGrassFieldEffectSpriteId(
|
2019-11-21 04:55:44 +01:00
|
|
|
objEvent->localId,
|
|
|
|
objEvent->mapNum,
|
|
|
|
objEvent->mapGroup,
|
|
|
|
objEvent->currentCoords.x,
|
|
|
|
objEvent->currentCoords.y);
|
2018-06-11 17:23:14 +02:00
|
|
|
|
|
|
|
if (spriteId == MAX_SPRITES)
|
2019-11-21 04:55:44 +01:00
|
|
|
GroundEffect_SpawnOnTallGrass(objEvent, sprite);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_JumpOnLongGrass(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objEvent->currentCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objEvent->currentCoords.y;
|
|
|
|
gFieldEffectArguments[2] = objEvent->previousElevation;
|
2018-06-11 17:23:14 +02:00
|
|
|
gFieldEffectArguments[3] = 2;
|
|
|
|
FieldEffectStart(FLDEFF_JUMP_LONG_GRASS);
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_JumpOnShallowWater(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objEvent->currentCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objEvent->currentCoords.y;
|
|
|
|
gFieldEffectArguments[2] = objEvent->previousElevation;
|
2018-06-11 17:23:14 +02:00
|
|
|
gFieldEffectArguments[3] = sprite->oam.priority;
|
|
|
|
FieldEffectStart(FLDEFF_JUMP_SMALL_SPLASH);
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_JumpOnWater(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objEvent->currentCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objEvent->currentCoords.y;
|
|
|
|
gFieldEffectArguments[2] = objEvent->previousElevation;
|
2018-06-11 17:23:14 +02:00
|
|
|
gFieldEffectArguments[3] = sprite->oam.priority;
|
|
|
|
FieldEffectStart(FLDEFF_JUMP_BIG_SPLASH);
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_JumpLandingDust(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objEvent->currentCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objEvent->currentCoords.y;
|
|
|
|
gFieldEffectArguments[2] = objEvent->previousElevation;
|
2018-06-11 17:23:14 +02:00
|
|
|
gFieldEffectArguments[3] = sprite->oam.priority;
|
|
|
|
FieldEffectStart(FLDEFF_DUST);
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_ShortGrass(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartFieldEffectForObjectEvent(FLDEFF_SHORT_GRASS, objEvent);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_HotSprings(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
StartFieldEffectForObjectEvent(FLDEFF_HOT_SPRINGS_WATER, objEvent);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void GroundEffect_Seaweed(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
gFieldEffectArguments[0] = objEvent->currentCoords.x;
|
|
|
|
gFieldEffectArguments[1] = objEvent->currentCoords.y;
|
2018-06-11 17:23:14 +02:00
|
|
|
FieldEffectStart(FLDEFF_BUBBLES);
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void (*const sGroundEffectFuncs[])(struct ObjectEvent *objEvent, struct Sprite *sprite) = {
|
2020-06-24 22:27:00 +02:00
|
|
|
GroundEffect_SpawnOnTallGrass, // GROUND_EFFECT_FLAG_TALL_GRASS_ON_SPAWN
|
|
|
|
GroundEffect_StepOnTallGrass, // GROUND_EFFECT_FLAG_TALL_GRASS_ON_MOVE
|
|
|
|
GroundEffect_SpawnOnLongGrass, // GROUND_EFFECT_FLAG_LONG_GRASS_ON_SPAWN
|
|
|
|
GroundEffect_StepOnLongGrass, // GROUND_EFFECT_FLAG_LONG_GRASS_ON_MOVE
|
2021-01-20 00:21:50 +01:00
|
|
|
GroundEffect_WaterReflection, // GROUND_EFFECT_FLAG_WATER_REFLECTION
|
|
|
|
GroundEffect_IceReflection, // GROUND_EFFECT_FLAG_ICE_REFLECTION
|
2020-06-24 22:27:00 +02:00
|
|
|
GroundEffect_FlowingWater, // GROUND_EFFECT_FLAG_SHALLOW_FLOWING_WATER
|
|
|
|
GroundEffect_SandTracks, // GROUND_EFFECT_FLAG_SAND
|
|
|
|
GroundEffect_DeepSandTracks, // GROUND_EFFECT_FLAG_DEEP_SAND
|
|
|
|
GroundEffect_Ripple, // GROUND_EFFECT_FLAG_RIPPLES
|
|
|
|
GroundEffect_StepOnPuddle, // GROUND_EFFECT_FLAG_PUDDLE
|
|
|
|
GroundEffect_SandHeap, // GROUND_EFFECT_FLAG_SAND_PILE
|
|
|
|
GroundEffect_JumpOnTallGrass, // GROUND_EFFECT_FLAG_LAND_IN_TALL_GRASS
|
|
|
|
GroundEffect_JumpOnLongGrass, // GROUND_EFFECT_FLAG_LAND_IN_LONG_GRASS
|
|
|
|
GroundEffect_JumpOnShallowWater, // GROUND_EFFECT_FLAG_LAND_IN_SHALLOW_WATER
|
|
|
|
GroundEffect_JumpOnWater, // GROUND_EFFECT_FLAG_LAND_IN_DEEP_WATER
|
|
|
|
GroundEffect_JumpLandingDust, // GROUND_EFFECT_FLAG_LAND_ON_NORMAL_GROUND
|
|
|
|
GroundEffect_ShortGrass, // GROUND_EFFECT_FLAG_SHORT_GRASS
|
|
|
|
GroundEffect_HotSprings, // GROUND_EFFECT_FLAG_HOT_SPRINGS
|
|
|
|
GroundEffect_Seaweed // GROUND_EFFECT_FLAG_SEAWEED
|
2018-06-11 17:23:14 +02:00
|
|
|
};
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void DoFlaggedGroundEffects(struct ObjectEvent *objEvent, struct Sprite *sprite, u32 flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2020-07-19 20:12:38 +02:00
|
|
|
if (ObjectEventIsFarawayIslandMew(objEvent) == TRUE && !ShouldMewShakeGrass(objEvent))
|
2018-06-11 17:23:14 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_COUNT(sGroundEffectFuncs); i++, flags >>= 1)
|
|
|
|
if (flags & 1)
|
2019-11-21 04:55:44 +01:00
|
|
|
sGroundEffectFuncs[i](objEvent, sprite);
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void filters_out_some_ground_effects(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objEvent->disableCoveringGroundEffects)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objEvent->inShortGrass = 0;
|
|
|
|
objEvent->inSandPile = 0;
|
|
|
|
objEvent->inShallowFlowingWater = 0;
|
|
|
|
objEvent->inHotSprings = 0;
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags &= ~(GROUND_EFFECT_FLAG_HOT_SPRINGS
|
|
|
|
| GROUND_EFFECT_FLAG_SHORT_GRASS
|
|
|
|
| GROUND_EFFECT_FLAG_SAND_PILE
|
|
|
|
| GROUND_EFFECT_FLAG_SHALLOW_FLOWING_WATER
|
|
|
|
| GROUND_EFFECT_FLAG_TALL_GRASS_ON_MOVE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void FilterOutStepOnPuddleGroundEffectIfJumping(struct ObjectEvent *objEvent, u32 *flags)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objEvent->landingJump)
|
2018-06-11 17:23:14 +02:00
|
|
|
*flags &= ~GROUND_EFFECT_FLAG_PUDDLE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void DoGroundEffects_OnSpawn(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
u32 flags;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objEvent->triggerGroundEffectsOnMove)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
flags = 0;
|
2022-01-21 18:48:19 +01:00
|
|
|
UpdateObjectEventElevationAndPriority(objEvent, sprite);
|
2019-11-21 04:55:44 +01:00
|
|
|
GetAllGroundEffectFlags_OnSpawn(objEvent, &flags);
|
|
|
|
SetObjectEventSpriteOamTableForLongGrass(objEvent, sprite);
|
|
|
|
DoFlaggedGroundEffects(objEvent, sprite, flags);
|
|
|
|
objEvent->triggerGroundEffectsOnMove = 0;
|
|
|
|
objEvent->disableCoveringGroundEffects = 0;
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void DoGroundEffects_OnBeginStep(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
u32 flags;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objEvent->triggerGroundEffectsOnMove)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
flags = 0;
|
2022-01-21 18:48:19 +01:00
|
|
|
UpdateObjectEventElevationAndPriority(objEvent, sprite);
|
2019-11-21 04:55:44 +01:00
|
|
|
GetAllGroundEffectFlags_OnBeginStep(objEvent, &flags);
|
|
|
|
SetObjectEventSpriteOamTableForLongGrass(objEvent, sprite);
|
|
|
|
filters_out_some_ground_effects(objEvent, &flags);
|
|
|
|
DoFlaggedGroundEffects(objEvent, sprite, flags);
|
|
|
|
objEvent->triggerGroundEffectsOnMove = 0;
|
|
|
|
objEvent->disableCoveringGroundEffects = 0;
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void DoGroundEffects_OnFinishStep(struct ObjectEvent *objEvent, struct Sprite *sprite)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
u32 flags;
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objEvent->triggerGroundEffectsOnStop)
|
2018-06-11 17:23:14 +02:00
|
|
|
{
|
|
|
|
flags = 0;
|
2022-01-21 18:48:19 +01:00
|
|
|
UpdateObjectEventElevationAndPriority(objEvent, sprite);
|
2019-11-21 04:55:44 +01:00
|
|
|
GetAllGroundEffectFlags_OnFinishStep(objEvent, &flags);
|
|
|
|
SetObjectEventSpriteOamTableForLongGrass(objEvent, sprite);
|
|
|
|
FilterOutStepOnPuddleGroundEffectIfJumping(objEvent, &flags);
|
|
|
|
DoFlaggedGroundEffects(objEvent, sprite, flags);
|
|
|
|
objEvent->triggerGroundEffectsOnStop = 0;
|
|
|
|
objEvent->landingJump = 0;
|
2018-06-11 17:23:14 +02:00
|
|
|
}
|
|
|
|
}
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
bool8 FreezeObjectEvent(struct ObjectEvent *objectEvent)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->heldMovementActive || objectEvent->frozen)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
else
|
|
|
|
{
|
2021-11-01 23:06:15 +01:00
|
|
|
objectEvent->frozen = TRUE;
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
objectEvent->spriteAnimPausedBackup = gSprites[objectEvent->spriteId].animPaused;
|
|
|
|
objectEvent->spriteAffineAnimPausedBackup = gSprites[objectEvent->spriteId].affineAnimPaused;
|
2021-11-01 23:06:15 +01:00
|
|
|
gSprites[objectEvent->spriteId].animPaused = TRUE;
|
|
|
|
gSprites[objectEvent->spriteId].affineAnimPaused = TRUE;
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void FreezeObjectEvents(void)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gObjectEvents[i].active && i != gPlayerAvatar.objectEventId)
|
|
|
|
FreezeObjectEvent(&gObjectEvents[i]);
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void FreezeObjectEventsExceptOne(u8 objectEventId)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2019-11-21 04:55:44 +01:00
|
|
|
if (i != objectEventId && gObjectEvents[i].active && i != gPlayerAvatar.objectEventId)
|
|
|
|
FreezeObjectEvent(&gObjectEvents[i]);
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void UnfreezeObjectEvent(struct ObjectEvent *objectEvent)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (objectEvent->active && objectEvent->frozen)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->frozen = 0;
|
|
|
|
gSprites[objectEvent->spriteId].animPaused = objectEvent->spriteAnimPausedBackup;
|
|
|
|
gSprites[objectEvent->spriteId].affineAnimPaused = objectEvent->spriteAffineAnimPausedBackup;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
void UnfreezeObjectEvents(void)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2019-11-21 04:55:44 +01:00
|
|
|
if (gObjectEvents[i].active)
|
|
|
|
UnfreezeObjectEvent(&gObjectEvents[i]);
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
static void Step1(struct Sprite *sprite, u8 dir)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x += sDirectionToVectors[dir].x;
|
|
|
|
sprite->y += sDirectionToVectors[dir].y;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
static void Step2(struct Sprite *sprite, u8 dir)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x += 2 * (u16) sDirectionToVectors[dir].x;
|
|
|
|
sprite->y += 2 * (u16) sDirectionToVectors[dir].y;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
static void Step3(struct Sprite *sprite, u8 dir)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x += 2 * (u16) sDirectionToVectors[dir].x + (u16) sDirectionToVectors[dir].x;
|
|
|
|
sprite->y += 2 * (u16) sDirectionToVectors[dir].y + (u16) sDirectionToVectors[dir].y;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
static void Step4(struct Sprite *sprite, u8 dir)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x += 4 * (u16) sDirectionToVectors[dir].x;
|
|
|
|
sprite->y += 4 * (u16) sDirectionToVectors[dir].y;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
static void Step8(struct Sprite *sprite, u8 dir)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x += 8 * (u16) sDirectionToVectors[dir].x;
|
|
|
|
sprite->y += 8 * (u16) sDirectionToVectors[dir].y;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
#define sSpeed data[4]
|
2021-04-06 23:55:29 +02:00
|
|
|
#define sTimer data[5]
|
|
|
|
|
|
|
|
static void SetSpriteDataForNormalStep(struct Sprite *sprite, u8 direction, u8 speed)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
sprite->sDirection = direction;
|
|
|
|
sprite->sSpeed = speed;
|
|
|
|
sprite->sTimer = 0;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
typedef void (*SpriteStepFunc)(struct Sprite *sprite, u8 direction);
|
2018-06-12 01:17:31 +02:00
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
static const SpriteStepFunc sStep1Funcs[] = {
|
2018-06-14 00:51:26 +02:00
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
|
|
|
Step1,
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
static const SpriteStepFunc sStep2Funcs[] = {
|
2018-06-14 00:51:26 +02:00
|
|
|
Step2,
|
|
|
|
Step2,
|
|
|
|
Step2,
|
|
|
|
Step2,
|
|
|
|
Step2,
|
|
|
|
Step2,
|
|
|
|
Step2,
|
|
|
|
Step2,
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
static const SpriteStepFunc sStep3Funcs[] = {
|
2018-06-14 00:51:26 +02:00
|
|
|
Step2,
|
|
|
|
Step3,
|
|
|
|
Step3,
|
|
|
|
Step2,
|
|
|
|
Step3,
|
|
|
|
Step3,
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
static const SpriteStepFunc sStep4Funcs[] = {
|
2018-06-14 00:51:26 +02:00
|
|
|
Step4,
|
|
|
|
Step4,
|
|
|
|
Step4,
|
|
|
|
Step4,
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
static const SpriteStepFunc sStep8Funcs[] = {
|
2018-06-14 00:51:26 +02:00
|
|
|
Step8,
|
|
|
|
Step8,
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
static const SpriteStepFunc *const sNpcStepFuncTables[] = {
|
2021-11-03 16:07:05 +01:00
|
|
|
[MOVE_SPEED_NORMAL] = sStep1Funcs,
|
|
|
|
[MOVE_SPEED_FAST_1] = sStep2Funcs,
|
|
|
|
[MOVE_SPEED_FAST_2] = sStep3Funcs,
|
|
|
|
[MOVE_SPEED_FASTER] = sStep4Funcs,
|
|
|
|
[MOVE_SPEED_FASTEST] = sStep8Funcs,
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
static const s16 sStepTimes[] = {
|
2022-05-15 15:44:04 +02:00
|
|
|
[MOVE_SPEED_NORMAL] = ARRAY_COUNT(sStep1Funcs),
|
|
|
|
[MOVE_SPEED_FAST_1] = ARRAY_COUNT(sStep2Funcs),
|
|
|
|
[MOVE_SPEED_FAST_2] = ARRAY_COUNT(sStep3Funcs),
|
|
|
|
[MOVE_SPEED_FASTER] = ARRAY_COUNT(sStep4Funcs),
|
|
|
|
[MOVE_SPEED_FASTEST] = ARRAY_COUNT(sStep8Funcs),
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
static bool8 NpcTakeStep(struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 23:55:29 +02:00
|
|
|
if (sprite->sTimer >= sStepTimes[sprite->sSpeed])
|
2018-06-11 17:34:51 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
sNpcStepFuncTables[sprite->sSpeed][sprite->sTimer](sprite, sprite->sDirection);
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
sprite->sTimer++;
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-04-06 23:55:29 +02:00
|
|
|
if (sprite->sTimer < sStepTimes[sprite->sSpeed])
|
2018-06-11 17:34:51 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
#undef sSpeed
|
2021-04-06 23:55:29 +02:00
|
|
|
#undef sTimer
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
#define sTimer data[4]
|
|
|
|
#define sNumSteps data[5]
|
|
|
|
|
|
|
|
static void SetWalkSlowSpriteData(struct Sprite *sprite, u8 direction)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sDirection = direction;
|
|
|
|
sprite->sTimer = 0;
|
|
|
|
sprite->sNumSteps = 0;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static bool8 UpdateWalkSlowAnim(struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (!(sprite->sTimer & 1))
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
Step1(sprite, sprite->sDirection);
|
|
|
|
sprite->sNumSteps++;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTimer++;
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
if (sprite->sNumSteps > 15)
|
2018-06-11 17:34:51 +02:00
|
|
|
return TRUE;
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
else
|
|
|
|
return FALSE;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
#undef sTimer
|
|
|
|
#undef sNumSteps
|
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
static const s8 sFigure8XOffsets[FIGURE_8_LENGTH] = {
|
2018-06-12 01:17:31 +02:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
static const s8 sFigure8YOffsets[FIGURE_8_LENGTH] = {
|
2018-06-12 01:17:31 +02:00
|
|
|
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,
|
|
|
|
};
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
s16 GetFigure8YOffset(s16 idx)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
return sFigure8YOffsets[idx];
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
s16 GetFigure8XOffset(s16 idx)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
return sFigure8XOffsets[idx];
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
static void InitSpriteForFigure8Anim(struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
sprite->data[6] = 0;
|
|
|
|
sprite->data[7] = 0;
|
|
|
|
}
|
|
|
|
|
2020-06-24 22:27:00 +02:00
|
|
|
static bool8 AnimateSpriteInFigure8(struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
bool8 finished = FALSE;
|
2018-06-11 17:34:51 +02:00
|
|
|
|
|
|
|
switch(sprite->data[7])
|
|
|
|
{
|
2020-06-24 22:27:00 +02:00
|
|
|
case 0:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 += GetFigure8XOffset(sprite->data[6]);
|
|
|
|
sprite->y2 += GetFigure8YOffset(sprite->data[6]);
|
2020-06-24 22:27:00 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 -= GetFigure8XOffset((FIGURE_8_LENGTH - 1) - sprite->data[6]);
|
|
|
|
sprite->y2 += GetFigure8YOffset((FIGURE_8_LENGTH - 1) - sprite->data[6]);
|
2020-06-24 22:27:00 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 -= GetFigure8XOffset(sprite->data[6]);
|
|
|
|
sprite->y2 += GetFigure8YOffset(sprite->data[6]);
|
2020-06-24 22:27:00 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->x2 += GetFigure8XOffset((FIGURE_8_LENGTH - 1) - sprite->data[6]);
|
|
|
|
sprite->y2 += GetFigure8YOffset((FIGURE_8_LENGTH - 1) - sprite->data[6]);
|
2020-06-24 22:27:00 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (++sprite->data[6] == FIGURE_8_LENGTH)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
sprite->data[6] = 0;
|
|
|
|
sprite->data[7]++;
|
|
|
|
}
|
2020-06-24 22:27:00 +02:00
|
|
|
if (sprite->data[7] == 4)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 = 0;
|
|
|
|
sprite->x2 = 0;
|
2020-06-24 22:27:00 +02:00
|
|
|
finished = TRUE;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
2020-06-24 22:27:00 +02:00
|
|
|
return finished;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static const s8 sJumpY_High[] = {
|
|
|
|
-4, -6, -8, -10, -11, -12, -12, -12,
|
|
|
|
-11, -10, -9, -8, -6, -4, 0, 0
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static const s8 sJumpY_Low[] = {
|
|
|
|
0, -2, -3, -4, -5, -6, -6, -6,
|
|
|
|
-5, -5, -4, -3, -2, 0, 0, 0
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static const s8 sJumpY_Normal[] = {
|
|
|
|
-2, -4, -6, -8, -9, -10, -10, -10,
|
|
|
|
-9, -8, -6, -5, -3, -2, 0, 0
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static const s8 *const sJumpYTable[] = {
|
|
|
|
[JUMP_TYPE_HIGH] = sJumpY_High,
|
|
|
|
[JUMP_TYPE_LOW] = sJumpY_Low,
|
|
|
|
[JUMP_TYPE_NORMAL] = sJumpY_Normal
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static s16 GetJumpY(s16 i, u8 type)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
return sJumpYTable[type][i];
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
#define sDistance data[4]
|
2021-04-06 11:05:33 +02:00
|
|
|
#define sJumpType data[5]
|
|
|
|
#define sTimer data[6]
|
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
static void SetJumpSpriteData(struct Sprite *sprite, u8 direction, u8 distance, u8 type)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sDirection = direction;
|
2021-11-28 04:35:01 +01:00
|
|
|
sprite->sDistance = distance;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sJumpType = type;
|
|
|
|
sprite->sTimer = 0;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static u8 DoJumpSpriteMovement(struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
s16 distanceToTime[] = {
|
|
|
|
[JUMP_DISTANCE_IN_PLACE] = 16,
|
|
|
|
[JUMP_DISTANCE_NORMAL] = 16,
|
|
|
|
[JUMP_DISTANCE_FAR] = 32,
|
|
|
|
};
|
|
|
|
u8 distanceToShift[] = {
|
|
|
|
[JUMP_DISTANCE_IN_PLACE] = 0,
|
|
|
|
[JUMP_DISTANCE_NORMAL] = 0,
|
|
|
|
[JUMP_DISTANCE_FAR] = 1,
|
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
u8 result = 0;
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-11-28 04:56:26 +01:00
|
|
|
if (sprite->sDistance != JUMP_DISTANCE_IN_PLACE)
|
2021-04-06 11:05:33 +02:00
|
|
|
Step1(sprite, sprite->sDirection);
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
sprite->y2 = GetJumpY(sprite->sTimer >> distanceToShift[sprite->sDistance], sprite->sJumpType);
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTimer++;
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
if (sprite->sTimer == distanceToTime[sprite->sDistance] >> 1)
|
2021-04-06 11:05:33 +02:00
|
|
|
result = JUMP_HALFWAY;
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
if (sprite->sTimer >= distanceToTime[sprite->sDistance])
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
result = JUMP_FINISHED;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
return result;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static u8 DoJumpSpecialSpriteMovement(struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-11-28 04:56:26 +01:00
|
|
|
s16 distanceToTime[] = {
|
|
|
|
[JUMP_DISTANCE_IN_PLACE] = 32,
|
|
|
|
[JUMP_DISTANCE_NORMAL] = 32,
|
|
|
|
[JUMP_DISTANCE_FAR] = 64,
|
|
|
|
};
|
|
|
|
u8 distanceToShift[] = {
|
|
|
|
[JUMP_DISTANCE_IN_PLACE] = 1,
|
|
|
|
[JUMP_DISTANCE_NORMAL] = 1,
|
|
|
|
[JUMP_DISTANCE_FAR] = 2,
|
|
|
|
};
|
2021-04-06 11:05:33 +02:00
|
|
|
u8 result = 0;
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-11-28 04:56:26 +01:00
|
|
|
if (sprite->sDistance != JUMP_DISTANCE_IN_PLACE && !(sprite->sTimer & 1))
|
2021-04-06 11:05:33 +02:00
|
|
|
Step1(sprite, sprite->sDirection);
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
sprite->y2 = GetJumpY(sprite->sTimer >> distanceToShift[sprite->sDistance], sprite->sJumpType);
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sTimer++;
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
if (sprite->sTimer == distanceToTime[sprite->sDistance] >> 1)
|
2021-04-06 11:05:33 +02:00
|
|
|
result = JUMP_HALFWAY;
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
if (sprite->sTimer >= distanceToTime[sprite->sDistance])
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
result = JUMP_FINISHED;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
return result;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-11-28 04:35:01 +01:00
|
|
|
#undef sDistance
|
2021-04-06 11:05:33 +02:00
|
|
|
#undef sJumpType
|
|
|
|
#undef sTimer
|
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
static void SetMovementDelay(struct Sprite *sprite, s16 timer)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
sprite->data[3] = timer;
|
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
static bool8 WaitForMovementDelay(struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
if (--sprite->data[3] == 0)
|
2018-06-11 17:34:51 +02:00
|
|
|
return TRUE;
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
else
|
|
|
|
return FALSE;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
void SetAndStartSpriteAnim(struct Sprite *sprite, u8 animNum, u8 animCmdIndex)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2018-10-20 22:01:45 +02:00
|
|
|
sprite->animNum = animNum;
|
|
|
|
sprite->animPaused = FALSE;
|
|
|
|
SeekSpriteAnim(sprite, animCmdIndex);
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
bool8 SpriteAnimEnded(struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
if (sprite->animEnded)
|
|
|
|
return TRUE;
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
else
|
|
|
|
return FALSE;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
void UpdateObjectEventSpriteInvisibility(struct Sprite *sprite, bool8 invisible)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
u16 x, y;
|
|
|
|
s16 x2, y2;
|
|
|
|
|
|
|
|
sprite->invisible = invisible;
|
|
|
|
|
|
|
|
if (sprite->coordOffsetEnabled)
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
x = sprite->x + sprite->x2 + sprite->centerToCornerVecX + gSpriteCoordOffsetX;
|
|
|
|
y = sprite->y + sprite->y2 + sprite->centerToCornerVecY + gSpriteCoordOffsetY;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
x = sprite->x + sprite->x2 + sprite->centerToCornerVecX;
|
|
|
|
y = sprite->y + sprite->y2 + sprite->centerToCornerVecY;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
x2 = x - (sprite->centerToCornerVecX >> 1);
|
|
|
|
y2 = y - (sprite->centerToCornerVecY >> 1);
|
|
|
|
|
2021-04-04 23:52:07 +02:00
|
|
|
if ((s16)x >= DISPLAY_WIDTH + 16 || x2 < -16)
|
2018-09-10 17:25:58 +02:00
|
|
|
sprite->invisible = TRUE;
|
2021-04-04 23:52:07 +02:00
|
|
|
if ((s16)y >= DISPLAY_HEIGHT + 16 || y2 < -16)
|
2018-09-10 17:25:58 +02:00
|
|
|
sprite->invisible = TRUE;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
#define sInvisible data[2]
|
|
|
|
#define sAnimNum data[3]
|
|
|
|
#define sAnimState data[4]
|
2020-06-01 16:23:12 +02:00
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
static void SpriteCB_VirtualObject(struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-11-18 05:28:43 +01:00
|
|
|
VirtualObject_UpdateAnim(sprite);
|
2022-01-21 18:48:19 +01:00
|
|
|
SetObjectSubpriorityByElevation(sprite->sVirtualObjElev, sprite, 1);
|
2021-04-06 11:05:33 +02:00
|
|
|
UpdateObjectEventSpriteInvisibility(sprite, sprite->sInvisible);
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
// Unused
|
2021-11-18 05:28:43 +01:00
|
|
|
static void DestroyVirtualObjects(void)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
for (i = 0; i < MAX_SPRITES; i++)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
struct Sprite *sprite = &gSprites[i];
|
2021-11-18 05:28:43 +01:00
|
|
|
if(sprite->inUse && sprite->callback == SpriteCB_VirtualObject)
|
2018-06-11 17:34:51 +02:00
|
|
|
DestroySprite(sprite);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
static int GetVirtualObjectSpriteId(u8 virtualObjId)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
for (i = 0; i < MAX_SPRITES; i++)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
struct Sprite *sprite = &gSprites[i];
|
2021-11-18 05:28:43 +01:00
|
|
|
if (sprite->inUse && sprite->callback == SpriteCB_VirtualObject && (u8)sprite->sVirtualObjId == virtualObjId)
|
2018-06-11 17:34:51 +02:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return MAX_SPRITES;
|
|
|
|
}
|
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
void TurnVirtualObject(u8 virtualObjId, u8 direction)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-11-18 05:28:43 +01:00
|
|
|
u8 spriteId = GetVirtualObjectSpriteId(virtualObjId);
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
|
|
|
StartSpriteAnim(&gSprites[spriteId], GetFaceDirectionAnimNum(direction));
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
void SetVirtualObjectGraphics(u8 virtualObjId, u8 graphicsId)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-11-18 05:28:43 +01:00
|
|
|
int spriteId = GetVirtualObjectSpriteId(virtualObjId);
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
struct Sprite *sprite = &gSprites[spriteId];
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(graphicsId);
|
2018-06-11 17:34:51 +02:00
|
|
|
u16 tileNum = sprite->oam.tileNum;
|
|
|
|
|
2018-10-20 22:01:45 +02:00
|
|
|
sprite->oam = *graphicsInfo->oam;
|
2018-06-11 17:34:51 +02:00
|
|
|
sprite->oam.tileNum = tileNum;
|
2018-10-20 22:01:45 +02:00
|
|
|
sprite->oam.paletteNum = graphicsInfo->paletteSlot;
|
|
|
|
sprite->images = graphicsInfo->images;
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
if (graphicsInfo->subspriteTables == NULL)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
sprite->subspriteTables = NULL;
|
|
|
|
sprite->subspriteTableNum = 0;
|
2019-12-05 03:00:45 +01:00
|
|
|
sprite->subspriteMode = SUBSPRITES_OFF;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-20 22:01:45 +02:00
|
|
|
SetSubspriteTables(sprite, graphicsInfo->subspriteTables);
|
2019-12-05 03:00:45 +01:00
|
|
|
sprite->subspriteMode = SUBSPRITES_IGNORE_PRIORITY;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
StartSpriteAnim(sprite, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
void SetVirtualObjectInvisibility(u8 virtualObjId, bool32 invisible)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-11-18 05:28:43 +01:00
|
|
|
u8 spriteId = GetVirtualObjectSpriteId(virtualObjId);
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
if (spriteId == MAX_SPRITES)
|
2018-06-11 17:34:51 +02:00
|
|
|
return;
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
if (invisible)
|
2021-04-06 11:05:33 +02:00
|
|
|
gSprites[spriteId].sInvisible = TRUE;
|
2018-06-11 17:34:51 +02:00
|
|
|
else
|
2021-04-06 11:05:33 +02:00
|
|
|
gSprites[spriteId].sInvisible = FALSE;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
bool32 IsVirtualObjectInvisible(u8 virtualObjId)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-11-18 05:28:43 +01:00
|
|
|
u8 spriteId = GetVirtualObjectSpriteId(virtualObjId);
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
if (spriteId == MAX_SPRITES)
|
2018-06-11 17:34:51 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
return (gSprites[spriteId].sInvisible == TRUE);
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
void SetVirtualObjectSpriteAnim(u8 virtualObjId, u8 animNum)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-11-18 05:28:43 +01:00
|
|
|
u8 spriteId = GetVirtualObjectSpriteId(virtualObjId);
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
if (spriteId != MAX_SPRITES)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
gSprites[spriteId].sAnimNum = animNum;
|
|
|
|
gSprites[spriteId].sAnimState = 0;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
static void MoveUnionRoomObjectUp(struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
switch(sprite->sAnimState)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-11-18 05:28:43 +01:00
|
|
|
case 0:
|
|
|
|
sprite->y2 = 0;
|
|
|
|
sprite->sAnimState++;
|
|
|
|
case 1:
|
|
|
|
sprite->y2 -= 8;
|
|
|
|
if (sprite->y2 == -DISPLAY_HEIGHT)
|
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 = 0;
|
2021-11-18 05:28:43 +01:00
|
|
|
sprite->sInvisible = TRUE;
|
|
|
|
sprite->sAnimNum = 0;
|
|
|
|
sprite->sAnimState = 0;
|
|
|
|
}
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
static void MoveUnionRoomObjectDown(struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
switch(sprite->sAnimState)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-11-18 05:28:43 +01:00
|
|
|
case 0:
|
|
|
|
sprite->y2 = -DISPLAY_HEIGHT;
|
|
|
|
sprite->sAnimState++;
|
|
|
|
case 1:
|
|
|
|
sprite->y2 += 8;
|
|
|
|
if(sprite->y2 == 0)
|
|
|
|
{
|
|
|
|
sprite->sAnimNum = 0;
|
|
|
|
sprite->sAnimState = 0;
|
|
|
|
}
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
static void VirtualObject_UpdateAnim(struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
switch(sprite->sAnimNum)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-11-18 05:28:43 +01:00
|
|
|
case UNION_ROOM_SPAWN_IN:
|
|
|
|
MoveUnionRoomObjectDown(sprite);
|
|
|
|
break;
|
|
|
|
case UNION_ROOM_SPAWN_OUT:
|
|
|
|
MoveUnionRoomObjectUp(sprite);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sprite->sAnimNum = 0;
|
|
|
|
break;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-18 05:28:43 +01:00
|
|
|
bool32 IsVirtualObjectAnimating(u8 virtualObjId)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-11-18 05:28:43 +01:00
|
|
|
u8 spriteId = GetVirtualObjectSpriteId(virtualObjId);
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2020-06-01 16:23:12 +02:00
|
|
|
if (spriteId == MAX_SPRITES)
|
2018-06-11 17:34:51 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
if (gSprites[spriteId].sAnimNum != 0)
|
2018-06-11 17:34:51 +02:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u32 StartFieldEffectForObjectEvent(u8 fieldEffectId, struct ObjectEvent *objectEvent)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
ObjectEventGetLocalIdAndMap(objectEvent, &gFieldEffectArguments[0], &gFieldEffectArguments[1], &gFieldEffectArguments[2]);
|
2018-06-11 17:34:51 +02:00
|
|
|
return FieldEffectStart(fieldEffectId);
|
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void DoShadowFieldEffect(struct ObjectEvent *objectEvent)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
if (!objectEvent->hasShadow)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
objectEvent->hasShadow = TRUE;
|
2019-11-21 04:55:44 +01:00
|
|
|
StartFieldEffectForObjectEvent(FLDEFF_SHADOW, objectEvent);
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
static void DoRippleFieldEffect(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId);
|
2021-07-07 15:11:52 +02:00
|
|
|
gFieldEffectArguments[0] = sprite->x;
|
|
|
|
gFieldEffectArguments[1] = sprite->y + (graphicsInfo->height >> 1) - 2;
|
2018-06-11 17:34:51 +02:00
|
|
|
gFieldEffectArguments[2] = 151;
|
|
|
|
gFieldEffectArguments[3] = 3;
|
|
|
|
FieldEffectStart(FLDEFF_RIPPLE);
|
|
|
|
}
|
|
|
|
|
2022-08-13 03:18:10 +02:00
|
|
|
u8 (*const gMovementActionFuncs_LockAnim[])(struct ObjectEvent *, struct Sprite *) = {
|
|
|
|
MovementAction_LockAnim_Step0,
|
2018-06-14 00:51:26 +02:00
|
|
|
MovementAction_Finish,
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2022-08-13 03:18:10 +02:00
|
|
|
u8 (*const gMovementActionFuncs_UnlockAnim[])(struct ObjectEvent *, struct Sprite *) = {
|
|
|
|
MovementAction_UnlockAnim_Step0,
|
2018-06-14 00:51:26 +02:00
|
|
|
MovementAction_Finish,
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 (*const gMovementActionFuncs_FlyUp[])(struct ObjectEvent *, struct Sprite *) = {
|
2018-06-14 00:51:26 +02:00
|
|
|
MovementAction_FlyUp_Step0,
|
|
|
|
MovementAction_FlyUp_Step1,
|
|
|
|
MovementAction_Fly_Finish,
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 (*const gMovementActionFuncs_FlyDown[])(struct ObjectEvent *, struct Sprite *) = {
|
2018-06-14 00:51:26 +02:00
|
|
|
MovementAction_FlyDown_Step0,
|
|
|
|
MovementAction_FlyDown_Step1,
|
|
|
|
MovementAction_Fly_Finish,
|
2018-06-12 01:17:31 +02:00
|
|
|
};
|
|
|
|
|
2022-08-13 03:18:10 +02:00
|
|
|
u8 MovementAction_LockAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
bool32 ableToStore = FALSE;
|
2021-04-06 11:05:33 +02:00
|
|
|
if (sLockedAnimObjectEvents == NULL)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-04-06 11:05:33 +02:00
|
|
|
sLockedAnimObjectEvents = AllocZeroed(sizeof(struct LockedAnimObjectEvents));
|
2022-08-13 03:18:10 +02:00
|
|
|
sLockedAnimObjectEvents->localIds[0] = objectEvent->localId;
|
2021-04-06 11:05:33 +02:00
|
|
|
sLockedAnimObjectEvents->count = 1;
|
2020-09-05 20:51:17 +02:00
|
|
|
ableToStore = TRUE;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
u8 i;
|
2022-08-13 03:18:10 +02:00
|
|
|
u8 firstFreeSlot = OBJECT_EVENTS_COUNT;
|
|
|
|
bool32 found = FALSE;
|
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2022-08-13 03:18:10 +02:00
|
|
|
if (firstFreeSlot == OBJECT_EVENTS_COUNT && sLockedAnimObjectEvents->localIds[i] == 0)
|
2018-06-11 17:34:51 +02:00
|
|
|
firstFreeSlot = i;
|
|
|
|
|
2022-08-13 03:18:10 +02:00
|
|
|
if (sLockedAnimObjectEvents->localIds[i] == objectEvent->localId)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-13 03:18:10 +02:00
|
|
|
if (!found && firstFreeSlot != OBJECT_EVENTS_COUNT)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2022-08-13 03:18:10 +02:00
|
|
|
sLockedAnimObjectEvents->localIds[firstFreeSlot] = objectEvent->localId;
|
2021-04-06 11:05:33 +02:00
|
|
|
sLockedAnimObjectEvents->count++;
|
2018-06-11 17:34:51 +02:00
|
|
|
ableToStore = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ableToStore == TRUE)
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->inanimate = TRUE;
|
|
|
|
objectEvent->facingDirectionLocked = TRUE;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
2018-06-11 17:34:51 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-08-13 03:18:10 +02:00
|
|
|
u8 MovementAction_UnlockAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
bool32 ableToStore;
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 index;
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId = 1;
|
|
|
|
if (sLockedAnimObjectEvents != NULL)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
ableToStore = FALSE;
|
2019-11-21 04:55:44 +01:00
|
|
|
index = FindLockedObjectEventIndex(objectEvent);
|
2022-08-13 03:18:10 +02:00
|
|
|
if (index != OBJECT_EVENTS_COUNT)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2022-08-13 03:18:10 +02:00
|
|
|
sLockedAnimObjectEvents->localIds[index] = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sLockedAnimObjectEvents->count--;
|
2018-06-11 17:34:51 +02:00
|
|
|
ableToStore = TRUE;
|
|
|
|
}
|
2021-04-06 11:05:33 +02:00
|
|
|
if (sLockedAnimObjectEvents->count == 0)
|
|
|
|
FREE_AND_SET_NULL(sLockedAnimObjectEvents);
|
2018-06-11 17:34:51 +02:00
|
|
|
if (ableToStore == TRUE)
|
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->inanimate = GetObjectEventGraphicsInfo(objectEvent->graphicsId)->inanimate;
|
|
|
|
objectEvent->facingDirectionLocked = FALSE;
|
2018-06-11 17:34:51 +02:00
|
|
|
sprite->animPaused = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 FindLockedObjectEventIndex(struct ObjectEvent *objectEvent)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2022-08-13 03:18:10 +02:00
|
|
|
if (sLockedAnimObjectEvents->localIds[i] == objectEvent->localId)
|
2018-06-11 17:34:51 +02:00
|
|
|
return i;
|
|
|
|
}
|
2019-11-21 05:12:51 +01:00
|
|
|
return OBJECT_EVENTS_COUNT;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void CreateLevitateMovementTask(struct ObjectEvent *objectEvent)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2018-06-14 00:51:26 +02:00
|
|
|
u8 taskId = CreateTask(ApplyLevitateMovement, 0xFF);
|
2018-06-11 17:34:51 +02:00
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
StoreWordInTwoHalfwords(&task->data[0], (u32)objectEvent);
|
2019-11-21 04:55:44 +01:00
|
|
|
objectEvent->warpArrowSpriteId = taskId;
|
2018-12-05 15:31:01 +01:00
|
|
|
task->data[3] = 0xFFFF;
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
|
2018-06-14 00:51:26 +02:00
|
|
|
static void ApplyLevitateMovement(u8 taskId)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEvent *objectEvent;
|
2018-06-11 17:34:51 +02:00
|
|
|
struct Sprite *sprite;
|
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
LoadWordFromTwoHalfwords(&task->data[0], (u32 *)&objectEvent); // load the map object pointer.
|
2019-11-21 04:55:44 +01:00
|
|
|
sprite = &gSprites[objectEvent->spriteId];
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
if(!(task->data[2] & 3))
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 += task->data[3];
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
if(!(task->data[2] & 15))
|
2018-06-11 17:34:51 +02:00
|
|
|
task->data[3] = -task->data[3];
|
|
|
|
|
|
|
|
task->data[2]++;
|
|
|
|
}
|
|
|
|
|
2021-04-06 11:05:33 +02:00
|
|
|
static void DestroyLevitateMovementTask(u8 taskId)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2019-11-21 04:55:44 +01:00
|
|
|
struct ObjectEvent *objectEvent;
|
2018-06-11 17:34:51 +02:00
|
|
|
struct Task *task = &gTasks[taskId];
|
|
|
|
|
Undo PokeCodec's PRs
This commit undoes most of PokeCodec's PRs after the debate in chat. Some
harmless or completely superseded PRs have been left alone, as there is not
much benefit in attempting to undo them.
Reverts #1104, #1108, #1115, #1118, #1119, #1124, #1126, #1127, #1132, #1136,
#1137, #1139, #1140, #1144, #1148, #1149, #1150, #1153, #1155, #1177, #1179,
#1180, #1181, #1182 and #1183.
2020-09-13 09:22:50 +02:00
|
|
|
LoadWordFromTwoHalfwords(&task->data[0], (u32 *)&objectEvent); // unused objectEvent
|
2018-06-11 17:34:51 +02:00
|
|
|
DestroyTask(taskId);
|
|
|
|
}
|
|
|
|
|
2021-01-26 10:41:13 +01:00
|
|
|
// Used to freeze other objects except two trainers approaching for battle
|
|
|
|
void FreezeObjectEventsExceptTwo(u8 objectEventId1, u8 objectEventId2)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
u8 i;
|
|
|
|
|
2019-11-21 05:12:51 +01:00
|
|
|
for(i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-01-26 10:41:13 +01:00
|
|
|
if(i != objectEventId1 && i != objectEventId2 &&
|
2019-11-21 04:55:44 +01:00
|
|
|
gObjectEvents[i].active && i != gPlayerAvatar.objectEventId)
|
|
|
|
FreezeObjectEvent(&gObjectEvents[i]);
|
2018-06-11 17:34:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementAction_FlyUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 = 0;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId++;
|
2018-06-11 17:34:51 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementAction_FlyUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 -= 8;
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
if(sprite->y2 == -DISPLAY_HEIGHT)
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId++;
|
2018-06-11 17:34:51 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementAction_FlyDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 = -DISPLAY_HEIGHT;
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId++;
|
2018-06-11 17:34:51 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementAction_FlyDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
2021-07-07 15:11:52 +02:00
|
|
|
sprite->y2 += 8;
|
2018-06-11 17:34:51 +02:00
|
|
|
|
2021-07-07 15:11:52 +02:00
|
|
|
if(!sprite->y2)
|
2021-04-06 11:05:33 +02:00
|
|
|
sprite->sActionFuncId++;
|
2018-06-11 17:34:51 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// though this function returns TRUE without doing anything, this header is required due to being in an array of functions which needs it.
|
2019-11-21 04:55:44 +01:00
|
|
|
u8 MovementAction_Fly_Finish(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
2018-06-11 17:34:51 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|