Z coord / height -> elevation

This commit is contained in:
GriffinR 2022-01-21 12:48:19 -05:00
parent fb81d9ad4a
commit 3d0326106e
16 changed files with 119 additions and 119 deletions

View File

@ -98,7 +98,7 @@ void ObjectEventClearHeldMovementIfActive(struct ObjectEvent *);
void TrySpawnObjectEvents(s16, s16);
u8 CreateObjectGraphicsSprite(u16, void (*)(struct Sprite *), s16 x, s16 y, u8 subpriority);
u8 TrySpawnObjectEvent(u8, u8, u8);
u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 localId, s16 x, s16 y, u8 z);
u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 localId, s16 x, s16 y, u8 elevation);
u8 SpawnSpecialObjectEvent(struct ObjectEventTemplate *);
void SetSpritePosToMapCoords(s16, s16, s16 *, s16 *);
void CameraObjectReset1(void);
@ -128,7 +128,7 @@ u8 GetCollisionAtCoords(struct ObjectEvent *, s16, s16, u32);
void MoveCoords(u8, s16 *, s16 *);
bool8 ObjectEventIsHeldMovementActive(struct ObjectEvent *);
u8 ObjectEventClearHeldMovementIfFinished(struct ObjectEvent *);
u8 GetObjectEventIdByXYZ(u16 x, u16 y, u8 z);
u8 GetObjectEventIdByPosition(u16 x, u16 y, u8 elevation);
void SetTrainerMovementType(struct ObjectEvent *objectEvent, u8 movementType);
u8 GetTrainerFacingDirectionMovementType(u8 direction);
const u8 *GetObjectEventScriptPointerByObjectEventId(u8 objectEventId);
@ -162,17 +162,15 @@ u8 ObjectEventCheckHeldMovementStatus(struct ObjectEvent *objectEvent);
u8 ObjectEventGetHeldMovementActionId(struct ObjectEvent *objectEvent);
void TryOverrideTemplateCoordsForObjectEvent(const struct ObjectEvent *objectEvent, u8 movementType);
void OverrideTemplateCoordsForObjectEvent(const struct ObjectEvent *objectEvent);
void ShiftStillObjectEventCoords(struct ObjectEvent *pObject);
void ObjectEventMoveDestCoords(struct ObjectEvent *pObject, u32 unk_19, s16 *pInt, s16 *pInt1);
void ShiftStillObjectEventCoords(struct ObjectEvent *objEvent);
void ObjectEventMoveDestCoords(struct ObjectEvent *objEvent, u32 direction, s16 *x, s16 *y);
u8 AddCameraObject(u8 linkedSpriteId);
void UpdateObjectEventsForCameraUpdate(s16 x, s16 y);
u8 GetWalkSlowMovementAction(u32);
u8 GetJumpMovementAction(u32);
bool8 AreZCoordsCompatible(u8, u8);
u8 ZCoordToPriority(u8);
void ObjectEventUpdateZCoord(struct ObjectEvent *pObject);
void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8);
bool8 IsZCoordMismatchAt(u8, s16, s16);
u8 ElevationToPriority(u8);
void ObjectEventUpdateElevation(struct ObjectEvent *objEvent);
void SetObjectSubpriorityByElevation(u8, struct Sprite *, u8);
void UnfreezeObjectEvent(struct ObjectEvent *);
u8 FindLockedObjectEventIndex(struct ObjectEvent *);
void SetAndStartSpriteAnim(struct Sprite *, u8, u8);
@ -413,7 +411,7 @@ u8 MovementType_Invisible_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementType_Invisible_Step1(struct ObjectEvent *, struct Sprite *);
u8 MovementType_Invisible_Step2(struct ObjectEvent *, struct Sprite *);
u8 CreateVirtualObject(u8 graphicsId, u8 virtualObjId, s16 x, s16 y, u8 z, u8 direction);
u8 CreateVirtualObject(u8 graphicsId, u8 virtualObjId, s16 x, s16 y, u8 elevation, u8 direction);
void TurnVirtualObject(u8 virtualObjId, u8 direction);
void SetVirtualObjectGraphics(u8 virtualObjId, u8 graphicsId);
void SetVirtualObjectInvisibility(u8 virtualObjId, bool32 invisible);

View File

@ -30,7 +30,7 @@ void PlayerSetAnimId(u8 a, u8 b);
bool8 IsPlayerCollidingWithFarawayIslandMew(u8 direction);
void PlayerOnBikeCollideWithFarawayIslandMew(u8 direction);
u8 CheckForObjectEventCollision(struct ObjectEvent *a, s16 b, s16 c, u8 d, u8 e);
u8 PlayerGetZCoord(void);
u8 PlayerGetElevation(void);
void SetPlayerAvatarTransitionFlags(u16 a);
void CancelPlayerForcedMovement(void);
void InitPlayerAvatar(s16 a, s16 b, u8 c, u8 d);

View File

