Finish EnMThunder documentation (#2702)

* Finish `EnMThunder` documentation

* Boolean conversion

* Hex to decimal conversions

* Rename static variables
This commit is contained in:
Jordan Longstaff
2026-02-26 03:59:16 -05:00
committed by GitHub
parent ba71ca39d2
commit 3d51e21020
4 changed files with 83 additions and 83 deletions
+1 -1
View File
@@ -1164,7 +1164,7 @@ void func_800F436C(Vec3f* pos, u16 sfxId, f32 arg2);
void func_800F4414(Vec3f* pos, u16 sfxId, f32);
void func_800F44EC(s8 arg0, s8 arg1);
void func_800F4524(Vec3f* pos, u16 sfxId, s8 arg2);
void func_800F4254(Vec3f* pos, u8 level);
void Audio_PlaySwordChargeSfx(Vec3f* pos, u8 level);
void Audio_PlaySfxRiver(Vec3f* pos, f32 freqScale);
void Audio_PlaySfxWaterfall(Vec3f* pos, f32 freqScale);
void Audio_SetBgmVolumeOffDuringFanfare(void);
+8 -8
View File
@@ -140,8 +140,8 @@ f32 sBehindScreenZ[2] = { -15.0f, -65.0f };
u8 sAudioIncreasingTranspose = 0;
u8 gMorphaTransposeTable[16] = { 0, 0, 0, 1, 1, 2, 4, 6, 8, 8, 8, 8, 8, 8, 8, 8 };
u8 sPrevChargeLevel = 0;
f32 D_801305E4[4] = { 1.0f, 1.12246f, 1.33484f, 1.33484f }; // 2**({0, 2, 5, 5}/12)
f32 D_801305F4 = 1.0f;
f32 sSfxSwordChargeFreqLevels[4] = { 1.0f, 1.12246f, 1.33484f, 1.33484f }; // 2**({0, 2, 5, 5}/12)
f32 sSfxSwordChargeFreq = 1.0f;
u8 sGanonsTowerLevelsVol[8] = { 127, 80, 75, 73, 70, 68, 65, 60 };
u8 sEnterGanonsTowerTimer = 0;
#if DEBUG_FEATURES
@@ -2819,17 +2819,17 @@ void Audio_PlaySfxRandom(Vec3f* pos, u16 baseSfxId, u8 randLim) {
SFX_PLAY_AT_POS(pos, baseSfxId + offset);
}
void func_800F4254(Vec3f* pos, u8 level) {
void Audio_PlaySwordChargeSfx(Vec3f* pos, u8 level) {
level &= 3;
if (level != sPrevChargeLevel) {
D_801305F4 = D_801305E4[level];
sSfxSwordChargeFreq = sSfxSwordChargeFreqLevels[level];
switch (level) {
case 1:
Audio_PlaySfxGeneral(NA_SE_PL_SWORD_CHARGE, pos, 4, &D_801305F4, &gSfxDefaultFreqAndVolScale,
Audio_PlaySfxGeneral(NA_SE_PL_SWORD_CHARGE, pos, 4, &sSfxSwordChargeFreq, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultReverb);
break;
case 2:
Audio_PlaySfxGeneral(NA_SE_PL_SWORD_CHARGE, pos, 4, &D_801305F4, &gSfxDefaultFreqAndVolScale,
Audio_PlaySfxGeneral(NA_SE_PL_SWORD_CHARGE, pos, 4, &sSfxSwordChargeFreq, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultReverb);
break;
}
@@ -2838,8 +2838,8 @@ void func_800F4254(Vec3f* pos, u8 level) {
}
if (level != 0) {
Audio_PlaySfxGeneral(NA_SE_IT_SWORD_CHARGE - SFX_FLAG, pos, 4, &D_801305F4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultReverb);
Audio_PlaySfxGeneral(NA_SE_IT_SWORD_CHARGE - SFX_FLAG, pos, 4, &sSfxSwordChargeFreq,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
}
}
@@ -32,9 +32,9 @@ void EnMThunder_Destroy(Actor* thisx, PlayState* play);
void EnMThunder_Update(Actor* thisx, PlayState* play);
void EnMThunder_Draw(Actor* thisx, PlayState* play2);
void func_80A9F314(PlayState* play, f32 arg1);
void func_80A9F408(EnMThunder* this, PlayState* play);
void func_80A9F9B4(EnMThunder* this, PlayState* play);
void EnMThunder_AdjustEnvLights(PlayState* play, f32 intensity);
void EnMThunder_ChargingSpinAttack(EnMThunder* this, PlayState* play);
void EnMThunder_SpinAttacking(EnMThunder* this, PlayState* play);
ActorProfile En_M_Thunder_Profile = {
/**/ ACTOR_EN_M_THUNDER,
@@ -48,7 +48,7 @@ ActorProfile En_M_Thunder_Profile = {
/**/ EnMThunder_Draw,
};
static ColliderCylinderInit D_80AA0420 = {
static ColliderCylinderInit sCylinderInit = {
{
COL_MATERIAL_NONE,
AT_ON | AT_TYPE_PLAYER,
@@ -68,11 +68,10 @@ static ColliderCylinderInit D_80AA0420 = {
{ 200, 200, 0, { 0, 0, 0 } },
};
static u32 D_80AA044C[] = { DMG_SPIN_MASTER, DMG_SPIN_KOKIRI, DMG_SPIN_GIANT };
static u32 D_80AA0458[] = { DMG_JUMP_MASTER, DMG_JUMP_KOKIRI, DMG_JUMP_GIANT };
static u32 sSpinAttackDmgFlags[] = { DMG_SPIN_MASTER, DMG_SPIN_KOKIRI, DMG_SPIN_GIANT };
static u32 sJumpAttackDmgFlags[] = { DMG_JUMP_MASTER, DMG_JUMP_KOKIRI, DMG_JUMP_GIANT };
// Setup action
void func_80A9EFE0(EnMThunder* this, EnMThunderActionFunc actionFunc) {
void EnMThunder_SetupAction(EnMThunder* this, EnMThunderActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
@@ -82,7 +81,7 @@ void EnMThunder_Init(Actor* thisx, PlayState* play2) {
Player* player = GET_PLAYER(play);
Collider_InitCylinder(play, &this->collider);
Collider_SetCylinder(play, &this->collider, &this->actor, &D_80AA0420);
Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit);
this->swordType = PARAMS_GET_S(this->actor.params, 0, 8) - 1;
Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y,
this->actor.world.pos.z, 255, 255, 255, 0);
@@ -91,14 +90,14 @@ void EnMThunder_Init(Actor* thisx, PlayState* play2) {
this->collider.dim.height = 40;
this->collider.dim.yShift = -20;
this->followPlayerTimer = 8;
this->unk_1B4 = 0.0f;
this->spinTrailTexScroll = 0.0f;
this->actor.world.pos = player->bodyPartsPos[PLAYER_BODYPART_WAIST];
this->unk_1AC = 0.0f;
this->unk_1BC = 0.0f;
this->spinAttackTimer = 0.0f;
this->dimmingIntensity = 0.0f;
this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000;
this->actor.room = -1;
Actor_SetScale(&this->actor, 0.1f);
this->unk_1CA = 0;
this->isUsingMagic = false;
if (player->stateFlags2 & PLAYER_STATE2_17) {
if (!gSaveContext.save.info.playerData.isMagicAcquired || (gSaveContext.magicState != MAGIC_STATE_IDLE) ||
@@ -111,16 +110,16 @@ void EnMThunder_Init(Actor* thisx, PlayState* play2) {
}
player->stateFlags2 &= ~PLAYER_STATE2_17;
this->unk_1CA = 1;
this->collider.elem.atDmgInfo.dmgFlags = D_80AA044C[this->swordType];
this->isUsingMagic = true;
this->collider.elem.atDmgInfo.dmgFlags = sSpinAttackDmgFlags[this->swordType];
this->attackStrength = M_THUNDER_ATTACK_WEAK;
this->targetScale = ((this->swordType == M_THUNDER_SWORD_KOKIRI) ? 2 : 4);
func_80A9EFE0(this, func_80A9F9B4);
EnMThunder_SetupAction(this, EnMThunder_SpinAttacking);
this->followPlayerTimer = 8;
SFX_PLAY_AT_POS(&player->actor.projectedPos, NA_SE_IT_ROLLING_CUT_LV1);
this->unk_1AC = 1.0f;
this->spinAttackTimer = 1.0f;
} else {
func_80A9EFE0(this, func_80A9F408);
EnMThunder_SetupAction(this, EnMThunder_ChargingSpinAttack);
}
this->actor.child = NULL;
}
@@ -128,20 +127,20 @@ void EnMThunder_Init(Actor* thisx, PlayState* play2) {
void EnMThunder_Destroy(Actor* thisx, PlayState* play) {
EnMThunder* this = (EnMThunder*)thisx;
if (this->unk_1CA != 0) {
if (this->isUsingMagic) {
Magic_Reset(play);
}
Collider_DestroyCylinder(play, &this->collider);
func_80A9F314(play, 0.0f);
EnMThunder_AdjustEnvLights(play, 0.0f);
LightContext_RemoveLight(play, &play->lightCtx, this->lightNode);
}
void func_80A9F314(PlayState* play, f32 arg1) {
Environment_AdjustLights(play, arg1, 850.0f, 0.2f, 0.0f);
void EnMThunder_AdjustEnvLights(PlayState* play, f32 intensity) {
Environment_AdjustLights(play, intensity, 850.0f, 0.2f, 0.0f);
}
void func_80A9F350(EnMThunder* this, PlayState* play) {
void EnMThunder_EmptySpinAttack(EnMThunder* this, PlayState* play) {
Player* player = GET_PLAYER(play);
if (player->stateFlags2 & PLAYER_STATE2_17) {
@@ -159,28 +158,28 @@ void func_80A9F350(EnMThunder* this, PlayState* play) {
}
}
void func_80A9F408(EnMThunder* this, PlayState* play) {
void EnMThunder_ChargingSpinAttack(EnMThunder* this, PlayState* play) {
Player* player = GET_PLAYER(play);
Actor* child = this->actor.child;
this->unk_1B8 = player->unk_858;
this->spinChargePercent = player->unk_858;
this->actor.world.pos = player->bodyPartsPos[PLAYER_BODYPART_WAIST];
this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000;
if (this->unk_1CA == 0) {
if (!this->isUsingMagic) {
if (player->unk_858 >= 0.1f) {
if ((gSaveContext.magicState != MAGIC_STATE_IDLE) ||
(PARAMS_GET_S(this->actor.params, 8, 8) &&
!(Magic_RequestChange(play, PARAMS_GET_S(this->actor.params, 8, 8), MAGIC_CONSUME_WAIT_PREVIEW)))) {
func_80A9F350(this, play);
func_80A9EFE0(this, func_80A9F350);
EnMThunder_EmptySpinAttack(this, play);
EnMThunder_SetupAction(this, EnMThunder_EmptySpinAttack);
this->chargeAlpha = 0;
this->unk_1BC = 0.0;
this->unk_1AC = 0.0f;
this->dimmingIntensity = 0.0;
this->spinAttackTimer = 0.0f;
return;
}
this->unk_1CA = 1;
this->isUsingMagic = true;
}
}
@@ -206,16 +205,16 @@ void func_80A9F408(EnMThunder* this, PlayState* play) {
gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP;
}
if (player->unk_858 < 0.85f) {
this->collider.elem.atDmgInfo.dmgFlags = D_80AA044C[this->swordType];
this->collider.elem.atDmgInfo.dmgFlags = sSpinAttackDmgFlags[this->swordType];
this->attackStrength = M_THUNDER_ATTACK_WEAK;
this->targetScale = ((this->swordType == M_THUNDER_SWORD_KOKIRI) ? 2 : 4);
} else {
this->collider.elem.atDmgInfo.dmgFlags = D_80AA0458[this->swordType];
this->collider.elem.atDmgInfo.dmgFlags = sJumpAttackDmgFlags[this->swordType];
this->attackStrength = M_THUNDER_ATTACK_STRONG;
this->targetScale = ((this->swordType == M_THUNDER_SWORD_KOKIRI) ? 4 : 8);
}
func_80A9EFE0(this, func_80A9F9B4);
EnMThunder_SetupAction(this, EnMThunder_SpinAttacking);
this->followPlayerTimer = 8;
{
@@ -229,7 +228,7 @@ void func_80A9F408(EnMThunder* this, PlayState* play) {
SFX_PLAY_AT_POS(&player->actor.projectedPos, sSfxIds[this->attackStrength]);
}
this->unk_1AC = 1.0f;
this->spinAttackTimer = 1.0f;
return;
}
}
@@ -249,21 +248,21 @@ void func_80A9F408(EnMThunder* this, PlayState* play) {
this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0,
this->swordType + 2);
}
this->unk_1BC += ((((player->unk_858 - 0.15f) * 1.5f) - this->unk_1BC) * 0.5f);
this->dimmingIntensity += ((((player->unk_858 - 0.15f) * 1.5f) - this->dimmingIntensity) * 0.5f);
} else if (player->unk_858 > .1f) {
this->chargeAlpha = (s32)((player->unk_858 - .1f) * 255.0f * 20.0f);
this->unk_1AC = (player->unk_858 - .1f) * 10.0f;
this->spinAttackTimer = (player->unk_858 - .1f) * 10.0f;
} else {
this->chargeAlpha = 0;
}
if (player->unk_858 > 0.85f) {
func_800F4254(&player->actor.projectedPos, 2);
Audio_PlaySwordChargeSfx(&player->actor.projectedPos, 2);
} else if (player->unk_858 > 0.15f) {
func_800F4254(&player->actor.projectedPos, 1);
Audio_PlaySwordChargeSfx(&player->actor.projectedPos, 1);
} else if (player->unk_858 > 0.1f) {
func_800F4254(&player->actor.projectedPos, 0);
Audio_PlaySwordChargeSfx(&player->actor.projectedPos, 0);
}
if (Play_InCsMode(play)) {
@@ -271,7 +270,7 @@ void func_80A9F408(EnMThunder* this, PlayState* play) {
}
}
void func_80A9F938(EnMThunder* this, PlayState* play) {
void EnMThunder_UpdateSpinAttack(EnMThunder* this, PlayState* play) {
if (this->followPlayerTimer < 2) {
if (this->chargeAlpha < 40) {
this->chargeAlpha = 0;
@@ -280,19 +279,19 @@ void func_80A9F938(EnMThunder* this, PlayState* play) {
}
}
this->unk_1B4 += 2.0f * this->unk_1B0;
this->spinTrailTexScroll += 2.0f * this->spinAttackAlpha;
if (this->unk_1BC < this->unk_1AC) {
this->unk_1BC += ((this->unk_1AC - this->unk_1BC) * 0.1f);
if (this->dimmingIntensity < this->spinAttackTimer) {
this->dimmingIntensity += ((this->spinAttackTimer - this->dimmingIntensity) * 0.1f);
} else {
this->unk_1BC = this->unk_1AC;
this->dimmingIntensity = this->spinAttackTimer;
}
}
void func_80A9F9B4(EnMThunder* this, PlayState* play) {
void EnMThunder_SpinAttacking(EnMThunder* this, PlayState* play) {
Player* player = GET_PLAYER(play);
if (Math_StepToF(&this->unk_1AC, 0.0f, 1 / 16.0f)) {
if (Math_StepToF(&this->spinAttackTimer, 0.0f, 1 / 16.0f)) {
Actor_Kill(&this->actor);
} else {
Math_SmoothStepToF(&this->actor.scale.x, (s32)this->targetScale, 0.6f, 0.8f, 0.0f);
@@ -308,13 +307,13 @@ void func_80A9F9B4(EnMThunder* this, PlayState* play) {
this->followPlayerTimer--;
}
if (this->unk_1AC > 0.6f) {
this->unk_1B0 = 1.0f;
if (this->spinAttackTimer > 0.6f) {
this->spinAttackAlpha = 1.0f;
} else {
this->unk_1B0 = this->unk_1AC * (5.0f / 3.0f);
this->spinAttackAlpha = this->spinAttackTimer * (5.0f / 3.0f);
}
func_80A9F938(this, play);
EnMThunder_UpdateSpinAttack(this, play);
if (Play_InCsMode(play)) {
Actor_Kill(&this->actor);
@@ -327,8 +326,8 @@ void EnMThunder_Update(Actor* thisx, PlayState* play) {
s32 redGreen;
this->actionFunc(this, play);
func_80A9F314(play, this->unk_1BC);
blueRadius = this->unk_1AC;
EnMThunder_AdjustEnvLights(play, this->dimmingIntensity);
blueRadius = this->spinAttackTimer;
redGreen = (u32)(blueRadius * 255.0f) & 0xFF;
Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y,
this->actor.world.pos.z, redGreen, redGreen, (u32)(blueRadius * 100.0f),
@@ -336,12 +335,12 @@ void EnMThunder_Update(Actor* thisx, PlayState* play) {
}
void EnMThunder_Draw(Actor* thisx, PlayState* play2) {
static f32 D_80AA046C[] = { 0.1f, 0.15f, 0.2f, 0.25f, 0.3f, 0.25f, 0.2f, 0.15f };
static f32 sSpinChargeScale[] = { 0.1f, 0.15f, 0.2f, 0.25f, 0.3f, 0.25f, 0.2f, 0.15f };
PlayState* play = play2;
EnMThunder* this = (EnMThunder*)thisx;
Player* player = GET_PLAYER(play);
f32 phi_f14;
s32 phi_t1;
f32 spinChargeScale;
s32 chargeTexScroll;
OPEN_DISPS(play->state.gfxCtx, "../z_en_m_thunder.c", 844);
Gfx_SetupDL_25Xlu(play->state.gfxCtx);
@@ -353,19 +352,19 @@ void EnMThunder_Draw(Actor* thisx, PlayState* play2) {
case M_THUNDER_ATTACK_WEAK:
gSPSegment(POLY_XLU_DISP++, 0x08,
Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE,
0xFF - ((u8)(s32)(this->unk_1B4 * 30) & 0xFF), 0, 0x40, 0x20, 1,
0xFF - ((u8)(s32)(this->unk_1B4 * 20) & 0xFF), 0, 8, 8));
0xFF - ((u8)(s32)(this->spinTrailTexScroll * 30) & 0xFF), 0, 64, 32, 1,
0xFF - ((u8)(s32)(this->spinTrailTexScroll * 20) & 0xFF), 0, 8, 8));
break;
}
switch (this->attackStrength) {
case M_THUNDER_ATTACK_STRONG:
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, (u8)(this->unk_1B0 * 255));
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, (u8)(this->spinAttackAlpha * 255));
gSPDisplayList(POLY_XLU_DISP++, gSpinAttack3DL);
gSPDisplayList(POLY_XLU_DISP++, gSpinAttack4DL);
break;
case M_THUNDER_ATTACK_WEAK:
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u8)(this->unk_1B0 * 255));
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, (u8)(this->spinAttackAlpha * 255));
gSPDisplayList(POLY_XLU_DISP++, gSpinAttack1DL);
gSPDisplayList(POLY_XLU_DISP++, gSpinAttack2DL);
break;
@@ -391,23 +390,24 @@ void EnMThunder_Draw(Actor* thisx, PlayState* play2) {
break;
}
if (this->unk_1B8 >= 0.85f) {
phi_f14 = (D_80AA046C[(play->gameplayFrames & 7)] * 6.0f) + 1.0f;
if (this->spinChargePercent >= 0.85f) {
spinChargeScale = (sSpinChargeScale[(play->gameplayFrames & 7)] * 6.0f) + 1.0f;
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 255, 255, 170, this->chargeAlpha);
gDPSetEnvColor(POLY_XLU_DISP++, 255, 100, 0, 128);
phi_t1 = 0x28;
chargeTexScroll = 40;
} else {
phi_f14 = (D_80AA046C[play->gameplayFrames & 7] * 2.0f) + 1.0f;
spinChargeScale = (sSpinChargeScale[play->gameplayFrames & 7] * 2.0f) + 1.0f;
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, this->chargeAlpha);
gDPSetEnvColor(POLY_XLU_DISP++, 0, 100, 255, 128);
phi_t1 = 0x14;
chargeTexScroll = 20;
}
Matrix_Scale(1.0f, phi_f14, phi_f14, MTXMODE_APPLY);
Matrix_Scale(1.0f, spinChargeScale, spinChargeScale, MTXMODE_APPLY);
MATRIX_FINALIZE_AND_LOAD(POLY_XLU_DISP++, play->state.gfxCtx, "../z_en_m_thunder.c", 960);
gSPSegment(POLY_XLU_DISP++, 0x09,
Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (play->gameplayFrames * 5) & 0xFF, 0, 0x20, 0x20,
1, (play->gameplayFrames * 20) & 0xFF, (play->gameplayFrames * phi_t1) & 0xFF, 8, 8));
Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (play->gameplayFrames * 5) & 0xFF, 0, 32, 32, 1,
(play->gameplayFrames * 20) & 0xFF, (play->gameplayFrames * chargeTexScroll) & 0xFF, 8,
8));
gSPDisplayList(POLY_XLU_DISP++, gSpinAttackChargingDL);
@@ -14,18 +14,18 @@ typedef struct EnMThunder {
/* 0x014C */ ColliderCylinder collider;
/* 0x0198 */ LightNode* lightNode;
/* 0x019C */ LightInfo lightInfo;
/* 0x01AC */ f32 unk_1AC;
/* 0x01B0 */ f32 unk_1B0;
/* 0x01B0 */ f32 unk_1B4;
/* 0x01B0 */ f32 unk_1B8;
/* 0x01BC */ f32 unk_1BC;
/* 0x01AC */ f32 spinAttackTimer;
/* 0x01B0 */ f32 spinAttackAlpha;
/* 0x01B0 */ f32 spinTrailTexScroll;
/* 0x01B0 */ f32 spinChargePercent;
/* 0x01BC */ f32 dimmingIntensity;
/* 0x01C0 */ EnMThunderActionFunc actionFunc;
/* 0x01C4 */ u16 followPlayerTimer;
/* 0x01C6 */ u8 attackStrength; // see `EnMThunderAttackStrength`
/* 0x01C7 */ u8 swordType; // see `EnMThunderSwordType`
/* 0x01C8 */ u8 chargeAlpha;
/* 0x01C9 */ u8 targetScale;
/* 0x01CA */ u8 unk_1CA;
/* 0x01CA */ u8 isUsingMagic;
} EnMThunder; // size = 0x01CC
#endif