From 7883c762dffa251f1b6b955884aa31e0d6aa581b Mon Sep 17 00:00:00 2001 From: Nabnut Date: Thu, 19 Sep 2024 12:31:56 +0200 Subject: [PATCH] Renaming Orange --- src/MM/ch/chimpystump.c | 1 - src/MM/ch/orange.c | 88 +++++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/MM/ch/chimpystump.c b/src/MM/ch/chimpystump.c index d6592cfc..6af64942 100644 --- a/src/MM/ch/chimpystump.c +++ b/src/MM/ch/chimpystump.c @@ -9,7 +9,6 @@ void func_80353064(f32 *, f32); void func_802BB3DC(s32, f32, f32); void func_80244BB0(s32, s32, s32, f32); -s32 mapSpecificFlags_get(s32); /* public function declarations */ void chchimpystump_update(Actor *this); diff --git a/src/MM/ch/orange.c b/src/MM/ch/orange.c index 2f55011b..1cc9584a 100644 --- a/src/MM/ch/orange.c +++ b/src/MM/ch/orange.c @@ -3,103 +3,105 @@ #include "functions.h" #include "variables.h" -#ifndef MIN -#define MIN(s,t) ((s < t)?(s):(t)) -#endif - -#ifndef ORANGE_FALLING_STATE -#define ORANGE_FALLING_STATE 1 -#endif - -#ifndef ORANGE_LANDED_STATE -#define ORANGE_LANDED_STATE 2 -#endif - /* extern functions */ -f32 mapModel_getFloorY(f32*); +f32 mapModel_getFloorY(f32 *); /* public functions */ -void MM_func_80387FF4(Actor *this); -Actor* func_80388188(ActorMarker *, Gfx **, Mtx**, Vtx**); +void chorange_update(Actor *this); +Actor *chorange_draw(ActorMarker *, Gfx **, Mtx **, Vtx **); /* .data */ -ActorInfo chorangeInfo = { MARKER_C_ORANGE_PROJECTILE, ACTOR_14_ORANGE_PROJECTILE, ASSET_2D2_MODEL_ORANGE, +enum chorange_state_e { + ORANGE_STATE_1_FALLING = 1, + ORANGE_STATE_2_LANDED +}; + +ActorInfo chorangeInfo = { + MARKER_C_ORANGE_PROJECTILE, ACTOR_14_ORANGE_PROJECTILE, ASSET_2D2_MODEL_ORANGE, 1, NULL, - MM_func_80387FF4, func_80326224, func_80388188, + chorange_update, func_80326224, chorange_draw, 0, 0, 0.6f, 0 }; -f32 D_803899F4[3] = {0.0f,-8.0f, 0.0f}; +f32 D_803899F4[3] = {0.0f, -8.0f, 0.0f}; f32 D_80389A00[3] = {0.0f, 0.0f, 0.0f}; -void func_80387F90(ActorMarker *arg0, ActorMarker *other_marker){ - if( !func_8028F22C(arg0) - && !mapSpecificFlags_get(MM_SPECIFIC_FLAG_8_HIT_WITH_ORANGE) - && func_80311480(ASSET_B3A_TEXT_CONGA_HITS_PLAYER, 0, 0, 0, NULL, NULL) - ){ +/* .code */ +void __chorange_collisionCallback(ActorMarker *marker, ActorMarker *other_marker) { + if (!func_8028F22C() && + !mapSpecificFlags_get(MM_SPECIFIC_FLAG_8_HIT_WITH_ORANGE) && + func_80311480(ASSET_B3A_TEXT_CONGA_HITS_PLAYER, 0, 0, 0, NULL, NULL)) { + mapSpecificFlags_set(MM_SPECIFIC_FLAG_8_HIT_WITH_ORANGE, TRUE); } - if(arg0); + if (marker); } -void MM_func_80387FF4(Actor * this){ - f32 ground_position_y; +void chorange_update(Actor *this) { + f32 floor_position_y; f32 velocity_y; - if(!this->initialized){ + if (!this->initialized) { this->marker->unk2C_1 = 1; - marker_setCollisionScripts(this->marker, NULL, func_80387F90, NULL); + marker_setCollisionScripts(this->marker, NULL, __chorange_collisionCallback, NULL); } - switch(this->state){ - case ORANGE_FALLING_STATE: + + switch (this->state) { + case ORANGE_STATE_1_FALLING: this->position_x += this->velocity_x; velocity_y = this->velocity_y - 5.0; this->velocity_y = velocity_y; this->position_y += velocity_y; this->position_z += this->velocity_z; - ground_position_y = mapModel_getFloorY(this->position); + floor_position_y = mapModel_getFloorY(this->position); - if(this->position_y < ground_position_y){ - this->position_y = ground_position_y; - this->unk1C_y = ground_position_y; + if (this->position_y < floor_position_y) { + this->position_y = floor_position_y; + this->unk1C_y = floor_position_y; func_8030E6D4(SFX_2F_ORANGE_SPLAT); this->actor_specific_1_f = 1.0f; this->lifetime_value = 340.0f; - this->state = 2; + this->state = ORANGE_STATE_2_LANDED; } break; - case ORANGE_LANDED_STATE: - if(this->lifetime_value < 324.0){ + + case ORANGE_STATE_2_LANDED: + if (this->lifetime_value < 324.0) { this->marker->collidable = FALSE; } + this->lifetime_value -= 4.0; - if(this->lifetime_value < 4.0){ + + if (this->lifetime_value < 4.0) { marker_despawn(this->marker); } break; } } -Actor *func_80388188(ActorMarker *this, Gfx **dl, Mtx **mptr, Vtx **vtx){ - Actor* actorPtr = actor_drawFullDepth(this, dl, mptr, vtx); +Actor *chorange_draw(ActorMarker *this, Gfx **dl, Mtx **mptr, Vtx **vtx) { + Actor *actorPtr = actor_drawFullDepth(this, dl, mptr, vtx); f32 sp60[3] = D_803899F4; f32 rotation[3] = D_80389A00; f32 position[3]; - if(actorPtr->state == 2){ + if (actorPtr->state == ORANGE_STATE_2_LANDED) { position[0] = actorPtr->position_x; position[1] = actorPtr->unk1C_y + 3.0f; position[2] = actorPtr->position_z; - modelRender_setAlpha( (s32) MIN(255.0f, actorPtr->lifetime_value) ); + + modelRender_setAlpha((s32) MIN(255.0f, actorPtr->lifetime_value)); modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); modelRender_draw(dl, mptr, position, rotation, actorPtr->actor_specific_1_f, sp60, func_8030A428(0x18)); actorPtr->position_y -= 1.9; - if(actorPtr->actor_specific_1_f < 2.428){ + + if (actorPtr->actor_specific_1_f < 2.428) { actorPtr->actor_specific_1_f += 0.1; } } + return actorPtr; }