@ -32,7 +32,7 @@ bool32 CanCameraMoveInDirection(int direction);
u16 GetMetatileAttributesById(u16 metatileId);
void GetCameraFocusCoords(u16 *x, u16 *y);
u8 MapGridGetMetatileLayerTypeAt(int x, int y);
u8 MapGridGetZCoordAt(int x, int y);
u8 MapGridGetElevationAt(int x, int y);
bool8 CameraMove(int deltaX, int deltaY);
void SaveMapView(void);
void SetCameraFocusCoords(u16 x, u16 y);

View File

@ -1022,7 +1022,7 @@ struct MapPosition
{
s16 x;
s16 y;
s8 height;
s8 elevation;
};
#endif // GUARD_GLOBAL_H

View File

@ -900,7 +900,7 @@ static bool8 IsRunningDisallowedByMetatile(u8 tile)
{
if (MetatileBehavior_IsRunningDisallowed(tile))
return TRUE;
if (MetatileBehavior_IsFortreeBridge(tile) && (PlayerGetZCoord() & 1) == 0)
if (MetatileBehavior_IsFortreeBridge(tile) && (PlayerGetElevation() & 1) == 0)
return TRUE;
return FALSE;
}

View File

@ -1534,7 +1534,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
if (!IsntInitialPosition(taskId, curX, curY, layerType))
return FALSE;
behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0);
behaviorAt = GetObjectEventIdByPosition(curX, curY, 0);
if (behaviorAt != 0 && behaviorAt != OBJECT_EVENTS_COUNT)
return FALSE;
}
@ -1555,7 +1555,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
if (!IsntInitialPosition(taskId, curX, curY, layerType))
return FALSE;
if (GetObjectEventIdByXYZ(curX, curY, 0) != OBJECT_EVENTS_COUNT)
if (GetObjectEventIdByPosition(curX, curY, 0) != OBJECT_EVENTS_COUNT)
return FALSE;
}
}
@ -1572,7 +1572,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
if (!IsntInitialPosition(taskId, curX, curY, layerType))
return FALSE;
behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0);
behaviorAt = GetObjectEventIdByPosition(curX, curY, 0);
if (behaviorAt != 0 && behaviorAt != OBJECT_EVENTS_COUNT)
return FALSE;
}
@ -1609,7 +1609,7 @@ static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration)
return FALSE;
}
if (GetObjectEventIdByXYZ(curX, curY, 0) != OBJECT_EVENTS_COUNT)
if (GetObjectEventIdByPosition(curX, curY, 0) != OBJECT_EVENTS_COUNT)
return FALSE;
}
break;

View File

