1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-03 06:24:30 +00:00

EnDivingGame OK (#745)

* update

* EnDivingGame_Draw OK

* dont feel like working on this function today

* fixed build errors

* fixing some merge conflicts

Signed-off-by: Angie <angheloalf95@gmail.com>

* more conflict fixing

Signed-off-by: Angie <angheloalf95@gmail.com>

* all merge conflicts fixed

Signed-off-by: Angie <angheloalf95@gmail.com>

* EnDivingGame_Update OK

Signed-off-by: Angie <angheloalf95@gmail.com>

* remove DECR

Signed-off-by: Angie <angheloalf95@gmail.com>

* format and unused_asm

Signed-off-by: Angie <angheloalf95@gmail.com>

* change reloc in spec

Signed-off-by: Angie <angheloalf95@gmail.com>

* damn reloc

Signed-off-by: Angie <angheloalf95@gmail.com>

* Apply suggestions from code review

Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>

* use OPEN_DISPS macro

Signed-off-by: Angie <angheloalf95@gmail.com>

* batch of suggestions

Signed-off-by: Angie <angheloalf95@gmail.com>

* more suggestions

Signed-off-by: Angie <angheloalf95@gmail.com>

* more changes, but this isn't ready yet

Signed-off-by: Angie <angheloalf95@gmail.com>

* rename two timers

Signed-off-by: angie <angheloalf95@gmail.com>

* Update src/overlays/actors/ovl_En_Diving_Game/z_en_diving_game.c

Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>

* grabbedRuppiesCounter

Signed-off-by: angie <angheloalf95@gmail.com>

* a lot of vec

Signed-off-by: angie <angheloalf95@gmail.com>

* Apply suggestions from code review

Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
Co-authored-by: petrie911 <69443847+petrie911@users.noreply.github.com>

* fix some typos

Signed-off-by: angie <angheloalf95@gmail.com>

* allRupeesThrowed

Signed-off-by: angie <angheloalf95@gmail.com>

* rupeesLeftToThrow

Signed-off-by: Angie <angheloalf95@gmail.com>

* boolean changes and minor comments

Signed-off-by: Angie <angheloalf95@gmail.com>

* and more renaming

Signed-off-by: Angie <angheloalf95@gmail.com>

* renaiming and chained assign

Signed-off-by: Angie <angheloalf95@gmail.com>

* rename 3 functions

Signed-off-by: Angie <angheloalf95@gmail.com>

* final rename and add two enums

Signed-off-by: angie <angheloalf95@gmail.com>

* format

Signed-off-by: angie <angheloalf95@gmail.com>

* enum naming

Signed-off-by: angie <angheloalf95@gmail.com>

Co-authored-by: Lucas Shaw <lgs84@cornell.edu>
Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>
Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
Co-authored-by: petrie911 <69443847+petrie911@users.noreply.github.com>
This commit is contained in:
Anghelo Carvajal 2021-04-03 13:15:16 -03:00 committed by GitHub
parent c94e595dc1
commit 9834f5517e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 565 additions and 1851 deletions

View file

@ -1,4 +1,12 @@
/*
* File: z_en_diving_game.c
* Overlay: ovl_En_Diving_Game
* Description: Diving minigame
*/
#include "z_en_diving_game.h"
#include "vt.h"
#include "overlays/actors/ovl_En_Ex_Ruppy/z_en_ex_ruppy.h"
#define FLAGS 0x00000019
@ -9,11 +17,23 @@ void EnDivingGame_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnDivingGame_Update(Actor* thisx, GlobalContext* globalCtx);
void EnDivingGame_Draw(Actor* thisx, GlobalContext* globalCtx);
extern UNK_TYPE D_0600219C;
extern UNK_TYPE D_06002FE8;
extern UNK_TYPE D_0600BFA8;
void func_809EDCB0(EnDivingGame* this, GlobalContext* globalCtx);
void EnDivingGame_Talk(EnDivingGame* this, GlobalContext* globalCtx);
void EnDivingGame_HandlePlayChoice(EnDivingGame* this, GlobalContext* globalCtx);
void func_809EE048(EnDivingGame* this, GlobalContext* globalCtx);
void func_809EE0FC(EnDivingGame* this, GlobalContext* globalCtx);
void func_809EE194(EnDivingGame* this, GlobalContext* globalCtx);
void EnDivingGame_SetupRupeeThrow(EnDivingGame* this, GlobalContext* globalCtx);
void EnDivingGame_RupeeThrow(EnDivingGame* this, GlobalContext* globalCtx);
void EnDivingGame_SetupUnderwaterViewCs(EnDivingGame* this, GlobalContext* globalCtx);
void func_809EE780(EnDivingGame* this, GlobalContext* globalCtx);
void func_809EE800(EnDivingGame* this, GlobalContext* globalCtx);
void func_809EE8F0(EnDivingGame* this, GlobalContext* globalCtx);
void func_809EE96C(EnDivingGame* this, GlobalContext* globalCtx);
void func_809EEA00(EnDivingGame* this, GlobalContext* globalCtx);
void func_809EEA90(EnDivingGame* this, GlobalContext* globalCtx);
void func_809EEAF8(EnDivingGame* this, GlobalContext* globalCtx);
/*
const ActorInit En_Diving_Game_InitVars = {
ACTOR_EN_DIVING_GAME,
ACTORCAT_NPC,
@ -26,7 +46,10 @@ const ActorInit En_Diving_Game_InitVars = {
(ActorFunc)EnDivingGame_Draw,
};
static ColliderCylinderInit D_809EF0B4 = {
// used to ensure there's only one instance of this actor.
static u8 D_809EF0B0 = false;
static ColliderCylinderInit sCylinderInit = {
{
COLTYPE_NONE,
AT_NONE,
@ -39,57 +62,516 @@ static ColliderCylinderInit D_809EF0B4 = {
ELEMTYPE_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00000000, 0x00, 0x00 },
TOUCH_NONE,
TOUCH_NONE | TOUCH_SFX_NORMAL,
BUMP_NONE,
OCELEM_ON,
},
{ 10, 10, 0, { 0, 0, 0 } },
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/EnDivingGame_Init.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/EnDivingGame_Destroy.s")
static u64* sEyeTextures[] = {
0x06003E40,
0x06004640,
0x06004E40,
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809ED9E0.s")
extern FlexSkeletonHeader D_0600BFA8;
extern AnimationHeader D_06002FE8; // Stand/static.
extern AnimationHeader D_0600219C; // Throw rupees animation.
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EDB08.s")
void EnDivingGame_Init(Actor* thisx, GlobalContext* globalCtx) {
EnDivingGame* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EDCB0.s")
this->actor.gravity = -3.0f;
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 30.0f);
SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_0600BFA8, &D_06002FE8, this->jointTable, this->morphTable, 20);
Collider_InitCylinder(globalCtx, &this->collider);
Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 素もぐりGO ☆☆☆☆☆ \n" VT_RST);
this->actor.room = -1;
this->actor.scale.x = 0.01f;
this->actor.scale.y = 0.012999999f;
this->actor.scale.z = 0.0139999995f;
if (D_809EF0B0) {
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ もういてる原 ☆☆☆☆☆ \n" VT_RST);
this->unk_31F = 1;
Actor_Kill(&this->actor);
} else {
D_809EF0B0 = true;
this->actor.targetMode = 0;
this->actor.colChkInfo.mass = MASS_IMMOVABLE;
this->actionFunc = func_809EDCB0;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EDD4C.s")
void EnDivingGame_Destroy(Actor* thisx, GlobalContext* globalCtx) {
EnDivingGame* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EDEDC.s")
if (this->unk_31F == 0) {
gSaveContext.timer1State = 0;
}
Collider_DestroyCylinder(globalCtx, &this->collider);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EE048.s")
void EnDivingGame_SpawnRuppy(EnDivingGame* this, GlobalContext* globalCtx) {
EnExRuppy* rupee;
Vec3f rupeePos;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EE0FC.s")
rupeePos.x = (Rand_ZeroOne() - 0.5f) * 30.0f + this->actor.world.pos.x;
rupeePos.y = (Rand_ZeroOne() - 0.5f) * 20.0f + (this->actor.world.pos.y + 30.0f);
rupeePos.z = (Rand_ZeroOne() - 0.5f) * 20.0f + this->actor.world.pos.z;
rupee = (EnExRuppy*)Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_EX_RUPPY, rupeePos.x,
rupeePos.y, rupeePos.z, 0, (s16)Rand_CenteredFloat(3500.0f) - 1000,
this->rupeesLeftToThrow, 0);
if (rupee != NULL) {
rupee->actor.speedXZ = 12.0f;
rupee->actor.velocity.y = 6.0f;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EE194.s")
s32 EnDivingGame_HasMinigameFinished(EnDivingGame* this, GlobalContext* globalCtx) {
if (gSaveContext.timer1State == 10 && !Gameplay_InCsMode(globalCtx)) {
// Failed.
gSaveContext.timer1State = 0;
func_800F5B58();
func_80078884(NA_SE_SY_FOUND);
this->actor.textId = 0x71AD;
func_8010B680(globalCtx, this->actor.textId, NULL);
this->unk_292 = 5;
this->allRupeesThrown = this->state = this->phase = this->unk_2A2 = this->grabbedRupeesCounter = 0;
func_8002DF54(globalCtx, NULL, 8);
this->actionFunc = func_809EE048;
return true;
} else {
s32 rupeesNeeded = 5;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EE1F4.s")
if (gSaveContext.eventChkInf[3] & 0x100) {
rupeesNeeded = 10;
}
if (this->grabbedRupeesCounter >= rupeesNeeded) {
// Won.
gSaveContext.timer1State = 0;
this->allRupeesThrown = this->state = this->phase = this->unk_2A2 = this->grabbedRupeesCounter = 0;
if (!(gSaveContext.eventChkInf[3] & 0x100)) {
this->actor.textId = 0x4055;
} else {
this->actor.textId = 0x405D;
if (this->extraWinCount < 100) {
this->extraWinCount++;
}
}
func_8010B680(globalCtx, this->actor.textId, NULL);
this->unk_292 = 5;
func_800F5B58();
func_800F5C64(0x39);
func_8002DF54(globalCtx, NULL, 8);
if (!(gSaveContext.eventChkInf[3] & 0x100)) {
this->actionFunc = func_809EE96C;
} else {
this->actionFunc = func_809EE048;
}
return true;
}
}
return false;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EE408.s")
// EnDivingGame_FinishMinigame ? // Reset probably
void func_809EDCB0(EnDivingGame* this, GlobalContext* globalCtx) {
f32 frameCount = Animation_GetLastFrame(&D_06002FE8);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EE6C8.s")
Animation_Change(&this->skelAnime, &D_06002FE8, 1.0f, 0.0f, (s16)frameCount, 0, -10.0f);
this->notPlayingMinigame = true;
this->actionFunc = EnDivingGame_Talk;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EE780.s")
void EnDivingGame_Talk(EnDivingGame* this, GlobalContext* globalCtx) {
SkelAnime_Update(&this->skelAnime);
if (this->state != ENDIVINGGAME_STATE_PLAYING || !EnDivingGame_HasMinigameFinished(this, globalCtx)) {
if (func_8002F194(&this->actor, globalCtx)) {
if (this->unk_292 != 6) {
switch (this->state) {
case ENDIVINGGAME_STATE_NOTPLAYING:
func_8002DF54(globalCtx, NULL, 8);
this->actionFunc = EnDivingGame_HandlePlayChoice;
break;
case ENDIVINGGAME_STATE_AWARDPRIZE:
this->actionFunc = func_809EEA00;
break;
case ENDIVINGGAME_STATE_PLAYING:
this->actionFunc = func_809EE8F0;
break;
}
}
} else {
if (Text_GetFaceReaction(globalCtx, 0x1D) != 0) {
this->actor.textId = Text_GetFaceReaction(globalCtx, 0x1D);
this->unk_292 = 6;
} else {
switch (this->state) {
case ENDIVINGGAME_STATE_NOTPLAYING:
this->unk_292 = 4;
if (!(gSaveContext.eventChkInf[3] & 0x100)) {
this->actor.textId = 0x4053;
this->phase = ENDIVINGGAME_PHASE_1;
} else {
this->actor.textId = 0x405C;
this->phase = ENDIVINGGAME_PHASE_2;
}
break;
case ENDIVINGGAME_STATE_AWARDPRIZE:
this->actor.textId = 0x4056;
this->unk_292 = 5;
break;
case ENDIVINGGAME_STATE_PLAYING:
this->actor.textId = 0x405B;
this->unk_292 = 5;
break;
}
}
func_8002F2CC(&this->actor, globalCtx, 80.0f);
}
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EE800.s")
void EnDivingGame_HandlePlayChoice(EnDivingGame* this, GlobalContext* globalCtx) {
SkelAnime_Update(&this->skelAnime);
if (this->unk_292 == func_8010BDBC(&globalCtx->msgCtx) &&
func_80106BC8(globalCtx)) { // Did player selected an answer?
switch (globalCtx->msgCtx.choiceIndex) {
case 0: // Yes
if (gSaveContext.rupees >= 20) {
Rupees_ChangeBy(-20);
this->actor.textId = 0x4054;
} else {
this->actor.textId = 0x85;
this->allRupeesThrown = this->state = this->phase = this->unk_2A2 = this->grabbedRupeesCounter = 0;
}
break;
case 1: // No
this->actor.textId = 0x2D;
this->allRupeesThrown = this->state = this->phase = this->unk_2A2 = this->grabbedRupeesCounter = 0;
break;
}
if (!(gSaveContext.eventChkInf[3] & 0x100) || this->actor.textId == 0x85 || this->actor.textId == 0x2D) {
func_8010B720(globalCtx, this->actor.textId);
this->unk_292 = 5;
this->actionFunc = func_809EE048;
} else {
globalCtx->msgCtx.msgMode = 0x37;
func_8002DF54(globalCtx, NULL, 8);
this->actionFunc = func_809EE0FC;
}
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EE8F0.s")
// Waits for the message to close
void func_809EE048(EnDivingGame* this, GlobalContext* globalCtx) {
SkelAnime_Update(&this->skelAnime);
if (this->unk_292 == func_8010BDBC(&globalCtx->msgCtx) && func_80106BC8(globalCtx)) {
if (this->phase == ENDIVINGGAME_PHASE_ENDED) {
func_80106CCC(globalCtx);
func_8002DF54(globalCtx, NULL, 7);
this->actionFunc = func_809EDCB0;
} else {
globalCtx->msgCtx.msgMode = 0x37;
func_8002DF54(globalCtx, NULL, 8);
this->actionFunc = func_809EE0FC;
}
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EE96C.s")
// another "start minigame" step
void func_809EE0FC(EnDivingGame* this, GlobalContext* globalCtx) {
f32 frameCount = Animation_GetLastFrame(&D_0600219C);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EEA00.s")
Animation_Change(&this->skelAnime, &D_0600219C, 1.0f, 0.0f, (s16)frameCount, 2, -10.0f);
this->notPlayingMinigame = false;
this->actionFunc = func_809EE194;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EEA90.s")
// Wait a bit before start throwing the rupees.
void func_809EE194(EnDivingGame* this, GlobalContext* globalCtx) {
f32 currentFrame = this->skelAnime.curFrame;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EEAF8.s")
SkelAnime_Update(&this->skelAnime);
if (currentFrame >= 15.0f) {
this->actionFunc = EnDivingGame_SetupRupeeThrow;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/EnDivingGame_Update.s")
void EnDivingGame_SetupRupeeThrow(EnDivingGame* this, GlobalContext* globalCtx) {
SkelAnime_Update(&this->skelAnime);
this->subCamId = Gameplay_CreateSubCamera(globalCtx);
Gameplay_ChangeCameraStatus(globalCtx, 0, CAM_STAT_WAIT);
Gameplay_ChangeCameraStatus(globalCtx, this->subCamId, CAM_STAT_ACTIVE);
this->spawnRuppyTimer = 10;
this->unk_2F4.x = -210.0f;
this->unk_2F4.y = -80.0f;
this->unk_2F4.z = -1020.0f;
this->unk_2D0.x = -280.0f;
this->unk_2D0.y = -20.0f;
this->unk_2D0.z = -240.0f;
if (!(gSaveContext.eventChkInf[3] & 0x100)) {
this->rupeesLeftToThrow = 5;
} else {
this->rupeesLeftToThrow = 10;
}
this->unk_2DC.x = this->unk_2DC.y = this->unk_2DC.z = this->unk_300.x = this->unk_300.y = this->unk_300.z = 0.1f;
this->camLookAt.x = globalCtx->view.lookAt.x;
this->camLookAt.y = globalCtx->view.lookAt.y;
this->camLookAt.z = globalCtx->view.lookAt.z;
this->camEye.x = globalCtx->view.eye.x;
this->camEye.y = globalCtx->view.eye.y + 80.0f;
this->camEye.z = globalCtx->view.eye.z + 250.0f;
this->unk_2E8.x = fabsf(this->camEye.x - this->unk_2D0.x) * 0.04f;
this->unk_2E8.y = fabsf(this->camEye.y - this->unk_2D0.y) * 0.04f;
this->unk_2E8.z = fabsf(this->camEye.z - this->unk_2D0.z) * 0.04f;
this->unk_30C.x = fabsf(this->camLookAt.x - this->unk_2F4.x) * 0.04f;
this->unk_30C.y = fabsf(this->camLookAt.y - this->unk_2F4.y) * 0.04f;
this->unk_30C.z = fabsf(this->camLookAt.z - this->unk_2F4.z) * 0.04f;
Gameplay_CameraSetAtEye(globalCtx, this->subCamId, &this->camLookAt, &this->camEye);
Gameplay_CameraSetFov(globalCtx, this->subCamId, globalCtx->mainCamera.fov);
this->csCameraTimer = 60;
this->actionFunc = EnDivingGame_RupeeThrow;
this->unk_318 = 0.0f;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EEDB8.s")
// Throws rupee when this->spawnRuppyTimer == 0
void EnDivingGame_RupeeThrow(EnDivingGame* this, GlobalContext* globalCtx) {
SkelAnime_Update(&this->skelAnime);
if (func_800C0DB4(globalCtx, &this->actor.projectedPos)) {
func_800F6828(0);
}
if (this->subCamId != 0) {
Math_ApproachF(&this->camEye.x, this->unk_2D0.x, this->unk_2DC.x, this->unk_2E8.x * this->unk_318);
Math_ApproachF(&this->camEye.z, this->unk_2D0.z, this->unk_2DC.z, this->unk_2E8.z * this->unk_318);
Math_ApproachF(&this->camLookAt.x, this->unk_2F4.x, this->unk_300.x, this->unk_30C.x * this->unk_318);
Math_ApproachF(&this->camLookAt.y, this->unk_2F4.y, this->unk_300.y, this->unk_30C.y * this->unk_318);
Math_ApproachF(&this->camLookAt.z, this->unk_2F4.z, this->unk_300.z, this->unk_30C.z * this->unk_318);
Math_ApproachF(&this->unk_318, 1.0f, 1.0f, 0.02f);
}
Gameplay_CameraSetAtEye(globalCtx, this->subCamId, &this->camLookAt, &this->camEye);
if (!this->allRupeesThrown && this->spawnRuppyTimer == 0) {
this->spawnRuppyTimer = 5;
EnDivingGame_SpawnRuppy(this, globalCtx);
this->rupeesLeftToThrow--;
if (!(gSaveContext.eventChkInf[3] & 0x100)) {
this->unk_296 = 30;
} else {
this->unk_296 = 5;
}
if (this->rupeesLeftToThrow <= 0) {
this->rupeesLeftToThrow = 0;
this->allRupeesThrown = true;
}
}
if (this->csCameraTimer == 0 ||
((fabsf(this->camEye.x - this->unk_2D0.x) < 2.0f) && (fabsf(this->camEye.y - this->unk_2D0.y) < 2.0f) &&
(fabsf(this->camEye.z - this->unk_2D0.z) < 2.0f) && (fabsf(this->camLookAt.x - this->unk_2F4.x) < 2.0f) &&
(fabsf(this->camLookAt.y - this->unk_2F4.y) < 2.0f) && (fabsf(this->camLookAt.z - this->unk_2F4.z) < 2.0f))) {
if (this->unk_2A2 != 0) {
this->csCameraTimer = 70;
this->unk_2A2 = 2;
this->actionFunc = func_809EE780;
} else {
this->actionFunc = EnDivingGame_SetupUnderwaterViewCs;
}
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/func_809EEDE4.s")
// Called just before changing the camera to focus the underwater rupees.
void EnDivingGame_SetupUnderwaterViewCs(EnDivingGame* this, GlobalContext* globalCtx) {
SkelAnime_Update(&this->skelAnime);
if (this->unk_296 == 0) {
this->unk_2A2 = 1;
this->csCameraTimer = 100;
this->actionFunc = EnDivingGame_RupeeThrow;
this->camLookAt.x = this->unk_2F4.x = -210.0f;
this->camLookAt.y = this->unk_2F4.y = -80.0f;
this->camLookAt.z = this->unk_2F4.z = -1020.0f;
this->camEye.x = this->unk_2D0.x = -280.0f;
this->camEye.y = this->unk_2D0.y = -20.0f;
this->camEye.z = this->unk_2D0.z = -240.0f;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Diving_Game/EnDivingGame_Draw.s")
// EnDivingGame_SayStartAndWait ?
void func_809EE780(EnDivingGame* this, GlobalContext* globalCtx) {
SkelAnime_Update(&this->skelAnime);
if (this->csCameraTimer == 0) {
Gameplay_ClearCamera(globalCtx, this->subCamId);
Gameplay_ChangeCameraStatus(globalCtx, 0, CAM_STAT_ACTIVE);
this->actor.textId = 0x405A;
func_8010B720(globalCtx, this->actor.textId);
this->unk_292 = 5;
this->actionFunc = func_809EE800;
}
}
// EnDivingGame_TalkDuringMinigame
void func_809EE800(EnDivingGame* this, GlobalContext* globalCtx) {
SkelAnime_Update(&this->skelAnime);
if (this->unk_292 == func_8010BDBC(&globalCtx->msgCtx) && func_80106BC8(globalCtx)) {
func_80106CCC(globalCtx);
if (!(gSaveContext.eventChkInf[3] & 0x100)) {
func_80088B34(BREG(2) + 50);
} else {
func_80088B34(BREG(2) + 50);
}
func_800F5ACC(0x6C);
func_8002DF54(globalCtx, NULL, 7);
this->actor.textId = 0x405B;
this->unk_292 = 5;
this->state = ENDIVINGGAME_STATE_PLAYING;
this->actionFunc = EnDivingGame_Talk;
}
}
void func_809EE8F0(EnDivingGame* this, GlobalContext* globalCtx) {
SkelAnime_Update(&this->skelAnime);
if ((this->unk_292 == func_8010BDBC(&globalCtx->msgCtx) && func_80106BC8(globalCtx))) {
func_80106CCC(globalCtx);
this->actionFunc = EnDivingGame_Talk;
} else {
EnDivingGame_HasMinigameFinished(this, globalCtx);
}
}
// EnDivingGame_SayCongratsAndWait ? // EnDivingGame_PlayerWonPhase1
void func_809EE96C(EnDivingGame* this, GlobalContext* globalCtx) {
SkelAnime_Update(&this->skelAnime);
if ((this->unk_292 == func_8010BDBC(&globalCtx->msgCtx) && func_80106BC8(globalCtx))) {
func_80106CCC(globalCtx);
func_8002DF54(globalCtx, NULL, 7);
this->actor.textId = 0x4056;
this->unk_292 = 5;
this->state = ENDIVINGGAME_STATE_AWARDPRIZE;
this->actionFunc = EnDivingGame_Talk;
}
}
void func_809EEA00(EnDivingGame* this, GlobalContext* globalCtx) {
SkelAnime_Update(&this->skelAnime);
if ((this->unk_292 == func_8010BDBC(&globalCtx->msgCtx) && func_80106BC8(globalCtx))) {
func_80106CCC(globalCtx);
this->actor.parent = NULL;
func_8002F434(&this->actor, globalCtx, GI_SCALE_SILVER, 90.0f, 10.0f);
this->actionFunc = func_809EEA90;
}
}
void func_809EEA90(EnDivingGame* this, GlobalContext* globalCtx) {
SkelAnime_Update(&this->skelAnime);
if (Actor_HasParent(&this->actor, globalCtx)) {
this->actionFunc = func_809EEAF8;
} else {
func_8002F434(&this->actor, globalCtx, GI_SCALE_SILVER, 90.0f, 10.0f);
}
}
// Award the scale?
void func_809EEAF8(EnDivingGame* this, GlobalContext* globalCtx) {
SkelAnime_Update(&this->skelAnime);
if (func_8010BDBC(&globalCtx->msgCtx) == 6 && func_80106BC8(globalCtx)) {
// "Successful completion"
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 正常終了 ☆☆☆☆☆ \n" VT_RST);
this->allRupeesThrown = this->state = this->phase = this->unk_2A2 = this->grabbedRupeesCounter = 0;
gSaveContext.eventChkInf[3] |= 0x100;
this->actionFunc = func_809EDCB0;
}
}
void EnDivingGame_Update(Actor* thisx, GlobalContext* globalCtx2) {
GlobalContext* globalCtx = globalCtx2;
EnDivingGame* this = THIS;
Player* player = PLAYER;
Vec3f pos;
if (this->csCameraTimer != 0) {
this->csCameraTimer--;
}
if (this->unk_296 != 0) {
this->unk_296--;
}
if (this->eyeTimer != 0) {
this->eyeTimer--;
}
if (this->spawnRuppyTimer != 0) {
this->spawnRuppyTimer--;
}
if (1) {}
if (gSaveContext.timer1Value == 10) {
func_800F5918();
}
if (this->eyeTimer == 0) {
this->eyeTimer = 2;
this->eyeTexIndex++;
if (this->eyeTexIndex >= 3) {
this->eyeTexIndex = 0;
this->eyeTimer = (s16)Rand_ZeroFloat(60.0f) + 20;
}
}
this->actionFunc(this, globalCtx);
Actor_SetFocus(&this->actor, 80.0f);
this->unk_324.unk_18 = player->actor.world.pos;
this->unk_324.unk_18.y = player->actor.world.pos.y;
func_80034A14(&this->actor, &this->unk_324, 2, 4);
this->vec_284 = this->unk_324.unk_08;
this->vec_28A = this->unk_324.unk_0E;
if ((globalCtx->gameplayFrames % 16) == 0) {
pos = this->actor.world.pos;
pos.y += 20.0f;
EffectSsGRipple_Spawn(globalCtx, &pos, 100, 500, 30);
}
this->unk_290++;
Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 20.0f, 60.0f, 29);
Collider_UpdateCylinder(&this->actor, &this->collider);
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
}
Gfx* EnDivingGame_EmptyDList(GraphicsContext* gfxCtx) {
Gfx* displayList = Graph_Alloc(gfxCtx, sizeof(Gfx));
gSPEndDisplayList(displayList);
return displayList;
}
s32 EnDivingGame_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot,
void* thisx) {
EnDivingGame* this = THIS;
s32 pad;
if (limbIndex == 6) {
rot->x += this->vec_28A.y;
}
if (limbIndex == 15) {
rot->x += this->vec_284.y;
rot->z += this->vec_284.z;
}
if (this->notPlayingMinigame && (limbIndex == 8 || limbIndex == 9 || limbIndex == 12)) {
rot->y += Math_SinS((globalCtx->state.frames * (limbIndex * 50 + 0x814))) * 200.0f;
rot->z += Math_CosS((globalCtx->state.frames * (limbIndex * 50 + 0x940))) * 200.0f;
}
return 0;
}
void EnDivingGame_Draw(Actor* thisx, GlobalContext* globalCtx) {
EnDivingGame* this = THIS;
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_diving_game.c", 1212);
func_80093D18(globalCtx->state.gfxCtx);
gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 255);
gSPSegment(POLY_OPA_DISP++, 0x0C, EnDivingGame_EmptyDList(globalCtx->state.gfxCtx));
gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeTexIndex]));
SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount,
EnDivingGame_OverrideLimbDraw, NULL, this);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_diving_game.c", 1232);
}

View file

@ -16,51 +16,51 @@ typedef struct EnDivingGame {
/* 0x0280 */ EnDivingGameActionFunc actionFunc;
/* 0x0284 */ Vec3s vec_284;
/* 0x028A */ Vec3s vec_28A;
/* 0x0290 */ s16 unk_290;
/* 0x0290 */ s16 unk_290; // counter that only goes up
/* 0x0292 */ s16 unk_292;
/* 0x0294 */ s16 unk_294;
/* 0x0296 */ s16 unk_296;
/* 0x0298 */ s16 unk_298;
/* 0x029A */ s16 unk_29A;
/* 0x029C */ s16 unk_29C;
/* 0x029E */ s16 unk_29E;
/* 0x02A0 */ s16 camId;
/* 0x02A2 */ s16 unk_2A2;
/* 0x02A4 */ s16 unk_2A4;
/* 0x02A6 */ s16 unk_2A6;
/* 0x02A8 */ s16 unk_2A8;
/* 0x02AA */ s16 unk_2AA;
/* 0x02AC */ char unk_2AC[0xC];
/* 0x02B8 */ Vec3f vec_2B8;
/* 0x02C4 */ Vec3f vec_2C4;
/* 0x02D0 */ f32 unk_2D0;
/* 0x02D4 */ f32 unk_2D4;
/* 0x02D8 */ f32 unk_2D8;
/* 0x02DC */ f32 unk_2DC;
/* 0x02E0 */ f32 unk_2E0;
/* 0x02E4 */ f32 unk_2E4;
/* 0x02E8 */ f32 unk_2E8;
/* 0x02EC */ f32 unk_2EC;
/* 0x02F0 */ f32 unk_2F0;
/* 0x02F4 */ f32 unk_2F4;
/* 0x02F8 */ f32 unk_2F8;
/* 0x02FC */ f32 unk_2FC;
/* 0x0300 */ f32 unk_300;
/* 0x0304 */ f32 unk_304;
/* 0x0308 */ f32 unk_308;
/* 0x030C */ f32 unk_30C;
/* 0x0310 */ f32 unk_310;
/* 0x0314 */ f32 unk_314;
/* 0x0294 */ s16 csCameraTimer;
/* 0x0296 */ s16 unk_296; // read by ExRuppy // timer?
/* 0x0298 */ s16 eyeTimer;
/* 0x029A */ s16 spawnRuppyTimer;
/* 0x029C */ s16 phase;
/* 0x029E */ s16 eyeTexIndex;
/* 0x02A0 */ s16 subCamId;
/* 0x02A2 */ s16 unk_2A2; // 0: , 1: , 2: Tells rupees to sink in water
/* 0x02A4 */ s16 grabbedRupeesCounter;
/* 0x02A6 */ s16 rupeesLeftToThrow;
/* 0x02A8 */ s16 state; // minigameState? 0: default, 1: waiting to give the scale, 2: minigame started
/* 0x02AA */ s16 extraWinCount; // counts how many times you have beaten the minigame **after** you got the scale. ExRuppy will reset it to zero if a 500 rupee is spawned.
/* 0x02AC */ char unk_2AC[0xC]; // probably another Vec3f, but unused.
/* 0x02B8 */ Vec3f camLookAt;
/* 0x02C4 */ Vec3f camEye;
/* 0x02D0 */ Vec3f unk_2D0;
/* 0x02DC */ Vec3f unk_2DC;
/* 0x02E8 */ Vec3f unk_2E8;
/* 0x02F4 */ Vec3f unk_2F4;
/* 0x0300 */ Vec3f unk_300;
/* 0x030C */ Vec3f unk_30C;
/* 0x0318 */ f32 unk_318;
/* 0x031C */ char unk_31C;
/* 0x031D */ u8 unk_31D;
/* 0x031E */ char unk_31E;
/* 0x031F */ u8 unk_31F;
/* 0x0320 */ char unk_320[0x4];
/* 0x031C */ char unk_31C; // unused
/* 0x031D */ u8 notPlayingMinigame; // flag
/* 0x031E */ u8 allRupeesThrown; // flag
/* 0x031F */ u8 unk_31F; // flag
/* 0x0320 */ char unk_320[0x4]; // unused
/* 0x0324 */ struct_80034A14_arg1 unk_324;
/* 0x034C */ ColliderCylinder collider;
} EnDivingGame; // size = 0x0398
extern const ActorInit En_Diving_Game_InitVars;
typedef enum {
/* 0 */ ENDIVINGGAME_PHASE_ENDED,
/* 1 */ ENDIVINGGAME_PHASE_1, // Player has not received the scale.
/* 2 */ ENDIVINGGAME_PHASE_2 // Player got the scale and there are 10 rupees thrown.
} EnDivingGamePhase;
typedef enum {
/* 0 */ ENDIVINGGAME_STATE_NOTPLAYING,
/* 1 */ ENDIVINGGAME_STATE_AWARDPRIZE, // Waiting to give the scale to player.
/* 2 */ ENDIVINGGAME_STATE_PLAYING
} EnDivingGameState;
#endif

