From 6208ea22bcabfba448f3ec6537ff7d58a664469e Mon Sep 17 00:00:00 2001 From: Owlenuff Date: Mon, 30 Sep 2024 19:35:49 +0200 Subject: [PATCH] Documented ch Loggo --- include/functions.h | 2 +- src/MMM/ch/loggo.c | 80 ++++++++++++++++++++++++------------------ src/core2/code_9E370.c | 15 ++++---- 3 files changed, 56 insertions(+), 41 deletions(-) diff --git a/include/functions.h b/include/functions.h index 9e0f31f0..5d72cf37 100644 --- a/include/functions.h +++ b/include/functions.h @@ -406,7 +406,7 @@ int func_80328A2C(Actor *, f32, s32, f32); void subaddie_set_state(Actor *, u32); ActorMarker *func_8032B16C(enum jiggy_e jiggy_id); int subaddie_maybe_set_state(Actor *, s32, f32); -void subaddie_set_state_with_direction(Actor * this, s32 myAnimId, f32 arg2, s32 direction); +void subaddie_set_state_with_direction(Actor * this, s32 myAnimId, f32 anim_start_position, s32 direction); bool subaddie_maybe_set_state_position_direction(Actor *, s32, f32, s32, f32 ); void func_80328CEC(Actor *, s32, s32, s32); void func_80328FB0(Actor *, f32); diff --git a/src/MMM/ch/loggo.c b/src/MMM/ch/loggo.c index 5d0809b8..36f4131c 100644 --- a/src/MMM/ch/loggo.c +++ b/src/MMM/ch/loggo.c @@ -2,11 +2,18 @@ #include "functions.h" #include "variables.h" +/* extern functions */ extern void ml_vec3f_assign(f32[3], f32, f32, f32); +/* public functions */ void chLoggo_update(Actor *this); /* .data */ +enum chLoggo_state_e { + LOGGO_STATE_1_IDLE = 1, + LOGGO_STATE_2_FLUSHING +}; + ActorAnimationInfo chLoggoAnimations[] = { {0, 0.0f}, {ASSET_238_ANIM_LOGGO_IDLE, 0.8f}, @@ -14,108 +21,113 @@ ActorAnimationInfo chLoggoAnimations[] = { }; ActorInfo chLoggo = { - MARKER_252_LOGGO, ACTOR_37F_LOGGO, ASSET_519_MODEL_LOGGO, - 0x1, chLoggoAnimations, - chLoggo_update, func_80326224, actor_draw, + MARKER_252_LOGGO, ACTOR_37F_LOGGO, ASSET_519_MODEL_LOGGO, + 0x1, chLoggoAnimations, + chLoggo_update, func_80326224, actor_draw, 1000, 0, 0.0f, 0 }; /* .code */ -void __chLoggo_flush(ActorMarker* marker) { - Actor* actor = marker_getActor(marker); +void __chLoggo_flush(ActorMarker *marker) { + Actor *actor = marker_getActor(marker); func_8028F918(2); - subaddie_set_state_with_direction(actor, 2, 0.01, 1); + subaddie_set_state_with_direction(actor, LOGGO_STATE_2_FLUSHING, 0.01, 1); actor_playAnimationOnce(actor); actor->lifetime_value = 3.2f; } -void __chLoggo_textCallback(ActorMarker* caller, enum asset_e text_id, s32 arg3) { +void __chLoggo_textCallback(ActorMarker *caller, enum asset_e text_id, s32 arg3) { __chLoggo_flush(caller); } -void __chLoggo_collide(ActorMarker* this_marker, ActorMarker *other_marker) { +void __chLoggo_collide(ActorMarker *this_marker, ActorMarker *other_marker) { Actor *this = marker_getActor(this_marker); + if ((player_getTransformation() == TRANSFORM_3_PUMPKIN) && !fileProgressFlag_get(FILEPROG_89_ENTERED_LOGGO_AS_PUMPKIN)) { if (gcdialog_showText(ASSET_ADF_TEXT_ENTER_LOGGO, 0x2B, this->position, this->marker, &__chLoggo_textCallback, 0) != 0) { actor_collisionOff(this); - fileProgressFlag_set(FILEPROG_89_ENTERED_LOGGO_AS_PUMPKIN, TRUE); } return; } + if ((player_getTransformation() == TRANSFORM_3_PUMPKIN) && fileProgressFlag_get(FILEPROG_89_ENTERED_LOGGO_AS_PUMPKIN)) { actor_collisionOff(this); __chLoggo_flush(this_marker); return; } - if ((player_getTransformation() == TRANSFORM_1_BANJO) && !fileProgressFlag_get(FILEPROG_88_TRIED_LOGGO_AS_BEAR)){ - if(gcdialog_showText(ASSET_ADE_TEXT_LOGGO_AS_BEAR, 0x2A, this->position, NULL, NULL, NULL)) { + if ((player_getTransformation() == TRANSFORM_1_BANJO) && !fileProgressFlag_get(FILEPROG_88_TRIED_LOGGO_AS_BEAR)) { + if (gcdialog_showText(ASSET_ADE_TEXT_LOGGO_AS_BEAR, 0x2A, this->position, NULL, NULL, NULL)) { fileProgressFlag_set(FILEPROG_88_TRIED_LOGGO_AS_BEAR, TRUE); } } } -void chLoggo_update(Actor *this){ - f32 sp44; - f32 sp38[3]; +void chLoggo_update(Actor *this) { + f32 tick; + f32 position[3]; s32 sp34; - sp44 = time_getDelta(); - if(!this->volatile_initialized){ + tick = time_getDelta(); + + if (!this->volatile_initialized) { this->volatile_initialized = TRUE; this->marker->propPtr->unk8_3 = TRUE; + actor_collisionOn(this); marker_setCollisionScripts(this->marker, __chLoggo_collide, NULL, NULL); - subaddie_set_state_with_direction(this, 1, 0.01f, 1); + + subaddie_set_state_with_direction(this, LOGGO_STATE_1_IDLE, 0.01f, 1); actor_loopAnimation(this); + this->lifetime_value = 0.0f; - if(!fileProgressFlag_get(FILEPROG_8A_EXITED_LOGGO) && levelSpecificFlags_get(0x33)){ - if(gcdialog_showText(ASSET_AE0_TEXT_EXIT_LOGGO, 4, NULL, NULL, NULL, NULL)){ + + if (!fileProgressFlag_get(FILEPROG_8A_EXITED_LOGGO) && levelSpecificFlags_get(0x33)) { + if (gcdialog_showText(ASSET_AE0_TEXT_EXIT_LOGGO, 4, NULL, NULL, NULL, NULL)) { fileProgressFlag_set(FILEPROG_8A_EXITED_LOGGO, TRUE); } } } - switch(this->state){ - case 1: + switch (this->state) { + case LOGGO_STATE_1_IDLE: sp34 = func_803114B0() ? 12000 : 0; - if(actor_animationIsAt(this, 0.09f)){ + if (actor_animationIsAt(this, 0.09f)) { func_8030E878(SFX_109_LOGGO_LID_CLAP, randf2(0.975f, 1.025f), MAX(0, 22000 - sp34), this->position, 400.0f, 1000.0f); break; } - if(actor_animationIsAt(this, 0.37f)){ + if (actor_animationIsAt(this, 0.37f)) { func_8030E878(SFX_20_METAL_CLANK_1, randf2(1.675f, 1.725f), MAX(0, 12000 - sp34), this->position, 400.0f, 1000.0f); break; } - if(actor_animationIsAt(this, 0.6f)){ + if (actor_animationIsAt(this, 0.6f)) { func_8030E878(SFX_3F_CAULDRON_SQEAK_1, randf2(0.975f, 1.025f), MAX(0, 7000 - sp34), this->position, 400.0f, 1000.0f); break; } - - if(actor_animationIsAt(this, 0.16f)){ + + if (actor_animationIsAt(this, 0.16f)) { func_8030E878(SFX_40_CAULDRON_SQEAK_2, randf2(0.975f, 1.025f), MAX(0, 7000 - sp34), this->position, 400.0f, 1000.0f); break; } - break; - case 2: - if(actor_animationIsAt(this, 0.46f)){ + case LOGGO_STATE_2_FLUSHING: + if (actor_animationIsAt(this, 0.46f)) { this->marker->propPtr->unk8_3 = FALSE; FUNC_8030E8B4(SFX_92_TOILET_FLUSH, 1.0f, 32000, this->position, 600, 1500); levelSpecificFlags_set(0x33, TRUE); - ml_vec3f_assign(sp38, this->position_x - 50.0f, this->position_y + 50.0f, this->position_z); - func_8028F6E4(BS_INTR_2F_LOGGO, sp38); + ml_vec3f_assign(position, this->position_x - 50.0f, this->position_y + 50.0f, this->position_z); + func_8028F6E4(BS_INTR_2F_LOGGO, position); } - if(0.0 < this->lifetime_value){ - this->lifetime_value -= sp44; + if (0.0 < this->lifetime_value) { + this->lifetime_value -= tick; } - else{ + else { warp_mmmEnterLoggo(0, 0); } break; diff --git a/src/core2/code_9E370.c b/src/core2/code_9E370.c index 9805d8d1..c356bbba 100644 --- a/src/core2/code_9E370.c +++ b/src/core2/code_9E370.c @@ -1190,9 +1190,11 @@ static bool __subaddie_set_state(Actor *this, s32 state) void func_803285E8(Actor *this, f32 anim_start_position, int direction){ animctrl_setStart(this->animctrl, anim_start_position); - if(direction != -1){ + + if (direction != -1) { animctrl_setDirection(this->animctrl, direction); } + this->sound_timer = anim_start_position; } @@ -1275,8 +1277,8 @@ int actor_animationIsAt(Actor *this, f32 arg1){ } } -void func_803289EC(Actor *this , f32 arg1, int direction){ - func_803285E8(this, arg1, direction); +void func_803289EC(Actor *this , f32 anim_start_position, int direction){ + func_803285E8(this, anim_start_position, direction); animctrl_start(this->animctrl, "subaddie.c", 0x6b1); } @@ -1316,9 +1318,10 @@ int subaddie_maybe_set_state(Actor *this, s32 myAnimId, f32 chance){ return 0; } -void subaddie_set_state_with_direction(Actor * this, s32 myAnimId, f32 arg2, s32 direction){ - if(__subaddie_set_state(this, myAnimId) && this->animctrl) - func_803289EC(this, arg2, direction); +void subaddie_set_state_with_direction(Actor * this, s32 myAnimId, f32 anim_start_position, s32 direction){ + if (__subaddie_set_state(this, myAnimId) && this->animctrl) { + func_803289EC(this, anim_start_position, direction); + } } bool subaddie_maybe_set_state_position_direction(Actor *this, s32 myAnimId, f32 start_position, s32 direction, f32 probability) {