Shipwright/soh/src/overlays/actors/ovl_En_Md/z_en_md.c

886 lines
28 KiB
C
Raw Normal View History

/*
* File: z_en_md.c
* Overlay: ovl_En_Md
* Description: Mido
*/
#include "z_en_md.h"
#include "objects/object_md/object_md.h"
#include "overlays/actors/ovl_En_Elf/z_en_elf.h"
#define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_3 | ACTOR_FLAG_4 | ACTOR_FLAG_25)
void EnMd_Init(Actor* thisx, GlobalContext* globalCtx);
void EnMd_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnMd_Update(Actor* thisx, GlobalContext* globalCtx);
void EnMd_Draw(Actor* thisx, GlobalContext* globalCtx);
void func_80AAB874(EnMd* this, GlobalContext* globalCtx);
void func_80AAB8F8(EnMd* this, GlobalContext* globalCtx);
void func_80AAB948(EnMd* this, GlobalContext* globalCtx);
void func_80AABC10(EnMd* this, GlobalContext* globalCtx);
void func_80AABD0C(EnMd* this, GlobalContext* globalCtx);
const ActorInit En_Md_InitVars = {
ACTOR_EN_MD,
ACTORCAT_NPC,
FLAGS,
OBJECT_MD,
sizeof(EnMd),
(ActorFunc)EnMd_Init,
(ActorFunc)EnMd_Destroy,
(ActorFunc)EnMd_Update,
(ActorFunc)EnMd_Draw,
NULL,
};
static ColliderCylinderInit sCylinderInit = {
{
COLTYPE_NONE,
AT_NONE,
AC_NONE,
OC1_ON | OC1_TYPE_ALL,
OC2_TYPE_2,
COLSHAPE_CYLINDER,
},
{
ELEMTYPE_UNK0,
{ 0x00000000, 0x00, 0x00 },
{ 0x00000000, 0x00, 0x00 },
TOUCH_NONE,
BUMP_NONE,
OCELEM_ON,
},
{ 36, 46, 0, { 0, 0, 0 } },
};
static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE };
typedef enum {
/* 0 */ ENMD_ANIM_0,
/* 1 */ ENMD_ANIM_1,
/* 2 */ ENMD_ANIM_2,
/* 3 */ ENMD_ANIM_3,
/* 4 */ ENMD_ANIM_4,
/* 5 */ ENMD_ANIM_5,
/* 6 */ ENMD_ANIM_6,
/* 7 */ ENMD_ANIM_7,
/* 8 */ ENMD_ANIM_8,
/* 9 */ ENMD_ANIM_9,
/* 10 */ ENMD_ANIM_10,
/* 11 */ ENMD_ANIM_11,
/* 12 */ ENMD_ANIM_12,
/* 13 */ ENMD_ANIM_13,
} EnMdAnimation;
static AnimationInfo sAnimationInfo[] = {
{ &gMidoHandsOnHipsIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f },
{ &gMidoHandsOnHipsIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -10.0f },
{ &gMidoRaiseHand1Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f },
{ &gMidoHaltAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f },
{ &gMidoPutHandDownAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f },
{ &gMidoAnnoyedPointedHeadIdle1Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f },
{ &gMidoAnnoyedPointedHeadIdle2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f },
{ &gMidoAnim_92B0, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f },
{ &gMidoWalkingAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f },
{ &gMidoHandsOnHipsTransitionAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f },
{ &gMidoHandsOnHipsIdleAnim, 0.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -8.0f },
{ &gMidoSlamAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f },
{ &gMidoRaiseHand2Anim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, -1.0f },
{ &gMidoAngryHeadTurnAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, -1.0f },
};
void func_80AAA250(EnMd* this) {
f32 startFrame;
startFrame = this->skelAnime.startFrame;
this->skelAnime.startFrame = this->skelAnime.endFrame;
this->skelAnime.curFrame = this->skelAnime.endFrame;
this->skelAnime.endFrame = startFrame;
this->skelAnime.playSpeed = -1.0f;
}
void func_80AAA274(EnMd* this) {
switch (this->unk_20A) {
case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_2);
this->unk_20A++;
case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_3);
this->unk_20A++;
}
}
}
void func_80AAA308(EnMd* this) {
switch (this->unk_20A) {
case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_4);
this->unk_20A++;
case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_5);
this->unk_20A++;
}
}
}
void func_80AAA39C(EnMd* this) {
switch (this->unk_20A) {
case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_2);
func_80AAA250(this);
this->unk_20A++;
case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_7);
this->unk_20A++;
} else {
break;
}
case 2:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_8);
this->unk_20A++;
}
}
}
void func_80AAA474(EnMd* this) {
switch (this->unk_20A) {
case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_7);
this->unk_20A++;
case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_10);
this->unk_20A++;
}
}
}
void func_80AAA508(EnMd* this) {
switch (this->unk_20A) {
case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_2);
func_80AAA250(this);
this->unk_20A++;
case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_10);
this->unk_20A++;
}
}
}
void func_80AAA5A4(EnMd* this) {
switch (this->unk_20A) {
case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_9);
this->unk_20A++;
case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_6);
this->unk_20A++;
}
}
}
void func_80AAA638(EnMd* this) {
switch (this->unk_20A) {
case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_9);
func_80AAA250(this);
this->unk_20A++;
case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_10);
this->unk_20A++;
}
}
}
void func_80AAA6D4(EnMd* this) {
switch (this->unk_20A) {
case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_11);
this->unk_20A++;
case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_6);
this->unk_20A++;
}
}
}
void func_80AAA768(EnMd* this) {
switch (this->unk_20A) {
case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_12);
this->unk_20A++;
case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_3);
this->unk_20A++;
}
}
}
void func_80AAA7FC(EnMd* this) {
switch (this->unk_20A) {
case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_13);
this->unk_20A++;
case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_6);
this->unk_20A++;
}
}
}
void func_80AAA890(EnMd* this) {
switch (this->unk_20A) {
case 0:
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_7);
func_80AAA250(this);
this->unk_20A++;
case 1:
if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_10);
this->unk_20A++;
}
}
}
void func_80AAA92C(EnMd* this, u8 arg1) {
this->unk_20B = arg1;
this->unk_20A = 0;
}
void func_80AAA93C(EnMd* this) {
switch (this->unk_20B) {
case 1:
func_80AAA274(this);
break;
case 2:
func_80AAA308(this);
break;
case 3:
func_80AAA39C(this);
break;
case 4:
func_80AAA474(this);
break;
case 5:
func_80AAA508(this);
break;
case 6:
func_80AAA5A4(this);
break;
case 7:
func_80AAA638(this);
break;
case 8:
func_80AAA6D4(this);
break;
case 9:
func_80AAA768(this);
break;
case 10:
func_80AAA7FC(this);
break;
case 11:
func_80AAA890(this);
}
}
void func_80AAAA24(EnMd* this) {
if (this->unk_1E0.unk_00 != 0) {
switch (this->actor.textId) {
case 0x102F:
if ((this->unk_208 == 0) && (this->unk_20B != 1)) {
func_80AAA92C(this, 1);
}
if ((this->unk_208 == 2) && (this->unk_20B != 2)) {
func_80AAA92C(this, 2);
}
if ((this->unk_208 == 5) && (this->unk_20B != 8)) {
func_80AAA92C(this, 8);
}
if ((this->unk_208 == 11) && (this->unk_20B != 9)) {
func_80AAA92C(this, 9);
}
break;
case 0x1033:
if ((this->unk_208 == 0) && (this->unk_20B != 1)) {
func_80AAA92C(this, 1);
}
if ((this->unk_208 == 1) && (this->unk_20B != 2)) {
func_80AAA92C(this, 2);
}
if ((this->unk_208 == 5) && (this->unk_20B != 10)) {
func_80AAA92C(this, 10);
}
if ((this->unk_208 == 7) && (this->unk_20B != 9)) {
func_80AAA92C(this, 9);
}
break;
case 0x1030:
case 0x1034:
case 0x1045:
if ((this->unk_208 == 0) && (this->unk_20B != 1)) {
func_80AAA92C(this, 1);
}
break;
case 0x1046:
if ((this->unk_208 == 0) && (this->unk_20B != 6)) {
func_80AAA92C(this, 6);
}
break;
}
} else if (this->skelAnime.animation != &gMidoHandsOnHipsIdleAnim) {
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_10);
func_80AAA92C(this, 0);
}
func_80AAA93C(this);
}
s16 func_80AAAC78(EnMd* this, GlobalContext* globalCtx) {
s16 dialogState = Message_GetState(&globalCtx->msgCtx);
if ((this->unk_209 == TEXT_STATE_AWAITING_NEXT) || (this->unk_209 == TEXT_STATE_EVENT) ||
(this->unk_209 == TEXT_STATE_CLOSING) || (this->unk_209 == TEXT_STATE_DONE_HAS_NEXT)) {
if (this->unk_209 != dialogState) {
this->unk_208++;
}
}
this->unk_209 = dialogState;
return dialogState;
}
u16 EnMd_GetTextKokiriForest(GlobalContext* globalCtx, EnMd* this) {
u16 reactionText = Text_GetFaceReaction(globalCtx, 0x11);
if (reactionText != 0) {
return reactionText;
}
this->unk_208 = 0;
this->unk_209 = TEXT_STATE_NONE;
testing out item replacement (#416) * skip learning song of storms * don't set flag when getting goron tunic as child * Initiates prelude check when master sword unloads. Not quite how N64 rando does it but so far it's the only way I've found to make it trigger without also triggering the time travel again. * Stops Shadow Temple lore prompts from appearing in rando. * Skips cutscene of royal tomb explosion in rando. Explosion sound doesn't play correctly and I think the debris appears in the wrong place, but the functionality is here. * Improves visual of exploding gravestone. * Adds some comments explaining the rando differences * Skip ruto text box in jabu blue warp For rando * skip intro cutscene in dodongo's cavern * load spoiler files on boot, fix spoilerfile existing check when making new saves * name entry dropped spoiler logic * make sure to actually init the cvar * no chime on load * uncomment * Skip ganondrof cutscene Skip to scream part of the death animation, skipping the text boxes etc. For rando * Update z_boss_ganondrof.c * skip owl flight cutscenes in rando * Fixes skipped text so it only applies to shadow temple. Earlier fix inadvertently applied to some other text as well, changed logic so that only specified sceneNums and textIds can have this enabled, and text skipped by sceneNum can have the skip overriden by textId if needed. Currently there are no overrides so the textId section of the logic is commented out to avoid compilation errors. * Adds a default to the switch case statements that leaves the randoSkipText variable unchanged, just in case. * TEST: Text for item * Adding ganon flavor text * ADD: AMMO Count * format ganon text/hint text * Autoskip the tower cutscene if settings call for tower collapse. * ganon hint text logic * Improved prelude after time travel fix * swapped the sizes between ganon hint text and ganon text, as they were set to the wrong things. * this is all i did * not the cleanest code ever but it's working * ADD: GS Count * ADD: Wallter (crash for now) * TWEAK: Wallet check * FIX: Use DrawItem instread of DrawUpgrade... b-baka! * Fixes some vanilla bugs introduced by rando code. * Added cutscene skip for zelda escaping Using the debug cutscene skipping function. Also added a conditional so the bridge doesn't spawn closed when cutscene is ready to trigger * ADD: X Spacing + Placeholders for song * ADD: default case for items * TWEAK: Spacing * FIX: Light Arrow * ADD: Ammo Option * use groups instead * ADD: More spacing logic * songs and names * TWEAK: Color on wallet * colors * Added flags cutscene before nabooru fight * ADD: ChromaKey text * First attempt skip cs after nabooru defeat * Better implementation for specific rando cutscene skips * use pulseaudio defaults * spaces/tabs * move color push/pop to stop crash * make the colors work again * the real bottle fix * pulseaudio values tuned for n64 audio at 44.1khz * update tlength * remove one hardcoded samplerate * Cleaned up and fixed zelda escape skip The if statement is a freaking monster, but unless we want to skip more cutscenes in the same way later, this is the most compact way of doing it that I know of. * Revert one line to match original nothing functional * another hint line that breaks autonewline logic * don't autospawn epona if we don't have the song/ocarina * Trying to use iron knuckle death effects not working yet * Streamlined OoT cutscene skip for future additions Also cleaned up if statement in general * Made if statement more readable Also added clarity for what cutscene was skipped * Fixed typo in comment * Janky nabooru defeat cs skip * altar text formatting (gonna need help shortening some of the french ones) * more altar text formatting * english altar text formatting complete * make gtg blocking guard check for card not bridge * FIX: Typo! * FIX: Uppercases * FIX: Typo * TWEAK: Alter + some names * TWEAK: More caps! * ADD: Missing string TWEAK more uppercases and namefixe s * Hide nabooru death by covering her in flames * bandaid fix for death crash issue * Twinrova defeat cs skip Skips the animation and manually calls the function to show the "beam" around the sisters * fix crash * fix caps to match * fix great fairy reward mashing/shielding issue * TWEAK : Typo clé to Clé * TWEAK: Some Altar hints TWEAK: Some capitals * TWEAK: Unmatching text + some cap again * TWEAK: More tweaks * fix build * remove extra json.hpp, add hint * Update randomizer_item_tracker.cpp * TWEAK: Double Defense with RedParticles instead of white * make sure we don't optimize out the check to ensure a spoilerfile exists * vanilla ganon boss key hint formatting * TWEAK: FR- better way of the hero text * fix * and again * Initializes dungeonsDone items in gSaveContext to 0. * Replaces sizeof calculation with a NUM_DUNGEONS constant. * Fixes Saria's Gift on the LW Bridge from getting killed when holding shield. * More airtight fix for Saria's Gift on the Bridge. * Lifts one of the conditions in the if statement a little higher to prevent unnecessary lookups of getItemId. * Invalidate text box icon before drawing * Fixes the case where Saria's gift is an Ice Trap. We still get the Ice Trap once, but never again. This does mean you can now hold R while walking in to avoid the ice trap, but everything else seems to work fine. * Initial commit Might need changing when we change the settings in the future * Fixes Door of Time opening cutscene after warping with prelude. * Initial waterfall skip Very rudimentary way of doing things but it seems to work so :shrug: * inital rework * fixed default rotation for 2D sprites * fix tab/space issues * 3d drops rando merge fix again * Allows Impa to appear in the Lullaby check post drawbridge escape. * Changes Ganon's Trials Count setting to a checkbox The checkbox is whether or not to skip all of them. Leaving the box unchecked will mean doing all of them. Eventually this will be switched back to a slider once we implement the logic for which trials start out completed. * Sets all Ganon's Trials to incomplete in new saves. Fixes https://github.com/briaguya-ai/rando-issue-tracker/issues/131 * fix castle guards when oot throw cutscene has already played in rando * Properly removes the beams when trials are cleared. * Removes Question Mark from Skip Ganon's Trials UI. * Adds a todo comment about when to change back to slider. * make deku seeds check for bullet bag * Various tweaks TWEAK: Altar Text TWEAK: Hint names TWEAK: Replace more problematic œ to oe * upgrade ocarina on both child and adult equips * FIX: Jabu Item * update equipped hookshot/longshot when obtained as other age * add hint * don't give the bgs check without the claim check * Skips Darunia Cutscene in Fire Temple * Added a TODO note about not skipping the cutscene. There is a setting we will want to have eventually that will require this cutscene to not be skipped since it is used during a glitch. * remove todo * restore fast ocarina option in imgui that was lost in merge * Fixes grey screen issue + tooltip for 2 handed shield * update to use dg instead of g for textures in item tracker * TWEAK: Default color for cosmetic RAND button was not the corect one * fix texture crash, remove unused item tracker code * don't open mask shop until we get zelda's letter * Update README.md * Prevents "correct" chime under incorrect conditions. * Fixes typo in conditional and adds "bonk" sound effect. "Bonk" sound is NA_SE_SY_OCARINA_ERROR and it plays when conditions for the Door of Time have not been met after playing Song of Time. This is only possible in rando's "Intended" Door of Time option, in which the Ocarina of Time and all 3 spritual stones are required to open the door, instead of the vanilla requirements of just having the song of time. * remove modify dpad equips toggle, replace with checks for dpad menu * remove extra check * add ability to hold c-up to assign to dpad when dpad menuing is enabled * disable d-pad navigation on item menu when holding c-up to equip * dpad+c-up stuff for equipment menu * ADD: Checbox for songs colors * TWEAK: RandoColors for normal songs * kind of quick and dirty but it works * TWEAK: Clarity of the tooltip Co-authored-by: briaguya <briaguya@alice> Co-authored-by: Christopher Leggett <chris@leggett.dev> Co-authored-by: aMannus <mannusmenting@gmail.com> Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com> Co-authored-by: Dog <5172592+Dog@users.noreply.github.com> Co-authored-by: Vague Rant <vaguerant@users.noreply.github.com> Co-authored-by: Baoulettes <perlouzerie@hotmail.fr> Co-authored-by: Ada <60364512+GreatArgorath@users.noreply.github.com>
2022-07-11 20:11:07 -04:00
if ((!gSaveContext.n64ddFlag && CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) ||
(gSaveContext.n64ddFlag && gSaveContext.dungeonsDone[1])) {
return 0x1045;
}
if (gSaveContext.eventChkInf[0] & 0x10) {
return 0x1034;
}
if ((CUR_EQUIP_VALUE(EQUIP_SHIELD) == 1) && (CUR_EQUIP_VALUE(EQUIP_SWORD) == 1)) {
return 0x1033;
}
if (gSaveContext.infTable[0] & 0x1000) {
return 0x1030;
}
return 0x102F;
}
u16 EnMd_GetTextKokiriHome(GlobalContext* globalCtx, EnMd* this) {
this->unk_208 = 0;
this->unk_209 = TEXT_STATE_NONE;
if (gSaveContext.eventChkInf[4] & 1) {
return 0x1028;
}
return 0x1046;
}
u16 EnMd_GetTextLostWoods(GlobalContext* globalCtx, EnMd* this) {
this->unk_208 = 0;
this->unk_209 = TEXT_STATE_NONE;
if (gSaveContext.eventChkInf[4] & 0x100) {
if (gSaveContext.infTable[1] & 0x200) {
return 0x1071;
}
return 0x1070;
}
if (gSaveContext.eventChkInf[0] & 0x400) {
return 0x1068;
}
if (gSaveContext.infTable[1] & 0x20) {
return 0x1061;
}
return 0x1060;
}
u16 EnMd_GetText(GlobalContext* globalCtx, Actor* thisx) {
EnMd* this = (EnMd*)thisx;
switch (globalCtx->sceneNum) {
case SCENE_SPOT04:
return EnMd_GetTextKokiriForest(globalCtx, this);
case SCENE_KOKIRI_HOME4:
return EnMd_GetTextKokiriHome(globalCtx, this);
case SCENE_SPOT10:
return EnMd_GetTextLostWoods(globalCtx, this);
default:
return 0;
}
}
s16 func_80AAAF04(GlobalContext* globalCtx, Actor* thisx) {
EnMd* this = (EnMd*)thisx;
switch (func_80AAAC78(this, globalCtx)) {
case TEXT_STATE_NONE:
case TEXT_STATE_DONE_HAS_NEXT:
case TEXT_STATE_DONE_FADING:
case TEXT_STATE_CHOICE:
case TEXT_STATE_DONE:
case TEXT_STATE_SONG_DEMO_DONE:
case TEXT_STATE_8:
case TEXT_STATE_9:
return 1;
case TEXT_STATE_CLOSING:
switch (this->actor.textId) {
case 0x1028:
gSaveContext.eventChkInf[0] |= 0x8000;
break;
case 0x102F:
gSaveContext.eventChkInf[0] |= 4;
gSaveContext.infTable[0] |= 0x1000;
break;
case 0x1060:
gSaveContext.infTable[1] |= 0x20;
break;
case 0x1070:
gSaveContext.infTable[1] |= 0x200;
break;
case 0x1033:
case 0x1067:
return 2;
}
return 0;
case TEXT_STATE_EVENT:
if (Message_ShouldAdvance(globalCtx)) {
return 2;
}
default:
return 1;
}
}
u8 EnMd_ShouldSpawn(EnMd* this, GlobalContext* globalCtx) {
if (globalCtx->sceneNum == SCENE_SPOT04) {
testing out item replacement (#416) * skip learning song of storms * don't set flag when getting goron tunic as child * Initiates prelude check when master sword unloads. Not quite how N64 rando does it but so far it's the only way I've found to make it trigger without also triggering the time travel again. * Stops Shadow Temple lore prompts from appearing in rando. * Skips cutscene of royal tomb explosion in rando. Explosion sound doesn't play correctly and I think the debris appears in the wrong place, but the functionality is here. * Improves visual of exploding gravestone. * Adds some comments explaining the rando differences * Skip ruto text box in jabu blue warp For rando * skip intro cutscene in dodongo's cavern * load spoiler files on boot, fix spoilerfile existing check when making new saves * name entry dropped spoiler logic * make sure to actually init the cvar * no chime on load * uncomment * Skip ganondrof cutscene Skip to scream part of the death animation, skipping the text boxes etc. For rando * Update z_boss_ganondrof.c * skip owl flight cutscenes in rando * Fixes skipped text so it only applies to shadow temple. Earlier fix inadvertently applied to some other text as well, changed logic so that only specified sceneNums and textIds can have this enabled, and text skipped by sceneNum can have the skip overriden by textId if needed. Currently there are no overrides so the textId section of the logic is commented out to avoid compilation errors. * Adds a default to the switch case statements that leaves the randoSkipText variable unchanged, just in case. * TEST: Text for item * Adding ganon flavor text * ADD: AMMO Count * format ganon text/hint text * Autoskip the tower cutscene if settings call for tower collapse. * ganon hint text logic * Improved prelude after time travel fix * swapped the sizes between ganon hint text and ganon text, as they were set to the wrong things. * this is all i did * not the cleanest code ever but it's working * ADD: GS Count * ADD: Wallter (crash for now) * TWEAK: Wallet check * FIX: Use DrawItem instread of DrawUpgrade... b-baka! * Fixes some vanilla bugs introduced by rando code. * Added cutscene skip for zelda escaping Using the debug cutscene skipping function. Also added a conditional so the bridge doesn't spawn closed when cutscene is ready to trigger * ADD: X Spacing + Placeholders for song * ADD: default case for items * TWEAK: Spacing * FIX: Light Arrow * ADD: Ammo Option * use groups instead * ADD: More spacing logic * songs and names * TWEAK: Color on wallet * colors * Added flags cutscene before nabooru fight * ADD: ChromaKey text * First attempt skip cs after nabooru defeat * Better implementation for specific rando cutscene skips * use pulseaudio defaults * spaces/tabs * move color push/pop to stop crash * make the colors work again * the real bottle fix * pulseaudio values tuned for n64 audio at 44.1khz * update tlength * remove one hardcoded samplerate * Cleaned up and fixed zelda escape skip The if statement is a freaking monster, but unless we want to skip more cutscenes in the same way later, this is the most compact way of doing it that I know of. * Revert one line to match original nothing functional * another hint line that breaks autonewline logic * don't autospawn epona if we don't have the song/ocarina * Trying to use iron knuckle death effects not working yet * Streamlined OoT cutscene skip for future additions Also cleaned up if statement in general * Made if statement more readable Also added clarity for what cutscene was skipped * Fixed typo in comment * Janky nabooru defeat cs skip * altar text formatting (gonna need help shortening some of the french ones) * more altar text formatting * english altar text formatting complete * make gtg blocking guard check for card not bridge * FIX: Typo! * FIX: Uppercases * FIX: Typo * TWEAK: Alter + some names * TWEAK: More caps! * ADD: Missing string TWEAK more uppercases and namefixe s * Hide nabooru death by covering her in flames * bandaid fix for death crash issue * Twinrova defeat cs skip Skips the animation and manually calls the function to show the "beam" around the sisters * fix crash * fix caps to match * fix great fairy reward mashing/shielding issue * TWEAK : Typo clé to Clé * TWEAK: Some Altar hints TWEAK: Some capitals * TWEAK: Unmatching text + some cap again * TWEAK: More tweaks * fix build * remove extra json.hpp, add hint * Update randomizer_item_tracker.cpp * TWEAK: Double Defense with RedParticles instead of white * make sure we don't optimize out the check to ensure a spoilerfile exists * vanilla ganon boss key hint formatting * TWEAK: FR- better way of the hero text * fix * and again * Initializes dungeonsDone items in gSaveContext to 0. * Replaces sizeof calculation with a NUM_DUNGEONS constant. * Fixes Saria's Gift on the LW Bridge from getting killed when holding shield. * More airtight fix for Saria's Gift on the Bridge. * Lifts one of the conditions in the if statement a little higher to prevent unnecessary lookups of getItemId. * Invalidate text box icon before drawing * Fixes the case where Saria's gift is an Ice Trap. We still get the Ice Trap once, but never again. This does mean you can now hold R while walking in to avoid the ice trap, but everything else seems to work fine. * Initial commit Might need changing when we change the settings in the future * Fixes Door of Time opening cutscene after warping with prelude. * Initial waterfall skip Very rudimentary way of doing things but it seems to work so :shrug: * inital rework * fixed default rotation for 2D sprites * fix tab/space issues * 3d drops rando merge fix again * Allows Impa to appear in the Lullaby check post drawbridge escape. * Changes Ganon's Trials Count setting to a checkbox The checkbox is whether or not to skip all of them. Leaving the box unchecked will mean doing all of them. Eventually this will be switched back to a slider once we implement the logic for which trials start out completed. * Sets all Ganon's Trials to incomplete in new saves. Fixes https://github.com/briaguya-ai/rando-issue-tracker/issues/131 * fix castle guards when oot throw cutscene has already played in rando * Properly removes the beams when trials are cleared. * Removes Question Mark from Skip Ganon's Trials UI. * Adds a todo comment about when to change back to slider. * make deku seeds check for bullet bag * Various tweaks TWEAK: Altar Text TWEAK: Hint names TWEAK: Replace more problematic œ to oe * upgrade ocarina on both child and adult equips * FIX: Jabu Item * update equipped hookshot/longshot when obtained as other age * add hint * don't give the bgs check without the claim check * Skips Darunia Cutscene in Fire Temple * Added a TODO note about not skipping the cutscene. There is a setting we will want to have eventually that will require this cutscene to not be skipped since it is used during a glitch. * remove todo * restore fast ocarina option in imgui that was lost in merge * Fixes grey screen issue + tooltip for 2 handed shield * update to use dg instead of g for textures in item tracker * TWEAK: Default color for cosmetic RAND button was not the corect one * fix texture crash, remove unused item tracker code * don't open mask shop until we get zelda's letter * Update README.md * Prevents "correct" chime under incorrect conditions. * Fixes typo in conditional and adds "bonk" sound effect. "Bonk" sound is NA_SE_SY_OCARINA_ERROR and it plays when conditions for the Door of Time have not been met after playing Song of Time. This is only possible in rando's "Intended" Door of Time option, in which the Ocarina of Time and all 3 spritual stones are required to open the door, instead of the vanilla requirements of just having the song of time. * remove modify dpad equips toggle, replace with checks for dpad menu * remove extra check * add ability to hold c-up to assign to dpad when dpad menuing is enabled * disable d-pad navigation on item menu when holding c-up to equip * dpad+c-up stuff for equipment menu * ADD: Checbox for songs colors * TWEAK: RandoColors for normal songs * kind of quick and dirty but it works * TWEAK: Clarity of the tooltip Co-authored-by: briaguya <briaguya@alice> Co-authored-by: Christopher Leggett <chris@leggett.dev> Co-authored-by: aMannus <mannusmenting@gmail.com> Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com> Co-authored-by: Dog <5172592+Dog@users.noreply.github.com> Co-authored-by: Vague Rant <vaguerant@users.noreply.github.com> Co-authored-by: Baoulettes <perlouzerie@hotmail.fr> Co-authored-by: Ada <60364512+GreatArgorath@users.noreply.github.com>
2022-07-11 20:11:07 -04:00
if (gSaveContext.n64ddFlag) {
// if we have beaten deku tree or have open forest turned on
// or have already shown mido we have an equipped sword/shield
if (gSaveContext.dungeonsDone[1] ||
Randomizer_GetSettingValue(RSK_FOREST) == 1 ||
gSaveContext.eventChkInf[0] & 0x10) {
testing out item replacement (#416) * skip learning song of storms * don't set flag when getting goron tunic as child * Initiates prelude check when master sword unloads. Not quite how N64 rando does it but so far it's the only way I've found to make it trigger without also triggering the time travel again. * Stops Shadow Temple lore prompts from appearing in rando. * Skips cutscene of royal tomb explosion in rando. Explosion sound doesn't play correctly and I think the debris appears in the wrong place, but the functionality is here. * Improves visual of exploding gravestone. * Adds some comments explaining the rando differences * Skip ruto text box in jabu blue warp For rando * skip intro cutscene in dodongo's cavern * load spoiler files on boot, fix spoilerfile existing check when making new saves * name entry dropped spoiler logic * make sure to actually init the cvar * no chime on load * uncomment * Skip ganondrof cutscene Skip to scream part of the death animation, skipping the text boxes etc. For rando * Update z_boss_ganondrof.c * skip owl flight cutscenes in rando * Fixes skipped text so it only applies to shadow temple. Earlier fix inadvertently applied to some other text as well, changed logic so that only specified sceneNums and textIds can have this enabled, and text skipped by sceneNum can have the skip overriden by textId if needed. Currently there are no overrides so the textId section of the logic is commented out to avoid compilation errors. * Adds a default to the switch case statements that leaves the randoSkipText variable unchanged, just in case. * TEST: Text for item * Adding ganon flavor text * ADD: AMMO Count * format ganon text/hint text * Autoskip the tower cutscene if settings call for tower collapse. * ganon hint text logic * Improved prelude after time travel fix * swapped the sizes between ganon hint text and ganon text, as they were set to the wrong things. * this is all i did * not the cleanest code ever but it's working * ADD: GS Count * ADD: Wallter (crash for now) * TWEAK: Wallet check * FIX: Use DrawItem instread of DrawUpgrade... b-baka! * Fixes some vanilla bugs introduced by rando code. * Added cutscene skip for zelda escaping Using the debug cutscene skipping function. Also added a conditional so the bridge doesn't spawn closed when cutscene is ready to trigger * ADD: X Spacing + Placeholders for song * ADD: default case for items * TWEAK: Spacing * FIX: Light Arrow * ADD: Ammo Option * use groups instead * ADD: More spacing logic * songs and names * TWEAK: Color on wallet * colors * Added flags cutscene before nabooru fight * ADD: ChromaKey text * First attempt skip cs after nabooru defeat * Better implementation for specific rando cutscene skips * use pulseaudio defaults * spaces/tabs * move color push/pop to stop crash * make the colors work again * the real bottle fix * pulseaudio values tuned for n64 audio at 44.1khz * update tlength * remove one hardcoded samplerate * Cleaned up and fixed zelda escape skip The if statement is a freaking monster, but unless we want to skip more cutscenes in the same way later, this is the most compact way of doing it that I know of. * Revert one line to match original nothing functional * another hint line that breaks autonewline logic * don't autospawn epona if we don't have the song/ocarina * Trying to use iron knuckle death effects not working yet * Streamlined OoT cutscene skip for future additions Also cleaned up if statement in general * Made if statement more readable Also added clarity for what cutscene was skipped * Fixed typo in comment * Janky nabooru defeat cs skip * altar text formatting (gonna need help shortening some of the french ones) * more altar text formatting * english altar text formatting complete * make gtg blocking guard check for card not bridge * FIX: Typo! * FIX: Uppercases * FIX: Typo * TWEAK: Alter + some names * TWEAK: More caps! * ADD: Missing string TWEAK more uppercases and namefixe s * Hide nabooru death by covering her in flames * bandaid fix for death crash issue * Twinrova defeat cs skip Skips the animation and manually calls the function to show the "beam" around the sisters * fix crash * fix caps to match * fix great fairy reward mashing/shielding issue * TWEAK : Typo clé to Clé * TWEAK: Some Altar hints TWEAK: Some capitals * TWEAK: Unmatching text + some cap again * TWEAK: More tweaks * fix build * remove extra json.hpp, add hint * Update randomizer_item_tracker.cpp * TWEAK: Double Defense with RedParticles instead of white * make sure we don't optimize out the check to ensure a spoilerfile exists * vanilla ganon boss key hint formatting * TWEAK: FR- better way of the hero text * fix * and again * Initializes dungeonsDone items in gSaveContext to 0. * Replaces sizeof calculation with a NUM_DUNGEONS constant. * Fixes Saria's Gift on the LW Bridge from getting killed when holding shield. * More airtight fix for Saria's Gift on the Bridge. * Lifts one of the conditions in the if statement a little higher to prevent unnecessary lookups of getItemId. * Invalidate text box icon before drawing * Fixes the case where Saria's gift is an Ice Trap. We still get the Ice Trap once, but never again. This does mean you can now hold R while walking in to avoid the ice trap, but everything else seems to work fine. * Initial commit Might need changing when we change the settings in the future * Fixes Door of Time opening cutscene after warping with prelude. * Initial waterfall skip Very rudimentary way of doing things but it seems to work so :shrug: * inital rework * fixed default rotation for 2D sprites * fix tab/space issues * 3d drops rando merge fix again * Allows Impa to appear in the Lullaby check post drawbridge escape. * Changes Ganon's Trials Count setting to a checkbox The checkbox is whether or not to skip all of them. Leaving the box unchecked will mean doing all of them. Eventually this will be switched back to a slider once we implement the logic for which trials start out completed. * Sets all Ganon's Trials to incomplete in new saves. Fixes https://github.com/briaguya-ai/rando-issue-tracker/issues/131 * fix castle guards when oot throw cutscene has already played in rando * Properly removes the beams when trials are cleared. * Removes Question Mark from Skip Ganon's Trials UI. * Adds a todo comment about when to change back to slider. * make deku seeds check for bullet bag * Various tweaks TWEAK: Altar Text TWEAK: Hint names TWEAK: Replace more problematic œ to oe * upgrade ocarina on both child and adult equips * FIX: Jabu Item * update equipped hookshot/longshot when obtained as other age * add hint * don't give the bgs check without the claim check * Skips Darunia Cutscene in Fire Temple * Added a TODO note about not skipping the cutscene. There is a setting we will want to have eventually that will require this cutscene to not be skipped since it is used during a glitch. * remove todo * restore fast ocarina option in imgui that was lost in merge * Fixes grey screen issue + tooltip for 2 handed shield * update to use dg instead of g for textures in item tracker * TWEAK: Default color for cosmetic RAND button was not the corect one * fix texture crash, remove unused item tracker code * don't open mask shop until we get zelda's letter * Update README.md * Prevents "correct" chime under incorrect conditions. * Fixes typo in conditional and adds "bonk" sound effect. "Bonk" sound is NA_SE_SY_OCARINA_ERROR and it plays when conditions for the Door of Time have not been met after playing Song of Time. This is only possible in rando's "Intended" Door of Time option, in which the Ocarina of Time and all 3 spritual stones are required to open the door, instead of the vanilla requirements of just having the song of time. * remove modify dpad equips toggle, replace with checks for dpad menu * remove extra check * add ability to hold c-up to assign to dpad when dpad menuing is enabled * disable d-pad navigation on item menu when holding c-up to equip * dpad+c-up stuff for equipment menu * ADD: Checbox for songs colors * TWEAK: RandoColors for normal songs * kind of quick and dirty but it works * TWEAK: Clarity of the tooltip Co-authored-by: briaguya <briaguya@alice> Co-authored-by: Christopher Leggett <chris@leggett.dev> Co-authored-by: aMannus <mannusmenting@gmail.com> Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com> Co-authored-by: Dog <5172592+Dog@users.noreply.github.com> Co-authored-by: Vague Rant <vaguerant@users.noreply.github.com> Co-authored-by: Baoulettes <perlouzerie@hotmail.fr> Co-authored-by: Ada <60364512+GreatArgorath@users.noreply.github.com>
2022-07-11 20:11:07 -04:00
return 0;
}
return 1;
}
if (!(gSaveContext.eventChkInf[1] & 0x1000) && !(gSaveContext.eventChkInf[4] & 1)) {
return 1;
}
}
if (globalCtx->sceneNum == SCENE_KOKIRI_HOME4) {
if (((gSaveContext.eventChkInf[1] & 0x1000) != 0) || ((gSaveContext.eventChkInf[4] & 1) != 0)) {
if (!LINK_IS_ADULT) {
return 1;
}
}
}
if (globalCtx->sceneNum == SCENE_SPOT10) {
return 1;
}
return 0;
}
void EnMd_UpdateEyes(EnMd* this) {
if (DECR(this->blinkTimer) == 0) {
this->eyeIdx++;
if (this->eyeIdx > 2) {
this->blinkTimer = Rand_S16Offset(30, 30);
this->eyeIdx = 0;
}
}
}
void func_80AAB158(EnMd* this, GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);
s16 absYawDiff;
s16 temp;
s16 temp2;
s16 yawDiff;
if (this->actor.xzDistToPlayer < 170.0f) {
yawDiff = (f32)this->actor.yawTowardsPlayer - this->actor.shape.rot.y;
absYawDiff = ABS(yawDiff);
temp = (absYawDiff <= func_800347E8(2)) ? 2 : 1;
temp2 = 1;
} else {
temp = 1;
temp2 = 0;
}
if (this->unk_1E0.unk_00 != 0) {
temp = 4;
}
if (this->actionFunc == func_80AABD0C) {
temp = 1;
temp2 = 0;
}
if (this->actionFunc == func_80AAB8F8) {
temp = 4;
temp2 = 1;
}
if ((globalCtx->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) {
this->unk_1E0.unk_18 = globalCtx->view.eye;
this->unk_1E0.unk_14 = 40.0f;
temp = 2;
} else {
this->unk_1E0.unk_18 = player->actor.world.pos;
this->unk_1E0.unk_14 = (gSaveContext.linkAge > 0) ? 0.0f : -18.0f;
}
func_80034A14(&this->actor, &this->unk_1E0, 2, temp);
if (this->actionFunc != func_80AABC10) {
if (temp2) {
func_800343CC(globalCtx, &this->actor, &this->unk_1E0.unk_00, this->collider.dim.radius + 30.0f,
EnMd_GetText, func_80AAAF04);
}
}
}
u8 EnMd_FollowPath(EnMd* this, GlobalContext* globalCtx) {
Path* path;
Vec3s* pointPos;
f32 pathDiffX;
f32 pathDiffZ;
if ((this->actor.params & 0xFF00) == 0xFF00) {
return 0;
}
path = &globalCtx->setupPathList[(this->actor.params & 0xFF00) >> 8];
pointPos = SEGMENTED_TO_VIRTUAL(path->points);
pointPos += this->waypoint;
pathDiffX = pointPos->x - this->actor.world.pos.x;
pathDiffZ = pointPos->z - this->actor.world.pos.z;
Math_SmoothStepToS(&this->actor.world.rot.y, Math_FAtan2F(pathDiffX, pathDiffZ) * (65536.0f / (2 * M_PI)), 4, 4000,
1);
if ((SQ(pathDiffX) + SQ(pathDiffZ)) < 100.0f) {
this->waypoint++;
if (this->waypoint >= path->count) {
this->waypoint = 0;
}
return 1;
}
return 0;
}
u8 EnMd_SetMovedPos(EnMd* this, GlobalContext* globalCtx) {
Path* path;
Vec3s* lastPointPos;
if ((this->actor.params & 0xFF00) == 0xFF00) {
return 0;
}
path = &globalCtx->setupPathList[(this->actor.params & 0xFF00) >> 8];
lastPointPos = SEGMENTED_TO_VIRTUAL(path->points);
lastPointPos += path->count - 1;
this->actor.world.pos.x = lastPointPos->x;
this->actor.world.pos.y = lastPointPos->y;
this->actor.world.pos.z = lastPointPos->z;
return 1;
}
void func_80AAB5A4(EnMd* this, GlobalContext* globalCtx) {
f32 temp;
if (globalCtx->sceneNum != SCENE_KOKIRI_HOME4) {
if (CVar_GetS32("gDisableKokiriDrawDistance", 0) != 0) {
temp = (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !(gSaveContext.eventChkInf[1] & 0x1000) &&
(globalCtx->sceneNum == SCENE_SPOT04))
? 100.0f
: 32767.0f;
} else {
temp = (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !(gSaveContext.eventChkInf[1] & 0x1000) &&
(globalCtx->sceneNum == SCENE_SPOT04))
? 100.0f
: 400.0f;
}
this->alpha = func_80034DD4(&this->actor, globalCtx, this->alpha, temp);
this->actor.shape.shadowAlpha = this->alpha;
} else {
this->alpha = 255;
this->actor.shape.shadowAlpha = this->alpha;
}
}
void EnMd_Init(Actor* thisx, GlobalContext* globalCtx) {
EnMd* this = (EnMd*)thisx;
s32 pad;
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 24.0f);
SkelAnime_InitFlex(globalCtx, &this->skelAnime, &gMidoSkel, NULL, this->jointTable, this->morphTable, 17);
Collider_InitCylinder(globalCtx, &this->collider);
Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit);
if (!EnMd_ShouldSpawn(this, globalCtx)) {
Actor_Kill(&this->actor);
return;
}
Animation_ChangeByInfo(&this->skelAnime, sAnimationInfo, ENMD_ANIM_0);
Actor_SetScale(&this->actor, 0.01f);
this->actor.targetMode = 6;
this->alpha = 255;
Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_ELF, this->actor.world.pos.x,
this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, FAIRY_KOKIRI);
if (((globalCtx->sceneNum == SCENE_SPOT04) && !(gSaveContext.eventChkInf[0] & 0x10)) ||
((globalCtx->sceneNum == SCENE_SPOT04) && (gSaveContext.eventChkInf[0] & 0x10) &&
CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD)) ||
((globalCtx->sceneNum == SCENE_SPOT10) && !(gSaveContext.eventChkInf[0] & 0x400))) {
this->actor.home.pos = this->actor.world.pos;
this->actionFunc = func_80AAB948;
return;
}
if (globalCtx->sceneNum != SCENE_KOKIRI_HOME4) {
EnMd_SetMovedPos(this, globalCtx);
}
this->actionFunc = func_80AAB874;
}
void EnMd_Destroy(Actor* thisx, GlobalContext* globalCtx) {
EnMd* this = (EnMd*)thisx;
Collider_DestroyCylinder(globalCtx, &this->collider);
}
void func_80AAB874(EnMd* this, GlobalContext* globalCtx) {
if (this->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) {
func_80034F54(globalCtx, this->unk_214, this->unk_236, 17);
} else if ((this->unk_1E0.unk_00 == 0) && (this->unk_20B != 7)) {
func_80AAA92C(this, 7);
}
func_80AAAA24(this);
}
void func_80AAB8F8(EnMd* this, GlobalContext* globalCtx) {
if (this->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) {
func_80034F54(globalCtx, this->unk_214, this->unk_236, 17);
}
func_80AAA93C(this);
}
void func_80AAB948(EnMd* this, GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);
f32 temp;
Actor* actorToBlock = &GET_PLAYER(globalCtx)->actor;
s16 yaw;
func_80AAAA24(this);
if (this->unk_1E0.unk_00 == 0) {
this->actor.world.rot.y = this->actor.yawTowardsPlayer;
this->actor.shape.rot.y = this->actor.yawTowardsPlayer;
yaw = Math_Vec3f_Yaw(&this->actor.home.pos, &actorToBlock->world.pos);
this->actor.world.pos.x = this->actor.home.pos.x;
this->actor.world.pos.x += 60.0f * Math_SinS(yaw);
this->actor.world.pos.z = this->actor.home.pos.z;
this->actor.world.pos.z += 60.0f * Math_CosS(yaw);
temp = fabsf((f32)this->actor.yawTowardsPlayer - yaw) * 0.001f * 3.0f;
this->skelAnime.playSpeed = CLAMP(temp, 1.0f, 3.0f);
}
if (this->unk_1E0.unk_00 == 2) {
if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !(gSaveContext.eventChkInf[1] & 0x1000) &&
(globalCtx->sceneNum == SCENE_SPOT04)) {
globalCtx->msgCtx.msgMode = MSGMODE_PAUSED;
}
if (globalCtx->sceneNum == SCENE_SPOT04) {
gSaveContext.eventChkInf[0] |= 0x10;
}
if (globalCtx->sceneNum == SCENE_SPOT10) {
gSaveContext.eventChkInf[0] |= 0x400;
}
func_80AAA92C(this, 3);
func_80AAA93C(this);
this->waypoint = 1;
this->unk_1E0.unk_00 = 0;
this->actionFunc = func_80AABD0C;
this->actor.speedXZ = 1.5f;
return;
}
if (this->skelAnime.animation == &gMidoHandsOnHipsIdleAnim) {
func_80034F54(globalCtx, this->unk_214, this->unk_236, 17);
}
if ((this->unk_1E0.unk_00 == 0) && (globalCtx->sceneNum == SCENE_SPOT10)) {
if (player->stateFlags2 & 0x1000000) {
player->stateFlags2 |= 0x2000000;
player->unk_6A8 = &this->actor;
func_8010BD58(globalCtx, OCARINA_ACTION_CHECK_SARIA);
this->actionFunc = func_80AABC10;
return;
}
if (this->actor.xzDistToPlayer < (30.0f + this->collider.dim.radius)) {
player->stateFlags2 |= 0x800000;
}
}
}
void func_80AABC10(EnMd* this, GlobalContext* globalCtx) {
Player* player = GET_PLAYER(globalCtx);
if (globalCtx->msgCtx.ocarinaMode >= OCARINA_MODE_04) {
this->actionFunc = func_80AAB948;
globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04;
} else if (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_03) {
Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
this->actor.textId = 0x1067;
func_8002F2CC(&this->actor, globalCtx, this->collider.dim.radius + 30.0f);
this->actionFunc = func_80AAB948;
globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04;
} else {
player->stateFlags2 |= 0x800000;
}
}
void func_80AABD0C(EnMd* this, GlobalContext* globalCtx) {
func_80034F54(globalCtx, this->unk_214, this->unk_236, 17);
func_80AAA93C(this);
if (!(EnMd_FollowPath(this, globalCtx)) || (this->waypoint != 0)) {
this->actor.shape.rot = this->actor.world.rot;
return;
}
if (CHECK_QUEST_ITEM(QUEST_KOKIRI_EMERALD) && !(gSaveContext.eventChkInf[1] & 0x1000) &&
(globalCtx->sceneNum == SCENE_SPOT04)) {
Message_CloseTextbox(globalCtx);
gSaveContext.eventChkInf[1] |= 0x1000;
Actor_Kill(&this->actor);
return;
}
func_80AAA92C(this, 11);
this->skelAnime.playSpeed = 0.0f;
this->actor.speedXZ = 0.0f;
this->actor.home.pos = this->actor.world.pos;
this->actionFunc = func_80AAB8F8;
}
void EnMd_Update(Actor* thisx, GlobalContext* globalCtx) {
EnMd* this = (EnMd*)thisx;
s32 pad;
Collider_UpdateCylinder(&this->actor, &this->collider);
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
SkelAnime_Update(&this->skelAnime);
EnMd_UpdateEyes(this);
func_80AAB5A4(this, globalCtx);
Actor_MoveForward(&this->actor);
func_80AAB158(this, globalCtx);
Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4);
this->actionFunc(this, globalCtx);
}
s32 EnMd_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx,
Gfx** gfx) {
EnMd* this = (EnMd*)thisx;
Vec3s vec;
if (limbIndex == 16) {
Matrix_Translate(1200.0f, 0.0f, 0.0f, MTXMODE_APPLY);
vec = this->unk_1E0.unk_08;
Matrix_RotateX((vec.y / 32768.0f) * M_PI, MTXMODE_APPLY);
Matrix_RotateZ((vec.x / 32768.0f) * M_PI, MTXMODE_APPLY);
Matrix_Translate(-1200.0f, 0.0f, 0.0f, MTXMODE_APPLY);
}
if (limbIndex == 9) {
vec = this->unk_1E0.unk_0E;
Matrix_RotateX((vec.x / 32768.0f) * M_PI, MTXMODE_APPLY);
Matrix_RotateY((vec.y / 32768.0f) * M_PI, MTXMODE_APPLY);
}
if (((limbIndex == 9) || (limbIndex == 10)) || (limbIndex == 13)) {
rot->y += Math_SinS(this->unk_214[limbIndex]) * 200.0f;
rot->z += Math_CosS(this->unk_236[limbIndex]) * 200.0f;
}
return false;
}
void EnMd_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx, Gfx** gfx) {
EnMd* this = (EnMd*)thisx;
Vec3f vec = { 400.0f, 0.0f, 0.0f };
if (limbIndex == 16) {
Matrix_MultVec3f(&vec, &this->actor.focus.pos);
}
}
void EnMd_Draw(Actor* thisx, GlobalContext* globalCtx) {
static void* sEyeTextures[] = {
gMidoEyeOpenTex,
gMidoEyeHalfTex,
gMidoEyeClosedTex,
};
EnMd* this = (EnMd*)thisx;
OPEN_DISPS(globalCtx->state.gfxCtx);
if (this->alpha == 255) {
gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIdx]));
func_80034BA0(globalCtx, &this->skelAnime, EnMd_OverrideLimbDraw, EnMd_PostLimbDraw, &this->actor, this->alpha);
} else if (this->alpha != 0) {
gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIdx]));
func_80034CC4(globalCtx, &this->skelAnime, EnMd_OverrideLimbDraw, EnMd_PostLimbDraw, &this->actor, this->alpha);
}
CLOSE_DISPS(globalCtx->state.gfxCtx);
}