mirror of
https://github.com/pret/pokeemerald.git
synced 2026-03-21 09:45:09 -05:00
This commit is contained in:
parent
86a159a1eb
commit
25ffb2c12c
|
|
@ -11,6 +11,15 @@
|
|||
#define MAPGRID_COLLISION_SHIFT 10
|
||||
#define MAPGRID_ELEVATION_SHIFT 12
|
||||
|
||||
enum
|
||||
{
|
||||
ELEVATION_TRANSITION = 0,
|
||||
ELEVATION_SURF = 1,
|
||||
ELEVATION_DEFAULT = 3,
|
||||
ELEVATION_MULTI_LEVEL = 15,
|
||||
ELEVATION_INVALID = 0xFFFF
|
||||
};
|
||||
|
||||
#define PACK_METATILE(metatileId) PACK(metatileId, MAPGRID_METATILE_ID_SHIFT, MAPGRID_METATILE_ID_MASK)
|
||||
#define PACK_COLLISION(collision) PACK(collision, MAPGRID_COLLISION_SHIFT, MAPGRID_COLLISION_MASK)
|
||||
#define PACK_ELEVATION(elevation) PACK(elevation, MAPGRID_ELEVATION_SHIFT, MAPGRID_ELEVATION_MASK)
|
||||
|
|
|
|||
|
|
@ -1191,7 +1191,7 @@ static void WarpToInitialPosition(u8 taskId)
|
|||
|
||||
static u16 GetDecorationElevation(u8 decoration, u8 tileIndex)
|
||||
{
|
||||
u16 elevation = -1;
|
||||
u16 elevation = ELEVATION_INVALID;
|
||||
switch (decoration)
|
||||
{
|
||||
case DECOR_STAND:
|
||||
|
|
@ -1234,7 +1234,7 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight,
|
|||
overlapsWall = 0;
|
||||
|
||||
elevation = GetDecorationElevation(gDecorations[decoration].id, j * decWidth + i);
|
||||
if (elevation != 0xFFFF)
|
||||
if (elevation != ELEVATION_INVALID)
|
||||
MapGridSetMetatileEntryAt(x, y, (gDecorations[decoration].tiles[j * decWidth + i] + (NUM_TILES_IN_PRIMARY | overlapsWall)) | impassableFlag | elevation);
|
||||
else
|
||||
MapGridSetMetatileIdAt(x, y, (gDecorations[decoration].tiles[j * decWidth + i] + (NUM_TILES_IN_PRIMARY | overlapsWall)) | impassableFlag);
|
||||
|
|
|
|||
|
|
@ -2208,7 +2208,7 @@ u8 GetObjectEventIdByPosition(u16 x, u16 y, u8 elevation)
|
|||
|
||||
static bool8 ObjectEventDoesElevationMatch(struct ObjectEvent *objectEvent, u8 elevation)
|
||||
{
|
||||
if (objectEvent->currentElevation != 0 && elevation != 0 && objectEvent->currentElevation != elevation)
|
||||
if (objectEvent->currentElevation != ELEVATION_TRANSITION && elevation != ELEVATION_TRANSITION && objectEvent->currentElevation != elevation)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
|
@ -7708,12 +7708,12 @@ static bool8 IsElevationMismatchAt(u8 elevation, s16 x, s16 y)
|
|||
{
|
||||
u8 mapElevation;
|
||||
|
||||
if (elevation == 0)
|
||||
if (elevation == ELEVATION_TRANSITION)
|
||||
return FALSE;
|
||||
|
||||
mapElevation = MapGridGetElevationAt(x, y);
|
||||
|
||||
if (mapElevation == 0 || mapElevation == 15)
|
||||
if (mapElevation == ELEVATION_TRANSITION || mapElevation == ELEVATION_MULTI_LEVEL)
|
||||
return FALSE;
|
||||
|
||||
if (mapElevation != elevation)
|
||||
|
|
@ -7761,12 +7761,12 @@ void ObjectEventUpdateElevation(struct ObjectEvent *objEvent)
|
|||
u8 curElevation = MapGridGetElevationAt(objEvent->currentCoords.x, objEvent->currentCoords.y);
|
||||
u8 prevElevation = MapGridGetElevationAt(objEvent->previousCoords.x, objEvent->previousCoords.y);
|
||||
|
||||
if (curElevation == 15 || prevElevation == 15)
|
||||
if (curElevation == ELEVATION_MULTI_LEVEL || prevElevation == ELEVATION_MULTI_LEVEL)
|
||||
return;
|
||||
|
||||
objEvent->currentElevation = curElevation;
|
||||
|
||||
if (curElevation != 0 && curElevation != 15)
|
||||
if (curElevation != ELEVATION_TRANSITION && curElevation != ELEVATION_MULTI_LEVEL)
|
||||
objEvent->previousElevation = curElevation;
|
||||
}
|
||||
|
||||
|
|
@ -7790,7 +7790,7 @@ static void ObjectEventUpdateSubpriority(struct ObjectEvent *objEvent, struct Sp
|
|||
|
||||
static bool8 AreElevationsCompatible(u8 a, u8 b)
|
||||
{
|
||||
if (a == 0 || b == 0)
|
||||
if (a == ELEVATION_TRANSITION || b == ELEVATION_TRANSITION)
|
||||
return TRUE;
|
||||
|
||||
if (a != b)
|
||||
|
|
|
|||
|
|
@ -203,10 +203,10 @@ static void GetInFrontOfPlayerPosition(struct MapPosition *position)
|
|||
|
||||
GetXYCoordsOneStepInFrontOfPlayer(&position->x, &position->y);
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
if (MapGridGetElevationAt(x, y) != 0)
|
||||
if (MapGridGetElevationAt(x, y) != ELEVATION_TRANSITION)
|
||||
position->elevation = PlayerGetElevation();
|
||||
else
|
||||
position->elevation = 0;
|
||||
position->elevation = ELEVATION_TRANSITION;
|
||||
}
|
||||
|
||||
static u16 GetPlayerCurMetatileBehavior(int runningState)
|
||||
|
|
@ -867,7 +867,7 @@ static s8 GetWarpEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 e
|
|||
{
|
||||
if ((u16)warpEvent->x == x && (u16)warpEvent->y == y)
|
||||
{
|
||||
if (warpEvent->elevation == elevation || warpEvent->elevation == 0)
|
||||
if (warpEvent->elevation == elevation || warpEvent->elevation == ELEVATION_TRANSITION)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
|
@ -904,7 +904,7 @@ static const u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16
|
|||
{
|
||||
if ((u16)coordEvents[i].x == x && (u16)coordEvents[i].y == y)
|
||||
{
|
||||
if (coordEvents[i].elevation == elevation || coordEvents[i].elevation == 0)
|
||||
if (coordEvents[i].elevation == elevation || coordEvents[i].elevation == ELEVATION_TRANSITION)
|
||||
{
|
||||
const u8 *script = TryRunCoordEventScript(&coordEvents[i]);
|
||||
if (script != NULL)
|
||||
|
|
@ -930,7 +930,7 @@ static const struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *mapH
|
|||
{
|
||||
if ((u16)bgEvents[i].x == x && (u16)bgEvents[i].y == y)
|
||||
{
|
||||
if (bgEvents[i].elevation == elevation || bgEvents[i].elevation == 0)
|
||||
if (bgEvents[i].elevation == elevation || bgEvents[i].elevation == ELEVATION_TRANSITION)
|
||||
return &bgEvents[i];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1094,7 +1094,7 @@ void SynchronizeSurfPosition(struct ObjectEvent *playerObj, struct Sprite *sprit
|
|||
for (i = DIR_SOUTH; i <= DIR_EAST; i++, x = sprite->sPrevX, y = sprite->sPrevY)
|
||||
{
|
||||
MoveCoords(i, &x, &y);
|
||||
if (MapGridGetElevationAt(x, y) == 3)
|
||||
if (MapGridGetElevationAt(x, y) == ELEVATION_DEFAULT)
|
||||
{
|
||||
// While dismounting the surf blob bobs at a slower rate
|
||||
sprite->sIntervalIdx++;
|
||||
|
|
|
|||
|
|
@ -729,8 +729,8 @@ static u8 CheckForObjectEventStaticCollision(struct ObjectEvent *objectEvent, s1
|
|||
static bool8 CanStopSurfing(s16 x, s16 y, u8 direction)
|
||||
{
|
||||
if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
|
||||
&& MapGridGetElevationAt(x, y) == 3
|
||||
&& GetObjectEventIdByPosition(x, y, 3) == OBJECT_EVENTS_COUNT)
|
||||
&& MapGridGetElevationAt(x, y) == ELEVATION_DEFAULT
|
||||
&& GetObjectEventIdByPosition(x, y, ELEVATION_DEFAULT) == OBJECT_EVENTS_COUNT)
|
||||
{
|
||||
CreateStopSurfingTask(direction);
|
||||
return TRUE;
|
||||
|
|
@ -1327,7 +1327,7 @@ bool8 IsPlayerFacingSurfableFishableWater(void)
|
|||
|
||||
MoveCoords(playerObjEvent->facingDirection, &x, &y);
|
||||
if (GetCollisionAtCoords(playerObjEvent, x, y, playerObjEvent->facingDirection) == COLLISION_ELEVATION_MISMATCH
|
||||
&& PlayerGetElevation() == 3
|
||||
&& PlayerGetElevation() == ELEVATION_DEFAULT
|
||||
&& MetatileBehavior_IsSurfableFishableWater(MapGridGetMetatileBehaviorAt(x, y)))
|
||||
return TRUE;
|
||||
else
|
||||
|
|
@ -1388,7 +1388,7 @@ void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender)
|
|||
playerObjEventTemplate.graphicsId = GetPlayerAvatarGraphicsIdByStateIdAndGender(PLAYER_AVATAR_STATE_NORMAL, gender);
|
||||
playerObjEventTemplate.x = x - MAP_OFFSET;
|
||||
playerObjEventTemplate.y = y - MAP_OFFSET;
|
||||
playerObjEventTemplate.elevation = 0;
|
||||
playerObjEventTemplate.elevation = ELEVATION_TRANSITION;
|
||||
playerObjEventTemplate.movementType = MOVEMENT_TYPE_PLAYER;
|
||||
playerObjEventTemplate.movementRangeX = 0;
|
||||
playerObjEventTemplate.movementRangeY = 0;
|
||||
|
|
|
|||
|
|
@ -1255,7 +1255,7 @@ void SpawnCameraObject(void)
|
|||
LOCALID_CAMERA,
|
||||
gSaveBlock1Ptr->pos.x + MAP_OFFSET,
|
||||
gSaveBlock1Ptr->pos.y + MAP_OFFSET,
|
||||
3); // elevation
|
||||
ELEVATION_DEFAULT);
|
||||
gObjectEvents[obj].invisible = TRUE;
|
||||
CameraObjectSetFollowedSpriteId(gObjectEvents[obj].spriteId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2753,7 +2753,7 @@ static const u8 *TryInteractWithPlayer(struct CableClubPlayer *player)
|
|||
otherPlayerPos = player->pos;
|
||||
otherPlayerPos.x += gDirectionToVectors[player->facing].x;
|
||||
otherPlayerPos.y += gDirectionToVectors[player->facing].y;
|
||||
otherPlayerPos.elevation = 0;
|
||||
otherPlayerPos.elevation = ELEVATION_TRANSITION;
|
||||
linkPlayerId = GetLinkPlayerIdAt(otherPlayerPos.x, otherPlayerPos.y);
|
||||
|
||||
if (linkPlayerId != MAX_LINK_PLAYERS)
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ static const u8 *const sModeStrings[NUM_TRAINER_HILL_MODES] =
|
|||
static const struct ObjectEventTemplate sTrainerObjectEventTemplate =
|
||||
{
|
||||
.graphicsId = OBJ_EVENT_GFX_RIVAL_BRENDAN_NORMAL,
|
||||
.elevation = 3,
|
||||
.elevation = ELEVATION_DEFAULT,
|
||||
.movementType = MOVEMENT_TYPE_LOOK_AROUND,
|
||||
.movementRangeX = 1,
|
||||
.movementRangeY = 1,
|
||||
|
|
@ -677,7 +677,7 @@ static u16 GetMapDataForFloor(u8 floorId, u32 x, u32 y, u32 floorWidth) // floor
|
|||
|
||||
impassable = (sHillData->floors[floorId].map.collisionData[y] >> (15 - x) & 1);
|
||||
metatileId = sHillData->floors[floorId].map.metatileData[floorWidth * y + x] + NUM_METATILES_IN_PRIMARY;
|
||||
elevation = PACK_ELEVATION(3);
|
||||
elevation = PACK_ELEVATION(ELEVATION_DEFAULT);
|
||||
|
||||
return PACK_COLLISION(impassable) | elevation | PACK_METATILE(metatileId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user