From bf33a8f7137d0341b853a8000f1ca3f1c5fbb481 Mon Sep 17 00:00:00 2001 From: roeming Date: Sun, 1 Jun 2025 17:11:09 -0400 Subject: [PATCH] link ef_hanabira --- configure.py | 2 +- src/effect/ef_hanabira.c | 78 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 74 insertions(+), 6 deletions(-) diff --git a/configure.py b/configure.py index 8bda1d96..29fe43d6 100644 --- a/configure.py +++ b/configure.py @@ -1266,7 +1266,7 @@ config.libs = [ Object(Matching, "effect/ef_hanabi_set.c"), Object(Matching, "effect/ef_hanabi_switch.c"), Object(Matching, "effect/ef_hanabi_yanagi.c"), - Object(NonMatching, "effect/ef_hanabira.c"), + Object(Matching, "effect/ef_hanabira.c"), Object(Matching, "effect/ef_hanatiri.c"), Object(Matching, "effect/ef_hirameki_den.c"), Object(Matching, "effect/ef_hirameki_hikari.c"), diff --git a/src/effect/ef_hanabira.c b/src/effect/ef_hanabira.c index 93c9930d..a7092821 100644 --- a/src/effect/ef_hanabira.c +++ b/src/effect/ef_hanabira.c @@ -1,10 +1,17 @@ #include "ef_effect_control.h" +#include "m_common_data.h" +#include "m_rcp.h" +#include "sys_matrix.h" +#include "m_debug.h" static void eHanabira_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1); static void eHanabira_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg); static void eHanabira_mv(eEC_Effect_c* effect, GAME* game); static void eHanabira_dw(eEC_Effect_c* effect, GAME* game); - +#define EFFECT_LIFETIME 60 +extern Gfx ef_hana01_pa_a_modelT[], ef_hana01_co_a_modelT[], ef_hana01_tu_a_modelT[], ef_hana01_ha_a_modelT[]; +Gfx* ef_hanabira_model_tbl[] = { ef_hana01_pa_a_modelT, ef_hana01_co_a_modelT, ef_hana01_tu_a_modelT, + ef_hana01_ha_a_modelT }; eEC_PROFILE_c iam_ef_hanabira = { // clang-format off &eHanabira_init, @@ -18,17 +25,78 @@ eEC_PROFILE_c iam_ef_hanabira = { }; static void eHanabira_init(xyz_t pos, int prio, s16 angle, GAME* game, u16 item_name, s16 arg0, s16 arg1) { - // TODO + eEC_CLIP->make_effect_proc(eEC_EFFECT_HANABIRA, pos, NULL, game, NULL, item_name, prio, arg0, arg1); } static void eHanabira_ct(eEC_Effect_c* effect, GAME* game, void* ct_arg) { - // TODO + f32 v; + effect->effect_specific[0] = effect->arg0 / 3; + effect->effect_specific[1] = effect->arg0 % 3; + effect->timer = EFFECT_LIFETIME; + v = RANDOM_F(0.5f) + 3.f; + + if (effect->arg1 == 2 || effect->arg1 == 3 || effect->arg1 == 1) { + v *= 1.5f; + } + + eEC_CLIP->random_first_speed_proc(&effect->velocity, v, 32.f, 32.f); + effect->acceleration.x = 0.f; + effect->acceleration.y = -effect->velocity.y * 0.05f; + effect->acceleration.z = 0.f; + effect->offset = ZeroVec; + effect->effect_specific[4] = qrand(); + effect->effect_specific[2] = qrand(); + effect->effect_specific[3] = qrand(); + effect->scale.x = effect->scale.y = effect->scale.z = 0.009f; + effect->effect_specific[5] = FALSE; } static void eHanabira_mv(eEC_Effect_c* effect, GAME* game) { - // TODO + xyz_t_add(&effect->velocity, &effect->acceleration, &effect->velocity); + xyz_t_add(&effect->position, &effect->velocity, &effect->position); + if (effect->effect_specific[5] == FALSE) { + effect->effect_specific[4] += 0xa00; + effect->effect_specific[2] += 0x280; + effect->effect_specific[3] += 0x280; + if (effect->velocity.y <= 0.f) { + effect->effect_specific[5] = TRUE; + effect->acceleration.y = -0.05f; + } + + } else { + f32 s = sin_s(effect->effect_specific[4]) * 2.f; + effect->offset.x = s; + effect->offset.y = 0.f; + effect->offset.z = -s; + effect->effect_specific[4] += 0xa00; + effect->effect_specific[2] += 0x662; + effect->effect_specific[3] += 0x662; + } } static void eHanabira_dw(eEC_Effect_c* effect, GAME* game) { - // TODO + Mtx* m = GRAPH_ALLOC(game->graph, 0x40); + int v = (u8)eEC_CLIP->calc_adjust_proc(effect->timer, 0, 20, 0.f, 255.f); + OPEN_DISP(game->graph); + _texture_z_light_fog_prim_xlu(game->graph); + suMtxMakeSRT_ZXY(m, effect->scale.x * (GETREG(MYKREG, 0x1b) * 0.01f + 1.f), + effect->scale.y * (GETREG(MYKREG, 0x1b) * 0.01f + 1.f), + effect->scale.z * (GETREG(MYKREG, 0x1b) * 0.01f + 1.f), effect->effect_specific[2], 0, + effect->effect_specific[3], effect->position.x + effect->offset.x, + effect->position.y + effect->offset.y, effect->position.z + effect->offset.z); + switch (effect->effect_specific[1]) { + case 0: { + gSPSegment(NEXT_POLY_XLU_DISP, G_MWO_SEGMENT_8, g_fdinfo->field_palette.flower0_pal); + } break; + case 1: { + gSPSegment(NEXT_POLY_XLU_DISP, G_MWO_SEGMENT_8, g_fdinfo->field_palette.flower1_pal); + } break; + default: { + gSPSegment(NEXT_POLY_XLU_DISP, G_MWO_SEGMENT_8, g_fdinfo->field_palette.flower2_pal); + } break; + } + gSPMatrix(NEXT_POLY_XLU_DISP, m, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(NEXT_POLY_XLU_DISP, 0, 255, 255, 255, 255, v); + gSPDisplayList(NEXT_POLY_XLU_DISP, ef_hanabira_model_tbl[effect->effect_specific[0]]); + CLOSE_DISP(game->graph); }