sideways stairs, try to integrate with follower code
This commit is contained in:
commit
b8dea3c7ec
15 changed files with 915 additions and 244 deletions
Binary file not shown.
|
@ -3,6 +3,7 @@
|
|||
|
||||
// Movement config
|
||||
#define OW_RUNNING_INDOORS GEN_LATEST // In Gen4+, players are allowed to run indoors.
|
||||
#define SLOW_MOVEMENT_ON_STAIRS TRUE // If enabled, the player will move slower up/down stairs like in FR
|
||||
|
||||
// Other settings
|
||||
#define OW_POISON_DAMAGE GEN_LATEST // In Gen4, Pokémon no longer faint from Poison in the overworld. In Gen5+, they no longer take damage at all.
|
||||
|
|
|
@ -247,6 +247,10 @@
|
|||
#define MOVEMENT_ACTION_EMOTE_DOUBLE_EXCL_MARK 0x9F
|
||||
#define MOVEMENT_ACTION_EXIT_POKEBALL 0xA0
|
||||
#define MOVEMENT_ACTION_ENTER_POKEBALL 0xA1
|
||||
#define MOVEMENT_ACTION_RUN_DOWN_SLOW 0xA2 // slow running for rocky stairs
|
||||
#define MOVEMENT_ACTION_RUN_UP_SLOW 0xA3
|
||||
#define MOVEMENT_ACTION_RUN_LEFT_SLOW 0xA4
|
||||
#define MOVEMENT_ACTION_RUN_RIGHT_SLOW 0xA5
|
||||
|
||||
#define MOVEMENT_ACTION_STEP_END 0xFE
|
||||
#define MOVEMENT_ACTION_NONE 0xFF
|
||||
|
|
|
@ -74,13 +74,13 @@
|
|||
#define MB_SLIDE_NORTH 0x46
|
||||
#define MB_SLIDE_SOUTH 0x47
|
||||
#define MB_TRICK_HOUSE_PUZZLE_8_FLOOR 0x48
|
||||
#define MB_UNUSED_49 0x49
|
||||
#define MB_UNUSED_4A 0x4A
|
||||
#define MB_UNUSED_4B 0x4B
|
||||
#define MB_UNUSED_4C 0x4C
|
||||
#define MB_UNUSED_4D 0x4D
|
||||
#define MB_UNUSED_4E 0x4E
|
||||
#define MB_UNUSED_4F 0x4F
|
||||
#define MB_SIDEWAYS_STAIRS_RIGHT_SIDE 0x49
|
||||
#define MB_SIDEWAYS_STAIRS_LEFT_SIDE 0x4A
|
||||
#define MB_SIDEWAYS_STAIRS_RIGHT_SIDE_TOP 0x4B
|
||||
#define MB_SIDEWAYS_STAIRS_LEFT_SIDE_TOP 0x4C
|
||||
#define MB_SIDEWAYS_STAIRS_RIGHT_SIDE_BOTTOM 0x4D
|
||||
#define MB_SIDEWAYS_STAIRS_LEFT_SIDE_BOTTOM 0x4E
|
||||
#define MB_ROCK_STAIRS 0x4F
|
||||
#define MB_EASTWARD_CURRENT 0x50
|
||||
#define MB_WESTWARD_CURRENT 0x51
|
||||
#define MB_NORTHWARD_CURRENT 0x52
|
||||
|
|
|
@ -484,6 +484,15 @@ void SetVirtualObjectInvisibility(u8 virtualObjId, bool32 invisible);
|
|||
bool32 IsVirtualObjectInvisible(u8 virtualObjId);
|
||||
void SetVirtualObjectSpriteAnim(u8 virtualObjId, u8 animNum);
|
||||
bool32 IsVirtualObjectAnimating(u8 virtualObjId);
|
||||
u8 GetObjectEventIdByLocalId(u8 localId);
|
||||
bool32 IsFollowerVisible(void);
|
||||
|
||||
// run slow
|
||||
u8 GetPlayerRunSlowMovementAction(u32);
|
||||
//sideways stairs
|
||||
u8 GetSidewaysStairsToRightDirection(s16, s16, u8);
|
||||
u8 GetSidewaysStairsToLeftDirection(s16, s16, u8);
|
||||
u8 GetSidewaysStairsCollision(struct ObjectEvent *objectEvent, u8 dir, u8 currentBehavior, u8 nextBehavior, u8 collision);
|
||||
|
||||
bool8 MovementAction_EmoteX_Step0(struct ObjectEvent *, struct Sprite *);
|
||||
bool8 MovementAction_EmoteDoubleExclamationMark_Step0(struct ObjectEvent *, struct Sprite *);
|
||||
|
|
|
@ -64,5 +64,9 @@ bool32 IsPlayerSpinExitActive(void);
|
|||
void SetPlayerInvisibility(bool8 invisible);
|
||||
u8 player_get_pos_including_state_based_drift(s16 *x, s16 *y);
|
||||
void StartFishing(u8 rod);
|
||||
bool8 ObjectMovingOnRockStairs(struct ObjectEvent *objectEvent, u8 direction);
|
||||
//sideways stairs
|
||||
u8 GetRightSideStairsDirection(u8 direction);
|
||||
u8 GetLeftSideStairsDirection(u8 direction);
|
||||
|
||||
#endif // GUARD_FIELD_PLAYER_AVATAR_H
|
||||
|
|
|
@ -217,7 +217,8 @@ struct ObjectEvent
|
|||
/*0x1D*/ u8 trainerRange_berryTreeId;
|
||||
/*0x1E*/ u8 currentMetatileBehavior;
|
||||
/*0x1F*/ u8 previousMetatileBehavior;
|
||||
/*0x20*/ u8 previousMovementDirection;
|
||||
/*0x20*/ u8 previousMovementDirection:4;
|
||||
u8 directionOverwrite:4;
|
||||
/*0x21*/ u8 directionSequenceIndex;
|
||||
/*0x22*/ u8 playerCopyableMovement; // COPY_MOVE_*
|
||||
/*0x23*/ u8 spriteId;
|
||||
|
@ -297,6 +298,9 @@ enum
|
|||
COLLISION_ISOLATED_HORIZONTAL_RAIL,
|
||||
COLLISION_VERTICAL_RAIL,
|
||||
COLLISION_HORIZONTAL_RAIL,
|
||||
//sideways_stairs
|
||||
COLLISION_SIDEWAYS_STAIRS_TO_RIGHT,
|
||||
COLLISION_SIDEWAYS_STAIRS_TO_LEFT
|
||||
};
|
||||
|
||||
// player running states
|
||||
|
|
|
@ -148,5 +148,15 @@ bool8 MetatileBehavior_IsQuestionnaire(u8);
|
|||
bool8 MetatileBehavior_IsLongGrass_Duplicate(u8);
|
||||
bool8 MetatileBehavior_IsLongGrassSouthEdge(u8);
|
||||
bool8 MetatileBehavior_IsTrainerHillTimer(u8);
|
||||
bool8 MetatileBehavior_IsRockStairs(u8);
|
||||
//sideways stairs
|
||||
bool8 MetatileBehavior_IsSidewaysStairsRightSide(u8);
|
||||
bool8 MetatileBehavior_IsSidewaysStairsLeftSide(u8);
|
||||
bool8 MetatileBehavior_IsSidewaysStairsRightSideTop(u8 metatileBehavior);
|
||||
bool8 MetatileBehavior_IsSidewaysStairsLeftSideTop(u8 metatileBehavior);
|
||||
bool8 MetatileBehavior_IsSidewaysStairsRightSideBottom(u8 metatileBehavior);
|
||||
bool8 MetatileBehavior_IsSidewaysStairsLeftSideBottom(u8 metatileBehavior);
|
||||
bool8 MetatileBehavior_IsSidewaysStairsRightSideAny(u8 metatileBehavior);
|
||||
bool8 MetatileBehavior_IsSidewaysStairsLeftSideAny(u8 metatileBehavior);
|
||||
|
||||
#endif // GUARD_METATILE_BEHAVIOR_H
|
||||
|
|
28
src/bike.c
28
src/bike.c
|
@ -142,6 +142,19 @@ static u8 GetMachBikeTransition(u8 *dirTraveling)
|
|||
{
|
||||
// if the dir updated before this function, get the relevent new direction to check later.
|
||||
u8 direction = GetPlayerMovementDirection();
|
||||
|
||||
// fix direction when moving on sideways stairs
|
||||
switch (direction)
|
||||
{
|
||||
case DIR_SOUTHWEST:
|
||||
case DIR_NORTHWEST:
|
||||
direction = DIR_WEST;
|
||||
break;
|
||||
case DIR_SOUTHEAST:
|
||||
case DIR_NORTHEAST:
|
||||
direction = DIR_EAST;
|
||||
break;
|
||||
}
|
||||
|
||||
// is the player standing still?
|
||||
if (*dirTraveling == 0)
|
||||
|
@ -193,7 +206,7 @@ static void MachBikeTransition_TurnDirection(u8 direction)
|
|||
Bike_SetBikeStill();
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
MachBikeTransition_FaceDirection(playerObjEvent->facingDirection);
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +246,9 @@ static void MachBikeTransition_TrySpeedUp(u8 direction)
|
|||
}
|
||||
else
|
||||
{
|
||||
// we did not hit anything that can slow us down, so perform the advancement callback depending on the bikeFrameCounter and try to increase the mach bike's speed.
|
||||
if (ObjectMovingOnRockStairs(playerObjEvent, direction) && gPlayerAvatar.bikeFrameCounter > 1)
|
||||
gPlayerAvatar.bikeFrameCounter--;
|
||||
|
||||
sMachBikeSpeedCallbacks[gPlayerAvatar.bikeFrameCounter](direction);
|
||||
gPlayerAvatar.bikeSpeed = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // same as dividing by 2, but compiler is insistent on >> 1
|
||||
if (gPlayerAvatar.bikeFrameCounter < 2) // do not go faster than the last element in the mach bike array
|
||||
|
@ -368,6 +383,7 @@ static u8 AcroBikeHandleInputWheelieStanding(u8 *newDirection, u16 newKeys, u16
|
|||
struct ObjectEvent *playerObjEvent;
|
||||
|
||||
direction = GetPlayerMovementDirection();
|
||||
|
||||
playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
|
||||
gPlayerAvatar.runningState = NOT_MOVING;
|
||||
|
||||
|
@ -563,7 +579,10 @@ static void AcroBikeTransition_Moving(u8 direction)
|
|||
}
|
||||
else
|
||||
{
|
||||
PlayerRideWaterCurrent(direction);
|
||||
if (ObjectMovingOnRockStairs(playerObjEvent, direction))
|
||||
PlayerWalkFast(direction);
|
||||
else
|
||||
PlayerRideWaterCurrent(direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -696,6 +715,7 @@ static void AcroBikeTransition_WheelieMoving(u8 direction)
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerWheelieMove(direction);
|
||||
gPlayerAvatar.runningState = MOVING;
|
||||
}
|
||||
|
@ -730,6 +750,7 @@ static void AcroBikeTransition_WheelieRisingMoving(u8 direction)
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerPopWheelieWhileMoving(direction);
|
||||
gPlayerAvatar.runningState = MOVING;
|
||||
}
|
||||
|
@ -753,6 +774,7 @@ static void AcroBikeTransition_WheelieLoweringMoving(u8 direction)
|
|||
PlayerEndWheelie(direction);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerEndWheelieWhileMoving(direction);
|
||||
}
|
||||
|
||||
|
|
|
@ -266,6 +266,12 @@ u8 MovementAction_FlyUp_Step1(struct ObjectEvent *, struct Sprite *);
|
|||
u8 MovementAction_Fly_Finish(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementAction_FlyDown_Step0(struct ObjectEvent *, struct Sprite *);
|
||||
u8 MovementAction_FlyDown_Step1(struct ObjectEvent *, struct Sprite *);
|
||||
//slow running
|
||||
u8 MovementActionFunc_RunSlowDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite);
|
||||
u8 MovementActionFunc_RunSlowUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite);
|
||||
u8 MovementActionFunc_RunSlowLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite);
|
||||
u8 MovementActionFunc_RunSlowRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite);
|
||||
u8 MovementActionFunc_RunSlow_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite);
|
||||
|
||||
u8 (*const gMovementActionFuncs_FaceDown[])(struct ObjectEvent *, struct Sprite *);
|
||||
u8 (*const gMovementActionFuncs_FaceUp[])(struct ObjectEvent *, struct Sprite *);
|
||||
|
@ -429,6 +435,11 @@ u8 (*const gMovementActionFuncs_FlyUp[])(struct ObjectEvent *, struct Sprite *);
|
|||
u8 (*const gMovementActionFuncs_FlyDown[])(struct ObjectEvent *, struct Sprite *);
|
||||
u8 (*const gMovementActionFuncs_EmoteX[])(struct ObjectEvent *, struct Sprite *);
|
||||
u8 (*const gMovementActionFuncs_EmoteDoubleExclMark[])(struct ObjectEvent *, struct Sprite *);
|
||||
//run slow
|
||||
u8 (*const gMovementActionFuncs_RunDownSlow[])(struct ObjectEvent *, struct Sprite *);
|
||||
u8 (*const gMovementActionFuncs_RunUpSlow[])(struct ObjectEvent *, struct Sprite *);
|
||||
u8 (*const gMovementActionFuncs_RunLeftSlow[])(struct ObjectEvent *, struct Sprite *);
|
||||
u8 (*const gMovementActionFuncs_RunRightSlow[])(struct ObjectEvent *, struct Sprite *);
|
||||
|
||||
u8 (*const *const gMovementActionFuncs[])(struct ObjectEvent *, struct Sprite *) = {
|
||||
[MOVEMENT_ACTION_FACE_DOWN] = gMovementActionFuncs_FaceDown,
|
||||
|
@ -593,6 +604,11 @@ u8 (*const *const gMovementActionFuncs[])(struct ObjectEvent *, struct Sprite *)
|
|||
[MOVEMENT_ACTION_EMOTE_DOUBLE_EXCL_MARK] = gMovementActionFuncs_EmoteDoubleExclMark,
|
||||
[MOVEMENT_ACTION_EXIT_POKEBALL] = gMovementActionFuncs_ExitPokeball,
|
||||
[MOVEMENT_ACTION_ENTER_POKEBALL] = gMovementActionFuncs_EnterPokeball,
|
||||
//run slow
|
||||
[MOVEMENT_ACTION_RUN_DOWN_SLOW] = gMovementActionFuncs_RunDownSlow,
|
||||
[MOVEMENT_ACTION_RUN_UP_SLOW] = gMovementActionFuncs_RunUpSlow,
|
||||
[MOVEMENT_ACTION_RUN_LEFT_SLOW] = gMovementActionFuncs_RunLeftSlow,
|
||||
[MOVEMENT_ACTION_RUN_RIGHT_SLOW] = gMovementActionFuncs_RunRightSlow,
|
||||
};
|
||||
|
||||
u8 (*const gMovementActionFuncs_FaceDown[])(struct ObjectEvent *, struct Sprite *) = {
|
||||
|
@ -1554,3 +1570,28 @@ u8 (*const gMovementActionFuncs_EmoteDoubleExclMark[])(struct ObjectEvent *, str
|
|||
MovementAction_EmoteDoubleExclamationMark_Step0,
|
||||
MovementAction_Finish,
|
||||
};
|
||||
|
||||
//slow running
|
||||
u8 (*const gMovementActionFuncs_RunDownSlow[])(struct ObjectEvent *, struct Sprite *) = {
|
||||
MovementActionFunc_RunSlowDown_Step0,
|
||||
MovementActionFunc_RunSlow_Step1,
|
||||
MovementAction_PauseSpriteAnim,
|
||||
};
|
||||
|
||||
u8 (*const gMovementActionFuncs_RunUpSlow[])(struct ObjectEvent *, struct Sprite *) = {
|
||||
MovementActionFunc_RunSlowUp_Step0,
|
||||
MovementActionFunc_RunSlow_Step1,
|
||||
MovementAction_PauseSpriteAnim,
|
||||
};
|
||||
|
||||
u8 (*const gMovementActionFuncs_RunLeftSlow[])(struct ObjectEvent *, struct Sprite *) = {
|
||||
MovementActionFunc_RunSlowLeft_Step0,
|
||||
MovementActionFunc_RunSlow_Step1,
|
||||
MovementAction_PauseSpriteAnim,
|
||||
};
|
||||
|
||||
u8 (*const gMovementActionFuncs_RunRightSlow[])(struct ObjectEvent *, struct Sprite *) = {
|
||||
MovementActionFunc_RunSlowRight_Step0,
|
||||
MovementActionFunc_RunSlow_Step1,
|
||||
MovementAction_PauseSpriteAnim,
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -310,8 +310,39 @@ static const u8 *GetInteractedObjectEventScript(struct MapPosition *position, u8
|
|||
{
|
||||
u8 objectEventId;
|
||||
const u8 *script;
|
||||
|
||||
objectEventId = GetObjectEventIdByPosition(position->x, position->y, position->elevation);
|
||||
s16 currX = gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.x;
|
||||
s16 currY = gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.y;
|
||||
u8 currBehavior = MapGridGetMetatileBehaviorAt(currX, currY);
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case DIR_EAST:
|
||||
if (MetatileBehavior_IsSidewaysStairsLeftSideAny(metatileBehavior))
|
||||
// sideways stairs left-side to your right -> check northeast
|
||||
objectEventId = GetObjectEventIdByPosition(currX + 1, currY - 1, position->elevation);
|
||||
else if (MetatileBehavior_IsSidewaysStairsRightSideAny(currBehavior))
|
||||
// on top of right-side stairs -> check southeast
|
||||
objectEventId = GetObjectEventIdByPosition(currX + 1, currY + 1, position->elevation);
|
||||
else
|
||||
// check in front of player
|
||||
objectEventId = GetObjectEventIdByPosition(position->x, position->y, position->elevation);
|
||||
break;
|
||||
case DIR_WEST:
|
||||
if (MetatileBehavior_IsSidewaysStairsRightSideAny(metatileBehavior))
|
||||
// facing sideways stairs right side -> check northwest
|
||||
objectEventId = GetObjectEventIdByPosition(currX - 1, currY - 1, position->elevation);
|
||||
else if (MetatileBehavior_IsSidewaysStairsLeftSideAny(currBehavior))
|
||||
// on top of left-side stairs -> check southwest
|
||||
objectEventId = GetObjectEventIdByPosition(currX - 1, currY + 1, position->elevation);
|
||||
else
|
||||
// check in front of player
|
||||
objectEventId = GetObjectEventIdByPosition(position->x, position->y, position->elevation);
|
||||
break;
|
||||
default:
|
||||
objectEventId = GetObjectEventIdByPosition(position->x, position->y, position->elevation);
|
||||
break;
|
||||
}
|
||||
|
||||
if (objectEventId == OBJECT_EVENTS_COUNT || gObjectEvents[objectEventId].localId == OBJ_EVENT_ID_PLAYER)
|
||||
{
|
||||
if (MetatileBehavior_IsCounter(metatileBehavior) != TRUE)
|
||||
|
|
|
@ -92,6 +92,8 @@ static bool8 PlayerAnimIsMultiFrameStationaryAndStateNotTurning(void);
|
|||
static bool8 PlayerIsAnimActive(void);
|
||||
static bool8 PlayerCheckIfAnimFinishedOrInactive(void);
|
||||
|
||||
static void PlayerWalkSlow(u8 direction);
|
||||
static void PlayerRunSlow(u8 direction);
|
||||
static void PlayerRun(u8);
|
||||
static void PlayerNotOnBikeCollide(u8);
|
||||
static void PlayerNotOnBikeCollideWithFarawayIslandMew(u8);
|
||||
|
@ -456,7 +458,22 @@ static bool8 ForcedMovement_None(void)
|
|||
static bool8 DoForcedMovement(u8 direction, void (*moveFunc)(u8))
|
||||
{
|
||||
struct PlayerAvatar *playerAvatar = &gPlayerAvatar;
|
||||
u8 collision = CheckForPlayerAvatarCollision(direction);
|
||||
u8 collision;
|
||||
|
||||
// Check for sideways stairs onto ice movement.
|
||||
switch (direction)
|
||||
{
|
||||
case DIR_NORTHWEST:
|
||||
case DIR_SOUTHWEST:
|
||||
direction = DIR_WEST;
|
||||
break;
|
||||
case DIR_NORTHEAST:
|
||||
case DIR_SOUTHEAST:
|
||||
direction = DIR_EAST;
|
||||
break;
|
||||
}
|
||||
|
||||
collision = CheckForPlayerAvatarCollision(direction);
|
||||
|
||||
playerAvatar->flags |= PLAYER_AVATAR_FLAG_FORCED_MOVE;
|
||||
if (collision)
|
||||
|
@ -621,7 +638,7 @@ static void PlayerNotOnBikeTurningInPlace(u8 direction, u16 heldKeys)
|
|||
static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys)
|
||||
{
|
||||
u8 collision = CheckForPlayerAvatarCollision(direction);
|
||||
|
||||
|
||||
if (collision)
|
||||
{
|
||||
if (collision == COLLISION_LEDGE_JUMP)
|
||||
|
@ -642,7 +659,7 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)
|
||||
{
|
||||
// same speed as running
|
||||
|
@ -653,13 +670,20 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys)
|
|||
if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_UNDERWATER) && (heldKeys & B_BUTTON) && FlagGet(FLAG_SYS_B_DASH)
|
||||
&& IsRunningDisallowed(gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior) == 0)
|
||||
{
|
||||
PlayerRun(direction);
|
||||
if (ObjectMovingOnRockStairs(&gObjectEvents[gPlayerAvatar.objectEventId], direction))
|
||||
PlayerRunSlow(direction);
|
||||
else
|
||||
PlayerRun(direction);
|
||||
|
||||
gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_DASH;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerWalkNormal(direction);
|
||||
if (ObjectMovingOnRockStairs(&gObjectEvents[gPlayerAvatar.objectEventId], direction))
|
||||
PlayerWalkSlow(direction);
|
||||
else
|
||||
PlayerWalkNormal(direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -670,6 +694,7 @@ static u8 CheckForPlayerAvatarCollision(u8 direction)
|
|||
|
||||
x = playerObjEvent->currentCoords.x;
|
||||
y = playerObjEvent->currentCoords.y;
|
||||
|
||||
MoveCoords(direction, &x, &y);
|
||||
return CheckForObjectEventCollision(playerObjEvent, x, y, direction, MapGridGetMetatileBehaviorAt(x, y));
|
||||
}
|
||||
|
@ -688,6 +713,8 @@ static u8 CheckForPlayerAvatarStaticCollision(u8 direction)
|
|||
u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction, u8 metatileBehavior)
|
||||
{
|
||||
u8 collision = GetCollisionAtCoords(objectEvent, x, y, direction);
|
||||
u8 currentBehavior = MapGridGetMetatileBehaviorAt(objectEvent->currentCoords.x, objectEvent->currentCoords.y);
|
||||
|
||||
if (collision == COLLISION_ELEVATION_MISMATCH && CanStopSurfing(x, y, direction))
|
||||
return COLLISION_STOP_SURFING;
|
||||
|
||||
|
@ -705,6 +732,22 @@ u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u
|
|||
return COLLISION_ROTATING_GATE;
|
||||
CheckAcroBikeCollision(x, y, metatileBehavior, &collision);
|
||||
}
|
||||
|
||||
//sideways stairs logic
|
||||
/*
|
||||
if (MetatileBehavior_IsSidewaysStairsLeftSideTop(metatileBehavior) && direction == DIR_EAST)
|
||||
return COLLISION_IMPASSABLE; //moving onto left-side top edge east from ground -> cannot move
|
||||
else if (MetatileBehavior_IsSidewaysStairsRightSideTop(metatileBehavior) && direction == DIR_WEST)
|
||||
return COLLISION_IMPASSABLE; //moving onto left-side top edge east from ground -> cannot move
|
||||
else if (MetatileBehavior_IsSidewaysStairsRightSideBottom(metatileBehavior) && (direction == DIR_EAST || direction == DIR_SOUTH))
|
||||
return COLLISION_IMPASSABLE;
|
||||
else if (MetatileBehavior_IsSidewaysStairsLeftSideBottom(metatileBehavior) && (direction == DIR_WEST || direction == DIR_SOUTH))
|
||||
return COLLISION_IMPASSABLE;
|
||||
else if ((MetatileBehavior_IsSidewaysStairsLeftSideTop(currentBehavior) || MetatileBehavior_IsSidewaysStairsRightSideTop(currentBehavior))
|
||||
&& direction == DIR_NORTH && collision == COLLISION_NONE)
|
||||
return COLLISION_IMPASSABLE; //trying to move north off of top-most tile onto same level doesn't work
|
||||
*/
|
||||
|
||||
return collision;
|
||||
}
|
||||
|
||||
|
@ -967,6 +1010,17 @@ void PlayerSetAnimId(u8 movementActionId, u8 copyableMovement)
|
|||
}
|
||||
}
|
||||
|
||||
// slow
|
||||
static void PlayerWalkSlow(u8 direction)
|
||||
{
|
||||
PlayerSetAnimId(GetWalkSlowMovementAction(direction), 2);
|
||||
}
|
||||
static void PlayerRunSlow(u8 direction)
|
||||
{
|
||||
PlayerSetAnimId(GetPlayerRunSlowMovementAction(direction), 2);
|
||||
}
|
||||
|
||||
// normal speed (1 speed)
|
||||
void PlayerWalkNormal(u8 direction)
|
||||
{
|
||||
PlayerSetAnimId(GetWalkNormalMovementAction(direction), COPY_MOVE_WALK);
|
||||
|
@ -1628,7 +1682,7 @@ static void CreateStopSurfingTask(u8 direction)
|
|||
LockPlayerFieldControls();
|
||||
Overworld_ClearSavedMusic();
|
||||
Overworld_ChangeMusicToDefault();
|
||||
gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_SURFING;
|
||||
gPlayerAvatar.flags ^= PLAYER_AVATAR_FLAG_SURFING;
|
||||
gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_ON_FOOT;
|
||||
gPlayerAvatar.preventStep = TRUE;
|
||||
taskId = CreateTask(Task_StopSurfingInit, 0xFF);
|
||||
|
@ -2422,3 +2476,71 @@ static u8 TrySpinPlayerForWarp(struct ObjectEvent *object, s16 *delayTimer)
|
|||
*delayTimer = 0;
|
||||
return sSpinDirections[object->facingDirection];
|
||||
}
|
||||
|
||||
//sideways stairs
|
||||
u8 GetRightSideStairsDirection(u8 direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case DIR_WEST:
|
||||
return DIR_NORTHWEST;
|
||||
case DIR_EAST:
|
||||
return DIR_SOUTHEAST;
|
||||
default:
|
||||
if (direction > DIR_EAST)
|
||||
direction -= DIR_EAST;
|
||||
|
||||
return direction;
|
||||
}
|
||||
}
|
||||
|
||||
u8 GetLeftSideStairsDirection(u8 direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case DIR_WEST:
|
||||
return DIR_SOUTHWEST;
|
||||
case DIR_EAST:
|
||||
return DIR_NORTHEAST;
|
||||
default:
|
||||
if (direction > DIR_EAST)
|
||||
direction -= DIR_EAST;
|
||||
|
||||
return direction;
|
||||
}
|
||||
}
|
||||
|
||||
bool8 ObjectMovingOnRockStairs(struct ObjectEvent *objectEvent, u8 direction)
|
||||
{
|
||||
#if SLOW_MOVEMENT_ON_STAIRS == TRUE
|
||||
s16 x = objectEvent->currentCoords.x;
|
||||
s16 y = objectEvent->currentCoords.y;
|
||||
|
||||
// TODO followers on sideways stairs
|
||||
if (IsFollowerVisible() && (objectEvent->isPlayer || objectEvent->localId == OBJ_EVENT_ID_FOLLOWER))
|
||||
return FALSE;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case DIR_NORTH:
|
||||
return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x,y));
|
||||
case DIR_SOUTH:
|
||||
MoveCoords(DIR_SOUTH, &x, &y);
|
||||
return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x,y));
|
||||
case DIR_WEST:
|
||||
case DIR_EAST:
|
||||
case DIR_NORTHEAST:
|
||||
case DIR_NORTHWEST:
|
||||
case DIR_SOUTHWEST:
|
||||
case DIR_SOUTHEAST:
|
||||
// directionOverwrite is only used for sideways stairs motion
|
||||
if (objectEvent->directionOverwrite)
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -66,8 +66,13 @@ static const u8 sTileBitAttributes[NUM_METATILE_BEHAVIORS] =
|
|||
[MB_SLIDE_NORTH] = TILE_FLAG_UNUSED,
|
||||
[MB_SLIDE_SOUTH] = TILE_FLAG_UNUSED,
|
||||
[MB_TRICK_HOUSE_PUZZLE_8_FLOOR] = TILE_FLAG_UNUSED,
|
||||
[MB_UNUSED_49] = TILE_FLAG_UNUSED,
|
||||
[MB_UNUSED_4A] = TILE_FLAG_UNUSED,
|
||||
[MB_SIDEWAYS_STAIRS_RIGHT_SIDE] = TILE_FLAG_UNUSED,
|
||||
[MB_SIDEWAYS_STAIRS_LEFT_SIDE] = TILE_FLAG_UNUSED,
|
||||
[MB_SIDEWAYS_STAIRS_RIGHT_SIDE_TOP] = TILE_FLAG_UNUSED,
|
||||
[MB_SIDEWAYS_STAIRS_LEFT_SIDE_TOP] = TILE_FLAG_UNUSED,
|
||||
[MB_SIDEWAYS_STAIRS_RIGHT_SIDE_BOTTOM] = TILE_FLAG_UNUSED,
|
||||
[MB_SIDEWAYS_STAIRS_LEFT_SIDE_BOTTOM] = TILE_FLAG_UNUSED,
|
||||
[MB_ROCK_STAIRS] = TILE_FLAG_UNUSED,
|
||||
[MB_EASTWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE,
|
||||
[MB_WESTWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE,
|
||||
[MB_NORTHWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE,
|
||||
|
@ -1400,3 +1405,81 @@ bool8 MetatileBehavior_IsTrainerHillTimer(u8 metatileBehavior)
|
|||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MetatileBehavior_IsSidewaysStairsRightSide(u8 metatileBehavior)
|
||||
{
|
||||
if (metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE || metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE_BOTTOM)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MetatileBehavior_IsSidewaysStairsLeftSide(u8 metatileBehavior)
|
||||
{
|
||||
if (metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE || metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE_BOTTOM)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MetatileBehavior_IsSidewaysStairsRightSideTop(u8 metatileBehavior)
|
||||
{
|
||||
if (metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE_TOP)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MetatileBehavior_IsSidewaysStairsLeftSideTop(u8 metatileBehavior)
|
||||
{
|
||||
if (metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE_TOP)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MetatileBehavior_IsSidewaysStairsRightSideBottom(u8 metatileBehavior)
|
||||
{
|
||||
if (metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE_BOTTOM)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MetatileBehavior_IsSidewaysStairsLeftSideBottom(u8 metatileBehavior)
|
||||
{
|
||||
if (metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE_BOTTOM)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MetatileBehavior_IsSidewaysStairsRightSideAny(u8 metatileBehavior)
|
||||
{
|
||||
if (metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE
|
||||
|| metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE_BOTTOM
|
||||
|| metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE_TOP)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MetatileBehavior_IsSidewaysStairsLeftSideAny(u8 metatileBehavior)
|
||||
{
|
||||
if (metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE
|
||||
|| metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE_BOTTOM
|
||||
|| metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE_TOP)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MetatileBehavior_IsRockStairs(u8 metatileBehavior)
|
||||
{
|
||||
if (metatileBehavior == MB_ROCK_STAIRS)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1008,6 +1008,8 @@ bool8 ScrCmd_applymovement(struct ScriptContext *ctx)
|
|||
ClearObjectEventMovement(objEvent, &gSprites[objEvent->spriteId]);
|
||||
gSprites[objEvent->spriteId].animCmdIndex = 0; // Reset start frame of animation
|
||||
}
|
||||
|
||||
gObjectEvents[GetObjectEventIdByLocalId(localId)].directionOverwrite = DIR_NONE;
|
||||
ScriptMovement_StartObjectMovementScript(localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, movementScript);
|
||||
sMovingNpcId = localId;
|
||||
objEvent = GetFollowerObject();
|
||||
|
@ -1032,6 +1034,7 @@ bool8 ScrCmd_applymovementat(struct ScriptContext *ctx)
|
|||
u8 mapGroup = ScriptReadByte(ctx);
|
||||
u8 mapNum = ScriptReadByte(ctx);
|
||||
|
||||
gObjectEvents[GetObjectEventIdByLocalId(localId)].directionOverwrite = DIR_NONE;
|
||||
ScriptMovement_StartObjectMovementScript(localId, mapNum, mapGroup, movementScript);
|
||||
sMovingNpcId = localId;
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in a new issue