Merge branch 'master' into _pret/pr/pyramidLocation

This commit is contained in:
GriffinR
2025-06-30 11:51:45 -04:00
committed by GitHub
799 changed files with 17249 additions and 16852 deletions

View File

@@ -30,6 +30,17 @@
#include "constants/trainer_types.h"
#include "constants/union_room.h"
#define SPECIAL_LOCALIDS_START (min(LOCALID_CAMERA, \
min(LOCALID_PLAYER, \
LOCALID_BERRY_BLENDER_PLAYER_END - MAX_RFU_PLAYERS + 1)))
// The object event templates on a map cannot use the special IDs listed above or they can behave unexpectedly.
// For more details on these special IDs see their definitions in 'include/constants/event_objects.h'.
// OBJECT_EVENT_TEMPLATES_COUNT should always be low enough that it doesn't overlap with these IDs.
#if OBJECT_EVENT_TEMPLATES_COUNT >= SPECIAL_LOCALIDS_START
#error "OBJECT_EVENT_TEMPLATES_COUNT is too large. Object event local IDs may overlap with reserved IDs."
#endif
// this file was known as evobjmv.c in Game Freak's original source
enum {
@@ -1171,9 +1182,9 @@ static const u8 sPlayerDirectionToCopyDirection[][4] = {
static void ClearObjectEvent(struct ObjectEvent *objectEvent)
{
*objectEvent = (struct ObjectEvent){};
objectEvent->localId = OBJ_EVENT_ID_PLAYER;
objectEvent->mapNum = MAP_NUM(UNDEFINED);
objectEvent->mapGroup = MAP_GROUP(UNDEFINED);
objectEvent->localId = LOCALID_PLAYER;
objectEvent->mapNum = MAP_NUM(MAP_UNDEFINED);
objectEvent->mapGroup = MAP_GROUP(MAP_UNDEFINED);
objectEvent->movementActionId = MOVEMENT_ACTION_NONE;
}
@@ -1222,7 +1233,7 @@ u8 GetFirstInactiveObjectEventId(void)
u8 GetObjectEventIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroupId)
{
if (localId < OBJ_EVENT_ID_PLAYER)
if (localId < LOCALID_PLAYER)
return GetObjectEventIdByLocalIdAndMapInternal(localId, mapNum, mapGroupId);
return GetObjectEventIdByLocalId(localId);
@@ -1301,8 +1312,8 @@ static u8 InitObjectEventStateFromTemplate(const struct ObjectEventTemplate *tem
objectEvent->previousCoords.y = y;
objectEvent->currentElevation = template->elevation;
objectEvent->previousElevation = template->elevation;
objectEvent->rangeX = template->movementRangeX;
objectEvent->rangeY = template->movementRangeY;
objectEvent->range.rangeX = template->movementRangeX;
objectEvent->range.rangeY = template->movementRangeY;
objectEvent->trainerType = template->trainerType;
objectEvent->mapNum = mapNum;
objectEvent->trainerRange_berryTreeId = template->trainerRange_berryTreeId;
@@ -1311,10 +1322,10 @@ static u8 InitObjectEventStateFromTemplate(const struct ObjectEventTemplate *tem
SetObjectEventDynamicGraphicsId(objectEvent);
if (sMovementTypeHasRange[objectEvent->movementType])
{
if (objectEvent->rangeX == 0)
objectEvent->rangeX++;
if (objectEvent->rangeY == 0)
objectEvent->rangeY++;
if (objectEvent->range.rangeX == 0)
objectEvent->range.rangeX++;
if (objectEvent->range.rangeY == 0)
objectEvent->range.rangeY++;
}
return objectEventId;
}
@@ -4682,18 +4693,18 @@ static bool8 IsCoordOutsideObjectEventMovementRange(struct ObjectEvent *objectEv
s16 top;
s16 bottom;
if (objectEvent->rangeX != 0)
if (objectEvent->range.rangeX != 0)
{
left = objectEvent->initialCoords.x - objectEvent->rangeX;
right = objectEvent->initialCoords.x + objectEvent->rangeX;
left = objectEvent->initialCoords.x - objectEvent->range.rangeX;
right = objectEvent->initialCoords.x + objectEvent->range.rangeX;
if (left > x || right < x)
return TRUE;
}
if (objectEvent->rangeY != 0)
if (objectEvent->range.rangeY != 0)
{
top = objectEvent->initialCoords.y - objectEvent->rangeY;
bottom = objectEvent->initialCoords.y + objectEvent->rangeY;
top = objectEvent->initialCoords.y - objectEvent->range.rangeY;
bottom = objectEvent->initialCoords.y + objectEvent->range.rangeY;
if (top > y || bottom < y)
return TRUE;
@@ -6171,7 +6182,7 @@ bool8 MovementAction_FacePlayer_Step0(struct ObjectEvent *objectEvent, struct Sp
{
u8 playerObjectId;
if (!TryGetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0, &playerObjectId))
if (!TryGetObjectEventIdByLocalIdAndMap(LOCALID_PLAYER, 0, 0, &playerObjectId))
FaceDirection(objectEvent, sprite, GetDirectionToFace(objectEvent->currentCoords.x,
objectEvent->currentCoords.y,
gObjectEvents[playerObjectId].currentCoords.x,
@@ -6184,7 +6195,7 @@ bool8 MovementAction_FaceAwayPlayer_Step0(struct ObjectEvent *objectEvent, struc
{
u8 playerObjectId;
if (!TryGetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0, &playerObjectId))
if (!TryGetObjectEventIdByLocalIdAndMap(LOCALID_PLAYER, 0, 0, &playerObjectId))
FaceDirection(objectEvent, sprite, GetOppositeDirection(GetDirectionToFace(objectEvent->currentCoords.x,
objectEvent->currentCoords.y,
gObjectEvents[playerObjectId].currentCoords.x,
@@ -8814,7 +8825,7 @@ u8 MovementAction_LockAnim_Step0(struct ObjectEvent *objectEvent, struct Sprite
bool32 found = FALSE;
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
{
if (firstFreeSlot == OBJECT_EVENTS_COUNT && sLockedAnimObjectEvents->localIds[i] == 0)
if (firstFreeSlot == OBJECT_EVENTS_COUNT && sLockedAnimObjectEvents->localIds[i] == LOCALID_NONE)
firstFreeSlot = i;
if (sLockedAnimObjectEvents->localIds[i] == objectEvent->localId)
@@ -8854,7 +8865,7 @@ u8 MovementAction_UnlockAnim_Step0(struct ObjectEvent *objectEvent, struct Sprit
index = FindLockedObjectEventIndex(objectEvent);
if (index != OBJECT_EVENTS_COUNT)
{
sLockedAnimObjectEvents->localIds[index] = 0;
sLockedAnimObjectEvents->localIds[index] = LOCALID_NONE;
sLockedAnimObjectEvents->count--;
ableToStore = TRUE;
}