From 0224f958638e02f785fee1c7a37bfe96699b4b14 Mon Sep 17 00:00:00 2001 From: Nabnut Date: Thu, 19 Sep 2024 13:01:49 +0200 Subject: [PATCH] Renaming Hut --- include/enums.h | 7 ++- src/MM/ch/hut.c | 108 ++++++++++++++++++-------------------- src/core2/ch/gameSelect.c | 2 +- src/core2/code_41FB0.c | 45 ++++++++-------- 4 files changed, 78 insertions(+), 84 deletions(-) diff --git a/include/enums.h b/include/enums.h index 457c2bd9..9a70a738 100644 --- a/include/enums.h +++ b/include/enums.h @@ -1723,10 +1723,9 @@ enum actor_e ACTOR_47_EMPTY_HONEYCOMB, ACTOR_49_EXTRA_LIFE = 0x49, - - ACTOR_4A_WOOD_EXPLOSION = 0x4A, - - ACTOR_4C_STEAM = 0x4C, + ACTOR_4A_WOOD_EXPLOSION, + ACTOR_4B_WOOD_EXPLOSION_2, + ACTOR_4C_STEAM, ACTOR_4D_STEAM_2, ACTOR_50_HONEYCOMB = 0x50, diff --git a/src/MM/ch/hut.c b/src/MM/ch/hut.c index c6615639..5e065263 100644 --- a/src/MM/ch/hut.c +++ b/src/MM/ch/hut.c @@ -5,85 +5,72 @@ #include "prop.h" -#ifndef HUT_STATE_INTACT -#define HUT_STATE_INTACT 0 -#endif - -#ifndef HUT_STATE_DAMAGED -#define HUT_STATE_DAMAGED 1 -#endif - -#ifndef HUT_STATE_DESTROYED -#define HUT_STATE_DESTROYED 2 -#endif - /* extern function declarations */ - void func_802C8F70(f32); void func_802C4218(s32, s32, s32, s32); /* public function declarations */ -Actor *chhut_draw(ActorMarker *, Gfx **, Mtx**, Vtx **); -void chhut_update(Actor *); +Actor *chhut_draw(ActorMarker *, Gfx **, Mtx **, Vtx **); +void chhut_update(Actor *); /* .bss */ -extern s32 D_8037DCB0; //mm_hut_smash_count - +extern s32 mm_hut_smash_count; //mm_hut_smash_count /* .data */ +enum chhut_state_e { + HUT_STATE_0_INTACT, + HUT_STATE_1_DAMAGED, + HUT_STATE_2_DESTROYED +}; + ActorAnimationInfo chhutAnimations[3] = { - {0, 0.0f}, - {ASSET_4E_ANIM_MUDHUT_SMASH, 0.25f}, + {0, 0.0f}, + {ASSET_4E_ANIM_MUDHUT_SMASH, 0.25f}, {ASSET_4E_ANIM_MUDHUT_SMASH, 1000000.0f} }; /* .code */ -Actor *chhut_draw(ActorMarker *this, Gfx **gfx, Mtx **mtx, Vtx **vtx){ - Actor *actorPtr; - s32 is_not_destroyed; - s32 is_intact_or_destroyed; +Actor *chhut_draw(ActorMarker *this, Gfx **gfx, Mtx **mtx, Vtx **vtx) { + Actor *actorPtr = marker_getActor(this); + s32 is_not_destroyed = actorPtr->state != HUT_STATE_2_DESTROYED; + s32 is_intact_or_destroyed = actorPtr->state == HUT_STATE_0_INTACT || actorPtr->state == HUT_STATE_2_DESTROYED; - actorPtr = marker_getActor(this); - - is_not_destroyed = actorPtr->state != HUT_STATE_DESTROYED; - is_intact_or_destroyed = actorPtr->state == HUT_STATE_INTACT || actorPtr->state == HUT_STATE_DESTROYED; this->propPtr->unk8_3 = is_intact_or_destroyed; func_8033A45C(1, is_not_destroyed); - return actor_draw(this, gfx, mtx, vtx); } -void func_803869EC(ActorMarker *this){ - Actor * actorPtr; - f32 *pos; - - actorPtr = marker_getActor(this); - actorPtr = spawn_actor_f32(0x4B, actorPtr->position, 0); +void __chhut_spawnExplosion(ActorMarker *this) { + Actor *actorPtr = marker_getActor(this); + actorPtr = spawn_actor_f32(ACTOR_4B_WOOD_EXPLOSION_2, actorPtr->position, 0); spawn_actor_f32(ACTOR_4D_STEAM_2, actorPtr->position, 0); - - if(this); + + if (this); } -void chhut_update(Actor *this){ - static s32 D_803898D8[6] = { 0, 1, 2, 3, 6, 4}; +void chhut_update(Actor *this) { + static s32 D_803898D8[6] = {0, 1, 2, 3, 6, 4}; f32 diff_pos[3]; f32 plyr_pos[3]; - if(func_80334904() != 2) + if (func_80334904() != 2) { return; + } - if(!this->initialized){ + if (!this->initialized) { this->marker->collidable = FALSE; this->initialized = TRUE; } - switch(this->state){ - case HUT_STATE_INTACT: + + switch (this->state) { + case HUT_STATE_0_INTACT: player_getPosition(plyr_pos); diff_pos[0] = plyr_pos[0] - this->position_x; diff_pos[1] = plyr_pos[1] - this->position_y; diff_pos[2] = plyr_pos[2] - this->position_z; - if(150.0f < diff_pos[1] - && player_getActiveHitbox(this->marker) == HITBOX_1_BEAK_BUSTER + + if (150.0f < diff_pos[1] + && player_getActiveHitbox(this->marker) == HITBOX_1_BEAK_BUSTER && func_8028F20C() && gu_sqrtf(diff_pos[0]*diff_pos[0] + diff_pos[1]*diff_pos[1] + diff_pos[2]*diff_pos[2]) < 350.0f ){ @@ -91,38 +78,43 @@ void chhut_update(Actor *this){ diff_pos[1] = this->position_y; diff_pos[2] = this->position_z; diff_pos[1] += 125.0; + func_8030E484(SFX_5B_HEAVY_STUFF_FALLING); - subaddie_set_state(this, HUT_STATE_DAMAGED); + subaddie_set_state(this, HUT_STATE_1_DAMAGED); actor_playAnimationOnce(this); - __spawnQueue_add_1((GenFunction_1)func_803869EC, (s32)this->marker); + __spawnQueue_add_1((GenFunction_1) __chhut_spawnExplosion, (s32) this->marker); func_802C8F70(this->yaw); - if(D_8037DCB0 < 5){ - __spawnQueue_add_4((GenFunction_4)func_802C4218, D_803898D8[D_8037DCB0], *(s32*)(&diff_pos[0]),*(s32*)(&diff_pos[1]),*(s32*)(&diff_pos[2])); + + if (mm_hut_smash_count < 5) { + __spawnQueue_add_4((GenFunction_4) func_802C4218, D_803898D8[mm_hut_smash_count], *(s32 * )(&diff_pos[0]), *(s32 * )(&diff_pos[1]),*(s32 * )(&diff_pos[2])); } - else{ + else { jiggy_spawn(JIGGY_5_MM_HUTS, diff_pos); } - D_8037DCB0 = ( D_8037DCB0 + 1 ) % 6; + + mm_hut_smash_count = (mm_hut_smash_count + 1) % 6; } break; - case HUT_STATE_DAMAGED: - if(animctrl_getAnimTimer(this->animctrl) > 0.99){ + + case HUT_STATE_1_DAMAGED: + if (animctrl_getAnimTimer(this->animctrl) > 0.99) { animctrl_setTransitionDuration(this->animctrl, 0.0f); - subaddie_set_state(this, HUT_STATE_DESTROYED); + subaddie_set_state(this, HUT_STATE_2_DESTROYED); this->position_y -= 160.0f; } break; - case HUT_STATE_DESTROYED: + + case HUT_STATE_2_DESTROYED: break; } - } -void mm_resetHuts(void){ - D_8037DCB0 = 0; +void mm_resetHuts(void) { + mm_hut_smash_count = 0; } -ActorInfo chhutInfo = { MARKER_51_MM_HUT, ACTOR_9_MM_HUT, ASSET_7D7_MODEL_MM_HUT, +ActorInfo chhutInfo = { + MARKER_51_MM_HUT, ACTOR_9_MM_HUT, ASSET_7D7_MODEL_MM_HUT, 0, chhutAnimations, chhut_update, func_80326224, chhut_draw, 0, 0x100, 0.0f, 0 diff --git a/src/core2/ch/gameSelect.c b/src/core2/ch/gameSelect.c index b844bfdd..0fa19ab6 100644 --- a/src/core2/ch/gameSelect.c +++ b/src/core2/ch/gameSelect.c @@ -79,7 +79,7 @@ ActorInfo D_80365F00 = { 0xE6, 0x197, 0x532, 0x1, D_80365ED0, func_802C4C14, fun /* .bss */ -s32 D_8037DCB0; +s32 mm_hut_smash_count; u32 D_8037DCB4; struct FF_StorageStruct* D_8037DCB8; s32 D_8037DCBC; diff --git a/src/core2/code_41FB0.c b/src/core2/code_41FB0.c index 76bb1e53..f159e238 100644 --- a/src/core2/code_41FB0.c +++ b/src/core2/code_41FB0.c @@ -134,45 +134,46 @@ void func_802C8F7C(f32 arg0){ Actor *func_802C8F88(s32 arg0, s32 arg1[3]){ f32 sp1C[3]; - sp1C[0] = arg1[0]; - sp1C[1] = arg1[1]; - sp1C[2] = arg1[2]; + TUPLE_COPY(sp1C, arg1) return func_802C937C(arg0, sp1C); } -Actor *func_802C8FE4(s32 arg0, f32 position[3], Actor *arg2){ +Actor *func_802C8FE4(s32 index, f32 position[3], Actor *arg2) { static f32 D_80366C4C = 400.0f; - struct41FB0s * sp74; //s2 - Actor *actor; //s3 + struct41FB0s *sp74 = D_80366460 + index; + Actor *actor = NULL; //s3 + s32 i; struct41FB0s_1 *s0; - sp74 = D_80366460 + arg0; - actor = NULL; - for(i = 0; i < sp74->count; i++){//L802C90B0 - D_8037DDB4 += 360.0/sp74->count; - while(360.0 <= D_8037DDB4){ D_8037DDB4 -= 360.0;} + for (i = 0; i < sp74->count; i++) {//L802C90B0 + D_8037DDB4 += 360.0 / sp74->count; + while (360.0 <= D_8037DDB4) { D_8037DDB4 -= 360.0; } //L802C9114 - actor =(i == 0 && arg2) ? arg2 : spawn_actor_f32(sp74->actor_id, position, 0); + + actor = (i == 0 && arg2) ? arg2 : spawn_actor_f32(sp74->actor_id, position, 0); actor->unk10_0 = 1; + s0 = (struct41FB0s_1 *) &actor->unkBC; - s0->unk0 = arg0; + s0->unk0 = index; s0->unk2F = 1; s0->unk6 = 1; + ml_vec3f_copy(s0->unk8, actor->position); ml_vec3f_copy(actor->position, s0->unk8); - if(D_8037DDB8 != 1.0f){ - s0->unk14[0] = sp74->unk14*D_8037DDB8; + + if (D_8037DDB8 != 1.0f) { + s0->unk14[0] = sp74->unk14 * D_8037DDB8; s0->unk14[1] = sp74->unk1C + randf2(0.0f, sp74->unk20); - s0->unk14[2] = sp74->unk24*D_8037DDB8; + s0->unk14[2] = sp74->unk24 * D_8037DDB8; D_8037DDB8 = 1.0f; } - else{//L802C91CC + else {//L802C91CC s0->unk14[0] = sp74->unk14 + randf2(0.0f, sp74->unk18); s0->unk14[1] = sp74->unk1C + randf2(0.0f, sp74->unk20); s0->unk14[2] = sp74->unk24 + randf2(0.0f, sp74->unk28); - }//L802C9210 + ml_vec3f_yaw_rotate_copy(s0->unk14, s0->unk14, D_8037DDB4); s0->unk24 = D_80366C4C *= -1; actor->yaw = s0->unk20 = (sp74->unk0 & 0x20) ? sp74->unk30 : randf2(0.0f, 360.0f); @@ -180,11 +181,13 @@ Actor *func_802C8FE4(s32 arg0, f32 position[3], Actor *arg2){ s0->unk2C = 0; s0->unk2D = 1; s0->unk4 = sp74->unk0; - s0->unk2E = (sp74->unk0 & 0x1) ? (0.5 < randf()) : 0 ; - if(sp74->unk0 & 0x200){ + s0->unk2E = (sp74->unk0 & 0x1) ? (0.5 < randf()) : 0; + + if (sp74->unk0 & 0x200) { actor->unk5C = s0->unk8[1]; } }//L802C92E8 + return actor; } @@ -194,7 +197,7 @@ Actor *func_802C9334(s32 arg0, Actor * arg1){ } Actor *func_802C937C(s32 arg0, f32 position[3]){ - return func_802C8FE4(arg0, position, 0); + return func_802C8FE4(arg0, position, NULL); } bool func_802C939C(Actor *actor, f32 arg1[3], f32 arg2[3], f32 arg3[3], bool arg4) {