mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Add missing collision constant usage
This commit is contained in:
parent
e30b16f0fd
commit
1ff0b0efa9
@ -4630,7 +4630,7 @@ u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir)
|
||||
u8 direction = dir;
|
||||
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
|
||||
return COLLISION_OUTSIDE_RANGE;
|
||||
else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction))
|
||||
else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction))
|
||||
return COLLISION_IMPASSABLE;
|
||||
else if (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction))
|
||||
return COLLISION_IMPASSABLE;
|
||||
@ -4646,13 +4646,13 @@ u8 GetCollisionFlagsAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 d
|
||||
u8 flags = 0;
|
||||
|
||||
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
|
||||
flags |= 1;
|
||||
if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)))
|
||||
flags |= 2;
|
||||
flags |= 1 << (COLLISION_OUTSIDE_RANGE - 1);
|
||||
if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction) || (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)))
|
||||
flags |= 1 << (COLLISION_IMPASSABLE - 1);
|
||||
if (IsElevationMismatchAt(objectEvent->currentElevation, x, y))
|
||||
flags |= 4;
|
||||
flags |= 1 << (COLLISION_ELEVATION_MISMATCH - 1);
|
||||
if (DoesObjectCollideWithObjectAt(objectEvent, x, y))
|
||||
flags |= 8;
|
||||
flags |= 1 << (COLLISION_OBJECT_EVENT - 1);
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
@ -367,8 +367,6 @@ static u8 GetTrainerApproachDistanceEast(struct ObjectEvent *trainerObj, s16 ran
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define COLLISION_MASK (~1)
|
||||
|
||||
static u8 CheckPathBetweenTrainerAndPlayer(struct ObjectEvent *trainerObj, u8 approachDistance, u8 direction)
|
||||
{
|
||||
s16 x, y;
|
||||
@ -385,8 +383,9 @@ static u8 CheckPathBetweenTrainerAndPlayer(struct ObjectEvent *trainerObj, u8 ap
|
||||
MoveCoords(direction, &x, &y);
|
||||
for (i = 0; i < approachDistance - 1; i++, MoveCoords(direction, &x, &y))
|
||||
{
|
||||
// Check for collisions on approach, ignoring the "out of range" collision for regular movement
|
||||
collision = GetCollisionFlagsAtCoords(trainerObj, x, y, direction);
|
||||
if (collision != 0 && (collision & COLLISION_MASK))
|
||||
if (collision != 0 && (collision & ~(1 << (COLLISION_OUTSIDE_RANGE - 1))))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user