diff options
| author | Lucas Shaw <49287729+shawlucas@users.noreply.github.com> | 2020-05-10 16:19:27 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-10 19:19:27 -0400 |
| commit | 7d7c85128960eeaa804ea73782cfae70d829e596 (patch) | |
| tree | c730f0684b18f1651b50f1f14e4d976045260cf0 /src | |
| parent | 3e5ed389b926ec751f7c782b8059b6cea98fa2e8 (diff) | |
ovl_En_Heishi3 OK (#121)
* almost done with heishi3
* heishi3 ok
* Added function names to heishi3
* EnHeishi3 OK
* Made some suggested changes. Still have questions about others
* Made suggsted changes
* fixed formatting
* fixed formatting
Diffstat (limited to 'src')
| -rw-r--r-- | src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.c | 229 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.h | 19 |
2 files changed, 224 insertions, 24 deletions
diff --git a/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.c b/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.c index 042e95216..17381fdc6 100644 --- a/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.c +++ b/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.c @@ -5,6 +5,7 @@ */ #include "z_en_heishi3.h" +#include <vt.h> #define FLAGS 0x00000000 @@ -15,7 +16,20 @@ void EnHeishi3_Destroy(Actor* thisx, GlobalContext* globalCtx); void EnHeishi3_Update(Actor* thisx, GlobalContext* globalCtx); void EnHeishi3_Draw(Actor* thisx, GlobalContext* globalCtx); -/* +void EnHeishi3_SetupGuardType(EnHeishi3* this, GlobalContext* globalCtx); +void EnHeishi3_StandSentinelInGrounds(EnHeishi3* this, GlobalContext* globalCtx); +void EnHeishi3_StandSentinelInCastle(EnHeishi3* this, GlobalContext* globalCtx); +void EnHeishi3_CatchStart(EnHeishi3* this, GlobalContext* globalCtx); +void EnHeishi3_ResetAnimationToIdle(EnHeishi3* this, GlobalContext* globalCtx); +void func_80A55D00(EnHeishi3* this, GlobalContext* globalCtx); +void func_80A55BD4(EnHeishi3* this, GlobalContext* globalCtx); + +extern SkeletonHeader D_0600BAC8; +extern AnimationHeader D_06005C30; // EnHeishi3_IdleAnimation +extern AnimationHeader D_06005880; // EnHeishi3_WalkAnimation + +static s16 sPlayerCaught = 0; + const ActorInit En_Heishi3_InitVars = { ACTOR_EN_HEISHI3, ACTORTYPE_NPC, @@ -27,27 +41,196 @@ const ActorInit En_Heishi3_InitVars = { (ActorFunc)EnHeishi3_Update, (ActorFunc)EnHeishi3_Draw, }; -*/ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Heishi3/EnHeishi3_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Heishi3/EnHeishi3_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Heishi3/func_80A557A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Heishi3/func_80A55850.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Heishi3/func_80A559B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Heishi3/func_80A55B2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Heishi3/func_80A55BD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Heishi3/func_80A55C6C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Heishi3/func_80A55D00.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Heishi3/EnHeishi3_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Heishi3/func_80A55E88.s") +static ColliderCylinderInit cylinderInit = { + { COLTYPE_UNK10, 0x00, 0x00, 0x39, 0x20, COLSHAPE_CYLINDER }, + { 0x00, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, 0x00, 0x00, 0x01 }, + { 15, 70, 0, { 0, 0, 0 } }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Heishi3/EnHeishi3_Draw.s") +void EnHeishi3_Init(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi3* this = THIS; + + sPlayerCaught = 0; + if (this->actor.params <= 0) { + this->unk_278 = 0; + } else { + this->unk_278 = 1; + if (this->actor.posRot.pos.x < -290.0f) { + this->unk_278 = 2; + } + } + Actor_SetScale(&this->actor, 0.01f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFunc_Circle, 30.0f); + SkelAnime_Init(globalCtx, &this->skelAnime, &D_0600BAC8, &D_06005C30, this->limbDrawTable, + this->transitionDrawTable, 17); + this->actor.colChkInfo.mass = -1; + this->actor.unk_1F = 6; + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &cylinderInit); + // "Castle Gate Soldier - Power Up" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 城門兵パワーアップ ☆☆☆☆☆ \n" VT_RST); + + this->actor.gravity = -3.0f; + this->actor.posRot2.pos = this->actor.posRot.pos; + this->actionFunc = EnHeishi3_SetupGuardType; +} + +void EnHeishi3_Destroy(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi3* this = THIS; + Collider_DestroyCylinder(globalCtx, &this->collider); +} + +void EnHeishi3_SetupGuardType(EnHeishi3* this, GlobalContext* globalCtx) { + f32 frames = SkelAnime_GetFrameCount(&D_06005C30.genericHeader); + SkelAnime_ChangeAnim(&this->skelAnime, &D_06005C30, 1.0f, 0.0f, (s16)(f32)frames, 0, -10.0f); + if (this->unk_278 == 0) { + this->actionFunc = EnHeishi3_StandSentinelInGrounds; + } else { + this->actionFunc = EnHeishi3_StandSentinelInCastle; + } +} + +/** + * Handles the guards standing on Hyrule Castle Grounds. + **/ +void EnHeishi3_StandSentinelInGrounds(EnHeishi3* this, GlobalContext* globalCtx) { + Player* player; + s16 yawDiff; + s16 yawDiffNew; + f32 sightRange; + + player = PLAYER; + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + yawDiff = this->actor.rotTowardsLinkY - this->actor.shape.rot.y; + yawDiffNew = ABS(yawDiff); + if (yawDiffNew < 0x4300) { + if (gSaveContext.nightFlag == 0) { + sightRange = 250.0f; + } else { + sightRange = 200.0f; + } + } else { + if (gSaveContext.nightFlag == 0) { + sightRange = 150.0f; + } else { + sightRange = 100.0f; + } + } + if ((this->actor.xzDistanceFromLink < sightRange) && + (fabsf(player->actor.posRot.pos.y - this->actor.posRot.pos.y) < 100.0f) && (sPlayerCaught == 0)) { + sPlayerCaught = 1; + func_8010B680(globalCtx, 0x702D, &this->actor); // "Hey you! Stop! You, kid, over there!" + func_80078884(NA_SE_SY_FOUND); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発見! ☆☆☆☆☆ \n" VT_RST); // "Discovered!" + func_8002DF54(globalCtx, &this->actor, 1); + this->actionFunc = EnHeishi3_CatchStart; + } +} + +/** + * Handles the guards standing in front of Hyrule Castle. + **/ +void EnHeishi3_StandSentinelInCastle(EnHeishi3* this, GlobalContext* globalCtx) { + Player* player = PLAYER; + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if ((player->actor.posRot.pos.x < -190.0f) && (player->actor.posRot.pos.x > -380.0f) && + (fabsf(player->actor.posRot.pos.y - this->actor.posRot.pos.y) < 100.0f) && + (player->actor.posRot.pos.z < 1020.0f) && (player->actor.posRot.pos.z > 700.0f) && (sPlayerCaught == 0)) { + if (this->unk_278 == 1) { + if ((player->actor.posRot.pos.x < -290.0f)) { + return; + } + } else { + if (player->actor.posRot.pos.x > -290.0f) { + return; + } + } + sPlayerCaught = 1; + func_8010B680(globalCtx, 0x702D, &this->actor); // "Hey you! Stop! You, kid, over there!" + func_80078884(NA_SE_SY_FOUND); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 発見! ☆☆☆☆☆ \n" VT_RST); // "Discovered!" + func_8002DF54(globalCtx, &this->actor, 1); + this->actionFunc = EnHeishi3_CatchStart; + } +} + +void EnHeishi3_CatchStart(EnHeishi3* this, GlobalContext* globalCtx) { + f32 frames = SkelAnime_GetFrameCount(&D_06005880.genericHeader); + SkelAnime_ChangeAnim(&this->skelAnime, &D_06005880, 1.0f, 0.0f, (s16)(f32)frames, 0, -10.0f); + this->caughtTimer = 20; + this->actionFunc = func_80A55BD4; + this->actor.speedXZ = 2.5f; +} + +void func_80A55BD4(EnHeishi3* this, GlobalContext* globalCtx) { + + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if ((func_800A56C8(&this->skelAnime, 1.0f) != 0) || (func_800A56C8(&this->skelAnime, 17.0f) != 0)) { + Audio_PlayActorSound2(&this->actor, NA_SE_EV_KNIGHT_WALK); + } + if (this->caughtTimer == 0) { + this->actionFunc = EnHeishi3_ResetAnimationToIdle; + this->actor.speedXZ = 0.0f; + } else { + Math_SmoothScaleMaxMinS(&this->actor.posRot.rot.y, this->actor.rotTowardsLinkY, 5, 3000, 0); + } +} + +void EnHeishi3_ResetAnimationToIdle(EnHeishi3* this, GlobalContext* globalCtx) { + f32 frames = SkelAnime_GetFrameCount(&D_06005C30.genericHeader); + SkelAnime_ChangeAnim(&this->skelAnime, &D_06005C30, 1.0f, 0.0f, (s16)(f32)frames, 0, -10.0f); + this->actionFunc = func_80A55D00; +} + +// This function initiates the respawn after the player gets caught. +void func_80A55D00(EnHeishi3* this, GlobalContext* globalCtx) { + SkelAnime_FrameUpdateMatrix(&this->skelAnime); + if ((func_8010BDBC(&globalCtx->msgCtx) == 5) && (func_80106BC8(globalCtx) != 0) && (this->respawnFlag == 0)) { + gSaveContext.eventChkInf[4] |= 0x4000; + globalCtx->nextEntranceIndex = 0x47E; // Hyrule Castle from Guard Capture (outside) + globalCtx->sceneLoadFlag = 0x14; + this->respawnFlag = 1; + globalCtx->fadeTransition = 0x2E; + gSaveContext.nextTransition = 0x2E; + } +} + +void EnHeishi3_Update(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi3* this = THIS; + s32 pad; + Actor_SetHeight(&this->actor, 60.0f); + this->unk_274 += 1; + if (this->caughtTimer != 0) { + this->caughtTimer -= 1; + } + this->actionFunc(this, globalCtx); + this->actor.shape.rot = this->actor.posRot.rot; + Actor_MoveForward(&this->actor); + func_8002E4B4(globalCtx, &this->actor, 20.0f, 20.0f, 50.0f, 0x1C); + Collider_CylinderUpdate(&this->actor, &this->collider); + CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider); +} + +s32 EnHeishi3_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + Actor* thisx) { + EnHeishi3* this = THIS; + if (limbIndex == 9) { + rot->x += this->unk_26E; + } + + if (limbIndex == 16) { + rot->x += this->unk_262; + rot->z += this->unk_264; + } + + return 0; +} + +void EnHeishi3_Draw(Actor* thisx, GlobalContext* globalCtx) { + EnHeishi3* this = THIS; + func_80093D18(globalCtx->state.gfxCtx); + SkelAnime_Draw(globalCtx, this->skelAnime.skeleton, this->skelAnime.limbDrawTbl, EnHeishi3_OverrideLimbDraw, NULL, + &this->actor); +} diff --git a/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.h b/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.h index e584e98bd..4ae1a1cde 100644 --- a/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.h +++ b/src/overlays/actors/ovl_En_Heishi3/z_en_heishi3.h @@ -6,9 +6,26 @@ struct EnHeishi3; +typedef void (*EnHeishi3ActionFunc)(struct EnHeishi3*, GlobalContext*); + typedef struct EnHeishi3 { /* 0x0000 */ Actor actor; - /* 0x014C */ char unk_14C[0x17C]; + /* 0x014C */ SkelAnime skelAnime; + /* 0x0190 */ Vec3s limbDrawTable[17]; + /* 0x01F6 */ Vec3s transitionDrawTable[17]; + /* 0x025C */ EnHeishi3ActionFunc actionFunc; + /* 0x0260 */ char unk_260[0x2]; + /* 0x0262 */ s16 unk_262; + /* 0x0264 */ s16 unk_264; + /* 0x0266 */ char unk_266[0x8]; + /* 0x026E */ s16 unk_26E; // All these s16 are probably part of a Vec3s + /* 0x0270 */ char unk_270[0x2]; + /* 0x0272 */ s16 caughtTimer; + /* 0x0274 */ s16 unk_274; + /* 0x0276 */ u8 respawnFlag; // set to 1 when reloading area after being thrown out + /* 0x0278 */ s16 unk_278; + /* 0x027A */ char unk_27A[0x2]; + /* 0x027C */ ColliderCylinder collider; } EnHeishi3; // size = 0x02C8 extern const ActorInit En_Heishi3_InitVars; |
