diff --git a/assets/xml/overlays/ovl_Effect_Ss_Fhg_Flash.xml b/assets/xml/overlays/ovl_Effect_Ss_Fhg_Flash.xml new file mode 100644 index 0000000000..0c23d17cdd --- /dev/null +++ b/assets/xml/overlays/ovl_Effect_Ss_Fhg_Flash.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/include/functions.h b/include/functions.h index 0fe7a0088d..f2a4751fc8 100644 --- a/include/functions.h +++ b/include/functions.h @@ -556,7 +556,7 @@ void EffectSsSibuki_SpawnBurst(PlayState* play, Vec3f* pos); void EffectSsStone1_Spawn(PlayState* play, Vec3f* pos, s32 reg0); void EffectSsHitmark_SpawnFixedScale(PlayState* play, s32 type, Vec3f* pos); void EffectSsHitmark_SpawnCustomScale(PlayState* play, s32 type, s16 scale, Vec3f* pos); -// void EffectSsFhgFlash_SpawnShock(UNK_TYPE4 uParm1, UNK_TYPE4 uParm2, Vec3f* pzParm3, UNK_TYPE2 uParm4, UNK_TYPE1 param_5); +void EffectSsFhgFlash_SpawnShock(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, u8 params); // void EffectSsKFire_Spawn(UNK_TYPE4 uParm1, Vec3f* pzParm2, Vec3f* pzParm3, Vec3f* pzParm4, UNK_TYPE2 param_5, UNK_TYPE1 param_6); void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16* linkDetected, s16 drawFlag); void EffectSsKakera_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objId, Gfx* dList); diff --git a/spec b/spec index 45aa80624e..851d5c40e0 100644 --- a/spec +++ b/spec @@ -1872,8 +1872,7 @@ beginseg name "ovl_Effect_Ss_Fhg_Flash" compress include "build/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.o" - include "build/data/ovl_Effect_Ss_Fhg_Flash/ovl_Effect_Ss_Fhg_Flash.data.o" - include "build/data/ovl_Effect_Ss_Fhg_Flash/ovl_Effect_Ss_Fhg_Flash.reloc.o" + include "build/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/ovl_Effect_Ss_Fhg_Flash_reloc.o" endseg beginseg diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index b6a5c46fa0..f9592478e2 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/src/code/z_effect_soft_sprite_old_init.c @@ -659,15 +659,15 @@ void EffectSsHitmark_SpawnCustomScale(PlayState* play, s32 type, s16 scale, Vec3 * param determines where the ligntning should go * 0: dont attach to any actor. spawns at the position specified by pos * 1: spawn at one of Player's body parts, chosen at random - * 2: spawn at one of Phantom Ganon's body parts, chosen at random + * 2 - 6: spawn at one of Goht's body parts */ -void EffectSsFhgFlash_SpawnShock(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, u8 param) { +void EffectSsFhgFlash_SpawnShock(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, u8 params) { EffectSsFhgFlashInitParams initParams; initParams.actor = actor; Math_Vec3f_Copy(&initParams.pos, pos); initParams.scale = scale; - initParams.param = param; + initParams.params = params; initParams.type = FHGFLASH_SHOCK; EffectSs_Spawn(play, EFFECT_SS_FHG_FLASH, 128, &initParams); diff --git a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h index ce809a32a1..4b82270210 100644 --- a/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h +++ b/src/overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h @@ -18,13 +18,22 @@ typedef struct BossHakuginEffect { #define BOSS_HAKUGIN_EFFECT_COUNT 180 +typedef struct BossHakuginFhgFlashUnkStruct { + /* 0x00 */ Vec3f unk_00; + /* 0x0C */ char unk_0C[0x8]; +} BossHakuginFhgFlashUnkStruct; // size = 0x14 + typedef struct BossHakugin { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_0144[0x44]; /* 0x0188 */ BossHakuginActionFunc actionFunc; - /* 0x018C */ char unk_018C[0x86C]; + /* 0x018C */ char unk_018C[0x5]; + /* 0x0191 */ u8 unk_191; + /* 0x018C */ char unk_0192[0x866]; /* 0x09F8 */ BossHakuginEffect unk_9F8[BOSS_HAKUGIN_EFFECT_COUNT]; - /* 0x2618 */ char unk_2618[0x11F8]; + /* 0x2618 */ char unk_2618[0x8E8]; + /* 0x2F00 */ BossHakuginFhgFlashUnkStruct unk_2F00[7][15]; + /* 0x3734 */ char unk_3734[0xDC]; } BossHakugin; // size = 0x3810 extern const ActorInit Boss_Hakugin_InitVars; diff --git a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c index 073b6bb1d6..764828bf4f 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c +++ b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.c @@ -1,27 +1,119 @@ /* * File: z_eff_ss_fhg_flash.c * Overlay: ovl_Effect_Ss_Fhg_Flash - * Description: + * Description: Shock and Light Ball Effect */ #include "z_eff_ss_fhg_flash.h" +#include "overlays/actors/ovl_Boss_Hakugin/z_boss_hakugin.h" +#include "assets/overlays/ovl_Effect_Ss_Fhg_Flash/ovl_Effect_Ss_Fhg_Flash.h" + +#define rAlpha regs[0] +#define rXZRot regs[3] +#define rParams regs[4] +#define rScale regs[8] #define PARAMS ((EffectSsFhgFlashInitParams*)initParamsx) -s32 EffectSsFhgFlash_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); +u32 EffectSsFhgFlash_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx); void EffectSsFhgFlash_Update(PlayState* play, u32 index, EffectSs* this); void EffectSsFhgFlash_Draw(PlayState* play, u32 index, EffectSs* this); -#if 0 const EffectSsInit Effect_Ss_Fhg_Flash_InitVars = { EFFECT_SS_FHG_FLASH, EffectSsFhgFlash_Init, }; -#endif +u32 EffectSsFhgFlash_Init(PlayState* play, u32 index, EffectSs* this, void* initParamsx) { + static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; + EffectSsFhgFlashInitParams* initParams = PARAMS; + Vec3f noActorPos = { 0.0f, -1000.0f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Fhg_Flash/EffectSsFhgFlash_Init.s") + this->actor = initParams->actor; + Math_Vec3f_Copy(&this->velocity, &gZeroVec3f); + Math_Vec3f_Copy(&this->accel, &gZeroVec3f); + this->life = (s32)(Rand_ZeroOne() * 10.0f) + 111; + this->rScale = (s32)Rand_ZeroFloat(initParams->scale) + initParams->scale; + this->rAlpha = 255; + this->draw = EffectSsFhgFlash_Draw; + this->update = EffectSsFhgFlash_Update; + this->rParams = initParams->params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Fhg_Flash/EffectSsFhgFlash_Draw.s") + if (initParams->params != FHGFLASH_SHOCK_NO_ACTOR) { + this->pos = noActorPos; + this->gfx = gEffFhgFlashDL; + } else { + this->pos = initParams->pos; + this->gfx = gEffFhgFlashDL; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Effect_Ss_Fhg_Flash/EffectSsFhgFlash_Update.s") + return 1; +} + +#include "overlays/ovl_Effect_Ss_Fhg_Flash/ovl_Effect_Ss_Fhg_Flash.c" + +void EffectSsFhgFlash_Draw(PlayState* play, u32 index, EffectSs* this) { + s32 pad; + GraphicsContext* gfxCtx = play->state.gfxCtx; + f32 scale = this->rScale / 100.0f; + + OPEN_DISPS(gfxCtx); + + Matrix_Translate(this->pos.x, this->pos.y, this->pos.z, MTXMODE_NEW); + Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); + if (this->rParams != FHGFLASH_SHOCK_NO_ACTOR) { + func_8012C448(play->state.gfxCtx); + Matrix_RotateXS(this->rXZRot, MTXMODE_APPLY); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_DECAL2); + } else { + func_8012C2DC(play->state.gfxCtx); + Matrix_ReplaceRotation(&play->billboardMtxF); + gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); + } + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, this->rAlpha); + gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 155, 0); + Matrix_RotateZS(this->rXZRot, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gSPDisplayList(POLY_XLU_DISP++, this->gfx); + + CLOSE_DISPS(gfxCtx); +} + +void EffectSsFhgFlash_Update(PlayState* play, u32 index, EffectSs* this) { + s16 randBodyPart; + s16 rand = Rand_ZeroOne() * 20000.0f; + + this->rXZRot = (this->rXZRot + rand) + 0x4000; + if (this->rParams == FHGFLASH_SHOCK_PLAYER) { + Player* player = GET_PLAYER(play); + + randBodyPart = Rand_ZeroFloat(18 - 0.1f); + this->pos.x = player->bodyPartsPos[randBodyPart].x + randPlusMinusPoint5Scaled(10.0f); + this->pos.y = player->bodyPartsPos[randBodyPart].y + randPlusMinusPoint5Scaled(15.0f); + this->pos.z = player->bodyPartsPos[randBodyPart].z + randPlusMinusPoint5Scaled(10.0f); + } else if ((this->rParams >= FHGFLASH_SHOCK_GOHT_2) && (this->rParams <= FHGFLASH_SHOCK_GOHT_6)) { + s32 pad; + Vec3f* bodyPartPos; + BossHakugin* goht = (BossHakugin*)this->actor; + s32 index = goht->unk_191 - 3; + + if (index < 0) { + bodyPartPos = &goht->unk_2F00[this->rParams][12].unk_00; + } else { + bodyPartPos = &goht->unk_2F00[this->rParams][index].unk_00; + } + + this->pos.x = randPlusMinusPoint5Scaled(70.0f) + bodyPartPos->x; + this->pos.y = randPlusMinusPoint5Scaled(70.0f) + bodyPartPos->y; + this->pos.z = randPlusMinusPoint5Scaled(70.0f) + bodyPartPos->z; + } + if (this->life < 100) { + this->rAlpha -= 50; + if (this->rAlpha < 0) { + this->rAlpha = 0; + this->life = 0; + } + } +} diff --git a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h index 0598377f87..c464047b58 100644 --- a/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h +++ b/src/overlays/effects/ovl_Effect_Ss_Fhg_Flash/z_eff_ss_fhg_flash.h @@ -23,7 +23,11 @@ typedef enum { typedef enum { /* 0x00 */ FHGFLASH_SHOCK_NO_ACTOR, /* 0x01 */ FHGFLASH_SHOCK_PLAYER, - /* 0x02 */ FHGFLASH_SHOCK_PG + /* 0x02 */ FHGFLASH_SHOCK_GOHT_2, + /* 0x03 */ FHGFLASH_SHOCK_GOHT_3, + /* 0x04 */ FHGFLASH_SHOCK_GOHT_4, + /* 0x05 */ FHGFLASH_SHOCK_GOHT_5, + /* 0x06 */ FHGFLASH_SHOCK_GOHT_6 } FhgFlashLightningParam; typedef struct { @@ -31,7 +35,7 @@ typedef struct { /* 0x0C */ Vec3f velocity; /* 0x18 */ Vec3f accel; /* 0x24 */ s16 scale; - /* 0x26 */ u8 param; + /* 0x26 */ u8 params; /* 0x28 */ Actor* actor; /* 0x2C */ u8 type; } EffectSsFhgFlashInitParams; // size = 0x30