diff --git a/include/z64player.h b/include/z64player.h index a231544879..7b8445beae 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -459,8 +459,16 @@ typedef enum { /* 0x67 */ PLAYER_CSMODE_MAX } PlayerCutsceneMode; +typedef enum { + /* 0 */ PLAYER_LEDGE_CLIMB_NONE, + /* 1 */ PLAYER_LEDGE_CLIMB_1, + /* 2 */ PLAYER_LEDGE_CLIMB_2, + /* 3 */ PLAYER_LEDGE_CLIMB_3, + /* 4 */ PLAYER_LEDGE_CLIMB_4 +} PlayerLedgeClimbType; + typedef struct { - /* 0x00 */ f32 unk_00; + /* 0x00 */ f32 ceilingCheckHeight; /* 0x04 */ f32 unk_04; /* 0x08 */ f32 unk_08; /* 0x0C */ f32 unk_0C; @@ -474,7 +482,7 @@ typedef struct { /* 0x2C */ f32 unk_2C; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; - /* 0x38 */ f32 unk_38; + /* 0x38 */ f32 wallCheckRadius; /* 0x3C */ f32 unk_3C; /* 0x40 */ f32 unk_40; /* 0x44 */ Vec3s unk_44; @@ -501,6 +509,8 @@ typedef struct { /* 0x10 */ Vec3f base; } WeaponInfo; // size = 0x1C +#define LEDGE_DIST_MAX 399.96002f + #define PLAYER_STATE1_0 (1 << 0) #define PLAYER_STATE1_SWINGING_BOTTLE (1 << 1) #define PLAYER_STATE1_2 (1 << 2) @@ -543,7 +553,7 @@ typedef struct { #define PLAYER_STATE2_6 (1 << 6) #define PLAYER_STATE2_7 (1 << 7) #define PLAYER_STATE2_8 (1 << 8) -#define PLAYER_STATE2_9 (1 << 9) +#define PLAYER_STATE2_FORCE_SAND_FLOOR_SOUND (1 << 9) #define PLAYER_STATE2_10 (1 << 10) #define PLAYER_STATE2_11 (1 << 11) #define PLAYER_STATE2_12 (1 << 12) @@ -713,10 +723,10 @@ typedef struct Player { /* 0x087C */ s16 unk_87C; /* 0x087E */ s16 unk_87E; /* 0x0880 */ f32 unk_880; - /* 0x0884 */ f32 wallHeight; // height used to determine whether link can climb or grab a ledge at the top - /* 0x0888 */ f32 wallDistance; // distance to the colliding wall plane - /* 0x088C */ u8 unk_88C; - /* 0x088D */ u8 unk_88D; + /* 0x0884 */ f32 yDistToLedge; // y distance to ground above an interact wall. LEDGE_DIST_MAX if no ground is found + /* 0x0888 */ f32 distToInteractWall; // xyz distance to the interact wall + /* 0x088C */ u8 ledgeClimbType; + /* 0x088D */ u8 ledgeClimbDelayTimer; /* 0x088E */ u8 unk_88E; /* 0x088F */ u8 unk_88F; /* 0x0890 */ u8 unk_890; @@ -725,8 +735,8 @@ typedef struct Player { /* 0x0893 */ u8 hoverBootsTimer; /* 0x0894 */ s16 fallStartHeight; // last truncated Y position before falling /* 0x0896 */ s16 fallDistance; // truncated Y distance the player has fallen so far (positive is down) - /* 0x0898 */ s16 unk_898; - /* 0x089A */ s16 unk_89A; + /* 0x0898 */ s16 floorPitch; // angle of the floor slope in the direction of current world yaw (positive for ascending slope) + /* 0x089A */ s16 floorPitchAlt; // the calculation for this value is bugged and doesn't represent anything meaningful /* 0x089C */ s16 unk_89C; /* 0x089E */ u16 floorSfxOffset; /* 0x08A0 */ u8 unk_8A0; @@ -745,9 +755,9 @@ typedef struct Player { /* 0x0A73 */ u8 unk_A73; /* 0x0A74 */ PlayerFuncA74 func_A74; /* 0x0A78 */ s8 invincibilityTimer; // prevents damage when nonzero (positive = visible, counts towards zero each frame) - /* 0x0A79 */ u8 unk_A79; - /* 0x0A7A */ u8 unk_A7A; - /* 0x0A7B */ u8 unk_A7B; + /* 0x0A79 */ u8 floorTypeTimer; // counts up every frame the current floor type is the same as the last frame + /* 0x0A7A */ u8 floorProperty; + /* 0x0A7B */ u8 prevFloorType; /* 0x0A7C */ f32 unk_A7C; /* 0x0A80 */ s16 unk_A80; /* 0x0A82 */ u16 prevFloorSfxOffset; diff --git a/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c b/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c index 8146c75c32..51eedf4ed5 100644 --- a/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c +++ b/src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c @@ -60,7 +60,7 @@ void func_8087B758(BgHaka* this, Player* player) { func_8002DBD0(&this->dyna.actor, &sp1C, &player->actor.world.pos); if (fabsf(sp1C.x) < 34.6f && sp1C.z > -112.8f && sp1C.z < -36.0f) { - player->stateFlags2 |= PLAYER_STATE2_9; + player->stateFlags2 |= PLAYER_STATE2_FORCE_SAND_FLOOR_SOUND; } } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index a02a588eee..a56a1e42fa 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -347,7 +347,7 @@ void func_80853148(PlayState* play, Actor* actor); // .bss part 1 static s32 D_80858AA0; static s32 D_80858AA4; -static Vec3f D_80858AA8; +static Vec3f sInteractWallCheckResult; static Input* sControlInput; // .data @@ -356,7 +356,7 @@ static u8 D_80853410[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, static PlayerAgeProperties sAgeProperties[] = { { - 56.0f, // unk_00 + 56.0f, // ceilingCheckHeight 90.0f, // unk_04 1.0f, // unk_08 111.0f, // unk_0C @@ -370,7 +370,7 @@ static PlayerAgeProperties sAgeProperties[] = { 56.0f, // unk_2C 68.0f, // unk_30 70.0f, // unk_34 - 18.0f, // unk_38 + 18.0f, // wallCheckRadius 15.0f, // unk_3C 70.0f, // unk_40 { 9, 4671, 359 }, // unk_44 @@ -408,7 +408,7 @@ static PlayerAgeProperties sAgeProperties[] = { { &gPlayerAnim_link_normal_climb_endBR, &gPlayerAnim_link_normal_climb_endBL }, // unk_CC }, { - 40.0f, // unk_00 + 40.0f, // ceilingCheckHeight 60.0f, // unk_04 11.0f / 17.0f, // unk_08 71.0f, // unk_0C @@ -422,7 +422,7 @@ static PlayerAgeProperties sAgeProperties[] = { 32.0f, // unk_2C 48.0f, // unk_30 70.0f * (11.0f / 17.0f), // unk_34 - 14.0f, // unk_38 + 14.0f, // wallCheckRadius 12.0f, // unk_3C 55.0f, // unk_40 { -24, 3565, 876 }, // unk_44 @@ -466,18 +466,18 @@ static f32 D_808535D4 = 0.0f; static s16 D_808535D8 = 0; static s16 D_808535DC = 0; static s32 D_808535E0 = 0; -static s32 D_808535E4 = FLOOR_TYPE_0; +static s32 sFloorType = FLOOR_TYPE_0; static f32 D_808535E8 = 1.0f; static f32 D_808535EC = 1.0f; -static u32 sInteractWallFlags = 0; -static u32 sConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; +static u32 sTouchedWallFlags = 0; +static u32 sConveyorSpeed = CONVEYOR_SPEED_DISABLED; static s16 sIsFloorConveyor = false; static s16 sConveyorYaw = 0; -static f32 D_80853600 = 0.0f; -static s32 D_80853604 = FLOOR_PROPERTY_0; -static s32 D_80853608 = 0; -static s32 D_8085360C = 0; -static s16 D_80853610 = 0; +static f32 sYDistToFloor = 0.0f; +static s32 sPrevFloorProperty = FLOOR_PROPERTY_0; // floor property from the previous frame +static s32 sShapeYawToTouchedWall = 0; +static s32 sWorldYawToTouchedWall = 0; +static s16 sFloorShapePitch = 0; static s32 D_80853614 = 0; static s32 D_80853618 = 0; @@ -2896,7 +2896,7 @@ void func_808355DC(Player* this) { this->stateFlags1 |= PLAYER_STATE1_17; if (!(this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_7) && - (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (D_80853608 < 0x2000)) { + (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (sShapeYawToTouchedWall < 0x2000)) { this->yaw = this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; } @@ -3517,7 +3517,7 @@ s32 func_80836FAC(PlayState* play, Player* this, f32* arg2, s16* arg3, f32 arg4) } if (D_808535D4 != 0.0f) { - temp_f0 = Math_SinS(this->unk_898); + temp_f0 = Math_SinS(this->floorPitch); temp_f12 = this->unk_880; temp_f14 = CLAMP(temp_f0, 0.0f, 0.6f); @@ -4059,7 +4059,7 @@ s32 func_808382DC(Player* this, PlayState* play) { } else { sp68 = ((Player_GetHeight(this) - 8.0f) < (this->unk_6C4 * this->actor.scale.y)); - if (sp68 || (this->actor.bgCheckFlags & BGCHECKFLAG_CRUSHED) || (D_808535E4 == FLOOR_TYPE_9) || + if (sp68 || (this->actor.bgCheckFlags & BGCHECKFLAG_CRUSHED) || (sFloorType == FLOOR_TYPE_9) || (this->stateFlags2 & PLAYER_STATE2_31)) { func_80832698(this, NA_SE_VO_LI_DAMAGE_S); @@ -4183,15 +4183,15 @@ s32 func_808382DC(Player* this, PlayState* play) { return 0; } else { static u8 D_808544F4[] = { 120, 60 }; - s32 sp48 = func_80838144(D_808535E4); + s32 sp48 = func_80838144(sFloorType); if (((this->actor.wallPoly != NULL) && func_80042108(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId)) || ((sp48 >= 0) && func_80042108(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) && - (this->unk_A79 >= D_808544F4[sp48])) || + (this->floorTypeTimer >= D_808544F4[sp48])) || ((sp48 >= 0) && - ((this->currentTunic != PLAYER_TUNIC_GORON) || (this->unk_A79 >= D_808544F4[sp48])))) { - this->unk_A79 = 0; + ((this->currentTunic != PLAYER_TUNIC_GORON) || (this->floorTypeTimer >= D_808544F4[sp48])))) { + this->floorTypeTimer = 0; this->actor.colChkInfo.damage = 4; func_80837C0C(play, this, 0, 4.0f, 5.0f, this->actor.shape.rot.y, 20); } else { @@ -4234,31 +4234,32 @@ s32 func_80838A14(Player* this, PlayState* play) { f32 wallPolyNormalZ; f32 sp24; - if (!(this->stateFlags1 & PLAYER_STATE1_11) && (this->unk_88C >= 2) && - (!(this->stateFlags1 & PLAYER_STATE1_27) || (this->ageProperties->unk_14 > this->wallHeight))) { + if (!(this->stateFlags1 & PLAYER_STATE1_11) && (this->ledgeClimbType >= PLAYER_LEDGE_CLIMB_2) && + (!(this->stateFlags1 & PLAYER_STATE1_27) || (this->ageProperties->unk_14 > this->yDistToLedge))) { sp3C = 0; if (func_808332B8(this)) { if (this->actor.yDistToWater < 50.0f) { - if ((this->unk_88C < 2) || (this->wallHeight > this->ageProperties->unk_10)) { + if ((this->ledgeClimbType < PLAYER_LEDGE_CLIMB_2) || + (this->yDistToLedge > this->ageProperties->unk_10)) { return 0; } - } else if ((this->currentBoots != PLAYER_BOOTS_IRON) || (this->unk_88C > 2)) { + } else if ((this->currentBoots != PLAYER_BOOTS_IRON) || (this->ledgeClimbType > PLAYER_LEDGE_CLIMB_2)) { return 0; } } else if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || - ((this->ageProperties->unk_14 <= this->wallHeight) && (this->stateFlags1 & PLAYER_STATE1_27))) { + ((this->ageProperties->unk_14 <= this->yDistToLedge) && (this->stateFlags1 & PLAYER_STATE1_27))) { return 0; } - if ((this->actor.wallBgId != BGCHECK_SCENE) && (sInteractWallFlags & WALL_FLAG_6)) { - if (this->unk_88D >= 6) { + if ((this->actor.wallBgId != BGCHECK_SCENE) && (sTouchedWallFlags & WALL_FLAG_6)) { + if (this->ledgeClimbDelayTimer >= 6) { this->stateFlags2 |= PLAYER_STATE2_2; if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { sp3C = 1; } } - } else if ((this->unk_88D >= 6) || CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { + } else if ((this->ledgeClimbDelayTimer >= 6) || CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { sp3C = 1; } @@ -4267,7 +4268,7 @@ s32 func_80838A14(Player* this, PlayState* play) { this->stateFlags1 |= PLAYER_STATE1_18; - sp34 = this->wallHeight; + sp34 = this->yDistToLedge; if (this->ageProperties->unk_14 <= sp34) { anim = &gPlayerAnim_link_normal_250jump_start; @@ -4275,7 +4276,7 @@ s32 func_80838A14(Player* this, PlayState* play) { } else { wallPolyNormalX = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); wallPolyNormalZ = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); - sp24 = this->wallDistance + 0.5f; + sp24 = this->distToInteractWall + 0.5f; this->stateFlags1 |= PLAYER_STATE1_14; @@ -4294,7 +4295,7 @@ s32 func_80838A14(Player* this, PlayState* play) { this->actor.shape.yOffset -= sp34 * 100.0f; this->actor.world.pos.x -= sp24 * wallPolyNormalX; - this->actor.world.pos.y += this->wallHeight; + this->actor.world.pos.y += this->yDistToLedge; this->actor.world.pos.z -= sp24 * wallPolyNormalZ; func_80832224(this); @@ -4309,8 +4310,9 @@ s32 func_80838A14(Player* this, PlayState* play) { return 1; } - } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->unk_88C == 1) && (this->unk_88D >= 3)) { - temp = (this->wallHeight * 0.08f) + 5.5f; + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->ledgeClimbType == PLAYER_LEDGE_CLIMB_1) && + (this->ledgeClimbDelayTimer >= 3)) { + temp = (this->yDistToLedge * 0.08f) + 5.5f; func_808389E8(this, &gPlayerAnim_link_normal_jump, temp, play); this->speedXZ = 2.5f; @@ -4411,7 +4413,7 @@ u8 sReturnEntranceGroupIndices[] = { 0, // ENTR_RETURN_GREAT_FAIRYS_FOUNTAIN_MAGIC }; -s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) { +s32 Player_HandleExitsAndVoids(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) { s32 exitIndex; s32 temp; s32 sp34; @@ -4424,12 +4426,12 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) if (!(this->stateFlags1 & PLAYER_STATE1_7) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (this->csMode == PLAYER_CSMODE_NONE) && !(this->stateFlags1 & PLAYER_STATE1_0) && (((poly != NULL) && (exitIndex = SurfaceType_GetExitIndex(&play->colCtx, poly, bgId), exitIndex != 0)) || - (func_8083816C(D_808535E4) && (this->unk_A7A == FLOOR_PROPERTY_12)))) { + (func_8083816C(sFloorType) && (this->floorProperty == FLOOR_PROPERTY_12)))) { sp34 = this->unk_A84 - (s32)this->actor.world.pos.y; if (!(this->stateFlags1 & (PLAYER_STATE1_23 | PLAYER_STATE1_27 | PLAYER_STATE1_29)) && - !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (sp34 < 100) && (D_80853600 > 100.0f)) { + !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (sp34 < 100) && (sYDistToFloor > 100.0f)) { return 0; } @@ -4488,7 +4490,7 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) gSaveContext.entranceSpeed = speedXZ; } - if (sConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) { + if (sConveyorSpeed != CONVEYOR_SPEED_DISABLED) { yaw = sConveyorYaw; } else { yaw = this->actor.world.rot.y; @@ -4510,13 +4512,13 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) if (play->transitionTrigger == TRANS_TRIGGER_OFF) { if ((this->actor.world.pos.y < -4000.0f) || - (((this->unk_A7A == FLOOR_PROPERTY_5) || (this->unk_A7A == FLOOR_PROPERTY_12)) && - ((D_80853600 < 100.0f) || (this->fallDistance > 400.0f) || + (((this->floorProperty == FLOOR_PROPERTY_5) || (this->floorProperty == FLOOR_PROPERTY_12)) && + ((sYDistToFloor < 100.0f) || (this->fallDistance > 400.0f) || ((play->sceneId != SCENE_SHADOW_TEMPLE) && (this->fallDistance > 200.0f)))) || ((play->sceneId == SCENE_GANONS_TOWER_COLLAPSE_EXTERIOR) && (this->fallDistance > 320.0f))) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - if (this->unk_A7A == FLOOR_PROPERTY_5) { + if (this->floorProperty == FLOOR_PROPERTY_5) { Play_TriggerRespawn(play); } else { Play_TriggerVoidOut(play); @@ -4526,7 +4528,7 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) } else { func_80838F5C(play, this); this->unk_850 = 9999; - if (this->unk_A7A == FLOOR_PROPERTY_5) { + if (this->floorProperty == FLOOR_PROPERTY_5) { this->unk_84F = -1; } else { this->unk_84F = 1; @@ -4542,25 +4544,30 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) return 0; } -void func_808395DC(Player* this, Vec3f* arg1, Vec3f* arg2, Vec3f* arg3) { +/** + * Gets a position relative to player's yaw. + * An offset is applied to the provided base position in the direction of shape y rotation. + * The resulting position is stored in `dest` + */ +void Player_GetRelativePosition(Player* this, Vec3f* base, Vec3f* offset, Vec3f* dest) { f32 cos = Math_CosS(this->actor.shape.rot.y); f32 sin = Math_SinS(this->actor.shape.rot.y); - arg3->x = arg1->x + ((arg2->x * cos) + (arg2->z * sin)); - arg3->y = arg1->y + arg2->y; - arg3->z = arg1->z + ((arg2->z * cos) - (arg2->x * sin)); + dest->x = base->x + ((offset->x * cos) + (offset->z * sin)); + dest->y = base->y + offset->y; + dest->z = base->z + ((offset->z * cos) - (offset->x * sin)); } Actor* Player_SpawnFairy(PlayState* play, Player* this, Vec3f* arg2, Vec3f* arg3, s32 type) { Vec3f pos; - func_808395DC(this, arg2, arg3, &pos); + Player_GetRelativePosition(this, arg2, arg3, &pos); return Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, pos.x, pos.y, pos.z, 0, 0, 0, type); } f32 func_808396F4(PlayState* play, Player* this, Vec3f* arg2, Vec3f* arg3, CollisionPoly** arg4, s32* arg5) { - func_808395DC(this, &this->actor.world.pos, arg2, arg3); + Player_GetRelativePosition(this, &this->actor.world.pos, arg2, arg3); return BgCheck_EntityRaycastDown3(&play->colCtx, arg4, arg5, arg3); } @@ -4572,17 +4579,25 @@ f32 func_8083973C(PlayState* play, Player* this, Vec3f* arg2, Vec3f* arg3) { return func_808396F4(play, this, arg2, arg3, &sp24, &sp20); } -s32 func_80839768(PlayState* play, Player* this, Vec3f* arg2, CollisionPoly** arg3, s32* arg4, Vec3f* arg5) { - Vec3f sp44; - Vec3f sp38; +/** + * Checks if a line between the player's position and the provided `offset` intersect a wall. + * + * Point A of the line is at player's world position offset by the height provided in `offset`. + * Point B of the line is at player's world position offset by the entire `offset` vector. + * Point A and B are always at the same height, meaning this is a horizontal line test. + */ +s32 Player_PosVsWallLineTest(PlayState* play, Player* this, Vec3f* offset, CollisionPoly** wallPoly, s32* bgId, + Vec3f* posResult) { + Vec3f posA; + Vec3f posB; - sp44.x = this->actor.world.pos.x; - sp44.y = this->actor.world.pos.y + arg2->y; - sp44.z = this->actor.world.pos.z; + posA.x = this->actor.world.pos.x; + posA.y = this->actor.world.pos.y + offset->y; + posA.z = this->actor.world.pos.z; - func_808395DC(this, &this->actor.world.pos, arg2, &sp38); + Player_GetRelativePosition(this, &this->actor.world.pos, offset, &posB); - return BgCheck_EntityLineTest1(&play->colCtx, &sp44, &sp38, arg5, arg3, true, false, false, true, arg4); + return BgCheck_EntityLineTest1(&play->colCtx, &posA, &posB, posResult, wallPoly, true, false, false, true, bgId); } s32 func_80839800(Player* this, PlayState* play) { @@ -4725,7 +4740,7 @@ s32 func_80839800(Player* this, PlayState* play) { BgCheck_EntityRaycastDown1(&play->colCtx, &groundPoly, &checkPos); //! @bug groundPoly's bgId is not guaranteed to be BGCHECK_SCENE - if (func_80839034(play, this, groundPoly, BGCHECK_SCENE)) { + if (Player_HandleExitsAndVoids(play, this, groundPoly, BGCHECK_SCENE)) { gSaveContext.entranceSpeed = 2.0f; gSaveContext.entranceSound = NA_SE_OC_DOOR_OPEN; } @@ -4963,7 +4978,10 @@ s32 func_8083A6AC(Player* this, PlayState* play) { Vec3f sp68; f32 temp1; - if ((this->actor.yDistToWater < -80.0f) && (ABS(this->unk_898) < 2730) && (ABS(this->unk_89A) < 2730)) { + //! @bug `floorPitch` and `floorPitchAlt` are cleared to 0 before this function is called, because the player + //! left the ground. The angles will always be zero and therefore will always pass these checks. + //! The intention seems to be to prevent ledge hanging or vine grabbing when walking off of a steep enough slope. + if ((this->actor.yDistToWater < -80.0f) && (ABS(this->floorPitch) < 0xAAA) && (ABS(this->floorPitchAlt) < 0xAAA)) { sp74.x = this->actor.prevPos.x - this->actor.world.pos.x; sp74.z = this->actor.prevPos.z - this->actor.world.pos.z; @@ -4989,7 +5007,7 @@ s32 func_8083A6AC(Player* this, PlayState* play) { sp54 = Math3D_UDistPlaneToPos(nx, ny, nz, sp84->dist, &this->actor.world.pos); - sp50 = D_80853604 == FLOOR_PROPERTY_6; + sp50 = (sPrevFloorProperty == FLOOR_PROPERTY_6); if (!sp50 && (SurfaceType_GetWallFlags(&play->colCtx, sp84, sp80) & WALL_FLAG_3)) { sp50 = 1; } @@ -5045,7 +5063,7 @@ void func_8083AA10(Player* this, PlayState* play) { if (!(this->stateFlags1 & (PLAYER_STATE1_27 | PLAYER_STATE1_29)) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { if (!func_80838FB8(play, this)) { - if (D_80853604 == FLOOR_PROPERTY_8) { + if (sPrevFloorProperty == FLOOR_PROPERTY_8) { this->actor.world.pos.x = this->actor.prevPos.x; this->actor.world.pos.z = this->actor.prevPos.z; return; @@ -5054,7 +5072,7 @@ void func_8083AA10(Player* this, PlayState* play) { if (!(this->stateFlags3 & PLAYER_STATE3_1) && !(this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_7) && (func_8084411C != this->func_674) && (func_80844A44 != this->func_674)) { - if ((D_80853604 == FLOOR_PROPERTY_7) || (this->meleeWeaponState != 0)) { + if ((sPrevFloorProperty == FLOOR_PROPERTY_7) || (this->meleeWeaponState != 0)) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); Player_ZeroSpeedXZ(this); return; @@ -5062,7 +5080,7 @@ void func_8083AA10(Player* this, PlayState* play) { if (this->hoverBootsTimer != 0) { this->actor.velocity.y = 1.0f; - D_80853604 = FLOOR_PROPERTY_9; + sPrevFloorProperty = FLOOR_PROPERTY_9; return; } @@ -5074,10 +5092,11 @@ void func_8083AA10(Player* this, PlayState* play) { this->floorSfxOffset = this->prevFloorSfxOffset; if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_LEAVE) && !(this->stateFlags1 & PLAYER_STATE1_27) && - (D_80853604 != FLOOR_PROPERTY_6) && (D_80853604 != FLOOR_PROPERTY_9) && (D_80853600 > 20.0f) && - (this->meleeWeaponState == 0) && (ABS(sp5C) < 0x2000) && (this->speedXZ > 3.0f)) { + (sPrevFloorProperty != FLOOR_PROPERTY_6) && (sPrevFloorProperty != FLOOR_PROPERTY_9) && + (sYDistToFloor > 20.0f) && (this->meleeWeaponState == 0) && (ABS(sp5C) < 0x2000) && + (this->speedXZ > 3.0f)) { - if ((D_80853604 == FLOOR_PROPERTY_11) && !(this->stateFlags1 & PLAYER_STATE1_11)) { + if ((sPrevFloorProperty == FLOOR_PROPERTY_11) && !(this->stateFlags1 & PLAYER_STATE1_11)) { sp40 = func_808396F4(play, this, &D_8085451C, &sp44, &sp58, &sp54); sp3C = this->actor.world.pos.y; @@ -5093,8 +5112,7 @@ void func_8083AA10(Player* this, PlayState* play) { func_8083A4A8(this, play); return; } - - if ((D_80853604 == FLOOR_PROPERTY_9) || (D_80853600 <= this->ageProperties->unk_34) || + if ((sPrevFloorProperty == FLOOR_PROPERTY_9) || (sYDistToFloor <= this->ageProperties->unk_34) || !func_8083A6AC(this, play)) { Player_AnimPlayLoop(play, this, &gPlayerAnim_link_normal_landing_wait); return; @@ -5495,7 +5513,7 @@ s32 func_8083BB20(Player* this) { } s32 func_8083BBA0(Player* this, PlayState* play) { - if (func_8083BB20(this) && (D_808535E4 != FLOOR_TYPE_7)) { + if (func_8083BB20(this) && (sFloorType != FLOOR_TYPE_7)) { func_8083BA90(play, this, PLAYER_MWA_JUMPSLASH_START, 3.0f, 4.5f); return 1; } @@ -5511,7 +5529,7 @@ void func_8083BC04(Player* this, PlayState* play) { } s32 func_8083BC7C(Player* this, PlayState* play) { - if ((this->unk_84B[this->unk_846] == 0) && (D_808535E4 != FLOOR_TYPE_7)) { + if ((this->unk_84B[this->unk_846] == 0) && (sFloorType != FLOOR_TYPE_7)) { func_8083BC04(this, play); return 1; } @@ -5539,7 +5557,7 @@ s32 func_8083BDBC(Player* this, PlayState* play) { s32 sp2C; if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && - (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && (D_808535E4 != FLOOR_TYPE_7) && + (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && (sFloorType != FLOOR_TYPE_7) && (SurfaceType_GetFloorEffect(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) != FLOOR_EFFECT_1)) { sp2C = this->unk_84B[this->unk_846]; @@ -6112,11 +6130,11 @@ void func_8083D6EC(PlayState* play, Player* this) { this->actor.minVelocityY = -20.0f; this->actor.gravity = REG(68) / 100.0f; - if (func_8083816C(D_808535E4)) { + if (func_8083816C(sFloorType)) { temp1 = fabsf(this->speedXZ) * 20.0f; temp3 = 0.0f; - if (D_808535E4 == FLOOR_TYPE_4) { + if (sFloorType == FLOOR_TYPE_4) { if (this->unk_6C4 > 1300.0f) { temp2 = this->unk_6C4; } else { @@ -6131,7 +6149,7 @@ void func_8083D6EC(PlayState* play, Player* this) { temp2 = 20000.0f; if (this->currentBoots != PLAYER_BOOTS_HOVER) { temp1 += temp1; - } else if ((D_808535E4 == FLOOR_TYPE_7) || (this->currentBoots == PLAYER_BOOTS_IRON)) { + } else if ((sFloorType == FLOOR_TYPE_7) || (this->currentBoots == PLAYER_BOOTS_IRON)) { temp1 = 0; } } @@ -6233,7 +6251,7 @@ void func_8083DC54(Player* this, PlayState* play) { return; } - if (D_808535E4 == FLOOR_TYPE_11) { + if (sFloorType == FLOOR_TYPE_11) { Math_SmoothStepToS(&this->actor.focus.rot.x, -20000, 10, 4000, 800); } else { sp46 = 0; @@ -6350,12 +6368,11 @@ void Player_GetSlopeDirection(CollisionPoly* floorPoly, Vec3f* slopeNormal, s16* *downwardSlopeYaw = Math_Atan2S(slopeNormal->z, slopeNormal->x); } -static LinkAnimationHeader* D_80854590[] = { - &gPlayerAnim_link_normal_down_slope_slip, - &gPlayerAnim_link_normal_up_slope_slip, -}; - -s32 func_8083E318(PlayState* play, Player* this, CollisionPoly* floorPoly) { +s32 Player_HandleSlopes(PlayState* play, Player* this, CollisionPoly* floorPoly) { + static LinkAnimationHeader* sSlopeSlipAnims[] = { + &gPlayerAnim_link_normal_down_slope_slip, + &gPlayerAnim_link_normal_up_slope_slip, + }; s32 pad; s16 playerVelYaw; Vec3f slopeNormal; @@ -6366,7 +6383,6 @@ s32 func_8083E318(PlayState* play, Player* this, CollisionPoly* floorPoly) { if (!Player_InBlockingCsMode(play, this) && (func_8084F390 != this->func_674) && (SurfaceType_GetFloorEffect(&play->colCtx, floorPoly, this->actor.floorBgId) == FLOOR_EFFECT_1)) { - // Get direction of movement relative to the downward direction of the slope playerVelYaw = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); Player_GetSlopeDirection(floorPoly, &slopeNormal, &downwardSlopeYaw); @@ -6376,6 +6392,7 @@ s32 func_8083E318(PlayState* play, Player* this, CollisionPoly* floorPoly) { // moving parallel or upwards on the slope, player does not slip but does slow down slopeSlowdownSpeed = (1.0f - slopeNormal.y) * 40.0f; slopeSlowdownSpeedStep = SQ(slopeSlowdownSpeed) * 0.015f; + if (slopeSlowdownSpeedStep < 1.2f) { slopeSlowdownSpeedStep = 1.2f; } @@ -6387,10 +6404,11 @@ s32 func_8083E318(PlayState* play, Player* this, CollisionPoly* floorPoly) { // moving downward on the slope, causing player to slip func_80835C58(play, this, func_8084F390, 0); func_80832564(play, this); - if (D_80853610 >= 0) { + + if (sFloorShapePitch >= 0) { this->unk_84F = 1; } - Player_AnimChangeLoopMorph(play, this, D_80854590[this->unk_84F]); + Player_AnimChangeLoopMorph(play, this, sSlopeSlipAnims[this->unk_84F]); this->speedXZ = sqrtf(SQ(this->actor.velocity.x) + SQ(this->actor.velocity.z)); this->yaw = playerVelYaw; return true; @@ -6568,13 +6586,13 @@ s32 func_8083EB44(Player* this, PlayState* play) { return 0; } -s32 func_8083EC18(Player* this, PlayState* play, u32 interactWallFlags) { - if (this->wallHeight >= 79.0f) { +s32 func_8083EC18(Player* this, PlayState* play, u32 wallFlags) { + if (this->yDistToLedge >= 79.0f) { if (!(this->stateFlags1 & PLAYER_STATE1_27) || (this->currentBoots == PLAYER_BOOTS_IRON) || (this->actor.yDistToWater < this->ageProperties->unk_2C)) { - s32 sp8C = (interactWallFlags & WALL_FLAG_3) ? 2 : 0; + s32 sp8C = (wallFlags & WALL_FLAG_3) ? 2 : 0; - if ((sp8C != 0) || (interactWallFlags & WALL_FLAG_1) || + if ((sp8C != 0) || (wallFlags & WALL_FLAG_1) || SurfaceType_CheckWallFlag2(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId)) { f32 phi_f20; CollisionPoly* wallPoly = this->actor.wallPoly; @@ -6633,21 +6651,21 @@ s32 func_8083EC18(Player* this, PlayState* play, u32 interactWallFlags) { if (phi_f12 < 8.0f) { f32 wallPolyNormalX = COLPOLY_GET_NORMAL(wallPoly->normal.x); f32 wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z); - f32 sp34 = this->wallDistance; + f32 sp34 = this->distToInteractWall; LinkAnimationHeader* anim; func_80836898(play, this, func_8083A3B0); this->stateFlags1 |= PLAYER_STATE1_21; this->stateFlags1 &= ~PLAYER_STATE1_27; - if ((sp8C != 0) || (interactWallFlags & WALL_FLAG_1)) { + if ((sp8C != 0) || (wallFlags & WALL_FLAG_1)) { if ((this->unk_84F = sp8C) != 0) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { anim = &gPlayerAnim_link_normal_Fclimb_startA; } else { anim = &gPlayerAnim_link_normal_Fclimb_hold2upL; } - sp34 = (this->ageProperties->unk_38 - 1.0f) - sp34; + sp34 = (this->ageProperties->wallCheckRadius - 1.0f) - sp34; } else { anim = this->ageProperties->unk_A4; sp34 = sp34 - 1.0f; @@ -6737,13 +6755,13 @@ s32 Player_TryEnteringCrawlspace(Player* this, PlayState* play, u32 interactWall // Enter Crawlspace f32 wallPolyNormalX = COLPOLY_GET_NORMAL(wallPoly->normal.x); f32 wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z); - f32 wallDistance = this->wallDistance; + f32 distToInteractWall = this->distToInteractWall; func_80836898(play, this, func_8083A40C); this->stateFlags2 |= PLAYER_STATE2_CRAWLING; this->actor.shape.rot.y = this->yaw = this->actor.wallYaw + 0x8000; - this->actor.world.pos.x = xVertex1 + (wallDistance * wallPolyNormalX); - this->actor.world.pos.z = zVertex1 + (wallDistance * wallPolyNormalZ); + this->actor.world.pos.x = xVertex1 + (distToInteractWall * wallPolyNormalX); + this->actor.world.pos.z = zVertex1 + (distToInteractWall * wallPolyNormalZ); func_80832224(this); this->actor.prevPos = this->actor.world.pos; Player_AnimPlayOnce(play, this, &gPlayerAnim_link_child_tunnel_start); @@ -6787,7 +6805,7 @@ s32 func_8083F360(PlayState* play, Player* this, f32 arg1, f32 arg2, f32 arg3, f this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_WALL_INTERACT; this->actor.wallBgId = wallBgId; - sInteractWallFlags = SurfaceType_GetWallFlags(&play->colCtx, wallPoly, wallBgId); + sTouchedWallFlags = SurfaceType_GetWallFlags(&play->colCtx, wallPoly, wallBgId); wallPolyNormalX = COLPOLY_GET_NORMAL(wallPoly->normal.x); wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z); @@ -6807,7 +6825,7 @@ s32 func_8083F360(PlayState* play, Player* this, f32 arg1, f32 arg2, f32 arg3, f } s32 func_8083F524(PlayState* play, Player* this) { - return func_8083F360(play, this, 26.0f, this->ageProperties->unk_38 + 5.0f, 30.0f, 0.0f); + return func_8083F360(play, this, 26.0f, this->ageProperties->wallCheckRadius + 5.0f, 30.0f, 0.0f); } /** @@ -6820,7 +6838,7 @@ s32 Player_TryLeavingCrawlspace(Player* this, PlayState* play) { s16 yawToWall; if ((this->speedXZ != 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && - (sInteractWallFlags & WALL_FLAG_CRAWLSPACE)) { + (sTouchedWallFlags & WALL_FLAG_CRAWLSPACE)) { // The exit wallYaws will always point inward on the crawlline // Interacting with the exit wall in front will have a yaw diff of 0x8000 @@ -6878,16 +6896,16 @@ s32 func_8083F7BC(Player* this, PlayState* play) { DynaPolyActor* wallPolyActor; if (!(this->stateFlags1 & PLAYER_STATE1_11) && (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && - (D_80853608 < 0x3000)) { + (sShapeYawToTouchedWall < 0x3000)) { - if (((this->speedXZ > 0.0f) && func_8083EC18(this, play, sInteractWallFlags)) || - Player_TryEnteringCrawlspace(this, play, sInteractWallFlags)) { + if (((this->speedXZ > 0.0f) && func_8083EC18(this, play, sTouchedWallFlags)) || + Player_TryEnteringCrawlspace(this, play, sTouchedWallFlags)) { return 1; } if (!func_808332B8(this) && ((this->speedXZ == 0.0f) || !(this->stateFlags2 & PLAYER_STATE2_2)) && - (sInteractWallFlags & WALL_FLAG_6) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && - (this->wallHeight >= 39.0f)) { + (sTouchedWallFlags & WALL_FLAG_6) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + (this->yDistToLedge >= 39.0f)) { this->stateFlags2 |= PLAYER_STATE2_0; @@ -6971,7 +6989,7 @@ void func_8083FB7C(Player* this, PlayState* play) { s32 func_8083FBC0(Player* this, PlayState* play) { if (!CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && - ((sInteractWallFlags & WALL_FLAG_3) || (sInteractWallFlags & WALL_FLAG_1) || + ((sTouchedWallFlags & WALL_FLAG_3) || (sTouchedWallFlags & WALL_FLAG_1) || SurfaceType_CheckWallFlag2(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId))) { return false; } @@ -7735,10 +7753,10 @@ void func_80841CC4(Player* this, s32 arg1, PlayState* play) { s16 target; f32 rate; - if (ABS(D_80853610) < 3640) { + if (ABS(sFloorShapePitch) < 3640) { target = 0; } else { - target = CLAMP(D_80853610, -10922, 10922); + target = CLAMP(sFloorShapePitch, -10922, 10922); } Math_ScaledStepToS(&this->unk_89C, target, 400); @@ -8457,8 +8475,8 @@ static struct_80832924 D_808545F0[] = { void func_80843CEC(Player* this, PlayState* play) { if (this->currentTunic != PLAYER_TUNIC_GORON) { - if ((play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) || (D_808535E4 == FLOOR_TYPE_9) || - ((func_80838144(D_808535E4) >= 0) && + if ((play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) || (sFloorType == FLOOR_TYPE_9) || + ((func_80838144(sFloorType) >= 0) && !func_80042108(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { func_8083821C(this); } @@ -8498,7 +8516,7 @@ static FallImpactInfo D_80854600[] = { s32 func_80843E64(PlayState* play, Player* this) { s32 sp34; - if ((D_808535E4 == FLOOR_TYPE_6) || (D_808535E4 == FLOOR_TYPE_9)) { + if ((sFloorType == FLOOR_TYPE_6) || (sFloorType == FLOOR_TYPE_9)) { sp34 = 0; } else { sp34 = this->fallDistance; @@ -8543,7 +8561,7 @@ s32 func_80843E64(PlayState* play, Player* this) { Player_RequestRumble(this, (u8)sp34, (u8)(sp34 * 0.1f), (u8)sp34, 0); - if (D_808535E4 == FLOOR_TYPE_6) { + if (sFloorType == FLOOR_TYPE_6) { func_80832698(this, NA_SE_VO_LI_CLIMB_END); } } @@ -8601,7 +8619,7 @@ void func_8084411C(Player* this, PlayState* play) { if (this->unk_850 >= 0) { if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (this->unk_850 == 0) || (this->fallDistance > 0)) { - if ((D_80853600 > 800.0f) || (this->stateFlags1 & PLAYER_STATE1_2)) { + if ((sYDistToFloor > 800.0f) || (this->stateFlags1 & PLAYER_STATE1_2)) { func_80843E14(this, NA_SE_VO_LI_FALL_S); this->stateFlags1 &= ~PLAYER_STATE1_2; } @@ -8611,7 +8629,7 @@ void func_8084411C(Player* this, PlayState* play) { this->unk_850 = -1; } } else { - if ((this->unk_850 == -1) && (this->fallDistance > 120.0f) && (D_80853600 > 280.0f)) { + if ((this->unk_850 == -1) && (this->fallDistance > 120.0f) && (sYDistToFloor > 280.0f)) { this->unk_850 = -2; func_80843E14(this, NA_SE_VO_LI_FALL_L); } @@ -8619,10 +8637,10 @@ void func_8084411C(Player* this, PlayState* play) { if ((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && !(this->stateFlags2 & PLAYER_STATE2_19) && !(this->stateFlags1 & (PLAYER_STATE1_11 | PLAYER_STATE1_27)) && (this->speedXZ > 0.0f)) { - if ((this->wallHeight >= 150.0f) && (this->unk_84B[this->unk_846] == 0)) { - func_8083EC18(this, play, sInteractWallFlags); - } else if ((this->unk_88C >= 2) && (this->wallHeight < 150.0f) && - (((this->actor.world.pos.y - this->actor.floorHeight) + this->wallHeight) > + if ((this->yDistToLedge >= 150.0f) && (this->unk_84B[this->unk_846] == 0)) { + func_8083EC18(this, play, sTouchedWallFlags); + } else if ((this->ledgeClimbType >= PLAYER_LEDGE_CLIMB_2) && (this->yDistToLedge < 150.0f) && + (((this->actor.world.pos.y - this->actor.floorHeight) + this->yDistToLedge) > (70.0f * this->ageProperties->unk_08))) { AnimationContext_DisableQueue(play); if (this->stateFlags1 & PLAYER_STATE1_2) { @@ -8630,8 +8648,8 @@ void func_8084411C(Player* this, PlayState* play) { } else { func_80832698(this, NA_SE_VO_LI_HANG); } - this->actor.world.pos.y += this->wallHeight; - func_8083A5C4(play, this, this->actor.wallPoly, this->wallDistance, + this->actor.world.pos.y += this->yDistToLedge; + func_8083A5C4(play, this, this->actor.wallPoly, this->distToInteractWall, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_jump_climb_hold, this->modelAnimType)); this->actor.shape.rot.y = this->yaw += 0x8000; this->stateFlags1 |= PLAYER_STATE1_13; @@ -8714,7 +8732,8 @@ void func_80844708(Player* this, PlayState* play) { } } else { if (this->speedXZ >= 7.0f) { - if (((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (D_8085360C < 0x2000)) || + if (((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && + (sWorldYawToTouchedWall < 0x2000)) || ((this->cylinder.base.ocFlags1 & OC1_HIT) && (cylinderOc = this->cylinder.base.oc, ((cylinderOc->id == ACTOR_EN_WOOD02) && @@ -9050,7 +9069,7 @@ void func_80845668(Player* this, PlayState* play) { this->speedXZ = 1.0f; if (LinkAnimation_OnFrame(&this->skelAnime, 8.0f)) { - temp1 = this->wallHeight; + temp1 = this->yDistToLedge; if (temp1 > this->ageProperties->unk_0C) { temp1 = this->ageProperties->unk_0C; @@ -9221,7 +9240,7 @@ void func_80845CA4(Player* this, PlayState* play) { if (this->stateFlags1 & PLAYER_STATE1_0) { sp34 = gSaveContext.entranceSpeed; - if (sConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) { + if (sConveyorSpeed != CONVEYOR_SPEED_DISABLED) { this->unk_450.x = (Math_SinS(sConveyorYaw) * 400.0f) + this->actor.world.pos.x; this->unk_450.z = (Math_CosS(sConveyorYaw) * 400.0f) + this->actor.world.pos.z; } @@ -9924,7 +9943,7 @@ void func_808473D4(PlayState* play, Player* this) { !Player_IsChildWithHylianShield(this))) { if ((!(this->stateFlags1 & PLAYER_STATE1_14) && (sp20 <= 0) && (func_8008E9C4(this) || - ((D_808535E4 != FLOOR_TYPE_7) && + ((sFloorType != FLOOR_TYPE_7) && (func_80833B2C(this) || ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && !(this->stateFlags1 & PLAYER_STATE1_22) && (sp20 == 0))))))) { doAction = DO_ACTION_ATTACK; @@ -9962,8 +9981,18 @@ void func_808473D4(PlayState* play, Player* this) { } } -s32 func_80847A78(Player* this) { - s32 cond; +/** + * Updates state related to the Hover Boots. + * Handles a special case where the Hover Boots are able to activate when standing on certain floor types even if the + * player is standing on the ground. + * + * If the player is not on the ground, regardless of the usage of the Hover Boots, various floor related variables are + * reset. + * + * @return true if not on the ground, false otherwise. Note this is independent of the Hover Boots state. + */ +s32 Player_UpdateHoverBoots(Player* this) { + s32 canHoverOnGround; if ((this->currentBoots == PLAYER_BOOTS_HOVER) && (this->hoverBootsTimer != 0)) { this->hoverBootsTimer--; @@ -9971,90 +10000,108 @@ s32 func_80847A78(Player* this) { this->hoverBootsTimer = 0; } - cond = (this->currentBoots == PLAYER_BOOTS_HOVER) && - ((this->actor.yDistToWater >= 0.0f) || (func_80838144(D_808535E4) >= 0) || func_8083816C(D_808535E4)); + canHoverOnGround = + (this->currentBoots == PLAYER_BOOTS_HOVER) && + ((this->actor.yDistToWater >= 0.0f) || (func_80838144(sFloorType) >= 0) || func_8083816C(sFloorType)); - if (cond && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->hoverBootsTimer != 0)) { + if (canHoverOnGround && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->hoverBootsTimer != 0)) { this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; } if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - if (!cond) { + if (!canHoverOnGround) { this->hoverBootsTimer = 19; } + return false; + } else { + sFloorType = FLOOR_TYPE_0; + this->floorPitch = this->floorPitchAlt = sFloorShapePitch = 0; + + return true; } - - D_808535E4 = FLOOR_TYPE_0; - this->unk_898 = this->unk_89A = D_80853610 = 0; - - return true; } -static Vec3f D_80854798 = { 0.0f, 18.0f, 0.0f }; - -void func_80847BA0(PlayState* play, Player* this) { - u8 spC7 = 0; +/** + * Peforms various tasks related to scene collision. + * + * This includes: + * - Update BgCheckInfo, parameters adjusted due to various state flags + * - Update floor type, floor property and floor sfx offset + * - Update conveyor, reverb and light settings according to the current floor poly + * - Handle exits and voids + * - Update information relating to the "interact wall" + * - Update information for ledge climbing + * - Update hover boots + * - Calculate floor poly angles + * + */ +void Player_ProcessSceneCollision(PlayState* play, Player* this) { + static Vec3f sInteractWallCheckOffset = { 0.0f, 18.0f, 0.0f }; + u8 nextLedgeClimbType = PLAYER_LEDGE_CLIMB_NONE; CollisionPoly* floorPoly; - Vec3f spB4; - f32 spB0; - f32 spAC; - f32 spA8; - u32 spA4; + Vec3f unusedWorldPos; + f32 float0; // multi-purpose variable, see define names (fake match?) + f32 float1; // multi-purpose variable, see define names (fake match?) + f32 ceilingCheckHeight; + u32 flags; - D_80853604 = this->unk_A7A; + sPrevFloorProperty = this->floorProperty; + +#define vWallCheckRadius float0 +#define vWallCheckHeight float1 if (this->stateFlags2 & PLAYER_STATE2_CRAWLING) { - spB0 = 10.0f; - spAC = 15.0f; - spA8 = 30.0f; + vWallCheckRadius = 10.0f; + vWallCheckHeight = 15.0f; + ceilingCheckHeight = 30.0f; } else { - spB0 = this->ageProperties->unk_38; - spAC = 26.0f; - spA8 = this->ageProperties->unk_00; + vWallCheckRadius = this->ageProperties->wallCheckRadius; + vWallCheckHeight = 26.0f; + ceilingCheckHeight = this->ageProperties->ceilingCheckHeight; } if (this->stateFlags1 & (PLAYER_STATE1_29 | PLAYER_STATE1_31)) { if (this->stateFlags1 & PLAYER_STATE1_31) { this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; - spA4 = UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; + flags = UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; } else if ((this->stateFlags1 & PLAYER_STATE1_0) && ((this->unk_A84 - (s32)this->actor.world.pos.y) >= 100)) { - spA4 = UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; + flags = UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; } else if (!(this->stateFlags1 & PLAYER_STATE1_0) && ((func_80845EF8 == this->func_674) || (func_80845CA4 == this->func_674))) { this->actor.bgCheckFlags &= ~(BGCHECKFLAG_WALL | BGCHECKFLAG_PLAYER_WALL_INTERACT); - spA4 = UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; + flags = UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; } else { - spA4 = UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | - UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; + flags = UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; } } else { - spA4 = UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | - UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; + flags = UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_5; } if (this->stateFlags3 & PLAYER_STATE3_0) { - spA4 &= ~(UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2); + flags &= ~(UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2); } - if (spA4 & UPDBGCHECKINFO_FLAG_2) { + if (flags & UPDBGCHECKINFO_FLAG_2) { this->stateFlags3 |= PLAYER_STATE3_4; } - Math_Vec3f_Copy(&spB4, &this->actor.world.pos); - Actor_UpdateBgCheckInfo(play, &this->actor, spAC, spB0, spA8, spA4); + Math_Vec3f_Copy(&unusedWorldPos, &this->actor.world.pos); + + Actor_UpdateBgCheckInfo(play, &this->actor, vWallCheckHeight, vWallCheckRadius, ceilingCheckHeight, flags); if (this->actor.bgCheckFlags & BGCHECKFLAG_CEILING) { this->actor.velocity.y = 0.0f; } - D_80853600 = this->actor.world.pos.y - this->actor.floorHeight; - sConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; - + sYDistToFloor = this->actor.world.pos.y - this->actor.floorHeight; + sConveyorSpeed = CONVEYOR_SPEED_DISABLED; floorPoly = this->actor.floorPoly; if (floorPoly != NULL) { - this->unk_A7A = SurfaceType_GetFloorProperty(&play->colCtx, floorPoly, this->actor.floorBgId); + this->floorProperty = SurfaceType_GetFloorProperty(&play->colCtx, floorPoly, this->actor.floorBgId); this->prevFloorSfxOffset = this->floorSfxOffset; if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { @@ -10064,7 +10111,7 @@ void func_80847BA0(PlayState* play, Player* this) { this->floorSfxOffset = SURFACE_SFX_OFFSET_WATER_DEEP; } } else { - if (this->stateFlags2 & PLAYER_STATE2_9) { + if (this->stateFlags2 & PLAYER_STATE2_FORCE_SAND_FLOOR_SOUND) { this->floorSfxOffset = SURFACE_SFX_OFFSET_SAND; } else { this->floorSfxOffset = SurfaceType_GetSfxOffset(&play->colCtx, floorPoly, this->actor.floorBgId); @@ -10082,37 +10129,40 @@ void func_80847BA0(PlayState* play, Player* this) { } } - // This block extracts the conveyor properties from the floor poly - sConveyorSpeedIndex = SurfaceType_GetConveyorSpeed(&play->colCtx, floorPoly, this->actor.floorBgId); - if (sConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) { + sConveyorSpeed = SurfaceType_GetConveyorSpeed(&play->colCtx, floorPoly, this->actor.floorBgId); + + if (sConveyorSpeed != CONVEYOR_SPEED_DISABLED) { sIsFloorConveyor = SurfaceType_IsFloorConveyor(&play->colCtx, floorPoly, this->actor.floorBgId); + if ((!sIsFloorConveyor && (this->actor.yDistToWater > 20.0f) && (this->currentBoots != PLAYER_BOOTS_IRON)) || (sIsFloorConveyor && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND))) { sConveyorYaw = CONVEYOR_DIRECTION_TO_BINANG( SurfaceType_GetConveyorDirection(&play->colCtx, floorPoly, this->actor.floorBgId)); } else { - sConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; + sConveyorSpeed = CONVEYOR_SPEED_DISABLED; } } } - func_80839034(play, this, floorPoly, this->actor.floorBgId); + Player_HandleExitsAndVoids(play, this, floorPoly, this->actor.floorBgId); this->actor.bgCheckFlags &= ~BGCHECKFLAG_PLAYER_WALL_INTERACT; if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { CollisionPoly* wallPoly; s32 wallBgId; - s16 sp9A; + s16 yawDiff; s32 pad; - D_80854798.y = 18.0f; - D_80854798.z = this->ageProperties->unk_38 + 10.0f; + sInteractWallCheckOffset.y = 18.0f; + sInteractWallCheckOffset.z = this->ageProperties->wallCheckRadius + 10.0f; if (!(this->stateFlags2 & PLAYER_STATE2_CRAWLING) && - func_80839768(play, this, &D_80854798, &wallPoly, &wallBgId, &D_80858AA8)) { + Player_PosVsWallLineTest(play, this, &sInteractWallCheckOffset, &wallPoly, &wallBgId, + &sInteractWallCheckResult)) { this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_WALL_INTERACT; + if (this->actor.wallPoly != wallPoly) { this->actor.wallPoly = wallPoly; this->actor.wallBgId = wallBgId; @@ -10120,80 +10170,87 @@ void func_80847BA0(PlayState* play, Player* this) { } } - sp9A = this->actor.shape.rot.y - (s16)(this->actor.wallYaw + 0x8000); + yawDiff = this->actor.shape.rot.y - (s16)(this->actor.wallYaw + 0x8000); + sTouchedWallFlags = SurfaceType_GetWallFlags(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId); + sShapeYawToTouchedWall = ABS(yawDiff); - sInteractWallFlags = SurfaceType_GetWallFlags(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId); + yawDiff = this->yaw - (s16)(this->actor.wallYaw + 0x8000); + sWorldYawToTouchedWall = ABS(yawDiff); - D_80853608 = ABS(sp9A); +#define vSpeedScale float0 +#define vSpeedLimit float1 - sp9A = this->yaw - (s16)(this->actor.wallYaw + 0x8000); + vSpeedScale = sWorldYawToTouchedWall * 0.00008f; - D_8085360C = ABS(sp9A); - - spB0 = D_8085360C * 0.00008f; - if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || spB0 >= 1.0f) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || vSpeedScale >= 1.0f) { this->unk_880 = R_RUN_SPEED_LIMIT / 100.0f; } else { - spAC = (R_RUN_SPEED_LIMIT / 100.0f * spB0); - this->unk_880 = spAC; - if (spAC < 0.1f) { + vSpeedLimit = (R_RUN_SPEED_LIMIT / 100.0f * vSpeedScale); + this->unk_880 = vSpeedLimit; + + if (vSpeedLimit < 0.1f) { this->unk_880 = 0.1f; } } - if ((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (D_80853608 < 0x3000)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (sShapeYawToTouchedWall < 0x3000)) { CollisionPoly* wallPoly = this->actor.wallPoly; if (ABS(wallPoly->normal.y) < 600) { f32 wallPolyNormalX = COLPOLY_GET_NORMAL(wallPoly->normal.x); f32 wallPolyNormalY = COLPOLY_GET_NORMAL(wallPoly->normal.y); f32 wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z); - f32 wallHeight; - CollisionPoly* groundPoly; - CollisionPoly* sp78; - s32 sp74; - Vec3f sp68; - f32 sp64; - f32 sp60; - s32 temp3; + f32 yDistToLedge; + CollisionPoly* ledgeFloorPoly; + CollisionPoly* poly; + s32 bgId; + Vec3f ledgeCheckPos; + f32 ledgePosY; + f32 ceillingPosY; + s32 wallYawDiff; - this->wallDistance = Math3D_UDistPlaneToPos(wallPolyNormalX, wallPolyNormalY, wallPolyNormalZ, - wallPoly->dist, &this->actor.world.pos); + this->distToInteractWall = Math3D_UDistPlaneToPos(wallPolyNormalX, wallPolyNormalY, wallPolyNormalZ, + wallPoly->dist, &this->actor.world.pos); - spB0 = this->wallDistance + 10.0f; - sp68.x = this->actor.world.pos.x - (spB0 * wallPolyNormalX); - sp68.z = this->actor.world.pos.z - (spB0 * wallPolyNormalZ); - sp68.y = this->actor.world.pos.y + this->ageProperties->unk_0C; +#define vLedgeCheckOffsetXZ float0 - sp64 = BgCheck_EntityRaycastDown1(&play->colCtx, &groundPoly, &sp68); - wallHeight = sp64 - this->actor.world.pos.y; - this->wallHeight = wallHeight; + vLedgeCheckOffsetXZ = this->distToInteractWall + 10.0f; - if ((this->wallHeight < 18.0f) || - BgCheck_EntityCheckCeiling(&play->colCtx, &sp60, &this->actor.world.pos, - (sp64 - this->actor.world.pos.y) + 20.0f, &sp78, &sp74, &this->actor)) { - this->wallHeight = 399.96002f; + ledgeCheckPos.x = this->actor.world.pos.x - (vLedgeCheckOffsetXZ * wallPolyNormalX); + ledgeCheckPos.z = this->actor.world.pos.z - (vLedgeCheckOffsetXZ * wallPolyNormalZ); + ledgeCheckPos.y = this->actor.world.pos.y + this->ageProperties->unk_0C; + + ledgePosY = BgCheck_EntityRaycastDown1(&play->colCtx, &ledgeFloorPoly, &ledgeCheckPos); + yDistToLedge = ledgePosY - this->actor.world.pos.y; + this->yDistToLedge = yDistToLedge; + + if ((this->yDistToLedge < 18.0f) || + BgCheck_EntityCheckCeiling(&play->colCtx, &ceillingPosY, &this->actor.world.pos, + (ledgePosY - this->actor.world.pos.y) + 20.0f, &poly, &bgId, + &this->actor)) { + this->yDistToLedge = LEDGE_DIST_MAX; } else { - D_80854798.y = (sp64 + 5.0f) - this->actor.world.pos.y; + sInteractWallCheckOffset.y = (ledgePosY + 5.0f) - this->actor.world.pos.y; - if (func_80839768(play, this, &D_80854798, &sp78, &sp74, &D_80858AA8) && - (temp3 = this->actor.wallYaw - Math_Atan2S(sp78->normal.z, sp78->normal.x), - ABS(temp3) < 0x4000) && - !SurfaceType_CheckWallFlag1(&play->colCtx, sp78, sp74)) { - this->wallHeight = 399.96002f; + if (Player_PosVsWallLineTest(play, this, &sInteractWallCheckOffset, &poly, &bgId, + &sInteractWallCheckResult) && + (wallYawDiff = this->actor.wallYaw - Math_Atan2S(poly->normal.z, poly->normal.x), + ABS(wallYawDiff) < 0x4000) && + !SurfaceType_CheckWallFlag1(&play->colCtx, poly, bgId)) { + this->yDistToLedge = LEDGE_DIST_MAX; } else if (SurfaceType_CheckWallFlag0(&play->colCtx, wallPoly, this->actor.wallBgId) == 0) { - if (this->ageProperties->unk_1C <= this->wallHeight) { - if (ABS(groundPoly->normal.y) > 28000) { - if (this->ageProperties->unk_14 <= this->wallHeight) { - spC7 = 4; - } else if (this->ageProperties->unk_18 <= this->wallHeight) { - spC7 = 3; + if (this->ageProperties->unk_1C <= this->yDistToLedge) { + if (ABS(ledgeFloorPoly->normal.y) > 0x6D60) { + if (this->ageProperties->unk_14 <= this->yDistToLedge) { + nextLedgeClimbType = PLAYER_LEDGE_CLIMB_4; + } else if (this->ageProperties->unk_18 <= this->yDistToLedge) { + nextLedgeClimbType = PLAYER_LEDGE_CLIMB_3; } else { - spC7 = 2; + nextLedgeClimbType = PLAYER_LEDGE_CLIMB_2; } } } else { - spC7 = 1; + nextLedgeClimbType = PLAYER_LEDGE_CLIMB_1; } } } @@ -10201,29 +10258,29 @@ void func_80847BA0(PlayState* play, Player* this) { } } else { this->unk_880 = R_RUN_SPEED_LIMIT / 100.0f; - this->unk_88D = 0; - this->wallHeight = 0.0f; + this->ledgeClimbDelayTimer = 0; + this->yDistToLedge = 0.0f; } - if (spC7 == this->unk_88C) { - if ((this->speedXZ != 0.0f) && (this->unk_88D < 100)) { - this->unk_88D++; + if (nextLedgeClimbType == this->ledgeClimbType) { + if ((this->speedXZ != 0.0f) && (this->ledgeClimbDelayTimer < 100)) { + this->ledgeClimbDelayTimer++; } } else { - this->unk_88C = spC7; - this->unk_88D = 0; + this->ledgeClimbType = nextLedgeClimbType; + this->ledgeClimbDelayTimer = 0; } if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - D_808535E4 = SurfaceType_GetFloorType(&play->colCtx, floorPoly, this->actor.floorBgId); + sFloorType = SurfaceType_GetFloorType(&play->colCtx, floorPoly, this->actor.floorBgId); - if (!func_80847A78(this)) { + if (!Player_UpdateHoverBoots(this)) { f32 floorPolyNormalX; f32 invFloorPolyNormalY; f32 floorPolyNormalZ; - f32 sp4C; + f32 sin; s32 pad2; - f32 sp44; + f32 cos; s32 pad3; if (this->actor.floorBgId != BGCHECK_SCENE) { @@ -10234,31 +10291,31 @@ void func_80847BA0(PlayState* play, Player* this) { invFloorPolyNormalY = 1.0f / COLPOLY_GET_NORMAL(floorPoly->normal.y); floorPolyNormalZ = COLPOLY_GET_NORMAL(floorPoly->normal.z); - sp4C = Math_SinS(this->yaw); - sp44 = Math_CosS(this->yaw); + sin = Math_SinS(this->yaw); + cos = Math_CosS(this->yaw); - this->unk_898 = - Math_Atan2S(1.0f, (-(floorPolyNormalX * sp4C) - (floorPolyNormalZ * sp44)) * invFloorPolyNormalY); - this->unk_89A = - Math_Atan2S(1.0f, (-(floorPolyNormalX * sp44) - (floorPolyNormalZ * sp4C)) * invFloorPolyNormalY); + this->floorPitch = + Math_Atan2S(1.0f, (-(floorPolyNormalX * sin) - (floorPolyNormalZ * cos)) * invFloorPolyNormalY); + this->floorPitchAlt = + Math_Atan2S(1.0f, (-(floorPolyNormalX * cos) - (floorPolyNormalZ * sin)) * invFloorPolyNormalY); - sp4C = Math_SinS(this->actor.shape.rot.y); - sp44 = Math_CosS(this->actor.shape.rot.y); + sin = Math_SinS(this->actor.shape.rot.y); + cos = Math_CosS(this->actor.shape.rot.y); - D_80853610 = - Math_Atan2S(1.0f, (-(floorPolyNormalX * sp4C) - (floorPolyNormalZ * sp44)) * invFloorPolyNormalY); + sFloorShapePitch = + Math_Atan2S(1.0f, (-(floorPolyNormalX * sin) - (floorPolyNormalZ * cos)) * invFloorPolyNormalY); - func_8083E318(play, this, floorPoly); + Player_HandleSlopes(play, this, floorPoly); } } else { - func_80847A78(this); + Player_UpdateHoverBoots(this); } - if (this->unk_A7B == D_808535E4) { - this->unk_A79++; + if (this->prevFloorType == sFloorType) { + this->floorTypeTimer++; } else { - this->unk_A7B = D_808535E4; - this->unk_A79 = 0; + this->prevFloorType = sFloorType; + this->floorTypeTimer = 0; } } @@ -10586,7 +10643,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { Actor_MoveXZGravity(&this->actor); } - func_80847BA0(play, this); + Player_ProcessSceneCollision(play, this); } else { f32 temp_f0; f32 phi_f12; @@ -10644,7 +10701,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { } if (!(this->skelAnime.moveFlags & ANIM_FLAG_PLAYER_7)) { - if (((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (D_808535E4 == FLOOR_TYPE_5) && + if (((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (sFloorType == FLOOR_TYPE_5) && (this->currentBoots != PLAYER_BOOTS_IRON)) || ((this->currentBoots == PLAYER_BOOTS_HOVER) && !(this->stateFlags1 & (PLAYER_STATE1_27 | PLAYER_STATE1_29)))) { @@ -10689,10 +10746,10 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { } Actor_UpdatePos(&this->actor); - func_80847BA0(play, this); + Player_ProcessSceneCollision(play, this); } else { - D_808535E4 = FLOOR_TYPE_0; - this->unk_A7A = FLOOR_PROPERTY_0; + sFloorType = FLOOR_TYPE_0; + this->floorProperty = FLOOR_PROPERTY_0; if (!(this->stateFlags1 & PLAYER_STATE1_0) && (this->stateFlags1 & PLAYER_STATE1_23)) { EnHorse* rideActor = (EnHorse*)this->rideActor; @@ -10707,7 +10764,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { sp58 = rideActor->actor.floorBgId; } - if ((sp5C != NULL) && func_80839034(play, this, sp5C, sp58)) { + if ((sp5C != NULL) && Player_HandleExitsAndVoids(play, this, sp5C, sp58)) { if (DREG(25) != 0) { DREG(25) = 0; } else { @@ -10716,25 +10773,25 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { } } - sConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; + sConveyorSpeed = CONVEYOR_SPEED_DISABLED; this->pushedSpeed = 0.0f; } // This block applies the bg conveyor to pushedSpeed - if ((sConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) && (this->currentBoots != PLAYER_BOOTS_IRON)) { + if ((sConveyorSpeed != CONVEYOR_SPEED_DISABLED) && (this->currentBoots != PLAYER_BOOTS_IRON)) { f32 conveyorSpeed; // converts 1-index to 0-index - sConveyorSpeedIndex--; + sConveyorSpeed--; if (!sIsFloorConveyor) { - conveyorSpeed = sWaterConveyorSpeeds[sConveyorSpeedIndex]; + conveyorSpeed = sWaterConveyorSpeeds[sConveyorSpeed]; if (!(this->stateFlags1 & PLAYER_STATE1_27)) { conveyorSpeed *= 0.25f; } } else { - conveyorSpeed = sFloorConveyorSpeeds[sConveyorSpeedIndex]; + conveyorSpeed = sFloorConveyorSpeeds[sConveyorSpeed]; } Math_StepToF(&this->pushedSpeed, conveyorSpeed, conveyorSpeed * 0.1f); @@ -10803,8 +10860,8 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { this->stateFlags1 &= ~(PLAYER_STATE1_SWINGING_BOTTLE | PLAYER_STATE1_9 | PLAYER_STATE1_12 | PLAYER_STATE1_22); this->stateFlags2 &= ~(PLAYER_STATE2_0 | PLAYER_STATE2_2 | PLAYER_STATE2_3 | PLAYER_STATE2_5 | PLAYER_STATE2_6 | - PLAYER_STATE2_8 | PLAYER_STATE2_9 | PLAYER_STATE2_12 | PLAYER_STATE2_14 | - PLAYER_STATE2_DO_ACTION_ENTER | PLAYER_STATE2_22 | PLAYER_STATE2_26); + PLAYER_STATE2_8 | PLAYER_STATE2_FORCE_SAND_FLOOR_SOUND | PLAYER_STATE2_12 | + PLAYER_STATE2_14 | PLAYER_STATE2_DO_ACTION_ENTER | PLAYER_STATE2_22 | PLAYER_STATE2_26); this->stateFlags3 &= ~PLAYER_STATE3_4; func_80847298(this); @@ -10939,7 +10996,7 @@ void Player_Update(Actor* thisx, PlayState* play) { gSaveContext.dogParams = 0; } else { gSaveContext.dogParams &= 0x7FFF; - func_808395DC(this, &this->actor.world.pos, &D_80854838, &sDogSpawnPos); + Player_GetRelativePosition(this, &this->actor.world.pos, &D_80854838, &sDogSpawnPos); dogParams = gSaveContext.dogParams; dog = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_DOG, sDogSpawnPos.x, sDogSpawnPos.y, sDogSpawnPos.z, @@ -11688,7 +11745,7 @@ void func_8084BF1C(Player* this, PlayState* play) { } } - Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 6.0f, this->ageProperties->unk_00, + Actor_UpdateBgCheckInfo(play, &this->actor, 26.0f, 6.0f, this->ageProperties->ceilingCheckHeight, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2); func_8083F360(play, this, 26.0f, this->ageProperties->unk_3C, 50.0f, -20.0f); } @@ -11916,8 +11973,9 @@ s32 func_8084C89C(PlayState* play, Player* this, s32 arg2, f32* arg3) { *arg3 = func_8083973C(play, this, &D_808548FC[arg2], &sp40); - return (sp4C < *arg3) && (*arg3 < sp50) && !func_80839768(play, this, &D_80854914[arg2], &sp30, &sp2C, &sp34) && - !func_80839768(play, this, &D_8085492C[arg2], &sp30, &sp2C, &sp34); + return (sp4C < *arg3) && (*arg3 < sp50) && + !Player_PosVsWallLineTest(play, this, &D_80854914[arg2], &sp30, &sp2C, &sp34) && + !Player_PosVsWallLineTest(play, this, &D_8085492C[arg2], &sp30, &sp2C, &sp34); } s32 func_8084C9BC(Player* this, PlayState* play) { @@ -13098,7 +13156,7 @@ void func_8084F710(Player* this, PlayState* play) { if ((this->unk_84F != 0) && (play->csCtx.curFrame < 305)) { this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; - } else if (D_80853600 < 150.0f) { + } else if (sYDistToFloor < 150.0f) { if (LinkAnimation_Update(play, &this->skelAnime)) { if (this->unk_850 == 0) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { @@ -13632,7 +13690,7 @@ void func_80850AEC(Player* this, PlayState* play) { if (func_80834FBC(this)) { Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); - func_80847BA0(play, this); + Player_ProcessSceneCollision(play, this); temp = this->actor.world.pos.y - this->actor.floorHeight; if (temp > 20.0f) {