diff --git a/include/player.h b/include/player.h index 6cfd1383..a003a610 100644 --- a/include/player.h +++ b/include/player.h @@ -209,6 +209,7 @@ typedef enum { SURFACE_AUTO_LADDER, SURFACE_CLIMB_WALL, SURFACE_2C, + SURFACE_FF = 0xff, } SurfaceType; typedef enum { diff --git a/include/tiles.h b/include/tiles.h index 9915face..1d3cac90 100644 --- a/include/tiles.h +++ b/include/tiles.h @@ -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, diff --git a/src/playerUtils.c b/src/playerUtils.c index 5a3c0225..7eacb048 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -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; @@ -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); } }