Document collision types
This commit is contained in:
@@ -259,7 +259,20 @@ enum
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
COLLISION_LEDGE_JUMP = 6
|
COLLISION_NONE,
|
||||||
|
COLLISION_OUTSIDE_RANGE,
|
||||||
|
COLLISION_IMPASSABLE,
|
||||||
|
COLLISION_ELEVATION_MISMATCH,
|
||||||
|
COLLISION_EVENT_OBJECT,
|
||||||
|
COLLISION_STOP_SURFING,
|
||||||
|
COLLISION_LEDGE_JUMP,
|
||||||
|
COLLISION_PUSHED_BOULDER,
|
||||||
|
COLLISION_ROTATING_GATE,
|
||||||
|
COLLISION_WHEELIE_HOP,
|
||||||
|
COLLISION_ISOLATED_VERTICAL_RAIL,
|
||||||
|
COLLISION_ISOLATED_HORIZONTAL_RAIL,
|
||||||
|
COLLISION_VERTICAL_RAIL,
|
||||||
|
COLLISION_HORIZONTAL_RAIL,
|
||||||
};
|
};
|
||||||
|
|
||||||
// player running states
|
// player running states
|
||||||
|
|||||||
+47
-50
@@ -45,8 +45,8 @@ static u8 AcroBike_GetJumpDirection(void);
|
|||||||
static void Bike_UpdateDirTimerHistory(u8);
|
static void Bike_UpdateDirTimerHistory(u8);
|
||||||
static void Bike_UpdateABStartSelectHistory(u8);
|
static void Bike_UpdateABStartSelectHistory(u8);
|
||||||
static u8 Bike_DPadToDirection(u16);
|
static u8 Bike_DPadToDirection(u16);
|
||||||
static u8 get_some_collision(u8);
|
static u8 GetBikeCollision(u8);
|
||||||
static u8 Bike_CheckCollisionTryAdvanceCollisionCount(struct EventObject *, s16, s16, u8, u8);
|
static u8 GetBikeCollisionAt(struct EventObject *, s16, s16, u8, u8);
|
||||||
static bool8 IsRunningDisallowedByMetatile(u8);
|
static bool8 IsRunningDisallowedByMetatile(u8);
|
||||||
static void Bike_TryAdvanceCyclingRoadCollisions();
|
static void Bike_TryAdvanceCyclingRoadCollisions();
|
||||||
static u8 CanBikeFaceDirOnMetatile(u8, u8);
|
static u8 CanBikeFaceDirOnMetatile(u8, u8);
|
||||||
@@ -214,8 +214,8 @@ static void MachBikeTransition_TrySpeedUp(u8 direction)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
collision = get_some_collision(direction);
|
collision = GetBikeCollision(direction);
|
||||||
if (collision > 0 && collision < 12)
|
if (collision > 0 && collision < COLLISION_VERTICAL_RAIL)
|
||||||
{
|
{
|
||||||
// we hit a solid object, but check to see if its a ledge and then jump.
|
// we hit a solid object, but check to see if its a ledge and then jump.
|
||||||
if (collision == COLLISION_LEDGE_JUMP)
|
if (collision == COLLISION_LEDGE_JUMP)
|
||||||
@@ -226,9 +226,9 @@ static void MachBikeTransition_TrySpeedUp(u8 direction)
|
|||||||
{
|
{
|
||||||
// we hit a solid object that is not a ledge, so perform the collision.
|
// we hit a solid object that is not a ledge, so perform the collision.
|
||||||
Bike_SetBikeStill();
|
Bike_SetBikeStill();
|
||||||
if (collision == 4 && IsPlayerCollidingWithFarawayIslandMew(direction))
|
if (collision == COLLISION_EVENT_OBJECT && IsPlayerCollidingWithFarawayIslandMew(direction))
|
||||||
PlayerOnBikeCollideWithFarawayIslandMew(direction);
|
PlayerOnBikeCollideWithFarawayIslandMew(direction);
|
||||||
else if (collision < 5 || collision > 8)
|
else if (collision < COLLISION_STOP_SURFING || collision > COLLISION_ROTATING_GATE)
|
||||||
PlayerOnBikeCollide(direction);
|
PlayerOnBikeCollide(direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,9 +250,9 @@ static void MachBikeTransition_TrySlowDown(u8 direction)
|
|||||||
if (gPlayerAvatar.bikeSpeed != SPEED_STANDING)
|
if (gPlayerAvatar.bikeSpeed != SPEED_STANDING)
|
||||||
gPlayerAvatar.bikeFrameCounter = --gPlayerAvatar.bikeSpeed;
|
gPlayerAvatar.bikeFrameCounter = --gPlayerAvatar.bikeSpeed;
|
||||||
|
|
||||||
collision = get_some_collision(direction);
|
collision = GetBikeCollision(direction);
|
||||||
|
|
||||||
if (collision > 0 && collision < 12)
|
if (collision > 0 && collision < COLLISION_VERTICAL_RAIL)
|
||||||
{
|
{
|
||||||
if (collision == COLLISION_LEDGE_JUMP)
|
if (collision == COLLISION_LEDGE_JUMP)
|
||||||
{
|
{
|
||||||
@@ -261,9 +261,9 @@ static void MachBikeTransition_TrySlowDown(u8 direction)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Bike_SetBikeStill();
|
Bike_SetBikeStill();
|
||||||
if (collision == 4 && IsPlayerCollidingWithFarawayIslandMew(direction))
|
if (collision == COLLISION_EVENT_OBJECT && IsPlayerCollidingWithFarawayIslandMew(direction))
|
||||||
PlayerOnBikeCollideWithFarawayIslandMew(direction);
|
PlayerOnBikeCollideWithFarawayIslandMew(direction);
|
||||||
else if (collision < 5 || collision > 8)
|
else if (collision < COLLISION_STOP_SURFING || collision > COLLISION_ROTATING_GATE)
|
||||||
PlayerOnBikeCollide(direction);
|
PlayerOnBikeCollide(direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -552,14 +552,14 @@ static void AcroBikeTransition_Moving(u8 direction)
|
|||||||
AcroBikeTransition_FaceDirection(playerEventObj->movementDirection);
|
AcroBikeTransition_FaceDirection(playerEventObj->movementDirection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
collision = get_some_collision(direction);
|
collision = GetBikeCollision(direction);
|
||||||
if (collision > 0 && collision < 12)
|
if (collision > 0 && collision < COLLISION_VERTICAL_RAIL)
|
||||||
{
|
{
|
||||||
if (collision == COLLISION_LEDGE_JUMP)
|
if (collision == COLLISION_LEDGE_JUMP)
|
||||||
PlayerJumpLedge(direction);
|
PlayerJumpLedge(direction);
|
||||||
else if (collision == 4 && IsPlayerCollidingWithFarawayIslandMew(direction))
|
else if (collision == COLLISION_EVENT_OBJECT && IsPlayerCollidingWithFarawayIslandMew(direction))
|
||||||
PlayerOnBikeCollideWithFarawayIslandMew(direction);
|
PlayerOnBikeCollideWithFarawayIslandMew(direction);
|
||||||
else if (collision < 5 || collision > 8)
|
else if (collision < COLLISION_STOP_SURFING || collision > COLLISION_ROTATING_GATE)
|
||||||
PlayerOnBikeCollide(direction);
|
PlayerOnBikeCollide(direction);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -614,19 +614,19 @@ static void AcroBikeTransition_WheelieHoppingMoving(u8 direction)
|
|||||||
AcroBikeTransition_WheelieHoppingStanding(playerEventObj->movementDirection);
|
AcroBikeTransition_WheelieHoppingStanding(playerEventObj->movementDirection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
collision = get_some_collision(direction);
|
collision = GetBikeCollision(direction);
|
||||||
// TODO: Try to get rid of this goto
|
// TODO: Try to get rid of this goto
|
||||||
if (collision == 0 || collision == 9)
|
if (collision == 0 || collision == COLLISION_WHEELIE_HOP)
|
||||||
{
|
{
|
||||||
goto derp;
|
goto derp;
|
||||||
}
|
}
|
||||||
else if (collision == 6)
|
else if (collision == COLLISION_LEDGE_JUMP)
|
||||||
{
|
{
|
||||||
PlayerLedgeHoppingWheelie(direction);
|
PlayerLedgeHoppingWheelie(direction);
|
||||||
}
|
}
|
||||||
else if (collision < 5 || collision > 8)
|
else if (collision < COLLISION_STOP_SURFING || collision > COLLISION_ROTATING_GATE)
|
||||||
{
|
{
|
||||||
if (collision <= 11)
|
if (collision < COLLISION_VERTICAL_RAIL)
|
||||||
{
|
{
|
||||||
AcroBikeTransition_WheelieHoppingStanding(direction);
|
AcroBikeTransition_WheelieHoppingStanding(direction);
|
||||||
}
|
}
|
||||||
@@ -643,12 +643,12 @@ static void AcroBikeTransition_SideJump(u8 direction)
|
|||||||
u8 collision;
|
u8 collision;
|
||||||
struct EventObject *playerEventObj;
|
struct EventObject *playerEventObj;
|
||||||
|
|
||||||
collision = get_some_collision(direction);
|
collision = GetBikeCollision(direction);
|
||||||
if (collision != 0)
|
if (collision)
|
||||||
{
|
{
|
||||||
if (collision == 7)
|
if (collision == COLLISION_PUSHED_BOULDER)
|
||||||
return;
|
return;
|
||||||
if (collision < 10)
|
if (collision < COLLISION_ISOLATED_VERTICAL_RAIL)
|
||||||
{
|
{
|
||||||
AcroBikeTransition_TurnDirection(direction);
|
AcroBikeTransition_TurnDirection(direction);
|
||||||
return;
|
return;
|
||||||
@@ -680,18 +680,18 @@ static void AcroBikeTransition_WheelieMoving(u8 direction)
|
|||||||
PlayerIdleWheelie(playerEventObj->movementDirection);
|
PlayerIdleWheelie(playerEventObj->movementDirection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
collision = get_some_collision(direction);
|
collision = GetBikeCollision(direction);
|
||||||
if (collision > 0 && collision < 12)
|
if (collision > 0 && collision < COLLISION_VERTICAL_RAIL)
|
||||||
{
|
{
|
||||||
if (collision == 6)
|
if (collision == COLLISION_LEDGE_JUMP)
|
||||||
{
|
{
|
||||||
PlayerLedgeHoppingWheelie(direction);
|
PlayerLedgeHoppingWheelie(direction);
|
||||||
}
|
}
|
||||||
else if (collision == 9)
|
else if (collision == COLLISION_WHEELIE_HOP)
|
||||||
{
|
{
|
||||||
PlayerIdleWheelie(direction);
|
PlayerIdleWheelie(direction);
|
||||||
}
|
}
|
||||||
else if (collision <= 4)
|
else if (collision < COLLISION_STOP_SURFING)
|
||||||
{
|
{
|
||||||
if (MetatileBehavior_IsBumpySlope(playerEventObj->currentMetatileBehavior))
|
if (MetatileBehavior_IsBumpySlope(playerEventObj->currentMetatileBehavior))
|
||||||
PlayerIdleWheelie(direction);
|
PlayerIdleWheelie(direction);
|
||||||
@@ -714,18 +714,18 @@ static void AcroBikeTransition_WheelieRisingMoving(u8 direction)
|
|||||||
PlayerStartWheelie(playerEventObj->movementDirection);
|
PlayerStartWheelie(playerEventObj->movementDirection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
collision = get_some_collision(direction);
|
collision = GetBikeCollision(direction);
|
||||||
if (collision > 0 && collision < 12)
|
if (collision > 0 && collision < COLLISION_VERTICAL_RAIL)
|
||||||
{
|
{
|
||||||
if (collision == 6)
|
if (collision == COLLISION_LEDGE_JUMP)
|
||||||
{
|
{
|
||||||
PlayerLedgeHoppingWheelie(direction);
|
PlayerLedgeHoppingWheelie(direction);
|
||||||
}
|
}
|
||||||
else if (collision == 9)
|
else if (collision == COLLISION_WHEELIE_HOP)
|
||||||
{
|
{
|
||||||
PlayerIdleWheelie(direction);
|
PlayerIdleWheelie(direction);
|
||||||
}
|
}
|
||||||
else if (collision <= 4)
|
else if (collision < COLLISION_STOP_SURFING)
|
||||||
{
|
{
|
||||||
if (MetatileBehavior_IsBumpySlope(playerEventObj->currentMetatileBehavior))
|
if (MetatileBehavior_IsBumpySlope(playerEventObj->currentMetatileBehavior))
|
||||||
PlayerIdleWheelie(direction);
|
PlayerIdleWheelie(direction);
|
||||||
@@ -748,12 +748,12 @@ static void AcroBikeTransition_WheelieLoweringMoving(u8 direction)
|
|||||||
PlayerEndWheelie(playerEventObj->movementDirection);
|
PlayerEndWheelie(playerEventObj->movementDirection);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
collision = get_some_collision(direction);
|
collision = GetBikeCollision(direction);
|
||||||
if (collision > 0 && collision < 12)
|
if (collision > 0 && collision < COLLISION_VERTICAL_RAIL)
|
||||||
{
|
{
|
||||||
if (collision == 6)
|
if (collision == COLLISION_LEDGE_JUMP)
|
||||||
PlayerJumpLedge(direction);
|
PlayerJumpLedge(direction);
|
||||||
else if (collision < 5 || collision > 8)
|
else if (collision < COLLISION_STOP_SURFING || collision > COLLISION_ROTATING_GATE)
|
||||||
PlayerEndWheelie(direction);
|
PlayerEndWheelie(direction);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -865,29 +865,26 @@ static u8 Bike_DPadToDirection(u16 heldKeys)
|
|||||||
return DIR_NONE;
|
return DIR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 get_some_collision(u8 direction)
|
static u8 GetBikeCollision(u8 direction)
|
||||||
{
|
{
|
||||||
s16 x;
|
|
||||||
s16 y;
|
|
||||||
u8 metatitleBehavior;
|
u8 metatitleBehavior;
|
||||||
struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
|
struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
|
||||||
|
s16 x = playerEventObj->currentCoords.x;
|
||||||
x = playerEventObj->currentCoords.x;
|
s16 y = playerEventObj->currentCoords.y;
|
||||||
y = playerEventObj->currentCoords.y;
|
|
||||||
MoveCoords(direction, &x, &y);
|
MoveCoords(direction, &x, &y);
|
||||||
metatitleBehavior = MapGridGetMetatileBehaviorAt(x, y);
|
metatitleBehavior = MapGridGetMetatileBehaviorAt(x, y);
|
||||||
return Bike_CheckCollisionTryAdvanceCollisionCount(playerEventObj, x, y, direction, metatitleBehavior);
|
return GetBikeCollisionAt(playerEventObj, x, y, direction, metatitleBehavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 Bike_CheckCollisionTryAdvanceCollisionCount(struct EventObject *eventObject, s16 x, s16 y, u8 direction, u8 metatitleBehavior)
|
static u8 GetBikeCollisionAt(struct EventObject *eventObject, s16 x, s16 y, u8 direction, u8 metatitleBehavior)
|
||||||
{
|
{
|
||||||
u8 collision = CheckForEventObjectCollision(eventObject, x, y, direction, metatitleBehavior);
|
u8 collision = CheckForEventObjectCollision(eventObject, x, y, direction, metatitleBehavior);
|
||||||
|
|
||||||
if (collision > 4)
|
if (collision > COLLISION_EVENT_OBJECT)
|
||||||
return collision;
|
return collision;
|
||||||
|
|
||||||
if (collision == 0 && IsRunningDisallowedByMetatile(metatitleBehavior))
|
if (collision == COLLISION_NONE && IsRunningDisallowedByMetatile(metatitleBehavior))
|
||||||
collision = 2;
|
collision = COLLISION_IMPASSABLE;
|
||||||
|
|
||||||
if (collision)
|
if (collision)
|
||||||
Bike_TryAdvanceCyclingRoadCollisions();
|
Bike_TryAdvanceCyclingRoadCollisions();
|
||||||
@@ -941,10 +938,10 @@ static bool8 WillPlayerCollideWithCollision(u8 newTileCollision, u8 direction)
|
|||||||
{
|
{
|
||||||
if (direction == DIR_NORTH || direction == DIR_SOUTH)
|
if (direction == DIR_NORTH || direction == DIR_SOUTH)
|
||||||
{
|
{
|
||||||
if (newTileCollision == 10 || newTileCollision == 12)
|
if (newTileCollision == COLLISION_ISOLATED_VERTICAL_RAIL || newTileCollision == COLLISION_VERTICAL_RAIL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else if (newTileCollision == 11 || newTileCollision == 13)
|
else if (newTileCollision == COLLISION_ISOLATED_HORIZONTAL_RAIL || newTileCollision == COLLISION_HORIZONTAL_RAIL)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-32
@@ -2723,9 +2723,8 @@ bool8 MovementType_WanderAround_Step4(struct EventObject *eventObject, struct Sp
|
|||||||
SetEventObjectDirection(eventObject, chosenDirection);
|
SetEventObjectDirection(eventObject, chosenDirection);
|
||||||
sprite->data[1] = 5;
|
sprite->data[1] = 5;
|
||||||
if (GetCollisionInDirection(eventObject, chosenDirection))
|
if (GetCollisionInDirection(eventObject, chosenDirection))
|
||||||
{
|
|
||||||
sprite->data[1] = 1;
|
sprite->data[1] = 1;
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3093,9 +3092,8 @@ bool8 MovementType_WanderUpAndDown_Step4(struct EventObject *eventObject, struct
|
|||||||
SetEventObjectDirection(eventObject, direction);
|
SetEventObjectDirection(eventObject, direction);
|
||||||
sprite->data[1] = 5;
|
sprite->data[1] = 5;
|
||||||
if (GetCollisionInDirection(eventObject, direction))
|
if (GetCollisionInDirection(eventObject, direction))
|
||||||
{
|
|
||||||
sprite->data[1] = 1;
|
sprite->data[1] = 1;
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3163,9 +3161,8 @@ bool8 MovementType_WanderLeftAndRight_Step4(struct EventObject *eventObject, str
|
|||||||
SetEventObjectDirection(eventObject, direction);
|
SetEventObjectDirection(eventObject, direction);
|
||||||
sprite->data[1] = 5;
|
sprite->data[1] = 5;
|
||||||
if (GetCollisionInDirection(eventObject, direction))
|
if (GetCollisionInDirection(eventObject, direction))
|
||||||
{
|
|
||||||
sprite->data[1] = 1;
|
sprite->data[1] = 1;
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3952,7 +3949,7 @@ bool8 MovementType_WalkBackAndForth_Step1(struct EventObject *eventObject, struc
|
|||||||
|
|
||||||
bool8 MovementType_WalkBackAndForth_Step2(struct EventObject *eventObject, struct Sprite *sprite)
|
bool8 MovementType_WalkBackAndForth_Step2(struct EventObject *eventObject, struct Sprite *sprite)
|
||||||
{
|
{
|
||||||
bool8 collisionState;
|
bool8 collision;
|
||||||
u8 movementActionId;
|
u8 movementActionId;
|
||||||
|
|
||||||
if (eventObject->directionSequenceIndex && eventObject->initialCoords.x == eventObject->currentCoords.x && eventObject->initialCoords.y == eventObject->currentCoords.y)
|
if (eventObject->directionSequenceIndex && eventObject->initialCoords.x == eventObject->currentCoords.x && eventObject->initialCoords.y == eventObject->currentCoords.y)
|
||||||
@@ -3960,19 +3957,19 @@ bool8 MovementType_WalkBackAndForth_Step2(struct EventObject *eventObject, struc
|
|||||||
eventObject->directionSequenceIndex = 0;
|
eventObject->directionSequenceIndex = 0;
|
||||||
SetEventObjectDirection(eventObject, GetOppositeDirection(eventObject->movementDirection));
|
SetEventObjectDirection(eventObject, GetOppositeDirection(eventObject->movementDirection));
|
||||||
}
|
}
|
||||||
collisionState = GetCollisionInDirection(eventObject, eventObject->movementDirection);
|
collision = GetCollisionInDirection(eventObject, eventObject->movementDirection);
|
||||||
movementActionId = GetWalkNormalMovementAction(eventObject->movementDirection);
|
movementActionId = GetWalkNormalMovementAction(eventObject->movementDirection);
|
||||||
if (collisionState == TRUE)
|
if (collision == COLLISION_OUTSIDE_RANGE)
|
||||||
{
|
{
|
||||||
eventObject->directionSequenceIndex++;
|
eventObject->directionSequenceIndex++;
|
||||||
SetEventObjectDirection(eventObject, GetOppositeDirection(eventObject->movementDirection));
|
SetEventObjectDirection(eventObject, GetOppositeDirection(eventObject->movementDirection));
|
||||||
movementActionId = GetWalkNormalMovementAction(eventObject->movementDirection);
|
movementActionId = GetWalkNormalMovementAction(eventObject->movementDirection);
|
||||||
collisionState = GetCollisionInDirection(eventObject, eventObject->movementDirection);
|
collision = GetCollisionInDirection(eventObject, eventObject->movementDirection);
|
||||||
}
|
}
|
||||||
if (collisionState)
|
|
||||||
{
|
if (collision)
|
||||||
movementActionId = GetWalkInPlaceNormalMovementAction(eventObject->facingDirection);
|
movementActionId = GetWalkInPlaceNormalMovementAction(eventObject->facingDirection);
|
||||||
}
|
|
||||||
EventObjectSetSingleMovement(eventObject, sprite, movementActionId);
|
EventObjectSetSingleMovement(eventObject, sprite, movementActionId);
|
||||||
eventObject->singleMovementActive = 1;
|
eventObject->singleMovementActive = 1;
|
||||||
sprite->data[1] = 3;
|
sprite->data[1] = 3;
|
||||||
@@ -3998,27 +3995,26 @@ bool8 MovementType_WalkSequence_Step0(struct EventObject *eventObject, struct Sp
|
|||||||
|
|
||||||
bool8 MoveNextDirectionInSequence(struct EventObject *eventObject, struct Sprite *sprite, u8 *route)
|
bool8 MoveNextDirectionInSequence(struct EventObject *eventObject, struct Sprite *sprite, u8 *route)
|
||||||
{
|
{
|
||||||
u8 collisionState;
|
u8 collision;
|
||||||
u8 movementActionId;
|
u8 movementActionId;
|
||||||
|
|
||||||
if (eventObject->directionSequenceIndex == 3 && eventObject->initialCoords.x == eventObject->currentCoords.x && eventObject->initialCoords.y == eventObject->currentCoords.y)
|
if (eventObject->directionSequenceIndex == 3 && eventObject->initialCoords.x == eventObject->currentCoords.x && eventObject->initialCoords.y == eventObject->currentCoords.y)
|
||||||
{
|
|
||||||
eventObject->directionSequenceIndex = 0;
|
eventObject->directionSequenceIndex = 0;
|
||||||
}
|
|
||||||
SetEventObjectDirection(eventObject, route[eventObject->directionSequenceIndex]);
|
SetEventObjectDirection(eventObject, route[eventObject->directionSequenceIndex]);
|
||||||
movementActionId = GetWalkNormalMovementAction(eventObject->movementDirection);
|
movementActionId = GetWalkNormalMovementAction(eventObject->movementDirection);
|
||||||
collisionState = GetCollisionInDirection(eventObject, eventObject->movementDirection);
|
collision = GetCollisionInDirection(eventObject, eventObject->movementDirection);
|
||||||
if (collisionState == TRUE)
|
if (collision == COLLISION_OUTSIDE_RANGE)
|
||||||
{
|
{
|
||||||
eventObject->directionSequenceIndex++;
|
eventObject->directionSequenceIndex++;
|
||||||
SetEventObjectDirection(eventObject, route[eventObject->directionSequenceIndex]);
|
SetEventObjectDirection(eventObject, route[eventObject->directionSequenceIndex]);
|
||||||
movementActionId = GetWalkNormalMovementAction(eventObject->movementDirection);
|
movementActionId = GetWalkNormalMovementAction(eventObject->movementDirection);
|
||||||
collisionState = GetCollisionInDirection(eventObject, eventObject->movementDirection);
|
collision = GetCollisionInDirection(eventObject, eventObject->movementDirection);
|
||||||
}
|
}
|
||||||
if (collisionState)
|
|
||||||
{
|
if (collision)
|
||||||
movementActionId = GetWalkInPlaceNormalMovementAction(eventObject->facingDirection);
|
movementActionId = GetWalkInPlaceNormalMovementAction(eventObject->facingDirection);
|
||||||
}
|
|
||||||
EventObjectSetSingleMovement(eventObject, sprite, movementActionId);
|
EventObjectSetSingleMovement(eventObject, sprite, movementActionId);
|
||||||
eventObject->singleMovementActive = 1;
|
eventObject->singleMovementActive = 1;
|
||||||
sprite->data[1] = 2;
|
sprite->data[1] = 2;
|
||||||
@@ -4868,22 +4864,20 @@ static u8 GetCollisionInDirection(struct EventObject *eventObject, u8 direction)
|
|||||||
return GetCollisionAtCoords(eventObject, x, y, direction);
|
return GetCollisionAtCoords(eventObject, x, y, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 GetCollisionAtCoords(struct EventObject *eventObject, s16 x, s16 y, u32 dirn)
|
u8 GetCollisionAtCoords(struct EventObject *eventObject, s16 x, s16 y, u32 dir)
|
||||||
{
|
{
|
||||||
u8 direction;
|
u8 direction = dir;
|
||||||
|
|
||||||
direction = dirn;
|
|
||||||
if (IsCoordOutsideEventObjectMovementRange(eventObject, x, y))
|
if (IsCoordOutsideEventObjectMovementRange(eventObject, x, y))
|
||||||
return 1;
|
return COLLISION_OUTSIDE_RANGE;
|
||||||
else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(eventObject, x, y, direction))
|
else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(eventObject, x, y, direction))
|
||||||
return 2;
|
return COLLISION_IMPASSABLE;
|
||||||
else if (eventObject->trackedByCamera && !CanCameraMoveInDirection(direction))
|
else if (eventObject->trackedByCamera && !CanCameraMoveInDirection(direction))
|
||||||
return 2;
|
return COLLISION_IMPASSABLE;
|
||||||
else if (IsZCoordMismatchAt(eventObject->currentElevation, x, y))
|
else if (IsZCoordMismatchAt(eventObject->currentElevation, x, y))
|
||||||
return 3;
|
return COLLISION_ELEVATION_MISMATCH;
|
||||||
else if (DoesObjectCollideWithObjectAt(eventObject, x, y))
|
else if (DoesObjectCollideWithObjectAt(eventObject, x, y))
|
||||||
return 4;
|
return COLLISION_EVENT_OBJECT;
|
||||||
return 0;
|
return COLLISION_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 GetCollisionFlagsAtCoords(struct EventObject *eventObject, s16 x, s16 y, u8 direction)
|
u8 GetCollisionFlagsAtCoords(struct EventObject *eventObject, s16 x, s16 y, u8 direction)
|
||||||
|
|||||||
+59
-62
@@ -71,10 +71,10 @@ static void PlayerNotOnBikeMoving(u8, u16);
|
|||||||
static u8 CheckForPlayerAvatarCollision(u8);
|
static u8 CheckForPlayerAvatarCollision(u8);
|
||||||
static u8 sub_808B028(u8);
|
static u8 sub_808B028(u8);
|
||||||
static u8 sub_808B164(struct EventObject *, s16, s16, u8, u8);
|
static u8 sub_808B164(struct EventObject *, s16, s16, u8, u8);
|
||||||
static bool8 sub_808B1BC(s16, s16, u8);
|
static bool8 CanStopSurfing(s16, s16, u8);
|
||||||
static bool8 ShouldJumpLedge(s16, s16, u8);
|
static bool8 ShouldJumpLedge(s16, s16, u8);
|
||||||
static u8 sub_808B238(s16, s16, u8);
|
static bool8 TryPushBoulder(s16, s16, u8);
|
||||||
static void check_acro_bike_metatile(s16, s16, u8, u8 *);
|
static void CheckAcroBikeCollision(s16, s16, u8, u8 *);
|
||||||
|
|
||||||
static void DoPlayerAvatarTransition(void);
|
static void DoPlayerAvatarTransition(void);
|
||||||
static void PlayerAvatarTransition_Dummy(struct EventObject *a);
|
static void PlayerAvatarTransition_Dummy(struct EventObject *a);
|
||||||
@@ -115,9 +115,9 @@ static bool8 PlayerAvatar_SecretBaseMatSpinStep1(struct Task *task, struct Event
|
|||||||
static bool8 PlayerAvatar_SecretBaseMatSpinStep2(struct Task *task, struct EventObject *eventObject);
|
static bool8 PlayerAvatar_SecretBaseMatSpinStep2(struct Task *task, struct EventObject *eventObject);
|
||||||
static bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task *task, struct EventObject *eventObject);
|
static bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task *task, struct EventObject *eventObject);
|
||||||
|
|
||||||
static void sub_808C750(u8);
|
static void CreateStopSurfingTask(u8);
|
||||||
static void taskFF_0805D1D4(u8 taskId);
|
static void Task_StopSurfingInit(u8 taskId);
|
||||||
static void sub_808C814(u8 taskId);
|
static void Task_WaitStopSurfing(u8 taskId);
|
||||||
|
|
||||||
static void Task_Fishing(u8 taskId);
|
static void Task_Fishing(u8 taskId);
|
||||||
static u8 Fishing1(struct Task *task);
|
static u8 Fishing1(struct Task *task);
|
||||||
@@ -194,7 +194,7 @@ static void (*const gUnknown_08497490[])(u8, u16) =
|
|||||||
PlayerNotOnBikeMoving,
|
PlayerNotOnBikeMoving,
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool8 (*const gUnknown_0849749C[])(u8) =
|
static bool8 (*const sAcroBikeTrickMetatiles[])(u8) =
|
||||||
{
|
{
|
||||||
MetatileBehavior_IsBumpySlope,
|
MetatileBehavior_IsBumpySlope,
|
||||||
MetatileBehavior_IsIsolatedVerticalRail,
|
MetatileBehavior_IsIsolatedVerticalRail,
|
||||||
@@ -203,7 +203,13 @@ static bool8 (*const gUnknown_0849749C[])(u8) =
|
|||||||
MetatileBehavior_IsHorizontalRail,
|
MetatileBehavior_IsHorizontalRail,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const u8 gUnknown_084974B0[] = {9, 10, 11, 12, 13, 0, 0, 0};
|
static const u8 sAcroBikeTrickCollisionTypes[] = {
|
||||||
|
COLLISION_WHEELIE_HOP,
|
||||||
|
COLLISION_ISOLATED_VERTICAL_RAIL,
|
||||||
|
COLLISION_ISOLATED_HORIZONTAL_RAIL,
|
||||||
|
COLLISION_VERTICAL_RAIL,
|
||||||
|
COLLISION_HORIZONTAL_RAIL,
|
||||||
|
};
|
||||||
|
|
||||||
static void (*const gUnknown_084974B8[])(struct EventObject *) =
|
static void (*const gUnknown_084974B8[])(struct EventObject *) =
|
||||||
{
|
{
|
||||||
@@ -432,19 +438,19 @@ static bool8 ForcedMovement_None(void)
|
|||||||
static u8 DoForcedMovement(u8 direction, void (*b)(u8))
|
static u8 DoForcedMovement(u8 direction, void (*b)(u8))
|
||||||
{
|
{
|
||||||
struct PlayerAvatar *playerAvatar = &gPlayerAvatar;
|
struct PlayerAvatar *playerAvatar = &gPlayerAvatar;
|
||||||
u8 collisionType = CheckForPlayerAvatarCollision(direction);
|
u8 collision = CheckForPlayerAvatarCollision(direction);
|
||||||
|
|
||||||
playerAvatar->flags |= PLAYER_AVATAR_FLAG_6;
|
playerAvatar->flags |= PLAYER_AVATAR_FLAG_6;
|
||||||
if (collisionType != 0)
|
if (collision)
|
||||||
{
|
{
|
||||||
ForcedMovement_None();
|
ForcedMovement_None();
|
||||||
if (collisionType <= 4)
|
if (collision < COLLISION_STOP_SURFING)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (collisionType == COLLISION_LEDGE_JUMP)
|
if (collision == COLLISION_LEDGE_JUMP)
|
||||||
PlayerJumpLedge(direction);
|
PlayerJumpLedge(direction);
|
||||||
playerAvatar->flags |= PLAYER_AVATAR_FLAG_6;
|
playerAvatar->flags |= PLAYER_AVATAR_FLAG_6;
|
||||||
playerAvatar->runningState = MOVING;
|
playerAvatar->runningState = MOVING;
|
||||||
@@ -605,33 +611,26 @@ static void PlayerNotOnBikeTurningInPlace(u8 direction, u16 heldKeys)
|
|||||||
|
|
||||||
static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys)
|
static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys)
|
||||||
{
|
{
|
||||||
u8 r0 = CheckForPlayerAvatarCollision(direction);
|
u8 collision = CheckForPlayerAvatarCollision(direction);
|
||||||
|
|
||||||
if (r0 != 0)
|
if (collision)
|
||||||
{
|
{
|
||||||
if (r0 == 6)
|
if (collision == COLLISION_LEDGE_JUMP)
|
||||||
{
|
{
|
||||||
PlayerJumpLedge(direction);
|
PlayerJumpLedge(direction);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (r0 == 4 && IsPlayerCollidingWithFarawayIslandMew(direction) != 0)
|
else if (collision == COLLISION_EVENT_OBJECT && IsPlayerCollidingWithFarawayIslandMew(direction))
|
||||||
{
|
{
|
||||||
PlayerNotOnBikeCollideWithFarawayIslandMew(direction);
|
PlayerNotOnBikeCollideWithFarawayIslandMew(direction);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u8 r4 = r0 - 5;
|
u8 adjustedCollision = collision - COLLISION_STOP_SURFING;
|
||||||
|
if (adjustedCollision > 3)
|
||||||
if (r4 > 3)
|
|
||||||
{
|
|
||||||
PlayerNotOnBikeCollide(direction);
|
PlayerNotOnBikeCollide(direction);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,50 +676,49 @@ static u8 sub_808B028(u8 direction)
|
|||||||
return sub_808B164(playerEventObj, x, y, direction, MapGridGetMetatileBehaviorAt(x, y));
|
return sub_808B164(playerEventObj, x, y, direction, MapGridGetMetatileBehaviorAt(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 CheckForEventObjectCollision(struct EventObject *a, s16 x, s16 y, u8 direction, u8 e)
|
u8 CheckForEventObjectCollision(struct EventObject *eventObject, s16 x, s16 y, u8 direction, u8 metatileBehavior)
|
||||||
{
|
{
|
||||||
u8 collision;
|
u8 collision = GetCollisionAtCoords(eventObject, x, y, direction);
|
||||||
|
if (collision == COLLISION_ELEVATION_MISMATCH && CanStopSurfing(x, y, direction))
|
||||||
|
return COLLISION_STOP_SURFING;
|
||||||
|
|
||||||
collision = GetCollisionAtCoords(a, x, y, direction);
|
|
||||||
if (collision == 3 && sub_808B1BC(x, y, direction))
|
|
||||||
return 5;
|
|
||||||
if (ShouldJumpLedge(x, y, direction))
|
if (ShouldJumpLedge(x, y, direction))
|
||||||
{
|
{
|
||||||
IncrementGameStat(GAME_STAT_JUMPED_DOWN_LEDGES);
|
IncrementGameStat(GAME_STAT_JUMPED_DOWN_LEDGES);
|
||||||
return COLLISION_LEDGE_JUMP;
|
return COLLISION_LEDGE_JUMP;
|
||||||
}
|
}
|
||||||
if (collision == 4 && sub_808B238(x, y, direction))
|
if (collision == COLLISION_EVENT_OBJECT && TryPushBoulder(x, y, direction))
|
||||||
return 7;
|
return COLLISION_PUSHED_BOULDER;
|
||||||
|
|
||||||
if (collision == 0)
|
if (collision == COLLISION_NONE)
|
||||||
{
|
{
|
||||||
if (CheckForRotatingGatePuzzleCollision(direction, x, y))
|
if (CheckForRotatingGatePuzzleCollision(direction, x, y))
|
||||||
return 8;
|
return COLLISION_ROTATING_GATE;
|
||||||
check_acro_bike_metatile(x, y, e, &collision);
|
CheckAcroBikeCollision(x, y, metatileBehavior, &collision);
|
||||||
}
|
}
|
||||||
return collision;
|
return collision;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 sub_808B164(struct EventObject *a, s16 x, s16 y, u8 direction, u8 e)
|
static u8 sub_808B164(struct EventObject *eventObject, s16 x, s16 y, u8 direction, u8 metatileBehavior)
|
||||||
{
|
{
|
||||||
u8 collision = GetCollisionAtCoords(a, x, y, direction);
|
u8 collision = GetCollisionAtCoords(eventObject, x, y, direction);
|
||||||
|
|
||||||
if (collision == 0)
|
if (collision == COLLISION_NONE)
|
||||||
{
|
{
|
||||||
if (CheckForRotatingGatePuzzleCollisionWithoutAnimation(direction, x, y) != 0)
|
if (CheckForRotatingGatePuzzleCollisionWithoutAnimation(direction, x, y))
|
||||||
return 8;
|
return COLLISION_ROTATING_GATE;
|
||||||
check_acro_bike_metatile(x, y, e, &collision);
|
CheckAcroBikeCollision(x, y, metatileBehavior, &collision);
|
||||||
}
|
}
|
||||||
return collision;
|
return collision;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool8 sub_808B1BC(s16 x, s16 y, u8 direction)
|
static bool8 CanStopSurfing(s16 x, s16 y, u8 direction)
|
||||||
{
|
{
|
||||||
if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
|
if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
|
||||||
&& MapGridGetZCoordAt(x, y) == 3
|
&& MapGridGetZCoordAt(x, y) == 3
|
||||||
&& GetEventObjectIdByXYZ(x, y, 3) == EVENT_OBJECTS_COUNT)
|
&& GetEventObjectIdByXYZ(x, y, 3) == EVENT_OBJECTS_COUNT)
|
||||||
{
|
{
|
||||||
sub_808C750(direction);
|
CreateStopSurfingTask(direction);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -737,7 +735,7 @@ static bool8 ShouldJumpLedge(s16 x, s16 y, u8 z)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 sub_808B238(s16 x, s16 y, u8 direction)
|
static bool8 TryPushBoulder(s16 x, s16 y, u8 direction)
|
||||||
{
|
{
|
||||||
if (FlagGet(FLAG_SYS_USE_STRENGTH))
|
if (FlagGet(FLAG_SYS_USE_STRENGTH))
|
||||||
{
|
{
|
||||||
@@ -748,26 +746,26 @@ static u8 sub_808B238(s16 x, s16 y, u8 direction)
|
|||||||
x = gEventObjects[eventObjectId].currentCoords.x;
|
x = gEventObjects[eventObjectId].currentCoords.x;
|
||||||
y = gEventObjects[eventObjectId].currentCoords.y;
|
y = gEventObjects[eventObjectId].currentCoords.y;
|
||||||
MoveCoords(direction, &x, &y);
|
MoveCoords(direction, &x, &y);
|
||||||
if (GetCollisionAtCoords(&gEventObjects[eventObjectId], x, y, direction) == 0
|
if (GetCollisionAtCoords(&gEventObjects[eventObjectId], x, y, direction) == COLLISION_NONE
|
||||||
&& MetatileBehavior_IsNonAnimDoor(MapGridGetMetatileBehaviorAt(x, y)) == 0)
|
&& MetatileBehavior_IsNonAnimDoor(MapGridGetMetatileBehaviorAt(x, y)) == 0)
|
||||||
{
|
{
|
||||||
StartStrengthAnim(eventObjectId, direction);
|
StartStrengthAnim(eventObjectId, direction);
|
||||||
return 1;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_acro_bike_metatile(s16 unused1, s16 unused2, u8 c, u8 *d)
|
static void CheckAcroBikeCollision(s16 x, s16 y, u8 metatileBehavior, u8 *collision)
|
||||||
{
|
{
|
||||||
u8 i;
|
u8 i;
|
||||||
|
|
||||||
for (i = 0; i < 5; i++)
|
for (i = 0; i < ARRAY_COUNT(sAcroBikeTrickMetatiles); i++)
|
||||||
{
|
{
|
||||||
if (gUnknown_0849749C[i](c))
|
if (sAcroBikeTrickMetatiles[i](metatileBehavior))
|
||||||
{
|
{
|
||||||
*d = gUnknown_084974B0[i];
|
*collision = sAcroBikeTrickCollisionTypes[i];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1314,7 +1312,8 @@ bool8 IsPlayerFacingSurfableFishableWater(void)
|
|||||||
s16 y = playerEventObj->currentCoords.y;
|
s16 y = playerEventObj->currentCoords.y;
|
||||||
|
|
||||||
MoveCoords(playerEventObj->facingDirection, &x, &y);
|
MoveCoords(playerEventObj->facingDirection, &x, &y);
|
||||||
if (GetCollisionAtCoords(playerEventObj, x, y, playerEventObj->facingDirection) == 3 && PlayerGetZCoord() == 3
|
if (GetCollisionAtCoords(playerEventObj, x, y, playerEventObj->facingDirection) == COLLISION_ELEVATION_MISMATCH
|
||||||
|
&& PlayerGetZCoord() == 3
|
||||||
&& MetatileBehavior_IsSurfableFishableWater(MapGridGetMetatileBehaviorAt(x, y)))
|
&& MetatileBehavior_IsSurfableFishableWater(MapGridGetMetatileBehaviorAt(x, y)))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
@@ -1626,9 +1625,7 @@ static bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task *task, struct Event
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Some Field effect */
|
static void CreateStopSurfingTask(u8 direction)
|
||||||
|
|
||||||
static void sub_808C750(u8 a)
|
|
||||||
{
|
{
|
||||||
u8 taskId;
|
u8 taskId;
|
||||||
|
|
||||||
@@ -1638,12 +1635,12 @@ static void sub_808C750(u8 a)
|
|||||||
gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_SURFING;
|
gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_SURFING;
|
||||||
gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_ON_FOOT;
|
gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_ON_FOOT;
|
||||||
gPlayerAvatar.preventStep = TRUE;
|
gPlayerAvatar.preventStep = TRUE;
|
||||||
taskId = CreateTask(taskFF_0805D1D4, 0xFF);
|
taskId = CreateTask(Task_StopSurfingInit, 0xFF);
|
||||||
gTasks[taskId].data[0] = a;
|
gTasks[taskId].data[0] = direction;
|
||||||
taskFF_0805D1D4(taskId);
|
Task_StopSurfingInit(taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void taskFF_0805D1D4(u8 taskId)
|
static void Task_StopSurfingInit(u8 taskId)
|
||||||
{
|
{
|
||||||
struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
|
struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
|
||||||
|
|
||||||
@@ -1654,10 +1651,10 @@ static void taskFF_0805D1D4(u8 taskId)
|
|||||||
}
|
}
|
||||||
sub_81555AC(playerEventObj->fieldEffectSpriteId, 2);
|
sub_81555AC(playerEventObj->fieldEffectSpriteId, 2);
|
||||||
EventObjectSetHeldMovement(playerEventObj, GetJumpSpecialMovementAction((u8)gTasks[taskId].data[0]));
|
EventObjectSetHeldMovement(playerEventObj, GetJumpSpecialMovementAction((u8)gTasks[taskId].data[0]));
|
||||||
gTasks[taskId].func = sub_808C814;
|
gTasks[taskId].func = Task_WaitStopSurfing;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sub_808C814(u8 taskId)
|
static void Task_WaitStopSurfing(u8 taskId)
|
||||||
{
|
{
|
||||||
struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
|
struct EventObject *playerEventObj = &gEventObjects[gPlayerAvatar.eventObjectId];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user