View file

@ -70,7 +70,7 @@ void EnExRuppy_Init(Actor* thisx, GlobalContext* globalCtx) {
if (this->actor.parent != NULL) {
divingGame = (EnDivingGame*)this->actor.parent;
if (divingGame->actor.update != NULL) {
temp2 = divingGame->unk_2AA * 10.0f;
temp2 = divingGame->extraWinCount * 10.0f;
temp1 += temp2;
}
}
@ -96,7 +96,7 @@ void EnExRuppy_Init(Actor* thisx, GlobalContext* globalCtx) {
if (this->actor.parent != NULL) {
divingGame = (EnDivingGame*)this->actor.parent;
if (divingGame->actor.update != NULL) {
divingGame->unk_2AA = 0;
divingGame->extraWinCount = 0;
}
}
}
@ -261,7 +261,7 @@ void EnExRuppy_Sink(EnExRuppy* this, GlobalContext* globalCtx) {
this->actionFunc = EnExRuppy_WaitInGame;
}
divingGame = (EnDivingGame*)this->actor.parent;
if ((divingGame != NULL) && (divingGame->actor.update != NULL) && (divingGame->unk_29C == 0)) {
if ((divingGame != NULL) && (divingGame->actor.update != NULL) && (divingGame->phase == ENDIVINGGAME_PHASE_ENDED)) {
this->timer = 20;
this->actionFunc = EnExRuppy_Kill;
}
@ -280,14 +280,14 @@ void EnExRuppy_WaitInGame(EnExRuppy* this, GlobalContext* globalCtx) {
if (this->actor.parent != NULL) {
divingGame = (EnDivingGame*)this->actor.parent;
if (divingGame->actor.update != NULL) {
if (divingGame->unk_29C == 0) {
if (divingGame->phase == ENDIVINGGAME_PHASE_ENDED) {
this->timer = 20;
this->actionFunc = EnExRuppy_Kill;
if (1) {}
} else if (this->actor.xyzDistToPlayerSq < SQ(localConst)) {
Rupees_ChangeBy(this->rupeeValue);
func_80078884(NA_SE_SY_GET_RUPY);
divingGame->unk_2A4++;
divingGame->grabbedRupeesCounter++;
Actor_Kill(&this->actor);
}
} else {