@ -110,7 +110,7 @@ static void GetGroundEffectFlags_Seaweed(struct ObjectEvent*, u32*);
static void GetGroundEffectFlags_JumpLanding(struct ObjectEvent*, u32*);
static u8 ObjectEventGetNearbyReflectionType(struct ObjectEvent*);
static u8 GetReflectionTypeByMetatileBehavior(u32);
static void InitObjectPriorityByZCoord(struct Sprite *sprite, u8 z);
static void InitObjectPriorityByElevation(struct Sprite *, u8);
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);
@ -142,27 +142,29 @@ static void ResetObjectEventFldEffData(struct ObjectEvent *);
static u8 LoadSpritePaletteIfTagExists(const struct SpritePalette *);
static u8 FindObjectEventPaletteIndexByTag(u16);
static void _PatchObjectPalette(u16, u8);
static bool8 ObjectEventDoesZCoordMatch(struct ObjectEvent *, u8);
static bool8 ObjectEventDoesElevationMatch(struct ObjectEvent *, u8);
static void SpriteCB_CameraObject(struct Sprite *);
static void CameraObject_0(struct Sprite *);
static void CameraObject_1(struct Sprite *);
static void CameraObject_2(struct Sprite *);
static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8 localId, struct ObjectEventTemplate *templates, u8 count);
static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8, struct ObjectEventTemplate *, u8);
static void ClearObjectEventMovement(struct ObjectEvent *, struct Sprite *);
static void ObjectEventSetSingleMovement(struct ObjectEvent *, struct Sprite *, u8);
static void SetSpriteDataForNormalStep(struct Sprite *, u8, u8);
static void InitSpriteForFigure8Anim(struct Sprite *sprite);
static bool8 AnimateSpriteInFigure8(struct Sprite *sprite);
static void InitSpriteForFigure8Anim(struct Sprite *);
static bool8 AnimateSpriteInFigure8(struct Sprite *);
static void SpriteCB_VirtualObject(struct Sprite *);
static void DoShadowFieldEffect(struct ObjectEvent *);
static void SetJumpSpriteData(struct Sprite *, u8, u8, u8);
static void SetWalkSlowSpriteData(struct Sprite *sprite, u8 direction);
static bool8 UpdateWalkSlowAnim(struct Sprite *sprite);
static u8 DoJumpSpriteMovement(struct Sprite *sprite);
static u8 DoJumpSpecialSpriteMovement(struct Sprite *sprite);
static void SetWalkSlowSpriteData(struct Sprite *, u8);
static bool8 UpdateWalkSlowAnim(struct Sprite *);
static u8 DoJumpSpriteMovement(struct Sprite *);
static u8 DoJumpSpecialSpriteMovement(struct Sprite *);
static void CreateLevitateMovementTask(struct ObjectEvent *);
static void DestroyLevitateMovementTask(u8);
static bool8 NpcTakeStep(struct Sprite *sprite);
static bool8 NpcTakeStep(struct Sprite *);
static bool8 IsElevationMismatchAt(u8, s16, s16);
static bool8 AreElevationsCompatible(u8 a, u8 b);
static const struct SpriteFrameImage sPicTable_PechaBerryTree[];
@ -1433,7 +1435,7 @@ static u8 TrySetupObjectEventSprite(struct ObjectEventTemplate *objectEventTempl
if (!objectEvent->inanimate)
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(objectEvent->facingDirection));
SetObjectSubpriorityByZCoord(objectEvent->previousElevation, sprite, 1);
SetObjectSubpriorityByElevation(objectEvent->previousElevation, sprite, 1);
UpdateObjectEventVisibility(objectEvent, sprite);
return objectEventId;
}
@ -1470,7 +1472,7 @@ u8 SpawnSpecialObjectEvent(struct ObjectEventTemplate *objectEventTemplate)
return TrySpawnObjectEventTemplate(objectEventTemplate, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, cameraX, cameraY);
}
u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 localId, s16 x, s16 y, u8 z)
u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 localId, s16 x, s16 y, u8 elevation)
{
struct ObjectEventTemplate objectEventTemplate;
@ -1481,7 +1483,7 @@ u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 l
objectEventTemplate.inConnection = 0;
objectEventTemplate.x = x;
objectEventTemplate.y = y;
objectEventTemplate.elevation = z;
objectEventTemplate.elevation = elevation;
objectEventTemplate.movementType = movementBehavior;
objectEventTemplate.movementRangeX = 0;
objectEventTemplate.movementRangeY = 0;
@ -1560,7 +1562,7 @@ u8 CreateObjectGraphicsSprite(u16 graphicsId, void (*callback)(struct Sprite *),
// 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.
u8 CreateVirtualObject(u8 graphicsId, u8 virtualObjId, s16 x, s16 y, u8 z, u8 direction)
u8 CreateVirtualObject(u8 graphicsId, u8 virtualObjId, s16 x, s16 y, u8 elevation, u8 direction)
{
u8 spriteId;
struct Sprite *sprite;
@ -1587,7 +1589,7 @@ u8 CreateVirtualObject(u8 graphicsId, u8 virtualObjId, s16 x, s16 y, u8 z, u8 di
sprite->coordOffsetEnabled = TRUE;
sprite->sVirtualObjId = virtualObjId;
sprite->sVirtualObjElev = z;
sprite->sVirtualObjElev = elevation;
if (graphicsInfo->paletteSlot == 10)
LoadSpecialObjectReflectionPalette(graphicsInfo->paletteTag, graphicsInfo->paletteSlot);
else if (graphicsInfo->paletteSlot >= 16)
@ -1598,8 +1600,8 @@ u8 CreateVirtualObject(u8 graphicsId, u8 virtualObjId, s16 x, s16 y, u8 z, u8 di
SetSubspriteTables(sprite, subspriteTables);
sprite->subspriteMode = SUBSPRITES_IGNORE_PRIORITY;
}
InitObjectPriorityByZCoord(sprite, z);
SetObjectSubpriorityByZCoord(z, sprite, 1);
InitObjectPriorityByElevation(sprite, elevation);
SetObjectSubpriorityByElevation(elevation, sprite, 1);
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(direction));
}
return spriteId;
@ -1755,7 +1757,7 @@ static void SpawnObjectEventOnReturnToField(u8 objectEventId, s16 x, s16 y)
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(objectEvent->facingDirection));
ResetObjectEventFldEffData(objectEvent);
SetObjectSubpriorityByZCoord(objectEvent->previousElevation, sprite, 1);
SetObjectSubpriorityByElevation(objectEvent->previousElevation, sprite, 1);
}
}
@ -2148,7 +2150,7 @@ void UpdateObjectEventCoordsForCameraUpdate(void)
}
}
u8 GetObjectEventIdByXYZ(u16 x, u16 y, u8 z)
u8 GetObjectEventIdByPosition(u16 x, u16 y, u8 elevation)
{
u8 i;
@ -2156,16 +2158,18 @@ u8 GetObjectEventIdByXYZ(u16 x, u16 y, u8 z)
{
if (gObjectEvents[i].active)
{
if (gObjectEvents[i].currentCoords.x == x && gObjectEvents[i].currentCoords.y == y && ObjectEventDoesZCoordMatch(&gObjectEvents[i], z))
if (gObjectEvents[i].currentCoords.x == x
&& gObjectEvents[i].currentCoords.y == y
&& ObjectEventDoesElevationMatch(&gObjectEvents[i], elevation))
return i;
}
}
return OBJECT_EVENTS_COUNT;
}
static bool8 ObjectEventDoesZCoordMatch(struct ObjectEvent *objectEvent, u8 z)
static bool8 ObjectEventDoesElevationMatch(struct ObjectEvent *objectEvent, u8 elevation)
{
if (objectEvent->currentElevation != 0 && z != 0 && objectEvent->currentElevation != z)
if (objectEvent->currentElevation != 0 && elevation != 0 && objectEvent->currentElevation != elevation)
return FALSE;
return TRUE;
@ -4630,7 +4634,7 @@ u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir)
return COLLISION_IMPASSABLE;
else if (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction))
return COLLISION_IMPASSABLE;
else if (IsZCoordMismatchAt(objectEvent->currentElevation, x, y))
else if (IsElevationMismatchAt(objectEvent->currentElevation, x, y))
return COLLISION_ELEVATION_MISMATCH;
else if (DoesObjectCollideWithObjectAt(objectEvent, x, y))
return COLLISION_OBJECT_EVENT;
@ -4645,7 +4649,7 @@ u8 GetCollisionFlagsAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 d
flags |= 1;
if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)))
flags |= 2;
if (IsZCoordMismatchAt(objectEvent->currentElevation, x, y))
if (IsElevationMismatchAt(objectEvent->currentElevation, x, y))
flags |= 4;
if (DoesObjectCollideWithObjectAt(objectEvent, x, y))
flags |= 8;
@ -4699,7 +4703,7 @@ static bool8 DoesObjectCollideWithObjectAt(struct ObjectEvent *objectEvent, s16
{
if ((curObject->currentCoords.x == x && curObject->currentCoords.y == y) || (curObject->previousCoords.x == x && curObject->previousCoords.y == y))
{
if (AreZCoordsCompatible(objectEvent->currentElevation, curObject->currentElevation))
if (AreElevationsCompatible(objectEvent->currentElevation, curObject->currentElevation))
return TRUE;
}
}
@ -7667,23 +7671,23 @@ static void SetObjectEventSpriteOamTableForLongGrass(struct ObjectEvent *objEven
sprite->subspriteTableNum = 4;
if (ZCoordToPriority(objEvent->previousElevation) == 1)
if (ElevationToPriority(objEvent->previousElevation) == 1)
sprite->subspriteTableNum = 5;
}
bool8 IsZCoordMismatchAt(u8 z, s16 x, s16 y)
static bool8 IsElevationMismatchAt(u8 elevation, s16 x, s16 y)
{
u8 mapZ;
u8 mapElevation;
if (z == 0)
if (elevation == 0)
return FALSE;
mapZ = MapGridGetZCoordAt(x, y);
mapElevation = MapGridGetElevationAt(x, y);
if (mapZ == 0 || mapZ == 15)
if (mapElevation == 0 || mapElevation == 15)
return FALSE;
if (mapZ != z)
if (mapElevation != elevation)
return TRUE;
return FALSE;
@ -7701,43 +7705,43 @@ static const u8 sElevationToSubspriteTableNum[] = {
1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 0, 1,
};
void UpdateObjectEventZCoordAndPriority(struct ObjectEvent *objEvent, struct Sprite *sprite)
static void UpdateObjectEventElevationAndPriority(struct ObjectEvent *objEvent, struct Sprite *sprite)
{
if (objEvent->fixedPriority)
return;
ObjectEventUpdateZCoord(objEvent);
ObjectEventUpdateElevation(objEvent);
sprite->subspriteTableNum = sElevationToSubspriteTableNum[objEvent->previousElevation];
sprite->oam.priority = sElevationToPriority[objEvent->previousElevation];
}
static void InitObjectPriorityByZCoord(struct Sprite *sprite, u8 z)
static void InitObjectPriorityByElevation(struct Sprite *sprite, u8 elevation)
{
sprite->subspriteTableNum = sElevationToSubspriteTableNum[z];
sprite->oam.priority = sElevationToPriority[z];
sprite->subspriteTableNum = sElevationToSubspriteTableNum[elevation];
sprite->oam.priority = sElevationToPriority[elevation];
}
u8 ZCoordToPriority(u8 z)
u8 ElevationToPriority(u8 elevation)
{
return sElevationToPriority[z];
return sElevationToPriority[elevation];
}
void ObjectEventUpdateZCoord(struct ObjectEvent *objEvent)
void ObjectEventUpdateElevation(struct ObjectEvent *objEvent)
{
u8 z = MapGridGetZCoordAt(objEvent->currentCoords.x, objEvent->currentCoords.y);
u8 z2 = MapGridGetZCoordAt(objEvent->previousCoords.x, objEvent->previousCoords.y);
u8 curElevation = MapGridGetElevationAt(objEvent->currentCoords.x, objEvent->currentCoords.y);
u8 prevElevation = MapGridGetElevationAt(objEvent->previousCoords.x, objEvent->previousCoords.y);
if (z == 0xF || z2 == 0xF)
if (curElevation == 15 || prevElevation == 15)
return;
objEvent->currentElevation = z;
objEvent->currentElevation = curElevation;
if (z != 0 && z != 0xF)
objEvent->previousElevation = z;
if (curElevation != 0 && curElevation != 15)
objEvent->previousElevation = curElevation;
}
void SetObjectSubpriorityByZCoord(u8 elevation, struct Sprite *sprite, u8 subpriority)
void SetObjectSubpriorityByElevation(u8 elevation, struct Sprite *sprite, u8 subpriority)
{
s32 tmp = sprite->centerToCornerVecY;
u32 tmpa = *(u16 *)&sprite->y;
@ -7752,10 +7756,10 @@ static void ObjectEventUpdateSubpriority(struct ObjectEvent *objEvent, struct Sp
if (objEvent->fixedPriority)
return;
SetObjectSubpriorityByZCoord(objEvent->previousElevation, sprite, 1);
SetObjectSubpriorityByElevation(objEvent->previousElevation, sprite, 1);
}
bool8 AreZCoordsCompatible(u8 a, u8 b)
static bool8 AreElevationsCompatible(u8 a, u8 b)
{
if (a == 0 || b == 0)
return TRUE;
@ -8051,7 +8055,7 @@ static void DoGroundEffects_OnSpawn(struct ObjectEvent *objEvent, struct Sprite
if (objEvent->triggerGroundEffectsOnMove)
{
flags = 0;
UpdateObjectEventZCoordAndPriority(objEvent, sprite);
UpdateObjectEventElevationAndPriority(objEvent, sprite);
GetAllGroundEffectFlags_OnSpawn(objEvent, &flags);
SetObjectEventSpriteOamTableForLongGrass(objEvent, sprite);
DoFlaggedGroundEffects(objEvent, sprite, flags);
@ -8067,7 +8071,7 @@ static void DoGroundEffects_OnBeginStep(struct ObjectEvent *objEvent, struct Spr
if (objEvent->triggerGroundEffectsOnMove)
{
flags = 0;
UpdateObjectEventZCoordAndPriority(objEvent, sprite);
UpdateObjectEventElevationAndPriority(objEvent, sprite);
GetAllGroundEffectFlags_OnBeginStep(objEvent, &flags);
SetObjectEventSpriteOamTableForLongGrass(objEvent, sprite);
filters_out_some_ground_effects(objEvent, &flags);
@ -8084,7 +8088,7 @@ static void DoGroundEffects_OnFinishStep(struct ObjectEvent *objEvent, struct Sp
if (objEvent->triggerGroundEffectsOnStop)
{
flags = 0;
UpdateObjectEventZCoordAndPriority(objEvent, sprite);
UpdateObjectEventElevationAndPriority(objEvent, sprite);
GetAllGroundEffectFlags_OnFinishStep(objEvent, &flags);
SetObjectEventSpriteOamTableForLongGrass(objEvent, sprite);
FilterOutStepOnPuddleGroundEffectIfJumping(objEvent, &flags);
@ -8548,7 +8552,7 @@ void UpdateObjectEventSpriteInvisibility(struct Sprite *sprite, bool8 invisible)
static void SpriteCB_VirtualObject(struct Sprite *sprite)
{
VirtualObject_UpdateAnim(sprite);
SetObjectSubpriorityByZCoord(sprite->sVirtualObjElev, sprite, 1);
SetObjectSubpriorityByElevation(sprite->sVirtualObjElev, sprite, 1);
UpdateObjectEventSpriteInvisibility(sprite, sprite->sInvisible);
}

View File

@ -194,7 +194,7 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
static void GetPlayerPosition(struct MapPosition *position)
{
PlayerGetDestCoords(&position->x, &position->y);
position->height = PlayerGetZCoord();
position->elevation = PlayerGetElevation();
}
static void GetInFrontOfPlayerPosition(struct MapPosition *position)
@ -203,10 +203,10 @@ static void GetInFrontOfPlayerPosition(struct MapPosition *position)
GetXYCoordsOneStepInFrontOfPlayer(&position->x, &position->y);
PlayerGetDestCoords(&x, &y);
if (MapGridGetZCoordAt(x, y) != 0)
position->height = PlayerGetZCoord();
if (MapGridGetElevationAt(x, y) != 0)
position->elevation = PlayerGetElevation();
else
position->height = 0;
position->elevation = 0;
}
static u16 GetPlayerCurMetatileBehavior(int runningState)
@ -264,9 +264,9 @@ const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatil
s32 i;
if (!MetatileBehavior_IsCounter(MapGridGetMetatileBehaviorAt(position->x, position->y)))
objectEventId = GetObjectEventIdByXYZ(position->x, position->y, position->height);
objectEventId = GetObjectEventIdByPosition(position->x, position->y, position->elevation);
else
objectEventId = GetObjectEventIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height);
objectEventId = GetObjectEventIdByPosition(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->elevation);
if (objectEventId == OBJECT_EVENTS_COUNT || gObjectEvents[objectEventId].localId == OBJ_EVENT_ID_PLAYER)
return NULL;
@ -288,14 +288,14 @@ static const u8 *GetInteractedObjectEventScript(struct MapPosition *position, u8
u8 objectEventId;
const u8 *script;
objectEventId = GetObjectEventIdByXYZ(position->x, position->y, position->height);
objectEventId = GetObjectEventIdByPosition(position->x, position->y, position->elevation);
if (objectEventId == OBJECT_EVENTS_COUNT || gObjectEvents[objectEventId].localId == OBJ_EVENT_ID_PLAYER)
{
if (MetatileBehavior_IsCounter(metatileBehavior) != TRUE)
return NULL;
// Look for an object event on the other side of the counter.
objectEventId = GetObjectEventIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height);
objectEventId = GetObjectEventIdByPosition(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->elevation);
if (objectEventId == OBJECT_EVENTS_COUNT || gObjectEvents[objectEventId].localId == OBJ_EVENT_ID_PLAYER)
return NULL;
}
@ -315,7 +315,7 @@ static const u8 *GetInteractedObjectEventScript(struct MapPosition *position, u8
static const u8 *GetInteractedBackgroundEventScript(struct MapPosition *position, u8 metatileBehavior, u8 direction)
{
struct BgEvent *bgEvent = GetBackgroundEventAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->height);
struct BgEvent *bgEvent = GetBackgroundEventAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->elevation);
if (bgEvent == NULL)
return NULL;
@ -366,7 +366,7 @@ static const u8 *GetInteractedBackgroundEventScript(struct MapPosition *position
static const u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 metatileBehavior, u8 direction)
{
s8 height;
s8 elevation;
if (MetatileBehavior_IsPlayerFacingTVScreen(metatileBehavior, direction) == TRUE)
return EventScript_TV;
@ -409,8 +409,8 @@ static const u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 me
if (MetatileBehavior_IsTrainerHillTimer(metatileBehavior) == TRUE)
return EventScript_TrainerHillTimer;
height = position->height;
if (height == MapGridGetZCoordAt(position->x, position->y))
elevation = position->elevation;
if (elevation == MapGridGetElevationAt(position->x, position->y))
{
if (MetatileBehavior_IsSecretBasePC(metatileBehavior) == TRUE)
return SecretBase_EventScript_PC;
@ -497,7 +497,7 @@ static bool8 TryStartStepBasedScript(struct MapPosition *position, u16 metatileB
static bool8 TryStartCoordEventScript(struct MapPosition *position)
{
u8 *script = GetCoordEventScriptAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->height);
u8 *script = GetCoordEventScriptAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->elevation);
if (script == NULL)
return FALSE;
@ -783,7 +783,7 @@ static bool8 IsArrowWarpMetatileBehavior(u16 metatileBehavior, u8 direction)
static s8 GetWarpEventAtMapPosition(struct MapHeader *mapHeader, struct MapPosition *position)
{
return GetWarpEventAtPosition(mapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->height);
return GetWarpEventAtPosition(mapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->elevation);
}
static void SetupWarp(struct MapHeader *unused, s8 warpEventId, struct MapPosition *position)
@ -918,7 +918,7 @@ static u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16 x, u16
u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position)
{
return GetCoordEventScriptAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->height);
return GetCoordEventScriptAtPosition(&gMapHeader, position->x - MAP_OFFSET, position->y - MAP_OFFSET, position->elevation);
}
static struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation)

View File

@ -359,7 +359,7 @@ void UpdateTallGrassFieldEffect(struct Sprite *sprite)
|| objectEvent->previousCoords.y != sprite->sY))
sprite->sObjectMoved = TRUE;
// Metatile behavior var re-used
// Metatile behavior var re-used as subpriority
metatileBehavior = 0;
if (sprite->animCmdIndex == 0)
metatileBehavior = 4;
@ -423,7 +423,7 @@ u32 FldEff_LongGrass(void)
{
sprite = &gSprites[spriteId];
sprite->coordOffsetEnabled = TRUE;
sprite->oam.priority = ZCoordToPriority(gFieldEffectArguments[2]);
sprite->oam.priority = ElevationToPriority(gFieldEffectArguments[2]);
sprite->sElevation = gFieldEffectArguments[2];
sprite->sX = gFieldEffectArguments[0];
sprite->sY = gFieldEffectArguments[1];
@ -1108,7 +1108,7 @@ void SynchroniseSurfPosition(struct ObjectEvent *playerObj, struct Sprite *sprit
for (i = DIR_SOUTH; i <= DIR_EAST; i++, x = sprite->data[6], y = sprite->data[7])
{
MoveCoords(i, &x, &y);
if (MapGridGetZCoordAt(x, y) == 3)
if (MapGridGetElevationAt(x, y) == 3)
{
sprite->data[5]++;
break;
@ -1646,7 +1646,7 @@ void UpdateJumpImpactEffect(struct Sprite *sprite)
else
{
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
SetObjectSubpriorityByZCoord(sprite->sElevation, sprite, 0);
SetObjectSubpriorityByElevation(sprite->sElevation, sprite, 0);
}
}
@ -1658,14 +1658,14 @@ void WaitFieldEffectSpriteAnim(struct Sprite *sprite)
UpdateObjectEventSpriteInvisibility(sprite, FALSE);
}
static void UpdateGrassFieldEffectSubpriority(struct Sprite *sprite, u8 z, u8 offset)
static void UpdateGrassFieldEffectSubpriority(struct Sprite *sprite, u8 elevation, u8 subpriority)
{
u8 i;
s16 var, xhi, lyhi, yhi, ylo;
const struct ObjectEventGraphicsInfo *graphicsInfo; // Unused Variable
struct Sprite *linkedSprite;
SetObjectSubpriorityByZCoord(z, sprite, offset);
SetObjectSubpriorityByElevation(elevation, sprite, subpriority);
for (i = 0; i < OBJECT_EVENTS_COUNT; i ++)
{
struct ObjectEvent *objectEvent = &gObjectEvents[i];

View File

@ -708,8 +708,8 @@ static u8 CheckForObjectEventStaticCollision(struct ObjectEvent *objectEvent, s1
static bool8 CanStopSurfing(s16 x, s16 y, u8 direction)
{
if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
&& MapGridGetZCoordAt(x, y) == 3
&& GetObjectEventIdByXYZ(x, y, 3) == OBJECT_EVENTS_COUNT)
&& MapGridGetElevationAt(x, y) == 3
&& GetObjectEventIdByPosition(x, y, 3) == OBJECT_EVENTS_COUNT)
{
CreateStopSurfingTask(direction);
return TRUE;
@ -1168,7 +1168,7 @@ u8 GetPlayerMovementDirection(void)
return gObjectEvents[gPlayerAvatar.objectEventId].movementDirection;
}
u8 PlayerGetZCoord(void)
u8 PlayerGetElevation(void)
{
return gObjectEvents[gPlayerAvatar.objectEventId].previousElevation;
}
@ -1306,7 +1306,7 @@ bool8 IsPlayerFacingSurfableFishableWater(void)
MoveCoords(playerObjEvent->facingDirection, &x, &y);
if (GetCollisionAtCoords(playerObjEvent, x, y, playerObjEvent->facingDirection) == COLLISION_ELEVATION_MISMATCH
&& PlayerGetZCoord() == 3
&& PlayerGetElevation() == 3
&& MetatileBehavior_IsSurfableFishableWater(MapGridGetMetatileBehaviorAt(x, y)))
return TRUE;
else

View File

@ -445,8 +445,8 @@ static void PacifidlogBridgePerStepCallback(u8 taskId)
static void TryLowerFortreeBridge(s16 x, s16 y)
{
u8 z = PlayerGetZCoord();
if (!(z & 1))
u8 elevation = PlayerGetElevation();
if (!(elevation & 1))
{
switch (MapGridGetMetatileIdAt(x, y))
{
@ -462,8 +462,8 @@ static void TryLowerFortreeBridge(s16 x, s16 y)
static void TryRaiseFortreeBridge(s16 x, s16 y)
{
u8 z = PlayerGetZCoord();
if (!(z & 1))
u8 elevation = PlayerGetElevation();
if (!(elevation & 1))
{
switch (MapGridGetMetatileIdAt(x, y))
{
@ -488,7 +488,7 @@ static void FortreeBridgePerStepCallback(u8 taskId)
{
bool8 isFortreeBridgeCur;
bool8 isFortreeBridgePrev;
u8 z, onBridgeElevation;
u8 elevation, onBridgeElevation;
s16 x, y, prevX, prevY;
s16 *data = gTasks[taskId].data;
PlayerGetDestCoords(&x, &y);
@ -520,9 +520,9 @@ static void FortreeBridgePerStepCallback(u8 taskId)
isFortreeBridgePrev = MetatileBehavior_IsFortreeBridge(MapGridGetMetatileBehaviorAt(prevX, prevY));
// Make sure player isn't below bridge
z = PlayerGetZCoord();
elevation = PlayerGetElevation();
onBridgeElevation = FALSE;
if ((u8)(z & 1) == 0)
if ((u8)(elevation & 1) == 0)
onBridgeElevation = TRUE;
if (onBridgeElevation && (isFortreeBridgeCur == TRUE || isFortreeBridgePrev == TRUE))

View File

@ -342,7 +342,7 @@ static void FillEastConnection(struct MapHeader const *mapHeader, struct MapHead
}
}
u8 MapGridGetZCoordAt(int x, int y)
u8 MapGridGetElevationAt(int x, int y)
{
u16 block = GetMapGridBlockAt(x, y);

View File

@ -181,7 +181,7 @@ bool8 SetUpFieldMove_Cut(void)
for (j = 0; j < CUT_NORMAL_SIDE; j++)
{
x = j - 1 + gPlayerFacingPosition.x;
if (MapGridGetZCoordAt(x, y) == gPlayerFacingPosition.height)
if (MapGridGetElevationAt(x, y) == gPlayerFacingPosition.elevation)
{
tileBehavior = MapGridGetMetatileBehaviorAt(x, y);
if (MetatileBehavior_IsPokeGrass(tileBehavior) == TRUE
@ -238,7 +238,7 @@ bool8 SetUpFieldMove_Cut(void)
if (tileCuttable == TRUE)
{
if (MapGridGetZCoordAt(x, y) == gPlayerFacingPosition.height)
if (MapGridGetElevationAt(x, y) == gPlayerFacingPosition.elevation)
{
u8 tileArrayId = ((sHyperCutStruct[i].y * 5) + 12) + (sHyperCutStruct[i].x);
tileBehavior = MapGridGetMetatileBehaviorAt(x, y);

View File

@ -19,7 +19,6 @@
#include "constants/map_types.h"
#include "constants/songs.h"
// static functions
static void Task_DoFieldMove_Init(u8 taskId);
static void Task_DoFieldMove_ShowMonAfterPose(u8 taskId);
static void Task_DoFieldMove_WaitForMon(u8 taskId);
@ -28,14 +27,13 @@ static void Task_DoFieldMove_RunFunc(u8 taskId);
static void FieldCallback_RockSmash(void);
static void FieldMove_RockSmash(void);
// text
bool8 CheckObjectGraphicsInFrontOfPlayer(u8 graphicsId)
{
u8 objEventId;
GetXYCoordsOneStepInFrontOfPlayer(&gPlayerFacingPosition.x, &gPlayerFacingPosition.y);
gPlayerFacingPosition.height = PlayerGetZCoord();
objEventId = GetObjectEventIdByXYZ(gPlayerFacingPosition.x, gPlayerFacingPosition.y, gPlayerFacingPosition.height);
gPlayerFacingPosition.elevation = PlayerGetElevation();
objEventId = GetObjectEventIdByPosition(gPlayerFacingPosition.x, gPlayerFacingPosition.y, gPlayerFacingPosition.elevation);
if (gObjectEvents[objEventId].graphicsId != graphicsId)
{
return FALSE;

View File

@ -725,11 +725,11 @@ static void ItemUseOnFieldCB_WailmerPailBerry(u8 taskId)
static bool8 TryToWaterSudowoodo(void)
{
u16 x, y;
u8 z;
u8 elevation;
u8 objId;
GetXYCoordsOneStepInFrontOfPlayer(&x, &y);
z = PlayerGetZCoord();
objId = GetObjectEventIdByXYZ(x, y, z);
elevation = PlayerGetElevation();
objId = GetObjectEventIdByPosition(x, y, elevation);
if (objId == OBJECT_EVENTS_COUNT || gObjectEvents[objId].graphicsId != OBJ_EVENT_GFX_SUDOWOODO)
return FALSE;
else

View File

@ -2692,7 +2692,7 @@ static void LoadCableClubPlayer(s32 linkPlayerId, s32 myPlayerId, struct CableCl
GetLinkPlayerCoords(linkPlayerId, &x, &y);
trainer->pos.x = x;
trainer->pos.y = y;
trainer->pos.height = GetLinkPlayerElevation(linkPlayerId);
trainer->pos.elevation = GetLinkPlayerElevation(linkPlayerId);
trainer->metatileBehavior = MapGridGetMetatileBehaviorAt(x, y);
}
@ -2745,7 +2745,7 @@ static const u8 *TryInteractWithPlayer(struct CableClubPlayer *player)
otherPlayerPos = player->pos;
otherPlayerPos.x += gDirectionToVectors[player->facing].x;
otherPlayerPos.y += gDirectionToVectors[player->facing].y;
otherPlayerPos.height = 0;
otherPlayerPos.elevation = 0;
linkPlayerId = GetLinkPlayerIdAt(otherPlayerPos.x, otherPlayerPos.y);
if (linkPlayerId != MAX_LINK_PLAYERS)
@ -2955,7 +2955,7 @@ static void InitLinkPlayerObjectEventPos(struct ObjectEvent *objEvent, s16 x, s1
objEvent->previousCoords.y = y;
SetSpritePosToMapCoords(x, y, &objEvent->initialCoords.x, &objEvent->initialCoords.y);
objEvent->initialCoords.x += 8;
ObjectEventUpdateZCoord(objEvent);
ObjectEventUpdateElevation(objEvent);
}
static void SetLinkPlayerObjectRange(u8 linkPlayerId, u8 dir)
@ -3095,7 +3095,7 @@ static bool8 FacingHandler_DpadMovement(struct LinkPlayerObjectEvent *linkPlayer
{
objEvent->directionSequenceIndex = 16;
ShiftObjectEventCoords(objEvent, x, y);
ObjectEventUpdateZCoord(objEvent);
ObjectEventUpdateElevation(objEvent);
return TRUE;
}
}
@ -3201,8 +3201,8 @@ static void SpriteCB_LinkPlayer(struct Sprite *sprite)
struct ObjectEvent *objEvent = &gObjectEvents[linkPlayerObjEvent->objEventId];
sprite->x = objEvent->initialCoords.x;
sprite->y = objEvent->initialCoords.y;
SetObjectSubpriorityByZCoord(objEvent->previousElevation, sprite, 1);
sprite->oam.priority = ZCoordToPriority(objEvent->previousElevation);
SetObjectSubpriorityByElevation(objEvent->previousElevation, sprite, 1);
sprite->oam.priority = ElevationToPriority(objEvent->previousElevation);
if (linkPlayerObjEvent->movementMode == MOVEMENT_MODE_FREE)
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(linkDirection(objEvent)));