diff --git a/assets/xml/objects/object_snowman.xml b/assets/xml/objects/object_snowman.xml index 91b650a75c..fde2d911fc 100644 --- a/assets/xml/objects/object_snowman.xml +++ b/assets/xml/objects/object_snowman.xml @@ -1,49 +1,77 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index a2d9a9ef37..f6b19ee8a9 100644 --- a/spec +++ b/spec @@ -3820,8 +3820,7 @@ beginseg name "ovl_En_Snowman" compress include "build/src/overlays/actors/ovl_En_Snowman/z_en_snowman.o" - include "build/data/ovl_En_Snowman/ovl_En_Snowman.data.o" - include "build/data/ovl_En_Snowman/ovl_En_Snowman.reloc.o" + include "build/src/overlays/actors/ovl_En_Snowman/ovl_En_Snowman_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c index 32d38ecb92..6836858890 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.c @@ -1,7 +1,7 @@ /* * File: z_en_snowman.c * Overlay: ovl_En_Snowman - * Description: Enos + * Description: Eeno */ #include "z_en_snowman.h" @@ -15,21 +15,52 @@ void EnSnowman_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx); void EnSnowman_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80B1746C(EnSnowman* this, GlobalContext* globalCtx); -void func_80B178B8(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17A58(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17D78(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17EFC(EnSnowman* this, GlobalContext* globalCtx); -void func_80B17FE0(EnSnowman* this, GlobalContext* globalCtx); -void func_80B18124(EnSnowman* this, GlobalContext* globalCtx); -void func_80B183A4(EnSnowman* this, GlobalContext* globalCtx); -void func_80B1848C(EnSnowman* this, GlobalContext* globalCtx); -void func_80B1861C(EnSnowman* this, GlobalContext* globalCtx); -void func_80B189C4(EnSnowman* this, GlobalContext* globalCtx); -void func_80B18A04(EnSnowman* this, GlobalContext* globalCtx); -void func_80B18C7C(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupMoveSnowPile(EnSnowman* this); +void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupEmerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Emerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupReadySnowball(EnSnowman* this); +void EnSnowman_ReadySnowball(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupThrowSnowball(EnSnowman* this); +void EnSnowman_ThrowSnowball(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupIdle(EnSnowman* this); +void EnSnowman_Idle(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupSubmerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Submerge(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Melt(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Stun(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_Damaged(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupDead(EnSnowman* this); +void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupSplitDoNothing(EnSnowman* this); +void EnSnowman_SplitDoNothing(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_SetupMarkForDeath(EnSnowman* this); +void EnSnowman_MarkForDeath(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_CreateSplitEeno(EnSnowman* this, Vec3f* basePos, s32 yRot); +void EnSnowman_SetupCombine(EnSnowman* this, GlobalContext* globalCtx, Vec3f* combinePos); +void EnSnowman_Combine(EnSnowman* this, GlobalContext* globalCtx); +void EnSnowman_UpdateSnowball(Actor* thisx, GlobalContext* globalCtx); +void EnSnowman_DrawSnowPile(Actor* thisx, GlobalContext* globalCtx); +void EnSnowman_DrawSnowball(Actor* thisx, GlobalContext* globalCtx); + +typedef enum { + // Indicates that this split Eeno is not currently trying to combine into a large Eeno. + /* 0 */ EN_SNOWMAN_COMBINE_STATE_NONE, + + // Indicates that this split Eeno is actively trying to combine into a large Eeno again. + // Eenos in this state can both absorb other Eenos and start being absorbed themselves. + /* 1 */ EN_SNOWMAN_COMBINE_STATE_ACTIVE, + + // Indicates that this Eeno cannot absorb other Eenos to combine into a large Eeno. + // It can still be absorbed by Eenos in the EN_SNOWMAN_COMBINE_STATE_ACTIVE state. + /* 2 */ EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION, + + // Indicates that either this Eeno is shrinking having been absorbed by another Eeno, or that + // this Eeno is a fully-combined large Eeno and is done trying to combine with other split + // Eenos. In both cases, this Eeno cannot be absorbed by any other Eeno. + /* 3 */ EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE, +} EnSnowmanCombineState; -#if 0 const ActorInit En_Snowman_InitVars = { ACTOR_EN_SNOWMAN, ACTORCAT_ENEMY, @@ -42,155 +73,1125 @@ const ActorInit En_Snowman_InitVars = { (ActorFunc)EnSnowman_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B19A00 = { - { COLTYPE_HIT4, AT_NONE, AC_ON | AC_TYPE_PLAYER, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON | BUMP_HOOKABLE, OCELEM_ON, }, +static ColliderCylinderInit sEenoCylinderInit = { + { + COLTYPE_HIT4, + AT_NONE, + AC_ON | AC_TYPE_PLAYER, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0.0f, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON | BUMP_HOOKABLE, + OCELEM_ON, + }, { 60, 80, 0, { 0, 0, 0 } }, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80B19A2C = { - { COLTYPE_NONE, AT_ON | AT_TYPE_ENEMY, AC_ON | AC_TYPE_PLAYER, OC1_NONE | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0xF7CFFFFF, 0x00, 0x04 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_ON | TOUCH_SFX_NONE, BUMP_ON, OCELEM_ON, }, +static ColliderCylinderInit sSnowballCylinderInit = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_ENEMY, + AC_ON | AC_TYPE_PLAYER, + OC1_NONE | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0xF7CFFFFF, 0x00, 0x04 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NONE, + BUMP_ON, + OCELEM_ON, + }, { 60, 80, 0, { 0, 0, 0 } }, }; -// static DamageTable sDamageTable = { -static DamageTable D_80B19A58 = { - /* Deku Nut */ DMG_ENTRY(0, 0x1), - /* Deku Stick */ DMG_ENTRY(1, 0x0), - /* Horse trample */ DMG_ENTRY(1, 0x0), - /* Explosives */ DMG_ENTRY(1, 0x0), - /* Zora boomerang */ DMG_ENTRY(1, 0x0), - /* Normal arrow */ DMG_ENTRY(1, 0x0), - /* UNK_DMG_0x06 */ DMG_ENTRY(0, 0x0), - /* Hookshot */ DMG_ENTRY(1, 0xF), - /* Goron punch */ DMG_ENTRY(2, 0x0), - /* Sword */ DMG_ENTRY(1, 0x0), - /* Goron pound */ DMG_ENTRY(1, 0x0), - /* Fire arrow */ DMG_ENTRY(2, 0x2), - /* Ice arrow */ DMG_ENTRY(1, 0x0), - /* Light arrow */ DMG_ENTRY(2, 0x4), - /* Goron spikes */ DMG_ENTRY(1, 0x0), - /* Deku spin */ DMG_ENTRY(0, 0x1), - /* Deku bubble */ DMG_ENTRY(1, 0x0), - /* Deku launch */ DMG_ENTRY(2, 0x0), - /* UNK_DMG_0x12 */ DMG_ENTRY(0, 0x1), - /* Zora barrier */ DMG_ENTRY(0, 0x5), - /* Normal shield */ DMG_ENTRY(0, 0x0), - /* Light ray */ DMG_ENTRY(0, 0x0), - /* Thrown object */ DMG_ENTRY(1, 0x0), - /* Zora punch */ DMG_ENTRY(1, 0x0), - /* Spin attack */ DMG_ENTRY(1, 0x0), - /* Sword beam */ DMG_ENTRY(0, 0x0), - /* Normal Roll */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1B */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1C */ DMG_ENTRY(0, 0x0), - /* Unblockable */ DMG_ENTRY(0, 0x0), - /* UNK_DMG_0x1E */ DMG_ENTRY(0, 0x0), - /* Powder Keg */ DMG_ENTRY(1, 0x0), +typedef enum { + /* 0x0 */ EN_SNOWMAN_DMGEFF_NONE, + /* 0x1 */ EN_SNOWMAN_DMGEFF_STUN, + /* 0x2 */ EN_SNOWMAN_DMGEFF_MELT, + /* 0x4 */ EN_SNOWMAN_DMGEFF_LIGHT_ORB = 0x4, + /* 0x5 */ EN_SNOWMAN_DMGEFF_ELECTRIC_STUN, + /* 0xF */ EN_SNOWMAN_DMGEFF_HOOKSHOT = 0xF, // Damages small Eenos, pulls the player towards large Eenos +} EnTalkGibudDamageEffect; + +static DamageTable sDamageTable = { + /* Deku Nut */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_STUN), + /* Deku Stick */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Horse trample */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Explosives */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Zora boomerang */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Normal arrow */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x06 */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Hookshot */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_HOOKSHOT), + /* Goron punch */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_NONE), + /* Sword */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Goron pound */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Fire arrow */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_MELT), + /* Ice arrow */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Light arrow */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_LIGHT_ORB), + /* Goron spikes */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Deku spin */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_STUN), + /* Deku bubble */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Deku launch */ DMG_ENTRY(2, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x12 */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_STUN), + /* Zora barrier */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_ELECTRIC_STUN), + /* Normal shield */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Light ray */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Thrown object */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Zora punch */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Spin attack */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), + /* Sword beam */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Normal Roll */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x1B */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x1C */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Unblockable */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* UNK_DMG_0x1E */ DMG_ENTRY(0, EN_SNOWMAN_DMGEFF_NONE), + /* Powder Keg */ DMG_ENTRY(1, EN_SNOWMAN_DMGEFF_NONE), }; -// sColChkInfoInit -static CollisionCheckInfoInit D_80B19A78 = { 2, 60, 80, 150 }; +static CollisionCheckInfoInit sColChkInfoInit = { 2, 60, 80, 150 }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80B19AAC[] = { +static Color_RGBA8 sDustPrimColor = { 250, 250, 250, 255 }; + +static Color_RGBA8 sDustEnvColor = { 180, 180, 180, 255 }; + +static Vec3f sDustVelocity = { 0.0f, 1.5f, 0.0f }; + +static Gfx* sSnowballDLs[] = { + gEenoSmallSnowballDL, + gEenoLargeSnowballDL, + gEenoSmallSnowballDL, +}; + +static Gfx* sSnowballFragmentDLs[] = { + gEenoSnowballFragment1DL, + gEenoSnowballFragment2DL, + gEenoSnowballFragment3DL, +}; + +static InitChainEntry sInitChain[] = { ICHAIN_S8(hintId, 20, ICHAIN_CONTINUE), ICHAIN_F32(targetArrowOffset, 3000, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(gravity, -1000, ICHAIN_STOP), }; -#endif +void EnSnowman_Init(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSnowman* this = THIS; + s32 attackRange; -extern ColliderCylinderInit D_80B19A00; -extern ColliderCylinderInit D_80B19A2C; -extern DamageTable D_80B19A58; -extern CollisionCheckInfoInit D_80B19A78; -extern InitChainEntry D_80B19AAC[]; + Actor_ProcessInitChain(thisx, sInitChain); + attackRange = EN_SNOWMAN_GET_ATTACK_RANGE(thisx); + if (attackRange == 0xFF) { + attackRange = 0; + } -extern UNK_TYPE D_06000404; -extern UNK_TYPE D_06004628; -extern UNK_TYPE D_060046D8; -extern UNK_TYPE D_06004F14; -extern UNK_TYPE D_0600554C; -extern UNK_TYPE D_060058CC; + thisx->params &= 7; + if (EN_SNOWMAN_GET_TYPE(thisx) < EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gEenoSkel, &gEenoEmergeAnim, this->jointTable, + this->morphTable, EENO_LIMB_MAX); + SkelAnime_InitFlex(globalCtx, &this->snowPileSkelAnime, &gEenoSnowPileSkel, &gEenoSnowPileMoveAnim, + this->snowPileJointTable, this->snowPileMorphTable, EENO_SNOW_PILE_LIMB_MAX); + CollisionCheck_SetInfo(&thisx->colChkInfo, &sDamageTable, &sColChkInfoInit); + Collider_InitAndSetCylinder(globalCtx, &this->collider, thisx, &sEenoCylinderInit); + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_LARGE) { + thisx->flags |= ACTOR_FLAG_400; + Actor_SpawnAsChild(&globalCtx->actorCtx, thisx, globalCtx, ACTOR_EN_SNOWMAN, thisx->world.pos.x, + thisx->world.pos.y, thisx->world.pos.z, 0, 0, 0, EN_SNOWMAN_TYPE_SPLIT); + thisx->parent = Actor_SpawnAsChildAndCutscene(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SNOWMAN, + thisx->world.pos.x, thisx->world.pos.y, thisx->world.pos.z, 0, + 0, 0, EN_SNOWMAN_TYPE_SPLIT, -1, thisx->unk20, NULL); + if ((thisx->child == NULL) || (thisx->parent == NULL)) { + if (thisx->child != NULL) { + Actor_MarkForDeath(thisx->child); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Init.s") + if (thisx->parent != NULL) { + Actor_MarkForDeath(thisx->parent); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Destroy.s") + Actor_MarkForDeath(thisx); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B16FC0.s") + // Makes each split Eeno the parent or child of other split Eenos + thisx->parent->child = thisx; + thisx->child->child = thisx->parent; + thisx->parent->parent = thisx->child; + if (1) {} + Actor_SetScale(thisx, 0.02f); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17144.s") + this->eenoScale = thisx->scale.x * 100.0f; + this->attackRange = (240.0f * this->eenoScale) + (attackRange * 0.1f * 40.0f); + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SPLIT) { + EnSnowman_SetupSplitDoNothing(this); + } else { + EnSnowman_SetupMoveSnowPile(this); + } + } else { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B173D0.s") + thisx->flags &= ~ACTOR_FLAG_1; + Collider_InitAndSetCylinder(globalCtx, &this->collider, thisx, &sSnowballCylinderInit); + thisx->world.rot.y = Actor_YawBetweenActors(thisx, &player->actor); + thisx->velocity.y = (Actor_XZDistanceBetweenActors(thisx, &player->actor) * 0.035f) + -5.0f; + thisx->velocity.y = CLAMP_MAX(thisx->velocity.y, 3.5f); + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + thisx->speedXZ = 15.0f; + } else { + thisx->speedXZ = 22.5f; + thisx->velocity.y *= 1.5f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B1746C.s") + thisx->world.pos.x += thisx->speedXZ * Math_SinS(thisx->world.rot.y); + thisx->world.pos.y += thisx->velocity.y; + thisx->world.pos.z += thisx->speedXZ * Math_CosS(thisx->world.rot.y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B177EC.s") + if (EN_SNOWMAN_GET_TYPE(thisx) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + this->collider.dim.radius = 8; + this->collider.dim.height = 12; + this->collider.dim.yShift = -6; + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 10.0f); + } else { + this->collider.dim.radius = 50; + this->collider.dim.height = 122; + this->collider.dim.yShift = -8; + this->collider.info.toucher.damage = 16; + thisx->world.pos.y -= 32.0f; + Actor_SetScale(thisx, 0.006f); + ActorShape_Init(&thisx->shape, 16000.0f / 3.0f, ActorShadow_DrawCircle, 170.0f); + thisx->gravity = -1.5f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B178B8.s") + thisx->flags |= ACTOR_FLAG_10; + thisx->update = EnSnowman_UpdateSnowball; + thisx->draw = EnSnowman_DrawSnowball; + this->work.timer = 5; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B179D0.s") +void EnSnowman_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17A58.s") + Collider_DestroyCylinder(globalCtx, &this->collider); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17CE8.s") +/** + * Spawns a circle of snow-colored dust around the actor. + */ +void EnSnowman_SpawnCircularDustEffect(EnSnowman* this, GlobalContext* globalCtx) { + s16 angle = 0; + Vec3f pos; + f32 offset; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17D78.s") + pos.y = (Rand_ZeroFloat(10.0f) * this->eenoScale) + this->actor.world.pos.y; + for (i = 0; i < 16; i++) { + offset = (Rand_ZeroFloat(10.0f) + 20.0f) * this->eenoScale; + pos.x = (Math_SinS(angle) * offset) + this->actor.world.pos.x; + pos.z = (Math_CosS(angle) * offset) + this->actor.world.pos.z; + func_800B0DE0(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, + this->eenoScale * 400.0f, 10); + angle += 0x1000; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17EB4.s") +/** + * Spawns a batch of large snowball fragments and some snow-colored dust at snowballPos. + */ +void EnSnowman_SpawnBigSnowballFragmentEffects(EnSnowman* this, GlobalContext* globalCtx) { + static Vec3f sAccel = { 0.0f, -1.0f, 0.0f }; + s16 altitude; + s16 azimuth; + Vec3f pos; + Vec3f velocity; + f32 speed; + s32 i; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17EFC.s") + for (i = 0; i < 15; i++) { + altitude = Rand_S16Offset(0x1800, 0x2800); + azimuth = ((u32)Rand_Next() >> 0x10); + speed = Rand_ZeroFloat(3.0f) + 8.0f; + velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); + velocity.y = speed * Math_SinS(altitude); + velocity.z = (speed * Math_CosS(altitude)) * Math_CosS(azimuth); + pos.x = (Rand_ZeroFloat(10.0f) * velocity.x) + this->snowballPos.x; + pos.y = (Rand_ZeroFloat(8.0f) * velocity.y) + this->snowballPos.y; + pos.z = (Rand_ZeroFloat(10.0f) * velocity.z) + this->snowballPos.z; + EffectSsHahen_Spawn(globalCtx, &pos, &velocity, &sAccel, 0, + Rand_S16Offset((((i % 3) * 50) + 50), (((i % 3) * 25) + 25)), 452, 20, + sSnowballFragmentDLs[i % 3]); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17F4C.s") + func_800B0DE0(globalCtx, &this->snowballPos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 1000, 150); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B17FE0.s") +void EnSnowman_SetupMoveSnowPile(EnSnowman* this) { + Animation_PlayLoop(&this->snowPileSkelAnime, &gEenoSnowPileMoveAnim); + this->actor.scale.y = this->actor.scale.x; + this->actor.speedXZ = 2.0f; + this->actor.draw = EnSnowman_DrawSnowPile; + this->work.timer = 40; + this->turningOnSteepSlope = false; + this->collider.dim.radius = this->eenoScale * 30.0f; + this->collider.dim.height = this->eenoScale * 10.0f; + this->actionFunc = EnSnowman_MoveSnowPile; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B180A4.s") +/** + * Moves around beneath the snow as a snow pile. + */ +void EnSnowman_MoveSnowPile(EnSnowman* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + Vec3f combinePos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18124.s") + SkelAnime_Update(&this->snowPileSkelAnime); + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + func_800B9010(&this->actor, NA_SE_EN_YMAJIN_MOVE - SFX_FLAG); + } else { + func_800B9010(&this->actor, NA_SE_EN_YMAJIN_MINI_MOVE - SFX_FLAG); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18380.s") + if (this->work.timer > 0) { + this->work.timer--; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B183A4.s") + if (this->work.timer == 0) { + this->collider.base.acFlags |= AC_ON; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B183C4.s") + if ((this->combineTimer == 0) && (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SPLIT)) { + // Sets the combinePos to be the average position of all living split Eenos. + if ((this->actor.parent->colChkInfo.health != 0) && (this->actor.child->colChkInfo.health != 0)) { + combinePos.x = + (this->actor.parent->world.pos.x + this->actor.child->world.pos.x + this->actor.world.pos.x) * + (1.0f / 3.0f); + combinePos.z = + (this->actor.parent->world.pos.z + this->actor.child->world.pos.z + this->actor.world.pos.z) * + (1.0f / 3.0f); + } else if (this->actor.parent->colChkInfo.health != 0) { + combinePos.x = (this->actor.parent->world.pos.x + this->actor.world.pos.x) / 2.0f; + combinePos.z = (this->actor.parent->world.pos.z + this->actor.world.pos.z) / 2.0f; + } else if (this->actor.child->colChkInfo.health != 0) { + combinePos.x = (this->actor.child->world.pos.x + this->actor.world.pos.x) / 2.0f; + combinePos.z = (this->actor.child->world.pos.z + this->actor.world.pos.z) / 2.0f; + } else { + combinePos.x = this->actor.world.pos.x; + combinePos.z = this->actor.world.pos.z; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B1848C.s") + combinePos.y = this->actor.world.pos.y; + EnSnowman_SetupCombine((EnSnowman*)this->actor.parent, globalCtx, &combinePos); + EnSnowman_SetupCombine((EnSnowman*)this->actor.child, globalCtx, &combinePos); + EnSnowman_SetupCombine(this, globalCtx, &combinePos); + } else if ((this->work.timer == 0) && (fabsf(this->actor.playerHeightRel) < 60.0f) && + (this->actor.xzDistToPlayer < this->attackRange) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + !(player->stateFlags1 & 0x800000)) { + EnSnowman_SetupEmerge(this, globalCtx); + } else if (this->snowPileTargetRotY != this->actor.shape.rot.y) { + if (Math_ScaledStepToS(&this->actor.shape.rot.y, this->snowPileTargetRotY, 0x100)) { + this->turningOnSteepSlope = false; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18600.s") + this->actor.world.rot.y = this->actor.shape.rot.y; + } else if (this->actor.bgCheckFlags & 8) { + this->snowPileTargetRotY = this->actor.wallYaw; + } else if (Actor_XZDistanceToPoint(&this->actor, &this->actor.home.pos) > 200.0f) { + this->snowPileTargetRotY = Actor_YawToPoint(&this->actor, &this->actor.home.pos) + (Rand_Next() >> 0x14); + } else if (Rand_ZeroOne() < 0.02f) { + this->snowPileTargetRotY += (s16)((((u32)Rand_Next() >> 0x13) + 0x1000) * ((Rand_ZeroOne() < 0.5f) ? -1 : 1)); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B1861C.s") +void EnSnowman_SetupEmerge(EnSnowman* this, GlobalContext* globalCtx) { + Animation_PlayOnce(&this->skelAnime, &gEenoEmergeAnim); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_SURFACE); + this->collider.dim.radius = this->eenoScale * 40.0f; + this->collider.dim.height = this->eenoScale * 25.0f; + this->actor.draw = EnSnowman_Draw; + this->actor.scale.y = this->actor.scale.x * 0.4f; + this->actor.speedXZ = 0.0f; + this->actor.shape.rot.y = this->actor.yawTowardsPlayer; + EnSnowman_SpawnCircularDustEffect(this, globalCtx); + this->collider.base.acFlags &= ~AC_ON; + this->actionFunc = EnSnowman_Emerge; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18908.s") +/** + * Emerge from beneath the snow and face the player. + */ +void EnSnowman_Emerge(EnSnowman* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B189C4.s") + Math_StepToF(&this->actor.scale.y, this->actor.scale.x, + (this->actor.scale.x * 0.6f) / Animation_GetLastFrame(&gEenoEmergeAnim)); + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B189D4.s") + if (SkelAnime_Update(&this->skelAnime)) { + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + EnSnowman_SetupSubmerge(this, globalCtx); + } else if (!(player->stateFlags1 & 0x800000) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE)) { + this->collider.base.acFlags |= AC_ON; + this->work.snowballsToThrowBeforeIdling = 3; + EnSnowman_SetupReadySnowball(this); + } else { + this->collider.base.acFlags |= AC_ON; + this->actor.scale.y = this->actor.scale.x; + EnSnowman_SetupIdle(this); + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18A04.s") +void EnSnowman_SetupReadySnowball(EnSnowman* this) { + this->actor.scale.y = this->actor.scale.x; + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + this->fwork.frameToStartHoldingSnowball = 15.0f; + Animation_PlayOnce(&this->skelAnime, &gEenoLargeSnowballCreateAnim); + } else { + this->fwork.frameToStartHoldingSnowball = 6.0f; + Animation_PlayOnce(&this->skelAnime, &gEenoSmallSnowballCreateAnim); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18A28.s") + this->actionFunc = EnSnowman_ReadySnowball; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18B30.s") +/** + * Plays the animation of the Eeno creating a snowball and spawns some snow-colored dust + * near the snowball at the appropriate part of their animation. + */ +void EnSnowman_ReadySnowball(EnSnowman* this, GlobalContext* globalCtx) { + Vec3f pos; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18BB4.s") + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); + if ((EN_SNOWMAN_GET_TYPE(&this->actor) != EN_SNOWMAN_TYPE_LARGE) && this->isHoldingSnowball && + ((globalCtx->gameplayFrames % 2) != 0)) { + pos.x = randPlusMinusPoint5Scaled(10.0f) + this->snowballPos.x; + pos.y = randPlusMinusPoint5Scaled(10.0f) + this->snowballPos.y; + pos.z = randPlusMinusPoint5Scaled(10.0f) + this->snowballPos.z; + func_800B0DE0(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 500, 30); + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + if ((this->skelAnime.curFrame > 3.0f) && (this->skelAnime.curFrame < 14.0f) && + ((globalCtx->gameplayFrames % 2) != 0)) { + pos.x = (this->actor.world.pos.x + (70.0f * Math_SinS(this->actor.shape.rot.y))) + + randPlusMinusPoint5Scaled(40.0f); + pos.y = this->actor.world.pos.y + randPlusMinusPoint5Scaled(20.0f); + pos.z = (this->actor.world.pos.z + (70.0f * Math_CosS(this->actor.shape.rot.y))) + + randPlusMinusPoint5Scaled(40.0f); + func_800B0DE0(globalCtx, &pos, &sDustVelocity, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 1000, 150); + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18C7C.s") + if (SkelAnime_Update(&this->skelAnime)) { + EnSnowman_SetupThrowSnowball(this); + } else if (Animation_OnFrame(&this->skelAnime, this->fwork.frameToStartHoldingSnowball)) { + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_HOLD_SNOW); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_HOLD); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B18F50.s") + this->isHoldingSnowball = true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Update.s") +void EnSnowman_SetupThrowSnowball(EnSnowman* this) { + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Animation_PlayOnce(&this->skelAnime, &gEenoLargeSnowballThrowAnim); + this->fwork.frameToThrowSnowball = 17.0f; + } else { + Animation_PlayOnce(&this->skelAnime, &gEenoSmallSnowballThrowAnim); + this->fwork.frameToThrowSnowball = 15.0f; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19474.s") + this->work.snowballsToThrowBeforeIdling--; + this->actionFunc = EnSnowman_ThrowSnowball; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19718.s") +/** + * Throws the snowball the Eeno is holding at the player. If there are still more snowballs + * to throw before idling, this function is responsible for calling EnSnowman_SetupReadySnowball + * so it can eventually throw another one. Otherwise, this function will call EnSnowman_SetupIdle + * to transition the Eeno into an idle state. + */ +void EnSnowman_ThrowSnowball(EnSnowman* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + s32 params; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/EnSnowman_Draw.s") + Math_ApproachS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000); + if (SkelAnime_Update(&this->skelAnime)) { + if ((this->work.snowballsToThrowBeforeIdling != 0) && (Player_GetMask(globalCtx) != PLAYER_MASK_STONE) && + !(player->stateFlags1 & 0x800000)) { + EnSnowman_SetupReadySnowball(this); + } else { + this->work.snowballsToThrowBeforeIdling = 0; + EnSnowman_SetupIdle(this); + } + } else if (Animation_OnFrame(&this->skelAnime, this->fwork.frameToThrowSnowball)) { + this->isHoldingSnowball = false; + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + params = EN_SNOWMAN_TYPE_LARGE_SNOWBALL; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_THROW); + } else { + params = EN_SNOWMAN_TYPE_SMALL_SNOWBALL; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_THROW); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19948.s") + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_SNOWMAN, this->snowballPos.x, this->snowballPos.y, + this->snowballPos.z, 0, this->actor.yawTowardsPlayer, 0, params); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Snowman/func_80B19998.s") +void EnSnowman_SetupIdle(EnSnowman* this) { + Animation_PlayLoop(&this->skelAnime, &gEenoIdleAnim); + this->work.timer = 60; + this->actionFunc = EnSnowman_Idle; +} + +/** + * Simply makes the Eeno wait around for a bit before submerging back into the snow. + */ +void EnSnowman_Idle(EnSnowman* this, GlobalContext* globalCtx) { + SkelAnime_Update(&this->skelAnime); + if (this->work.timer > 0) { + this->work.timer--; + } else { + EnSnowman_SetupSubmerge(this, globalCtx); + } +} + +void EnSnowman_SetupSubmerge(EnSnowman* this, GlobalContext* globalCtx) { + Animation_Change(&this->skelAnime, &gEenoEmergeAnim, -1.0f, Animation_GetLastFrame(&gEenoEmergeAnim), 0.0f, + ANIMMODE_ONCE, -3.0f); + EnSnowman_SpawnCircularDustEffect(this, globalCtx); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_HIDE); + this->actionFunc = EnSnowman_Submerge; +} + +/** + * Submerge beneath the snow and become a snow pile. + */ +void EnSnowman_Submerge(EnSnowman* this, GlobalContext* globalCtx) { + Math_StepToF(&this->actor.scale.y, this->actor.scale.x * 0.4f, + (this->actor.scale.x * 0.6f) / Animation_GetLastFrame(&gEenoEmergeAnim)); + + if (SkelAnime_Update(&this->skelAnime)) { + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + this->actor.draw = EnSnowman_DrawSnowPile; + this->collider.base.acFlags |= AC_ON; + + // Calling EnSnowman_SetupCombine while EnSnowman_Submerge is our actionFunc will result + // in the broken target scale bug described in EnSnowman_SetupCombine. + EnSnowman_SetupCombine(this, globalCtx, &this->combinePos); + } else { + EnSnowman_SetupMoveSnowPile(this); + } + } +} + +void EnSnowman_SetupMelt(EnSnowman* this) { + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 50); + this->collider.base.acFlags &= ~AC_ON; + this->work.timer = 50; + this->actor.flags &= ~ACTOR_FLAG_1; + this->actor.flags |= ACTOR_FLAG_10; + this->actor.scale.y = this->actor.scale.x; + this->actor.speedXZ = 0.0f; + this->actionFunc = EnSnowman_Melt; +} + +/** + * Spawns smoke and shrinks the Eeno down until the timer runs out, then kills the Eeno. + */ +void EnSnowman_Melt(EnSnowman* this, GlobalContext* globalCtx) { + Vec3f smokeVelocity; + Vec3f smokePos; + + this->work.timer--; + if ((this->work.timer >= 38) && (!(this->work.timer & 1))) { + smokeVelocity.y = (this->work.timer - 38) * (1.0f / 12.0f); + smokeVelocity.x = randPlusMinusPoint5Scaled(1.5f) * smokeVelocity.y; + smokeVelocity.z = randPlusMinusPoint5Scaled(1.5f) * smokeVelocity.y; + smokeVelocity.y += 0.8f; + smokePos.x = ((smokeVelocity.x >= 0.0f ? 1.0f : -1.0f) * Rand_ZeroFloat(20.0f) * this->eenoScale) + + this->actor.world.pos.x; + smokePos.z = ((smokeVelocity.z >= 0.0f ? 1.0f : -1.0f) * Rand_ZeroFloat(20.0f) * this->eenoScale) + + this->actor.world.pos.z; + smokePos.y = this->actor.world.pos.y + 3.0f; + EffectSsIceSmoke_Spawn(globalCtx, &smokePos, &smokeVelocity, &gZeroVec3f, this->eenoScale * 300.0f); + } + + if (this->work.timer == 0) { + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SPLIT) { + EnSnowman_SetupSplitDoNothing(this); + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_MarkForDeath(this->actor.parent); + Actor_MarkForDeath(this->actor.child); + Actor_MarkForDeath(&this->actor); + } else { + Actor_MarkForDeath(&this->actor); + } + } + + this->actor.scale.y = this->work.timer * 0.0002f * this->eenoScale; + this->actor.scale.x = (this->eenoScale * (1.4f * 0.01f)) - (0.4f * this->actor.scale.y); + this->actor.scale.z = (this->eenoScale * (1.4f * 0.01f)) - (0.4f * this->actor.scale.y); +} + +void EnSnowman_SetupStun(EnSnowman* this) { + if (this->actionFunc != EnSnowman_Stun) { + this->prevActionFunc = this->actionFunc; + } + + this->actionFunc = EnSnowman_Stun; +} + +/** + * Simply makes the Eeno do absolutely nothing until the stun is over. + * Once the stun is over, this swaps the actionFunc back to what it was before the stun. + */ +void EnSnowman_Stun(EnSnowman* this, GlobalContext* globalCtx) { + if (this->actor.colorFilterTimer == 0) { + this->actionFunc = this->prevActionFunc; + } +} + +void EnSnowman_SetupDamaged(EnSnowman* this) { + Animation_PlayLoop(&this->skelAnime, &gEenoDamageAnim); + Actor_SetColorFilter(&this->actor, 0x4000, 255, 0, 20); + this->collider.base.acFlags &= ~AC_ON; + this->work.timer = 20; + this->actor.draw = EnSnowman_Draw; + this->actor.scale.y = this->actor.scale.x; + this->actor.speedXZ = 10.0f; + func_800BE504(&this->actor, &this->collider); + + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_DAMAGE); + } else { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_MINI_DAMAGE); + } + + this->actionFunc = EnSnowman_Damaged; +} + +/** + * Plays the damage animation and spins the Eeno around. + * Once it's done spinning, it will spawn three small split-off Eenos if the Eeno is a large one. + * Otherwise, it will either submerge underground (if it has health remaining) or die. + */ +void EnSnowman_Damaged(EnSnowman* this, GlobalContext* globalCtx) { + s32 rotationalVelocityScale; + + SkelAnime_Update(&this->skelAnime); + rotationalVelocityScale = CLAMP_MAX(this->work.timer, 10); + this->actor.shape.rot.y += rotationalVelocityScale * 0x300; + Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f); + + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Math_StepToF(&this->actor.scale.y, 1.3f * 0.01f, 0.7f * 0.001f); + this->actor.scale.x = this->actor.scale.y; + this->actor.scale.z = this->actor.scale.y; + } + + if (this->work.timer > 0) { + this->work.timer--; + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_YMAJIN_SPLIT); + EnSnowman_SpawnCircularDustEffect(this, globalCtx); + this->drawDmgEffAlpha = 0.0f; + EnSnowman_CreateSplitEeno((EnSnowman*)this->actor.parent, &this->actor.world.pos, + this->actor.shape.rot.y + 0x10000 / 3); + EnSnowman_CreateSplitEeno((EnSnowman*)this->actor.child, &this->actor.world.pos, + this->actor.shape.rot.y - 0x10000 / 3); + EnSnowman_CreateSplitEeno(this, &this->actor.world.pos, this->actor.shape.rot.y); + + // This is a hack to reuse EnSnowman_SpawnBigSnowballFragmentEffects, since it + // draws the fragments at snowballPos. + Math_Vec3f_Copy(&this->snowballPos, &this->actor.world.pos); + EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + } else if (this->actor.colChkInfo.health != 0) { + this->collider.base.acFlags |= AC_ON; + EnSnowman_SetupSubmerge(this, globalCtx); + } else { + EnSnowman_SetupDead(this); + } +} + +void EnSnowman_SetupDead(EnSnowman* this) { + this->drawDmgEffAlpha = 0.0f; + this->actionFunc = EnSnowman_Dead; +} + +/** + * Spawns snow-colored dust and snowball fragments and kills the Eeno. + */ +void EnSnowman_Dead(EnSnowman* this, GlobalContext* globalCtx) { + static Vec3f sAccel = { 0.0f, -0.5f, 0.0f }; + Vec3f velocity; + Vec3f pos; + s16 altitude; + s16 azimuth; + f32 speed; + s32 i; + + for (i = 0; i < 15; i++) { + altitude = Rand_S16Offset(0x1000, 0x3000); + azimuth = ((u32)Rand_Next() >> 0x10); + speed = Rand_ZeroFloat(2.0f) + 4.0f; + velocity.x = (speed * Math_CosS(altitude)) * Math_SinS(azimuth); + velocity.y = speed * Math_SinS(altitude); + velocity.z = (speed * Math_CosS(altitude)) * Math_CosS(azimuth); + pos.x = (Rand_ZeroFloat(6.0f) * velocity.x) + this->actor.world.pos.x; + pos.y = (Rand_ZeroFloat(3.0f) * velocity.y) + this->actor.world.pos.y; + pos.z = (Rand_ZeroFloat(6.0f) * velocity.z) + this->actor.world.pos.z; + EffectSsHahen_Spawn(globalCtx, &pos, &velocity, &sAccel, 0, + Rand_S16Offset((((i % 3) * 20) + 20), (((i % 3) * 10) + 10)), 452, 20, + sSnowballFragmentDLs[i % 3]); + } + + func_800B0DE0(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, 500, + 30); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 30, NA_SE_EN_YMAJIN_DEAD_BREAK); + Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0x60); + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SPLIT) { + EnSnowman_SetupSplitDoNothing(this); + } else { + Actor_MarkForDeath(&this->actor); + } +} + +/** + * There are some cases where a split Eeno shouldn't do anything, but we don't want to mark it for death. + * This is because we want to keep it around until *all* split Eenos are killed. + * + * This function is called whenever we want to put a split Eeno into this "do nothing" state. It disables + * collision and turns off drawing for the Eeno. If all three split Eenos are killed, this function is + * responsible for marking all of them for death. + */ +void EnSnowman_SetupSplitDoNothing(EnSnowman* this) { + this->collider.base.acFlags &= ~AC_HIT; + this->collider.base.acFlags &= ~AC_HIT; + this->actor.draw = NULL; + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + this->combineState = EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION; + } + + this->actor.flags &= ~(ACTOR_FLAG_1 | ACTOR_FLAG_10); + if ((this->actor.parent != NULL) && (((EnSnowman*)this->actor.parent)->actionFunc == EnSnowman_SplitDoNothing)) { + if ((this->actor.child != NULL) && (((EnSnowman*)this->actor.child)->actionFunc == EnSnowman_SplitDoNothing)) { + EnSnowman_SetupMarkForDeath((EnSnowman*)this->actor.parent); + EnSnowman_SetupMarkForDeath((EnSnowman*)this->actor.child); + Actor_MarkForDeath(&this->actor); + } + } + + this->actionFunc = EnSnowman_SplitDoNothing; +} + +void EnSnowman_SplitDoNothing(EnSnowman* this, GlobalContext* globalCtx) { +} + +/** + * Turns off collision on the Eeno before calling Actor_MarkForDeath on it. + */ +void EnSnowman_SetupMarkForDeath(EnSnowman* this) { + this->collider.base.acFlags &= ~(AC_ON | AC_HIT); + this->collider.base.ocFlags1 &= ~(OC1_ON | OC1_HIT); + this->actionFunc = EnSnowman_MarkForDeath; +} + +/** + * Simply calls Actor_MarkForDeath on the Eeno. + */ +void EnSnowman_MarkForDeath(EnSnowman* this, GlobalContext* globalCtx) { + Actor_MarkForDeath(&this->actor); +} + +/** + * Creates a small split Eeno with a certain Y-rotation and at a certain offset from basePos. + */ +void EnSnowman_CreateSplitEeno(EnSnowman* this, Vec3f* basePos, s32 yRot) { + this->actor.flags |= ACTOR_FLAG_1; + Actor_SetScale(&this->actor, 0.01f); + this->actor.shape.rot.y = yRot; + this->actor.world.rot.y = this->actor.shape.rot.y; + this->combineState = EN_SNOWMAN_COMBINE_STATE_NONE; + this->actor.colChkInfo.health = 2; + this->eenoScale = 1.0f; + this->actor.world.pos.x = (Math_SinS(yRot) * 40.0f) + basePos->x; + this->actor.world.pos.y = basePos->y; + this->actor.world.pos.z = (Math_CosS(yRot) * 40.0f) + basePos->z; + this->combineTimer = 600; + this->actor.params = EN_SNOWMAN_TYPE_SPLIT; + this->actor.flags &= ~ACTOR_FLAG_400; + this->collider.base.ocFlags1 |= OC1_ON; + this->collider.base.acFlags &= ~AC_ON; + EnSnowman_SetupMoveSnowPile(this); +} + +/** + * Absorbs the smaller Eeno into the larger one. The smaller Eeno's target scale is set to + * zero so it gradually disappears, and its collision is disabled, while the larger Eeno's + * target scale increases. + */ +void EnSnowman_AbsorbEeno(EnSnowman* smallerEeno, EnSnowman* largerEeno) { + Actor_PlaySfxAtPos(&largerEeno->actor, NA_SE_EN_YMAJIN_UNITE); + largerEeno->fwork.targetScaleDuringCombine += 0.005f; + smallerEeno->combineState = EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE; + smallerEeno->collider.base.ocFlags1 &= ~OC1_HIT; + smallerEeno->collider.base.acFlags &= ~AC_HIT; + smallerEeno->collider.base.ocFlags1 &= ~OC1_ON; + smallerEeno->collider.base.acFlags &= ~AC_ON; + smallerEeno->fwork.targetScaleDuringCombine = 0.0f; +} + +void EnSnowman_SetupCombine(EnSnowman* this, GlobalContext* globalCtx, Vec3f* combinePos) { + if (this->actor.colChkInfo.health == 0) { + this->combineState = EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION; + } else { + this->actor.flags |= ACTOR_FLAG_10; + Math_Vec3f_Copy(&this->combinePos, combinePos); + this->combineState = EN_SNOWMAN_COMBINE_STATE_ACTIVE; + + if (this->actionFunc != EnSnowman_Submerge) { + this->combineTimer = 400; + + //! @bug: Skipping this based the current actionFunc results in whatever is currently in fwork + //! being treated as the target scale when this function is called from EnSnowman_Submerge. + //! Since the only other things that get put in fwork are animation frame numbers, this results + //! in an enormous target scale, potentially creating the so-called "Mega Eeno" glitch. + //! It can still fail to become a Mega Eeno if it gets absorbed before it gets a chance to call + //! EnSnowman_Combine, though. + this->fwork.targetScaleDuringCombine = 0.01f; + } + + //! @bug: If an Eeno is in the middle of submerging, its draw function will still be EnSnowman_Draw. + //! It will call EnSnowman_SetupSubmerge again, resulting in the submerge animation playing twice. + if (this->actor.draw == EnSnowman_DrawSnowPile) { + this->actor.speedXZ = 3.0f; + this->actionFunc = EnSnowman_Combine; + } else { + this->isHoldingSnowball = false; + this->actor.speedXZ = 0.0f; + + // At this point, the combineState is EN_SNOWMAN_COMBINE_STATE_ACTIVE, and the actionFunc + // will be set to EnSnowman_Submerge. When the submerging animation is complete with this + // combineState, EnSnowman_Submerge will call EnSnowman_SetupCombine, causing the broken + // target scale bug described above. + EnSnowman_SetupSubmerge(this, globalCtx); + } + } +} + +/** + * Makes the small, split-off Eenos try to combine into a large Eeno by absorbing each other. + */ +void EnSnowman_Combine(EnSnowman* this, GlobalContext* globalCtx) { + EnSnowman* parent; + EnSnowman* child; + + SkelAnime_Update(&this->snowPileSkelAnime); + parent = (EnSnowman*)this->actor.parent; + child = (EnSnowman*)this->actor.child; + Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->combinePos), 0x1000); + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (this->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE) { + if (this->collider.base.ocFlags1 & OC1_HIT) { + if ((this->collider.base.oc == this->actor.parent) && + (parent->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE)) { + if (this->actor.scale.x < this->actor.parent->scale.x) { + EnSnowman_AbsorbEeno(this, parent); + } else { + EnSnowman_AbsorbEeno(parent, this); + } + } else if ((this->collider.base.oc == this->actor.child) && + (child->combineState == EN_SNOWMAN_COMBINE_STATE_ACTIVE)) { + if (this->actor.scale.x < this->actor.child->scale.x) { + EnSnowman_AbsorbEeno(this, child); + } else { + EnSnowman_AbsorbEeno(child, this); + } + } + } + + if (parent->combineState == EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION) { + EnSnowman_AbsorbEeno(parent, this); + } + + if (child->combineState == EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION) { + EnSnowman_AbsorbEeno(child, this); + } + } + + if ((this->combineTimer == 0) && (parent->fwork.targetScaleDuringCombine > 0.0f) && + (child->fwork.targetScaleDuringCombine > 0.0f) && (this->fwork.targetScaleDuringCombine < 0.011f) && + (this->combineState != EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE)) { + this->combineState = EN_SNOWMAN_COMBINE_STATE_NO_ABSORPTION; + this->fwork.targetScaleDuringCombine = 0.0f; + } + + if (Actor_XZDistanceToPoint(&this->actor, &this->combinePos) < 20.0f) { + this->actor.speedXZ = 0.0f; + } + + if (Math_StepToF(&this->actor.scale.x, this->fwork.targetScaleDuringCombine, 0.0005f)) { + if (this->fwork.targetScaleDuringCombine < 0.01f) { + EnSnowman_SetupSplitDoNothing(this); + } else if (this->fwork.targetScaleDuringCombine > 0.018f) { + Actor_SetScale(&this->actor, 0.02f); + this->actor.params = EN_SNOWMAN_TYPE_LARGE; + this->actor.flags |= ACTOR_FLAG_400; + this->collider.base.ocFlags1 |= OC1_ON; + this->combineState = EN_SNOWMAN_COMBINE_STATE_BEING_ABSORBED_OR_DONE; + this->eenoScale = 2.0f; + EnSnowman_SetupMoveSnowPile(this); + } + } + + this->actor.scale.y = this->actor.scale.x; + this->actor.scale.z = this->actor.scale.x; +} + +void EnSnowman_UpdateDamage(EnSnowman* this, GlobalContext* globalCtx) { + if (this->collider.base.acFlags & AC_HIT) { + this->collider.base.acFlags &= ~AC_HIT; + Actor_SetDropFlag(&this->actor, &this->collider.info); + if ((this->actor.colChkInfo.damageEffect != EN_SNOWMAN_DMGEFF_HOOKSHOT) || + (EN_SNOWMAN_GET_TYPE(&this->actor) != EN_SNOWMAN_TYPE_LARGE)) { + if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_MELT) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + Actor_ApplyDamage(&this->actor); + EnSnowman_SetupMelt(this); + } else { + if ((this->actionFunc == EnSnowman_MoveSnowPile) || (this->actionFunc == EnSnowman_Combine)) { + EnSnowman_SetupEmerge(this, globalCtx); + } else if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnSnowman_SetupStun(this); + } else if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_ELECTRIC_STUN) { + Actor_SetColorFilter(&this->actor, 0, 255, 0, 40); + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 2.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_ELECTRIC_SPARKS_LARGE; + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_COMMON_FREEZE); + EnSnowman_SetupStun(this); + } else if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) { + if (this->isHoldingSnowball == true) { + this->isHoldingSnowball = false; + EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + } + + EnSnowman_SetupDamaged(this); + } else { + if (Actor_ApplyDamage(&this->actor) == 0) { + Enemy_StartFinishingBlow(globalCtx, &this->actor); + } + + EnSnowman_SetupDamaged(this); + } + } + + if (this->actor.colChkInfo.damageEffect == EN_SNOWMAN_DMGEFF_LIGHT_ORB) { + this->drawDmgEffScale = 0.55f; + this->drawDmgEffAlpha = 4.0f; + this->drawDmgEffType = ACTOR_DRAW_DMGEFF_LIGHT_ORBS; + Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, this->collider.info.bumper.hitPos.x, + this->collider.info.bumper.hitPos.y, this->collider.info.bumper.hitPos.z, 0, 0, 0, + CLEAR_TAG_LARGE_LIGHT_RAYS); + } + } + } +} + +void EnSnowman_Update(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + EnSnowman* this = THIS; + f32 wallCheckRadius; + + if (this->actionFunc != EnSnowman_SplitDoNothing) { + DECR(this->combineTimer); + + EnSnowman_UpdateDamage(this, globalCtx); + this->actionFunc(this, globalCtx); + + if (this->actionFunc != EnSnowman_MarkForDeath) { + Actor_MoveWithGravity(&this->actor); + if ((EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_LARGE) && + (this->actionFunc == EnSnowman_ReadySnowball)) { + wallCheckRadius = (this->skelAnime.curFrame * (1.0f / 60.0f)) + 1.0f; + wallCheckRadius = CLAMP_MAX(wallCheckRadius, 1.3f); + wallCheckRadius *= this->collider.dim.radius; + } else { + wallCheckRadius = this->collider.dim.radius; + } + + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, wallCheckRadius, 0.0f, 0x1D); + if ((this->actor.floorPoly != NULL) && ((this->actor.floorPoly->normal.y * SHT_MINV) < 0.7f)) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + if (!this->turningOnSteepSlope) { + this->snowPileTargetRotY = Math_FAtan2F(this->actor.floorPoly->normal.z * SHT_MINV, + this->actor.floorPoly->normal.x * SHT_MINV); + this->turningOnSteepSlope = true; + } + } else { + func_800BE3D0(&this->actor, this->actor.shape.rot.y, &this->actor.shape.rot); + } + + Collider_UpdateCylinder(&this->actor, &this->collider); + if (this->collider.base.acFlags & AC_ON) { + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + + if (this->actor.draw == EnSnowman_Draw) { + Actor_SetFocus(&this->actor, this->actor.scale.y * 1800.0f); + } else { + Actor_SetFocus(&this->actor, this->actor.scale.y * 720.0f); + } + + if (this->drawDmgEffAlpha > 0.0f) { + Math_StepToF(&this->drawDmgEffAlpha, 0.0f, 0.05f); + this->drawDmgEffScale = (this->drawDmgEffAlpha + 1.0f) * 0.275f; + this->drawDmgEffScale = CLAMP_MAX(this->drawDmgEffScale, 0.55f); + } + } + } +} + +void EnSnowman_UpdateSnowball(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; + s16 scale; + s32 i; + + if (this->work.timer > 0) { + this->work.timer--; + } else { + this->collider.base.ocFlags1 |= OC1_ON; + } + + if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1) || (this->actor.bgCheckFlags & 0x10) || + (this->collider.base.atFlags & AT_HIT) || (this->collider.base.acFlags & AC_HIT) || + (this->collider.base.ocFlags1 & OC1_HIT)) { + if (EN_SNOWMAN_GET_TYPE(&this->actor) == EN_SNOWMAN_TYPE_SMALL_SNOWBALL) { + scale = 10; + for (i = 0; i < 3; i++) { + EffectSsHahen_SpawnBurst(globalCtx, &thisx->world.pos, 5.0f, 0, scale, scale >> 1, 3, 452, 20, + sSnowballFragmentDLs[i]); + scale *= 2; + } + + func_800B0DE0(globalCtx, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f, &sDustPrimColor, &sDustEnvColor, + 500, 30); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_SMALL_SNOWBALL_BROKEN); + } else { + // EnSnowman_SpawnBigSnowballFragmentEffects only fworks with snowballPos, so we need + // to copy the snowball actor's current position into snowballPos to make this fwork. + Math_Vec3f_Copy(&this->snowballPos, &this->actor.world.pos); + EnSnowman_SpawnBigSnowballFragmentEffects(this, globalCtx); + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_EV_SNOWBALL_BROKEN); + } + + SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &this->actor.world.pos, 20, NA_SE_IT_REFLECTION_WOOD); + Actor_MarkForDeath(&this->actor); + } else { + this->actor.shape.rot.x += 0xF00; + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 30.0f, this->collider.dim.radius * 0.6f, + this->collider.dim.height - this->collider.dim.yShift, 0x1F); + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + } +} + +/** + * This maps a given limb based on its limbIndex to its appropriate index + * in the bodyPartsPos array. An index of -1 indicates that the limb is + * not part of the bodyPartsPos array. + */ +static s8 sLimbIndexToBodyPartsPosIndex[] = { + -1, -1, -1, -1, -1, -1, 0, 1, -1, 2, 3, 4, +}; + +/** + * The last five elements of the bodyPartsPos array are duplicates of the body + * bottom limb, each offset by a certain certain amount. + */ +static Vec3f sBodyBottomBodyPartOffsets[] = { + { 2000.0f, 3000.0f, 0.0f }, { 2000.0f, -2000.0f, 0.0f }, { 3000.0f, 0.0f, 0.0f }, + { 1000.0f, 0.0f, 3000.0f }, { 1000.0f, 0.0f, -3000.0f }, +}; + +void EnSnowman_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + s32 pad; + EnSnowman* this = THIS; + Gfx* gfx; + s32 i; + + if (sLimbIndexToBodyPartsPosIndex[limbIndex] != -1) { + if (sLimbIndexToBodyPartsPosIndex[limbIndex] == 4) { + for (i = 0; i < 5; i++) { + Matrix_MultiplyVector3fByState(&sBodyBottomBodyPartOffsets[i], &this->bodyPartsPos[i + 4]); + } + } else { + Matrix_GetStateTranslation(&this->bodyPartsPos[sLimbIndexToBodyPartsPosIndex[limbIndex]]); + } + } + + if ((limbIndex == EENO_LIMB_RIGHT_HAND) && (this->isHoldingSnowball == true)) { + OPEN_DISPS(globalCtx->state.gfxCtx); + + gfx = POLY_OPA_DISP; + + if (EN_SNOWMAN_GET_TYPE(thisx) != EN_SNOWMAN_TYPE_LARGE) { + Matrix_InsertTranslation(800.0f, -600.0f, 0.0f, MTXMODE_APPLY); + } else { + Matrix_InsertTranslation(300.0f, -2300.0f, -1900.0f, MTXMODE_APPLY); + Matrix_Scale(0.3f, 0.3f, 0.3f, MTXMODE_APPLY); + } + + gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(&gfx[1], sSnowballDLs[EN_SNOWMAN_GET_TYPE(&this->actor)]); + + POLY_OPA_DISP = &gfx[2]; + + CLOSE_DISPS(globalCtx->state.gfxCtx); + + Matrix_GetStateTranslation(&this->snowballPos); + } +} + +void EnSnowman_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + NULL, EnSnowman_PostLimbDraw, &this->actor); + Actor_DrawDamageEffects(globalCtx, &this->actor, this->bodyPartsPos, ARRAY_COUNT(this->bodyPartsPos), + this->drawDmgEffScale * this->eenoScale, 0.0f, this->drawDmgEffAlpha, this->drawDmgEffType); +} + +void EnSnowman_DrawSnowPile(Actor* thisx, GlobalContext* globalCtx) { + EnSnowman* this = THIS; + + func_8012C28C(globalCtx->state.gfxCtx); + SkelAnime_DrawFlexOpa(globalCtx, this->snowPileSkelAnime.skeleton, this->snowPileSkelAnime.jointTable, + this->snowPileSkelAnime.dListCount, NULL, NULL, &this->actor); +} + +void EnSnowman_DrawSnowball(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, sSnowballDLs[EN_SNOWMAN_GET_TYPE(thisx) - EN_SNOWMAN_TYPE_SMALL_SNOWBALL]); +} diff --git a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h index ceb7112024..07d7f98c38 100644 --- a/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h +++ b/src/overlays/actors/ovl_En_Snowman/z_en_snowman.h @@ -2,16 +2,56 @@ #define Z_EN_SNOWMAN_H #include "global.h" +#include "objects/object_snowman/object_snowman.h" + +#define EN_SNOWMAN_GET_TYPE(thisx) ((thisx)->params) +#define EN_SNOWMAN_GET_ATTACK_RANGE(thisx) (((thisx)->params >> 8) & 0xFF) + +typedef enum { + /* 0 */ EN_SNOWMAN_TYPE_SMALL, + /* 1 */ EN_SNOWMAN_TYPE_LARGE, + /* 2 */ EN_SNOWMAN_TYPE_SPLIT, + /* 3 */ EN_SNOWMAN_TYPE_SMALL_SNOWBALL, + /* 4 */ EN_SNOWMAN_TYPE_LARGE_SNOWBALL, +} EnSnowmanType; struct EnSnowman; typedef void (*EnSnowmanActionFunc)(struct EnSnowman*, GlobalContext*); typedef struct EnSnowman { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x13C]; - /* 0x0280 */ EnSnowmanActionFunc actionFunc; - /* 0x0284 */ char unk_284[0xF4]; + /* 0x000 */ Actor actor; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ SkelAnime snowPileSkelAnime; + /* 0x1CC */ Vec3s jointTable[EENO_LIMB_MAX]; + /* 0x214 */ Vec3s morphTable[EENO_LIMB_MAX]; + /* 0x25C */ Vec3s snowPileJointTable[EENO_SNOW_PILE_LIMB_MAX]; + /* 0x26E */ Vec3s snowPileMorphTable[EENO_SNOW_PILE_LIMB_MAX]; + /* 0x280 */ EnSnowmanActionFunc actionFunc; + /* 0x284 */ EnSnowmanActionFunc prevActionFunc; + /* 0x288 */ u8 isHoldingSnowball; + /* 0x289 */ u8 combineState; + /* 0x28A */ u8 turningOnSteepSlope; + /* 0x28B */ u8 drawDmgEffType; + /* 0x28C */ union { + s16 timer; + s16 snowballsToThrowBeforeIdling; + } work; + /* 0x28E */ s16 snowPileTargetRotY; + /* 0x290 */ s16 combineTimer; + /* 0x294 */ f32 eenoScale; + /* 0x298 */ union { + f32 frameToStartHoldingSnowball; + f32 frameToThrowSnowball; + f32 targetScaleDuringCombine; + } fwork; + /* 0x29C */ f32 attackRange; + /* 0x2A0 */ f32 drawDmgEffAlpha; + /* 0x2A4 */ f32 drawDmgEffScale; + /* 0x2A8 */ Vec3f combinePos; + /* 0x2B4 */ Vec3f snowballPos; + /* 0x2C0 */ Vec3f bodyPartsPos[9]; + /* 0x32C */ ColliderCylinder collider; } EnSnowman; // size = 0x378 extern const ActorInit En_Snowman_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index fe4697ca9f..4967ab0a2a 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -13112,43 +13112,43 @@ 0x80B16808:("BgHakuginSwitch_Draw",), 0x80B16B00:("EnSnowman_Init",), 0x80B16F94:("EnSnowman_Destroy",), - 0x80B16FC0:("func_80B16FC0",), - 0x80B17144:("func_80B17144",), - 0x80B173D0:("func_80B173D0",), - 0x80B1746C:("func_80B1746C",), - 0x80B177EC:("func_80B177EC",), - 0x80B178B8:("func_80B178B8",), - 0x80B179D0:("func_80B179D0",), - 0x80B17A58:("func_80B17A58",), - 0x80B17CE8:("func_80B17CE8",), - 0x80B17D78:("func_80B17D78",), - 0x80B17EB4:("func_80B17EB4",), - 0x80B17EFC:("func_80B17EFC",), - 0x80B17F4C:("func_80B17F4C",), - 0x80B17FE0:("func_80B17FE0",), - 0x80B180A4:("func_80B180A4",), - 0x80B18124:("func_80B18124",), - 0x80B18380:("func_80B18380",), - 0x80B183A4:("func_80B183A4",), - 0x80B183C4:("func_80B183C4",), - 0x80B1848C:("func_80B1848C",), - 0x80B18600:("func_80B18600",), - 0x80B1861C:("func_80B1861C",), - 0x80B18908:("func_80B18908",), - 0x80B189C4:("func_80B189C4",), - 0x80B189D4:("func_80B189D4",), - 0x80B18A04:("func_80B18A04",), - 0x80B18A28:("func_80B18A28",), - 0x80B18B30:("func_80B18B30",), - 0x80B18BB4:("func_80B18BB4",), - 0x80B18C7C:("func_80B18C7C",), - 0x80B18F50:("func_80B18F50",), + 0x80B16FC0:("EnSnowman_SpawnCircularDustEffect",), + 0x80B17144:("EnSnowman_SpawnBigSnowballFragmentEffects",), + 0x80B173D0:("EnSnowman_SetupMoveSnowPile",), + 0x80B1746C:("EnSnowman_MoveSnowPile",), + 0x80B177EC:("EnSnowman_SetupEmerge",), + 0x80B178B8:("EnSnowman_Emerge",), + 0x80B179D0:("EnSnowman_SetupReadySnowball",), + 0x80B17A58:("EnSnowman_ReadySnowball",), + 0x80B17CE8:("EnSnowman_SetupThrowSnowball",), + 0x80B17D78:("EnSnowman_ThrowSnowball",), + 0x80B17EB4:("EnSnowman_SetupIdle",), + 0x80B17EFC:("EnSnowman_Idle",), + 0x80B17F4C:("EnSnowman_SetupSubmerge",), + 0x80B17FE0:("EnSnowman_Submerge",), + 0x80B180A4:("EnSnowman_SetupMelt",), + 0x80B18124:("EnSnowman_Melt",), + 0x80B18380:("EnSnowman_SetupStun",), + 0x80B183A4:("EnSnowman_Stun",), + 0x80B183C4:("EnSnowman_SetupDamaged",), + 0x80B1848C:("EnSnowman_Damaged",), + 0x80B18600:("EnSnowman_SetupDead",), + 0x80B1861C:("EnSnowman_Dead",), + 0x80B18908:("EnSnowman_SetupSplitDoNothing",), + 0x80B189C4:("EnSnowman_SplitDoNothing",), + 0x80B189D4:("EnSnowman_SetupMarkForDeath",), + 0x80B18A04:("EnSnowman_MarkForDeath",), + 0x80B18A28:("EnSnowman_CreateSplitEeno",), + 0x80B18B30:("EnSnowman_AbsorbEeno",), + 0x80B18BB4:("EnSnowman_SetupCombine",), + 0x80B18C7C:("EnSnowman_Combine",), + 0x80B18F50:("EnSnowman_UpdateDamage",), 0x80B1918C:("EnSnowman_Update",), - 0x80B19474:("func_80B19474",), - 0x80B19718:("func_80B19718",), + 0x80B19474:("EnSnowman_UpdateSnowball",), + 0x80B19718:("EnSnowman_PostLimbDraw",), 0x80B198B0:("EnSnowman_Draw",), - 0x80B19948:("func_80B19948",), - 0x80B19998:("func_80B19998",), + 0x80B19948:("EnSnowman_DrawSnowPile",), + 0x80B19998:("EnSnowman_DrawSnowball",), 0x80B19F60:("TGSw_ActionDecider",), 0x80B1A008:("TGSw_ActionExecuteOneShot",), 0x80B1A15C:("TGSw_Init",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 6b1a7fcb7d..5827c7261a 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -13908,10 +13908,8 @@ 0x80B19AAC:("D_80B19AAC","UNK_TYPE1","",0x1), 0x80B19AB8:("D_80B19AB8","UNK_TYPE1","",0x1), 0x80B19AC4:("D_80B19AC4","UNK_TYPE1","",0x1), - 0x80B19AD0:("D_80B19AD0","UNK_TYPE1","",0x1), - 0x80B19ADA:("D_80B19ADA","UNK_TYPE1","",0x1), - 0x80B19ADC:("D_80B19ADC","UNK_TYPE1","",0x1), - 0x80B19B18:("D_80B19B18","UNK_TYPE1","",0x1), + 0x80B19AD0:("D_80B19AD0","s8","[12]",0xC), + 0x80B19ADC:("D_80B19ADC","Vec3f","[5]",0x3C), 0x80B19B20:("D_80B19B20","f32","",0x4), 0x80B19B24:("D_80B19B24","f32","",0x4), 0x80B19B28:("D_80B19B28","f32","",0x4), diff --git a/undefined_syms.txt b/undefined_syms.txt index 1ef7e69420..1567d0b70f 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1458,19 +1458,6 @@ D_06000650 = 0x06000650; D_06000828 = 0x06000828; D_06000A10 = 0x06000A10; -// ovl_En_Snowman - -D_06000404 = 0x06000404; -D_060007B4 = 0x060007B4; -D_060045A0 = 0x060045A0; -D_06004628 = 0x06004628; -D_060046D8 = 0x060046D8; -D_06004A90 = 0x06004A90; -D_06004F14 = 0x06004F14; -D_0600544C = 0x0600544C; -D_0600554C = 0x0600554C; -D_060058CC = 0x060058CC; - // ovl_En_Snowwd D_06000198 = 0x06000198;