From f35352c1601b3bcc3a202b5fab6a614f1b9ceb06 Mon Sep 17 00:00:00 2001 From: JordanLongstaff Date: Mon, 2 Jun 2025 09:26:18 -0400 Subject: [PATCH] Rename more water-related variables --- src/overlays/actors/ovl_En_Ru1/z_en_ru1.c | 34 ++++++++++++----------- src/overlays/actors/ovl_En_Ru1/z_en_ru1.h | 8 +++--- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c index 9076e93672..3c71bff382 100644 --- a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c +++ b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c @@ -1479,18 +1479,20 @@ void func_80AEE02C(EnRu1* this) { void EnRu1_UpdateWaterState(EnRu1* this) { s32 pad; - f32 sp28; - f32 sp24; + f32 bobMagnitude; + f32 startY; EnRu1* thisx = this; // necessary to match if (this->waterState == ENRU1_WATER_OUTSIDE) { if ((this->actor.minVelocityY == 0.0f) && (this->actor.speed == 0.0f)) { + // When Ruto's velocity has been slowed enough by the water, stop her motion this->waterState = ENRU1_WATER_IMMERSED; func_80AEE02C(this); - this->unk_35C = 0; - this->unk_358 = (this->actor.depthInWater - 10.0f) * 0.5f; - this->unk_354 = this->actor.world.pos.y + thisx->unk_358; // thisx only used here + this->bobPhase = 0; + this->bobDepth = (this->actor.depthInWater - 10.0f) * 0.5f; + this->sinkingStartPosY = this->actor.world.pos.y + thisx->bobDepth; // thisx only used here } else { + // Ruto is touching the water but still traveling along some path, e.g. from being thrown this->actor.gravity = 0.0f; this->actor.minVelocityY *= 0.2f; this->actor.velocity.y *= 0.2f; @@ -1508,23 +1510,23 @@ void EnRu1_UpdateWaterState(EnRu1* this) { } } else { if (this->waterState == ENRU1_WATER_IMMERSED) { - if (this->unk_358 <= 1.0f) { + if (this->bobDepth <= 1.0f) { func_80AEE02C(this); this->waterState = ENRU1_WATER_BOBBING; - this->unk_360 = 0.0f; + this->isSinking = 0.0f; } else { - f32 temp_f10; + f32 deltaY; - sp28 = this->unk_358; - sp24 = this->unk_354; - temp_f10 = Math_CosS(this->unk_35C) * -sp28; - this->actor.world.pos.y = temp_f10 + sp24; - this->unk_35C += 0x3E8; - this->unk_358 *= 0.95f; + bobMagnitude = this->bobDepth; + startY = this->sinkingStartPosY; + deltaY = Math_CosS(this->bobPhase) * -bobMagnitude; + this->actor.world.pos.y = deltaY + startY; + this->bobPhase += 0x3E8; + this->bobDepth *= 0.95f; } } else { - this->unk_360 += 1.0f; - if (this->unk_360 > 0.0f) { + this->isSinking += 1.0f; + if (this->isSinking > 0.0f) { this->waterState = ENRU1_WATER_SINKING; } } diff --git a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.h b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.h index f1a14c0e1e..0d6c15bcfa 100644 --- a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.h +++ b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.h @@ -48,10 +48,10 @@ typedef struct EnRu1 { /* 0x0300 */ ColliderCylinder collider2; /* 0x034C */ s32 unk_34C; /* 0x0350 */ s32 waterState; - /* 0x0354 */ f32 unk_354; - /* 0x0358 */ f32 unk_358; - /* 0x035C */ s16 unk_35C; - /* 0x0360 */ f32 unk_360; + /* 0x0354 */ f32 sinkingStartPosY; + /* 0x0358 */ f32 bobDepth; + /* 0x035C */ s16 bobPhase; + /* 0x0360 */ f32 isSinking; /* 0x0364 */ Vec3f unk_364; /* 0x0370 */ f32 unk_370; /* 0x0374 */ NpcInteractInfo interactInfo;