EnFirefly OK and mostly documented (#194)

* Data imported, 8/30 functions done

* OK

* Delete ASM references, add SFX

* Named functions

* more naming

* Type the nop ActorFunc correctly

* A couple more bits of documentation

* Sorted object_script

* Merge remote-tracking branch 'upstream/master' into Firefly

* format

* Update other includes

* Review suggestions

* Review changes; named Actor_Noop

* Format
This commit is contained in:
EllipticEllipsis
2021-07-05 22:47:55 +01:00
committed by GitHub
parent e57fb5780d
commit 0e51bf35a1
26 changed files with 1157 additions and 387 deletions
+1 -1
View File
@@ -846,7 +846,7 @@ void Actor_FreeOverlay(ActorOverlay* entry) {
#pragma GLOBAL_ASM("./asm/non_matchings/code/z_actor//func_800BDCF4.asm")
#pragma GLOBAL_ASM("./asm/non_matchings/code/z_actor//func_800BDFB0.asm")
#pragma GLOBAL_ASM("./asm/non_matchings/code/z_actor//Actor_Noop.asm")
#pragma GLOBAL_ASM("./asm/non_matchings/code/z_actor//func_800BDFC0.asm")
@@ -17,7 +17,7 @@ const ActorInit Bg_Inibs_Movebg_InitVars = {
sizeof(BgInibsMovebg),
(ActorFunc)BgInibsMovebg_Init,
(ActorFunc)BgInibsMovebg_Destroy,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)BgInibsMovebg_Draw,
};
*/
@@ -16,7 +16,7 @@ const ActorInit Bg_Lbfshot_InitVars = {
sizeof(BgLbfshot),
(ActorFunc)BgLbfshot_Init,
(ActorFunc)BgLbfshot_Destroy,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)BgLbfshot_Draw,
};
@@ -14,8 +14,8 @@ const ActorInit Bg_Market_Step_InitVars = {
OBJECT_MARKET_OBJ,
sizeof(BgMarketStep),
(ActorFunc)BgMarketStep_Init,
(ActorFunc)func_800BDFB0,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)Actor_Noop,
(ActorFunc)BgMarketStep_Draw,
};
+757 -32
View File
@@ -1,4 +1,11 @@
/*
* File: z_en_firefly.c
* Overlay: ovl_En_Firefly
* Description: Keese (Normal, Fire, Ice)
*/
#include "z_en_firefly.h"
#include "overlays/actors/ovl_Obj_Syokudai/z_obj_syokudai.h"
#define FLAGS 0x00005005
@@ -9,7 +16,33 @@ void EnFirefly_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx);
void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx);
/*
void EnFirefly_FlyIdle(EnFirefly* this, GlobalContext* globalCtx);
void EnFirefly_Fall(EnFirefly* this, GlobalContext* globalCtx);
void EnFirefly_SetupDie(EnFirefly* this);
void EnFirefly_Die(EnFirefly* this, GlobalContext* globalCtx);
void EnFirefly_SetupDiveAttack(EnFirefly* this);
void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx);
void EnFirefly_Rebound(EnFirefly* this, GlobalContext* globalCtx);
void EnFirefly_SetupFlyAway(EnFirefly* this);
void EnFirefly_FlyAway(EnFirefly* this, GlobalContext* globalCtx);
void EnFirefly_Stunned(EnFirefly* this, GlobalContext* globalCtx);
void EnFirefly_SetupPerch(EnFirefly* this);
void EnFirefly_Perch(EnFirefly* this, GlobalContext* globalCtx);
void EnFirefly_SetupDisturbDiveAttack(EnFirefly* this);
void EnFirefly_DisturbDiveAttack(EnFirefly* this, GlobalContext* globalCtx);
typedef enum {
/* 0 */ KEESE_FIRE,
/* 3 */ KEESE_NORMAL = 3,
/* 4 */ KEESE_ICE
} KeeseCurrentType;
typedef enum {
/* 0 */ KEESE_AURA_NONE,
/* 1 */ KEESE_AURA_FIRE,
/* 2 */ KEESE_AURA_ICE
} KeeseAuraType;
const ActorInit En_Firefly_InitVars = {
ACTOR_EN_FIREFLY,
ACTORCAT_ENEMY,
@@ -21,64 +54,756 @@ const ActorInit En_Firefly_InitVars = {
(ActorFunc)EnFirefly_Update,
(ActorFunc)EnFirefly_Draw,
};
*/
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/EnFirefly_Init.asm")
static ColliderSphereInit sSphereInit = {
{
COLTYPE_HIT3,
AT_ON | AT_TYPE_ENEMY,
AC_ON | AC_TYPE_PLAYER,
OC1_ON | OC1_TYPE_ALL,
OC2_TYPE_1,
COLSHAPE_SPHERE,
},
{
ELEMTYPE_UNK0,
{ 0xF7CFFFFF, 0x01, 0x08 },
{ 0xF7CFFFFF, 0x00, 0x00 },
TOUCH_ON | TOUCH_SFX_HARD,
BUMP_ON,
OCELEM_ON,
},
{ 1, { { 0, 1000, 0 }, 15 }, 100 },
};
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/EnFirefly_Destroy.asm")
static CollisionCheckInfoInit sColChkInfoInit = { 1, 10, 10, 10 };
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_808798C4.asm")
static DamageTable sDamageTable = {
0x10, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x22, 0x32, 0x42, 0x01, 0x01,
0x01, 0x02, 0x10, 0x50, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
};
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_80879930.asm")
static InitChainEntry sInitChain[] = {
ICHAIN_VEC3F_DIV1000(scale, 5, ICHAIN_CONTINUE),
ICHAIN_F32_DIV1000(gravity, -500, ICHAIN_CONTINUE),
ICHAIN_U8(targetMode, 2, ICHAIN_CONTINUE),
ICHAIN_F32(targetArrowOffset, 4000, ICHAIN_STOP),
};
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_80879950.asm")
extern AnimationHeader D_0600017C;
extern SkeletonHeader D_060018B8;
extern Gfx D_06001678[];
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087997C.asm")
void EnFirefly_Init(Actor* thisx, GlobalContext* globalCtx) {
EnFirefly* this = THIS;
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_80879A98.asm")
Actor_ProcessInitChain(&this->actor, sInitChain);
ActorShape_Init(&this->actor.shape, 0.0f, func_800B3FC0, 25.0f);
SkelAnime_Init(globalCtx, &this->skelAnime, &D_060018B8, &D_0600017C, this->jointTable, this->morphTable, 28);
Collider_InitAndSetSphere(globalCtx, &this->collider, &this->actor, &sSphereInit);
CollisionCheck_SetInfo(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit);
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_80879C14.asm")
if (this->actor.params & KEESE_INVISIBLE) {
this->actor.flags |= 0x80;
this->actor.params = KEESE_GET_MAIN_TYPE(thisx);
this->isInvisible = true;
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_80879CC0.asm")
if (this->actor.params == KEESE_FIRE_FLY) {
this->auraType = KEESE_AURA_FIRE;
this->timer = Rand_S16Offset(20, 60);
this->actor.shape.rot.x = 0x1554;
this->actor.hintId = 0x11; // Fire Keese
this->maxAltitude = this->actor.home.pos.y;
this->actionFunc = EnFirefly_FlyIdle;
} else if (this->actor.params == KEESE_ICE_FLY) {
this->auraType = KEESE_AURA_ICE;
this->collider.info.toucher.effect = 2; // Freeze
this->actor.hintId = 0x56; // Ice Keese
this->maxAltitude = this->actor.home.pos.y + 100.0f;
this->actionFunc = EnFirefly_FlyIdle;
} else {
this->auraType = KEESE_AURA_NONE;
this->collider.info.toucher.effect = 0; // Nothing
this->actor.hintId = 0x12; // Keese
this->maxAltitude = this->actor.home.pos.y + 100.0f;
this->actionFunc = EnFirefly_Perch;
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_80879F28.asm")
this->currentType = this->actor.params;
this->collider.dim.worldSphere.radius = sSphereInit.dim.modelSphere.radius;
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A110.asm")
void EnFirefly_Destroy(Actor* thisx, GlobalContext* globalCtx) {
EnFirefly* this = THIS;
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A1C8.asm")
Collider_DestroySphere(globalCtx, &this->collider);
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A1EC.asm")
void EnFirefly_SpawnIceEffects(EnFirefly* this, GlobalContext* globalCtx) {
if (this->unk_18F == 0xA) {
this->unk_18F = 0;
this->unk_2E8.x = 0.0f;
func_800BF7CC(globalCtx, &this->actor, &this->unk_2F8, 3, 2, 0.2f, 0.2f);
}
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A268.asm")
void EnFirefly_Extinguish(EnFirefly* this) {
this->currentType = KEESE_NORMAL;
this->collider.info.toucher.effect = 0; // Nothing
this->auraType = KEESE_AURA_NONE;
this->actor.hintId = 0x12; // Keese
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A2D8.asm")
void EnFirefly_Ignite(EnFirefly* this) {
if (this->actor.params == KEESE_FIRE_FLY) {
this->currentType = KEESE_FIRE;
this->collider.info.toucher.effect = 1; // Fire
this->auraType = KEESE_AURA_FIRE;
this->actor.hintId = 0x11; // Fire Keese
}
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A50C.asm")
s32 EnFirefly_ReturnToPerch(EnFirefly* this, GlobalContext* globalCtx) {
Player* player = PLAYER;
f32 distFromHome;
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A548.asm")
if (this->actor.params != KEESE_NORMAL_PERCH) {
return false;
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A5DC.asm")
if (Actor_XZDistanceToPoint(&player->actor, &this->actor.home.pos) > 300.0f) {
distFromHome = Actor_DistanceToPoint(&this->actor, &this->actor.home.pos);
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A60C.asm")
if (distFromHome < 5.0f) {
EnFirefly_SetupPerch(this);
} else {
if (distFromHome * 0.05f < 1.0f) {
this->actor.speedXZ *= distFromHome * 0.05f;
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A774.asm")
Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x300);
Math_ScaledStepToS(&this->actor.shape.rot.x,
Actor_PitchToPoint(&this->actor, &this->actor.home.pos) + 0x1554, 0x100);
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A818.asm")
return true;
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A8FC.asm")
return false;
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A920.asm")
s32 EnFirefly_SeekTorch(EnFirefly* this, GlobalContext* globalCtx) {
ObjSyokudai* findTorch = (ObjSyokudai*)globalCtx->actorCtx.actorList[ACTORCAT_PROP].first;
ObjSyokudai* closestTorch = NULL;
f32 currentMinDist = 35000.0f;
f32 currentDist;
Vec3f flamePos;
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087A9E0.asm")
if ((this->actor.params != KEESE_FIRE_FLY) || (this->currentType != KEESE_NORMAL)) {
return false;
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087AA1C.asm")
while (findTorch != NULL) {
if ((findTorch->actor.id == ACTOR_OBJ_SYOKUDAI) && (findTorch->unk_1DC != 0)) {
currentDist = Actor_DistanceBetweenActors(&this->actor, &findTorch->actor);
if (currentDist < currentMinDist) {
currentMinDist = currentDist;
closestTorch = findTorch;
}
}
findTorch = (ObjSyokudai*)findTorch->actor.next;
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087AAF4.asm")
if (closestTorch != NULL) {
flamePos.x = closestTorch->actor.world.pos.x;
flamePos.y = closestTorch->actor.world.pos.y + 52.0f + 30.0f;
flamePos.z = closestTorch->actor.world.pos.z;
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/EnFirefly_Update.asm")
if (Actor_DistanceToPoint(&this->actor, &flamePos) < 15.0f) {
EnFirefly_Ignite(this);
} else {
Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawBetweenActors(&this->actor, &closestTorch->actor),
0x300);
Math_ScaledStepToS(&this->actor.shape.rot.x, Actor_PitchToPoint(&this->actor, &flamePos) + 0x1554, 0x100);
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087AF48.asm")
return true;
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/func_8087AF98.asm")
return false;
}
#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_En_Firefly_0x808796F0/EnFirefly_Draw.asm")
void EnFirefly_SetupFlyIdle(EnFirefly* this) {
this->timer = Rand_S16Offset(70, 100);
this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 1.5f;
Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x300);
this->targetPitch = ((this->maxAltitude < this->actor.world.pos.y) ? 0xC00 : -0xC00) + 0x1554;
this->skelAnime.animPlaybackSpeed = 1.0f;
this->actionFunc = EnFirefly_FlyIdle;
}
void EnFirefly_FlyIdle(EnFirefly* this, GlobalContext* globalCtx) {
s32 isSkelAnimeUpdated;
f32 rand;
SkelAnime_FrameUpdateMatrix(&this->skelAnime);
if (this->timer != 0) {
this->timer--;
}
isSkelAnimeUpdated = func_801378B8(&this->skelAnime, 0.0f);
this->actor.speedXZ = (Rand_ZeroOne() * 1.5f) + 1.5f;
if (!EnFirefly_ReturnToPerch(this, globalCtx) && !EnFirefly_SeekTorch(this, globalCtx)) {
if (isSkelAnimeUpdated) {
rand = Rand_ZeroOne();
if (rand < 0.5f) {
Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos),
0x300);
} else if (rand < 0.8f) {
this->actor.shape.rot.y += (s16)randPlusMinusPoint5Scaled(1536.0f);
}
// Climb if too close to ground
if (this->actor.world.pos.y < this->actor.floorHeight + 20.0f) {
this->targetPitch = 0x954;
// Descend if above maxAltitude
} else if (this->maxAltitude < this->actor.world.pos.y) {
this->targetPitch = 0x2154;
// Otherwise ascend or descend at random, biased towards ascending
} else if (Rand_ZeroOne() > 0.35f) {
this->targetPitch = 0x954;
} else {
this->targetPitch = 0x2154;
}
} else {
if (this->actor.bgCheckFlags & 1) {
this->targetPitch = 0x954;
} else if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) {
this->targetPitch = 0x2154;
}
}
Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100);
}
if (this->actor.bgCheckFlags & 8) {
Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300);
}
if ((this->timer == 0) && (this->actor.xzDistToPlayer < 200.0f) &&
(Player_GetMask(globalCtx) != PLAYER_MASK_STONE_MASK)) {
EnFirefly_SetupDiveAttack(this);
}
}
void EnFirefly_SetupFall(EnFirefly* this, GlobalContext* globalCtx) {
this->timer = 40;
this->actor.velocity.y = 0.0f;
SkelAnime_ChangeAnim(&this->skelAnime, &D_0600017C, 0.0f, 6.0f, 6.0f, 2, 0.0f);
Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_DEAD);
this->actor.flags |= 0x10;
if (this->isInvisible) {
func_800BCB70(&this->actor, 0x4000, 255, 0x2000, 40);
} else {
func_800BCB70(&this->actor, 0x4000, 255, 0, 40);
}
if (this->actor.colChkInfo.damageEffect == 3) {
this->unk_18F = 0xA;
this->unk_2E8.x = 1.0f;
this->unk_2E8.y = 0.55f;
this->unk_2E8.z = 0.82500005f;
} else if (this->actor.colChkInfo.damageEffect == 4) {
this->unk_18F = 0x14;
this->unk_2E8.x = 4.0f;
this->unk_2E8.y = 0.55f;
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, 3);
} else if (this->actor.colChkInfo.damageEffect == 2) {
this->unk_18F = 0;
this->unk_2E8.x = 4.0f;
this->unk_2E8.y = 0.55f;
}
if (this->unk_2E8.x > 0.0f) {
this->auraType = KEESE_AURA_NONE;
}
if (this->actor.flags & 0x8000) {
this->actor.speedXZ = 0.0f;
}
this->actionFunc = EnFirefly_Fall;
}
// Fall to the ground after being hit
void EnFirefly_Fall(EnFirefly* this, GlobalContext* globalCtx) {
this->actor.colorFilterTimer = 40;
Math_StepToF(&this->actor.speedXZ, 0.0f, 0.5f);
if (!(this->actor.flags & 0x8000)) {
if (this->unk_18F != 0xA) {
Math_ScaledStepToS(&this->actor.shape.rot.x, 0x6800, 0x200);
this->actor.shape.rot.y -= 0x300;
}
if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) {
EnFirefly_SpawnIceEffects(this, globalCtx);
EnFirefly_SetupDie(this);
}
}
}
void EnFirefly_SetupDie(EnFirefly* this) {
this->timer = 15;
this->actor.speedXZ = 0.0f;
this->actionFunc = EnFirefly_Die;
}
// Hit the ground or burn up, spawn drops
void EnFirefly_Die(EnFirefly* this, GlobalContext* globalCtx) {
if (this->timer != 0) {
this->timer--;
}
Math_StepToF(&this->actor.scale.x, 0.0f, 0.00034f);
this->actor.scale.y = this->actor.scale.z = this->actor.scale.x;
if (this->timer == 0) {
Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xA0);
Actor_MarkForDeath(&this->actor);
}
}
void EnFirefly_SetupDiveAttack(EnFirefly* this) {
this->timer = Rand_S16Offset(70, 100);
this->skelAnime.animPlaybackSpeed = 1.0f;
this->targetPitch = ((this->actor.yDistToPlayer > 0.0f) ? -0xC00 : 0xC00) + 0x1554;
this->actionFunc = EnFirefly_DiveAttack;
}
void EnFirefly_DiveAttack(EnFirefly* this, GlobalContext* globalCtx) {
Player* player = PLAYER;
Vec3f preyPos;
SkelAnime_FrameUpdateMatrix(&this->skelAnime);
if (this->timer != 0) {
this->timer--;
}
Math_StepToF(&this->actor.speedXZ, 4.0f, 0.5f);
if (this->actor.bgCheckFlags & 8) {
Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300);
Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100);
} else if (Actor_IsActorFacingLink(&this->actor, 0x2800)) {
if (func_801378B8(&this->skelAnime, 4.0f)) {
this->skelAnime.animPlaybackSpeed = 0.0f;
this->skelAnime.animCurrentFrame = 4.0f;
}
Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xC00, 0x300);
preyPos.x = player->actor.world.pos.x;
preyPos.y = player->actor.world.pos.y + 20.0f;
preyPos.z = player->actor.world.pos.z;
Math_SmoothStepToS(&this->actor.shape.rot.x, Actor_PitchToPoint(&this->actor, &preyPos) + 0x1554, 2, 0x400,
0x100);
} else {
this->skelAnime.animPlaybackSpeed = 1.5f;
if (this->actor.xzDistToPlayer > 80.0f) {
Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 2, 0xC00, 0x300);
}
if (this->actor.bgCheckFlags & 1) {
this->targetPitch = 0x954;
}
if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) {
this->targetPitch = 0x2154;
} else {
this->targetPitch = 0x954;
}
Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100);
}
if ((this->timer == 0) || (Player_GetMask(globalCtx) == PLAYER_MASK_STONE_MASK) || (player->stateFlags2 & 0x80) ||
(player->actor.freezeTimer > 0)) {
EnFirefly_SetupFlyAway(this);
}
}
void EnFirefly_SetupRebound(EnFirefly* this) {
this->actor.world.rot.x = 0x7000;
this->timer = 18;
this->skelAnime.animPlaybackSpeed = 1.0f;
this->actor.speedXZ = 2.5f;
this->actionFunc = EnFirefly_Rebound;
}
// Knockback after hitting player
void EnFirefly_Rebound(EnFirefly* this, GlobalContext* globalCtx) {
SkelAnime_FrameUpdateMatrix(&this->skelAnime);
Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x100);
Math_StepToF(&this->actor.velocity.y, 0.0f, 0.4f);
if (Math_StepToF(&this->actor.speedXZ, 0.0f, 0.15f)) {
if (this->timer != 0) {
this->timer--;
}
if (this->timer == 0) {
EnFirefly_SetupFlyAway(this);
}
}
}
void EnFirefly_SetupFlyAway(EnFirefly* this) {
this->timer = 150;
this->targetPitch = 0x954;
this->actionFunc = EnFirefly_FlyAway;
this->skelAnime.animPlaybackSpeed = 1.0f;
}
void EnFirefly_FlyAway(EnFirefly* this, GlobalContext* globalCtx) {
SkelAnime_FrameUpdateMatrix(&this->skelAnime);
if (this->timer != 0) {
this->timer--;
}
if ((fabsf(this->actor.world.pos.y - this->maxAltitude) < 10.0f) &&
(Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) < 20.0f) ||
(this->timer == 0)) {
EnFirefly_SetupFlyIdle(this);
return;
}
Math_StepToF(&this->actor.speedXZ, 3.0f, 0.3f);
if (this->actor.bgCheckFlags & 1) {
this->targetPitch = 0x954;
} else if ((this->actor.bgCheckFlags & 0x10) || (this->maxAltitude < this->actor.world.pos.y)) {
this->targetPitch = 0x2154;
} else {
this->targetPitch = 0x954;
}
if (this->actor.bgCheckFlags & 8) {
Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.wallYaw, 2, 0xC00, 0x300);
} else {
Math_ScaledStepToS(&this->actor.shape.rot.y, Actor_YawToPoint(&this->actor, &this->actor.home.pos), 0x300);
}
Math_ScaledStepToS(&this->actor.shape.rot.x, this->targetPitch, 0x100);
}
void EnFirefly_SetupStunned(EnFirefly* this) {
if (this->isInvisible) {
func_800BCB70(&this->actor, 0, 255, 0x2000, this->timer);
} else {
func_800BCB70(&this->actor, 0, 255, 0, this->timer);
}
if (this->actionFunc != EnFirefly_Stunned) {
this->actor.velocity.y = 0.0f;
this->actor.speedXZ = 0.0f;
}
this->auraType = KEESE_AURA_NONE;
Audio_PlayActorSound2(&this->actor, NA_SE_EN_COMMON_FREEZE);
this->actionFunc = EnFirefly_Stunned;
}
void EnFirefly_Stunned(EnFirefly* this, GlobalContext* globalCtx) {
Math_ScaledStepToS(&this->actor.shape.rot.x, 0x1554, 0x100);
if ((this->actor.bgCheckFlags & 1) || (this->actor.floorHeight == BGCHECK_Y_MIN)) {
if (this->timer != 0) {
this->timer--;
}
if (this->timer == 0) {
if (this->currentType == KEESE_FIRE) {
this->auraType = KEESE_AURA_FIRE;
} else if (this->currentType == KEESE_ICE) {
this->auraType = KEESE_AURA_ICE;
}
EnFirefly_SetupFlyIdle(this);
}
} else {
this->actor.colorFilterTimer = 40;
if (this->unk_2E8.x > 0.0f) {
this->unk_2E8.x = 2.0f;
}
}
}
void EnFirefly_SetupPerch(EnFirefly* this) {
this->timer = 1;
this->actionFunc = EnFirefly_Perch;
this->actor.speedXZ = 0.0f;
}
// When perching, sit on collision and flap at random intervals
void EnFirefly_Perch(EnFirefly* this, GlobalContext* globalCtx) {
Math_ScaledStepToS(&this->actor.shape.rot.x, 0, 0x100);
if (this->timer != 0) {
SkelAnime_FrameUpdateMatrix(&this->skelAnime);
if (func_801378B8(&this->skelAnime, 6.0f)) {
this->timer--;
}
} else if (Rand_ZeroOne() < 0.02f) {
this->timer = 1;
}
if (this->actor.xzDistToPlayer < 120.0f) {
EnFirefly_SetupDisturbDiveAttack(this);
}
}
void EnFirefly_SetupDisturbDiveAttack(EnFirefly* this) {
this->skelAnime.animPlaybackSpeed = 3.0f;
this->actor.shape.rot.x = 0x1554;
this->actor.shape.rot.y = this->actor.yawTowardsPlayer;
this->timer = 50;
this->actor.speedXZ = 3.0f;
this->actionFunc = EnFirefly_DisturbDiveAttack;
}
void EnFirefly_DisturbDiveAttack(EnFirefly* this, GlobalContext* globalCtx) {
Player* player = PLAYER;
Vec3f preyPos;
SkelAnime_FrameUpdateMatrix(&this->skelAnime);
if (this->timer != 0) {
this->timer--;
}
if (this->timer < 40) {
Math_ScaledStepToS(&this->actor.shape.rot.x, -0xAAC, 0x100);
} else {
preyPos.x = player->actor.world.pos.x;
preyPos.y = player->actor.world.pos.y + 20.0f;
preyPos.z = player->actor.world.pos.z;
Math_ScaledStepToS(&this->actor.shape.rot.x, Actor_PitchToPoint(&this->actor, &preyPos) + 0x1554, 0x100);
Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x300);
}
if (this->timer == 0) {
EnFirefly_SetupFlyIdle(this);
}
}
void EnFirefly_UpdateDamage(EnFirefly* this, GlobalContext* globalCtx) {
if (this->collider.base.acFlags & AC_HIT) {
this->collider.base.acFlags &= ~AC_HIT;
func_800BE258(&this->actor, &this->collider.info);
if (this->actor.colChkInfo.damageEffect == 1) {
this->timer = 40;
EnFirefly_SetupStunned(this);
} else if (this->actor.colChkInfo.damageEffect == 5) {
this->timer = 40;
this->unk_18F = 0x1F;
this->unk_2E8.x = 2.0f;
this->unk_2E8.y = 0.55f;
EnFirefly_SetupStunned(this);
} else {
func_800BBA88(globalCtx, &this->actor);
this->actor.colChkInfo.health = 0;
this->actor.flags &= ~1;
// Negate effects of fire on Fire Keese and Ice on Ice Keese
if (((this->currentType == KEESE_FIRE) && (this->actor.colChkInfo.damageEffect == 2)) ||
((this->currentType == KEESE_ICE) && (this->actor.colChkInfo.damageEffect == 3))) {
this->actor.colChkInfo.damageEffect = 0;
}
EnFirefly_SetupFall(this, globalCtx);
}
}
}
void EnFirefly_Update(Actor* thisx, GlobalContext* globalCtx2) {
GlobalContext* globalCtx = globalCtx2;
EnFirefly* this = THIS;
if (this->collider.base.atFlags & AT_HIT) {
this->collider.base.atFlags &= ~AT_HIT;
Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_ATTACK);
if (this->currentType != KEESE_NORMAL) {
EnFirefly_Extinguish(this);
}
if (this->actionFunc != EnFirefly_DisturbDiveAttack) {
EnFirefly_SetupRebound(this);
}
}
EnFirefly_UpdateDamage(this, globalCtx);
this->actionFunc(this, globalCtx);
if (!(this->actor.flags & 0x8000)) {
if ((this->actor.colChkInfo.health == 0) || (this->actionFunc == EnFirefly_Stunned)) {
Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor);
} else {
if (this->actionFunc != EnFirefly_Rebound) {
this->actor.world.rot.x = 0x1554 - this->actor.shape.rot.x;
}
Actor_SetVelocityAndMoveXYRotation(&this->actor);
}
}
Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 10.0f, 15.0f, 7);
this->collider.dim.worldSphere.center.x = this->actor.world.pos.x;
this->collider.dim.worldSphere.center.y = (s32)this->actor.world.pos.y + 10;
this->collider.dim.worldSphere.center.z = this->actor.world.pos.z;
if ((this->actionFunc == EnFirefly_DiveAttack) || (this->actionFunc == EnFirefly_DisturbDiveAttack)) {
CollisionCheck_SetAT(globalCtx, &globalCtx->colCheckCtx, &this->collider.base);
}
if (this->actor.colChkInfo.health != 0) {
CollisionCheck_SetAC(globalCtx, &globalCtx->colCheckCtx, &this->collider.base);
this->actor.world.rot.y = this->actor.shape.rot.y;
if (func_801378B8(&this->skelAnime, 5.0f)) {
Audio_PlayActorSound2(&this->actor, NA_SE_EN_FFLY_FLY);
}
}
CollisionCheck_SetOC(globalCtx, &globalCtx->colCheckCtx, &this->collider.base);
if (this->unk_2E8.x > 0.0f) {
if (this->unk_18F != 0xA) {
Math_StepToF(&this->unk_2E8.x, 0.0f, 0.05f);
this->unk_2E8.y = (this->unk_2E8.x + 1.0f) * 0.275f;
this->unk_2E8.y = CLAMP_MAX(this->unk_2E8.y, 0.55f);
} else if (!Math_StepToF(&this->unk_2E8.z, 0.55f, 0.01375f)) {
func_800B9010(&this->actor, NA_SE_EV_ICE_FREEZE - SFX_FLAG);
}
}
this->actor.focus.pos.x =
10.0f * Math_SinS(this->actor.shape.rot.x) * Math_SinS(this->actor.shape.rot.y) + this->actor.world.pos.x;
this->actor.focus.pos.y = 10.0f * Math_CosS(this->actor.shape.rot.x) + this->actor.world.pos.y;
this->actor.focus.pos.z =
10.0f * Math_SinS(this->actor.shape.rot.x) * Math_CosS(this->actor.shape.rot.y) + this->actor.world.pos.z;
}
s32 EnFirefly_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
Actor* thisx, Gfx** gfx) {
EnFirefly* this = THIS;
if (this->isInvisible && (globalCtx->actorCtx.unk4 != 0x64)) {
*dList = NULL;
} else if (limbIndex == 1) {
pos->y += 2300.0f;
}
return false;
}
void EnFirefly_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) {
static Color_RGBA8 fireAuraPrimColor = { 255, 255, 100, 255 };
static Color_RGBA8 fireAuraEnvColor = { 255, 50, 0, 0 };
static Color_RGBA8 iceAuraPrimColor = { 100, 200, 255, 255 };
static Color_RGBA8 iceAuraEnvColor = { 0, 0, 255, 0 };
static Vec3f auraVelocity = { 0.0f, 0.5f, 0.0f };
static Vec3f auraAccel = { 0.0f, 0.5f, 0.0f };
Vec3f auraPos;
Color_RGBA8* auraPrimColor;
Color_RGBA8* auraEnvColor;
s16 auraScaleStep;
s16 auraLife;
s32 pad;
EnFirefly* this = THIS;
if ((this->currentType != KEESE_FIRE) && (limbIndex == 27)) {
gSPDisplayList((*gfx)++, D_06001678);
} else if ((this->unk_2F4 != globalCtx->gameplayFrames) &&
((this->auraType == KEESE_AURA_FIRE) || (this->auraType == KEESE_AURA_ICE)) &&
((limbIndex == 15) || (limbIndex == 21))) {
if (this->actionFunc != EnFirefly_Die) {
SysMatrix_GetStateTranslation(&auraPos);
auraPos.x += Rand_ZeroFloat(5.0f);
auraPos.y += Rand_ZeroFloat(5.0f);
auraPos.z += Rand_ZeroFloat(5.0f);
auraScaleStep = -40;
auraLife = 3;
} else {
if (limbIndex == 15) {
auraPos.x = Math_SinS(9100 * this->timer) * this->timer + this->actor.world.pos.x;
auraPos.z = Math_CosS(9100 * this->timer) * this->timer + this->actor.world.pos.z;
} else {
auraPos.x = this->actor.world.pos.x - Math_SinS(9100 * this->timer) * this->timer;
auraPos.z = this->actor.world.pos.z - Math_CosS(9100 * this->timer) * this->timer;
}
auraPos.y = this->actor.world.pos.y + (15 - this->timer) * 1.5f;
auraScaleStep = -5;
auraLife = 10;
}
if (this->auraType == KEESE_AURA_FIRE) {
auraPrimColor = &fireAuraPrimColor;
auraEnvColor = &fireAuraEnvColor;
} else {
auraPrimColor = &iceAuraPrimColor;
auraEnvColor = &iceAuraEnvColor;
}
func_800B0F80(globalCtx, &auraPos, &auraVelocity, &auraAccel, auraPrimColor, auraEnvColor, 250, auraScaleStep,
auraLife);
}
if (limbIndex == 15) {
SysMatrix_GetStateTranslation(&this->unk_2F8);
} else if (limbIndex == 21) {
SysMatrix_GetStateTranslation(&this->unk_304);
} else if (limbIndex == 10) {
SysMatrix_GetStateTranslation(&this->unk_310);
}
}
void EnFirefly_Draw(Actor* thisx, GlobalContext* globalCtx) {
s32 pad;
EnFirefly* this = THIS;
Gfx* gfx;
OPEN_DISPS(globalCtx->state.gfxCtx);
if (this->isInvisible) {
gfx = POLY_XLU_DISP;
} else {
gfx = POLY_OPA_DISP;
}
gSPDisplayList(gfx, &sSetupDL[150]);
if (this->currentType == KEESE_FIRE) {
gDPSetEnvColor(gfx + 1, 0, 0, 0, 0);
} else {
gDPSetEnvColor(gfx + 1, 0, 0, 0, 255);
}
gfx = SkelAnime_Draw2(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, EnFirefly_OverrideLimbDraw,
EnFirefly_PostLimbDraw, &this->actor, gfx + 2);
if (this->isInvisible) {
POLY_XLU_DISP = gfx;
} else {
POLY_OPA_DISP = gfx;
}
func_800BE680(globalCtx, NULL, &this->unk_2F8, 3, this->unk_2E8.y * this->actor.scale.y * 200.0f, this->unk_2E8.z,
this->unk_2E8.x, this->unk_18F);
this->unk_2F4 = globalCtx->gameplayFrames;
CLOSE_DISPS(globalCtx->state.gfxCtx);
}
@@ -5,9 +5,37 @@
struct EnFirefly;
typedef void (*EnFireflyActionFunc)(struct EnFirefly*, GlobalContext*);
typedef enum {
/* 0 */ KEESE_FIRE_FLY,
/* 2 */ KEESE_NORMAL_FLY = 2,
/* 3 */ KEESE_NORMAL_PERCH,
/* 4 */ KEESE_ICE_FLY
} KeeseMainType;
#define KEESE_INVISIBLE (1 << 0xF)
#define KEESE_GET_MAIN_TYPE(thisx) ((thisx)->params & 0x7FFF)
typedef struct EnFirefly {
/* 0x000 */ Actor actor;
/* 0x144 */ char unk_144[0x230];
/* 0x144 */ SkelAnime skelAnime;
/* 0x188 */ EnFireflyActionFunc actionFunc;
/* 0x18C */ u8 auraType;
/* 0x18D */ u8 currentType;
/* 0x18E */ u8 isInvisible;
/* 0x18F */ u8 unk_18F;
/* 0x190 */ s16 timer;
/* 0x192 */ s16 targetPitch;
/* 0x194 */ Vec3s jointTable[28];
/* 0x23C */ Vec3s morphTable[28];
/* 0x2E4 */ f32 maxAltitude;
/* 0x2E8 */ Vec3f unk_2E8;
/* 0x2F4 */ s32 unk_2F4;
/* 0x2F8 */ Vec3f unk_2F8;
/* 0x304 */ Vec3f unk_304;
/* 0x304 */ Vec3f unk_310;
/* 0x31C */ ColliderSphere collider;
} EnFirefly; // size = 0x374
extern const ActorInit En_Firefly_InitVars;
@@ -5,7 +5,7 @@
*/
#include "z_en_pametfrog.h"
#include "src/overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h"
#include "overlays/actors/ovl_En_Bigpamet/z_en_bigpamet.h"
#define FLAGS 0x00000035
@@ -1,5 +1,5 @@
#include "z_en_po_fusen.h"
#include "../ovl_En_Ma4/z_en_ma4.h"
#include "overlays/actors/ovl_En_Ma4/z_en_ma4.h"
#define FLAGS 0x80100030
@@ -16,7 +16,7 @@ const ActorInit En_River_Sound_InitVars = {
GAMEPLAY_KEEP,
sizeof(EnRiverSound),
(ActorFunc)EnRiverSound_Init,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)EnRiverSound_Update,
(ActorFunc)EnRiverSound_Draw,
};
@@ -15,7 +15,7 @@ const ActorInit En_Test2_InitVars = {
GAMEPLAY_KEEP,
sizeof(EnTest2),
(ActorFunc)EnTest2_Init,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)EnTest2_Update,
(ActorFunc)NULL,
};
@@ -15,7 +15,7 @@ const ActorInit Obj_Blockstop_InitVars = {
GAMEPLAY_KEEP,
sizeof(ObjBlockstop),
(ActorFunc)ObjBlockstop_Init,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)ObjBlockstop_Update,
(ActorFunc)NULL,
};
@@ -5,8 +5,8 @@
*/
#include "z_obj_boyo.h"
#include "../ovl_En_Kaizoku/z_en_kaizoku.h"
#include "../ovl_En_Bom/z_en_bom.h"
#include "overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.h"
#include "overlays/actors/ovl_En_Bom/z_en_bom.h"
#define FLAGS 0x00000010
@@ -15,7 +15,7 @@ const ActorInit Obj_Demo_InitVars = {
GAMEPLAY_KEEP,
sizeof(ObjDemo),
(ActorFunc)ObjDemo_Init,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)ObjDemo_Update,
(ActorFunc)NULL,
};
@@ -16,7 +16,7 @@ const ActorInit Obj_Ending_InitVars = {
OBJECT_ENDING_OBJ,
sizeof(ObjEnding),
(ActorFunc)ObjEnding_Init,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)ObjEnding_Update,
(ActorFunc)ObjEnding_Draw,
};
@@ -14,8 +14,8 @@ const ActorInit Obj_Funen_InitVars = {
OBJECT_FUNEN,
sizeof(ObjFunen),
(ActorFunc)ObjFunen_Init,
(ActorFunc)func_800BDFB0,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)Actor_Noop,
(ActorFunc)ObjFunen_Draw,
};
@@ -14,8 +14,8 @@ const ActorInit Obj_Grass_Unit_InitVars = {
GAMEPLAY_FIELD_KEEP,
sizeof(ObjGrassUnit),
(ActorFunc)ObjGrassUnit_Init,
(ActorFunc)func_800BDFB0,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)Actor_Noop,
(ActorFunc)NULL,
};
*/
@@ -15,7 +15,7 @@ const ActorInit Obj_Makeoshihiki_InitVars = {
GAMEPLAY_KEEP,
sizeof(ObjMakeoshihiki),
(ActorFunc)ObjMakeoshihiki_Init,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)ObjMakeoshihiki_Update,
(ActorFunc)NULL,
};
@@ -15,7 +15,7 @@ const ActorInit Obj_Mure2_InitVars = {
GAMEPLAY_KEEP,
sizeof(ObjMure2),
(ActorFunc)ObjMure2_Init,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)ObjMure2_Update,
(ActorFunc)NULL,
};
@@ -7,7 +7,9 @@ struct ObjSyokudai;
typedef struct ObjSyokudai {
/* 0x000 */ Actor actor;
/* 0x144 */ char unk_144[0xB0];
/* 0x144 */ char unk_144[0x98];
/* 0x1DC */ s16 unk_1DC;
/* 0x1DE */ char unk_1DE[0x16];
} ObjSyokudai; // size = 0x1F4
extern const ActorInit Obj_Syokudai_InitVars;
@@ -16,7 +16,7 @@ const ActorInit Obj_Visiblock_InitVars = {
sizeof(ObjVisiblock),
(ActorFunc)ObjVisiblock_Init,
(ActorFunc)ObjVisiblock_Destroy,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)ObjVisiblock_Draw,
};
@@ -15,7 +15,7 @@ const ActorInit Obj_Wturn_InitVars = {
GAMEPLAY_KEEP,
sizeof(ObjWturn),
(ActorFunc)ObjWturn_Init,
(ActorFunc)func_800BDFB0,
(ActorFunc)Actor_Noop,
(ActorFunc)ObjWturn_Update,
(ActorFunc)NULL,
};