mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 11:44:17 +01:00
MapGridIsImpassableAt -> MapGridGetCollisionAt, and add fixes
This commit is contained in:
parent
5101811407
commit
e5c36cd745
@ -26,7 +26,7 @@ u32 MapGridGetMetatileBehaviorAt(int, int);
|
|||||||
void MapGridSetMetatileIdAt(int, int, u16);
|
void MapGridSetMetatileIdAt(int, int, u16);
|
||||||
void MapGridSetMetatileEntryAt(int, int, u16);
|
void MapGridSetMetatileEntryAt(int, int, u16);
|
||||||
void GetCameraCoords(u16 *, u16 *);
|
void GetCameraCoords(u16 *, u16 *);
|
||||||
bool8 MapGridIsImpassableAt(int, int);
|
u8 MapGridGetCollisionAt(int, int);
|
||||||
int GetMapBorderIdAt(int x, int y);
|
int GetMapBorderIdAt(int x, int y);
|
||||||
bool32 CanCameraMoveInDirection(int direction);
|
bool32 CanCameraMoveInDirection(int direction);
|
||||||
u16 GetMetatileAttributesById(u16 metatileId);
|
u16 GetMetatileAttributesById(u16 metatileId);
|
||||||
|
@ -4630,7 +4630,7 @@ u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir)
|
|||||||
u8 direction = dir;
|
u8 direction = dir;
|
||||||
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
|
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
|
||||||
return COLLISION_OUTSIDE_RANGE;
|
return COLLISION_OUTSIDE_RANGE;
|
||||||
else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction))
|
else if (MapGridGetCollisionAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction))
|
||||||
return COLLISION_IMPASSABLE;
|
return COLLISION_IMPASSABLE;
|
||||||
else if (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction))
|
else if (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction))
|
||||||
return COLLISION_IMPASSABLE;
|
return COLLISION_IMPASSABLE;
|
||||||
@ -4647,7 +4647,7 @@ u8 GetCollisionFlagsAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 d
|
|||||||
|
|
||||||
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
|
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
|
||||||
flags |= 1 << (COLLISION_OUTSIDE_RANGE - 1);
|
flags |= 1 << (COLLISION_OUTSIDE_RANGE - 1);
|
||||||
if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)))
|
if (MapGridGetCollisionAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)))
|
||||||
flags |= 1 << (COLLISION_IMPASSABLE - 1);
|
flags |= 1 << (COLLISION_IMPASSABLE - 1);
|
||||||
if (IsElevationMismatchAt(objectEvent->currentElevation, x, y))
|
if (IsElevationMismatchAt(objectEvent->currentElevation, x, y))
|
||||||
flags |= 1 << (COLLISION_ELEVATION_MISMATCH - 1);
|
flags |= 1 << (COLLISION_ELEVATION_MISMATCH - 1);
|
||||||
|
@ -352,7 +352,7 @@ u8 MapGridGetElevationAt(int x, int y)
|
|||||||
return block >> MAPGRID_ELEVATION_SHIFT;
|
return block >> MAPGRID_ELEVATION_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool8 MapGridIsImpassableAt(int x, int y)
|
u8 MapGridGetCollisionAt(int x, int y)
|
||||||
{
|
{
|
||||||
u16 block = GetMapGridBlockAt(x, y);
|
u16 block = GetMapGridBlockAt(x, y);
|
||||||
|
|
||||||
|
@ -191,7 +191,12 @@ bool8 SetUpFieldMove_Cut(void)
|
|||||||
sHyperCutTiles[6 + (i * 5) + j] = TRUE;
|
sHyperCutTiles[6 + (i * 5) + j] = TRUE;
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
}
|
}
|
||||||
if (MapGridIsImpassableAt(x, y) == TRUE)
|
#ifdef BUGFIX
|
||||||
|
// Collision has a range 0-3, any value != 0 is impassable
|
||||||
|
if (MapGridGetCollisionAt(x, y))
|
||||||
|
#else
|
||||||
|
if (MapGridGetCollisionAt(x, y) == 1)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
cutTiles[i * 3 + j] = FALSE;
|
cutTiles[i * 3 + j] = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ static bool32 CanFish(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior) && !MapGridIsImpassableAt(x, y))
|
if (MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior) && MapGridGetCollisionAt(x, y) == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
if (MetatileBehavior_IsBridgeOverWaterNoEdge(tileBehavior) == TRUE)
|
if (MetatileBehavior_IsBridgeOverWaterNoEdge(tileBehavior) == TRUE)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -129,7 +129,7 @@ static void ResetAllPlayerLinkStates(void);
|
|||||||
static void UpdateHeldKeyCode(u16);
|
static void UpdateHeldKeyCode(u16);
|
||||||
static void UpdateAllLinkPlayers(u16 *, s32);
|
static void UpdateAllLinkPlayers(u16 *, s32);
|
||||||
static u8 FlipVerticalAndClearForced(u8, u8);
|
static u8 FlipVerticalAndClearForced(u8, u8);
|
||||||
static u8 LinkPlayerDetectCollision(u8, u8, s16, s16);
|
static u8 LinkPlayerGetCollision(u8, u8, s16, s16);
|
||||||
static void CreateLinkPlayerSprite(u8, u8);
|
static void CreateLinkPlayerSprite(u8, u8);
|
||||||
static void GetLinkPlayerCoords(u8, u16 *, u16 *);
|
static void GetLinkPlayerCoords(u8, u16 *, u16 *);
|
||||||
static u8 GetLinkPlayerFacingDirection(u8);
|
static u8 GetLinkPlayerFacingDirection(u8);
|
||||||
@ -3087,7 +3087,7 @@ static bool8 FacingHandler_DpadMovement(struct LinkPlayerObjectEvent *linkPlayer
|
|||||||
linkDirection(objEvent) = FlipVerticalAndClearForced(dir, linkDirection(objEvent));
|
linkDirection(objEvent) = FlipVerticalAndClearForced(dir, linkDirection(objEvent));
|
||||||
ObjectEventMoveDestCoords(objEvent, linkDirection(objEvent), &x, &y);
|
ObjectEventMoveDestCoords(objEvent, linkDirection(objEvent), &x, &y);
|
||||||
|
|
||||||
if (LinkPlayerDetectCollision(linkPlayerObjEvent->objEventId, linkDirection(objEvent), x, y))
|
if (LinkPlayerGetCollision(linkPlayerObjEvent->objEventId, linkDirection(objEvent), x, y))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -3147,7 +3147,7 @@ static u8 FlipVerticalAndClearForced(u8 newFacing, u8 oldFacing)
|
|||||||
return oldFacing;
|
return oldFacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool8 LinkPlayerDetectCollision(u8 selfObjEventId, u8 direction, s16 x, s16 y)
|
static u8 LinkPlayerGetCollision(u8 selfObjEventId, u8 direction, s16 x, s16 y)
|
||||||
{
|
{
|
||||||
u8 i;
|
u8 i;
|
||||||
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
||||||
@ -3157,11 +3157,11 @@ static bool8 LinkPlayerDetectCollision(u8 selfObjEventId, u8 direction, s16 x, s
|
|||||||
if ((gObjectEvents[i].currentCoords.x == x && gObjectEvents[i].currentCoords.y == y)
|
if ((gObjectEvents[i].currentCoords.x == x && gObjectEvents[i].currentCoords.y == y)
|
||||||
|| (gObjectEvents[i].previousCoords.x == x && gObjectEvents[i].previousCoords.y == y))
|
|| (gObjectEvents[i].previousCoords.x == x && gObjectEvents[i].previousCoords.y == y))
|
||||||
{
|
{
|
||||||
return TRUE;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return MapGridIsImpassableAt(x, y);
|
return MapGridGetCollisionAt(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion)
|
static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion)
|
||||||
|
@ -874,7 +874,12 @@ static s32 RotatingGate_CanRotate(u8 gateId, s32 rotationDirection)
|
|||||||
|
|
||||||
if (sRotatingGate_ArmLayout[shape][2 * i + j])
|
if (sRotatingGate_ArmLayout[shape][2 * i + j])
|
||||||
{
|
{
|
||||||
if (MapGridIsImpassableAt(x + armPos[armIndex].x, y + armPos[armIndex].y) == TRUE)
|
#ifdef BUGFIX
|
||||||
|
// Collision has a range 0-3, any value != 0 is impassable
|
||||||
|
if (MapGridGetCollisionAt(x + armPos[armIndex].x, y + armPos[armIndex].y))
|
||||||
|
#else
|
||||||
|
if (MapGridGetCollisionAt(x + armPos[armIndex].x, y + armPos[armIndex].y) == 1)
|
||||||
|
#endif
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user