Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaned up matching function #633

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ typedef enum {
SURFACE_AUTO_LADDER,
SURFACE_CLIMB_WALL,
SURFACE_2C,
SURFACE_FF = 0xff,
} SurfaceType;

typedef enum {
Expand Down
9 changes: 9 additions & 0 deletions include/tiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ typedef enum {
CUT_TREE = 0x1F,
ROCK = 0x55,
CHEST = 0x73,
CHEST_OPEN = 0x74,
TORCH = 0x76,
TORCH_LIT = 0x77,
PRESSURE_BUTTON = 0x78,
PRESSURE_BUTTON_PRESSED = 0x79,
PRESSURE_SQUARE = 0x7a,
PRESSURE_SQUARE_PRESSED = 0x7b,
STAIRS_UP = 0x92,
STAIRS_DOWN = 0x93,
SIGNPOST = 0x176,
PERMA_ROCK = 0x1D3,
PERMA_ROCK2 = 0x1D4,
Expand Down
56 changes: 27 additions & 29 deletions src/playerUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ void sub_08078FB0(Entity* this) {
if (gPlayerState.flags & PL_MINISH) {
animIndex = 0x18;
} else {
if (gPlayerState.animation >> 8 == 7) {
if (gPlayerState.animation >> 8 == (ANIM_PORTAL_ACTIVATE >> 8)) {
animIndex = 0x34;
} else {
animIndex = 0xb8;
Expand Down Expand Up @@ -1691,40 +1691,38 @@ void sub_080792BC(s32 speed, u32 direction, u32 field_0x38) {
void sub_080792D8(void) {
Entity* playerEntity = &gPlayerEntity;

if (playerEntity->knockbackDuration != 0) {
if (((((playerEntity->action == 0xb) || (gPlayerState.dash_state != 0)) ||
((u8)(gPlayerState.heldObject - 1) < 4)) ||
(((gPlayerState.jump_status != 0 || (gPlayerState.floor_type == 0xff)) ||
(((gPlayerState.field_0x7 & 0x80) != 0 ||
((0 < (s32)((gPlayerState.swim_state & 0xf) - 1) || (playerEntity->action == 3)))))))) ||
((gPlayerState.flags & 0x40000) != 0)) {
playerEntity->knockbackDuration = 0;
} else if ((playerEntity->action == 0x1d) && (playerEntity->knockbackDirection != 0x10)) {
playerEntity->knockbackDuration = 0;
if (playerEntity->knockbackDuration == 0)
return;

if (playerEntity->action == PLAYER_08071DB8 || gPlayerState.dash_state || (u8)(gPlayerState.heldObject - 1) < 4 ||
gPlayerState.jump_status || gPlayerState.floor_type == SURFACE_FF || gPlayerState.field_0x7 & 0x80 ||
0 < (gPlayerState.swim_state & 0xf) - 1 || playerEntity->action == PLAYER_FALL ||
gPlayerState.flags & PL_ROLLING) {
playerEntity->knockbackDuration = 0;
} else if (playerEntity->action == PLAYER_CLIMB && playerEntity->knockbackDirection != DirectionSouth) {
playerEntity->knockbackDuration = 0;
} else {
if ((s8)playerEntity->knockbackDuration >= 1) {
playerEntity->knockbackDuration--;
} else {
playerEntity->knockbackDuration++;
}

if ((s8)(playerEntity->knockbackDuration) >= 1) {
playerEntity->knockbackDuration--;
if (playerEntity->knockbackDuration == 0)
return;

gPlayerState.field_0x7 &= 0xdf;
if (0 < playerEntity->iframes && !gPlayerState.swim_state && !(gPlayerState.flags & PL_MINISH) &&
!gPlayerState.jump_status) {
ResetActiveItems();
if (!(gPlayerState.flags & PL_NO_CAP)) {
gPlayerState.animation = ANIM_BOUNCE;
} else {
playerEntity->knockbackDuration++;
}
if (playerEntity->knockbackDuration != 0) {
gPlayerState.field_0x7 &= 0xdf;
if ((((0 < playerEntity->iframes) && (gPlayerState.swim_state == 0)) &&
((gPlayerState.flags & 0x80) == 0)) &&
gPlayerState.jump_status == 0) {
ResetActiveItems();
if ((gPlayerState.flags & 8) == 0) {
gPlayerState.animation = 0x114;
} else {
gPlayerState.animation = 0x418;
}
}
sub_080027EA(playerEntity, 0x280, playerEntity->knockbackDirection);
sub_0807A5B8(playerEntity->knockbackDirection);
gPlayerState.animation = ANIM_BOUNCE_NOCAP;
}
}
sub_080027EA(playerEntity, 0x280, playerEntity->knockbackDirection);
sub_0807A5B8(playerEntity->knockbackDirection);
}
}

Expand Down
Loading