1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-06-08 17:41:56 +00:00

[Doc] actor En_Skb (Stalchild) (#1299)

* en_skb stalchild actor doc

* missed a sneaky one

* rename Main to DecideNextAction

* action state rename and become enum

* tweak bodybreak comment

* rename SPAWNING to BURIED

* rename to headlessWalkYawOffset

* rename hitboxActive to enableATCollision

* use bools for enableATCollision

* formatting

* move EnSkbActionState out of header

* rename enableATCollision -> setColliderAT

* remove unnecessary prototypes

* renaming per review, settle on breakFlags
This commit is contained in:
krm01 2022-07-28 00:02:46 -07:00 committed by GitHub
parent 423fec9f79
commit 3122143f96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 126 additions and 112 deletions

View file

@ -1,31 +1,44 @@
/*
* File: z_en_skb.c
* Overlay: ovl_En_Skb
* Description: Stalchild
*/
#include "z_en_skb.h" #include "z_en_skb.h"
#include "overlays/actors/ovl_En_Encount1/z_en_encount1.h" #include "overlays/actors/ovl_En_Encount1/z_en_encount1.h"
#include "assets/objects/object_skb/object_skb.h" #include "assets/objects/object_skb/object_skb.h"
#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4) #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4)
typedef enum {
SKB_BEHAVIOR_BURIED,
SKB_BEHAVIOR_DYING,
SKB_BEHAVIOR_DAMAGED,
SKB_BEHAVIOR_ATTACKING,
SKB_BEHAVIOR_WALKING,
SKB_BEHAVIOR_RECOILING,
SKB_BEHAVIOR_STUNNED
} StalchildBehavior;
void EnSkb_Init(Actor* thisx, PlayState* play); void EnSkb_Init(Actor* thisx, PlayState* play);
void EnSkb_Destroy(Actor* thisx, PlayState* play); void EnSkb_Destroy(Actor* thisx, PlayState* play);
void EnSkb_Update(Actor* thisx, PlayState* play); void EnSkb_Update(Actor* thisx, PlayState* play);
void EnSkb_Draw(Actor* thisx, PlayState* play); void EnSkb_Draw(Actor* thisx, PlayState* play);
void func_80AFCD60(EnSkb* this); void EnSkb_SetupRiseFromGround(EnSkb* this);
void func_80AFCDF8(EnSkb* this); void EnSkb_RiseFromGround(EnSkb* this, PlayState* play);
void func_80AFCE5C(EnSkb* this, PlayState* play); void EnSkb_SetupDespawn(EnSkb* this);
void func_80AFCF48(EnSkb* this); void EnSkb_Despawn(EnSkb* this, PlayState* play);
void func_80AFCFF0(EnSkb* this, PlayState* play); void EnSkb_SetupWalkForward(EnSkb* this);
void func_80AFD0A4(EnSkb* this); void EnSkb_WalkForward(EnSkb* this, PlayState* play);
void EnSkb_Advance(EnSkb* this, PlayState* play); void EnSkb_SetupAttack(EnSkb* this);
void func_80AFD33C(EnSkb* this); void EnSkb_Attack(EnSkb* this, PlayState* play);
void EnSkb_SetupAttack(EnSkb* this, PlayState* play); void EnSkb_SetupRecoil(EnSkb* this);
void func_80AFD47C(EnSkb* this); void EnSkb_Recoil(EnSkb* this, PlayState* play);
void func_80AFD508(EnSkb* this, PlayState* play); void EnSkb_Stunned(EnSkb* this, PlayState* play);
void EnSkb_SetupStunned(EnSkb* this); void EnSkb_TakeDamage(EnSkb* this, PlayState* play);
void func_80AFD59C(EnSkb* this, PlayState* play); void EnSkb_SetupDeath(EnSkb* this, PlayState* play);
void func_80AFD6CC(EnSkb* this, PlayState* play); void EnSkb_Death(EnSkb* this, PlayState* play);
void func_80AFD7B4(EnSkb* this, PlayState* play);
void func_80AFD880(EnSkb* this, PlayState* play);
void func_80AFD968(EnSkb* this, PlayState* play);
static ColliderJntSphElementInit sJntSphElementsInit[2] = { static ColliderJntSphElementInit sJntSphElementsInit[2] = {
{ {
@ -142,8 +155,8 @@ static InitChainEntry sInitChain[] = {
void EnSkb_Init(Actor* thisx, PlayState* play) { void EnSkb_Init(Actor* thisx, PlayState* play) {
EnSkb* this = (EnSkb*)thisx; EnSkb* this = (EnSkb*)thisx;
s16 paramOffsetBody; s16 armOffset;
s16 paramOffsetArm; s16 bodyOffset;
Actor_ProcessInitChain(&this->actor, sInitChain); Actor_ProcessInitChain(&this->actor, sInitChain);
this->actor.colChkInfo.damageTable = &sDamageTable; this->actor.colChkInfo.damageTable = &sDamageTable;
@ -160,16 +173,16 @@ void EnSkb_Init(Actor* thisx, PlayState* play) {
Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderItem); Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderItem);
Actor_SetScale(&this->actor, ((this->actor.params * 0.1f) + 1.0f) * 0.01f); Actor_SetScale(&this->actor, ((this->actor.params * 0.1f) + 1.0f) * 0.01f);
paramOffsetBody = this->actor.params + 0xA; armOffset = this->actor.params + 0xA;
this->collider.elements[0].dim.worldSphere.radius = paramOffsetBody; this->collider.elements[0].dim.worldSphere.radius = armOffset;
this->collider.elements[0].dim.modelSphere.radius = paramOffsetBody; this->collider.elements[0].dim.modelSphere.radius = armOffset;
if (1) {}; if (1) {};
paramOffsetArm = (this->actor.params * 2) + 0x14; bodyOffset = (this->actor.params * 2) + 0x14;
this->collider.elements[1].dim.worldSphere.radius = paramOffsetArm; this->collider.elements[1].dim.worldSphere.radius = bodyOffset;
this->collider.elements[1].dim.modelSphere.radius = paramOffsetArm; this->collider.elements[1].dim.modelSphere.radius = bodyOffset;
this->actor.home.pos = this->actor.world.pos; this->actor.home.pos = this->actor.world.pos;
this->actor.floorHeight = this->actor.world.pos.y; this->actor.floorHeight = this->actor.world.pos.y;
func_80AFCDF8(this); EnSkb_SetupRiseFromGround(this);
} }
void EnSkb_Destroy(Actor* thisx, PlayState* play) { void EnSkb_Destroy(Actor* thisx, PlayState* play) {
@ -187,26 +200,26 @@ void EnSkb_Destroy(Actor* thisx, PlayState* play) {
Collider_DestroyJntSph(play, &this->collider); Collider_DestroyJntSph(play, &this->collider);
} }
void func_80AFCD60(EnSkb* this) { void EnSkb_DecideNextAction(EnSkb* this) {
if (IS_DAY) { if (IS_DAY) {
func_80AFCF48(this); EnSkb_SetupDespawn(this);
} else if (Actor_IsFacingPlayer(&this->actor, 0x11C7) && } else if (Actor_IsFacingPlayer(&this->actor, 0x11C7) &&
(this->actor.xzDistToPlayer < (60.0f + (this->actor.params * 6.0f)))) { (this->actor.xzDistToPlayer < (60.0f + (this->actor.params * 6.0f)))) {
func_80AFD33C(this); EnSkb_SetupAttack(this);
} else { } else {
func_80AFD0A4(this); EnSkb_SetupWalkForward(this);
} }
} }
void func_80AFCDF8(EnSkb* this) { void EnSkb_SetupRiseFromGround(EnSkb* this) {
Animation_PlayOnceSetSpeed(&this->skelAnime, &gStalchildUncurlingAnim, 1.0f); Animation_PlayOnceSetSpeed(&this->skelAnime, &gStalchildUncurlingAnim, 1.0f);
this->unk_280 = 0; this->actionState = SKB_BEHAVIOR_BURIED;
this->actor.flags &= ~ACTOR_FLAG_0; this->actor.flags &= ~ACTOR_FLAG_0;
Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIVA_APPEAR); Audio_PlayActorSound2(&this->actor, NA_SE_EN_RIVA_APPEAR);
EnSkb_SetupAction(this, func_80AFCE5C); EnSkb_SetupAction(this, EnSkb_RiseFromGround);
} }
void func_80AFCE5C(EnSkb* this, PlayState* play) { void EnSkb_RiseFromGround(EnSkb* this, PlayState* play) {
if (this->skelAnime.curFrame < 4.0f) { if (this->skelAnime.curFrame < 4.0f) {
this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer;
this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.shape.rot.y = this->actor.yawTowardsPlayer;
@ -219,22 +232,22 @@ void func_80AFCE5C(EnSkb* this, PlayState* play) {
EnSkb_SpawnDebris(play, this, &this->actor.world.pos); EnSkb_SpawnDebris(play, this, &this->actor.world.pos);
} }
if ((SkelAnime_Update(&this->skelAnime) != 0) && (0.0f == this->actor.shape.yOffset)) { if ((SkelAnime_Update(&this->skelAnime) != 0) && (0.0f == this->actor.shape.yOffset)) {
func_80AFCD60(this); EnSkb_DecideNextAction(this);
} }
} }
void func_80AFCF48(EnSkb* this) { void EnSkb_SetupDespawn(EnSkb* this) {
Animation_Change(&this->skelAnime, &gStalchildUncurlingAnim, -1.0f, Animation_Change(&this->skelAnime, &gStalchildUncurlingAnim, -1.0f,
Animation_GetLastFrame(&gStalchildUncurlingAnim), 0.0f, ANIMMODE_ONCE, -4.0f); Animation_GetLastFrame(&gStalchildUncurlingAnim), 0.0f, ANIMMODE_ONCE, -4.0f);
this->unk_280 = 0; this->actionState = SKB_BEHAVIOR_BURIED;
this->unk_281 = 0; this->setColliderAT = false;
this->actor.flags &= ~ACTOR_FLAG_0; this->actor.flags &= ~ACTOR_FLAG_0;
this->actor.speedXZ = 0.0f; this->actor.speedXZ = 0.0f;
Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); Audio_PlayActorSound2(&this->actor, NA_SE_EN_AKINDONUTS_HIDE);
EnSkb_SetupAction(this, func_80AFCFF0); EnSkb_SetupAction(this, EnSkb_Despawn);
} }
void func_80AFCFF0(EnSkb* this, PlayState* play) { void EnSkb_Despawn(EnSkb* this, PlayState* play) {
if ((Math_SmoothStepToF(&this->actor.shape.yOffset, -8000.0f, 1.0f, 500.0f, 0.0f) != 0.0f) && if ((Math_SmoothStepToF(&this->actor.shape.yOffset, -8000.0f, 1.0f, 500.0f, 0.0f) != 0.0f) &&
(play->gameplayFrames & 1)) { (play->gameplayFrames & 1)) {
EnSkb_SpawnDebris(play, this, &this->actor.world.pos); EnSkb_SpawnDebris(play, this, &this->actor.world.pos);
@ -245,25 +258,25 @@ void func_80AFCFF0(EnSkb* this, PlayState* play) {
} }
} }
void func_80AFD0A4(EnSkb* this) { void EnSkb_SetupWalkForward(EnSkb* this) {
Animation_Change(&this->skelAnime, &gStalchildWalkingAnim, 0.96000004f, 0.0f, Animation_Change(&this->skelAnime, &gStalchildWalkingAnim, 0.96000004f, 0.0f,
Animation_GetLastFrame(&gStalchildWalkingAnim), ANIMMODE_LOOP, -4.0f); Animation_GetLastFrame(&gStalchildWalkingAnim), ANIMMODE_LOOP, -4.0f);
this->unk_280 = 4; this->actionState = SKB_BEHAVIOR_WALKING;
this->unk_288 = 0; this->headlessYawOffset = 0;
this->actor.speedXZ = this->actor.scale.y * 160.0f; this->actor.speedXZ = this->actor.scale.y * 160.0f;
EnSkb_SetupAction(this, EnSkb_Advance); EnSkb_SetupAction(this, EnSkb_WalkForward);
} }
void EnSkb_Advance(EnSkb* this, PlayState* play) { void EnSkb_WalkForward(EnSkb* this, PlayState* play) {
s32 thisKeyFrame; s32 thisKeyFrame;
s32 prevKeyFrame; s32 prevKeyFrame;
f32 playSpeed; f32 playSpeed;
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
if ((this->unk_283 != 0) && ((play->gameplayFrames & 0xF) == 0)) { if ((this->breakFlags != 0) && ((play->gameplayFrames & 0xF) == 0)) {
this->unk_288 = Rand_CenteredFloat(50000.0f); this->headlessYawOffset = Rand_CenteredFloat(50000.0f);
} }
Math_SmoothStepToS(&this->actor.shape.rot.y, (this->actor.yawTowardsPlayer + this->unk_288), 1, 0x2EE, 0); Math_SmoothStepToS(&this->actor.shape.rot.y, (this->actor.yawTowardsPlayer + this->headlessYawOffset), 1, 0x2EE, 0);
this->actor.world.rot.y = this->actor.shape.rot.y; this->actor.world.rot.y = this->actor.shape.rot.y;
thisKeyFrame = this->skelAnime.curFrame; thisKeyFrame = this->skelAnime.curFrame;
SkelAnime_Update(&this->skelAnime); SkelAnime_Update(&this->skelAnime);
@ -286,52 +299,52 @@ void EnSkb_Advance(EnSkb* this, PlayState* play) {
} }
} }
if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) > 800.0f || IS_DAY) { if (Math_Vec3f_DistXZ(&this->actor.home.pos, &player->actor.world.pos) > 800.0f || IS_DAY) {
func_80AFCF48(this); EnSkb_SetupDespawn(this);
} else if (Actor_IsFacingPlayer(&this->actor, 0x11C7) && } else if (Actor_IsFacingPlayer(&this->actor, 0x11C7) &&
(this->actor.xzDistToPlayer < (60.0f + (this->actor.params * 6.0f)))) { (this->actor.xzDistToPlayer < (60.0f + (this->actor.params * 6.0f)))) {
func_80AFD33C(this); EnSkb_SetupAttack(this);
} }
} }
void func_80AFD33C(EnSkb* this) { void EnSkb_SetupAttack(EnSkb* this) {
Animation_Change(&this->skelAnime, &gStalchildAttackingAnim, 0.6f, 0.0f, Animation_Change(&this->skelAnime, &gStalchildAttackingAnim, 0.6f, 0.0f,
Animation_GetLastFrame(&gStalchildAttackingAnim), ANIMMODE_ONCE_INTERP, 4.0f); Animation_GetLastFrame(&gStalchildAttackingAnim), ANIMMODE_ONCE_INTERP, 4.0f);
this->collider.base.atFlags &= ~AT_BOUNCED; this->collider.base.atFlags &= ~AT_BOUNCED;
this->unk_280 = 3; this->actionState = SKB_BEHAVIOR_ATTACKING;
this->actor.speedXZ = 0.0f; this->actor.speedXZ = 0.0f;
EnSkb_SetupAction(this, EnSkb_SetupAttack); EnSkb_SetupAction(this, EnSkb_Attack);
} }
void EnSkb_SetupAttack(EnSkb* this, PlayState* play) { void EnSkb_Attack(EnSkb* this, PlayState* play) {
s32 frameData; s32 frameData;
frameData = this->skelAnime.curFrame; frameData = this->skelAnime.curFrame;
if (frameData == 3) { if (frameData == 3) {
Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK); Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_ATTACK);
this->unk_281 = 1; this->setColliderAT = true;
} else if (frameData == 6) { } else if (frameData == 6) {
this->unk_281 = 0; this->setColliderAT = false;
} }
if (this->collider.base.atFlags & AT_BOUNCED) { if (this->collider.base.atFlags & AT_BOUNCED) {
this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED); this->collider.base.atFlags &= ~(AT_HIT | AT_BOUNCED);
func_80AFD47C(this); EnSkb_SetupRecoil(this);
} else if (SkelAnime_Update(&this->skelAnime) != 0) { } else if (SkelAnime_Update(&this->skelAnime) != 0) {
func_80AFCD60(this); EnSkb_DecideNextAction(this);
} }
} }
void func_80AFD47C(EnSkb* this) { void EnSkb_SetupRecoil(EnSkb* this) {
Animation_Change(&this->skelAnime, &gStalchildAttackingAnim, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f, Animation_Change(&this->skelAnime, &gStalchildAttackingAnim, -0.4f, this->skelAnime.curFrame - 1.0f, 0.0f,
ANIMMODE_ONCE_INTERP, 0.0f); ANIMMODE_ONCE_INTERP, 0.0f);
this->collider.base.atFlags &= ~AT_BOUNCED; this->collider.base.atFlags &= ~AT_BOUNCED;
this->unk_280 = 5; this->actionState = SKB_BEHAVIOR_RECOILING;
this->unk_281 = 0; this->setColliderAT = false;
EnSkb_SetupAction(this, func_80AFD508); EnSkb_SetupAction(this, EnSkb_Recoil);
} }
void func_80AFD508(EnSkb* this, PlayState* play) { void EnSkb_Recoil(EnSkb* this, PlayState* play) {
if (SkelAnime_Update(&this->skelAnime) != 0) { if (SkelAnime_Update(&this->skelAnime) != 0) {
func_80AFCD60(this); EnSkb_DecideNextAction(this);
} }
} }
@ -340,12 +353,12 @@ void EnSkb_SetupStunned(EnSkb* this) {
this->actor.speedXZ = 0.0f; this->actor.speedXZ = 0.0f;
} }
Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE); Audio_PlayActorSound2(&this->actor, NA_SE_EN_GOMA_JR_FREEZE);
this->unk_281 = 0; this->setColliderAT = false;
this->unk_280 = 6; this->actionState = SKB_BEHAVIOR_STUNNED;
EnSkb_SetupAction(this, func_80AFD59C); EnSkb_SetupAction(this, EnSkb_Stunned);
} }
void func_80AFD59C(EnSkb* this, PlayState* play) { void EnSkb_Stunned(EnSkb* this, PlayState* play) {
if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) {
this->actor.speedXZ = 0.0f; this->actor.speedXZ = 0.0f;
} }
@ -356,32 +369,32 @@ void func_80AFD59C(EnSkb* this, PlayState* play) {
} }
if ((this->actor.colorFilterTimer == 0) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { if ((this->actor.colorFilterTimer == 0) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) {
if (this->actor.colChkInfo.health == 0) { if (this->actor.colChkInfo.health == 0) {
func_80AFD7B4(this, play); EnSkb_SetupDeath(this, play);
} else { } else {
func_80AFCD60(this); EnSkb_DecideNextAction(this);
} }
} }
} }
void func_80AFD644(EnSkb* this) { void EnSkb_SetupTakeDamage(EnSkb* this) {
Animation_MorphToPlayOnce(&this->skelAnime, &gStalchildDamagedAnim, -4.0f); Animation_MorphToPlayOnce(&this->skelAnime, &gStalchildDamagedAnim, -4.0f);
if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) {
this->actor.speedXZ = -4.0f; this->actor.speedXZ = -4.0f;
} }
this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer;
Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE); Audio_PlayActorSound2(&this->actor, NA_SE_EN_STALKID_DAMAGE);
this->unk_280 = 2; this->actionState = SKB_BEHAVIOR_DAMAGED;
EnSkb_SetupAction(this, func_80AFD6CC); EnSkb_SetupAction(this, EnSkb_TakeDamage);
} }
void func_80AFD6CC(EnSkb* this, PlayState* play) { void EnSkb_TakeDamage(EnSkb* this, PlayState* play) {
// this cast is likely not real, but allows for a match // this cast is likely not real, but allows for a match
u8* new_var; u8* new_var;
new_var = &this->unk_283; new_var = &this->breakFlags;
if ((this->unk_283 != 1) || BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, play, 1)) { if ((this->breakFlags != 1) || BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, play, 1)) {
if ((*new_var) != 0) { if ((*new_var) != 0) {
this->unk_283 = (*new_var) | 2; this->breakFlags = (*new_var) | 2;
} }
if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) {
this->actor.speedXZ = 0; this->actor.speedXZ = 0;
@ -394,27 +407,27 @@ void func_80AFD6CC(EnSkb* this, PlayState* play) {
Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0x1194, 0); Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 1, 0x1194, 0);
if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { if (SkelAnime_Update(&this->skelAnime) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) {
func_80AFCD60(this); EnSkb_DecideNextAction(this);
} }
} }
} }
void func_80AFD7B4(EnSkb* this, PlayState* play) { void EnSkb_SetupDeath(EnSkb* this, PlayState* play) {
Animation_MorphToPlayOnce(&this->skelAnime, &gStalchildDyingAnim, -4.0f); Animation_MorphToPlayOnce(&this->skelAnime, &gStalchildDyingAnim, -4.0f);
this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.shape.rot.y = this->actor.yawTowardsPlayer;
this->actor.world.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer;
if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) {
this->actor.speedXZ = -6.0f; this->actor.speedXZ = -6.0f;
} }
this->unk_280 = 1; this->actionState = SKB_BEHAVIOR_DYING;
this->actor.flags &= ~ACTOR_FLAG_0; this->actor.flags &= ~ACTOR_FLAG_0;
BodyBreak_Alloc(&this->bodyBreak, 18, play); BodyBreak_Alloc(&this->bodyBreak, 18, play);
this->unk_283 |= 4; this->breakFlags |= 4;
EffectSsDeadSound_SpawnStationary(play, &this->actor.projectedPos, NA_SE_EN_STALKID_DEAD, 1, 1, 0x28); EffectSsDeadSound_SpawnStationary(play, &this->actor.projectedPos, NA_SE_EN_STALKID_DEAD, 1, 1, 0x28);
EnSkb_SetupAction(this, func_80AFD880); EnSkb_SetupAction(this, EnSkb_Death);
} }
void func_80AFD880(EnSkb* this, PlayState* play) { void EnSkb_Death(EnSkb* this, PlayState* play) {
if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, play, 1)) { if (BodyBreak_SpawnParts(&this->actor, &this->bodyBreak, play, 1)) {
if (this->actor.scale.x == 0.01f) { if (this->actor.scale.x == 0.01f) {
Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x10); Item_DropCollectibleRandom(play, &this->actor, &this->actor.world.pos, 0x10);
@ -426,39 +439,40 @@ void func_80AFD880(EnSkb* this, PlayState* play) {
Item_DropCollectible(play, &this->actor.world.pos, ITEM00_RUPEE_RED); Item_DropCollectible(play, &this->actor.world.pos, ITEM00_RUPEE_RED);
} }
this->unk_283 |= 8; this->breakFlags |= 8;
Actor_Kill(&this->actor); Actor_Kill(&this->actor);
} }
} }
void func_80AFD968(EnSkb* this, PlayState* play) { void EnSkb_CheckDamage(EnSkb* this, PlayState* play) {
s16 pad; s16 pad;
s32 i; s32 i;
Vec3f flamePos; Vec3f flamePos;
s16 scale; s16 scale;
s16 phi_v1; s16 colorFilterDuration;
Player* player; Player* player;
if ((this->unk_280 != 1) && (this->actor.bgCheckFlags & (BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH)) && if ((this->actionState != SKB_BEHAVIOR_DYING) &&
(this->actor.bgCheckFlags & (BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH)) &&
(this->actor.yDistToWater >= 40.0f)) { (this->actor.yDistToWater >= 40.0f)) {
this->actor.colChkInfo.health = 0; this->actor.colChkInfo.health = 0;
this->unk_281 = 0; this->setColliderAT = false;
func_80AFD7B4(this, play); EnSkb_SetupDeath(this, play);
} else if (this->unk_280 >= 3) { } else if (this->actionState >= SKB_BEHAVIOR_ATTACKING) {
if (this->collider.base.acFlags & AC_HIT) { if (this->collider.base.acFlags & AC_HIT) {
this->collider.base.acFlags &= ~AC_HIT; this->collider.base.acFlags &= ~AC_HIT;
if (this->actor.colChkInfo.damageEffect != 6) { if (this->actor.colChkInfo.damageEffect != 6) {
this->unk_282 = this->actor.colChkInfo.damageEffect; this->lastDamageEffect = this->actor.colChkInfo.damageEffect;
Actor_SetDropFlag(&this->actor, &this->collider.elements[1].info, true); Actor_SetDropFlag(&this->actor, &this->collider.elements[1].info, true);
this->unk_281 = 0; this->setColliderAT = false;
if (this->actor.colChkInfo.damageEffect == 1) { if (this->actor.colChkInfo.damageEffect == 1) {
if (this->unk_280 != 6) { if (this->actionState != SKB_BEHAVIOR_STUNNED) {
Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 0x50); Actor_SetColorFilter(&this->actor, 0, 0x78, 0, 0x50);
Actor_ApplyDamage(&this->actor); Actor_ApplyDamage(&this->actor);
EnSkb_SetupStunned(this); EnSkb_SetupStunned(this);
} }
} else { } else {
phi_v1 = 8; colorFilterDuration = 8;
if (this->actor.colChkInfo.damageEffect == 7) { if (this->actor.colChkInfo.damageEffect == 7) {
scale = this->actor.scale.y * 7500.0f; scale = this->actor.scale.y * 7500.0f;
for (i = 4; i >= 0; i--) { for (i = 4; i >= 0; i--) {
@ -468,15 +482,15 @@ void func_80AFD968(EnSkb* this, PlayState* play) {
flamePos.y += (Rand_ZeroOne() * 25.0f); flamePos.y += (Rand_ZeroOne() * 25.0f);
EffectSsEnFire_SpawnVec3f(play, &this->actor, &flamePos, scale, 0, 0, -1); EffectSsEnFire_SpawnVec3f(play, &this->actor, &flamePos, scale, 0, 0, -1);
} }
phi_v1 = 25; colorFilterDuration = 25;
} }
Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, phi_v1); Actor_SetColorFilter(&this->actor, 0x4000, 0xFF, 0, colorFilterDuration);
if (!Actor_ApplyDamage(&this->actor)) { if (!Actor_ApplyDamage(&this->actor)) {
func_80AFD7B4(this, play); EnSkb_SetupDeath(this, play);
return; return;
} }
player = GET_PLAYER(play); player = GET_PLAYER(play);
if (this->unk_283 == 0) { if (this->breakFlags == 0) {
if ((this->actor.colChkInfo.damageEffect == 0xD) || if ((this->actor.colChkInfo.damageEffect == 0xD) ||
((this->actor.colChkInfo.damageEffect == 0xE) && ((this->actor.colChkInfo.damageEffect == 0xE) &&
((player->meleeWeaponAnimation >= PLAYER_MWA_RIGHT_SLASH_1H && ((player->meleeWeaponAnimation >= PLAYER_MWA_RIGHT_SLASH_1H &&
@ -484,10 +498,10 @@ void func_80AFD968(EnSkb* this, PlayState* play) {
(player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_RIGHT || (player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_RIGHT ||
player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_LEFT)))) { player->meleeWeaponAnimation == PLAYER_MWA_BACKSLASH_LEFT)))) {
BodyBreak_Alloc(&this->bodyBreak, 2, play); BodyBreak_Alloc(&this->bodyBreak, 2, play);
this->unk_283 = 1; this->breakFlags = 1; // setup for head bodybreak
} }
} }
func_80AFD644(this); EnSkb_SetupTakeDamage(this);
} }
} }
} }
@ -498,7 +512,7 @@ void EnSkb_Update(Actor* thisx, PlayState* play) {
EnSkb* this = (EnSkb*)thisx; EnSkb* this = (EnSkb*)thisx;
s32 pad; s32 pad;
func_80AFD968(this, play); EnSkb_CheckDamage(this, play);
Actor_MoveForward(&this->actor); Actor_MoveForward(&this->actor);
Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 60.0f, Actor_UpdateBgCheckInfo(play, &this->actor, 15.0f, 30.0f, 60.0f,
UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 |
@ -506,11 +520,11 @@ void EnSkb_Update(Actor* thisx, PlayState* play) {
this->actionFunc(this, play); this->actionFunc(this, play);
this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos = this->actor.world.pos;
this->actor.focus.pos.y += (3000.0f * this->actor.scale.y); this->actor.focus.pos.y += (3000.0f * this->actor.scale.y);
if (this->unk_281 != 0) { if (this->setColliderAT) {
CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAT(play, &play->colChkCtx, &this->collider.base);
} }
if (this->unk_280 >= 3) { if (this->actionState >= SKB_BEHAVIOR_ATTACKING) {
if ((this->actor.colorFilterTimer == 0) || ((this->actor.colorFilterParams & 0x4000) == 0)) { if ((this->actor.colorFilterTimer == 0) || ((this->actor.colorFilterParams & 0x4000) == 0)) {
CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base);
@ -525,7 +539,7 @@ s32 EnSkb_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p
s16 pad[2]; s16 pad[2];
if (limbIndex == 11) { if (limbIndex == 11) {
if ((this->unk_283 & 2) == 0) { if ((this->breakFlags & 2) == 0) { // head limb, head is still attached
OPEN_DISPS(play->state.gfxCtx, "../z_en_skb.c", 972); OPEN_DISPS(play->state.gfxCtx, "../z_en_skb.c", 972);
color = ABS((s16)(Math_SinS(play->gameplayFrames * 0x1770) * 95.0f)) + 160; color = ABS((s16)(Math_SinS(play->gameplayFrames * 0x1770) * 95.0f)) + 160;
gDPPipeSync(POLY_OPA_DISP++); gDPPipeSync(POLY_OPA_DISP++);
@ -534,7 +548,7 @@ s32 EnSkb_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p
} else { } else {
*dList = NULL; *dList = NULL;
} }
} else if ((limbIndex == 12) && ((this->unk_283 & 2) != 0)) { } else if ((limbIndex == 12) && ((this->breakFlags & 2) != 0)) { // jaw limb, don't draw if headless
*dList = NULL; *dList = NULL;
} }
return 0; return 0;
@ -545,9 +559,9 @@ void EnSkb_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot,
Collider_UpdateSpheres(limbIndex, &this->collider); Collider_UpdateSpheres(limbIndex, &this->collider);
if ((this->unk_283 ^ 1) == 0) { if ((this->breakFlags ^ 1) == 0) {
BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 11, 12, 18, dList, BODYBREAK_OBJECT_DEFAULT); BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 11, 12, 18, dList, BODYBREAK_OBJECT_DEFAULT);
} else if ((this->unk_283 ^ (this->unk_283 | 4)) == 0) { } else if ((this->breakFlags ^ (this->breakFlags | 4)) == 0) {
BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 18, 18, dList, BODYBREAK_OBJECT_DEFAULT); BodyBreak_SetInfo(&this->bodyBreak, limbIndex, 0, 18, 18, dList, BODYBREAK_OBJECT_DEFAULT);
} }
} }

View file

@ -13,12 +13,12 @@ typedef struct EnSkb {
/* 0x014C */ SkelAnime skelAnime; /* 0x014C */ SkelAnime skelAnime;
/* 0x0190 */ Vec3s jointTable[20]; /* 0x0190 */ Vec3s jointTable[20];
/* 0x0208 */ Vec3s morphTable[20]; /* 0x0208 */ Vec3s morphTable[20];
/* 0x0280 */ u8 unk_280; /* 0x0280 */ u8 actionState;
/* 0x0281 */ u8 unk_281; /* 0x0281 */ u8 setColliderAT;
/* 0x0282 */ u8 unk_282; /* 0x0282 */ u8 lastDamageEffect;
/* 0x0283 */ u8 unk_283; /* 0x0283 */ u8 breakFlags;
/* 0x0284 */ EnSkbActionFunc actionFunc; /* 0x0284 */ EnSkbActionFunc actionFunc;
/* 0x0288 */ s16 unk_288; /* 0x0288 */ s16 headlessYawOffset;
/* 0x028C */ BodyBreak bodyBreak; /* 0x028C */ BodyBreak bodyBreak;
/* 0x02A4 */ ColliderJntSph collider; /* 0x02A4 */ ColliderJntSph collider;
/* 0x02C4 */ ColliderJntSphElement colliderItem[2]; /* 0x02C4 */ ColliderJntSphElement colliderItem[2];