1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-07 06:40:15 +00:00

ovl_Item_Ocarina OK (#299)

* first commit

* fixes

* remove unwanted file

Co-authored-by: fig02 <fig02srl@gmail.com>
This commit is contained in:
Half-asian 2020-08-29 06:35:35 +12:00 committed by GitHub
parent 04a0d7c132
commit b687ef1143
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 178 additions and 566 deletions

View file

@ -15,7 +15,14 @@ void ItemOcarina_Destroy(Actor* thisx, GlobalContext* globalCtx);
void ItemOcarina_Update(Actor* thisx, GlobalContext* globalCtx);
void ItemOcarina_Draw(Actor* thisx, GlobalContext* globalCtx);
/*
void ItemOcarina_GetThrown(ItemOcarina* this, GlobalContext* globalCtx);
void ItemOcarina_Fly(ItemOcarina* this, GlobalContext* globalCtx);
void ItemOcarina_WaitInWater(ItemOcarina* this, GlobalContext* globalCtx);
void ItemOcarina_StartSoTCutscene(ItemOcarina* this, GlobalContext* globalCtx);
void func_80B864EC(ItemOcarina* this, GlobalContext* globalCtx);
void func_80B865E0(ItemOcarina* this, GlobalContext* globalCtx);
void ItemOcarina_DoNothing(ItemOcarina* this, GlobalContext* globalCtx);
const ActorInit Item_Ocarina_InitVars = {
ACTOR_ITEM_OCARINA,
ACTORTYPE_ITEMACTION,
@ -27,27 +34,173 @@ const ActorInit Item_Ocarina_InitVars = {
(ActorFunc)ItemOcarina_Update,
(ActorFunc)ItemOcarina_Draw,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Ocarina/func_80B86130.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Ocarina/ItemOcarina_Init.s")
extern CutsceneData D_0200F870[]; // song of time cutscene
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Ocarina/ItemOcarina_Destroy.s")
void ItemOcarina_SetupAction(ItemOcarina* this, ItemOcarinaActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Ocarina/func_80B862EC.s")
void ItemOcarina_Init(Actor* thisx, GlobalContext* globalCtx) {
ItemOcarina* this = THIS;
s32 params = thisx->params;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Ocarina/func_80B86494.s")
ActorShape_Init(&this->actor.shape, 0, 0, 0);
Actor_SetScale(&this->actor, 0.1f);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Ocarina/func_80B864EC.s")
switch (params) {
case 0:
ItemOcarina_SetupAction(this, ItemOcarina_GetThrown);
break;
case 1:
ItemOcarina_SetupAction(this, func_80B865E0);
break;
case 2:
ItemOcarina_SetupAction(this, ItemOcarina_DoNothing);
break;
case 3:
ItemOcarina_SetupAction(this, ItemOcarina_WaitInWater);
if (!(gSaveContext.eventChkInf[8] & 1) || (gSaveContext.eventChkInf[4] & 8)) {
Actor_Kill(thisx);
return;
}
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_ELF_MSG2, 299.0f, -140.0f, 884.0f, 0, 4, 1, 0x3800);
Actor_SetScale(thisx, 0.2f);
break;
default:
Actor_Kill(thisx);
return;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Ocarina/func_80B865E0.s")
LOG_NUM("no", params, "../z_item_ocarina.c", 210);
this->spinRotOffset = 0x400;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Ocarina/func_80B86640.s")
void ItemOcarina_Destroy(Actor* thisx, GlobalContext* globalCtx) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Ocarina/func_80B8664C.s")
void ItemOcarina_Fly(ItemOcarina* this, GlobalContext* globalCtx) {
Vec3f ripplePos;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Ocarina/func_80B866BC.s")
func_8002D7EC(&this->actor);
this->actor.shape.rot.x += this->spinRotOffset * 2;
this->actor.shape.rot.y += this->spinRotOffset * 3;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Ocarina/ItemOcarina_Update.s")
if (this->actor.minVelocityY < this->actor.velocity.y) {
this->actor.velocity.y += this->actor.gravity;
if (this->actor.velocity.y < this->actor.minVelocityY) {
this->actor.velocity.y = this->actor.minVelocityY;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Item_Ocarina/ItemOcarina_Draw.s")
if (globalCtx->csCtx.frames == 881) {
this->actor.posRot.pos.x = 250.0f;
this->actor.posRot.pos.y = 60.0f;
this->actor.posRot.pos.z = 1075.0f;
this->actor.velocity.x = 1.0f;
this->actor.velocity.y = -5.0f;
this->actor.velocity.z = -7.0f;
}
if (globalCtx->csCtx.frames == 897) {
func_80029444(globalCtx, &this->actor.posRot.pos, 100, 500, 0);
func_8002949C(globalCtx, &this->actor.posRot.pos, 0, 0, 1, 0);
this->actor.velocity.x = 0.0f;
this->actor.velocity.y = 0.0f;
this->actor.velocity.z = 0.0f;
this->actor.gravity = -0.1f;
this->actor.minVelocityY = -0.5f;
this->spinRotOffset = 0;
Audio_PlayActorSound2(&this->actor, NA_SE_EV_BOMB_DROP_WATER);
}
// landed in water
if (globalCtx->csCtx.frames == 906) {
ripplePos.x = 274.0f;
ripplePos.y = -60.0f;
ripplePos.z = 907.0f;
func_80029444(globalCtx, &ripplePos, 100, 500, 0);
}
}
void ItemOcarina_GetThrown(ItemOcarina* this, GlobalContext* globalCtx) {
this->actor.gravity = -0.3f;
this->actor.minVelocityY = -5.0f;
this->actor.velocity.x = 0.0f;
this->actor.velocity.y = 6.0f;
this->actor.velocity.z = 0.0f;
ItemOcarina_SetupAction(this, ItemOcarina_Fly);
}
void func_80B864EC(ItemOcarina* this, GlobalContext* globalCtx) {
func_8002D7EC(&this->actor);
this->actor.shape.rot.x += this->spinRotOffset * 2;
this->actor.shape.rot.y += this->spinRotOffset * 3;
if (this->actor.minVelocityY < this->actor.velocity.y) {
this->actor.velocity.y += this->actor.gravity;
if (this->actor.velocity.y < this->actor.minVelocityY) {
this->actor.velocity.y = this->actor.minVelocityY;
}
}
if (globalCtx->csCtx.frames == 220) {
this->actor.posRot.pos.x = 144.0f;
this->actor.posRot.pos.y = 80.0f;
this->actor.posRot.pos.z = 1686.0f;
this->actor.velocity.x = 1.0f;
this->actor.velocity.y = 2.0f;
this->actor.velocity.z = -7.0f;
this->actor.gravity = -0.15f;
this->actor.minVelocityY = -5.0f;
}
}
void func_80B865E0(ItemOcarina* this, GlobalContext* globalCtx) {
this->actor.gravity = -0.3f;
this->actor.minVelocityY = -5.0f;
this->actor.velocity.x = 0.0f;
this->actor.velocity.y = 4.0f;
this->actor.velocity.z = 6.0f;
ItemOcarina_SetupAction(this, func_80B864EC);
}
void ItemOcarina_DoNothing(ItemOcarina* this, GlobalContext* globalCtx) {
}
void ItemOcarina_StartSoTCutscene(ItemOcarina* this, GlobalContext* globalCtx) {
if (func_8002F334(&this->actor, globalCtx)) {
globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(D_0200F870);
gSaveContext.cutsceneTrigger = 1;
}
}
void ItemOcarina_WaitInWater(ItemOcarina* this, GlobalContext* globalCtx) {
if (func_8002F410(&this->actor, globalCtx)) {
gSaveContext.eventChkInf[4] |= 8;
Flags_SetSwitch(globalCtx, 3);
this->actionFunc = ItemOcarina_StartSoTCutscene;
this->actor.draw = NULL;
} else {
func_8002F434(&this->actor, globalCtx, GI_OCARINA_OOT, 30.0f, 50.0f);
if ((globalCtx->gameplayFrames & 13) == 0) {
func_800293E4(globalCtx, &this->actor.posRot.pos, 0.0f, 0.0f, 10.0f, 0.13f);
}
}
}
void ItemOcarina_Update(Actor* thisx, GlobalContext* globalCtx) {
ItemOcarina* this = THIS;
this->actionFunc(this, globalCtx);
}
void ItemOcarina_Draw(Actor* thisx, GlobalContext* globalCtx) {
ItemOcarina* this = THIS;
func_8002EBCC(thisx, globalCtx, 0);
func_8002ED80(thisx, globalCtx, 0);
func_800694A0(globalCtx, 0x2E);
}

View file

@ -6,9 +6,12 @@
struct ItemOcarina;
typedef void (*ItemOcarinaActionFunc)(struct ItemOcarina*, GlobalContext*);
typedef struct ItemOcarina {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0x8];
/* 0x014C */ ItemOcarinaActionFunc actionFunc;
/* 0x0150 */ s16 spinRotOffset;
} ItemOcarina; // size = 0x0154
extern const ActorInit Item_Ocarina_InitVars;