diff --git a/Makefile b/Makefile index 892d0355b2..8782c02ad2 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ endif # Check code syntax with host compiler ifneq ($(RUN_CC_CHECK),0) - CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-label + CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces -Wno-int-conversion -Wno-unused-but-set-variable -Wno-unused-label -Wno-sign-compare -Wno-tautological-compare CC_CHECK := gcc -fno-builtin -fsyntax-only -funsigned-char -fdiagnostics-color -std=gnu89 -D _LANGUAGE_C -D NON_MATCHING $(IINC) -nostdinc $(CHECK_WARNINGS) ifneq ($(WERROR), 0) CC_CHECK += -Werror diff --git a/diff_settings.py b/diff_settings.py old mode 100755 new mode 100644 diff --git a/include/functions.h b/include/functions.h index 292c5e2104..bcc79f9e5e 100644 --- a/include/functions.h +++ b/include/functions.h @@ -726,8 +726,9 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s1 Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params); void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx); void Enemy_StartFinishingBlow(PlayState* play, Actor* actor); -s16 func_800BBAC0(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3); -s16 func_800BBB74(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3); +s16 func_800BBAC0(BlinkInfo* info, s16 arg1, s16 arg2, s16 arg3); +s16 func_800BBB74(BlinkInfo* info, s16 arg1, s16 arg2, s16 arg3); +s16 func_800BBC20(BlinkInfo* info, s16 arg1, s16 arg2, s16 arg3); void Actor_SpawnBodyParts(Actor* actor, PlayState* play, s32 partParams, Gfx** dList); void Actor_SpawnFloorDustRing(PlayState* play, Actor* actor, Vec3f* posXZ, f32 radius, s32 countMinusOne, f32 randAccelWeight, s16 scale, s16 scaleStep, u8 useLighting); void func_800BBFB0(PlayState* play, Vec3f* position, f32 arg2, s32 arg3, s16 arg4, s16 scaleStep, u8 arg6); diff --git a/include/macros.h b/include/macros.h index 9e74c40cd0..f2bcb07ddb 100644 --- a/include/macros.h +++ b/include/macros.h @@ -17,6 +17,8 @@ #define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0])) #define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0])) +#define ARRAY_COUNT_2D(arr) (ARRAY_COUNT(arr) * ARRAY_COUNT(arr[0])) + // TODO: After uintptr_t cast change should have an AVOID_UB target that just toggles the KSEG0 bit in the address rather than add/sub 0x80000000 #define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr) + RDRAM_CACHED) #define VIRTUAL_TO_PHYSICAL(addr) (uintptr_t)((u8*)(addr) - RDRAM_CACHED) diff --git a/include/z64.h b/include/z64.h index 6388bc1202..05aad655e3 100644 --- a/include/z64.h +++ b/include/z64.h @@ -82,11 +82,12 @@ #define Z_PRIORITY_IRQMGR 18 typedef enum { - /* 0 */ EQUIP_SLOT_B, - /* 1 */ EQUIP_SLOT_C_LEFT, - /* 2 */ EQUIP_SLOT_C_DOWN, - /* 3 */ EQUIP_SLOT_C_RIGHT, - /* 4 */ EQUIP_SLOT_A + /* -1 */ EQUIP_SLOT_NONE = -1, + /* 0 */ EQUIP_SLOT_B, + /* 1 */ EQUIP_SLOT_C_LEFT, + /* 2 */ EQUIP_SLOT_C_DOWN, + /* 3 */ EQUIP_SLOT_C_RIGHT, + /* 4 */ EQUIP_SLOT_A } EquipSlot; typedef struct { @@ -517,7 +518,7 @@ typedef struct PlayState { /* 0x18770 */ void (*unk_18770)(struct PlayState* play, Player* player); /* 0x18774 */ s32 (*startPlayerFishing)(struct PlayState* play); /* 0x18778 */ s32 (*grabPlayer)(struct PlayState* play, Player* player); - /* 0x1877C */ s32 (*startPlayerCutscene)(struct PlayState* play, Player* player, s32 mode); + /* 0x1877C */ s32 (*startPlayerCutscene)(struct PlayState* play, Player* player, PlayerCsMode csMode); /* 0x18780 */ void (*func_18780)(Player* player, struct PlayState* play); /* 0x18784 */ s32 (*damagePlayer)(struct PlayState* play, s32 damage); /* 0x18788 */ void (*talkWithPlayer)(struct PlayState* play, Actor* actor); diff --git a/include/z64actor.h b/include/z64actor.h index 3a646fe8fd..f587164010 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -739,6 +739,11 @@ typedef struct NpcInteractInfo { /* 0x24 */ UNK_TYPE1 unk_24[0x4]; } NpcInteractInfo; // size = 0x28 +typedef struct BlinkInfo { + /* 0x0 */ s16 eyeTexIndex; + /* 0x2 */ s16 blinkTimer; +} BlinkInfo; // size = 0x4 + extern TargetRangeParams gTargetRanges[]; extern s16 D_801AED48[8]; extern Gfx D_801AEF88[]; diff --git a/include/z64animation.h b/include/z64animation.h index 44c35312d7..316dfe3415 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -14,9 +14,13 @@ struct PlayerAnimationFrame; #define LIMB_DONE 0xFF #define ANIM_FLAG_1 (1 << 0) -#define ANIM_FLAG_UPDATEY (1 << 1) +#define ANIM_FLAG_UPDATE_Y (1 << 1) #define ANIM_FLAG_4 (1 << 2) +#define ANIM_FLAG_8 (1 << 3) #define ANIM_FLAG_NOMOVE (1 << 4) +#define ANIM_FLAG_80 (1 << 7) +#define ANIM_FLAG_100 (1 << 8) +#define ANIM_FLAG_200 (1 << 9) typedef enum AnimationMode { /* 0 */ ANIMMODE_LOOP, @@ -326,6 +330,7 @@ void AnimationContext_Update(struct PlayState* play, AnimationContext* animation void SkelAnime_InitPlayer(struct PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, PlayerAnimationHeader* animation, s32 flags, void* jointTableBuffer, void* morphTableBuffer, s32 limbBufCount); void PlayerAnimation_SetUpdateFunction(SkelAnime* skelAnime); s32 PlayerAnimation_Update(struct PlayState* play, SkelAnime* skelAnime); +void PlayerAnimation_AnimateFrame(struct PlayState* play, SkelAnime* skelAnime); void Animation_SetMorph(struct PlayState* play, SkelAnime* skelAnime, f32 morphFrames); void PlayerAnimation_Change(struct PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); void PlayerAnimation_PlayOnce(struct PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation); diff --git a/include/z64door.h b/include/z64door.h new file mode 100644 index 0000000000..26653c3081 --- /dev/null +++ b/include/z64door.h @@ -0,0 +1,24 @@ +#ifndef Z64_DOOR_H +#define Z64_DOOR_H + +#include "ultra64.h" +#include "z64actor.h" + +typedef struct KnobDoorActor { + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ SkelAnime skelAnime; + /* 0x1A0 */ u8 animIndex; + /* 0x1A1 */ u8 playOpenAnim; + /* 0x1A2 */ s8 requiredObjBankIndex; + /* 0x1A3 */ s8 dlIndex; +} KnobDoorActor; // size = 0x1A4 + +typedef struct SlidingDoorActor { + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s16 unk_15C; + /* 0x15E */ s16 unk_15E; +} SlidingDoorActor; // size = 0x160 + +#define DOOR_GET_TRANSITION_ID(thisx) ((u16)(thisx)->params >> 10) + +#endif diff --git a/include/z64effect.h b/include/z64effect.h index d6ab8b3b56..71ad80510c 100644 --- a/include/z64effect.h +++ b/include/z64effect.h @@ -118,10 +118,10 @@ typedef struct { /* 0x188 */ u16 flags; /* 0x18A */ s16 addAngleChange; /* 0x18C */ s16 addAngle; - /* 0x18E */ Color_RGBA8 p1StartColor; - /* 0x192 */ Color_RGBA8 p2StartColor; - /* 0x196 */ Color_RGBA8 p1EndColor; - /* 0x19A */ Color_RGBA8 p2EndColor; + /* 0x18E */ u8 p1StartColor[4]; + /* 0x192 */ u8 p2StartColor[4]; + /* 0x196 */ u8 p1EndColor[4]; + /* 0x19A */ u8 p2EndColor[4]; /* 0x19E */ u8 numElements; // "now_edge_num" /* 0x19F */ u8 elemDuration; /* 0x1A0 */ u8 unkFlag; diff --git a/include/z64item.h b/include/z64item.h index d1d36ebbad..345a228976 100644 --- a/include/z64item.h +++ b/include/z64item.h @@ -332,12 +332,16 @@ typedef enum GetItemId { /* 0x08 */ GI_WALLET_ADULT, /* 0x09 */ GI_WALLET_GIANT, /* 0x0A */ GI_RECOVERY_HEART, - /* 0x0C */ GI_HEART_PIECE = 0x0C, + /* 0x0B */ GI_0B, + /* 0x0C */ GI_HEART_PIECE, /* 0x0D */ GI_HEART_CONTAINER, /* 0x0E */ GI_MAGIC_SMALL, /* 0x0F */ GI_MAGIC_LARGE, - /* 0x11 */ GI_STRAY_FAIRY = 0x11, - /* 0x14 */ GI_BOMBS_1 = 0x14, + /* 0x10 */ GI_10, + /* 0x11 */ GI_STRAY_FAIRY, + /* 0x12 */ GI_12, + /* 0x13 */ GI_13, + /* 0x14 */ GI_BOMBS_1, /* 0x15 */ GI_BOMBS_5, /* 0x16 */ GI_BOMBS_10, /* 0x17 */ GI_BOMBS_20, @@ -360,8 +364,14 @@ typedef enum GetItemId { /* 0x28 */ GI_NUTS_1, /* 0x29 */ GI_NUTS_5, /* 0x2A */ GI_NUTS_10, - /* 0x2E */ GI_BOMBCHUS_20 = 0x2E, - /* 0x32 */ GI_SHIELD_HERO = 0x32, + /* 0x2B */ GI_2B, + /* 0x2C */ GI_2C, + /* 0x2D */ GI_2D, + /* 0x2E */ GI_BOMBCHUS_20, + /* 0x2F */ GI_2F, + /* 0x30 */ GI_30, + /* 0x31 */ GI_31, + /* 0x32 */ GI_SHIELD_HERO, /* 0x33 */ GI_SHIELD_MIRROR, /* 0x34 */ GI_POWDER_KEG, /* 0x35 */ GI_MAGIC_BEANS, @@ -379,10 +389,24 @@ typedef enum GetItemId { /* 0x41 */ GI_HOOKSHOT, /* 0x42 */ GI_LENS, /* 0x43 */ GI_PICTO_BOX, - /* 0x4C */ GI_OCARINA = 0x4C, - /* 0x50 */ GI_BOMBERS_NOTEBOOK = 0x50, - /* 0x52 */ GI_SKULL_TOKEN = 0x52, - /* 0x55 */ GI_REMAINS_ODOLWA = 0x55, + /* 0x44 */ GI_44, + /* 0x45 */ GI_45, + /* 0x46 */ GI_46, + /* 0x47 */ GI_47, + /* 0x48 */ GI_48, + /* 0x49 */ GI_49, + /* 0x4A */ GI_4A, + /* 0x4B */ GI_4B, + /* 0x4C */ GI_OCARINA, + /* 0x4D */ GI_4D, + /* 0x4E */ GI_4E, + /* 0x4F */ GI_4F, + /* 0x50 */ GI_BOMBERS_NOTEBOOK, + /* 0x51 */ GI_51, + /* 0x52 */ GI_SKULL_TOKEN, + /* 0x53 */ GI_53, + /* 0x54 */ GI_54, + /* 0x55 */ GI_REMAINS_ODOLWA, /* 0x56 */ GI_REMAINS_GOHT, /* 0x57 */ GI_REMAINS_GYORG, /* 0x58 */ GI_REMAINS_TWINMOLD, @@ -410,9 +434,14 @@ typedef enum GetItemId { /* 0x6E */ GI_SEAHORSE, /* 0x6F */ GI_CHATEAU_BOTTLE, /* 0x70 */ GI_HYLIAN_LOACH, - /* 0x75 */ GI_75 = 0x75, + /* 0x71 */ GI_71, + /* 0x72 */ GI_72, + /* 0x73 */ GI_73, + /* 0x74 */ GI_74, + /* 0x75 */ GI_75, /* 0x76 */ GI_ICE_TRAP, - /* 0x78 */ GI_MASK_DEKU = 0x78, + /* 0x77 */ GI_77, + /* 0x78 */ GI_MASK_DEKU, /* 0x79 */ GI_MASK_GORON, /* 0x7A */ GI_MASK_ZORA, /* 0x7B */ GI_MASK_FIERCE_DEITY, @@ -436,7 +465,8 @@ typedef enum GetItemId { /* 0x8D */ GI_MASK_BLAST, /* 0x8E */ GI_MASK_SCENTS, /* 0x8F */ GI_MASK_KAFEIS_MASK, - /* 0x91 */ GI_CHATEAU = 0x91, + /* 0x90 */ GI_90, + /* 0x91 */ GI_CHATEAU, /* 0x92 */ GI_MILK, /* 0x93 */ GI_GOLD_DUST_2, /* 0x94 */ GI_HYLIAN_LOACH_2, // Unused bottled eel @@ -463,7 +493,15 @@ typedef enum GetItemId { /* 0xA9 */ GI_BOTTLE_STOLEN, // buy back stolen bottle /* 0xAA */ GI_LETTER_TO_KAFEI, /* 0xAB */ GI_PENDANT_OF_MEMORIES, - /* 0xB4 */ GI_TINGLE_MAP_CLOCK_TOWN = 0xB4, + /* 0xAC */ GI_AC, + /* 0xAD */ GI_AD, + /* 0xAE */ GI_AE, + /* 0xAF */ GI_AF, + /* 0xB0 */ GI_B0, + /* 0xB1 */ GI_B1, + /* 0xB2 */ GI_B2, + /* 0xB3 */ GI_B3, + /* 0xB4 */ GI_TINGLE_MAP_CLOCK_TOWN, /* 0xB5 */ GI_TINGLE_MAP_WOODFALL, /* 0xB6 */ GI_TINGLE_MAP_SNOWHEAD, /* 0xB7 */ GI_TINGLE_MAP_ROMANI_RANCH, diff --git a/include/z64player.h b/include/z64player.h index 3bcc53fde3..d9c80384f0 100644 --- a/include/z64player.h +++ b/include/z64player.h @@ -43,35 +43,6 @@ typedef enum PlayerTransformation { /* 5 */ PLAYER_FORM_MAX } PlayerTransformation; -typedef enum PlayerMask { - /* 0x00 */ PLAYER_MASK_NONE, - /* 0x01 */ PLAYER_MASK_TRUTH, - /* 0x02 */ PLAYER_MASK_KAFEIS_MASK, - /* 0x03 */ PLAYER_MASK_ALL_NIGHT, - /* 0x04 */ PLAYER_MASK_BUNNY, - /* 0x05 */ PLAYER_MASK_KEATON, - /* 0x06 */ PLAYER_MASK_GARO, - /* 0x07 */ PLAYER_MASK_ROMANI, - /* 0x08 */ PLAYER_MASK_CIRCUS_LEADER, - /* 0x09 */ PLAYER_MASK_POSTMAN, - /* 0x0A */ PLAYER_MASK_COUPLE, - /* 0x0B */ PLAYER_MASK_GREAT_FAIRY, - /* 0x0C */ PLAYER_MASK_GIBDO, - /* 0x0D */ PLAYER_MASK_DON_GERO, - /* 0x0E */ PLAYER_MASK_KAMARO, - /* 0x0F */ PLAYER_MASK_CAPTAIN, - /* 0x10 */ PLAYER_MASK_STONE, - /* 0x11 */ PLAYER_MASK_BREMEN, - /* 0x12 */ PLAYER_MASK_BLAST, - /* 0x13 */ PLAYER_MASK_SCENTS, - /* 0x14 */ PLAYER_MASK_GIANT, - /* 0x15 */ PLAYER_MASK_FIERCE_DEITY, - /* 0x16 */ PLAYER_MASK_GORON, - /* 0x17 */ PLAYER_MASK_ZORA, - /* 0x18 */ PLAYER_MASK_DEKU, - /* 0x19 */ PLAYER_MASK_MAX -} PlayerMask; - typedef enum { /* 0 */ PLAYER_ENV_HAZARD_NONE, /* 1 */ PLAYER_ENV_HAZARD_HOTROOM, @@ -89,7 +60,7 @@ typedef enum PlayerItemAction { /* 0x03 */ PLAYER_IA_SWORD_KOKIRI = PLAYER_IA_SWORD_MIN, /* 0x04 */ PLAYER_IA_SWORD_RAZOR, /* 0x05 */ PLAYER_IA_SWORD_GILDED, - /* 0x06 */ PLAYER_IA_SWORD_GREAT_FAIRY, + /* 0x06 */ PLAYER_IA_SWORD_TWO_HANDED, /* 0x07 */ PLAYER_IA_STICK, /* 0x08 */ PLAYER_IA_ZORA_FINS, /* 0x09 */ PLAYER_IA_BOW, @@ -143,7 +114,8 @@ typedef enum PlayerItemAction { /* 0x37 */ PLAYER_IA_37, /* 0x38 */ PLAYER_IA_38, /* 0x39 */ PLAYER_IA_39, - /* 0x3A */ PLAYER_IA_MASK_TRUTH, + /* 0x3A */ PLAYER_IA_MASK_MIN, + /* 0x3A */ PLAYER_IA_MASK_TRUTH = PLAYER_IA_MASK_MIN, /* 0x3B */ PLAYER_IA_MASK_KAFEIS_MASK, /* 0x3C */ PLAYER_IA_MASK_ALL_NIGHT, /* 0x3D */ PLAYER_IA_MASK_BUNNY, @@ -163,10 +135,12 @@ typedef enum PlayerItemAction { /* 0x4B */ PLAYER_IA_MASK_BLAST, /* 0x4C */ PLAYER_IA_MASK_SCENTS, /* 0x4D */ PLAYER_IA_MASK_GIANT, - /* 0x4E */ PLAYER_IA_MASK_FIERCE_DEITY, + /* 0x4E */ PLAYER_IA_MASK_TRANSFORMATION_MIN, + /* 0x4E */ PLAYER_IA_MASK_FIERCE_DEITY = PLAYER_IA_MASK_TRANSFORMATION_MIN, /* 0x4F */ PLAYER_IA_MASK_GORON, /* 0x50 */ PLAYER_IA_MASK_ZORA, /* 0x51 */ PLAYER_IA_MASK_DEKU, + /* 0x51 */ PLAYER_IA_MASK_MAX = PLAYER_IA_MASK_DEKU, /* 0x52 */ PLAYER_IA_LENS, /* 0x53 */ PLAYER_IA_MAX } PlayerItemAction; @@ -190,12 +164,45 @@ typedef enum PlayerMeleeWeapon { /* 1 */ PLAYER_MELEEWEAPON_SWORD_KOKIRI = GET_MELEE_WEAPON_FROM_IA(PLAYER_IA_SWORD_KOKIRI), /* 2 */ PLAYER_MELEEWEAPON_SWORD_RAZOR = GET_MELEE_WEAPON_FROM_IA(PLAYER_IA_SWORD_RAZOR), /* 3 */ PLAYER_MELEEWEAPON_SWORD_GILDED = GET_MELEE_WEAPON_FROM_IA(PLAYER_IA_SWORD_GILDED), - /* 4 */ PLAYER_MELEEWEAPON_SWORD_GREAT_FAIRY = GET_MELEE_WEAPON_FROM_IA(PLAYER_IA_SWORD_GREAT_FAIRY), + /* 4 */ PLAYER_MELEEWEAPON_SWORD_TWO_HANDED = GET_MELEE_WEAPON_FROM_IA(PLAYER_IA_SWORD_TWO_HANDED), /* 5 */ PLAYER_MELEEWEAPON_STICK = GET_MELEE_WEAPON_FROM_IA(PLAYER_IA_STICK), /* 6 */ PLAYER_MELEEWEAPON_ZORA_FINS = GET_MELEE_WEAPON_FROM_IA(PLAYER_IA_ZORA_FINS), /* 7 */ PLAYER_MELEEWEAPON_MAX } PlayerMeleeWeapon; +// Relies on mask item actions to be contiguous +#define GET_MASK_FROM_IA(itemAction) ((itemAction) - (PLAYER_IA_MASK_MIN - 1)) +#define GET_IA_FROM_MASK(mask) ((mask) + (PLAYER_IA_MASK_MIN - 1)) + +typedef enum PlayerMask { + /* 0x00 */ PLAYER_MASK_NONE, + /* 0x01 */ PLAYER_MASK_TRUTH = GET_MASK_FROM_IA(PLAYER_IA_MASK_TRUTH), + /* 0x02 */ PLAYER_MASK_KAFEIS_MASK = GET_MASK_FROM_IA(PLAYER_IA_MASK_KAFEIS_MASK), + /* 0x03 */ PLAYER_MASK_ALL_NIGHT = GET_MASK_FROM_IA(PLAYER_IA_MASK_ALL_NIGHT), + /* 0x04 */ PLAYER_MASK_BUNNY = GET_MASK_FROM_IA(PLAYER_IA_MASK_BUNNY), + /* 0x05 */ PLAYER_MASK_KEATON = GET_MASK_FROM_IA(PLAYER_IA_MASK_KEATON), + /* 0x06 */ PLAYER_MASK_GARO = GET_MASK_FROM_IA(PLAYER_IA_MASK_GARO), + /* 0x07 */ PLAYER_MASK_ROMANI = GET_MASK_FROM_IA(PLAYER_IA_MASK_ROMANI), + /* 0x08 */ PLAYER_MASK_CIRCUS_LEADER = GET_MASK_FROM_IA(PLAYER_IA_MASK_CIRCUS_LEADER), + /* 0x09 */ PLAYER_MASK_POSTMAN = GET_MASK_FROM_IA(PLAYER_IA_MASK_POSTMAN), + /* 0x0A */ PLAYER_MASK_COUPLE = GET_MASK_FROM_IA(PLAYER_IA_MASK_COUPLE), + /* 0x0B */ PLAYER_MASK_GREAT_FAIRY = GET_MASK_FROM_IA(PLAYER_IA_MASK_GREAT_FAIRY), + /* 0x0C */ PLAYER_MASK_GIBDO = GET_MASK_FROM_IA(PLAYER_IA_MASK_GIBDO), + /* 0x0D */ PLAYER_MASK_DON_GERO = GET_MASK_FROM_IA(PLAYER_IA_MASK_DON_GERO), + /* 0x0E */ PLAYER_MASK_KAMARO = GET_MASK_FROM_IA(PLAYER_IA_MASK_KAMARO), + /* 0x0F */ PLAYER_MASK_CAPTAIN = GET_MASK_FROM_IA(PLAYER_IA_MASK_CAPTAIN), + /* 0x10 */ PLAYER_MASK_STONE = GET_MASK_FROM_IA(PLAYER_IA_MASK_STONE), + /* 0x11 */ PLAYER_MASK_BREMEN = GET_MASK_FROM_IA(PLAYER_IA_MASK_BREMEN), + /* 0x12 */ PLAYER_MASK_BLAST = GET_MASK_FROM_IA(PLAYER_IA_MASK_BLAST), + /* 0x13 */ PLAYER_MASK_SCENTS = GET_MASK_FROM_IA(PLAYER_IA_MASK_SCENTS), + /* 0x14 */ PLAYER_MASK_GIANT = GET_MASK_FROM_IA(PLAYER_IA_MASK_GIANT), + /* 0x15 */ PLAYER_MASK_FIERCE_DEITY = GET_MASK_FROM_IA(PLAYER_IA_MASK_FIERCE_DEITY), + /* 0x16 */ PLAYER_MASK_GORON = GET_MASK_FROM_IA(PLAYER_IA_MASK_GORON), + /* 0x17 */ PLAYER_MASK_ZORA = GET_MASK_FROM_IA(PLAYER_IA_MASK_ZORA), + /* 0x18 */ PLAYER_MASK_DEKU = GET_MASK_FROM_IA(PLAYER_IA_MASK_DEKU), + /* 0x19 */ PLAYER_MASK_MAX +} PlayerMask; + // Relies on bottle-related item actions to be contiguous #define GET_BOTTLE_FROM_IA(itemAction) ((itemAction) - PLAYER_IA_BOTTLE_MIN) @@ -244,7 +251,7 @@ typedef enum PlayerSword { /* 0 */ PLAYER_SWORD_KOKIRI = GET_SWORD_FROM_IA(PLAYER_IA_SWORD_KOKIRI), /* 1 */ PLAYER_SWORD_RAZOR = GET_SWORD_FROM_IA(PLAYER_IA_SWORD_RAZOR), /* 2 */ PLAYER_SWORD_GILDED = GET_SWORD_FROM_IA(PLAYER_IA_SWORD_GILDED), - /* 3 */ PLAYER_SWORD_GREAT_FAIRY = GET_SWORD_FROM_IA(PLAYER_IA_SWORD_GREAT_FAIRY), + /* 3 */ PLAYER_SWORD_TWO_HANDED = GET_SWORD_FROM_IA(PLAYER_IA_SWORD_TWO_HANDED), /* 4 */ PLAYER_SWORD_MAX } PlayerSword; @@ -287,6 +294,12 @@ typedef enum PlayerMeleeWeaponAnimation { /* 34 */ PLAYER_MWA_MAX } PlayerMeleeWeaponAnimation; +typedef enum PlayerMeleeWeaponState { + /* -1 */ PLAYER_MELEE_WEAPON_STATE_MINUS_1 = -1, + /* 0 */ PLAYER_MELEE_WEAPON_STATE_0, + /* 1 */ PLAYER_MELEE_WEAPON_STATE_1 +} PlayerMeleeWeaponState; + typedef enum PlayerDoorType { /* -1 */ PLAYER_DOORTYPE_TALKING = -1, // Displays a message instead of opening /* 0 */ PLAYER_DOORTYPE_NONE, @@ -300,13 +313,61 @@ typedef enum PlayerDoorType { typedef enum PlayerAnimType { /* 0 */ PLAYER_ANIMTYPE_DEFAULT, // DEFAULT /* 1 */ PLAYER_ANIMTYPE_1, - /* 2 */ PLAYER_ANIMTYPE_2, + /* 2 */ PLAYER_ANIMTYPE_2, // Shield but no sword? /* 3 */ PLAYER_ANIMTYPE_3, // Two hand weapon /* 4 */ PLAYER_ANIMTYPE_4, /* 5 */ PLAYER_ANIMTYPE_5, /* 6 */ PLAYER_ANIMTYPE_MAX } PlayerAnimType; +typedef enum PlayerAnimGroup { + /* 0 */ PLAYER_ANIMGROUP_0, // STANDING_IDLE + /* 1 */ PLAYER_ANIMGROUP_1, // WALKING + /* 2 */ PLAYER_ANIMGROUP_2, // RUNNING + /* 3 */ PLAYER_ANIMGROUP_3, + /* 4 */ PLAYER_ANIMGROUP_4, + /* 5 */ PLAYER_ANIMGROUP_5, // Z-Targeting ? + /* 6 */ PLAYER_ANIMGROUP_6, // Start or finishing some animation + /* 7 */ PLAYER_ANIMGROUP_7, // DRAW_MELEE_WEAPON + /* 8 */ PLAYER_ANIMGROUP_8, // OPEN_DOOR_LEFT_FIERCE_DEITY + /* 9 */ PLAYER_ANIMGROUP_9, // OPEN_DOOR_LEFT_HUMAN + /* 10 */ PLAYER_ANIMGROUP_10, // OPEN_DOOR_RIGHT_FIERCE_DEITY + /* 11 */ PLAYER_ANIMGROUP_11, // OPEN_DOOR_RIGHT_HUMAN + /* 12 */ PLAYER_ANIMGROUP_12, // GRABBING + /* 13 */ PLAYER_ANIMGROUP_13, // FALLING/LANDING? + /* 14 */ PLAYER_ANIMGROUP_14, // landing from short distances? + /* 15 */ PLAYER_ANIMGROUP_15, // ROLLING + /* 16 */ PLAYER_ANIMGROUP_16, // BONK/BONKING + /* 17 */ PLAYER_ANIMGROUP_17, + /* 18 */ PLAYER_ANIMGROUP_18, + /* 19 */ PLAYER_ANIMGROUP_19, // START_SHIELDING + /* 20 */ PLAYER_ANIMGROUP_20, // SHIELDING + /* 21 */ PLAYER_ANIMGROUP_21, // STOP_SHIELDING/END_SHIELDING + /* 22 */ PLAYER_ANIMGROUP_22, // SLOW_SIDE_WALK? + /* 23 */ PLAYER_ANIMGROUP_23, // SIDE_WALK + /* 24 */ PLAYER_ANIMGROUP_24, // SIDE_WALK_RIGHT + /* 25 */ PLAYER_ANIMGROUP_25, + /* 26 */ PLAYER_ANIMGROUP_26, + /* 27 */ PLAYER_ANIMGROUP_27, + /* 28 */ PLAYER_ANIMGROUP_28, // THROWING + /* 29 */ PLAYER_ANIMGROUP_29, // PUT_DOWN_OBJECT? + /* 30 */ PLAYER_ANIMGROUP_30, // back walking slow? + /* 31 */ PLAYER_ANIMGROUP_31, + /* 32 */ PLAYER_ANIMGROUP_32, + /* 33 */ PLAYER_ANIMGROUP_33, + /* 34 */ PLAYER_ANIMGROUP_34, // PULLING_START + /* 35 */ PLAYER_ANIMGROUP_35, // PULLING + /* 36 */ PLAYER_ANIMGROUP_36, // PULLING_END + /* 37 */ PLAYER_ANIMGROUP_37, // climbing from a ledge? + /* 38 */ PLAYER_ANIMGROUP_38, // ledge + /* 39 */ PLAYER_ANIMGROUP_39, // ledge + /* 40 */ PLAYER_ANIMGROUP_40, // climbing from a ledge + /* 41 */ PLAYER_ANIMGROUP_41, + /* 42 */ PLAYER_ANIMGROUP_42, + /* 43 */ PLAYER_ANIMGROUP_43, + /* 44 */ PLAYER_ANIMGROUP_MAX +} PlayerAnimGroup; + typedef enum PlayerModelType { // left hand /* 0 */ PLAYER_MODELTYPE_LH_OPEN, @@ -464,7 +525,7 @@ typedef struct PlayerAnimationFrame { #define GET_RIGHT_HAND_INDEX_FROM_JOINT_TABLE(jointTable) (GET_APPEARANCE_FROM_JOINT_TABLE(jointTable) & 0x0F00) typedef struct PlayerAgeProperties { - /* 0x00 */ f32 unk_00; // ceilingCheckHeight? + /* 0x00 */ f32 unk_00; // ceilingCheckHeight /* 0x04 */ f32 shadowScale; /* 0x08 */ f32 unk_08; /* 0x0C */ f32 unk_0C; @@ -478,7 +539,7 @@ typedef struct PlayerAgeProperties { /* 0x2C */ f32 unk_2C; // water stuff // depthInWater /* 0x30 */ f32 unk_30; // water stuff // depthInWater /* 0x34 */ f32 unk_34; - /* 0x38 */ f32 unk_38; // wallCheckHeight? + /* 0x38 */ f32 unk_38; // wallCheckHeight /* 0x3C */ f32 unk_3C; /* 0x40 */ f32 unk_40; /* 0x44 */ Vec3s unk_44; @@ -489,9 +550,9 @@ typedef struct PlayerAgeProperties { /* 0x94 */ u16 surfaceSfxIdOffset; /* 0x98 */ f32 unk_98; /* 0x9C */ f32 unk_9C; - /* 0xA0 */ PlayerAnimationHeader* unk_A0; - /* 0xA4 */ PlayerAnimationHeader* unk_A4; - /* 0xA8 */ PlayerAnimationHeader* unk_A8; + /* 0xA0 */ PlayerAnimationHeader* openChestAnim; + /* 0xA4 */ PlayerAnimationHeader* unk_A4; // OoT leftovers to interact with the Master Sword + /* 0xA8 */ PlayerAnimationHeader* unk_A8; // OoT leftovers to interact with the Master Sword /* 0xAC */ PlayerAnimationHeader* unk_AC; /* 0xB0 */ PlayerAnimationHeader* unk_B0; /* 0xB4 */ PlayerAnimationHeader* unk_B4[4]; @@ -547,7 +608,7 @@ typedef enum PlayerCsMode { /* 0x0F */ PLAYER_CSMODE_15, /* 0x10 */ PLAYER_CSMODE_16, /* 0x11 */ PLAYER_CSMODE_17, - /* 0x12 */ PLAYER_CSMODE_18, + /* 0x12 */ PLAYER_CSMODE_18, // Strangled by Wallmaster /* 0x13 */ PLAYER_CSMODE_19, /* 0x14 */ PLAYER_CSMODE_20, /* 0x15 */ PLAYER_CSMODE_21, @@ -555,7 +616,7 @@ typedef enum PlayerCsMode { /* 0x17 */ PLAYER_CSMODE_23, /* 0x18 */ PLAYER_CSMODE_24, /* 0x19 */ PLAYER_CSMODE_25, - /* 0x1A */ PLAYER_CSMODE_26, + /* 0x1A */ PLAYER_CSMODE_26, // Halt! /* 0x1B */ PLAYER_CSMODE_27, /* 0x1C */ PLAYER_CSMODE_28, /* 0x1D */ PLAYER_CSMODE_29, @@ -613,7 +674,7 @@ typedef enum PlayerCsMode { /* 0x51 */ PLAYER_CSMODE_81, /* 0x52 */ PLAYER_CSMODE_82, /* 0x53 */ PLAYER_CSMODE_83, - /* 0x54 */ PLAYER_CSMODE_84, + /* 0x54 */ PLAYER_CSMODE_84, // Sucked by the moon /* 0x55 */ PLAYER_CSMODE_85, /* 0x56 */ PLAYER_CSMODE_86, /* 0x57 */ PLAYER_CSMODE_87, @@ -867,10 +928,11 @@ typedef enum PlayerCsMode { #define PLAYER_STATE3_20000000 (1 << 29) // #define PLAYER_STATE3_40000000 (1 << 30) -// +// TARGETING_HOSTILE? #define PLAYER_STATE3_80000000 (1 << 31) +#define PLAYER_GET_BG_CAM_INDEX(thisx) ((thisx)->params & 0xFF) #define PLAYER_GET_INITMODE(thisx) (((thisx)->params & 0xF00) >> 8) typedef enum PlayerInitMode { @@ -894,6 +956,15 @@ typedef enum PlayerInitMode { #define PLAYER_PARAMS(startBgCamIndex, initMode) ((startBgCamIndex & 0xFF) | ((initMode & 0xF) << 8)) +typedef enum PlayerUnkAA5 { + /* 0 */ PLAYER_UNKAA5_0, + /* 1 */ PLAYER_UNKAA5_1, + /* 2 */ PLAYER_UNKAA5_2, + /* 3 */ PLAYER_UNKAA5_3, + /* 4 */ PLAYER_UNKAA5_4, + /* 5 */ PLAYER_UNKAA5_5, +} PlayerUnkAA5; + typedef void (*PlayerActionFunc)(struct Player* this, struct PlayState* play); typedef s32 (*PlayerFuncAC4)(struct Player* this, struct PlayState* play); typedef void (*PlayerFuncD58)(struct PlayState* play, struct Player* this); @@ -917,31 +988,13 @@ typedef struct Player { /* 0x151 */ u8 rightHandType; /* 0x152 */ u8 sheathType; /* 0x153 */ u8 currentMask; // PlayerMask enum - /* 0x154 */ s8 unk_154; + /* 0x154 */ s8 unk_154; // EquipSlot enum // Last pressed equip slot? /* 0x155 */ u8 prevMask; /* 0x158 */ Gfx** rightHandDLists; /* 0x15C */ Gfx** leftHandDLists; /* 0x160 */ Gfx** sheathDLists; /* 0x164 */ Gfx** waistDLists; - /* 0x168 */ f32 unk_168; - /* 0x16C */ f32 unk_16C; - /* 0x170 */ f32 unk_170; - /* 0x174 */ f32 unk_174; - /* 0x178 */ f32 unk_178; - /* 0x17C */ f32 unk_17C; - /* 0x180 */ f32 unk_180; - /* 0x184 */ f32 unk_184; - /* 0x188 */ f32 unk_188; - /* 0x18C */ f32 unk_18C; - /* 0x190 */ f32 unk_190; - /* 0x194 */ f32 unk_194; - /* 0x198 */ f32 unk_198; - /* 0x19C */ f32 unk_19C; - /* 0x1A0 */ f32 unk_1A0; - /* 0x1A4 */ f32 unk_1A4; - /* 0x1A8 */ f32 unk_1A8; - /* 0x1AC */ f32 unk_1AC; - /* 0x1B0 */ f32 unk_1B0; + /* 0x168 */ UNK_TYPE1 unk_168[0x4C]; /* 0x1B4 */ s16 unk_1B4; /* 0x1B6 */ char unk_1B6[2]; /* 0x1B8 */ u8 giObjectLoading; @@ -960,8 +1013,7 @@ typedef struct Player { /* 0x2C8 */ SkelAnime unk_2C8; /* 0x30C */ Vec3s jointTable[5]; /* 0x32A */ Vec3s morphTable[5]; - /* 0x348 */ s16 eyeTexId; - /* 0x34A */ s16 eyeAnimTimer; + /* 0x348 */ BlinkInfo blinkInfo; /* 0x34C */ Actor* heldActor; /* 0x350 */ PosRot leftHandWorld; /* 0x364 */ Actor* rightHandActor; @@ -980,12 +1032,12 @@ typedef struct Player { /* 0x395 */ u8 prevCsMode; // PlayerCsMode enum /* 0x396 */ u8 unk_396; // currentActorActionId? /* 0x397 */ u8 unk_397; // PlayerDoorType enum - /* 0x398 */ Actor* unk_398; + /* 0x398 */ Actor* unk_398; // csActor? /* 0x39C */ UNK_TYPE1 unk_39C[0x4]; /* 0x3A0 */ Vec3f unk_3A0; /* 0x3AC */ Vec3f unk_3AC; /* 0x3B8 */ u16 unk_3B8; - /* 0x3BA */ s16 unk_3BA; + /* 0x3BA */ s16 doorBgCamIndex; /* 0x3BC */ s16 subCamId; /* 0x3BE */ char unk_3BE[2]; /* 0x3C0 */ Vec3f unk_3C0; @@ -1028,7 +1080,7 @@ typedef struct Player { /* 0xA9C */ f32 secretRumbleCharge; // builds per frame until discharges with a rumble request /* 0xAA0 */ f32 closestSecretDistSq; // Used to augment `secretRumbleCharge`. Cleared every frame /* 0xAA4 */ s8 unk_AA4; - /* 0xAA5 */ u8 unk_AA5; + /* 0xAA5 */ u8 unk_AA5; // PlayerUnkAA5 enum /* 0xAA6 */ u16 unk_AA6; // flags of some kind /* 0xAA8 */ s16 unk_AA8; /* 0xAAA */ s16 unk_AAA; @@ -1049,20 +1101,21 @@ typedef struct Player { /* 0xADA */ s8 meleeWeaponAnimation; /* 0xADB */ s8 meleeWeaponState; /* 0xADC */ s8 unk_ADC; - /* 0xADD */ s8 unk_ADD; + /* 0xADD */ s8 unk_ADD; // Some sort of combo counter /* 0xADE */ u8 unk_ADE; /* 0xADF */ s8 unk_ADF[4]; // Circular buffer used for testing for triggering a quickspin /* 0xAE3 */ s8 unk_AE3[4]; // Circular buffer used for ? - /* 0xAE7 */ s8 unk_AE7; // a timer + /* 0xAE7 */ s8 unk_AE7; // a timer, used as an index for multiple kinds of animations too, room index?, etc /* 0xAE8 */ s16 unk_AE8; // multipurpose timer /* 0xAEC */ f32 unk_AEC; - /* 0xAF0 */ union { // TODO: this may be an union of two structs + /* 0xAF0 */ union { Vec3f unk_AF0[2]; f32 arr_AF0[6]; }; - /* 0xB08 */ f32 unk_B08[2]; // TODO: Investigate if this member actually is an array + /* 0xB08 */ f32 unk_B08; + /* 0xB0C */ f32 unk_B0C; /* 0xB10 */ f32 unk_B10[6]; - /* 0xB28 */ s16 unk_B28; //Burning stick timer? + /* 0xB28 */ s16 unk_B28; // Burning stick timer? /* 0xB2A */ s8 getItemDrawIdPlusOne; /* 0xB2B */ s8 unk_B2B; /* 0xB2C */ f32 windSpeed; @@ -1088,7 +1141,7 @@ typedef struct Player { /* 0xB64 */ u8 unk_B64; /* 0xB65 */ u8 shockTimer; /* 0xB66 */ u8 unk_B66; - /* 0xB67 */ u8 unk_B67; // deku remaining hops counter + /* 0xB67 */ u8 remainingHopsCounter; // Deku hopping on water /* 0xB68 */ s16 fallStartHeight; // last truncated Y position before falling /* 0xB6A */ s16 fallDistance; // truncated Y distance the player has fallen so far (positive is down) /* 0xB6C */ s16 unk_B6C; @@ -1100,8 +1153,8 @@ typedef struct Player { /* 0xB76 */ s16 unk_B76; /* 0xB78 */ f32 unk_B78; /* 0xB7C */ f32 unk_B7C; - /* 0xB80 */ f32 unk_B80; - /* 0xB84 */ s16 unk_B84; + /* 0xB80 */ f32 pushedSpeed; // Pushing player, examples include water currents, floor conveyors, climbing sloped surfaces + /* 0xB84 */ s16 pushedYaw; // Yaw of direction in which player is being pushed /* 0xB86 */ s16 unk_B86[2]; // unknown length /* 0xB8A */ s16 unk_B8A; /* 0xB8C */ s16 unk_B8C; @@ -1112,7 +1165,7 @@ typedef struct Player { /* 0xB96 */ s16 unk_B96; /* 0xB98 */ WeaponInfo meleeWeaponInfo[3]; /* 0xBEC */ Vec3f bodyPartsPos[PLAYER_BODYPART_MAX]; - /* 0xCC4 */ MtxF mf_CC4; + /* 0xCC4 */ MtxF leftHandMf; /* 0xD04 */ MtxF shieldMf; /* 0xD44 */ u8 isBurning; /* 0xD45 */ u8 flameTimers[PLAYER_BODYPART_MAX]; // one flame per body part @@ -1120,8 +1173,7 @@ typedef struct Player { /* 0xD58 */ PlayerFuncD58 unk_D58; /* 0xD5C */ s8 invincibilityTimer; // prevents damage when nonzero (positive = visible, counts towards zero each frame) /* 0xD5D */ u8 unk_D5D; - /* 0xD5E */ u8 unk_D5E; - /* 0xD5F */ u8 unk_D5F; + /* 0xD5E */ u8 floorProperty; // FloorProperty enum /* 0xD60 */ f32 unk_D60; /* 0xD64 */ s16 unk_D64; /* 0xD66 */ u16 unk_D66; // sfx diff --git a/include/z64save.h b/include/z64save.h index 9d580803f1..01acfed0eb 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -338,7 +338,7 @@ typedef struct SaveContext { /* 0x3DB8 */ u16 entranceSound; // "player_wipe_door_SE" /* 0x3DBA */ u8 unk_3DBA; // "player_wipe_item" /* 0x3DBB */ u8 unk_3DBB; // "next_walk" - /* 0x3DBC */ s16 dogParams; // "dog_flag" + /* 0x3DBC */ s16 dogParams; // OoT leftover. "dog_flag" /* 0x3DBE */ u8 envHazardTextTriggerFlags; // "guide_status" /* 0x3DBF */ u8 showTitleCard; // "name_display" /* 0x3DC0 */ s16 unk_3DC0; // "shield_magic_timer" diff --git a/spec b/spec index 81f25e3745..003c76dd4e 100644 --- a/spec +++ b/spec @@ -700,9 +700,7 @@ beginseg name "ovl_player_actor" compress include "build/src/overlays/actors/ovl_player_actor/z_player.o" - include "build/data/ovl_player_actor/ovl_player_actor.data.o" - include "build/data/ovl_player_actor/ovl_player_actor.bss.o" - include "build/data/ovl_player_actor/ovl_player_actor.reloc.o" + include "build/src/overlays/actors/ovl_player_actor/ovl_player_actor_reloc.o" endseg beginseg diff --git a/src/boot_O2_g3/boot_main.c b/src/boot_O2_g3/boot_main.c index 7b8d7126bf..6a561992b3 100644 --- a/src/boot_O2_g3/boot_main.c +++ b/src/boot_O2_g3/boot_main.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" #include "stack.h" #include "stackcheck.h" diff --git a/src/code/z_actor.c b/src/code/z_actor.c index a5ca767dcd..ffa77e9bf4 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1374,7 +1374,7 @@ s32 func_800B724C(PlayState* play, Actor* actor, u8 csMode) { player->csMode = csMode; player->unk_398 = actor; - player->unk_3BA = 0; + player->doorBgCamIndex = 0; return true; } @@ -1382,7 +1382,7 @@ s32 func_800B7298(PlayState* play, Actor* actor, u8 csMode) { Player* player = GET_PLAYER(play); if (func_800B724C(play, actor, csMode)) { - player->unk_3BA = 1; + player->doorBgCamIndex = 1; return true; } return false; @@ -3490,49 +3490,50 @@ void Enemy_StartFinishingBlow(PlayState* play, Actor* actor) { } // blinking routine -s16 func_800BBAC0(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3) { - if (DECR(arg0[1]) == 0) { - arg0[1] = Rand_S16Offset(arg1, arg2); +s16 func_800BBAC0(BlinkInfo* info, s16 arg1, s16 arg2, s16 arg3) { + if (DECR(info->blinkTimer) == 0) { + info->blinkTimer = Rand_S16Offset(arg1, arg2); } - if (arg0[1] - arg3 > 0) { - arg0[0] = 0; - } else if ((arg0[1] - arg3 >= -1) || (arg0[1] < 2)) { - arg0[0] = 1; + if (info->blinkTimer - arg3 > 0) { + info->eyeTexIndex = 0; + } else if ((info->blinkTimer - arg3 >= -1) || (info->blinkTimer < 2)) { + info->eyeTexIndex = 1; } else { - arg0[0] = 2; + info->eyeTexIndex = 2; } - return arg0[0]; + return info->eyeTexIndex; } // blinking routine -s16 func_800BBB74(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3) { - if (DECR(arg0[1]) == 0) { - arg0[1] = Rand_S16Offset(arg1, arg2); +s16 func_800BBB74(BlinkInfo* info, s16 arg1, s16 arg2, s16 arg3) { + if (DECR(info->blinkTimer) == 0) { + info->blinkTimer = Rand_S16Offset(arg1, arg2); } - if (arg0[1] - arg3 > 0) { - arg0[0] = 0; - } else if (arg0[1] - arg3 == 0) { - arg0[0] = 1; + if (info->blinkTimer - arg3 > 0) { + info->eyeTexIndex = 0; + } else if (info->blinkTimer - arg3 == 0) { + info->eyeTexIndex = 1; } else { - arg0[0] = 2; + info->eyeTexIndex = 2; } - return arg0[0]; + return info->eyeTexIndex; } // unused blinking routine -s16 func_800BBC20(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3) { - if (DECR(arg0[1]) == 0) { - arg0[1] = Rand_S16Offset(arg1, arg2); - arg0[0]++; - if ((arg0[0] % 3) == 0) { - arg0[0] = (s32)(Rand_ZeroOne() * arg3) * 3; +s16 func_800BBC20(BlinkInfo* info, s16 arg1, s16 arg2, s16 arg3) { + if (DECR(info->blinkTimer) == 0) { + info->blinkTimer = Rand_S16Offset(arg1, arg2); + info->eyeTexIndex++; + if ((info->eyeTexIndex % 3) == 0) { + info->eyeTexIndex = (s32)(Rand_ZeroOne() * arg3) * 3; } } - return arg0[0]; + + return info->eyeTexIndex; } void Actor_SpawnBodyParts(Actor* actor, PlayState* play, s32 partParams, Gfx** dList) { @@ -3614,15 +3615,15 @@ void func_800BC154(PlayState* play, ActorContext* actorCtx, Actor* actor, u8 act // Damage flags for EnArrow u32 sArrowDmgFlags[] = { - DMG_FIRE_ARROW, // ENARROW_0 - DMG_NORMAL_ARROW, // ENARROW_1 - DMG_NORMAL_ARROW, // ENARROW_2 - DMG_FIRE_ARROW, // ENARROW_3 - DMG_ICE_ARROW, // ENARROW_4 - DMG_LIGHT_ARROW, // ENARROW_5 - DMG_DEKU_NUT, // ENARROW_6 - DMG_DEKU_BUBBLE, // ENARROW_7 - DMG_DEKU_NUT, // ENARROW_8 + DMG_FIRE_ARROW, // ARROW_TYPE_NORMAL_LIT + DMG_NORMAL_ARROW, // ARROW_TYPE_NORMAL_HORSE + DMG_NORMAL_ARROW, // ARROW_TYPE_NORMAL + DMG_FIRE_ARROW, // ARROW_TYPE_FIRE + DMG_ICE_ARROW, // ARROW_TYPE_ICE + DMG_LIGHT_ARROW, // ARROW_TYPE_LIGHT + DMG_DEKU_NUT, // ARROW_TYPE_SLINGSHOT + DMG_DEKU_BUBBLE, // ARROW_TYPE_DEKU_BUBBLE + DMG_DEKU_NUT, // ARROW_TYPE_DEKU_NUT }; u32 Actor_GetArrowDmgFlags(s32 params) { @@ -4476,7 +4477,7 @@ s32 func_800BE184(PlayState* play, Actor* actor, f32 xzDist, s16 arg3, s16 arg4, s16 phi_v0 = BINANG_SUB(BINANG_ROT180(actor->yawTowardsPlayer), player->actor.shape.rot.y); s16 temp_t0 = actor->yawTowardsPlayer - arg5; - if ((actor->xzDistToPlayer <= xzDist) && (player->meleeWeaponState != 0)) { + if ((actor->xzDistToPlayer <= xzDist) && (player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0)) { if ((arg4 >= ABS_ALT(phi_v0)) && (arg3 >= ABS_ALT(temp_t0))) { return true; } diff --git a/src/code/z_camera.c b/src/code/z_camera.c index ea600b30e9..89b1489421 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -465,13 +465,13 @@ s32 func_800CBA7C(Camera* camera) { } } -s32 func_800CBAAC(Camera* camera) { +PlayerMeleeWeaponState func_800CBAAC(Camera* camera) { Actor* focalActor = camera->focalActor; if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { return ((Player*)focalActor)->meleeWeaponState; } else { - return 0; + return PLAYER_MELEE_WEAPON_STATE_0; } } @@ -506,13 +506,13 @@ s32 func_800CBB88(Camera* camera) { Actor* focalActor = camera->focalActor; if (camera->focalActor == &GET_PLAYER(camera->play)->actor) { - if ((((Player*)focalActor)->meleeWeaponState != 0) && + if ((((Player*)focalActor)->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) && (((Player*)focalActor)->meleeWeaponAnimation == PLAYER_MWA_GORON_PUNCH_BUTT)) { return 3; } if ((((Player*)focalActor)->stateFlags2 & PLAYER_STATE2_20000) || - ((((Player*)focalActor)->meleeWeaponState != 0) && + ((((Player*)focalActor)->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) && (((Player*)focalActor)->meleeWeaponAnimation == PLAYER_MWA_ZORA_PUNCH_KICK))) { return 1; } @@ -3958,7 +3958,7 @@ s32 Camera_Battle1(Camera* camera) { } camera->roll = Camera_ScaledStepToCeilS(sp88, camera->roll, 0.06f, 5); - if (func_800CBAAC(camera) != 0) { + if (func_800CBAAC(camera) != PLAYER_MELEE_WEAPON_STATE_0) { phi_f12 = ((camera->play->state.frames & 8) != 0) ? roData->unk_20 - (roData->unk_20 * 0.5f) : roData->unk_20; } else { phi_f12 = ((gSaveContext.save.saveInfo.playerData.health <= 16) ? 0.8f : 1.0f) * (sp78 - (sp78 * 0.05f * spEC)); diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index 5f02219698..520431401a 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -114,23 +114,17 @@ void EffectBlure_Init1(void* thisx, void* initParamsx) { EffectBlureInit1* initParams = (EffectBlureInit1*)initParamsx; if ((this != NULL) && (initParams != NULL)) { + s32 i; + EffectBlure_InitElements(this); - this->p1StartColor.r = initParams->p1StartColor[0]; - this->p2StartColor.r = initParams->p2StartColor[0]; - this->p1EndColor.r = initParams->p1EndColor[0]; - this->p2EndColor.r = initParams->p2EndColor[0]; - this->p1StartColor.g = initParams->p1StartColor[1]; - this->p2StartColor.g = initParams->p2StartColor[1]; - this->p1EndColor.g = initParams->p1EndColor[1]; - this->p2EndColor.g = initParams->p2EndColor[1]; - this->p1StartColor.b = initParams->p1StartColor[2]; - this->p2StartColor.b = initParams->p2StartColor[2]; - this->p1EndColor.b = initParams->p1EndColor[2]; - this->p2EndColor.b = initParams->p2EndColor[2]; - this->p1StartColor.a = initParams->p1StartColor[3]; - this->p2StartColor.a = initParams->p2StartColor[3]; - this->p1EndColor.a = initParams->p1EndColor[3]; - this->p2EndColor.a = initParams->p2EndColor[3]; + + for (i = 0; i < 4; i++) { + this->p1StartColor[i] = initParams->p1StartColor[i]; + this->p2StartColor[i] = initParams->p2StartColor[i]; + this->p1EndColor[i] = initParams->p1EndColor[i]; + this->p2EndColor[i] = initParams->p2EndColor[i]; + } + this->elemDuration = initParams->elemDuration; this->unkFlag = initParams->unkFlag; this->calcMode = initParams->calcMode; @@ -155,23 +149,17 @@ void EffectBlure_Init2(void* thisx, void* initParamsx) { EffectBlureInit2* initParams = (EffectBlureInit2*)initParamsx; if ((this != NULL) && (initParams != NULL)) { + s32 i; + EffectBlure_InitElements(this); - this->p1StartColor.r = initParams->p1StartColor[0]; - this->p2StartColor.r = initParams->p2StartColor[0]; - this->p1EndColor.r = initParams->p1EndColor[0]; - this->p2EndColor.r = initParams->p2EndColor[0]; - this->p1StartColor.g = initParams->p1StartColor[1]; - this->p2StartColor.g = initParams->p2StartColor[1]; - this->p1EndColor.g = initParams->p1EndColor[1]; - this->p2EndColor.g = initParams->p2EndColor[1]; - this->p1StartColor.b = initParams->p1StartColor[2]; - this->p2StartColor.b = initParams->p2StartColor[2]; - this->p1EndColor.b = initParams->p1EndColor[2]; - this->p2EndColor.b = initParams->p2EndColor[2]; - this->p1StartColor.a = initParams->p1StartColor[3]; - this->p2StartColor.a = initParams->p2StartColor[3]; - this->p1EndColor.a = initParams->p1EndColor[3]; - this->p2EndColor.a = initParams->p2EndColor[3]; + + for (i = 0; i < 4; i++) { + this->p1StartColor[i] = initParams->p1StartColor[i]; + this->p2StartColor[i] = initParams->p2StartColor[i]; + this->p1EndColor[i] = initParams->p1EndColor[i]; + this->p2EndColor[i] = initParams->p2EndColor[i]; + } + this->elemDuration = initParams->elemDuration; this->unkFlag = initParams->unkFlag; this->calcMode = initParams->calcMode; @@ -372,14 +360,14 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3 color1->r = color1->g = color1->b = color1->a = 255; color2->r = color2->g = color2->b = color2->a = 255; } else { - color1->r = func_800B0A24(this->p1StartColor.r, this->p1EndColor.r, ratio); - color1->g = func_800B0A24(this->p1StartColor.g, this->p1EndColor.g, ratio); - color1->b = func_800B0A24(this->p1StartColor.b, this->p1EndColor.b, ratio); - color1->a = func_800B0A24(this->p1StartColor.a, this->p1EndColor.a, ratio); - color2->r = func_800B0A24(this->p2StartColor.r, this->p2EndColor.r, ratio); - color2->g = func_800B0A24(this->p2StartColor.g, this->p2EndColor.g, ratio); - color2->b = func_800B0A24(this->p2StartColor.b, this->p2EndColor.b, ratio); - color2->a = func_800B0A24(this->p2StartColor.a, this->p2EndColor.a, ratio); + color1->r = func_800B0A24(this->p1StartColor[0], this->p1EndColor[0], ratio); + color1->g = func_800B0A24(this->p1StartColor[1], this->p1EndColor[1], ratio); + color1->b = func_800B0A24(this->p1StartColor[2], this->p1EndColor[2], ratio); + color1->a = func_800B0A24(this->p1StartColor[3], this->p1EndColor[3], ratio); + color2->r = func_800B0A24(this->p2StartColor[0], this->p2EndColor[0], ratio); + color2->g = func_800B0A24(this->p2StartColor[1], this->p2EndColor[1], ratio); + color2->b = func_800B0A24(this->p2StartColor[2], this->p2EndColor[2], ratio); + color2->a = func_800B0A24(this->p2StartColor[3], this->p2EndColor[3], ratio); } } @@ -992,19 +980,19 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { vtx[j].v.flag = 0; vtx[j].v.tc[0] = 0; vtx[j].v.tc[1] = 0; - vtx[j].v.cn[0] = func_800B0A24(this->p1StartColor.r, this->p1EndColor.r, ratio); - vtx[j].v.cn[1] = func_800B0A24(this->p1StartColor.g, this->p1EndColor.g, ratio); - vtx[j].v.cn[2] = func_800B0A24(this->p1StartColor.b, this->p1EndColor.b, ratio); - vtx[j].v.cn[3] = func_800B0A24(this->p1StartColor.a, this->p1EndColor.a, ratio); + vtx[j].v.cn[0] = func_800B0A24(this->p1StartColor[0], this->p1EndColor[0], ratio); + vtx[j].v.cn[1] = func_800B0A24(this->p1StartColor[1], this->p1EndColor[1], ratio); + vtx[j].v.cn[2] = func_800B0A24(this->p1StartColor[2], this->p1EndColor[2], ratio); + vtx[j].v.cn[3] = func_800B0A24(this->p1StartColor[3], this->p1EndColor[3], ratio); j++; vtx[j].v.flag = 0; vtx[j].v.tc[0] = 0; vtx[j].v.tc[1] = 0; - vtx[j].v.cn[0] = func_800B0A24(this->p2StartColor.r, this->p2EndColor.r, ratio); - vtx[j].v.cn[1] = func_800B0A24(this->p2StartColor.g, this->p2EndColor.g, ratio); - vtx[j].v.cn[2] = func_800B0A24(this->p2StartColor.b, this->p2EndColor.b, ratio); - vtx[j].v.cn[3] = func_800B0A24(this->p2StartColor.a, this->p2EndColor.a, ratio); + vtx[j].v.cn[0] = func_800B0A24(this->p2StartColor[0], this->p2EndColor[0], ratio); + vtx[j].v.cn[1] = func_800B0A24(this->p2StartColor[1], this->p2EndColor[1], ratio); + vtx[j].v.cn[2] = func_800B0A24(this->p2StartColor[2], this->p2EndColor[2], ratio); + vtx[j].v.cn[3] = func_800B0A24(this->p2StartColor[3], this->p2EndColor[3], ratio); j++; } } diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index 674f4bfa4c..b5992dec43 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -69,13 +69,13 @@ EnDoor* EnHy_FindNearestDoor(Actor* actor, PlayState* play) { do { doorIter = SubS_FindActor(play, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR); door = (EnDoor*)doorIter; - dist = Actor_WorldDistXYZToActor(actor, &door->dyna.actor); + dist = Actor_WorldDistXYZToActor(actor, &door->knobDoor.dyna.actor); if (!isSetup || (dist < minDist)) { nearestDoor = door; minDist = dist; isSetup = true; } - doorIter = door->dyna.actor.next; + doorIter = door->knobDoor.dyna.actor.next; } while (doorIter != NULL); if (1) {} @@ -134,16 +134,16 @@ void func_800F0BB4(EnHy* enHy, PlayState* play, EnDoor* door, s16 arg3, s16 arg4 Vec3f offset; f32 phi_f0; - Actor_OffsetOfPointInActorCoords(&door->dyna.actor, &offset, &enHy->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&door->knobDoor.dyna.actor, &offset, &enHy->actor.world.pos); phi_f0 = (offset.z >= 0.0f) ? 1.0f : -1.0f; animIndex = ((s8)phi_f0 < 0) ? 0 : 2; EnHy_ChangeObjectAndAnim(enHy, play, (animIndex == 0) ? arg3 : arg4); enHy->skelAnime.baseTransl = *enHy->skelAnime.jointTable; enHy->skelAnime.prevTransl = *enHy->skelAnime.jointTable; - enHy->skelAnime.moveFlags |= (ANIM_FLAG_UPDATEY | ANIM_FLAG_1); + enHy->skelAnime.moveFlags |= (ANIM_FLAG_UPDATE_Y | ANIM_FLAG_1); AnimationContext_SetMoveActor(play, &enHy->actor, &enHy->skelAnime, 1.0f); - door->unk_1A1 = 1; - door->animIndex = animIndex; + door->knobDoor.playOpenAnim = true; + door->knobDoor.animIndex = animIndex; } s32 func_800F0CE4(EnHy* enHy, PlayState* play, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5) { @@ -157,7 +157,7 @@ s32 func_800F0CE4(EnHy* enHy, PlayState* play, ActorFunc draw, s16 arg3, s16 arg if (door != NULL) { ret = true; func_800F0BB4(enHy, play, door, arg3, arg4); - yaw = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->dyna.actor.world.pos); + yaw = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->knobDoor.dyna.actor.world.pos); enHy->actor.world.pos.x += arg5 * Math_SinS(yaw); enHy->actor.world.pos.z += arg5 * Math_CosS(yaw); enHy->actor.world.rot.y = -yaw; @@ -179,7 +179,7 @@ s32 func_800F0DD4(EnHy* enHy, PlayState* play, s16 arg2, s16 arg3) { if (door != NULL) { ret = true; func_800F0BB4(enHy, play, door, arg2, arg3); - enHy->actor.shape.rot.y = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->dyna.actor.world.pos); + enHy->actor.shape.rot.y = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->knobDoor.dyna.actor.world.pos); enHy->actor.world.rot.y = enHy->actor.shape.rot.y; enHy->actor.gravity = 0.0f; enHy->actor.flags &= ~ACTOR_FLAG_1; diff --git a/src/code/z_play.c b/src/code/z_play.c index 7f615018eb..e25b50b4bb 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -2327,8 +2327,8 @@ void Play_Init(GameState* thisx) { Camera_InitFocalActorSettings(&this->mainCamera, &player->actor); gDbgCamEnabled = false; - if ((player->actor.params & 0xFF) != 0xFF) { - Camera_ChangeActorCsCamIndex(&this->mainCamera, player->actor.params & 0xFF); + if (PLAYER_GET_BG_CAM_INDEX(&player->actor) != 0xFF) { + Camera_ChangeActorCsCamIndex(&this->mainCamera, PLAYER_GET_BG_CAM_INDEX(&player->actor)); } CutsceneManager_StoreCamera(&this->mainCamera); diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index f8b33b853b..5509fd4a16 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -472,7 +472,7 @@ void func_80123140(PlayState* play, Player* player) { REG(39) = bootRegs[8]; REG(43) = bootRegs[9]; R_RUN_SPEED_LIMIT = bootRegs[10]; - REG(68) = bootRegs[11]; + REG(68) = bootRegs[11]; // gravity REG(69) = bootRegs[12]; IREG(66) = bootRegs[13]; IREG(67) = bootRegs[14]; @@ -503,7 +503,7 @@ s32 Player_InBlockingCsMode(PlayState* play, Player* player) { s32 Player_InCsMode(PlayState* play) { Player* player = GET_PLAYER(play); - return Player_InBlockingCsMode(play, player) || player->unk_AA5 == 5; + return Player_InBlockingCsMode(play, player) || (player->unk_AA5 == PLAYER_UNKAA5_5); } s32 func_80123420(Player* player) { @@ -556,8 +556,8 @@ s32 func_801235DC(PlayState* play, f32 arg1, s16 arg2) { Player* player = GET_PLAYER(play); if (player->stateFlags3 & PLAYER_STATE3_1000) { - player->unk_B08[0] = arg1; - player->unk_B08[1] += arg1 * 0.05f; + player->unk_B08 = arg1; + player->unk_B0C += arg1 * 0.05f; player->currentYaw = arg2; player->actor.home.rot.y = arg2; player->actor.shape.rot.y = arg2; @@ -659,7 +659,7 @@ u8 sActionModelGroups[PLAYER_IA_MAX] = { PLAYER_MODELGROUP_ONE_HAND_SWORD, // PLAYER_IA_SWORD_KOKIRI PLAYER_MODELGROUP_ONE_HAND_SWORD, // PLAYER_IA_SWORD_RAZOR PLAYER_MODELGROUP_ONE_HAND_SWORD, // PLAYER_IA_SWORD_GILDED - PLAYER_MODELGROUP_TWO_HAND_SWORD, // PLAYER_IA_SWORD_GREAT_FAIRY + PLAYER_MODELGROUP_TWO_HAND_SWORD, // PLAYER_IA_SWORD_TWO_HANDED PLAYER_MODELGROUP_STICK, // PLAYER_IA_STICK PLAYER_MODELGROUP_ZORA_FINS, // PLAYER_IA_ZORA_FINS PLAYER_MODELGROUP_BOW, // PLAYER_IA_BOW @@ -1316,6 +1316,7 @@ void Player_UpdateBottleHeld(PlayState* play, Player* player, ItemId itemId, Pla player->itemAction = itemAction; } +// Player_Untarget / Player_StopTargeting? void func_80123DA4(Player* player) { player->targetedActor = NULL; player->stateFlags2 &= ~PLAYER_STATE2_2000; @@ -1445,7 +1446,7 @@ PlayerMeleeWeapon Player_GetMeleeWeaponHeld(Player* player) { s32 Player_IsHoldingTwoHandedWeapon(Player* player) { // Relies on the itemActions for two-handed weapons being contiguous. - if ((player->heldItemAction >= PLAYER_IA_SWORD_GREAT_FAIRY) && (player->heldItemAction <= PLAYER_IA_STICK)) { + if ((player->heldItemAction >= PLAYER_IA_SWORD_TWO_HANDED) && (player->heldItemAction <= PLAYER_IA_STICK)) { return true; } @@ -2038,7 +2039,7 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx** pos->x *= player->ageProperties->unk_08; pos->z *= player->ageProperties->unk_08; } - if (!(player->skelAnime.moveFlags & ANIM_FLAG_4) || (player->skelAnime.moveFlags & ANIM_FLAG_UPDATEY)) { + if (!(player->skelAnime.moveFlags & ANIM_FLAG_4) || (player->skelAnime.moveFlags & ANIM_FLAG_UPDATE_Y)) { pos->y *= player->ageProperties->unk_08; } } @@ -2552,14 +2553,16 @@ void func_8012669C(PlayState* play, Player* player, Vec3f* arg2, Vec3f* arg3) { Matrix_MultVec3f(arg2, &sp3C); Matrix_MultVec3f(arg3, &sp30); - if (player->meleeWeaponState != 0) { + if (player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) { if (func_80126440(play, NULL, &player->meleeWeaponInfo[0], &sp3C, &sp30) && (player->transformation != PLAYER_FORM_GORON) && (!(player->stateFlags1 & PLAYER_STATE1_400000))) { EffectBlure_AddVertex(Effect_GetByIndex(player->meleeWeaponEffectIndex[0]), &player->meleeWeaponInfo[0].tip, &player->meleeWeaponInfo[0].base); } - if ((player->meleeWeaponState > 0) && ((player->meleeWeaponAnimation < PLAYER_MWA_SPIN_ATTACK_1H) || - (player->stateFlags2 & PLAYER_STATE2_20000))) { + + if ((player->meleeWeaponState >= PLAYER_MELEE_WEAPON_STATE_1) && + ((player->meleeWeaponAnimation < PLAYER_MWA_SPIN_ATTACK_1H) || + (player->stateFlags2 & PLAYER_STATE2_20000))) { Matrix_MultVec3f(&arg2[1], &sp3C); Matrix_MultVec3f(&arg3[1], &sp30); func_80126440(play, &player->meleeWeaponQuads[0], &player->meleeWeaponInfo[1], &sp3C, &sp30); @@ -2714,7 +2717,7 @@ void func_80126BD0(PlayState* play, Player* player, s32 arg2) { gSPDisplayList(POLY_OPA_DISP++, D_801C0AB4[arg2]); - if (player->meleeWeaponState != 0) { + if (player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) { if ((((player->meleeWeaponAnimation == PLAYER_MWA_ZORA_PUNCH_LEFT)) && (arg2 == 0)) || ((player->meleeWeaponAnimation == PLAYER_MWA_ZORA_PUNCH_COMBO) && (arg2 != 0))) { func_8012669C(play, player, D_801C0A00, D_801C09DC); @@ -3296,7 +3299,7 @@ s32 func_80128640(PlayState* play, Player* player, Gfx* dlist) { Matrix_Push(); Matrix_Translate(-428.26f, 267.2f, -33.82f, MTXMODE_APPLY); Matrix_RotateZYX(-0x8000, 0, 0x4000, MTXMODE_APPLY); - Matrix_Scale(1.0f, player->unk_B08[1], 1.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, player->unk_B0C, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gDekuStickDL); @@ -3413,7 +3416,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G 3000.0f, // PLAYER_MELEEWEAPON_SWORD_KOKIRI 3000.0f, // PLAYER_MELEEWEAPON_SWORD_RAZOR 4000.0f, // PLAYER_MELEEWEAPON_SWORD_GILDED - 5500.0f, // PLAYER_MELEEWEAPON_SWORD_GREAT_FAIRY + 5500.0f, // PLAYER_MELEEWEAPON_SWORD_TWO_HANDED -1.0f, // PLAYER_MELEEWEAPON_STICK 2500.0f, // PLAYER_MELEEWEAPON_ZORA_FINS }; @@ -3421,19 +3424,19 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G if ((player->transformation == PLAYER_FORM_FIERCE_DEITY) || ((player->transformation != PLAYER_FORM_ZORA) && ((player->itemAction == PLAYER_IA_STICK) || - ((player->meleeWeaponState != 0) && + ((player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) && (player->meleeWeaponAnimation != PLAYER_MWA_GORON_PUNCH_RIGHT) && (player->meleeWeaponAnimation != PLAYER_MWA_GORON_PUNCH_BUTT))))) { if (player->itemAction == PLAYER_IA_STICK) { - D_801C0994->x = player->unk_B08[1] * 5000.0f; + D_801C0994->x = player->unk_B0C * 5000.0f; } else { D_801C0994->x = sMeleeWeaponLengths[Player_GetMeleeWeaponHeld(player)]; } func_80126B8C(play, player); } - Matrix_Get(&player->mf_CC4); - Matrix_MtxFToYXZRot(&player->mf_CC4, &player->leftHandWorld.rot, false); + Matrix_Get(&player->leftHandMf); + Matrix_MtxFToYXZRot(&player->leftHandMf, &player->leftHandWorld.rot, false); } } } else if (limbIndex == PLAYER_LIMB_RIGHT_HAND) { @@ -3458,18 +3461,18 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G Matrix_MultZero(&sp20C); temp_fv0 = Math_Vec3f_DistXYZ(sPlayerCurBodyPartPos, &sp20C); - player->unk_B08[0] = temp_fv0 - 3.0f; + player->unk_B08 = temp_fv0 - 3.0f; if (temp_fv0 < 3.0f) { - player->unk_B08[0] = 0.0f; + player->unk_B08 = 0.0f; } else { - player->unk_B08[0] *= 1.6f; - if (player->unk_B08[0] > 1.0f) { - player->unk_B08[0] = 1.0f; + player->unk_B08 *= 1.6f; + if (player->unk_B08 > 1.0f) { + player->unk_B08 = 1.0f; } } - player->unk_B08[1] = -0.5f; + player->unk_B0C = -0.5f; } - Matrix_Scale(1.0f, player->unk_B08[0], 1.0f, MTXMODE_APPLY); + Matrix_Scale(1.0f, player->unk_B08, 1.0f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -3518,7 +3521,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G Player_DrawHookshotReticle(play, player, 77600.0f); } } - } else if (player->meleeWeaponState != 0) { + } else if (player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) { if (player->meleeWeaponAnimation == PLAYER_MWA_GORON_PUNCH_RIGHT) { func_80126B8C(play, player); } @@ -3590,6 +3593,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G for (i = 0; i < ARRAY_COUNT(sp178); i++) { Matrix_Push(); Matrix_Scale(sp178[i].x, sp178[i].y, sp178[i].z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -3811,7 +3815,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G &player->meleeWeaponInfo[0].base); } } else if (limbIndex == PLAYER_LIMB_RIGHT_SHIN) { - if (player->meleeWeaponState != 0) { + if (player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) { if ((player->meleeWeaponAnimation == PLAYER_MWA_ZORA_PUNCH_KICK) || (player->meleeWeaponAnimation == PLAYER_MWA_ZORA_JUMPKICK_START) || (player->meleeWeaponAnimation == PLAYER_MWA_ZORA_JUMPKICK_FINISH)) { @@ -3819,7 +3823,7 @@ void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList1, G } } } else if (limbIndex == PLAYER_LIMB_WAIST) { - if (player->meleeWeaponState != 0) { + if (player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) { if (player->meleeWeaponAnimation == PLAYER_MWA_GORON_PUNCH_BUTT) { Math_Vec3f_Copy(&player->unk_AF0[1], &player->meleeWeaponInfo[0].base); func_8012669C(play, player, D_801C0A90, D_801C0A6C); diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 085cb4de27..cff66dacbb 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1944,7 +1944,7 @@ void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* diff, s16 angle) { skelAnime->jointTable->x = skelAnime->baseTransl.x; skelAnime->prevTransl.z = skelAnime->jointTable->z; skelAnime->jointTable->z = skelAnime->baseTransl.z; - if (skelAnime->moveFlags & ANIM_FLAG_UPDATEY) { + if (skelAnime->moveFlags & ANIM_FLAG_UPDATE_Y) { if (skelAnime->moveFlags & ANIM_FLAG_NOMOVE) { diff->y = 0.0f; } else { diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index a4d95af64b..d19253df59 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -15,7 +15,7 @@ Vec3f gOneVec3f = { 1.0f, 1.0f, 1.0f }; s32 D_801C5DBC[] = { 0, 1 }; // Unused /** - * Finds the first EnDoor instance with unk_1A4 == 5 and the specified switchFlag. + * Finds the first EnDoor instance with doorType == ENDOOR_TYPE_5 and the specified switchFlag. */ EnDoor* SubS_FindDoor(PlayState* play, s32 switchFlag) { Actor* actor = NULL; @@ -29,7 +29,7 @@ EnDoor* SubS_FindDoor(PlayState* play, s32 switchFlag) { break; } - if ((door->unk_1A4 == 5) && (door->switchFlag == (u8)switchFlag)) { + if ((door->doorType == ENDOOR_TYPE_5) && (door->switchFlag == (u8)switchFlag)) { break; } diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index e271449b59..49525c864f 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -141,6 +141,7 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { if (this->timer != 0 && (this->collider.base.atFlags & AT_HIT) && (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4)) { Actor* touchedActor = this->collider.base.at; + if ((touchedActor->update != NULL) && (touchedActor->flags & (ACTOR_FLAG_200 | ACTOR_FLAG_400))) { if (this->collider.info.atHitInfo->bumperFlags & BUMP_HOOKABLE) { ArmsHook_AttachHookToActor(this, touchedActor); diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h index 31b675f419..bde007da1a 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.h @@ -15,7 +15,7 @@ typedef struct ArmsHook { /* 0x1EC */ Vec3f unk1EC; /* 0x1F8 */ Actor* grabbed; /* 0x1FC */ Vec3f unk1FC; - /* 0x208 */ UNK_TYPE1 unk208[0x2]; + /* 0x208 */ s8 unk_208; /* 0x20A */ s16 timer; /* 0x20C */ ArmsHookActionFunc actionFunc; } ArmsHook; // size = 0x210 diff --git a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c index 8f3de2b2e0..db2c79e39f 100644 --- a/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c +++ b/src/overlays/actors/ovl_Bg_Dblue_Waterfall/z_bg_dblue_waterfall.c @@ -321,8 +321,8 @@ void func_80B84610(BgDblueWaterfall* this, PlayState* play) { player->actor.world.pos.x += sp34.x; player->actor.world.pos.z += sp34.z; if (this && this && this) {} - player->unk_B80 = 8.0f; - player->unk_B84 = this->actor.yawTowardsPlayer; + player->pushedSpeed = 8.0f; + player->pushedYaw = this->actor.yawTowardsPlayer; } static InitChainEntry sInitChain[] = { diff --git a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c index 9a3bbabdfa..119c3854a1 100644 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c +++ b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c @@ -68,10 +68,10 @@ s8 func_80ACABA8(BgOpenShutter* this, PlayState* play) { f32 temp_fv0; s16 temp_v0; - if (!Player_InCsMode(play) && (this->dyna.actor.xzDistToPlayer < 100.0f)) { - temp_fv0 = func_80ACAB10(play, &this->dyna.actor, 0.0f, 65.0f, 15.0f); + if (!Player_InCsMode(play) && (this->slidingDoor.dyna.actor.xzDistToPlayer < 100.0f)) { + temp_fv0 = func_80ACAB10(play, &this->slidingDoor.dyna.actor, 0.0f, 65.0f, 15.0f); if (fabsf(temp_fv0) < 50.0f) { - temp_v0 = player->actor.shape.rot.y - this->dyna.actor.shape.rot.y; + temp_v0 = player->actor.shape.rot.y - this->slidingDoor.dyna.actor.shape.rot.y; if (temp_fv0 > 0.0f) { temp_v0 = (0x8000 - temp_v0); } @@ -91,31 +91,32 @@ s8 func_80ACABA8(BgOpenShutter* this, PlayState* play) { void BgOpenShutter_Init(Actor* thisx, PlayState* play) { BgOpenShutter* this = THIS; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); - DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_open_obj_Colheader_001640); + Actor_ProcessInitChain(&this->slidingDoor.dyna.actor, sInitChain); + DynaPolyActor_Init(&this->slidingDoor.dyna, DYNA_TRANSFORM_POS); + DynaPolyActor_LoadMesh(play, &this->slidingDoor.dyna, &object_open_obj_Colheader_001640); this->actionFunc = func_80ACAD88; } void BgOpenShutter_Destroy(Actor* thisx, PlayState* play) { BgOpenShutter* this = THIS; - s32 params = BGOPENSHUTTER_GET_A(thisx); + s32 transition = DOOR_GET_TRANSITION_ID(thisx); - play->doorCtx.transitionActorList[params].id = -play->doorCtx.transitionActorList[params].id; - DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + play->doorCtx.transitionActorList[transition].id = -play->doorCtx.transitionActorList[transition].id; + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->slidingDoor.dyna.bgId); } void func_80ACAD88(BgOpenShutter* this, PlayState* play) { s32 doorDirection; - if (this->unk_15C != 0) { + if (this->slidingDoor.unk_15C != 0) { Player* player = GET_PLAYER(play); - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); - Camera_ChangeDoorCam(play->cameraPtrs[CAM_ID_MAIN], &this->dyna.actor, player->unk_3BA, 0.0f, 12, 15, 10); + Actor_PlaySfx(&this->slidingDoor.dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + Camera_ChangeDoorCam(play->cameraPtrs[CAM_ID_MAIN], &this->slidingDoor.dyna.actor, player->doorBgCamIndex, 0.0f, + 12, 15, 10); this->unk_164 = 0; this->actionFunc = func_80ACAE5C; - this->dyna.actor.velocity.y = 0.0f; + this->slidingDoor.dyna.actor.velocity.y = 0.0f; } else { Player* player = GET_PLAYER(play); @@ -123,20 +124,20 @@ void func_80ACAD88(BgOpenShutter* this, PlayState* play) { if (doorDirection > 0) { player->doorType = PLAYER_DOORTYPE_SLIDING; player->doorDirection = doorDirection; - player->doorActor = &this->dyna.actor; + player->doorActor = &this->slidingDoor.dyna.actor; func_80122F28(player); } } } void func_80ACAE5C(BgOpenShutter* this, PlayState* play) { - Math_StepToF(&this->dyna.actor.velocity.y, 15.0f, 3.0f); - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 120.0f, - this->dyna.actor.velocity.y)) { + Math_StepToF(&this->slidingDoor.dyna.actor.velocity.y, 15.0f, 3.0f); + if (Math_StepToF(&this->slidingDoor.dyna.actor.world.pos.y, this->slidingDoor.dyna.actor.home.pos.y + 120.0f, + this->slidingDoor.dyna.actor.velocity.y)) { this->unk_164++; } if (this->unk_164 >= 10) { - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + Actor_PlaySfx(&this->slidingDoor.dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); this->actionFunc = func_80ACAEF0; } } @@ -145,20 +146,22 @@ void func_80ACAEF0(BgOpenShutter* this, PlayState* play) { s32 pad; s16 quakeIndex; - Math_StepToF(&this->dyna.actor.velocity.y, 20.0f, 8.0f); - if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, this->dyna.actor.velocity.y)) { - this->dyna.actor.floorHeight = this->dyna.actor.home.pos.y; - Actor_SpawnFloorDustRing(play, &this->dyna.actor, &this->dyna.actor.world.pos, 60.0f, 10, 8.0f, 500, 10, true); - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); + Math_StepToF(&this->slidingDoor.dyna.actor.velocity.y, 20.0f, 8.0f); + if (Math_StepToF(&this->slidingDoor.dyna.actor.world.pos.y, this->slidingDoor.dyna.actor.home.pos.y, + this->slidingDoor.dyna.actor.velocity.y)) { + this->slidingDoor.dyna.actor.floorHeight = this->slidingDoor.dyna.actor.home.pos.y; + Actor_SpawnFloorDustRing(play, &this->slidingDoor.dyna.actor, &this->slidingDoor.dyna.actor.world.pos, 60.0f, + 10, 8.0f, 500, 10, true); + Actor_PlaySfx(&this->slidingDoor.dyna.actor, NA_SE_EV_BIGWALL_BOUND); quakeIndex = Quake_Request(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, -32536); Quake_SetPerturbations(quakeIndex, 2, 0, 0, 0); Quake_SetDuration(quakeIndex, 10); - Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 180, 20, 100); + Rumble_Request(this->slidingDoor.dyna.actor.xyzDistToPlayerSq, 180, 20, 100); - this->unk_15C = 0; + this->slidingDoor.unk_15C = 0; this->actionFunc = func_80ACAD88; } } @@ -172,14 +175,14 @@ void BgOpenShutter_Update(Actor* thisx, PlayState* play2) { cueChannel = Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_124); if (play->csCtx.actorCues[cueChannel]->id == BGOPENSHUTTER_DOOR_OPEN) { if (this->actionFunc == func_80ACAD88) { - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + Actor_PlaySfx(&this->slidingDoor.dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); this->actionFunc = func_80ACAE5C; - this->dyna.actor.velocity.y = 0.0f; + this->slidingDoor.dyna.actor.velocity.y = 0.0f; } this->unk_164 = 0; } else if (play->csCtx.actorCues[cueChannel]->id == BGOPENSHUTTER_DOOR_CLOSED) { if (this->actionFunc == func_80ACAE5C) { - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + Actor_PlaySfx(&this->slidingDoor.dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); this->actionFunc = func_80ACAEF0; } } diff --git a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h index f6c6067d4b..c035606b17 100644 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h +++ b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h @@ -2,16 +2,14 @@ #define Z_BG_OPEN_SHUTTER_H #include "global.h" - -#define BGOPENSHUTTER_GET_A(thisx) ((u16)((thisx)->params) >> 0xA) +#include "z64door.h" struct BgOpenShutter; typedef void (*BgOpenShutterActionFunc)(struct BgOpenShutter*, PlayState*); typedef struct BgOpenShutter { - /* 0x000 */ DynaPolyActor dyna; - /* 0x15C */ s16 unk_15C; + /* 0x000 */ SlidingDoorActor slidingDoor; /* 0x160 */ BgOpenShutterActionFunc actionFunc; /* 0x164 */ s32 unk_164; } BgOpenShutter; // size = 0x168 diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index 054b612bc2..c8ceed19bd 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -1842,16 +1842,16 @@ void Boss03_UpdateCollision(Boss03* this, PlayState* play) { for (i = 0; i < ARRAY_COUNT(sHeadJntSphElementsInit); i++) { if (this->headCollider.elements[i].info.toucherFlags & TOUCH_HIT) { this->headCollider.elements[i].info.toucherFlags &= ~TOUCH_HIT; - player->unk_B84 = this->actor.shape.rot.y; - player->unk_B80 = 20.0f; + player->pushedYaw = this->actor.shape.rot.y; + player->pushedSpeed = 20.0f; } } for (i = 0; i < ARRAY_COUNT(sBodyJntSphElementsInit); i++) { if (this->bodyCollider.elements[i].info.toucherFlags & TOUCH_HIT) { this->bodyCollider.elements[i].info.toucherFlags &= ~TOUCH_HIT; - player->unk_B84 = this->actor.shape.rot.y; - player->unk_B80 = 20.0f; + player->pushedYaw = this->actor.shape.rot.y; + player->pushedSpeed = 20.0f; } } } diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c index fcc183ef98..eac8b10ab2 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.c @@ -139,15 +139,17 @@ void DoorShutter_SetupAction(DoorShutter* this, DoorShutterActionFunc actionFunc } s32 func_808A0900(DoorShutter* this, PlayState* play) { - TransitionActorEntry* transitionEntry = &play->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)]; + TransitionActorEntry* transitionEntry = + &play->doorCtx.transitionActorList[DOOR_GET_TRANSITION_ID(&this->slidingDoor.dyna.actor)]; s8 frontRoom = transitionEntry->sides[0].room; if (frontRoom == transitionEntry->sides[1].room) { - if (ABS_ALT(BINANG_SUB(this->actor.shape.rot.y, this->actor.yawTowardsPlayer)) < 0x4000) { + if (ABS_ALT(BINANG_SUB(this->slidingDoor.dyna.actor.shape.rot.y, + this->slidingDoor.dyna.actor.yawTowardsPlayer)) < 0x4000) { frontRoom = -1; } } - return frontRoom == this->actor.room; + return frontRoom == this->slidingDoor.dyna.actor.room; } s32 DoorShutter_SetupDoor(DoorShutter* this, PlayState* play) { @@ -173,13 +175,13 @@ s32 DoorShutter_SetupDoor(DoorShutter* this, PlayState* play) { } if (doorType == 1) { - if (!Flags_GetClear(play, this->actor.room)) { + if (!Flags_GetClear(play, this->slidingDoor.dyna.actor.room)) { DoorShutter_SetupAction(this, func_808A0F88); this->unk_168 = 1.0f; return true; } } else if ((doorType == 2) || (doorType == 7)) { - if (!Flags_GetSwitch(play, DOORSHUTTER_GET_7F(&this->actor))) { + if (!Flags_GetSwitch(play, DOORSHUTTER_GET_7F(&this->slidingDoor.dyna.actor))) { DoorShutter_SetupAction(this, func_808A1548); this->unk_168 = 1.0f; return true; @@ -201,8 +203,8 @@ void DoorShutter_Init(Actor* thisx, PlayState* play2) { s32 sp24; s32 i; - Actor_ProcessInitChain(&this->actor, sInitChain); - this->doorType = DOORSHUTTER_GET_380(&this->actor); + Actor_ProcessInitChain(&this->slidingDoor.dyna.actor, sInitChain); + this->doorType = DOORSHUTTER_GET_380(&this->slidingDoor.dyna.actor); sp24 = D_808A2240[this->doorType]; if (sp24 < 0) { @@ -216,7 +218,7 @@ void DoorShutter_Init(Actor* thisx, PlayState* play2) { sp24 = shutterSceneInfo->index; if (sp24 == 6) { - this->actor.flags |= ACTOR_FLAG_10000000; + this->slidingDoor.dyna.actor.flags |= ACTOR_FLAG_10000000; } } else if (sp24 == 0) { BossDoorInfo* bossDoorInfo = &D_808A22A0[0]; @@ -227,13 +229,13 @@ void DoorShutter_Init(Actor* thisx, PlayState* play2) { } } - this->unk_15E = bossDoorInfo->index; + this->slidingDoor.unk_15E = bossDoorInfo->index; } else { - this->actor.room = -1; + this->slidingDoor.dyna.actor.room = -1; } if ((this->requiredObjBankIndex = Object_GetIndex(&play->objectCtx, D_808A2180[sp24].objectId)) < 0) { - Actor_Kill(&this->actor); + Actor_Kill(&this->slidingDoor.dyna.actor); return; } @@ -241,19 +243,19 @@ void DoorShutter_Init(Actor* thisx, PlayState* play2) { this->unk_163 = sp24; if ((this->doorType == 4) || (this->doorType == 5)) { - if (!Flags_GetSwitch(play, DOORSHUTTER_GET_7F(&this->actor))) { + if (!Flags_GetSwitch(play, DOORSHUTTER_GET_7F(&this->slidingDoor.dyna.actor))) { this->unk_166 = 10; } } - Actor_SetFocus(&this->actor, 60.0f); + Actor_SetFocus(&this->slidingDoor.dyna.actor, 60.0f); } void DoorShutter_Destroy(Actor* thisx, PlayState* play) { DoorShutter* this = THIS; - if (this->actor.room >= 0) { - s32 transitionActorId = DOORSHUTTER_GET_FC00(&this->actor); + if (this->slidingDoor.dyna.actor.room >= 0) { + s32 transitionActorId = DOOR_GET_TRANSITION_ID(&this->slidingDoor.dyna.actor); play->doorCtx.transitionActorList[transitionActorId].id = -play->doorCtx.transitionActorList[transitionActorId].id; @@ -263,8 +265,8 @@ void DoorShutter_Destroy(Actor* thisx, PlayState* play) { void DoorShutter_SetupType(DoorShutter* this, PlayState* play) { if (Object_IsLoaded(&play->objectCtx, this->requiredObjBankIndex) && (!R_PLAY_FILL_SCREEN_ON || (R_PLAY_FILL_SCREEN_ALPHA == 0))) { - this->actor.objBankIndex = this->requiredObjBankIndex; - this->actor.draw = DoorShutter_Draw; + this->slidingDoor.dyna.actor.objBankIndex = this->requiredObjBankIndex; + this->slidingDoor.dyna.actor.draw = DoorShutter_Draw; DoorShutter_SetupDoor(this, play); } } @@ -278,7 +280,7 @@ f32 func_808A0D90(PlayState* play, DoorShutter* this, f32 arg2, f32 arg3, f32 ar sp28.y = player->actor.world.pos.y + arg2; sp28.z = player->actor.world.pos.z; - Actor_OffsetOfPointInActorCoords(&this->actor, &sp1C, &sp28); + Actor_OffsetOfPointInActorCoords(&this->slidingDoor.dyna.actor, &sp1C, &sp28); if ((arg3 < fabsf(sp1C.x)) || (arg4 < fabsf(sp1C.y))) { return FLT_MAX; @@ -294,7 +296,7 @@ s32 func_808A0E28(DoorShutter* this, PlayState* play) { f32 temp_f0 = func_808A0D90(play, this, 0.0f, shutterInfo->unk_0A, shutterInfo->unk_0B); if (fabsf(temp_f0) < 50.0f) { - s16 temp_v0_2 = BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y); + s16 temp_v0_2 = BINANG_SUB(player->actor.shape.rot.y, this->slidingDoor.dyna.actor.shape.rot.y); if (temp_f0 > 0.0f) { temp_v0_2 = 0x8000 - temp_v0_2; @@ -309,8 +311,9 @@ s32 func_808A0E28(DoorShutter* this, PlayState* play) { } void func_808A0F88(DoorShutter* this, PlayState* play) { - if (Flags_GetClear(play, this->actor.room) || Flags_GetClearTemp(play, this->actor.room)) { - this->csId = this->actor.csId; + if (Flags_GetClear(play, this->slidingDoor.dyna.actor.room) || + Flags_GetClearTemp(play, this->slidingDoor.dyna.actor.room)) { + this->csId = this->slidingDoor.dyna.actor.csId; if (this->doorType == 7) { if (this->csId != CS_ID_NONE) { this->csId = CutsceneManager_GetAdditionalCsId(this->csId); @@ -318,8 +321,8 @@ void func_808A0F88(DoorShutter* this, PlayState* play) { } if (CutsceneManager_IsNext(this->csId)) { - CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); - Flags_SetClear(play, this->actor.room); + CutsceneManager_StartWithPlayerCs(this->csId, &this->slidingDoor.dyna.actor); + Flags_SetClear(play, this->slidingDoor.dyna.actor.room); DoorShutter_SetupAction(this, func_808A1784); this->unk_167 = -1; } else { @@ -329,8 +332,8 @@ void func_808A0F88(DoorShutter* this, PlayState* play) { Player* player = GET_PLAYER(play); player->doorType = PLAYER_DOORTYPE_TALKING; - player->doorActor = &this->actor; - this->actor.textId = 0x1801; + player->doorActor = &this->slidingDoor.dyna.actor; + this->slidingDoor.dyna.actor.textId = 0x1801; func_80122F28(player); } } @@ -339,16 +342,16 @@ void func_808A1080(DoorShutter* this, PlayState* play) { } void func_808A1090(DoorShutter* this, PlayState* play) { - if (this->unk_15C != 0) { + if (this->slidingDoor.unk_15C != 0) { DoorShutter_SetupAction(this, func_808A1684); - this->actor.velocity.y = 0.0f; + this->slidingDoor.dyna.actor.velocity.y = 0.0f; if (this->unk_166 != 0) { - Flags_SetSwitch(play, DOORSHUTTER_GET_7F(&this->actor)); + Flags_SetSwitch(play, DOORSHUTTER_GET_7F(&this->slidingDoor.dyna.actor)); if (this->doorType != 5) { gSaveContext.save.saveInfo.inventory.dungeonKeys[gSaveContext.mapIndex]--; - Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK); + Actor_PlaySfx(&this->slidingDoor.dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK); } else { - Actor_PlaySfx(&this->actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); + Actor_PlaySfx(&this->slidingDoor.dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK_B); } } } else { @@ -359,7 +362,7 @@ void func_808A1090(DoorShutter* this, PlayState* play) { player->doorType = PLAYER_DOORTYPE_SLIDING; player->doorDirection = doorDirection; - player->doorActor = &this->actor; + player->doorActor = &this->slidingDoor.dyna.actor; if (this->unk_163 == 7) { player->doorTimer = 12; @@ -368,20 +371,21 @@ void func_808A1090(DoorShutter* this, PlayState* play) { } if (this->doorType == 6) { - if (gSaveContext.save.saveInfo.playerData.healthCapacity < (DOORSHUTTER_GET_1F(&this->actor) * 0x10)) { + if (gSaveContext.save.saveInfo.playerData.healthCapacity < + (DOORSHUTTER_GET_1F(&this->slidingDoor.dyna.actor) * 0x10)) { player->doorType = PLAYER_DOORTYPE_TALKING; - this->actor.textId = 0x14FC; + this->slidingDoor.dyna.actor.textId = 0x14FC; } } else if (this->unk_166 != 0) { if (this->doorType == 5) { if (!CHECK_DUNGEON_ITEM(DUNGEON_BOSS_KEY, gSaveContext.mapIndex)) { player->doorType = PLAYER_DOORTYPE_TALKING; - this->actor.textId = 0x1803; + this->slidingDoor.dyna.actor.textId = 0x1803; } player->doorTimer += 10; } else if (DUNGEON_KEY_COUNT(gSaveContext.mapIndex) <= 0) { player->doorType = PLAYER_DOORTYPE_TALKING; - this->actor.textId = 0x1802; + this->slidingDoor.dyna.actor.textId = 0x1802; } else { player->doorTimer += 10; } @@ -392,7 +396,7 @@ void func_808A1090(DoorShutter* this, PlayState* play) { } void func_808A1288(DoorShutter* this, PlayState* play) { - if (this->actor.category == ACTORCAT_DOOR) { + if (this->slidingDoor.dyna.actor.category == ACTORCAT_DOOR) { Player* player = GET_PLAYER(play); s32 sp38 = this->unk_164; s32 sp34 = 0xF; @@ -406,17 +410,18 @@ void func_808A1288(DoorShutter* this, PlayState* play) { this->unk_164 = sp38; this->unk_168 = 0.0f; - Camera_ChangeDoorCam(play->cameraPtrs[CAM_ID_MAIN], &this->actor, player->unk_3BA, this->unk_168, 12, sp34, 10); + Camera_ChangeDoorCam(play->cameraPtrs[CAM_ID_MAIN], &this->slidingDoor.dyna.actor, player->doorBgCamIndex, + this->unk_168, 12, sp34, 10); } } s32 func_808A1340(DoorShutter* this, PlayState* play) { Vec3f sp2C; - if (this->actor.velocity.y == 0.0f) { + if (this->slidingDoor.dyna.actor.velocity.y == 0.0f) { func_808A1288(this, play); if (this->unk_163 != 7) { - Actor_PlaySfx(&this->actor, NA_SE_EV_SLIDE_DOOR_OPEN); + Actor_PlaySfx(&this->slidingDoor.dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); } } @@ -424,20 +429,22 @@ s32 func_808A1340(DoorShutter* this, PlayState* play) { s32 pad; if (this->unk_163 == 7) { - func_800B9010(&this->actor, NA_SE_EV_IKANA_DOOR_OPEN - SFX_FLAG); + func_800B9010(&this->slidingDoor.dyna.actor, NA_SE_EV_IKANA_DOOR_OPEN - SFX_FLAG); } - Lib_Vec3f_TranslateAndRotateY(&this->actor.home.pos, this->actor.shape.rot.y, + Lib_Vec3f_TranslateAndRotateY(&this->slidingDoor.dyna.actor.home.pos, this->slidingDoor.dyna.actor.shape.rot.y, (this->unk_163 == 7) ? &D_808A22C4 : &D_808A22D0, &sp2C); - Math_StepToF(&this->actor.velocity.y, 5.0f, 0.5f); + Math_StepToF(&this->slidingDoor.dyna.actor.velocity.y, 5.0f, 0.5f); - if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &sp2C, this->actor.velocity.y) == 0.0f) { + if (Math_Vec3f_StepToXZ(&this->slidingDoor.dyna.actor.world.pos, &sp2C, + this->slidingDoor.dyna.actor.velocity.y) == 0.0f) { return true; } } else { - Math_StepToF(&this->actor.velocity.y, 15.0f, 3.0f); + Math_StepToF(&this->slidingDoor.dyna.actor.velocity.y, 15.0f, 3.0f); - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y + 200.0f, this->actor.velocity.y)) { + if (Math_StepToF(&this->slidingDoor.dyna.actor.world.pos.y, this->slidingDoor.dyna.actor.home.pos.y + 200.0f, + this->slidingDoor.dyna.actor.velocity.y)) { return true; } } @@ -449,13 +456,13 @@ s32 func_808A1478(DoorShutter* this, PlayState* play, f32 arg2) { if (temp == this->unk_168) { if (arg2 == 1.0f) { - Actor_PlaySfx(&this->actor, NA_SE_EV_METALDOOR_CLOSE); + Actor_PlaySfx(&this->slidingDoor.dyna.actor, NA_SE_EV_METALDOOR_CLOSE); } else { - Actor_PlaySfx(&this->actor, NA_SE_EV_METALDOOR_OPEN); + Actor_PlaySfx(&this->slidingDoor.dyna.actor, NA_SE_EV_METALDOOR_OPEN); } if ((this->csId != CS_ID_NONE) && (CutsceneManager_GetCurrentCsId() == this->csId)) { - func_800B724C(play, &this->actor, PLAYER_CSMODE_1); + func_800B724C(play, &this->slidingDoor.dyna.actor, PLAYER_CSMODE_1); } } @@ -467,10 +474,10 @@ s32 func_808A1478(DoorShutter* this, PlayState* play, f32 arg2) { void func_808A1548(DoorShutter* this, PlayState* play) { if (func_808A1478(this, play, 1.0f)) { - if (Flags_GetSwitch(play, DOORSHUTTER_GET_7F(&this->actor))) { - this->csId = this->actor.csId; + if (Flags_GetSwitch(play, DOORSHUTTER_GET_7F(&this->slidingDoor.dyna.actor))) { + this->csId = this->slidingDoor.dyna.actor.csId; if (CutsceneManager_IsNext(this->csId)) { - CutsceneManager_StartWithPlayerCs(this->csId, &this->actor); + CutsceneManager_StartWithPlayerCs(this->csId, &this->slidingDoor.dyna.actor); DoorShutter_SetupAction(this, func_808A1784); this->unk_167 = -1; } else { @@ -480,15 +487,15 @@ void func_808A1548(DoorShutter* this, PlayState* play) { Player* player = GET_PLAYER(play); player->doorType = PLAYER_DOORTYPE_TALKING; - player->doorActor = &this->actor; - this->actor.textId = 0x1800; + player->doorActor = &this->slidingDoor.dyna.actor; + this->slidingDoor.dyna.actor.textId = 0x1800; func_80122F28(player); } } } void func_808A1618(DoorShutter* this, PlayState* play) { - if ((this->unk_15C == 0) && !Flags_GetSwitch(play, DOORSHUTTER_GET_7F(&this->actor))) { + if ((this->slidingDoor.unk_15C == 0) && !Flags_GetSwitch(play, DOORSHUTTER_GET_7F(&this->slidingDoor.dyna.actor))) { DoorShutter_SetupAction(this, func_808A1548); } else { func_808A1090(this, play); @@ -505,14 +512,14 @@ void func_808A1684(DoorShutter* this, PlayState* play) { phi_f0 = 50.0f; } - if (phi_f0 < this->actor.xzDistToPlayer) { + if (phi_f0 < this->slidingDoor.dyna.actor.xzDistToPlayer) { if (this->unk_163 == 7) { - this->actor.velocity.y = 0.0f; + this->slidingDoor.dyna.actor.velocity.y = 0.0f; } else { if (DoorShutter_SetupDoor(this, play)) { - this->actor.velocity.y = 30.0f; + this->slidingDoor.dyna.actor.velocity.y = 30.0f; } - Actor_PlaySfx(&this->actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + Actor_PlaySfx(&this->slidingDoor.dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); } DoorShutter_SetupAction(this, func_808A1B48); } @@ -521,7 +528,7 @@ void func_808A1684(DoorShutter* this, PlayState* play) { void func_808A1784(DoorShutter* this, PlayState* play) { if (this->unk_167 != 0) { - if (func_800F22C4(this->csId, &this->actor) != 0) { + if (func_800F22C4(this->csId, &this->slidingDoor.dyna.actor) != 0) { if (this->unk_167 < 0) { if ((play->state.frames % 2) != 0) { this->unk_167++; @@ -545,16 +552,18 @@ void func_808A1784(DoorShutter* this, PlayState* play) { void func_808A1884(DoorShutter* this, PlayState* play) { Player* player = GET_PLAYER(play); - s8 room = this->actor.room; + s8 room = this->slidingDoor.dyna.actor.room; Vec3f sp44; - if (this->actor.room >= 0) { - Actor_OffsetOfPointInActorCoords(&this->actor, &sp44, &player->actor.world.pos); + if (this->slidingDoor.dyna.actor.room >= 0) { + Actor_OffsetOfPointInActorCoords(&this->slidingDoor.dyna.actor, &sp44, &player->actor.world.pos); - this->actor.room = - play->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)].sides[(sp44.z < 0.0f) ? 0 : 1].room; + this->slidingDoor.dyna.actor.room = + play->doorCtx.transitionActorList[DOOR_GET_TRANSITION_ID(&this->slidingDoor.dyna.actor)] + .sides[(sp44.z < 0.0f) ? 0 : 1] + .room; - if (room != this->actor.room) { + if (room != this->slidingDoor.dyna.actor.room) { Room temp = play->roomCtx.curRoom; play->roomCtx.curRoom = play->roomCtx.prevRoom; @@ -564,8 +573,8 @@ void func_808A1884(DoorShutter* this, PlayState* play) { func_8012EBF8(play, &play->roomCtx); } - this->unk_15C = 0; - this->actor.velocity.y = 0.0f; + this->slidingDoor.unk_15C = 0; + this->slidingDoor.dyna.actor.velocity.y = 0.0f; if (DoorShutter_SetupDoor(this, play) && !(player->stateFlags1 & PLAYER_STATE1_800)) { DoorShutter_SetupAction(this, func_808A1C50); @@ -580,20 +589,22 @@ void func_808A1884(DoorShutter* this, PlayState* play) { s32 func_808A1A70(DoorShutter* this) { if (this->unk_163 == 7) { if (this->unk_163 == 7) { - func_800B9010(&this->actor, NA_SE_EV_IKANA_DOOR_CLOSE - SFX_FLAG); + func_800B9010(&this->slidingDoor.dyna.actor, NA_SE_EV_IKANA_DOOR_CLOSE - SFX_FLAG); } - Math_StepToF(&this->actor.velocity.y, 5.0f, 0.5f); + Math_StepToF(&this->slidingDoor.dyna.actor.velocity.y, 5.0f, 0.5f); - if (Math_Vec3f_StepToXZ(&this->actor.world.pos, &this->actor.home.pos, this->actor.velocity.y) == 0.0f) { + if (Math_Vec3f_StepToXZ(&this->slidingDoor.dyna.actor.world.pos, &this->slidingDoor.dyna.actor.home.pos, + this->slidingDoor.dyna.actor.velocity.y) == 0.0f) { return true; } } else { - if (this->actor.velocity.y < 20.0f) { - Math_StepToF(&this->actor.velocity.y, 20.0f, 8.0f); + if (this->slidingDoor.dyna.actor.velocity.y < 20.0f) { + Math_StepToF(&this->slidingDoor.dyna.actor.velocity.y, 20.0f, 8.0f); } - if (Math_StepToF(&this->actor.world.pos.y, this->actor.home.pos.y, this->actor.velocity.y)) { + if (Math_StepToF(&this->slidingDoor.dyna.actor.world.pos.y, this->slidingDoor.dyna.actor.home.pos.y, + this->slidingDoor.dyna.actor.velocity.y)) { return true; } } @@ -604,18 +615,19 @@ void func_808A1B48(DoorShutter* this, PlayState* play) { s16 quakeIndex; if (func_808A1A70(this)) { - if (this->actor.velocity.y > 20.0f) { - this->actor.floorHeight = this->actor.home.pos.y; - Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, 45.0f, 10, 8.0f, 500, 10, 0); + if (this->slidingDoor.dyna.actor.velocity.y > 20.0f) { + this->slidingDoor.dyna.actor.floorHeight = this->slidingDoor.dyna.actor.home.pos.y; + Actor_SpawnFloorDustRing(play, &this->slidingDoor.dyna.actor, &this->slidingDoor.dyna.actor.world.pos, + 45.0f, 10, 8.0f, 500, 10, 0); } - Actor_PlaySfx(&this->actor, NA_SE_EV_BIGWALL_BOUND); + Actor_PlaySfx(&this->slidingDoor.dyna.actor, NA_SE_EV_BIGWALL_BOUND); quakeIndex = Quake_Request(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); Quake_SetSpeed(quakeIndex, -32536); Quake_SetPerturbations(quakeIndex, 2, 0, 0, 0); Quake_SetDuration(quakeIndex, 10); - Rumble_Request(this->actor.xyzDistToPlayerSq, 180, 20, 100); + Rumble_Request(this->slidingDoor.dyna.actor.xyzDistToPlayerSq, 180, 20, 100); func_808A1884(this, play); } @@ -639,7 +651,9 @@ void DoorShutter_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); if (this->unk_163 == 7) { - this->actor.home.rot.z = Math_Vec3f_DistXZ(&this->actor.home.pos, &this->actor.world.pos) * -100.0f; + this->slidingDoor.dyna.actor.home.rot.z = + Math_Vec3f_DistXZ(&this->slidingDoor.dyna.actor.home.pos, &this->slidingDoor.dyna.actor.world.pos) * + -100.0f; } } } @@ -652,8 +666,9 @@ s32 func_808A1D68(DoorShutter* this, PlayState* play) { return true; } - temp_a0 = BINANG_SUB(Actor_WorldYawTowardPoint(&this->actor, &play->view.eye), this->actor.shape.rot.y); - temp_a1 = BINANG_SUB(this->actor.yawTowardsPlayer, this->actor.shape.rot.y); + temp_a0 = BINANG_SUB(Actor_WorldYawTowardPoint(&this->slidingDoor.dyna.actor, &play->view.eye), + this->slidingDoor.dyna.actor.shape.rot.y); + temp_a1 = BINANG_SUB(this->slidingDoor.dyna.actor.yawTowardsPlayer, this->slidingDoor.dyna.actor.shape.rot.y); temp_a0 = ABS_ALT(temp_a0); temp_a1 = ABS_ALT(temp_a1); @@ -678,26 +693,27 @@ void DoorShutter_Draw(Actor* thisx, PlayState* play) { if (this->unk_164 == 7) { Matrix_Translate(0.0f, 64.96f, 0.0f, MTXMODE_APPLY); - Matrix_RotateZS(this->actor.home.rot.z, MTXMODE_APPLY); + Matrix_RotateZS(this->slidingDoor.dyna.actor.home.rot.z, MTXMODE_APPLY); Matrix_Translate(0.0f, -64.96f, 0.0f, MTXMODE_APPLY); } if (sp44->unk_04 != 0) { TransitionActorEntry* transitionEntry = - &play->doorCtx.transitionActorList[DOORSHUTTER_GET_FC00(&this->actor)]; + &play->doorCtx.transitionActorList[DOOR_GET_TRANSITION_ID(&this->slidingDoor.dyna.actor)]; if ((play->roomCtx.prevRoom.num >= 0) || (transitionEntry->sides[0].room == transitionEntry->sides[1].room)) { - s16 yaw = this->actor.shape.rot.y - Math_Vec3f_Yaw(&play->view.eye, &this->actor.world.pos); + s16 yaw = this->slidingDoor.dyna.actor.shape.rot.y - + Math_Vec3f_Yaw(&play->view.eye, &this->slidingDoor.dyna.actor.world.pos); if (ABS_ALT(yaw) < 0x4000) { Matrix_RotateYF(M_PI, MTXMODE_APPLY); } - } else if (this->actor.room == transitionEntry->sides[0].room) { + } else if (this->slidingDoor.dyna.actor.room == transitionEntry->sides[0].room) { Matrix_RotateYF(M_PI, MTXMODE_APPLY); } } else if (this->doorType == 5) { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_808A22DC[this->unk_15E])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_808A22DC[this->slidingDoor.unk_15E])); } gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h index 7f18e05460..abdf0ce84d 100644 --- a/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h +++ b/src/overlays/actors/ovl_Door_Shutter/z_door_shutter.h @@ -2,6 +2,7 @@ #define Z_DOOR_SHUTTER_H #include "global.h" +#include "z64door.h" struct DoorShutter; @@ -10,14 +11,10 @@ typedef void (*DoorShutterActionFunc)(struct DoorShutter*, PlayState*); #define DOORSHUTTER_GET_1F(thisx) ((thisx)->params & 0x1F) #define DOORSHUTTER_GET_7F(thisx) ((thisx)->params & 0x7F) #define DOORSHUTTER_GET_380(thisx) (((thisx)->params >> 7) & 7) -#define DOORSHUTTER_GET_FC00(thisx) ((u16)(thisx)->params >> 0xA) typedef struct DoorShutter { - /* 0x0000 */ Actor actor; - /* 0x0144 */ UNK_TYPE1 unk144[0x18]; - /* 0x015C */ s16 unk_15C; - /* 0x015E */ s16 unk_15E; - /* 0x0160 */ s16 csId; + /* 0x000 */ SlidingDoorActor slidingDoor; + /* 0x160 */ s16 csId; /* 0x0162 */ u8 doorType; /* 0x0163 */ u8 unk_163; /* 0x0164 */ u8 unk_164; diff --git a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.h b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.h index 701b386395..af4f27aead 100644 --- a/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.h +++ b/src/overlays/actors/ovl_Door_Spiral/z_door_spiral.h @@ -7,7 +7,8 @@ struct DoorSpiral; typedef struct DoorSpiral { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0xC]; + /* 0x144 */ u8 shouldClimb; + /* 0x145 */ UNK_TYPE1 unk_145[0xB]; } DoorSpiral; // size = 0x150 #endif // Z_DOOR_SPIRAL_H diff --git a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c index 2833477e4a..02dad6c0c4 100644 --- a/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c +++ b/src/overlays/actors/ovl_Eff_Dust/z_eff_dust.c @@ -326,7 +326,7 @@ void func_809199FC(Actor* thisx, PlayState* play2) { distanceTraveled = this->distanceTraveled; gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); - if (player->unk_B08[0] >= 0.85f) { + if (player->unk_B08 >= 0.85f) { gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 0); } else { gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 255, 0); @@ -339,7 +339,7 @@ void func_809199FC(Actor* thisx, PlayState* play2) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, (*distanceTraveled * 255.0f)); aux = 1.0f - SQ(*distanceTraveled); - Matrix_Mult(&player->mf_CC4, MTXMODE_NEW); + Matrix_Mult(&player->leftHandMf, MTXMODE_NEW); Matrix_Translate(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)), (initialPositions->y * (1.0f - *distanceTraveled)) + 320.0f, (initialPositions->z * (1.0f - *distanceTraveled)) + -20.0f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c index fbe4c27cf6..03123fedc2 100644 --- a/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c +++ b/src/overlays/actors/ovl_Eff_Kamejima_Wave/z_eff_kamejima_wave.c @@ -4,7 +4,6 @@ * Description: Wave Created by Turtle Awakening */ -#include "prevent_bss_reordering.h" #include "z_eff_kamejima_wave.h" #include "objects/object_kamejima/object_kamejima.h" diff --git a/src/overlays/actors/ovl_En_Am/z_en_am.c b/src/overlays/actors/ovl_En_Am/z_en_am.c index 31d1372991..261b47bd42 100644 --- a/src/overlays/actors/ovl_En_Am/z_en_am.c +++ b/src/overlays/actors/ovl_En_Am/z_en_am.c @@ -422,8 +422,9 @@ void func_808B0894(EnAm* this, PlayState* play) { this->armosYaw = this->actor.yawTowardsPlayer; func_808B0208(this, play); if (this->explodeTimer == 1) { - EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 2, 0); + EnBom* bomb = + (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, BOMB_EXPLOSIVE_TYPE_BOMB, 0, 2, BOMB_TYPE_BODY); if (bomb != NULL) { bomb->timer = 0; } diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c index b94e3ecb51..aff4a9de66 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.c @@ -78,26 +78,26 @@ void EnArrow_Init(Actor* thisx, PlayState* play) { EnArrow* this = THIS; Actor_ProcessInitChain(&this->actor, sInitChain); - if (this->actor.params == -ENARROW_8) { + if (this->actor.params == -ARROW_TYPE_DEKU_NUT) { this->unk_263 = 1; - this->actor.params = ENARROW_8; + this->actor.params = ARROW_TYPE_DEKU_NUT; } - if (this->actor.params < ENARROW_6) { + if (ARROW_IS_ARROW(this->actor.params)) { SkelAnime_Init(play, &this->arrow.skelAnime, &gameplay_keep_Skel_014560, &gameplay_keep_Anim_0128BC, this->arrow.jointTable, this->arrow.jointTable, 5); - if (this->actor.params < ENARROW_3) { - if (this->actor.params == ENARROW_1) { + if (this->actor.params < ARROW_TYPE_FIRE) { + if (this->actor.params == ARROW_TYPE_NORMAL_HORSE) { D_8088C234.elemDuration = 4; } else { D_8088C234.elemDuration = 16; } Effect_Add(play, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C234); - } else if (this->actor.params == ENARROW_3) { + } else if (this->actor.params == ARROW_TYPE_FIRE) { Effect_Add(play, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C258); - } else if (this->actor.params == ENARROW_4) { + } else if (this->actor.params == ARROW_TYPE_ICE) { Effect_Add(play, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C27C); - } else if (this->actor.params == ENARROW_5) { + } else if (this->actor.params == ARROW_TYPE_LIGHT) { Effect_Add(play, &this->unk_240, EFFECT_BLURE2, 0, 0, &D_8088C2A0); } } @@ -105,20 +105,20 @@ void EnArrow_Init(Actor* thisx, PlayState* play) { Collider_InitQuad(play, &this->collider); Collider_SetQuad(play, &this->collider, &this->actor, &sQuadInit); - if (this->actor.params < ENARROW_6) { + if (ARROW_IS_ARROW(this->actor.params)) { this->collider.info.toucherFlags &= ~(TOUCH_SFX_WOOD | TOUCH_SFX_HARD); this->collider.info.toucherFlags |= 0; } - if (this->actor.params < ENARROW_0) { + if (this->actor.params < ARROW_TYPE_NORMAL_LIT) { this->collider.base.atFlags = (AT_TYPE_ENEMY | AT_ON); } else { this->collider.info.toucher.dmgFlags = Actor_GetArrowDmgFlags(this->actor.params); - if (this->actor.params == ENARROW_8) { + if (this->actor.params == ARROW_TYPE_DEKU_NUT) { this->collider.info.toucher.damage = 1; } - if (this->actor.params == ENARROW_7) { + if (this->actor.params == ARROW_TYPE_DEKU_BUBBLE) { Actor_SetScale(&this->actor, 1.0f); } } @@ -128,7 +128,7 @@ void EnArrow_Init(Actor* thisx, PlayState* play) { void EnArrow_Destroy(Actor* thisx, PlayState* play) { EnArrow* this = THIS; - if (this->actor.params < ENARROW_6) { + if (ARROW_IS_ARROW(this->actor.params)) { Effect_Destroy(play, this->unk_240); } @@ -138,7 +138,7 @@ void EnArrow_Destroy(Actor* thisx, PlayState* play) { this->unk_264->flags &= ~ACTOR_FLAG_8000; } - if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6) && (this->actor.child == NULL)) { + if (ARROW_IS_MAGICAL(this->actor.params) && (this->actor.child == NULL)) { Magic_Reset(play); } } @@ -153,7 +153,7 @@ void func_8088A594(EnArrow* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->actor.parent != NULL) { - if (this->actor.params == ENARROW_7) { + if (this->actor.params == ARROW_TYPE_DEKU_BUBBLE) { if (Math_SmoothStepToF(&this->bubble.unk_144, 16.0f, 0.07f, 1.8f, 0.0f) > 0.5f) { func_800B9010(&this->actor, NA_SE_PL_DEKUNUTS_BUBLE_BREATH - SFX_FLAG); return; @@ -166,8 +166,8 @@ void func_8088A594(EnArrow* this, PlayState* play) { } } } else { - if ((this->actor.params != ENARROW_8) && (player->unk_D57 == 0)) { - if (this->actor.params == ENARROW_7) { + if ((this->actor.params != ARROW_TYPE_DEKU_NUT) && (player->unk_D57 == 0)) { + if (this->actor.params == ARROW_TYPE_DEKU_BUBBLE) { Magic_Reset(play); } Actor_Kill(&this->actor); @@ -175,22 +175,22 @@ void func_8088A594(EnArrow* this, PlayState* play) { } switch (this->actor.params) { - case ENARROW_6: + case ARROW_TYPE_SLINGSHOT: Player_PlaySfx(player, NA_SE_IT_SLING_SHOT); break; - case ENARROW_0: - case ENARROW_1: - case ENARROW_2: + case ARROW_TYPE_NORMAL_LIT: + case ARROW_TYPE_NORMAL_HORSE: + case ARROW_TYPE_NORMAL: Player_PlaySfx(player, NA_SE_IT_ARROW_SHOT); break; - case ENARROW_3: - case ENARROW_4: - case ENARROW_5: + case ARROW_TYPE_FIRE: + case ARROW_TYPE_ICE: + case ARROW_TYPE_LIGHT: Player_PlaySfx(player, NA_SE_IT_MAGIC_ARROW_SHOT); - case ENARROW_7: + case ARROW_TYPE_DEKU_BUBBLE: Player_PlaySfx(player, NA_SE_PL_DEKUNUTS_FIRE); break; } @@ -198,13 +198,13 @@ void func_8088A594(EnArrow* this, PlayState* play) { this->actionFunc = func_8088ACE0; Math_Vec3f_Copy(&this->unk_228, &this->actor.world.pos); - if (this->actor.params == ENARROW_7) { + if (this->actor.params == ARROW_TYPE_DEKU_BUBBLE) { this->bubble.unk_144 = CLAMP_MIN(this->bubble.unk_144, 3.5f); func_8088A514(this); this->unk_260 = 99; Magic_Reset(play); - } else if (this->actor.params >= ENARROW_6) { - if ((this->actor.params == ENARROW_8) && (this->actor.world.rot.x < 0)) { + } else if (!ARROW_IS_ARROW(this->actor.params)) { + if ((this->actor.params == ARROW_TYPE_DEKU_NUT) && (this->actor.world.rot.x < 0)) { Actor_SetScale(&this->actor, 0.009f); this->unk_260 = 40; } else { @@ -295,14 +295,14 @@ void func_8088AA98(EnArrow* this, PlayState* play) { EffectSsGRipple_Spawn(play, &sp44, 100, 500, 4); EffectSsGRipple_Spawn(play, &sp44, 100, 500, 8); - if ((this->actor.params == ENARROW_4) || (this->actor.params == ENARROW_3)) { - if ((this->actor.params == ENARROW_4) && (func_8088B6B0 != this->actionFunc)) { + if ((this->actor.params == ARROW_TYPE_ICE) || (this->actor.params == ARROW_TYPE_FIRE)) { + if ((this->actor.params == ARROW_TYPE_ICE) && (func_8088B6B0 != this->actionFunc)) { Actor_Spawn(&play->actorCtx, play, ACTOR_BG_ICEFLOE, sp44.x, sp44.y, sp44.z, 0, 0, 0, 300); Actor_Kill(&this->actor); return; } - this->actor.params = ENARROW_2; + this->actor.params = ARROW_TYPE_NORMAL; this->collider.info.toucher.dmgFlags = 0x20; if (this->actor.child != NULL) { @@ -329,9 +329,9 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { s32 sp50; if ((DECR(this->unk_260) == 0) || - ((this->actor.params == ENARROW_7) && + ((this->actor.params == ARROW_TYPE_DEKU_BUBBLE) && ((this->unk_262 != 0) || (phi_a2 = (this->collider.base.atFlags & AT_HIT) != 0)))) { - if (this->actor.params == ENARROW_7) { + if (this->actor.params == ARROW_TYPE_DEKU_BUBBLE) { if (phi_a2 && (this->collider.info.atHitInfo->elemType != ELEMTYPE_UNK4) && (this->collider.base.atFlags & AT_BOUNCED)) { if ((this->collider.base.at != NULL) && (this->collider.base.at->id != ACTOR_OBJ_SYOKUDAI)) { @@ -361,18 +361,18 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { return; } - sp50 = - (this->actor.params != ENARROW_0) && (this->actor.params < ENARROW_8) && (this->collider.base.atFlags & AT_HIT); + sp50 = (this->actor.params != ARROW_TYPE_NORMAL_LIT) && (this->actor.params < ARROW_TYPE_DEKU_NUT) && + (this->collider.base.atFlags & AT_HIT); if (sp50 || (this->unk_262 != 0)) { - if (this->actor.params >= ENARROW_6) { + if (!ARROW_IS_ARROW(this->actor.params)) { if (sp50) { this->actor.world.pos.x = (this->actor.world.pos.x + this->actor.prevPos.x) * 0.5f; this->actor.world.pos.y = (this->actor.world.pos.y + this->actor.prevPos.y) * 0.5f; this->actor.world.pos.z = (this->actor.world.pos.z + this->actor.prevPos.z) * 0.5f; } - if (this->actor.params == ENARROW_8) { + if (this->actor.params == ARROW_TYPE_DEKU_NUT) { R_TRANS_FADE_FLASH_ALPHA_STEP = -1; Actor_Spawn(&play->actorCtx, play, ACTOR_EN_M_FIRE1, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, this->actor.speed == 0.0f); @@ -408,12 +408,12 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { } else if (this->unk_262 != 0) { this->actionFunc = func_8088B630; Animation_PlayOnce(&this->arrow.skelAnime, &gameplay_keep_Anim_0128BC); - if (this->actor.params >= ENARROW_0) { + if (this->actor.params >= ARROW_TYPE_NORMAL_LIT) { this->unk_260 = 60; } else { this->unk_260 = 20; } - if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6)) { + if (ARROW_IS_MAGICAL(this->actor.params)) { this->actor.draw = NULL; } Actor_PlaySfx(&this->actor, NA_SE_IT_ARROW_STICK_OBJ); @@ -422,7 +422,7 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { } } else { func_8088AA98(this, play); - if (this->actor.params == ENARROW_7) { + if (this->actor.params == ARROW_TYPE_DEKU_BUBBLE) { if (this->bubble.unk_149 == 0) { sp78 = sqrtf(SQ(this->actor.speed) + SQ(this->actor.velocity.y)); sp74 = Math_SinS(this->actor.world.rot.y) * this->actor.speed; @@ -473,7 +473,7 @@ void func_8088ACE0(EnArrow* this, PlayState* play) { this->actor.wallBgId = spA8; } - if (this->actor.params < ENARROW_6) { + if (ARROW_IS_ARROW(this->actor.params)) { this->actor.shape.rot.x = Math_Atan2S_XY(this->actor.speed, -this->actor.velocity.y); } } @@ -540,21 +540,27 @@ void EnArrow_Update(Actor* thisx, PlayState* play) { Player* player = GET_PLAYER(play); if ((this->unk_263 != 0) || - ((this->actor.params >= ENARROW_0) && ((this->actor.params == ENARROW_7) || (player->unk_D57 != 0))) || + ((this->actor.params >= ARROW_TYPE_NORMAL_LIT) && + ((this->actor.params == ARROW_TYPE_DEKU_BUBBLE) || (player->unk_D57 != 0))) || !Player_InBlockingCsMode(play, player)) { this->actionFunc(this, play); } - if ((this->actor.params >= ENARROW_3) && (this->actor.params < ENARROW_6)) { - s16 sp44[] = { ACTOR_ARROW_FIRE, ACTOR_ARROW_ICE, ACTOR_ARROW_LIGHT }; + if (ARROW_IS_MAGICAL(this->actor.params)) { + s16 sp44[] = { + ACTOR_ARROW_FIRE, // ARROW_MAGIC_FIRE + ACTOR_ARROW_ICE, // ARROW_MAGIC_ICE + ACTOR_ARROW_LIGHT, // ARROW_MAGIC_LIGHT + }; if (this->actor.child == NULL) { - Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, sp44[this->actor.params - ENARROW_3], + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, sp44[ARROW_GET_MAGIC_FROM_TYPE(this->actor.params)], this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); } - } else if (this->actor.params == ENARROW_0) { + } else if (this->actor.params == ARROW_TYPE_NORMAL_LIT) { func_800B0EB0(play, &this->unk_234, &D_8088C2CC, &D_8088C2D8, &D_8088C2E4, &D_8088C2E8, 100, 0, 8); } + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.prevPos); } @@ -579,8 +585,8 @@ void func_8088B88C(PlayState* play, EnArrow* this, EnArrowUnkStruct* arg2) { } Matrix_MultVec3f(&sp4C[0], &sp40); Matrix_MultVec3f(&sp4C[1], &sp34); - if (this->actor.params < ENARROW_8) { - sp30 = this->actor.params < ENARROW_6; + if (this->actor.params < ARROW_TYPE_DEKU_NUT) { + sp30 = ARROW_IS_ARROW(this->actor.params); if (this->unk_264 == NULL) { sp30 &= func_80126440(play, &this->collider, &this->unk_244, &sp40, &sp34); } else if (sp30 && (sp40.x == this->unk_244.tip.x) && (sp40.y == this->unk_244.tip.y) && @@ -635,11 +641,11 @@ void EnArrow_Draw(Actor* thisx, PlayState* play) { EnArrow* this = THIS; s32 phi_v0; - if (this->actor.params < ENARROW_6) { + if (ARROW_IS_ARROW(this->actor.params)) { func_8012C28C(play->state.gfxCtx); SkelAnime_DrawLod(play, this->arrow.skelAnime.skeleton, this->arrow.skelAnime.jointTable, NULL, NULL, &this->actor, this->actor.projectedPos.z < 160.0f ? 0 : 1); - } else if (this->actor.params == ENARROW_7) { + } else if (this->actor.params == ARROW_TYPE_DEKU_BUBBLE) { s32 spA4 = 255 - (s32)(this->bubble.unk_144 * 4.0f); f32 spA0 = (this->actor.speed * 0.1f) + 1.0f; f32 sp9C = (1.0f / spA0); @@ -697,7 +703,7 @@ void EnArrow_Draw(Actor* thisx, PlayState* play) { gSPClearGeometryMode(POLY_XLU_DISP++, G_FOG | G_LIGHTING); - if (this->actor.params == ENARROW_6) { + if (this->actor.params == ARROW_TYPE_SLINGSHOT) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, sp63); sp5C = 50.0f; @@ -737,5 +743,6 @@ void EnArrow_Draw(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } + func_8088B88C(play, this, &D_8088C2EC[0]); } diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h index 313dd86bbb..14d5bef947 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h @@ -7,17 +7,30 @@ struct EnArrow; typedef void (*EnArrowActionFunc)(struct EnArrow*, PlayState*); -enum { - /* 0 */ ENARROW_0, // Lit arrow - /* 1 */ ENARROW_1, // Horse arrow - /* 2 */ ENARROW_2, // Normal arrow - /* 3 */ ENARROW_3, // Fire arrow - /* 4 */ ENARROW_4, // Ice arrow - /* 5 */ ENARROW_5, // Light arrow - /* 6 */ ENARROW_6, // ? - /* 7 */ ENARROW_7, // Deku bubble - /* 8 */ ENARROW_8, // Deku Nut -}; +typedef enum ArrowType { + /* 0 */ ARROW_TYPE_NORMAL_LIT, // Normal arrow lit on fire + /* 1 */ ARROW_TYPE_NORMAL_HORSE, // Normal arrow shot while riding a horse + /* 2 */ ARROW_TYPE_NORMAL, + /* 3 */ ARROW_TYPE_FIRE, + /* 4 */ ARROW_TYPE_ICE, + /* 5 */ ARROW_TYPE_LIGHT, + /* 6 */ ARROW_TYPE_SLINGSHOT, + /* 7 */ ARROW_TYPE_DEKU_BUBBLE, + /* 8 */ ARROW_TYPE_DEKU_NUT +} ArrowType; + +#define ARROW_IS_MAGICAL(arrowType) (((arrowType) >= ARROW_TYPE_FIRE) && ((arrowType) <= ARROW_TYPE_LIGHT)) +#define ARROW_GET_MAGIC_FROM_TYPE(arrowType) (s32)((arrowType) - ARROW_TYPE_FIRE) +#define ARROW_IS_ARROW(arrowType) ((arrowType) < ARROW_TYPE_SLINGSHOT) + +typedef enum ArrowMagic { + /* -1 */ ARROW_MAGIC_INVALID = -1, + /* 0 */ ARROW_MAGIC_FIRE = ARROW_GET_MAGIC_FROM_TYPE(ARROW_TYPE_FIRE), + /* 1 */ ARROW_MAGIC_ICE = ARROW_GET_MAGIC_FROM_TYPE(ARROW_TYPE_ICE), + /* 2 */ ARROW_MAGIC_LIGHT = ARROW_GET_MAGIC_FROM_TYPE(ARROW_TYPE_LIGHT), + /* 3 */ ARROW_MAGIC_DEKU_BUBBLE // Only used in Player. Does not map to ARROW_TYPE_SLINGSHOT +} ArrowMagic; + typedef struct { /* 0x144 */ SkelAnime skelAnime; diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.c b/src/overlays/actors/ovl_En_Bom/z_en_bom.c index 17ebe10f7d..cb9c6e3ec4 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.c +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.c @@ -348,7 +348,7 @@ void EnBom_Explode(EnBom* this, PlayState* play) { this->collider2.elements->dim.worldSphere.radius = D_80872E8C[this->isPowderKeg]; if (this->timer == 7) { - this->collider2.base.atFlags &= ~OC1_TYPE_1; + this->collider2.base.atFlags &= ~AT_TYPE_ENEMY; } if (this->actor.params == BOMB_TYPE_EXPLOSION) { diff --git a/src/overlays/actors/ovl_En_Bom/z_en_bom.h b/src/overlays/actors/ovl_En_Bom/z_en_bom.h index bf568cd6aa..40558a9199 100644 --- a/src/overlays/actors/ovl_En_Bom/z_en_bom.h +++ b/src/overlays/actors/ovl_En_Bom/z_en_bom.h @@ -11,11 +11,17 @@ typedef void (*EnBomActionFunc)(struct EnBom*, PlayState*); #define ENBOM_GETZ_80(thisx) ((thisx)->shape.rot.z & 0x80) #define ENBOM_GETZ_FF00(thisx) (((thisx)->shape.rot.z & 0xFF00) >> 8) -typedef enum { +typedef enum BombType { /* 0 */ BOMB_TYPE_BODY, /* 1 */ BOMB_TYPE_EXPLOSION, } BombType; +// Passed via x rotation +typedef enum EnBomExplosiveType { + /* 0 */ BOMB_EXPLOSIVE_TYPE_BOMB, + /* 1 */ BOMB_EXPLOSIVE_TYPE_POWDER_KEG, +} EnBomExplosiveType; + typedef struct EnBom { /* 0x000 */ Actor actor; /* 0x144 */ ColliderCylinder collider1; diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index a2246b4426..8d24616497 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -326,7 +326,7 @@ void EnBomChu_Explode(EnBomChu* this, PlayState* play) { s32 i; bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, 0, 0, 0); + this->actor.world.pos.z, BOMB_EXPLOSIVE_TYPE_BOMB, 0, 0, BOMB_TYPE_BODY); this->shouldTimerCountDown = true; this->isMoving = false; diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.c b/src/overlays/actors/ovl_En_Boom/z_en_boom.c index 4abfad7b17..eacaa3dce0 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.c +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.c @@ -164,7 +164,7 @@ void EnBoom_Destroy(Actor* thisx, PlayState* play) { } void func_808A2918(EnBoom* this, PlayState* play) { - Actor* sp7C; + Actor* targetActor; Player* player = GET_PLAYER(play); s32 sp74; s16 sp72; @@ -175,25 +175,26 @@ void func_808A2918(EnBoom* this, PlayState* play) { f32 sp64; f32 distXYZ; - sp7C = this->player; + targetActor = this->moveTo; - if (sp7C != NULL) { - sp72 = Actor_WorldYawTowardPoint(&this->actor, &sp7C->focus.pos); + if (targetActor != NULL) { + sp72 = Actor_WorldYawTowardPoint(&this->actor, &targetActor->focus.pos); sp70 = this->actor.world.rot.y - sp72; - sp6E = Actor_WorldPitchTowardPoint(&this->actor, &sp7C->focus.pos); + sp6E = Actor_WorldPitchTowardPoint(&this->actor, &targetActor->focus.pos); sp6C = this->actor.world.rot.x - sp6E; - sp64 = (200.0f - Math_Vec3f_DistXYZ(&this->actor.world.pos, &sp7C->focus.pos)) * 0.005f; + sp64 = (200.0f - Math_Vec3f_DistXYZ(&this->actor.world.pos, &targetActor->focus.pos)) * 0.005f; if (sp64 < 0.12f) { sp64 = 0.12f; } - if ((&player->actor != sp7C) && ((sp7C->update == NULL) || ((this->unk_1CF < 0) && (ABS_ALT(sp70) > 0x4000)))) { - this->player = NULL; + if ((&player->actor != targetActor) && + ((targetActor->update == NULL) || ((this->unk_1CF < 0) && (ABS_ALT(sp70) > 0x4000)))) { + this->moveTo = NULL; } else { if (this->unk_1CE != 0) { this->unk_1CE--; - this->actor.world.rot.y += (this->actor.params == 0) ? 0x190 : -0x190; + this->actor.world.rot.y += (this->actor.params == ZORA_BOOMERANG_LEFT) ? 0x190 : -0x190; } else { if (this->unk_1CF > 0) { this->unk_1CF--; @@ -242,7 +243,7 @@ void func_808A2918(EnBoom* this, PlayState* play) { if (sp74 != 0) { this->actor.world.rot.x = -this->actor.world.rot.x; this->actor.world.rot.y += 0x8000; - this->player = &player->actor; + this->moveTo = &player->actor; this->unk_1CC = 0; } } @@ -250,34 +251,34 @@ void func_808A2918(EnBoom* this, PlayState* play) { if (this->unk_1CC <= 16) { distXYZ = Math_Vec3f_DistXYZ(&this->actor.world.pos, &player->actor.focus.pos); - if (&player->actor != this->player) { - if (this->player == 0) { + if (&player->actor != this->moveTo) { + if (this->moveTo == 0) { this->unk_1CE = 8; } - this->player = &player->actor; + this->moveTo = &player->actor; } if (distXYZ < 40.0f) { - sp7C = this->unk_1C8; - if (sp7C != NULL) { - Math_Vec3f_Copy(&sp7C->world.pos, &player->actor.world.pos); - if (sp7C->id == ACTOR_EN_ITEM00) { - sp7C->gravity = -0.9f; - sp7C->bgCheckFlags &= ~(BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH); + targetActor = this->unk_1C8; + if (targetActor != NULL) { + Math_Vec3f_Copy(&targetActor->world.pos, &player->actor.world.pos); + if (targetActor->id == ACTOR_EN_ITEM00) { + targetActor->gravity = -0.9f; + targetActor->bgCheckFlags &= ~(BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH); } else { - sp7C->flags &= ~ACTOR_FLAG_2000; + targetActor->flags &= ~ACTOR_FLAG_2000; } } Actor_Kill(&this->actor); } } - sp7C = this->unk_1C8; - if (sp7C != NULL) { - if (sp7C->update == NULL) { + targetActor = this->unk_1C8; + if (targetActor != NULL) { + if (targetActor->update == NULL) { this->unk_1C8 = NULL; } else { - Math_Vec3f_Copy(&sp7C->world.pos, &this->actor.world.pos); + Math_Vec3f_Copy(&targetActor->world.pos, &this->actor.world.pos); } } } @@ -298,7 +299,7 @@ void EnBoom_Update(Actor* thisx, PlayState* play) { Actor_SetFocus(&this->actor, 0.0f); } - if (this->actor.params != 0) { + if (this->actor.params != ZORA_BOOMERANG_LEFT) { this->unk_1CD--; } else { this->unk_1CD++; @@ -326,7 +327,7 @@ void EnBoom_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); Matrix_RotateYS(this->actor.world.rot.y, MTXMODE_APPLY); - Matrix_RotateZS((this->actor.params != 0) ? 0x1F40 : -0x1F40, MTXMODE_APPLY); + Matrix_RotateZS((this->actor.params != ZORA_BOOMERANG_LEFT) ? 0x1F40 : -0x1F40, MTXMODE_APPLY); Matrix_RotateXS(this->actor.world.rot.x, MTXMODE_APPLY); Matrix_MultVec3f(&sp58->unk_04, &sp4C); Matrix_MultVec3f(&sp58->unk_10, &sp40); diff --git a/src/overlays/actors/ovl_En_Boom/z_en_boom.h b/src/overlays/actors/ovl_En_Boom/z_en_boom.h index e5e3fa2b34..7bae2b150e 100644 --- a/src/overlays/actors/ovl_En_Boom/z_en_boom.h +++ b/src/overlays/actors/ovl_En_Boom/z_en_boom.h @@ -3,6 +3,11 @@ #include "global.h" +typedef enum { + /* 0 */ ZORA_BOOMERANG_LEFT, + /* 1 */ ZORA_BOOMERANG_RIGHT +} EnBoomType; + struct EnBoom; typedef void (*EnBoomActionFunc)(struct EnBoom*, PlayState*); @@ -10,7 +15,7 @@ typedef void (*EnBoomActionFunc)(struct EnBoom*, PlayState*); typedef struct EnBoom { /* 0x000 */ Actor actor; /* 0x144 */ ColliderQuad collider; - /* 0x1C4 */ Actor* player; + /* 0x1C4 */ Actor* moveTo; /* 0x1C8 */ Actor* unk_1C8; /* 0x1CC */ u8 unk_1CC; /* 0x1CD */ u8 unk_1CD; diff --git a/src/overlays/actors/ovl_En_Butte/z_en_butte.c b/src/overlays/actors/ovl_En_Butte/z_en_butte.c index 05072da729..4055399e21 100644 --- a/src/overlays/actors/ovl_En_Butte/z_en_butte.c +++ b/src/overlays/actors/ovl_En_Butte/z_en_butte.c @@ -416,7 +416,7 @@ void EnButte_Update(Actor* thisx, PlayState* play) { this->unk_258 += 0x600; if (ENBUTTE_GET_1(&this->actor) == ENBUTTE_1) { - if (GET_PLAYER(play)->meleeWeaponState == 0) { + if (GET_PLAYER(play)->meleeWeaponState == PLAYER_MELEE_WEAPON_STATE_0) { if (this->unk_252 > 0) { this->unk_252--; } diff --git a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c index 6f7d32de14..def6dd27a1 100644 --- a/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c +++ b/src/overlays/actors/ovl_En_Col_Man/z_en_col_man.c @@ -203,7 +203,8 @@ void func_80AFE25C(EnColMan* this, PlayState* play) { CLEAR_TAG_SMALL_EXPLOSION); } else { EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + this->actor.world.pos.y, this->actor.world.pos.z, + BOMB_EXPLOSIVE_TYPE_BOMB, 0, 0, BOMB_TYPE_BODY); if (bomb != NULL) { bomb->timer = 0; diff --git a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c index 535b0d65f3..8446ff4137 100644 --- a/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c +++ b/src/overlays/actors/ovl_En_Dinofos/z_en_dinofos.c @@ -438,8 +438,9 @@ s32 func_8089AE00(EnDinofos* this, PlayState* play) { return true; } - if ((this->actor.xzDistToPlayer < 100.0f) && (player->meleeWeaponState != 0) && this->actor.isTargeted && - (Rand_ZeroOne() < 0.5f) && func_8089A968(this) && Player_IsFacingActor(&this->actor, 0x2000, play)) { + if ((this->actor.xzDistToPlayer < 100.0f) && (player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) && + this->actor.isTargeted && (Rand_ZeroOne() < 0.5f) && func_8089A968(this) && + Player_IsFacingActor(&this->actor, 0x2000, play)) { if (Rand_ZeroOne() < 0.5f) { func_8089C024(this, 2); } else { diff --git a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c index a578143377..c2fd7acf19 100644 --- a/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c +++ b/src/overlays/actors/ovl_En_Dodongo/z_en_dodongo.c @@ -914,7 +914,8 @@ void func_808787B0(EnDodongo* this, PlayState* play) { if (SkelAnime_Update(&this->skelAnime)) { if (this->timer == 0) { EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 0); + this->actor.world.pos.y, this->actor.world.pos.z, + BOMB_EXPLOSIVE_TYPE_BOMB, 0, 0, BOMB_TYPE_BODY); if (bomb != NULL) { bomb->timer = 0; } diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index e2b225e238..47a7bcd34d 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -15,7 +15,6 @@ #include "objects/object_wdor03/object_wdor03.h" #include "objects/object_wdor04/object_wdor04.h" #include "objects/object_wdor05/object_wdor05.h" -#include "objects/gameplay_keep/gameplay_keep.h" #include "objects/object_numa_obj/object_numa_obj.h" #include "objects/object_kaizoku_obj/object_kaizoku_obj.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" @@ -387,21 +386,22 @@ static Gfx* D_808679A4[14][2] = { void EnDoor_Init(Actor* thisx, PlayState* play2) { PlayState* play = play2; s32 objectBankIndex; - EnDoorInfo* objectInfo = sObjInfo; + EnDoorInfo* objectInfo = &sObjInfo[0]; EnDoor* this = THIS; s32 i; - Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + Actor_ProcessInitChain(&this->knobDoor.dyna.actor, sInitChain); - this->unk_1A4 = ENDOOR_GET_PARAMS_7(thisx); + this->doorType = ENDOOR_GET_TYPE(thisx); this->switchFlag = ENDOOR_GET_PARAMS_7F(thisx); - if ((this->unk_1A4 == 7) && (this->switchFlag == 0)) { - DynaPolyActor_Init(&this->dyna, 0); - DynaPolyActor_LoadMesh(play, &this->dyna, &gDoorCol); + if ((this->doorType == ENDOOR_TYPE_7) && (this->switchFlag == 0)) { + DynaPolyActor_Init(&this->knobDoor.dyna, 0); + DynaPolyActor_LoadMesh(play, &this->knobDoor.dyna, &gDoorCol); } - SkelAnime_Init(play, &this->skelAnime, &gDoorSkel, &gameplay_keep_Anim_020658, this->limbTable, this->limbTable, 5); - if (this->unk_1A4 == 5) { + SkelAnime_Init(play, &this->knobDoor.skelAnime, &gDoorSkel, &gameplay_keep_Anim_020658, this->limbTable, + this->limbTable, DOOR_LIMB_MAX); + if (this->doorType == ENDOOR_TYPE_5) { objectInfo = &sObjInfo[17 + this->switchFlag]; } else { for (i = 0; i < ARRAY_COUNT(sObjInfo) - 34; i++, objectInfo++) { @@ -414,52 +414,53 @@ void EnDoor_Init(Actor* thisx, PlayState* play2) { } } - this->dlIndex = objectInfo->dListIndex; + this->knobDoor.dlIndex = objectInfo->dListIndex; objectBankIndex = Object_GetIndex(&play->objectCtx, objectInfo->objectId); if (objectBankIndex < 0) { objectInfo = &sObjInfo[15]; objectBankIndex = Object_GetIndex(&play->objectCtx, objectInfo->objectId); if (objectBankIndex != 0) { - Actor_Kill(&this->dyna.actor); + Actor_Kill(&this->knobDoor.dyna.actor); return; } } - this->requiredObjBankIndex = objectBankIndex; - this->dlIndex = objectInfo->dListIndex; // Set twice? - if (this->dyna.actor.objBankIndex == this->requiredObjBankIndex) { + this->knobDoor.requiredObjBankIndex = objectBankIndex; + this->knobDoor.dlIndex = objectInfo->dListIndex; // Set twice? + if (this->knobDoor.dyna.actor.objBankIndex == this->knobDoor.requiredObjBankIndex) { func_80866A5C(this, play); } else { this->actionFunc = func_80866A5C; } - Actor_SetFocus(&this->dyna.actor, 35.0f); + Actor_SetFocus(&this->knobDoor.dyna.actor, 35.0f); } void EnDoor_Destroy(Actor* thisx, PlayState* play) { EnDoor* this = (EnDoor*)thisx; - if (this->unk_1A4 != 7) { - TransitionActorEntry* transitionEntry = &play->doorCtx.transitionActorList[(u16)this->dyna.actor.params >> 0xA]; + if (this->doorType != ENDOOR_TYPE_7) { + TransitionActorEntry* transitionEntry = + &play->doorCtx.transitionActorList[DOOR_GET_TRANSITION_ID(&this->knobDoor.dyna.actor)]; if (transitionEntry->id < 0) { transitionEntry->id = -transitionEntry->id; } } else if (this->switchFlag == 0) { - DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->knobDoor.dyna.bgId); } } void func_80866A5C(EnDoor* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->requiredObjBankIndex)) { - this->dyna.actor.objBankIndex = this->requiredObjBankIndex; + if (Object_IsLoaded(&play->objectCtx, this->knobDoor.requiredObjBankIndex)) { + this->knobDoor.dyna.actor.objBankIndex = this->knobDoor.requiredObjBankIndex; this->actionFunc = func_80866B20; - this->dyna.actor.world.rot.y = 0; - if (this->unk_1A4 == 1) { + this->knobDoor.dyna.actor.world.rot.y = 0; + if (this->doorType == ENDOOR_TYPE_1) { if (!Flags_GetSwitch(play, this->switchFlag)) { this->unk_1A6 = 10; } - } else if ((this->unk_1A4 == 4) && - (Actor_WorldDistXZToActor(&this->dyna.actor, &GET_PLAYER(play)->actor) > 120.0f)) { + } else if ((this->doorType == ENDOOR_TYPE_4) && + (Actor_WorldDistXZToActor(&this->knobDoor.dyna.actor, &GET_PLAYER(play)->actor) > 120.0f)) { this->actionFunc = func_8086704C; - this->dyna.actor.world.rot.y = -0x1800; + this->knobDoor.dyna.actor.world.rot.y = -0x1800; } } } @@ -468,28 +469,29 @@ void func_80866B20(EnDoor* this, PlayState* play) { static s32 D_80867BC0; Player* player = GET_PLAYER(play); - if (Actor_ProcessTalkRequest(&this->dyna.actor, &play->state) && (this->dyna.actor.textId == 0x1821)) { + if (Actor_ProcessTalkRequest(&this->knobDoor.dyna.actor, &play->state) && + (this->knobDoor.dyna.actor.textId == 0x1821)) { D_80867BC0 = true; } - if (this->unk_1A1 != 0) { + if (this->knobDoor.playOpenAnim) { this->actionFunc = func_80867144; - Animation_PlayOnceSetSpeed(&this->skelAnime, sAnimations[this->animIndex], + Animation_PlayOnceSetSpeed(&this->knobDoor.skelAnime, sAnimations[this->knobDoor.animIndex], (player->stateFlags1 & PLAYER_STATE1_8000000) ? 0.75f : 1.5f); if (this->unk_1A6 != 0) { gSaveContext.save.saveInfo.inventory.dungeonKeys[gSaveContext.mapIndex]--; Flags_SetSwitch(play, this->switchFlag); - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK); + Actor_PlaySfx(&this->knobDoor.dyna.actor, NA_SE_EV_CHAIN_KEY_UNLOCK); } } else if (this->unk_1A7 != 0) { this->actionFunc = func_80866F94; - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_DOOR_OPEN); + Actor_PlaySfx(&this->knobDoor.dyna.actor, NA_SE_EV_DOOR_OPEN); } else if (!Player_InCsMode(play)) { Vec3f playerPosRelToDoor; - Actor_OffsetOfPointInActorCoords(&this->dyna.actor, &playerPosRelToDoor, &player->actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->knobDoor.dyna.actor, &playerPosRelToDoor, &player->actor.world.pos); if (D_80867BC0 || ((fabsf(playerPosRelToDoor.y) < 20.0f) && (fabsf(playerPosRelToDoor.x) < 20.0f) && (fabsf(playerPosRelToDoor.z) < 50.0f))) { - s16 yawDiff = player->actor.shape.rot.y - this->dyna.actor.shape.rot.y; + s16 yawDiff = player->actor.shape.rot.y - this->knobDoor.dyna.actor.shape.rot.y; if (playerPosRelToDoor.z > 0.0f) { yawDiff = (0x8000 - yawDiff); @@ -497,51 +499,52 @@ void func_80866B20(EnDoor* this, PlayState* play) { if (ABS_ALT(yawDiff) < 0x3000) { player->doorType = PLAYER_DOORTYPE_HANDLE; player->doorDirection = playerPosRelToDoor.z >= 0.0f ? 1.0f : -1.0f; - player->doorActor = &this->dyna.actor; + player->doorActor = &this->knobDoor.dyna.actor; if (this->unk_1A6 != 0) { if (gSaveContext.save.saveInfo.inventory.dungeonKeys[((void)0, gSaveContext.mapIndex)] <= 0) { player->doorType = PLAYER_DOORTYPE_TALKING; - this->dyna.actor.textId = 0x1802; + this->knobDoor.dyna.actor.textId = 0x1802; } else { player->doorTimer = 10; } - } else if (this->unk_1A4 == 4) { + } else if (this->doorType == ENDOOR_TYPE_4) { player->doorType = PLAYER_DOORTYPE_TALKING; - this->dyna.actor.textId = 0x1800; - } else if ((this->unk_1A4 == 0) || (this->unk_1A4 == 2) || (this->unk_1A4 == 3)) { + this->knobDoor.dyna.actor.textId = 0x1800; + } else if ((this->doorType == ENDOOR_TYPE_0) || (this->doorType == ENDOOR_TYPE_2) || + (this->doorType == ENDOOR_TYPE_3)) { s32 halfDaysDayBit = (play->actorCtx.halfDaysBit & HALFDAYBIT_DAWNS) >> 1; s32 halfDaysNightBit = play->actorCtx.halfDaysBit & HALFDAYBIT_NIGHTS; s16 temp_a2 = D_801AED48[this->switchFlag & 7]; s32 textIdOffset = (this->switchFlag >> 3) & 0xF; - if (((this->unk_1A4 == 0) && !((halfDaysDayBit | halfDaysNightBit) & temp_a2)) || - ((this->unk_1A4 == 2) && !(halfDaysNightBit & temp_a2)) || - ((this->unk_1A4 == 3) && !(halfDaysDayBit & temp_a2))) { + if (((this->doorType == ENDOOR_TYPE_0) && !((halfDaysDayBit | halfDaysNightBit) & temp_a2)) || + ((this->doorType == ENDOOR_TYPE_2) && !(halfDaysNightBit & temp_a2)) || + ((this->doorType == ENDOOR_TYPE_3) && !(halfDaysDayBit & temp_a2))) { s16 baseTextId = 0x182D; - if (this->unk_1A4 == 3) { + if (this->doorType == ENDOOR_TYPE_3) { baseTextId = 0x180D; - } else if (this->unk_1A4 == 2) { + } else if (this->doorType == ENDOOR_TYPE_2) { baseTextId = 0x181D; } player->doorType = PLAYER_DOORTYPE_TALKING; - this->dyna.actor.textId = baseTextId + textIdOffset; + this->knobDoor.dyna.actor.textId = baseTextId + textIdOffset; } - } else if ((this->unk_1A4 == 5) && (playerPosRelToDoor.z > 0.0f)) { + } else if ((this->doorType == ENDOOR_TYPE_5) && (playerPosRelToDoor.z > 0.0f)) { ScheduleOutput scheduleOutput; if (Schedule_RunScript(play, D_8086778C[this->switchFlag], &scheduleOutput)) { - this->dyna.actor.textId = scheduleOutput.result + 0x1800; + this->knobDoor.dyna.actor.textId = scheduleOutput.result + 0x1800; - player->doorType = ((this->dyna.actor.textId == 0x1821) && D_80867BC0) + player->doorType = ((this->knobDoor.dyna.actor.textId == 0x1821) && D_80867BC0) ? PLAYER_DOORTYPE_PROXIMITY : PLAYER_DOORTYPE_TALKING; } } func_80122F28(player); } - } else if ((this->unk_1A4 == 4) && (this->dyna.actor.xzDistToPlayer > 240.0f)) { - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_DOOR_OPEN); + } else if ((this->doorType == ENDOOR_TYPE_4) && (this->knobDoor.dyna.actor.xzDistToPlayer > 240.0f)) { + Actor_PlaySfx(&this->knobDoor.dyna.actor, NA_SE_EV_DOOR_OPEN); this->actionFunc = func_80867080; } } @@ -556,34 +559,34 @@ void func_80866F94(EnDoor* this, PlayState* play) { } else { direction = -1; } - if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, direction * 0x3E80, 0x7D0)) { + if (Math_ScaledStepToS(&this->knobDoor.dyna.actor.world.rot.y, direction * 0x3E80, 0x7D0)) { Math_StepToC(&this->unk_1A7, 0, 1); } } else { - if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, 0, 0x7D0)) { + if (Math_ScaledStepToS(&this->knobDoor.dyna.actor.world.rot.y, 0, 0x7D0)) { this->actionFunc = func_80866B20; - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_AUTO_DOOR_CLOSE); + Actor_PlaySfx(&this->knobDoor.dyna.actor, NA_SE_EV_AUTO_DOOR_CLOSE); } } } void func_8086704C(EnDoor* this, PlayState* play) { - if (this->dyna.actor.xzDistToPlayer < 120.0f) { + if (this->knobDoor.dyna.actor.xzDistToPlayer < 120.0f) { this->actionFunc = func_808670F0; } } void func_80867080(EnDoor* this, PlayState* play) { - if (this->dyna.actor.xzDistToPlayer < 120.0f) { + if (this->knobDoor.dyna.actor.xzDistToPlayer < 120.0f) { this->actionFunc = func_808670F0; - } else if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, -0x1800, 0x100)) { + } else if (Math_ScaledStepToS(&this->knobDoor.dyna.actor.world.rot.y, -0x1800, 0x100)) { this->actionFunc = func_8086704C; } } void func_808670F0(EnDoor* this, PlayState* play) { - if (Math_ScaledStepToS(&this->dyna.actor.world.rot.y, 0, 0x700)) { - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_DOOR_CLOSE); + if (Math_ScaledStepToS(&this->knobDoor.dyna.actor.world.rot.y, 0, 0x700)) { + Actor_PlaySfx(&this->knobDoor.dyna.actor, NA_SE_EV_DOOR_CLOSE); this->actionFunc = func_80866B20; } } @@ -593,19 +596,19 @@ void func_80867144(EnDoor* this, PlayState* play) { s32 i; if (DECR(this->unk_1A6) == 0) { - if (SkelAnime_Update(&this->skelAnime) != 0) { + if (SkelAnime_Update(&this->knobDoor.skelAnime)) { this->actionFunc = func_80866B20; - this->unk_1A1 = 0; - } else if (Animation_OnFrame(&this->skelAnime, sAnimOpenFrames[this->animIndex])) { - Actor_PlaySfx(&this->dyna.actor, NA_SE_OC_DOOR_OPEN); - if (this->skelAnime.playSpeed < 1.5f) { + this->knobDoor.playOpenAnim = false; + } else if (Animation_OnFrame(&this->knobDoor.skelAnime, sAnimOpenFrames[this->knobDoor.animIndex])) { + Actor_PlaySfx(&this->knobDoor.dyna.actor, NA_SE_OC_DOOR_OPEN); + if (this->knobDoor.skelAnime.playSpeed < 1.5f) { numEffects = (s32)(Rand_ZeroOne() * 30.0f) + 50; for (i = 0; i < numEffects; i++) { - EffectSsBubble_Spawn(play, &this->dyna.actor.world.pos, 60.0, 100.0f, 50.0f, 0.15f); + EffectSsBubble_Spawn(play, &this->knobDoor.dyna.actor.world.pos, 60.0, 100.0f, 50.0f, 0.15f); } } - } else if (Animation_OnFrame(&this->skelAnime, sAnimCloseFrames[this->animIndex])) { - Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_DOOR_CLOSE); + } else if (Animation_OnFrame(&this->knobDoor.skelAnime, sAnimCloseFrames[this->knobDoor.animIndex])) { + Actor_PlaySfx(&this->knobDoor.dyna.actor, NA_SE_EV_DOOR_CLOSE); } } } @@ -620,28 +623,28 @@ s32 EnDoor_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* TransitionActorEntry* transitionEntry; EnDoor* this = THIS; - if (limbIndex == 4) { - Gfx** dl = D_808679A4[this->dlIndex]; + if (limbIndex == DOOR_LIMB_4) { + Gfx** dl = D_808679A4[this->knobDoor.dlIndex]; s16 temp; s32 dlIndex; transitionEntry = NULL; - if (this->unk_1A4 != 7) { - transitionEntry = &play->doorCtx.transitionActorList[(u16)this->dyna.actor.params >> 0xA]; + if (this->doorType != ENDOOR_TYPE_7) { + transitionEntry = &play->doorCtx.transitionActorList[DOOR_GET_TRANSITION_ID(&this->knobDoor.dyna.actor)]; } - rot->z += this->dyna.actor.world.rot.y; - if ((this->unk_1A4 == 7) || (play->roomCtx.prevRoom.num >= 0) || + rot->z += this->knobDoor.dyna.actor.world.rot.y; + if ((this->doorType == ENDOOR_TYPE_7) || (play->roomCtx.prevRoom.num >= 0) || (transitionEntry->sides[0].room == transitionEntry->sides[1].room)) { s32 pad; - temp = (this->dyna.actor.shape.rot.y + this->skelAnime.jointTable[3].z + rot->z) - - Math_Vec3f_Yaw(&play->view.eye, &this->dyna.actor.world.pos); + temp = (this->knobDoor.dyna.actor.shape.rot.y + this->knobDoor.skelAnime.jointTable[3].z + rot->z) - + Math_Vec3f_Yaw(&play->view.eye, &this->knobDoor.dyna.actor.world.pos); *dList = (ABS_ALT(temp) < 0x4000) ? dl[0] : dl[1]; } else { dlIndex = 0; - if (transitionEntry->sides[0].room != this->dyna.actor.room) { + if (transitionEntry->sides[0].room != this->knobDoor.dyna.actor.room) { dlIndex = 1; } *dList = dl[dlIndex]; @@ -653,17 +656,17 @@ s32 EnDoor_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* void EnDoor_Draw(Actor* thisx, PlayState* play) { EnDoor* this = THIS; - if (this->dyna.actor.objBankIndex == this->requiredObjBankIndex) { + if (this->knobDoor.dyna.actor.objBankIndex == this->knobDoor.requiredObjBankIndex) { OPEN_DISPS(play->state.gfxCtx); - if ((this->unk_1A4 == 7) && (this->switchFlag == 0)) { + if ((this->doorType == ENDOOR_TYPE_7) && (this->switchFlag == 0)) { Gfx_DrawDListOpa(play, gameplay_keep_DL_0221B8); } else { func_8012C28C(play->state.gfxCtx); } - SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, EnDoor_OverrideLimbDraw, NULL, - &this->dyna.actor); - if (this->dyna.actor.world.rot.y != 0) { - if (this->dyna.actor.world.rot.y > 0) { + SkelAnime_DrawOpa(play, this->knobDoor.skelAnime.skeleton, this->knobDoor.skelAnime.jointTable, + EnDoor_OverrideLimbDraw, NULL, &this->knobDoor.dyna.actor); + if (this->knobDoor.dyna.actor.world.rot.y != 0) { + if (this->knobDoor.dyna.actor.world.rot.y > 0) { gSPDisplayList(POLY_OPA_DISP++, gDoorRightDL); } else { gSPDisplayList(POLY_OPA_DISP++, gDoorLeftDL); diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.h b/src/overlays/actors/ovl_En_Door/z_en_door.h index bea44a1226..b6fc7c2544 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.h +++ b/src/overlays/actors/ovl_En_Door/z_en_door.h @@ -2,27 +2,34 @@ #define Z_EN_DOOR_H #include "global.h" +#include "z64door.h" +#include "objects/gameplay_keep/gameplay_keep.h" struct EnDoor; typedef void (*EnDoorActionFunc)(struct EnDoor*, PlayState*); -#define ENDOOR_GET_PARAMS_7(thisx) (((thisx)->params >> 7) & 7) +#define ENDOOR_GET_TYPE(thisx) (((thisx)->params >> 7) & 7) #define ENDOOR_GET_PARAMS_7F(thisx) (((thisx)->params) & 0x7F) +typedef enum EnDoorType { + /* 0 */ ENDOOR_TYPE_0, + /* 1 */ ENDOOR_TYPE_1, + /* 2 */ ENDOOR_TYPE_2, + /* 3 */ ENDOOR_TYPE_3, + /* 4 */ ENDOOR_TYPE_4, + /* 5 */ ENDOOR_TYPE_5, + /* 6 */ ENDOOR_TYPE_6, + /* 7 */ ENDOOR_TYPE_7 +} EnDoorType; typedef struct EnDoor { - /* 0x000 */ DynaPolyActor dyna; - /* 0x15C */ SkelAnime skelAnime; - /* 0x1A0 */ u8 animIndex; - /* 0x1A1 */ u8 unk_1A1; - /* 0x1A2 */ s8 requiredObjBankIndex; - /* 0x1A3 */ s8 dlIndex; - /* 0x1A4 */ u8 unk_1A4; + /* 0x000 */ KnobDoorActor knobDoor; + /* 0x1A4 */ u8 doorType; /* 0x1A5 */ u8 switchFlag; /* 0x1A6 */ u8 unk_1A6; /* 0x1A7 */ s8 unk_1A7; - /* 0x1A8 */ Vec3s limbTable[5]; + /* 0x1A8 */ Vec3s limbTable[DOOR_LIMB_MAX]; /* 0x1C8 */ EnDoorActionFunc actionFunc; } EnDoor; diff --git a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c index 8959dde7ac..84902f5400 100644 --- a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c +++ b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.c @@ -92,9 +92,9 @@ void EnDoorEtc_Init(Actor* thisx, PlayState* play2) { s32 i; EnDoorEtc* this = THIS; - Actor_ProcessInitChain(&this->actor, sInitChain); - Actor_SetScale(&this->actor, 0.01f); - this->actor.shape.rot.x = -0x4000; + Actor_ProcessInitChain(&this->knobDoor.dyna.actor, sInitChain); + Actor_SetScale(&this->knobDoor.dyna.actor, 0.01f); + this->knobDoor.dyna.actor.shape.rot.x = -0x4000; this->angle = 0; for (i = 0; i < 15; i++, objectInfo++) { if (play->sceneId == objectInfo->sceneId) { @@ -106,19 +106,19 @@ void EnDoorEtc_Init(Actor* thisx, PlayState* play2) { } objectIndex = Object_GetIndex(&play->objectCtx, objectInfo->objectId); if (objectIndex < 0) { - Actor_Kill(&this->actor); + Actor_Kill(&this->knobDoor.dyna.actor); } else { - this->objectIndex = objectIndex; - this->dListIndex = objectInfo->dListIndex; - if (this->actor.objBankIndex == this->objectIndex) { + this->knobDoor.requiredObjBankIndex = objectIndex; + this->knobDoor.dlIndex = objectInfo->dListIndex; + if (this->knobDoor.dyna.actor.objBankIndex == this->knobDoor.requiredObjBankIndex) { EnDoorEtc_WaitForObject(this, play); } else { this->actionFunc = EnDoorEtc_WaitForObject; } } Collider_InitCylinder(play, &this->collider); - Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); - this->actor.colChkInfo.mass = MASS_IMMOVABLE; + Collider_SetCylinder(play, &this->collider, &this->knobDoor.dyna.actor, &sCylinderInit); + this->knobDoor.dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; } void EnDoorEtc_Destroy(Actor* thisx, PlayState* play) { @@ -139,11 +139,11 @@ s32 EnDoorEtc_IsDistanceGreater(Vec3f* a, Vec3f* b, f32 c) { } void EnDoorEtc_WaitForObject(EnDoorEtc* this, PlayState* play) { - if (Object_IsLoaded(&play->objectCtx, this->objectIndex)) { - this->actor.flags &= ~ACTOR_FLAG_10; - this->actor.objBankIndex = this->objectIndex; + if (Object_IsLoaded(&play->objectCtx, this->knobDoor.requiredObjBankIndex)) { + this->knobDoor.dyna.actor.flags &= ~ACTOR_FLAG_10; + this->knobDoor.dyna.actor.objBankIndex = this->knobDoor.requiredObjBankIndex; this->actionFunc = func_80AC2354; - this->actor.draw = EnDoorEtc_Draw; + this->knobDoor.dyna.actor.draw = EnDoorEtc_Draw; } } @@ -175,27 +175,28 @@ void func_80AC21A0(EnDoorEtc* this, PlayState* play) { s16 yawDiff; s32 yawDiffAbs; - Actor_OffsetOfPointInActorCoords(&this->actor, &playerOffsetFromDoor, &player->actor.world.pos); - if (this->unk_1A1 == 0) { + Actor_OffsetOfPointInActorCoords(&this->knobDoor.dyna.actor, &playerOffsetFromDoor, &player->actor.world.pos); + if (!this->knobDoor.playOpenAnim) { if ((!Player_InCsMode(play)) && ((fabsf(playerOffsetFromDoor.y) < 20.0f) && fabsf(playerOffsetFromDoor.x) < 20.0f) && (fabsf(playerOffsetFromDoor.z) < 50.0f)) { - yawDiff = player->actor.shape.rot.y - this->actor.shape.rot.y; + yawDiff = player->actor.shape.rot.y - this->knobDoor.dyna.actor.shape.rot.y; if (playerOffsetFromDoor.z > 0.0f) { yawDiff = 0x8000 - yawDiff; } yawDiffAbs = ABS_ALT(yawDiff); if (yawDiffAbs < 0x3000) { player->doorDirection = (playerOffsetFromDoor.z >= 0.0f) ? 1.0f : -1.0f; - player->doorActor = &this->actor; - player->doorType = -1; + player->doorActor = &this->knobDoor.dyna.actor; + player->doorType = PLAYER_DOORTYPE_TALKING; } } } - if ((this->actor.textId == 0x239B) && Flags_GetSwitch(play, ENDOORETC_GET_SWITCHFLAG(&this->actor))) { - Flags_UnsetSwitch(play, ENDOORETC_GET_SWITCHFLAG(&this->actor)); + if ((this->knobDoor.dyna.actor.textId == 0x239B) && + Flags_GetSwitch(play, ENDOORETC_GET_SWITCHFLAG(&this->knobDoor.dyna.actor))) { + Flags_UnsetSwitch(play, ENDOORETC_GET_SWITCHFLAG(&this->knobDoor.dyna.actor)); this->actionFunc = func_80AC2154; - this->actor.textId = 0x1800; // "It won't budge!" + this->knobDoor.dyna.actor.textId = 0x1800; // "It won't budge!" this->unk_1F4 |= 1; this->timer = 0x5A; } @@ -206,18 +207,18 @@ void func_80AC2354(EnDoorEtc* this, PlayState* play) { while (door != NULL) { if ((door->id != ACTOR_EN_DOOR) || - !EnDoorEtc_IsDistanceGreater(&door->world.pos, &this->actor.world.pos, 10.0f)) { + !EnDoorEtc_IsDistanceGreater(&door->world.pos, &this->knobDoor.dyna.actor.world.pos, 10.0f)) { door = door->next; } else { - this->actor.world.pos.x = door->world.pos.x; - this->actor.world.pos.y = door->world.pos.y; - this->actor.world.pos.z = door->world.pos.z; - this->actor.shape.rot.y = door->shape.rot.y; - this->actor.world.rot.y = door->world.rot.y; + this->knobDoor.dyna.actor.world.pos.x = door->world.pos.x; + this->knobDoor.dyna.actor.world.pos.y = door->world.pos.y; + this->knobDoor.dyna.actor.world.pos.z = door->world.pos.z; + this->knobDoor.dyna.actor.shape.rot.y = door->shape.rot.y; + this->knobDoor.dyna.actor.world.rot.y = door->world.rot.y; Actor_Kill(door); this->actionFunc = func_80AC21A0; - this->actor.textId = 0x239B; - Actor_SetFocus(&this->actor, 70.0f); + this->knobDoor.dyna.actor.textId = 0x239B; + Actor_SetFocus(&this->knobDoor.dyna.actor, 70.0f); break; } } @@ -229,7 +230,7 @@ void EnDoorEtc_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); if (this->unk_1F4 & 1) { - Collider_UpdateCylinder(&this->actor, &this->collider); + Collider_UpdateCylinder(&this->knobDoor.dyna.actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } } diff --git a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h index 49ca83f2aa..9cd63248fd 100644 --- a/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h +++ b/src/overlays/actors/ovl_En_Door_Etc/z_en_door_etc.h @@ -2,6 +2,7 @@ #define Z_EN_DOOR_ETC_H #include "global.h" +#include "z64door.h" struct EnDoorEtc; @@ -10,11 +11,7 @@ struct EnDoorEtc; typedef void (*EnDoorEtcActionFunc)(struct EnDoorEtc*, PlayState*); typedef struct EnDoorEtc { - /* 0x000 */ Actor actor; - /* 0x144 */ char pad_144[0x5D]; - /* 0x1A1 */ u8 unk_1A1; - /* 0x1A2 */ s8 objectIndex; - /* 0x1A3 */ u8 dListIndex; // Never read, inferred from ovl_En_Door + /* 0x000 */ KnobDoorActor knobDoor; /* 0x1A4 */ s16 angle; /* 0x1A6 */ s16 timer; /* 0x1A8 */ ColliderCylinder collider; diff --git a/src/overlays/actors/ovl_En_Egol/z_en_egol.c b/src/overlays/actors/ovl_En_Egol/z_en_egol.c index 2c7fdc030b..0f9b4c7667 100644 --- a/src/overlays/actors/ovl_En_Egol/z_en_egol.c +++ b/src/overlays/actors/ovl_En_Egol/z_en_egol.c @@ -1268,7 +1268,8 @@ void EnEgol_Update(Actor* thisx, PlayState* play) { // last argument is DMG_ZORA_BOOMERANG | DMG_HOOKSHOT | DMG_NORMAL_ARROW | DMG_FIRE_ARROW | DMG_ICE_ARROW | // DMG_LIGHT_ARROW | DMG_DEKU_BUBBLE - if ((projectile != NULL) && !((projectile->id == ACTOR_EN_ARROW) && (projectile->params == ENARROW_5))) { + if ((projectile != NULL) && + !((projectile->id == ACTOR_EN_ARROW) && (projectile->params == ARROW_TYPE_LIGHT))) { this->eyelidRotTarget = 0xFA0; this->eyeShutTimer = 20; if (this->action == EYEGORE_ACTION_LASER) { diff --git a/src/overlays/actors/ovl_En_Famos/z_en_famos.c b/src/overlays/actors/ovl_En_Famos/z_en_famos.c index 3d68d34d71..097822dd16 100644 --- a/src/overlays/actors/ovl_En_Famos/z_en_famos.c +++ b/src/overlays/actors/ovl_En_Famos/z_en_famos.c @@ -489,7 +489,7 @@ void EnFamos_SetupChase(EnFamos* this) { void EnFamos_Chase(EnFamos* this, PlayState* play) { Player* player = GET_PLAYER(play); Vec3f abovePlayerPos; - u32 surfaceType; + FloorProperty surfaceType; EnFamos_UpdateBobbingHeight(this); Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0x800); @@ -502,7 +502,7 @@ void EnFamos_Chase(EnFamos* this, PlayState* play) { surfaceType = SurfaceType_GetFloorProperty2(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); if ((this->actor.xzDistToPlayer < 30.0f) && (this->actor.floorHeight > BGCHECK_Y_MIN) && // close enough - (surfaceType != 0xC && surfaceType != 0xD)) { + (surfaceType != FLOOR_PROPERTY_12 && surfaceType != FLOOR_PROPERTY_13)) { EnFamos_SetupAttackAim(this); } else if ((Player_GetMask(play) == PLAYER_MASK_STONE) || @@ -689,9 +689,9 @@ void EnFamos_DeathExplosion(EnFamos* this, PlayState* play) { this->actor.world.pos.x = randPlusMinusPoint5Scaled(5.0f) + this->targetDest.x; this->actor.world.pos.z = randPlusMinusPoint5Scaled(5.0f) + this->targetDest.z; if (this->stateTimer == 1) { - EnBom* explosion = - (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, 0, 0, 0, BOMB_TYPE_BODY); + EnBom* explosion = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, + this->actor.world.pos.y + 40.0f, this->actor.world.pos.z, + BOMB_EXPLOSIVE_TYPE_BOMB, 0, 0, BOMB_TYPE_BODY); if (explosion != NULL) { explosion->timer = 0; // instant explosion } diff --git a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c index 306f1d94dc..d9645885ec 100644 --- a/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c +++ b/src/overlays/actors/ovl_En_Fishing/z_en_fishing.c @@ -1949,25 +1949,25 @@ void EnFishing_DrawRod(PlayState* play) { D_8090CD34 = 0.0f; } - spC8 = player->unk_B08[1]; - Math_SmoothStepToF(&player->unk_B08[1], input->rel.stick_y * 0.02f, 0.3f, 5.0f, 0.0f); - spC8 = player->unk_B08[1] - spC8; + spC8 = player->unk_B0C; + Math_SmoothStepToF(&player->unk_B0C, input->rel.stick_y * 0.02f, 0.3f, 5.0f, 0.0f); + spC8 = player->unk_B0C - spC8; - spC4 = player->unk_B08[0]; - Math_SmoothStepToF(&player->unk_B08[0], input->rel.stick_x * 0.02f, 0.3f, 5.0f, 0.0f); - spC4 = player->unk_B08[0] - spC4; + spC4 = player->unk_B08; + Math_SmoothStepToF(&player->unk_B08, input->rel.stick_x * 0.02f, 0.3f, 5.0f, 0.0f); + spC4 = player->unk_B08 - spC4; - if (player->unk_B08[0] > 1.0f) { - player->unk_B08[0] = 1.0f; + if (player->unk_B08 > 1.0f) { + player->unk_B08 = 1.0f; } - if (player->unk_B08[1] > 1.0f) { - player->unk_B08[1] = 1.0f; + if (player->unk_B0C > 1.0f) { + player->unk_B0C = 1.0f; } - if (player->unk_B08[0] < -1.0f) { - player->unk_B08[0] = -1.0f; + if (player->unk_B08 < -1.0f) { + player->unk_B08 = -1.0f; } - if (player->unk_B08[1] < -1.0f) { - player->unk_B08[1] = -1.0f; + if (player->unk_B0C < -1.0f) { + player->unk_B0C = -1.0f; } Math_ApproachF(&D_8090CD28, spC4 * 70.0f * -0.01f, 1.0f, D_8090CD30); @@ -1976,8 +1976,8 @@ void EnFishing_DrawRod(PlayState* play) { Math_ApproachF(&D_8090CD34, 1.0f, 1.0f, 0.1f); Math_ApproachZeroF(&D_8090CD38, 1.0f, 0.05f); } else { - Math_ApproachZeroF(&player->unk_B08[1], 1.0f, 0.1f); - Math_ApproachZeroF(&player->unk_B08[0], 1.0f, 0.1f); + Math_ApproachZeroF(&player->unk_B0C, 1.0f, 0.1f); + Math_ApproachZeroF(&player->unk_B08, 1.0f, 0.1f); Math_ApproachF(&D_8090CD2C, (Math_SinS(D_809171FE * 3000) * 0.025f) + -0.03f, 1.0f, 0.05f); Math_ApproachZeroF(&D_8090CD28, 1.0f, 0.05f); @@ -1994,7 +1994,7 @@ void EnFishing_DrawRod(PlayState* play) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 155, 0, 255); - Matrix_Mult(&player->mf_CC4, MTXMODE_NEW); + Matrix_Mult(&player->leftHandMf, MTXMODE_NEW); if (sLinkAge != 1) { Matrix_Translate(0.0f, 400.0f, 0.0f, MTXMODE_APPLY); @@ -2009,11 +2009,11 @@ void EnFishing_DrawRod(PlayState* play) { } Matrix_RotateXFApply(-0.6283185f); - Matrix_RotateZF((player->unk_B08[0] * 0.5f) + 0.4712389f, MTXMODE_APPLY); + Matrix_RotateZF((player->unk_B08 * 0.5f) + 0.4712389f, MTXMODE_APPLY); Matrix_RotateXFApply((D_8090CD40 + 20.0f) * 0.01f * M_PI); Matrix_Scale(0.70000005f, 0.70000005f, 0.70000005f, MTXMODE_APPLY); - spC0 = (D_8090CD3C * (((player->unk_B08[1] - 1.0f) * -0.25f) + 0.5f)) + (D_8090CD2C + D_8090CD38); + spC0 = (D_8090CD3C * (((player->unk_B0C - 1.0f) * -0.25f) + 0.5f)) + (D_8090CD2C + D_8090CD38); Matrix_Translate(0.0f, 0.0f, -1300.0f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index f31dd7cd23..573b911c4f 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -1019,7 +1019,7 @@ s32 func_8094F904(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { this->timePath = SubS_GetAdditionalPath(play, sp55, D_80951A0C[scheduleOutput->result]); } - if ((door != NULL) && (door->dyna.actor.update != NULL)) { + if ((door != NULL) && (door->knobDoor.dyna.actor.update != NULL)) { if (this->timePath != NULL) { sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); @@ -1029,7 +1029,7 @@ s32 func_8094F904(EnGm* this, PlayState* play, ScheduleOutput* scheduleOutput) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, door->dyna.actor.shape.rot.y)) <= 0x4000) { + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, door->knobDoor.dyna.actor.shape.rot.y)) <= 0x4000) { this->unk_261 = -75; } else { this->unk_261 = 75; @@ -1450,7 +1450,7 @@ s32 func_80950804(EnGm* this, PlayState* play) { door = func_8094DF90(play, this->unk_258); if (!SubS_InCsMode(play) && (this->timePathTimeSpeed != 0)) { - if ((door != NULL) && (door->dyna.actor.update != NULL)) { + if ((door != NULL) && (door->knobDoor.dyna.actor.update != NULL)) { if ((this->unk_3BA / (f32)this->unk_3B8) <= 0.9f) { door->unk_1A7 = this->unk_261; } else { diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index 3f993ae3a4..edf1cb104f 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -6,6 +6,7 @@ #include "z_en_go.h" #include "z64quake.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/object_oF1d_map/object_oF1d_map.h" #include "objects/object_hakugin_demo/object_hakugin_demo.h" #include "objects/object_taisou/object_taisou.h" @@ -1249,7 +1250,8 @@ s32 func_80A13E80(EnGo* this, PlayState* play) { func_80A12C48(this, play, 1); Lib_Vec3f_TranslateAndRotateY(&this->actor.world.pos, this->actor.shape.rot.y, &D_80A166A4, &sp48); gSaveContext.powderKegTimer = 2400; - Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, sp48.x, sp48.y, sp48.z, 1, 0, 0, 0); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, sp48.x, sp48.y, sp48.z, BOMB_EXPLOSIVE_TYPE_POWDER_KEG, + 0, 0, BOMB_TYPE_BODY); func_80A134B0(this, play, 1); this->unk_3C2 = 0; this->unk_3C0++; diff --git a/src/overlays/actors/ovl_En_Gs/z_en_gs.c b/src/overlays/actors/ovl_En_Gs/z_en_gs.c index 6d8e649319..b9f6acb681 100644 --- a/src/overlays/actors/ovl_En_Gs/z_en_gs.c +++ b/src/overlays/actors/ovl_En_Gs/z_en_gs.c @@ -5,6 +5,7 @@ */ #include "z_en_gs.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" #include "objects/object_gs/object_gs.h" #include "objects/gameplay_keep/gameplay_keep.h" @@ -871,7 +872,7 @@ s32 func_809995A4(EnGs* this, PlayState* play) { if (this->actor.playerHeightRel < -12000.0f) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, - this->actor.world.pos.z, 0, this->actor.world.rot.y, 0, 0); + this->actor.world.pos.z, BOMB_EXPLOSIVE_TYPE_BOMB, this->actor.world.rot.y, 0, BOMB_TYPE_BODY); Actor_Kill(&this->actor); sp7C = 0; } diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index 44e42d01aa..a88c8bb380 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -279,8 +279,8 @@ void func_80B22500(EnHakurock* this, PlayState* play) { } else if ((&player->actor == this->collider.base.oc) && (player->stateFlags3 & (PLAYER_STATE3_1000 | PLAYER_STATE3_80000)) && (player->linearVelocity > 8.0f)) { - player->unk_B08[0] = player->linearVelocity = -5.0f; - player->unk_B08[1] += (player->linearVelocity * 0.05f); + player->unk_B08 = player->linearVelocity = -5.0f; + player->unk_B0C += (player->linearVelocity * 0.05f); player->actor.velocity.y = 5.0f; player->currentYaw = player->actor.world.rot.y; player->actor.home.rot.y = player->actor.world.rot.y; diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index f12599df72..2e68c75d66 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -108,18 +108,6 @@ typedef struct { RaceWaypoint* waypoints; } RaceInfo; -typedef enum { - /* 0 */ ENHORSE_ANIM_IDLE, - /* 1 */ ENHORSE_ANIM_WHINNY, - /* 2 */ ENHORSE_ANIM_STOPPING, - /* 3 */ ENHORSE_ANIM_REARING, - /* 4 */ ENHORSE_ANIM_WALK, - /* 5 */ ENHORSE_ANIM_TROT, - /* 6 */ ENHORSE_ANIM_GALLOP, - /* 7 */ ENHORSE_ANIM_LOW_JUMP, - /* 8 */ ENHORSE_ANIM_HIGH_JUMP -} EnHorseAnimation; - static AnimationHeader* sEponaAnimations[] = { &object_horse_link_child_Anim_006D44, &object_horse_link_child_Anim_007468, &object_horse_link_child_Anim_005F64, &object_horse_link_child_Anim_004DE8, &object_horse_link_child_Anim_007D50, &object_horse_link_child_Anim_0043AC, diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.h b/src/overlays/actors/ovl_En_Horse/z_en_horse.h index b2c58bcadb..9f8cd20633 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.h +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.h @@ -75,7 +75,7 @@ typedef enum EnHorseAction { /* 25 */ ENHORSE_ACTION_25 } EnHorseAction; -typedef enum { +typedef enum EnHorsePlayerDir { /* 0 */ PLAYER_DIR_FRONT_R, /* 1 */ PLAYER_DIR_FRONT_L, /* 2 */ PLAYER_DIR_BACK_R, @@ -84,7 +84,19 @@ typedef enum { /* 5 */ PLAYER_DIR_SIDE_L } EnHorsePlayerDir; -typedef enum { +typedef enum EnHorseAnimation { + /* 0 */ ENHORSE_ANIM_IDLE, + /* 1 */ ENHORSE_ANIM_WHINNY, + /* 2 */ ENHORSE_ANIM_STOPPING, + /* 3 */ ENHORSE_ANIM_REARING, + /* 4 */ ENHORSE_ANIM_WALK, + /* 5 */ ENHORSE_ANIM_TROT, + /* 6 */ ENHORSE_ANIM_GALLOP, + /* 7 */ ENHORSE_ANIM_LOW_JUMP, + /* 8 */ ENHORSE_ANIM_HIGH_JUMP +} EnHorseAnimation; + +typedef enum HorseType { /* 0 */ HORSE_TYPE_EPONA, /* 1 */ HORSE_TYPE_HNI, /* 2 */ HORSE_TYPE_2, diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index e053a85289..a0960a60f8 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -556,7 +556,7 @@ s32 func_80BF1DF4(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { this->timePath = SubS_GetAdditionalPath(play, sp55, D_80BF3318[scheduleOutput->result]); } - if ((door != NULL) && (door->dyna.actor.update != NULL)) { + if ((door != NULL) && (door->knobDoor.dyna.actor.update != NULL)) { if (this->timePath != NULL) { sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); @@ -566,7 +566,7 @@ s32 func_80BF1DF4(EnIg* this, PlayState* play, ScheduleOutput* scheduleOutput) { this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, door->dyna.actor.shape.rot.y)) <= 0x4000) { + if (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, door->knobDoor.dyna.actor.shape.rot.y)) <= 0x4000) { this->unk_2A4 = -75; } else { this->unk_2A4 = 75; @@ -735,7 +735,7 @@ s32 func_80BF2470(EnIg* this, PlayState* play) { s32 pad; if (!SubS_InCsMode(play) && (this->timePathTimeSpeed != 0)) { - if ((door != NULL) && (door->dyna.actor.update != NULL)) { + if ((door != NULL) && (door->knobDoor.dyna.actor.update != NULL)) { if (((f32)this->unk_3E2 / this->unk_3E0) <= 0.9f) { door->unk_1A7 = this->unk_2A4; } else { diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.c b/src/overlays/actors/ovl_En_Js/z_en_js.c index 8f48622c85..2134ded5bc 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -377,7 +377,7 @@ void EnJs_TakeMask(s32 itemActions, s32 childType) { s32 temp = 0; if ((childType >= 0) && (childType < 9)) { - itemActions -= PLAYER_IA_MASK_TRUTH; + itemActions -= PLAYER_IA_MASK_MIN; childType *= 3; if (itemActions < 8) { masksGivenOnMoon[childType] |= 1 << itemActions; @@ -543,7 +543,7 @@ void func_80969748(EnJs* this, PlayState* play) { } if (itemAction > PLAYER_IA_NONE) { Message_CloseTextbox(play); - if ((itemAction >= PLAYER_IA_MASK_TRUTH) && (itemAction <= PLAYER_IA_MASK_GIANT)) { + if ((itemAction >= PLAYER_IA_MASK_MIN) && (itemAction < PLAYER_IA_MASK_TRANSFORMATION_MIN)) { EnJs_TakeMask(itemAction, ENJS_GET_TYPE(&this->actor)); Inventory_UnequipItem(itemAction - 4); if (!func_809692A8(ENJS_GET_TYPE(&this->actor))) { @@ -551,7 +551,7 @@ void func_80969748(EnJs* this, PlayState* play) { } else { player->actor.textId = 0x2213; } - } else if ((itemAction >= PLAYER_IA_MASK_FIERCE_DEITY) && (itemAction <= PLAYER_IA_MASK_DEKU)) { + } else if ((itemAction >= PLAYER_IA_MASK_TRANSFORMATION_MIN) && (itemAction <= PLAYER_IA_MASK_MAX)) { player->actor.textId = 0x2211; } else { player->actor.textId = 0x2210; @@ -692,7 +692,7 @@ void func_80969C54(EnJs* this, PlayState* play) { if (itemAction > PLAYER_IA_NONE) { Message_CloseTextbox(play); - if ((itemAction >= PLAYER_IA_MASK_TRUTH) && (itemAction <= PLAYER_IA_MASK_GIANT)) { + if ((itemAction >= PLAYER_IA_MASK_MIN) && (itemAction < PLAYER_IA_MASK_TRANSFORMATION_MIN)) { EnJs_TakeMask(itemAction, ENJS_GET_TYPE(&this->actor)); Inventory_UnequipItem(itemAction - 4); if (!func_809692A8(ENJS_GET_TYPE(&this->actor))) { @@ -700,7 +700,7 @@ void func_80969C54(EnJs* this, PlayState* play) { } else { player->actor.textId = 0x2222; } - } else if ((itemAction >= PLAYER_IA_MASK_FIERCE_DEITY) && (itemAction <= PLAYER_IA_MASK_DEKU)) { + } else if ((itemAction >= PLAYER_IA_MASK_TRANSFORMATION_MIN) && (itemAction <= PLAYER_IA_MASK_MAX)) { player->actor.textId = 0x2220; } else { player->actor.textId = 0x221D; diff --git a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c index 7d8f46f91e..e90b14f829 100644 --- a/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c +++ b/src/overlays/actors/ovl_En_Kaizoku/z_en_kaizoku.c @@ -902,7 +902,8 @@ void func_80B872F4(EnKaizoku* this, PlayState* play) { if ((this->lookTimer == 0) && !func_80B85858(this, play) && !func_80B85A00(this, play, false)) { s16 yawDiff = this->picto.actor.yawTowardsPlayer - this->picto.actor.shape.rot.y; - if ((this->picto.actor.xzDistToPlayer < 100.0f) && (player->meleeWeaponState != 0) && (yawDiff >= 0x1F40)) { + if ((this->picto.actor.xzDistToPlayer < 100.0f) && (player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) && + (yawDiff >= 0x1F40)) { this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; func_80B88CD8(this); } else if (Actor_IsFacingPlayer(&this->picto.actor, 0xBB8)) { @@ -1285,7 +1286,8 @@ void func_80B88378(EnKaizoku* this, PlayState* play) { this->skelAnime.playSpeed = 1.0f; sp2A = ABS_ALT(player->actor.shape.rot.y - this->picto.actor.shape.rot.y); - if (this->picto.actor.xzDistToPlayer < 150.0f && player->meleeWeaponState != 0 && sp2A >= 0x2000) { + if ((this->picto.actor.xzDistToPlayer < 150.0f) && (player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) && + (sp2A >= 0x2000)) { this->picto.actor.shape.rot.y = this->picto.actor.world.rot.y = this->picto.actor.yawTowardsPlayer; if (Rand_ZeroOne() > 0.7f) { func_80B88CD8(this); @@ -1938,8 +1940,8 @@ void func_80B89A08(EnKaizoku* this, PlayState* play) { pos.z = this->bodyCollider.info.bumper.hitPos.z; if (player->transformation != PLAYER_FORM_HUMAN) { - player->unk_B84 = this->picto.actor.yawTowardsPlayer; - player->unk_B80 = 15.0f; + player->pushedYaw = this->picto.actor.yawTowardsPlayer; + player->pushedSpeed = 15.0f; } this->bodyCollider.base.acFlags &= ~AC_HIT; diff --git a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c index c3cdeae33b..24147b0d1a 100644 --- a/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c +++ b/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c @@ -359,8 +359,8 @@ s32 func_80B26BF8(EnKendoJs* this, PlayState* play) { return 0; } - if ((player->meleeWeaponState != 0) || (player->stateFlags3 & PLAYER_STATE3_8000000) || - (player->stateFlags2 & PLAYER_STATE2_80000)) { + if ((player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) || + (player->stateFlags3 & PLAYER_STATE3_8000000) || (player->stateFlags2 & PLAYER_STATE2_80000)) { return 1; } break; @@ -370,7 +370,8 @@ s32 func_80B26BF8(EnKendoJs* this, PlayState* play) { return 0; } - if ((player->meleeWeaponState != 0) || (player->stateFlags2 & PLAYER_STATE2_80000)) { + if ((player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) || + (player->stateFlags2 & PLAYER_STATE2_80000)) { return 1; } break; @@ -380,8 +381,8 @@ s32 func_80B26BF8(EnKendoJs* this, PlayState* play) { return 0; } - if ((player->meleeWeaponState != 0) || (player->stateFlags3 & PLAYER_STATE3_8000000) || - (player->stateFlags2 & PLAYER_STATE2_80000)) { + if ((player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) || + (player->stateFlags3 & PLAYER_STATE3_8000000) || (player->stateFlags2 & PLAYER_STATE2_80000)) { return 1; } this->unk_28E = 0; diff --git a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c index 0586b21117..1b9cb743ac 100644 --- a/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c +++ b/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c @@ -144,7 +144,7 @@ void EnMThunder_Init(Actor* thisx, PlayState* play) { this->isCharging = false; if (CHECK_WEEKEVENTREG(WEEKEVENTREG_23_02)) { - player->unk_B08[0] = 1.0f; + player->unk_B08 = 1.0f; this->collider.info.toucher.damage = sDamages[this->type + ENMTHUNDER_TYPE_MAX]; this->subtype = ENMTHUNDER_SUBTYPE_SPIN_GREAT; if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { @@ -155,7 +155,7 @@ void EnMThunder_Init(Actor* thisx, PlayState* play) { this->scaleTarget = 3; } } else { - player->unk_B08[0] = 0.5f; + player->unk_B08 = 0.5f; this->collider.info.toucher.damage = sDamages[this->type]; this->subtype = ENMTHUNDER_SUBTYPE_SPIN_REGULAR; if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { @@ -229,11 +229,11 @@ void EnMThunder_Charge(EnMThunder* this, PlayState* play) { Player* player = GET_PLAYER(play); Actor* child = this->actor.child; - this->unk1B0 = player->unk_B08[0]; + this->unk1B0 = player->unk_B08; this->actor.world.pos = player->bodyPartsPos[0]; this->actor.shape.rot.y = player->actor.shape.rot.y + 0x8000; - if (!this->isCharging && (player->unk_B08[0] >= 0.1f)) { + if (!this->isCharging && (player->unk_B08 >= 0.1f)) { if ((gSaveContext.magicState != MAGIC_STATE_IDLE) || ((ENMTHUNDER_GET_MAGIC_COST(&this->actor) != 0) && !Magic_Consume(play, ENMTHUNDER_GET_MAGIC_COST(&this->actor), MAGIC_CONSUME_WAIT_PREVIEW))) { @@ -247,8 +247,8 @@ void EnMThunder_Charge(EnMThunder* this, PlayState* play) { this->isCharging = true; } - if (player->unk_B08[0] >= 0.1f) { - Rumble_Request(0.0f, (s32)(player->unk_B08[0] * 150.0f), 2, (s32)(player->unk_B08[0] * 150.0f)); + if (player->unk_B08 >= 0.1f) { + Rumble_Request(0.0f, (s32)(player->unk_B08 * 150.0f), 2, (s32)(player->unk_B08 * 150.0f)); } if (player->stateFlags2 & PLAYER_STATE2_20000) { @@ -256,8 +256,8 @@ void EnMThunder_Charge(EnMThunder* this, PlayState* play) { child->parent = NULL; } - if (player->unk_B08[0] <= 0.15f) { - if ((player->unk_B08[0] >= 0.1f) && (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H)) { + if (player->unk_B08 <= 0.15f) { + if ((player->unk_B08 >= 0.1f) && (player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H)) { AudioSfx_PlaySfx(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); AudioSfx_PlaySfx(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, @@ -273,7 +273,7 @@ void EnMThunder_Charge(EnMThunder* this, PlayState* play) { gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; } - if (player->unk_B08[0] < 0.85f) { + if (player->unk_B08 < 0.85f) { this->collider.info.toucher.damage = sDamages[this->type]; this->subtype = ENMTHUNDER_SUBTYPE_SPIN_REGULAR; if (this->type == ENMTHUNDER_TYPE_GREAT_FAIRY_SWORD) { @@ -320,26 +320,26 @@ void EnMThunder_Charge(EnMThunder* this, PlayState* play) { return; } - if (player->unk_B08[0] > 0.15f) { + if (player->unk_B08 > 0.15f) { this->chargingAlpha = 255; if (this->actor.child == NULL) { Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EFF_DUST, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, EFF_DUST_TYPE_SPIN_ATTACK_CHARGE); } - this->adjustLightsArg1 += (((player->unk_B08[0] - 0.15f) * 1.5f) - this->adjustLightsArg1) * 0.5f; - } else if (player->unk_B08[0] > .1f) { - this->chargingAlpha = (s32)((player->unk_B08[0] - .1f) * 255.0f * 20.0f); - this->lightColorFrac = (player->unk_B08[0] - .1f) * 10.0f; + this->adjustLightsArg1 += (((player->unk_B08 - 0.15f) * 1.5f) - this->adjustLightsArg1) * 0.5f; + } else if (player->unk_B08 > .1f) { + this->chargingAlpha = (s32)((player->unk_B08 - .1f) * 255.0f * 20.0f); + this->lightColorFrac = (player->unk_B08 - .1f) * 10.0f; } else { this->chargingAlpha = 0; } - if (player->unk_B08[0] > 0.85f) { + if (player->unk_B08 > 0.85f) { func_8019F900(&player->actor.projectedPos, 2); - } else if (player->unk_B08[0] > 0.15f) { + } else if (player->unk_B08 > 0.15f) { func_8019F900(&player->actor.projectedPos, 1); - } else if (player->unk_B08[0] > 0.1f) { + } else if (player->unk_B08 > 0.1f) { func_8019F900(&player->actor.projectedPos, 0); } @@ -540,7 +540,7 @@ void EnMThunder_Draw(Actor* thisx, PlayState* play2) { break; } - Matrix_Mult(&player->mf_CC4, MTXMODE_NEW); + Matrix_Mult(&player->leftHandMf, MTXMODE_NEW); if (this->type == ENMTHUNDER_TYPE_GILDED_SWORD) { Matrix_Translate(0.0f, 220.0f, 0.0f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c index 95890455cf..7d79bcd75d 100644 --- a/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c +++ b/src/overlays/actors/ovl_En_Maruta/z_en_maruta.c @@ -491,11 +491,11 @@ s32 func_80B37B78(EnMaruta* this, PlayState* play) { s16 temp_v1 = BINANG_SUB(this->actor.yawTowardsPlayer, 0x8000); temp_v1 = BINANG_SUB(temp_v1, player->actor.shape.rot.y); - if ((ABS_ALT(temp_v1) < 0x1555) || - ((player->meleeWeaponState != 0) && ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || - (player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_COMBO_1H) || - (player->meleeWeaponAnimation == PLAYER_MWA_SPIN_ATTACK_1H) || - (player->meleeWeaponAnimation == PLAYER_MWA_BIG_SPIN_1H)))) { + if ((ABS_ALT(temp_v1) < 0x1555) || ((player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) && + ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_COMBO_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_SPIN_ATTACK_1H) || + (player->meleeWeaponAnimation == PLAYER_MWA_BIG_SPIN_1H)))) { return true; } return false; diff --git a/src/overlays/actors/ovl_En_Ot/z_en_ot.c b/src/overlays/actors/ovl_En_Ot/z_en_ot.c index a4d8203645..aefebdfc4c 100644 --- a/src/overlays/actors/ovl_En_Ot/z_en_ot.c +++ b/src/overlays/actors/ovl_En_Ot/z_en_ot.c @@ -4,6 +4,7 @@ * Description: Seahorse */ +#include "prevent_bss_reordering.h" #include "z_en_ot.h" #include "objects/object_ot/object_ot.h" #include "objects/gameplay_keep/gameplay_keep.h" diff --git a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c index 2f4678b8db..d45cacbae7 100644 --- a/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c +++ b/src/overlays/actors/ovl_En_Peehat/z_en_peehat.c @@ -660,8 +660,9 @@ void func_80898654(EnPeehat* this) { void func_808986A4(EnPeehat* this, PlayState* play) { if (this->unk_2B0 == 5) { - EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0x602, 0); + EnBom* bomb = + (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, BOMB_EXPLOSIVE_TYPE_BOMB, 0, 0x602, BOMB_TYPE_BODY); if (bomb != NULL) { bomb->timer = 0; diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 088d5c8a4d..f00d64fcae 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -1242,7 +1242,7 @@ s32 func_80AF9008(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { this->timePath = SubS_GetAdditionalPath(play, sp55, D_80AFB430[scheduleOutput->result]); } - if ((door != NULL) && (door->dyna.actor.update != NULL)) { + if ((door != NULL) && (door->knobDoor.dyna.actor.update != NULL)) { if (this->timePath != 0) { sp4C = Lib_SegmentedToVirtual(this->timePath->points); Math_Vec3s_ToVec3f(&sp40, &sp4C[0]); @@ -1251,7 +1251,7 @@ s32 func_80AF9008(EnPm* this, PlayState* play, ScheduleOutput* scheduleOutput) { Math_Vec3f_Copy(&this->unk_278, &sp34); this->actor.world.rot.y = Math_Vec3f_Yaw(&sp40, &sp34); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); - temp = this->actor.world.rot.y - door->dyna.actor.shape.rot.y; + temp = this->actor.world.rot.y - door->knobDoor.dyna.actor.shape.rot.y; if (ABS_ALT(temp) <= 0x4000) { this->unk_260 = -0x4B; } else { @@ -1704,7 +1704,7 @@ s32 func_80AF9D04(EnPm* this, PlayState* play) { f32 temp; if (!SubS_InCsMode(play) && (this->timePathTimeSpeed != 0)) { - if ((door != NULL) && (door->dyna.actor.update != NULL)) { + if ((door != NULL) && (door->knobDoor.dyna.actor.update != NULL)) { if (((f32)this->unk_36E / this->unk_36C) <= 0.9f) { door->unk_1A7 = this->unk_260; } else { diff --git a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c index 53ae734795..3516364bae 100644 --- a/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c +++ b/src/overlays/actors/ovl_En_Po_Sisters/z_en_po_sisters.c @@ -243,7 +243,8 @@ void EnPoSisters_MatchPlayerXZ(EnPoSisters* this, PlayState* play) { f32 dist; if (this->megCloneId == POE_SISTERS_MEG_REAL || this->actionFunc != EnPoSisters_DamageFlinch) { - if ((player->meleeWeaponState == 0 || player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H) && + if ((player->meleeWeaponState == PLAYER_MELEE_WEAPON_STATE_0 || + player->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H) && ((player->actor.world.pos.y - player->actor.floorHeight) < 1.0f)) { Math_StepToF(&this->megDistToPlayer, 110.0f, 3.0f); } else { diff --git a/src/overlays/actors/ovl_En_Rat/z_en_rat.c b/src/overlays/actors/ovl_En_Rat/z_en_rat.c index 81898dfa6d..8badfe7414 100644 --- a/src/overlays/actors/ovl_En_Rat/z_en_rat.c +++ b/src/overlays/actors/ovl_En_Rat/z_en_rat.c @@ -740,8 +740,9 @@ void EnRat_Bounced(EnRat* this, PlayState* play) { } void EnRat_Explode(EnRat* this, PlayState* play) { - EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, BOMB_TYPE_BODY); + EnBom* bomb = + (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, BOMB_EXPLOSIVE_TYPE_BOMB, 0, 0, BOMB_TYPE_BODY); if (bomb != NULL) { bomb->timer = 0; diff --git a/src/overlays/actors/ovl_En_Rg/z_en_rg.c b/src/overlays/actors/ovl_En_Rg/z_en_rg.c index d552c5605c..0acd6fbf97 100644 --- a/src/overlays/actors/ovl_En_Rg/z_en_rg.c +++ b/src/overlays/actors/ovl_En_Rg/z_en_rg.c @@ -589,8 +589,8 @@ void func_80BF4AB8(EnRg* this, PlayState* play) { this->unk_326 = 0x28; if (player->stateFlags3 & PLAYER_STATE3_1000) { player->linearVelocity *= 0.5f; - player->unk_B08[0] = player->linearVelocity; - player->unk_B08[1] += player->linearVelocity * 0.05f; + player->unk_B08 = player->linearVelocity; + player->unk_B0C += player->linearVelocity * 0.05f; if (BINANG_SUB(this->actor.yawTowardsPlayer, player->currentYaw) > 0) { player->currentYaw += 0x2000; } else { diff --git a/src/overlays/actors/ovl_En_Stream/z_en_stream.c b/src/overlays/actors/ovl_En_Stream/z_en_stream.c index 11e5ce7d60..912a700f8e 100644 --- a/src/overlays/actors/ovl_En_Stream/z_en_stream.c +++ b/src/overlays/actors/ovl_En_Stream/z_en_stream.c @@ -93,11 +93,11 @@ void EnStream_SuckPlayer(EnStream* this, PlayState* play) { this->actor.scale.y) != EN_STREAM_PLAYER_OUTSIDE_RANGE) { xzDist = sqrtf(SQ(posDifference.x) + SQ(posDifference.z)); yDistWithOffset = player->actor.world.pos.y - (this->actor.world.pos.y - 90.0f); - player->unk_B84 = Math_Atan2S(-posDifference.x, -posDifference.z); + player->pushedYaw = Math_Atan2S(-posDifference.x, -posDifference.z); if (xzDist > 3.0f) { - Math_SmoothStepToF(&player->unk_B80, 3.0f, 0.5f, xzDist, 0.0f); + Math_SmoothStepToF(&player->pushedSpeed, 3.0f, 0.5f, xzDist, 0.0f); } else { - player->unk_B80 = 0.0f; + player->pushedSpeed = 0.0f; Math_SmoothStepToF(&player->actor.world.pos.x, this->actor.world.pos.x, 0.5f, 3.0f, 0.0f); Math_SmoothStepToF(&player->actor.world.pos.z, this->actor.world.pos.z, 0.5f, 3.0f, 0.0f); } diff --git a/src/overlays/actors/ovl_En_Test3/z_en_test3.c b/src/overlays/actors/ovl_En_Test3/z_en_test3.c index cedf008611..4441427159 100644 --- a/src/overlays/actors/ovl_En_Test3/z_en_test3.c +++ b/src/overlays/actors/ovl_En_Test3/z_en_test3.c @@ -589,13 +589,13 @@ s32 func_80A3F384(EnTest3* this, PlayState* play) { EnDoor* door = (EnDoor*)func_80A3F2BC(play, this, ACTOR_EN_DOOR, ACTORCAT_DOOR, 55.0f, 20.0f); Vec3f offset; - if ((door != NULL) && (door->unk_1A1 == 0) && - ((player->doorType == 0) || (&door->dyna.actor != player->doorActor)) && - Actor_ActorAIsFacingActorB(&this->player.actor, &door->dyna.actor, 0x3000)) { - Actor_OffsetOfPointInActorCoords(&door->dyna.actor, &offset, &this->player.actor.world.pos); - this->player.doorType = 1; + if ((door != NULL) && !door->knobDoor.playOpenAnim && + ((player->doorType == PLAYER_DOORTYPE_NONE) || (&door->knobDoor.dyna.actor != player->doorActor)) && + Actor_ActorAIsFacingActorB(&this->player.actor, &door->knobDoor.dyna.actor, 0x3000)) { + Actor_OffsetOfPointInActorCoords(&door->knobDoor.dyna.actor, &offset, &this->player.actor.world.pos); + this->player.doorType = PLAYER_DOORTYPE_HANDLE; this->player.doorDirection = (offset.z >= 0.0f) ? 1.0f : -1.0f; - this->player.doorActor = &door->dyna.actor; + this->player.doorActor = &door->knobDoor.dyna.actor; this->player.csId = CS_ID_NONE; return true; } @@ -1103,7 +1103,7 @@ s32 EnTest3_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos->z *= this->player.ageProperties->unk_08; } if (!(this->player.skelAnime.moveFlags & ANIM_FLAG_4) || - (this->player.skelAnime.moveFlags & ANIM_FLAG_UPDATEY)) { + (this->player.skelAnime.moveFlags & ANIM_FLAG_UPDATE_Y)) { pos->y *= this->player.ageProperties->unk_08; } pos->y -= this->player.unk_AB8; @@ -1176,8 +1176,8 @@ void EnTest3_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList1, Gfx** dL leftHandActor->world.rot.y = this->player.actor.shape.rot.y + this->player.leftHandWorld.rot.y; leftHandActor->shape.rot.y = leftHandActor->world.rot.y; } else { - Matrix_Get(&this->player.mf_CC4); - Matrix_MtxFToYXZRot(&this->player.mf_CC4, &this->player.leftHandWorld.rot, false); + Matrix_Get(&this->player.leftHandMf); + Matrix_MtxFToYXZRot(&this->player.leftHandMf, &this->player.leftHandWorld.rot, false); func_80126B8C(play, &this->player); } diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index d434bacaa6..01fa7c7cd1 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -471,7 +471,7 @@ s32 func_80AECE60(EnTk* this, PlayState* play) { if ((door != NULL) && (this->unk_2CA & 0x400)) { Vec3f sp5C; - Actor_OffsetOfPointInActorCoords(&this->actor, &sp5C, &door->dyna.actor.world.pos); + Actor_OffsetOfPointInActorCoords(&this->actor, &sp5C, &door->knobDoor.dyna.actor.world.pos); door->unk_1A7 = 2; if (sp5C.z < -20.0f) { this->unk_2CA &= ~0x400; diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index 3a563ab609..6c07339797 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -214,7 +214,7 @@ void func_80BA383C(EnToto* this, PlayState* play) { } Animation_PlayOnce(&this->skelAnime, D_80BA5078[this->unk2B4]); } - func_800BBB74(this->unk260, 0x14, 0x50, 3); + func_800BBB74(&this->blinkInfo, 20, 80, 3); } void func_80BA3930(EnToto* this, PlayState* play) { @@ -316,7 +316,7 @@ void func_80BA3D38(EnToto* this, PlayState* play) { this->text = ENTOTO_WEEK_EVENT_FLAGS ? D_80BA50BC : D_80BA5088; func_80BA4C0C(this, play); play->actorCtx.flags |= ACTORCTX_FLAG_5; - this->unk260[0] = 0; + this->blinkInfo.eyeTexIndex = 0; } void func_80BA3DBC(EnToto* this, PlayState* play) { @@ -586,6 +586,7 @@ s32 func_80BA47E0(EnToto* this, PlayState* play) { for (i = 0; i < ARRAY_COUNT(D_80BA50DC); i++) { if (gSaveContext.save.playerForm != (i + 1) && (D_80BA5128[i] & this->unk2B3)) { Math_Vec3s_ToVec3f(&spawnPos, &D_80BA50DC[i].unk6); + Actor_Spawn(&play->actorCtx, play, ACTOR_PLAYER, spawnPos.x, spawnPos.y, spawnPos.z, i + 2, 0, 0, PLAYER_PARAMS(0xFF, PLAYER_INITMODE_F) | 0xFFFFF000); } @@ -728,7 +729,7 @@ void EnToto_Draw(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp4C[this->unk260[0]])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sp4C[this->blinkInfo.eyeTexIndex])); Scene_SetRenderModeXlu(play, 0, 1); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, NULL, &this->actor); diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.h b/src/overlays/actors/ovl_En_Toto/z_en_toto.h index cf9f3c718f..dc2b0947e9 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.h +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.h @@ -26,7 +26,7 @@ typedef struct EnToto { /* 0x144 */ SkelAnime skelAnime; /* 0x188 */ Vec3s jointTable[18]; /* 0x1F4 */ Vec3s morphTable[18]; - /* 0x260 */ s16 unk260[2]; + /* 0x260 */ BlinkInfo blinkInfo; /* 0x264 */ ColliderCylinder collider; /* 0x2B0 */ u8 actionFuncIndex; /* 0x2B1 */ u8 unk2B1; diff --git a/src/overlays/actors/ovl_En_Vm/z_en_vm.c b/src/overlays/actors/ovl_En_Vm/z_en_vm.c index 505df7f112..29778ec710 100644 --- a/src/overlays/actors/ovl_En_Vm/z_en_vm.c +++ b/src/overlays/actors/ovl_En_Vm/z_en_vm.c @@ -391,8 +391,9 @@ void func_808CCCF0(EnVm* this, PlayState* play) { this->unk_214--; if (this->unk_214 == 1) { - EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0x6FF, 0); + EnBom* bomb = + (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, BOMB_EXPLOSIVE_TYPE_BOMB, 0, 0x6FF, BOMB_TYPE_BODY); if (bomb != NULL) { bomb->timer = 0; diff --git a/src/overlays/actors/ovl_En_Wf/z_en_wf.c b/src/overlays/actors/ovl_En_Wf/z_en_wf.c index 44a50e99d3..ed3ec36f9f 100644 --- a/src/overlays/actors/ovl_En_Wf/z_en_wf.c +++ b/src/overlays/actors/ovl_En_Wf/z_en_wf.c @@ -616,7 +616,8 @@ void func_80991280(EnWf* this, PlayState* play) { if (!func_8099408C(play, this) && !func_80990948(play, this, 0)) { phi_v1 = ABS_ALT(BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y)); - if ((this->actor.xzDistToPlayer < 80.0f) && (player->meleeWeaponState != 0) && (phi_v1 >= 0x1F40)) { + if ((this->actor.xzDistToPlayer < 80.0f) && (player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) && + (phi_v1 >= 0x1F40)) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; func_80991948(this); @@ -666,7 +667,8 @@ void func_8099149C(EnWf* this, PlayState* play) { sp28 = ABS_ALT(BINANG_SUB(player->actor.shape.rot.y, this->actor.shape.rot.y)); - if ((this->actor.xzDistToPlayer < (150.0f + sp2C)) && (player->meleeWeaponState != 0) && (sp28 >= 0x1F40)) { + if ((this->actor.xzDistToPlayer < (150.0f + sp2C)) && + (player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) && (sp28 >= 0x1F40)) { this->actor.shape.rot.y = this->actor.yawTowardsPlayer; this->actor.world.rot.y = this->actor.yawTowardsPlayer; if (Rand_ZeroOne() > 0.7f) { diff --git a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c index 41cdd83695..336076199f 100644 --- a/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c +++ b/src/overlays/actors/ovl_Obj_Hunsui/z_obj_hunsui.c @@ -184,8 +184,8 @@ void func_80B9C5E8(ObjHunsui* this, PlayState* play) { Math_ApproachF(&this->unk_1A0, 3.0f, 1.0f, 1.0f); Math_ApproachF(&this->unk_19C, this->unk_1A0, 1.0f, 0.1f); } - player->unk_B84 = this->unk_1A4; - player->unk_B80 = this->unk_19C; + player->pushedYaw = this->unk_1A4; + player->pushedSpeed = this->unk_19C; } } else { if (this->unk_172 & 8) { diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 1f92e8825e..5147f87325 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -9,1297 +9,20198 @@ #include "z64rumble.h" #include "z64shrink_window.h" -#define THIS ((Player*)thisx) +#include "overlays/actors/ovl_Arms_Hook/z_arms_hook.h" +#include "overlays/actors/ovl_Door_Spiral/z_door_spiral.h" +#include "overlays/actors/ovl_Door_Shutter/z_door_shutter.h" +#include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" +#include "overlays/actors/ovl_En_Bom/z_en_bom.h" +#include "overlays/actors/ovl_En_Boom/z_en_boom.h" +#include "overlays/actors/ovl_En_Box/z_en_box.h" +#include "overlays/actors/ovl_En_Door/z_en_door.h" +#include "overlays/actors/ovl_En_Horse/z_en_horse.h" +#include "overlays/actors/ovl_En_Ishi/z_en_ishi.h" +#include "overlays/actors/ovl_En_Test3/z_en_test3.h" +#include "overlays/actors/ovl_En_Test7/z_en_test7.h" +#include "overlays/actors/ovl_En_Torch2/z_en_torch2.h" -extern UNK_TYPE D_06008860; -extern UNK_TYPE D_0600BDD8; -extern UNK_TYPE D_060178D0; +#include "overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.h" + +#include "objects/gameplay_keep/gameplay_keep.h" + +#include "objects/object_link_boy/object_link_boy.h" +#include "objects/object_link_goron/object_link_goron.h" +#include "objects/object_link_zora/object_link_zora.h" +#include "objects/object_link_nuts/object_link_nuts.h" +#include "objects/object_link_child/object_link_child.h" + +#define THIS ((Player*)thisx) void Player_Init(Actor* thisx, PlayState* play); void Player_Destroy(Actor* thisx, PlayState* play); void Player_Update(Actor* thisx, PlayState* play); void Player_Draw(Actor* thisx, PlayState* play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DA90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DABC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DAD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DAFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DB18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DB3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DB60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DB90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DBC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DC28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DC38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DC64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DCA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DD2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DE14.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DE50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DE88.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DF2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DF48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082DF8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E00C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E078.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E094.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E0CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E0F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E12C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E188.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E1BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E1F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E224.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E438.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E4A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E514.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E55C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E5A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E5EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E634.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E67C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E6D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E6F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E784.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E794.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E820.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E920.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082E9C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EA10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EA38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EA60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EA80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EAC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EAF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EB18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EB38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EC9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082ECCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082ECE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082ED20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082ED94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EEA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EEE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EF20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EF54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EF9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082EFE4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F02C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F09C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F0E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F164.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F1AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F43C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F470.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F524.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F594.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F5A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F5C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F5FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F62C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F7F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F8A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F8BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082F938.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FA5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FB68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FBE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FC24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FC60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FC78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FCC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FD0C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FDC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8082FE0C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808302CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808304BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808305BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808306F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808308DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808309CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830A58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830AE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830B38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830B88.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830CE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830D40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830DF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830E30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830F9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80830FD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831010.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831094.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831124.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831194.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083133C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808313A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808313F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831454.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831494.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083172C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831760.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808317C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831814.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808318C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831944.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831990.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80831F34.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832090.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083213C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083216C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808323C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832444.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083249C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808324EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832558.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832578.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832660.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832754.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832888.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832CAC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832F24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80832F78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833058.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808331FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808332A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808333CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808334D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808335B0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808335F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833728.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083375C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833864.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833998.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808339B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808339D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833A64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833AA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80833B18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808340AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808340D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834104.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834140.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808341F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808344C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834534.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083456C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808345A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808345C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834600.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834CD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834D50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834DB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80834DFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835324.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808353DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835428.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808354A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808355D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083562C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835BC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835BF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835C64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835CD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835D2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835D58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835DF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80835EAC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083604C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836258.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808365DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836888.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083692C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836988.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808369F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836A5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836A98.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836AD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836B3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836C70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836D8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836DC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836EA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80836F10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808370D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837134.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808373A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808373F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837730.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083784C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808378FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083798C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808379C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837B60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837BD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837BF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837C20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837C78.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837CEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80837DEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808381A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808381F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083827C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083868C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80838760.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808387A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80838830.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808388B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808389BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80838A20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80838A90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808391D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839518.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808395F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808396B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839770.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839800.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839860.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839978.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839A10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839A84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839B18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839CD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839E3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839E74.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839ED0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80839F98.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A04C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A0CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A114.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A274.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A4A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A548.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A580.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A658.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A6C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A794.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A844.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A878.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083A98C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083AD04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083AD8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083ADB8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083ADF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083AE38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083AECC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083AF30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083AF8C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B030.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B090.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B0E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B1A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B23C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B29C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B2E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B32C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B3B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B73C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B798.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B850.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B8D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083B930.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083BB4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083BF54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083C62C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083C6E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083C85C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083C8E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083CB04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083CB58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083CBC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083CCB4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083CF68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083D168.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083D23C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083D6DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083D738.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083D78C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083D860.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083DCC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083DD1C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083DEE4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083DF38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083DFC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E14C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E234.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E28C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E2F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E354.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E404.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E514.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E758.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E7F8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E8E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E958.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083E9C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083EA44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083EBD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083EE60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F144.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F190.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F230.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F27C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F358.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F57C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F828.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083F8A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FBC4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FCF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FD80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FE38.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FE90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FEF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FF30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8083FFEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840094.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808400CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808401F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840770.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840980.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808409A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840A30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840CD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840DEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840E24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840E5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840EC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840F34.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80840F90.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808411D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808412A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808412BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841358.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841408.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808414E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841528.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808415A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808415E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841624.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841744.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084182C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80841A50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Init.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80842510.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808425B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808426F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808430E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80843178.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80843EC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808442D8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808445C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808446F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80844784.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80844D80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80844EF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Update.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808463C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80846460.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Draw.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/Player_Destroy.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847190.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084748C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808475B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808477D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847880.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847994.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808479F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847A50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847A94.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847BF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847E2C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847ED4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847F1C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80847FF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848048.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848094.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808481CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848250.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848294.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808482E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808484CC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808484F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848570.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848640.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848780.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808487B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848808.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084894C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848A0C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848AB0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848B6C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848BF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80848E4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80849054.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808490B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808491B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084923C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808492C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084933C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80849570.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80849620.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808496AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808497A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80849A9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80849DD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80849FE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084A26C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084A5C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084A794.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084A884.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084A8E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084AB4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084AC84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084AEEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084AF9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084B0EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084B288.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084B3B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084B4A8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084B5C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084BAA4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084BBF0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084BC64.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084BE40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084BF28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084BFDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084C124.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084C16C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084C6EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084C94C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084CA24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084CB58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084CCEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084CE84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084D18C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084D4EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084D770.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084D820.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E034.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E25C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E334.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E434.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E4E4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E58C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E65C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E724.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084E980.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084ED9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084EE50.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084EF9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084F1B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084F3DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084F4E8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084FC0C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084FD7C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084FE48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8084FE7C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808505D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850734.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850854.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808508C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850B18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850BA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850BF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850D20.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80850D68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808513EC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851588.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808516B4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808519FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851B58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851BD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851C40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851D30.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851EAC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851EC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80851F18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808521E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80852290.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085255C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808525C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085269C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80852B28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80852C04.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80852FD4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808530E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80853194.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808534C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80853754.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80853850.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80853A5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80853CC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80853D68.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854010.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808540A0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854118.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085421C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085437C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085439C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854430.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854614.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808546D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854800.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808548B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854C70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854CD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80854EFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808550D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855218.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808553F4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855818.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855A7C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855AF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855B9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855C28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855E08.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80855F9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80856000.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80856074.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80856110.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808561B0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808566C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085687C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80856888.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80856918.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808573A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80857640.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808576BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808577E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80857950.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80857A44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80857AEC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80857BE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858C84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858CC8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858D48.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858DB4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858DDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858DFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858E40.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858E60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858E80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858EA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858EC0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858EFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858F1C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858F3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858F5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858F7C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858F9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858FBC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80858FE8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859028.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859168.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808591BC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859210.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859248.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085929C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859300.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859414.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808594D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808595B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085968C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859708.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085978C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859890.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859990.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_808599DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859A10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859A44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859AD0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859AF8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859B28.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859B54.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859BA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859C60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859CA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859CE0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859CFC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859D44.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859D70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859EBC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859F4C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859FCC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_80859FF4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A04C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A120.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A144.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A19C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A1D4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A24C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A2AC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A330.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A364.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A40C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A4A4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A530.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A5DC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A66C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A6C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A710.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A768.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A7C0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A8C4.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085A940.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AA10.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AA60.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AA84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AACC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AB58.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085ABA8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AC9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085AD5C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085ADA0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B08C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B134.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B170.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B1F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B28C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B384.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B3E0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B460.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B74C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B820.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B854.s") - -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_player_actor/func_8085B930.s") +s32 Player_GrabPlayer(PlayState* play, Player* player); +s32 func_8085B28C(PlayState* play, Player* this, PlayerCsMode csMode); +void func_8085B384(Player* this, PlayState* play); +s32 Player_InflictDamage(PlayState* play, s32 damage); +void Player_TalkWithPlayer(PlayState* play, Actor* actor); +void func_8085B74C(PlayState* play); +void func_8085B820(PlayState* play, s16 arg1); +PlayerItemAction func_8085B854(PlayState* play, Player* player, ItemId itemId); +s32 func_8085B930(PlayState* play, PlayerAnimationHeader* talkAnim, AnimationMode animMode); + +void Player_UpdateCommon(Player* this, PlayState* play, Input* input); +s32 Player_StartFishing(PlayState* play); +void func_8085B170(PlayState* play, Player* this); +s32 func_8083A658(PlayState* play, Player* this); +void func_8082F8BC(PlayState* play, Player* this, PlayerItemAction itemAction); + +void func_80831990(PlayState* play, Player* this, ItemId item); + +s32 func_80848BF4(Player* this, PlayState* play); + +void func_80836988(Player* this, PlayState* play); + +void func_808484F0(Player* this); + +void func_80838A20(PlayState* play, Player* this); +void func_80839978(PlayState* play, Player* this); +void func_80839A10(PlayState* play, Player* this); + +typedef enum AnimSfxType { + /* 1 */ ANIMSFX_TYPE_GENERAL = 1, + /* 2 */ ANIMSFX_TYPE_FLOOR, + /* 3 */ ANIMSFX_TYPE_FLOOR_BY_AGE, + /* 4 */ ANIMSFX_TYPE_VOICE, + /* 5 */ ANIMSFX_TYPE_FLOOR_LAND, // does not use sfxId + /* 6 */ ANIMSFX_TYPE_6, // FLOOR_WALK_Something // does not use sfxId + /* 7 */ ANIMSFX_TYPE_FLOOR_JUMP, // does not use sfxId + /* 8 */ ANIMSFX_TYPE_8, // FLOOR_WALK_Something2 // does not use sfxId + /* 9 */ ANIMSFX_TYPE_9, // Uses NA_SE_PL_WALK_LADDER // does not use sfxId, unused + /* 10 */ ANIMSFX_TYPE_SURFACE, +} AnimSfxType; + +#define ANIMSFX_SHIFT_TYPE(type) ((type) << 11) + +#define ANIMSFX_CONTINUE (1) +#define ANIMSFX_STOP (0) + +#define ANIMSFX_FLAGS(type, frame, cont) \ + (((ANIMSFX_##cont) == ANIMSFX_STOP ? -1 : 1) * (ANIMSFX_SHIFT_TYPE(type) | ((frame)&0x7FF))) + +#define ANIMSFX(type, frame, sfxId, cont) \ + { (sfxId), ANIMSFX_FLAGS(type, frame, cont) } + +#define ANIMSFX_GET_TYPE(data) ((data)&0x7800) +#define ANIMSFX_GET_FRAME(data) ((data)&0x7FF) + +typedef struct AnimSfxEntry { + /* 0x0 */ u16 sfxId; + /* 0x2 */ s16 flags; // negative marks the end +} AnimSfxEntry; // size = 0x4 + +/* action funcs */ +void func_808496AC(Player* this, PlayState* play); +void func_808497A0(Player* this, PlayState* play); +void func_80849A9C(Player* this, PlayState* play); +void func_80849DD0(Player* this, PlayState* play); +void func_80849FE0(Player* this, PlayState* play); +void func_8084A26C(Player* this, PlayState* play); +void func_8084A5C0(Player* this, PlayState* play); +void func_8084A794(Player* this, PlayState* play); +void func_8084A884(Player* this, PlayState* play); +void func_8084A8E8(Player* this, PlayState* play); +void func_8084AB4C(Player* this, PlayState* play); +void func_8084AC84(Player* this, PlayState* play); +void func_8084AEEC(Player* this, PlayState* play); +void func_8084AF9C(Player* this, PlayState* play); +void func_8084B0EC(Player* this, PlayState* play); +void func_8084B288(Player* this, PlayState* play); +void func_8084B3B8(Player* this, PlayState* play); +void func_8084B4A8(Player* this, PlayState* play); +void func_8084B5C0(Player* this, PlayState* play); +void func_8084BAA4(Player* this, PlayState* play); +void func_8084BBF0(Player* this, PlayState* play); +void func_8084BC64(Player* this, PlayState* play); +void func_8084BE40(Player* this, PlayState* play); +void func_8084BF28(Player* this, PlayState* play); +void func_8084BFDC(Player* this, PlayState* play); +void func_8084C16C(Player* this, PlayState* play); +void func_8084C6EC(Player* this, PlayState* play); +void func_8084C94C(Player* this, PlayState* play); +void func_8084CA24(Player* this, PlayState* play); +void func_8084CB58(Player* this, PlayState* play); +void func_8084CCEC(Player* this, PlayState* play); +void func_8084CE84(Player* this, PlayState* play); +void func_8084D18C(Player* this, PlayState* play); +void func_8084D4EC(Player* this, PlayState* play); +void func_8084D770(Player* this, PlayState* play); +void func_8084D820(Player* this, PlayState* play); +void func_8084E034(Player* this, PlayState* play); +void func_8084E25C(Player* this, PlayState* play); +void func_8084E334(Player* this, PlayState* play); +void func_8084E434(Player* this, PlayState* play); +void func_8084E4E4(Player* this, PlayState* play); +void func_8084E58C(Player* this, PlayState* play); +void func_8084E65C(Player* this, PlayState* play); +void func_8084E724(Player* this, PlayState* play); +void func_8084E980(Player* this, PlayState* play); +void func_8084ED9C(Player* this, PlayState* play); +void func_8084EE50(Player* this, PlayState* play); +void func_8084EF9C(Player* this, PlayState* play); +void func_8084F1B8(Player* this, PlayState* play); +void func_8084F3DC(Player* this, PlayState* play); +void func_8084F4E8(Player* this, PlayState* play); +void func_8084FC0C(Player* this, PlayState* play); +void func_8084FE7C(Player* this, PlayState* play); +void func_808505D0(Player* this, PlayState* play); +void func_808508C8(Player* this, PlayState* play); +void func_80850B18(Player* this, PlayState* play); +void func_80850D68(Player* this, PlayState* play); +void func_808513EC(Player* this, PlayState* play); +void func_80851588(Player* this, PlayState* play); +void func_808516B4(Player* this, PlayState* play); +void func_808519FC(Player* this, PlayState* play); +void func_80851B58(Player* this, PlayState* play); +void func_80851BD4(Player* this, PlayState* play); +void func_8085269C(Player* this, PlayState* play); +void func_80852B28(Player* this, PlayState* play); +void func_80852C04(Player* this, PlayState* play); +void func_80852FD4(Player* this, PlayState* play); +void func_80853194(Player* this, PlayState* play); +void func_808534C0(Player* this, PlayState* play); +void func_80853754(Player* this, PlayState* play); +void func_80853850(Player* this, PlayState* play); +void func_80853A5C(Player* this, PlayState* play); +void func_80853CC0(Player* this, PlayState* play); +void func_80853D68(Player* this, PlayState* play); +void func_80854010(Player* this, PlayState* play); +void func_808540A0(Player* this, PlayState* play); +void func_80854118(Player* this, PlayState* play); +void func_8085421C(Player* this, PlayState* play); +void func_8085437C(Player* this, PlayState* play); +void func_8085439C(Player* this, PlayState* play); +void func_80854430(Player* this, PlayState* play); +void func_80854614(Player* this, PlayState* play); +void func_808546D0(Player* this, PlayState* play); +void func_80854800(Player* this, PlayState* play); +void func_808548B8(Player* this, PlayState* play); +void func_80854C70(Player* this, PlayState* play); +void func_808553F4(Player* this, PlayState* play); +void func_80855818(Player* this, PlayState* play); +void func_80855A7C(Player* this, PlayState* play); +void func_80855AF4(Player* this, PlayState* play); +void func_80855B9C(Player* this, PlayState* play); +void func_80855C28(Player* this, PlayState* play); +void func_80855E08(Player* this, PlayState* play); +void func_808561B0(Player* this, PlayState* play); +void func_80856918(Player* this, PlayState* play); +void func_808573A4(Player* this, PlayState* play); +void func_80857BE8(Player* this, PlayState* play); +void func_8085B08C(Player* this, PlayState* play); + +s32 func_80839518(Player* this, PlayState* play); +s32 func_808365DC(Player* this, PlayState* play); +s32 func_8083D23C(Player* this, PlayState* play); +s32 func_8083CCB4(Player* this, PlayState* play); +s32 func_808391D8(Player* this, PlayState* play); +s32 func_8083DFC4(Player* this, PlayState* play); +s32 func_8083A114(Player* this, PlayState* play); +s32 func_80848570(Player* this, PlayState* play); +s32 func_8083A580(Player* this, PlayState* play); +s32 func_8083D78C(Player* this, PlayState* play); +s32 func_80839B18(Player* this, PlayState* play); +s32 func_8083A274(Player* this, PlayState* play); +s32 func_80834DFC(Player* this, PlayState* play); +s32 func_80838A90(Player* this, PlayState* play); +s32 func_8083A0CC(Player* this, PlayState* play); + +s32 func_80848780(Player* this, PlayState* play); +s32 func_808487B8(Player* this, PlayState* play); +s32 func_80848B6C(Player* this, PlayState* play); +s32 func_808490B4(Player* this, PlayState* play); +s32 func_808491B4(Player* this, PlayState* play); +s32 func_80848808(Player* this, PlayState* play); +s32 func_8084894C(Player* this, PlayState* play); +s32 func_80848A0C(Player* this, PlayState* play); +s32 func_80848AB0(Player* this, PlayState* play); +s32 func_80848E4C(Player* this, PlayState* play); +s32 func_80849054(Player* this, PlayState* play); +s32 func_8084923C(Player* this, PlayState* play); +s32 func_808492C4(Player* this, PlayState* play); +s32 func_8084933C(Player* this, PlayState* play); +s32 func_80849570(Player* this, PlayState* play); +s32 func_80849620(Player* this, PlayState* play); + +/* Init Mode functions */ +void Player_InitMode_0(PlayState* play, Player* this); +void Player_InitMode_1(PlayState* play, Player* this); +void Player_InitMode_2(PlayState* play, Player* this); +void Player_InitMode_3(PlayState* play, Player* this); +void Player_InitMode_4(PlayState* play, Player* this); +void Player_InitMode_5(PlayState* play, Player* this); +void Player_InitMode_6(PlayState* play, Player* this); +void Player_InitMode_7(PlayState* play, Player* this); +void func_80841744(PlayState* play, Player* this); +void func_80841744(PlayState* play, Player* this); +void func_8083ADF0(PlayState* play, Player* this); +void Player_InitMode_B(PlayState* play, Player* this); +void Player_InitMode_Telescope(PlayState* play, Player* this); +void Player_InitMode_D(PlayState* play, Player* this); +void func_8083ADF0(PlayState* play, Player* this); +void Player_InitMode_F(PlayState* play, Player* this); + +void func_80859F4C(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859FCC(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859FF4(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A120(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A144(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A19C(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A1D4(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A24C(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A2AC(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A330(PlayState* play, Player* this, UNK_TYPE arg2); + +void func_80859EBC(PlayState* play, Player* this, s32 arg2); + +void func_80859414(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859AD0(PlayState* play, Player* this, void* arg2); +void func_80859B28(PlayState* play, Player* this, void* arg2); +void func_8085ADA0(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085AACC(PlayState* play, Player* this, UNK_TYPE arg2); +void func_808595B8(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859890(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859C60(PlayState* play, Player* this, void* arg2); +void func_8085A710(PlayState* play, Player* this, void* anim); +void func_808595B8(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859D70(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A6C0(PlayState* play, Player* this, void* anim); +void func_80859FF4(PlayState* play, Player* this, UNK_TYPE arg2); +void Player_Cutscene_TranslateReverse(PlayState* play, Player* this, void* arg); +void func_8085A144(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A1D4(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A364(PlayState* play, Player* this, void* arg2); +void func_808599DC(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A40C(PlayState* play, Player* this, void* arg2); +void func_80859708(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A2AC(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A940(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A4A4(PlayState* play, Player* this, void* arg2); +void func_8085A5DC(PlayState* play, Player* this, void* arg2); +void func_8085AA84(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A7C0(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085AA10(PlayState* play, Player* this, UNK_TYPE arg2); +void func_808599DC(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859AF8(PlayState* play, Player* this, void* arg2); +void func_80859A44(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859D44(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859EBC(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859F4C(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859F4C(PlayState* play, Player* this, UNK_TYPE arg2); + +void func_8085A768(PlayState* play, Player* this, void* arg2); +void func_8085AA60(PlayState* play, Player* this, UNK_TYPE arg2); + +void func_808594D0(PlayState* play, Player* this, UNK_TYPE arg2); +void func_808594D0(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085978C(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859B54(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859CA0(PlayState* play, Player* this, UNK_TYPE arg2); +void func_808594D0(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859CFC(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A66C(PlayState* play, Player* this, void* arg2); +void func_80859FCC(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A120(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A19C(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085968C(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A24C(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A330(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A8C4(PlayState* play, Player* this, UNK_TYPE arg2); +void func_8085A530(PlayState* play, Player* this, void* arg2); +void func_8085A768(PlayState* play, Player* this, void* arg2); +void func_8085AA60(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859990(PlayState* play, Player* this, UNK_TYPE arg2); +void func_80859A10(PlayState* play, Player* this, UNK_TYPE arg2); + +// ItemActions +void func_8082F594(PlayState* play, Player* this); +void func_8082F5A4(PlayState* play, Player* this); +void func_8082F8A0(PlayState* play, Player* this); +void func_8082F5C0(PlayState* play, Player* this); +void func_8082F7F4(PlayState* play, Player* this); +void Player_SpawnExplosive(PlayState* play, Player* this); + +void func_80858DB4(PlayState* play, Player* this, void* anim); +void func_80858DDC(PlayState* play, Player* this, void* anim); +void func_80858E40(PlayState* play, Player* this, void* anim); +void func_80858E60(PlayState* play, Player* this, void* anim); +void func_80858E80(PlayState* play, Player* this, void* anim); +void func_80858EA0(PlayState* play, Player* this, void* anim); +void func_80858EFC(PlayState* play, Player* this, void* anim); +void func_80858F1C(PlayState* play, Player* this, void* anim); +void func_80858F3C(PlayState* play, Player* this, void* anim); +void func_80858F5C(PlayState* play, Player* this, void* anim); +void func_80858FBC(PlayState* play, Player* this, void* anim); +void func_80859028(PlayState* play, Player* this, void* anim); +void func_808591BC(PlayState* play, Player* this, void* anim); +void func_80858DFC(PlayState* play, Player* this, void* anim); +void func_80858EC0(PlayState* play, Player* this, void* anim); +void func_80858F7C(PlayState* play, Player* this, void* anim); +void func_80858F9C(PlayState* play, Player* this, void* anim); +void func_80859168(PlayState* play, Player* this, void* anim); +void func_80859210(PlayState* play, Player* this, void* arg2); + +typedef struct struct_8085C2A4 { + /* 0x0 */ PlayerAnimationHeader* unk_0; + /* 0x4 */ PlayerAnimationHeader* unk_4; + /* 0x8 */ PlayerAnimationHeader* unk_8; +} struct_8085C2A4; // size = 0xC + +typedef struct BlureColors { + /* 0x0 */ u8 p1StartColor[4]; + /* 0x4 */ u8 p2StartColor[4]; + /* 0x8 */ u8 p1EndColor[4]; + /* 0xC */ u8 p2EndColor[4]; +} BlureColors; // size = 0x10 + +typedef void (*PlayerCueInterpreter)(PlayState*, Player*, CsCmdActorCue*); + +typedef struct struct_8085DA94 { + /* 0x0 */ s8 type; + /* 0x4 */ union { + void* ptr; // Do not use, required in the absence of designated initialisors + PlayerAnimationHeader* anim; + PlayerCueInterpreter func; + AnimSfxEntry* entry; + }; +} struct_8085DA94; // size = 0x8 + +typedef struct struct_8085E368 { + /* 0x0 */ Vec3s base; + /* 0x6 */ Vec3s range; +} struct_8085E368; // size = 0xC + +typedef struct struct_8085D910 { + /* 0x0 */ u8 unk_0; + /* 0x1 */ u8 unk_1; + /* 0x2 */ u8 unk_2; + /* 0x3 */ u8 unk_3; +} struct_8085D910; // size = 0x4 + +typedef struct struct_8085D848_unk_00 { + /* 0x0 */ s16 fogNear; + /* 0x2 */ u8 fogColor[3]; + /* 0x5 */ u8 ambientColor[3]; +} struct_8085D848_unk_00; // size = 0x8 + +typedef struct struct_8085D848_unk_18 { + /* 0x00 */ Vec3f pos; + /* 0x0C */ u8 color[3]; + /* 0x10 */ s16 radius; +} struct_8085D848_unk_18; // size = 0x14 + +typedef struct struct_8085D848 { + /* 0x00 */ struct_8085D848_unk_00 unk_00[3]; + /* 0x18 */ struct_8085D848_unk_18 light[3]; +} struct_8085D848; // size = 0x54 + +typedef struct struct_8085D80C { + /* 0x0 */ s16 actorId; + /* 0x2 */ s16 params; +} struct_8085D80C; // size = 0x4 + +typedef struct struct_8085D798 { + /* 0x0 */ s16 actorId; + /* 0x2 */ s8 actorParams; + /* 0x3 */ u8 itemId; + /* 0x4 */ u8 itemAction; + /* 0x5 */ u8 textId; +} struct_8085D798; // size = 0x6 + +typedef struct struct_8085D714 { + /* 0x0 */ u8 unk_0; + /* 0x4 */ PlayerAnimationHeader* unk_4; +} struct_8085D714; // size = 0x8 + +typedef struct struct_8085D224 { + /* 0x0 */ PlayerAnimationHeader* anim; + /* 0x4 */ f32 unk_4; + /* 0x8 */ f32 unk_8; +} struct_8085D224; // size = 0xC + +typedef struct FallImpactInfo { + /* 0x0 */ s8 damage; + /* 0x1 */ u8 sourceIntensity; + /* 0x2 */ u8 decayTimer; + /* 0x3 */ u8 decayStep; + /* 0x4 */ u16 sfxId; +} FallImpactInfo; // size = 0x6 + +typedef struct AttackAnimInfo { + /* 0x00 */ PlayerAnimationHeader* unk_0; + /* 0x04 */ PlayerAnimationHeader* unk_4; + /* 0x08 */ PlayerAnimationHeader* unk_8; + /* 0x0C */ u8 unk_C; + /* 0x0D */ u8 unk_D; +} AttackAnimInfo; // size = 0x10 + +typedef struct MeleeWeaponDamageInfo { + /* 0x0 */ s32 dmgFlags; + // Presumably these two fields are intended for Fierce Deity, but will also work for Deku if it can equip a sword + /* 0x4 */ u8 dmgTransformedNormal; + /* 0x5 */ u8 dmgTransformedStrong; + /* 0x6 */ u8 dmgHumanNormal; + /* 0x7 */ u8 dmgHumanStrong; +} MeleeWeaponDamageInfo; // size = 0x8 + +typedef struct struct_8085CC88 { + /* 0x0 */ PlayerAnimationHeader* anim; + /* 0x4 */ u8 frame; +} struct_8085CC88; // size = 0x8 + +typedef struct { + /* 0x0 */ u8 itemId; + /* 0x2 */ s16 actorId; +} ExplosiveInfo; // size = 0x4 + +typedef struct { + /* 0x0 */ Color_RGB8 unk_0; + /* 0x3 */ Color_RGB8 unk_3; + /* 0x6 */ Color_RGB8 unk_6; + /* 0xA */ s16 unk_A; + /* 0xC */ s16 unk_C; +} struct_8082F02C_arg1; // size = 0xE + +typedef struct GetItemEntry { + /* 0x0 */ u8 itemId; + /* 0x1 */ u8 field; // various bit-packed data + /* 0x2 */ s8 gid; // defines the draw id and chest opening animation + /* 0x3 */ u8 textId; + /* 0x4 */ u16 objectId; +} GetItemEntry; // size = 0x6 + +typedef struct struct_8085D200 { + /* 0x0 */ PlayerAnimationHeader* unk_0; + /* 0x4 */ PlayerAnimationHeader* unk_4; + /* 0x8 */ u8 unk_8; + /* 0x9 */ u8 unk_9; +} struct_8085D200; // size = 0xC + +f32 D_80862AFC; // distance of the analog stick to its center +s16 D_80862B00; // analog stick angle/yaw +s16 D_80862B02; // analog stick yaw + camera yaw +s32 D_80862B04; // boolean, set to the return value of func_8083216C +FloorType sPlayerCurrentFloorType; +u32 sPlayerCurrentWallFlags; +ConveyorSpeed sPlayerConveyorSpeedIndex; +s16 sPlayerIsOnFloorConveyor; +s16 D_80862B16; // SurfaceType_GetConveyorDirection << 0xA +f32 D_80862B18; // D_80862B18 = this->actor.world.pos.y - this->actor.floorHeight; +FloorProperty sPlayerPrevFloorProperty; +s32 D_80862B20; // ABS_ALT(this->actor.shape.rot.y - BINANG_ADD(this->actor.wallYaw, 0x8000)) +s32 D_80862B24; // ABS_ALT(BINANG_SUB(this->currentYaw, BINANG_ADD(this->actor.wallYaw, 0x8000))) +s16 D_80862B28; +s32 D_80862B2C; // D_80862B2C = player->currentMask; +Vec3f D_80862B30; +f32 D_80862B3C; +FloorEffect D_80862B40; // SurfaceType_GetFloorEffect +Input* sPlayerControlInput; +s32 D_80862B48; +s32 D_80862B4C; +EnvLightSettings D_80862B50; // backup of play->envCtx.lightSettings +s32 D_80862B6C; // this->skelAnime.moveFlags // sPlayerSkelMoveFlags? + +s32 func_8082DA90(PlayState* play) { + return (play->transitionTrigger != TRANS_TRIGGER_OFF) || (play->transitionMode != TRANS_MODE_OFF); +} + +void Player_StopHorizontalMovement(Player* this) { + this->linearVelocity = 0.0f; + this->actor.speed = 0.0f; +} + +void func_8082DAD4(Player* this) { + Player_StopHorizontalMovement(this); + this->unk_AA5 = PLAYER_UNKAA5_0; +} + +s32 func_8082DAFC(PlayState* play) { + Player* player = GET_PLAYER(play); + + return CHECK_FLAG_ALL(player->actor.flags, ACTOR_FLAG_TALK_REQUESTED); +} + +void Player_AnimationPlayOnce(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + PlayerAnimation_PlayOnce(play, &this->skelAnime, anim); +} + +void Player_AnimationPlayLoop(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + PlayerAnimation_PlayLoop(play, &this->skelAnime, anim); +} + +void func_8082DB60(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + PlayerAnimation_PlayLoopSetSpeed(play, &this->skelAnime, anim, 2.0f / 3.0f); +} + +void func_8082DB90(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + PlayerAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, 2.0f / 3.0f); +} + +void Player_AnimationPlayOnceReverse(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + PlayerAnimation_Change(play, &this->skelAnime, anim, -2.0f / 3.0f, Animation_GetLastFrame(anim), 0.0f, + ANIMMODE_ONCE, 0.0f); +} + +void func_8082DC28(Player* this) { + this->skelAnime.jointTable[PLAYER_LIMB_WAIST - 1].y = 0; +} + +void func_8082DC38(Player* this) { + this->stateFlags2 &= ~PLAYER_STATE2_20000; + this->meleeWeaponState = PLAYER_MELEE_WEAPON_STATE_0; + this->meleeWeaponInfo[2].active = false; + this->meleeWeaponInfo[1].active = false; + this->meleeWeaponInfo[0].active = false; +} + +void func_8082DC64(PlayState* play, Player* this) { + if ((this->subCamId != CAM_ID_NONE) && (play->cameraPtrs[this->subCamId] != NULL)) { + this->subCamId = CAM_ID_NONE; + } + + this->stateFlags2 &= ~(PLAYER_STATE2_400 | PLAYER_STATE2_800); +} + +void func_8082DCA0(PlayState* play, Player* this) { + Actor* heldActor = this->heldActor; + + if ((heldActor != NULL) && !Player_IsHoldingHookshot(this)) { + this->actor.child = NULL; + this->heldActor = NULL; + this->interactRangeActor = NULL; + heldActor->parent = NULL; + this->stateFlags1 &= ~PLAYER_STATE1_800; + } + + if (Player_GetExplosiveHeld(this) > PLAYER_EXPLOSIVE_NONE) { + func_8082F8BC(play, this, PLAYER_IA_NONE); + this->heldItemId = ITEM_FE; + } +} + +void func_8082DD2C(PlayState* play, Player* this) { + if ((this->stateFlags1 & PLAYER_STATE1_800) && (this->heldActor == NULL)) { + if (this->interactRangeActor != NULL) { + if (this->getItemId == GI_NONE) { + this->stateFlags1 &= ~PLAYER_STATE1_800; + this->interactRangeActor = NULL; + } + } else { + this->stateFlags1 &= ~PLAYER_STATE1_800; + } + } + + func_8082DC38(this); + this->unk_AA5 = PLAYER_UNKAA5_0; + func_8082DC64(play, this); + func_800E0238(Play_GetCamera(play, CAM_ID_MAIN)); + this->stateFlags1 &= + ~(PLAYER_STATE1_4 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_100000 | PLAYER_STATE1_200000); + this->stateFlags2 &= ~(PLAYER_STATE2_10 | PLAYER_STATE2_80); + this->unk_ADD = 0; + this->unk_ADC = 0; + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->unk_ABC = 0.0f; + this->unk_AC0 = 0.0f; +} + +s32 func_8082DE14(PlayState* play, Player* this) { + if (this->heldItemAction > PLAYER_IA_LAST_USED) { + func_80831990(play, this, ITEM_NONE); + return true; + } else { + return false; + } +} + +void func_8082DE50(PlayState* play, Player* this) { + func_8082DD2C(play, this); + func_8082DCA0(play, this); +} + +s32 func_8082DE88(Player* this, s32 arg1, s32 arg2) { + s16 temp_v0 = this->unk_D64 - D_80862B00; + + this->unk_AE8 += arg1 + (s16)(ABS_ALT(temp_v0) * fabsf(D_80862AFC) * (1.0f / 0x600F0)); + if (CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_B | BTN_A)) { + this->unk_AE8 += 5; + } + + return this->unk_AE8 >= arg2; +} + +void func_8082DF2C(PlayState* play) { + if (play->actorCtx.freezeFlashTimer == 0) { + play->actorCtx.freezeFlashTimer = 1; + } +} + +u8 D_8085B9F0[PLAYER_LIMB_MAX] = { + false, // PLAYER_LIMB_NONE + false, // PLAYER_LIMB_ROOT + false, // PLAYER_LIMB_WAIST + false, // PLAYER_LIMB_LOWER_ROOT + false, // PLAYER_LIMB_R_THIGH + false, // PLAYER_LIMB_R_SHIN + false, // PLAYER_LIMB_R_FOOT + false, // PLAYER_LIMB_L_THIGH + false, // PLAYER_LIMB_L_SHIN + false, // PLAYER_LIMB_L_FOOT + true, // PLAYER_LIMB_UPPER_ROOT + true, // PLAYER_LIMB_HEAD + true, // PLAYER_LIMB_HAT + true, // PLAYER_LIMB_COLLAR + true, // PLAYER_LIMB_L_SHOULDER + true, // PLAYER_LIMB_L_FOREARM + true, // PLAYER_LIMB_L_HAND + true, // PLAYER_LIMB_R_SHOULDER + true, // PLAYER_LIMB_R_FOREARM + true, // PLAYER_LIMB_R_HAND + true, // PLAYER_LIMB_SHEATH + true, // PLAYER_LIMB_TORSO +}; +u8 D_8085BA08[PLAYER_LIMB_MAX] = { + false, // PLAYER_LIMB_NONE + false, // PLAYER_LIMB_ROOT + false, // PLAYER_LIMB_WAIST + false, // PLAYER_LIMB_LOWER_ROOT + false, // PLAYER_LIMB_R_THIGH + false, // PLAYER_LIMB_R_SHIN + false, // PLAYER_LIMB_R_FOOT + false, // PLAYER_LIMB_L_THIGH + false, // PLAYER_LIMB_L_SHIN + false, // PLAYER_LIMB_L_FOOT + false, // PLAYER_LIMB_UPPER_ROOT + false, // PLAYER_LIMB_HEAD + false, // PLAYER_LIMB_HAT + false, // PLAYER_LIMB_COLLAR + true, // PLAYER_LIMB_L_SHOULDER + true, // PLAYER_LIMB_L_FOREARM + true, // PLAYER_LIMB_L_HAND + false, // PLAYER_LIMB_R_SHOULDER + false, // PLAYER_LIMB_R_FOREARM + false, // PLAYER_LIMB_R_HAND + false, // PLAYER_LIMB_SHEATH + false, // PLAYER_LIMB_TORSO +}; +u8 D_8085BA20[PLAYER_LIMB_MAX] = { + false, // PLAYER_LIMB_NONE + false, // PLAYER_LIMB_ROOT + false, // PLAYER_LIMB_WAIST + false, // PLAYER_LIMB_LOWER_ROOT + false, // PLAYER_LIMB_R_THIGH + false, // PLAYER_LIMB_R_SHIN + false, // PLAYER_LIMB_R_FOOT + false, // PLAYER_LIMB_L_THIGH + false, // PLAYER_LIMB_L_SHIN + false, // PLAYER_LIMB_L_FOOT + false, // PLAYER_LIMB_UPPER_ROOT + false, // PLAYER_LIMB_HEAD + false, // PLAYER_LIMB_HAT + false, // PLAYER_LIMB_COLLAR + false, // PLAYER_LIMB_L_SHOULDER + false, // PLAYER_LIMB_L_FOREARM + false, // PLAYER_LIMB_L_HAND + true, // PLAYER_LIMB_R_SHOULDER + true, // PLAYER_LIMB_R_FOREARM + true, // PLAYER_LIMB_R_HAND + false, // PLAYER_LIMB_SHEATH + false, // PLAYER_LIMB_TORSO +}; + +void Player_RequestRumble(PlayState* play, Player* this, s32 sourceIntensity, s32 decayTimer, s32 decayStep, + s32 distSq) { + if (this == GET_PLAYER(play)) { + Rumble_Request(distSq, sourceIntensity, decayTimer, decayStep); + } +} + +// TODO: less dumb name +#define SFX_VOICE_BANK_SIZE 0x20 + +PlayerAgeProperties sPlayerAgeProperties[PLAYER_FORM_MAX] = { + { + // unk_00; + 84.0f, + // shadowScale; + 90.0f, + // unk_08; + 1.5f, + // unk_0C; + 166.5f, + // unk_10; + 105.0f, + // unk_14; + 119.100006f, + // unk_18; + 88.5f, + // unk_1C; + 61.5f, + // unk_20; + 28.5f, + // unk_24; + 54.0f, + // unk_28; + 75.0f, + // unk_2C; + 84.0f, + // unk_30; + 102.0f, + // unk_34; // height? + 70.0f, + // unk_38; + 27.0f, + // unk_3C; + 24.75f, + // unk_40; + 105.0f, + // unk_44 + { 9, 0x123F, 0x167 }, + { + { 8, 0x1256, 0x17C }, + { 9, 0x17EA, 0x167 }, + { 8, 0x1256, 0x17C }, + { 9, 0x17EA, 0x167 }, + }, + { + { 9, 0x17EA, 0x167 }, + { 9, 0x1E0D, 0x17C }, + { 9, 0x17EA, 0x167 }, + { 9, 0x1E0D, 0x17C }, + }, + { + { 8, 0x1256, 0x17C }, + { 9, 0x17EA, 0x167 }, + { -0x638, 0x1256, 0x17C }, + { -0x637, 0x17EA, 0x167 }, + }, + // voiceSfxIdOffset; + SFX_VOICE_BANK_SIZE * 0, + // surfaceSfxIdOffset; + 0x80, + // unk_98; + 33.0f, + // unk_9C; + 44.15145f, + // openChestAnim + &gPlayerAnim_link_demo_Tbox_open, + // unk_A4 + &gPlayerAnim_link_demo_back_to_past, + // unk_A8 + &gPlayerAnim_link_demo_return_to_past, + // unk_AC + &gPlayerAnim_link_normal_climb_startA, + // unk_B0 + &gPlayerAnim_link_normal_climb_startB, + // unk_B4 + { + &gPlayerAnim_link_normal_climb_upL, + &gPlayerAnim_link_normal_climb_upR, + &gPlayerAnim_link_normal_Fclimb_upL, + &gPlayerAnim_link_normal_Fclimb_upR, + }, + // unk_C4 + { + &gPlayerAnim_link_normal_Fclimb_sideL, + &gPlayerAnim_link_normal_Fclimb_sideR, + }, + // unk_CC + { + &gPlayerAnim_link_normal_climb_endAL, + &gPlayerAnim_link_normal_climb_endAR, + }, + // unk_D4 + { + &gPlayerAnim_link_normal_climb_endBR, + &gPlayerAnim_link_normal_climb_endBL, + }, + }, + { + // unk_00; + 70.0f, + // shadowScale; + 90.0f, + // unk_08; + 0.74f, + // unk_0C; + 111.0f, + // unk_10; + 70.0f, + // unk_14; + 79.4f, + // unk_18; + 59.0f, + // unk_1C; + 41.0f, + // unk_20; + 19.0f, + // unk_24; + 36.0f, + // unk_28; + 50.0f, + // unk_2C; + 56.0f, + // unk_30; + 68.0f, + // unk_34; // height? + 70.0f, + // unk_38; + 19.5f, + // unk_3C; + 18.2f, + // unk_40; + 80.0f, + // unk_44 + { 0x17, 0xF3B, 0xDF }, + { + { 0x18, 0xF3B, 0xDF }, + { 0x17, 0x14CF, 0xDF }, + { 0x18, 0xF3B, 0xDF }, + { 0x17, 0x14CF, 0xDF }, + }, + { + { 0x17, 0x14CF, 0xDF }, + { 0x18, 0x1AF2, 0xDF }, + { 0x17, 0x14CF, 0xDF }, + { 0x18, 0x1AF2, 0xDF }, + }, + { + { 8, 0x1256, 0x17C }, + { 9, 0x17EA, 0x167 }, + { -0x638, 0x1256, 0x17C }, + { -0x637, 0x17EA, 0x167 }, + }, + // voiceSfxIdOffset; + SFX_VOICE_BANK_SIZE * 6, + // surfaceSfxIdOffset; + 0x150, + // unk_98; + -25.0f, + // unk_9C; + 42.0f, + // openChestAnim + &gPlayerAnim_pg_Tbox_open, + // unk_A4 + &gPlayerAnim_link_demo_back_to_past, + // unk_A8 + &gPlayerAnim_link_demo_return_to_past, + // unk_AC + &gPlayerAnim_pg_climb_startA, + // unk_B0 + &gPlayerAnim_pg_climb_startB, + // unk_B4 + { + &gPlayerAnim_pg_climb_upL, + &gPlayerAnim_pg_climb_upR, + &gPlayerAnim_pg_climb_upL, + &gPlayerAnim_pg_climb_upR, + }, + // unk_C4 + { + &gPlayerAnim_link_normal_Fclimb_sideL, + &gPlayerAnim_link_normal_Fclimb_sideR, + }, + // unk_CC + { + &gPlayerAnim_pg_climb_endAL, + &gPlayerAnim_pg_climb_endAR, + }, + // unk_D4 + { + &gPlayerAnim_pg_climb_endBR, + &gPlayerAnim_pg_climb_endBL, + }, + }, + { + // unk_00; + 56.0f, + // shadowScale; + 90.0f, + // unk_08; + 1.0f, + // unk_0C; + 111.0f, + // unk_10; + 70.0f, + // unk_14; + 79.4f, + // unk_18; + 59.0f, + // unk_1C; + 41.0f, + // unk_20; + 19.0f, + // unk_24; + 36.0f, + // unk_28; + 50.0f, + // unk_2C; + 56.0f, + // unk_30; + 68.0f, + // unk_34; // height? + 70.0f, + // unk_38; + 18.0f, + // unk_3C; + 23.0f, + // unk_40; + 70.0f, + // unk_44 + { 0x17, 0x1323, -0x6D }, + { + { 0x17, 0x1323, -0x58 }, + { 0x17, 0x18B7, -0x6D }, + { 0x17, 0x1323, -0x58 }, + { 0x17, 0x18B7, -0x6D }, + }, + { + { 0x17, 0x18B7, -0x6D }, + { 0x18, 0x1EDA, -0x58 }, + { 0x17, 0x18B7, -0x6D }, + { 0x18, 0x1EDA, -0x58 }, + }, + { + { 8, 0x1256, 0x17C }, + { 9, 0x17EA, 0x167 }, + { -0x638, 0x1256, 0x17C }, + { -0x637, 0x17EA, 0x167 }, + }, + // voiceSfxIdOffset; + SFX_VOICE_BANK_SIZE * 5, + // surfaceSfxIdOffset; + 0x120, + // unk_98; + 22.0f, + // unk_9C; + 36.0f, + // openChestAnim + &gPlayerAnim_pz_Tbox_open, + // unk_A4 + &gPlayerAnim_link_demo_back_to_past, + // unk_A8 + &gPlayerAnim_link_demo_return_to_past, + // unk_AC + &gPlayerAnim_pz_climb_startA, + // unk_B0 + &gPlayerAnim_pz_climb_startB, + // unk_B4 + { + &gPlayerAnim_pz_climb_upL, + &gPlayerAnim_pz_climb_upR, + &gPlayerAnim_link_normal_Fclimb_upL, + &gPlayerAnim_link_normal_Fclimb_upR, + }, + // unk_C4 + { + &gPlayerAnim_link_normal_Fclimb_sideL, + &gPlayerAnim_link_normal_Fclimb_sideR, + }, + // unk_CC + { + &gPlayerAnim_pz_climb_endAL, + &gPlayerAnim_pz_climb_endAR, + }, + // unk_D4 + { + &gPlayerAnim_pz_climb_endBR, + &gPlayerAnim_pz_climb_endBL, + }, + }, + { + // unk_00; + 35.0f, + // shadowScale; + 50.0f, + // unk_08; + 0.3f, + // unk_0C; + 71.0f, + // unk_10; + 50.0f, + // unk_14; + 49.0f, + // unk_18; + 39.0f, + // unk_1C; + 27.0f, + // unk_20; + 19.0f, + // unk_24; + 8.0f, + // unk_28; + 13.6f, + // unk_2C; + 24.0f, + // unk_30; + 24.0f, + // unk_34; // height? + 70.0f, + // unk_38; + 14.0f, + // unk_3C; + 12.0f, + // unk_40; + 55.0f, + // unk_44 + { -0x18, 0xDED, 0x36C }, + { + { -0x18, 0xD92, 0x35E }, + { -0x18, 0x1371, 0x3A9 }, + { 8, 0x1256, 0x17C }, + { 9, 0x17EA, 0x167 }, + }, + { + { -0x18, 0x1371, 0x3A9 }, + { -0x18, 0x195F, 0x3A9 }, + { 9, 0x17EA, 0x167 }, + { 9, 0x1E0D, 0x17C }, + }, + { + { 8, 0x1256, 0x17C }, + { 9, 0x17EA, 0x167 }, + { -0x638, 0x1256, 0x17C }, + { -0x637, 0x17EA, 0x167 }, + }, + // voiceSfxIdOffset; + SFX_VOICE_BANK_SIZE * 4, + // surfaceSfxIdOffset; + 0xF0, + // unk_98; + -21.0f, + // unk_9C; + 33.0f, + // openChestAnim + &gPlayerAnim_pn_Tbox_open, + // unk_A4 + &gPlayerAnim_link_demo_back_to_past, + // unk_A8 + &gPlayerAnim_link_demo_return_to_past, + // unk_AC + &gPlayerAnim_clink_normal_climb_startA, + // unk_B0 + &gPlayerAnim_clink_normal_climb_startB, + // unk_B4 + { + &gPlayerAnim_clink_normal_climb_upL, + &gPlayerAnim_clink_normal_climb_upR, + &gPlayerAnim_link_normal_Fclimb_upL, + &gPlayerAnim_link_normal_Fclimb_upR, + }, + // unk_C4 + { + &gPlayerAnim_link_normal_Fclimb_sideL, + &gPlayerAnim_link_normal_Fclimb_sideR, + }, + // unk_CC + { + &gPlayerAnim_clink_normal_climb_endAL, + &gPlayerAnim_clink_normal_climb_endAR, + }, + // unk_D4 + { + &gPlayerAnim_clink_normal_climb_endBR, + &gPlayerAnim_clink_normal_climb_endBL, + }, + }, + { + // unk_00; + 40.0f, + // shadowScale; + 60.0f, + // unk_08; + 11.0f / 17.0f, + // unk_0C; + 71.0f, + // unk_10; + 50.0f, + // unk_14; + 49.0f, + // unk_18; + 39.0f, + // unk_1C; + 27.0f, + // unk_20; + 19.0f, + // unk_24; + 22.0f, + // unk_28; + 32.4f, + // unk_2C; + 32.0f, + // unk_30; + 48.0f, + // unk_34; // height? + 11.0f / 17.0f * 70.0f, + // unk_38; + 14.0f, + // unk_3C; + 12.0f, + // unk_40; + 55.0f, + // unk_44 + { -0x18, 0xDED, 0x36C }, + { + { -0x18, 0xD92, 0x35E }, + { -0x18, 0x1371, 0x3A9 }, + { 8, 0x1256, 0x17C }, + { 9, 0x17EA, 0x167 }, + }, + { + { -0x18, 0x1371, 0x3A9 }, + { -0x18, 0x195F, 0x3A9 }, + { 9, 0x17EA, 0x167 }, + { 9, 0x1E0D, 0x17C }, + }, + { + { 8, 0x1256, 0x17C }, + { 9, 0x17EA, 0x167 }, + { -0x638, 0x1256, 0x17C }, + { -0x637, 0x17EA, 0x167 }, + }, + // voiceSfxIdOffset; + SFX_VOICE_BANK_SIZE * 1, + // surfaceSfxIdOffset; + 0, + // unk_98; + 22.0f, + // unk_9C; + 29.4343f, + // openChestAnim + &gPlayerAnim_clink_demo_Tbox_open, + // unk_A4 + &gPlayerAnim_clink_demo_goto_future, + // unk_A8 + &gPlayerAnim_clink_demo_return_to_future, + // unk_AC + &gPlayerAnim_clink_normal_climb_startA, + // unk_B0 + &gPlayerAnim_clink_normal_climb_startB, + // unk_B4 + { + &gPlayerAnim_clink_normal_climb_upL, + &gPlayerAnim_clink_normal_climb_upR, + &gPlayerAnim_link_normal_Fclimb_upL, + &gPlayerAnim_link_normal_Fclimb_upR, + }, + // unk_C4 + { + &gPlayerAnim_link_normal_Fclimb_sideL, + &gPlayerAnim_link_normal_Fclimb_sideR, + }, + // unk_CC + { + &gPlayerAnim_clink_normal_climb_endAL, + &gPlayerAnim_clink_normal_climb_endAR, + }, + // unk_D4 + { + &gPlayerAnim_clink_normal_climb_endBR, + &gPlayerAnim_clink_normal_climb_endBL, + }, + }, +}; + +PlayerAnimationHeader* D_8085BE84[PLAYER_ANIMGROUP_MAX][PLAYER_ANIMTYPE_MAX] = { + // PLAYER_ANIMGROUP_0 + { + &gPlayerAnim_link_normal_wait_free, // Default idle standing, looking forward + &gPlayerAnim_link_normal_wait, // Default idle standing, looking forward, sword and shield + &gPlayerAnim_link_normal_wait, // Default idle standing, looking forward, sword and shield + &gPlayerAnim_link_fighter_wait_long, // Default idle standing, looking forward, two hand weapon + &gPlayerAnim_link_normal_wait_free, // Default idle standing, looking forward + &gPlayerAnim_link_normal_wait_free, // Default idle standing, looking forward + }, + // PLAYER_ANIMGROUP_1 + { + &gPlayerAnim_link_normal_walk_free, + &gPlayerAnim_link_normal_walk, + &gPlayerAnim_link_normal_walk, + &gPlayerAnim_link_fighter_walk_long, + &gPlayerAnim_link_normal_walk_free, + &gPlayerAnim_link_normal_walk_free, + }, + // PLAYER_ANIMGROUP_2 + { + &gPlayerAnim_link_normal_run_free, // Running with empty hands + &gPlayerAnim_link_fighter_run, // Running with Sword and Shield in hands + &gPlayerAnim_link_normal_run, + &gPlayerAnim_link_fighter_run_long, // Running with Two handed weapon + &gPlayerAnim_link_normal_run_free, // Running with empty hands + &gPlayerAnim_link_normal_run_free, // Running with empty hands + }, + // PLAYER_ANIMGROUP_3 + { + &gPlayerAnim_link_normal_damage_run_free, + &gPlayerAnim_link_fighter_damage_run, + &gPlayerAnim_link_normal_damage_run_free, + &gPlayerAnim_link_fighter_damage_run_long, + &gPlayerAnim_link_normal_damage_run_free, + &gPlayerAnim_link_normal_damage_run_free, + }, + // PLAYER_ANIMGROUP_4 + { + &gPlayerAnim_link_normal_waitL_free, + &gPlayerAnim_link_anchor_waitL, + &gPlayerAnim_link_anchor_waitL, + &gPlayerAnim_link_fighter_waitL_long, + &gPlayerAnim_link_normal_waitL_free, + &gPlayerAnim_link_normal_waitL_free, + }, + // PLAYER_ANIMGROUP_5 + { + &gPlayerAnim_link_normal_waitR_free, + &gPlayerAnim_link_anchor_waitR, + &gPlayerAnim_link_anchor_waitR, + &gPlayerAnim_link_fighter_waitR_long, + &gPlayerAnim_link_normal_waitR_free, + &gPlayerAnim_link_normal_waitR_free, + }, + // PLAYER_ANIMGROUP_6 + { + &gPlayerAnim_link_fighter_wait2waitR_long, + &gPlayerAnim_link_normal_wait2waitR, + &gPlayerAnim_link_normal_wait2waitR, + &gPlayerAnim_link_fighter_wait2waitR_long, + &gPlayerAnim_link_fighter_wait2waitR_long, + &gPlayerAnim_link_fighter_wait2waitR_long, + }, + // PLAYER_ANIMGROUP_7 + { + &gPlayerAnim_link_normal_normal2fighter_free, + &gPlayerAnim_link_fighter_normal2fighter, + &gPlayerAnim_link_fighter_normal2fighter, + &gPlayerAnim_link_normal_normal2fighter_free, + &gPlayerAnim_link_normal_normal2fighter_free, + &gPlayerAnim_link_normal_normal2fighter_free, + }, + // PLAYER_ANIMGROUP_8 + { + &gPlayerAnim_link_demo_doorA_link_free, + &gPlayerAnim_link_demo_doorA_link, + &gPlayerAnim_link_demo_doorA_link, + &gPlayerAnim_link_demo_doorA_link_free, + &gPlayerAnim_link_demo_doorA_link_free, + &gPlayerAnim_link_demo_doorA_link_free, + }, + // PLAYER_ANIMGROUP_9 + { + &gPlayerAnim_clink_demo_doorA_link, + &gPlayerAnim_clink_demo_doorA_link, + &gPlayerAnim_clink_demo_doorA_link, + &gPlayerAnim_clink_demo_doorA_link, + &gPlayerAnim_clink_demo_doorA_link, + &gPlayerAnim_clink_demo_doorA_link, + }, + // PLAYER_ANIMGROUP_10 + { + &gPlayerAnim_link_demo_doorB_link_free, + &gPlayerAnim_link_demo_doorB_link, + &gPlayerAnim_link_demo_doorB_link, + &gPlayerAnim_link_demo_doorB_link_free, + &gPlayerAnim_link_demo_doorB_link_free, + &gPlayerAnim_link_demo_doorB_link_free, + }, + // PLAYER_ANIMGROUP_11 + { + &gPlayerAnim_clink_demo_doorB_link, + &gPlayerAnim_clink_demo_doorB_link, + &gPlayerAnim_clink_demo_doorB_link, + &gPlayerAnim_clink_demo_doorB_link, + &gPlayerAnim_clink_demo_doorB_link, + &gPlayerAnim_clink_demo_doorB_link, + }, + // PLAYER_ANIMGROUP_12 + { + &gPlayerAnim_link_normal_carryB_free, // Grabbing something from the floor + &gPlayerAnim_link_normal_carryB, // + &gPlayerAnim_link_normal_carryB, // + &gPlayerAnim_link_normal_carryB_free, // Grabbing something from the floor + &gPlayerAnim_link_normal_carryB_free, // Grabbing something from the floor + &gPlayerAnim_link_normal_carryB_free, // Grabbing something from the floor + }, + // PLAYER_ANIMGROUP_13 + { + &gPlayerAnim_link_normal_landing_free, + &gPlayerAnim_link_normal_landing, + &gPlayerAnim_link_normal_landing, + &gPlayerAnim_link_normal_landing_free, + &gPlayerAnim_link_normal_landing_free, + &gPlayerAnim_link_normal_landing_free, + }, + // PLAYER_ANIMGROUP_14 + { + &gPlayerAnim_link_normal_short_landing_free, + &gPlayerAnim_link_normal_short_landing, + &gPlayerAnim_link_normal_short_landing, + &gPlayerAnim_link_normal_short_landing_free, + &gPlayerAnim_link_normal_short_landing_free, + &gPlayerAnim_link_normal_short_landing_free, + }, + // PLAYER_ANIMGROUP_15 + { + &gPlayerAnim_link_normal_landing_roll_free, // Rolling with nothing in hands + &gPlayerAnim_link_normal_landing_roll, // Rolling with sword and shield + &gPlayerAnim_link_normal_landing_roll, // Rolling with sword and shield + &gPlayerAnim_link_fighter_landing_roll_long, // Rolling with two hand weapon + &gPlayerAnim_link_normal_landing_roll_free, // Rolling with nothing in hands + &gPlayerAnim_link_normal_landing_roll_free, // Rolling with nothing in hands + }, + // PLAYER_ANIMGROUP_16 + { + &gPlayerAnim_link_normal_hip_down_free, // Rolling bonk + &gPlayerAnim_link_normal_hip_down, // Rolling bonk swrod and shield + &gPlayerAnim_link_normal_hip_down, // Rolling bonk swrod and shield + &gPlayerAnim_link_normal_hip_down_long, // Rolling bonk two hand weapon + &gPlayerAnim_link_normal_hip_down_free, // Rolling bonk + &gPlayerAnim_link_normal_hip_down_free, // Rolling bonk + }, + // PLAYER_ANIMGROUP_17 + { + &gPlayerAnim_link_normal_walk_endL_free, + &gPlayerAnim_link_normal_walk_endL, + &gPlayerAnim_link_normal_walk_endL, + &gPlayerAnim_link_fighter_walk_endL_long, + &gPlayerAnim_link_normal_walk_endL_free, + &gPlayerAnim_link_normal_walk_endL_free, + }, + // PLAYER_ANIMGROUP_18 + { + &gPlayerAnim_link_normal_walk_endR_free, + &gPlayerAnim_link_normal_walk_endR, + &gPlayerAnim_link_normal_walk_endR, + &gPlayerAnim_link_fighter_walk_endR_long, + &gPlayerAnim_link_normal_walk_endR_free, + &gPlayerAnim_link_normal_walk_endR_free, + }, + // PLAYER_ANIMGROUP_19 + { + &gPlayerAnim_link_normal_defense_free, + &gPlayerAnim_link_normal_defense, + &gPlayerAnim_link_normal_defense, + &gPlayerAnim_link_normal_defense_free, + &gPlayerAnim_link_bow_defense, + &gPlayerAnim_link_normal_defense_free, + }, + // PLAYER_ANIMGROUP_20 + { + &gPlayerAnim_link_normal_defense_wait_free, + &gPlayerAnim_link_normal_defense_wait, + &gPlayerAnim_link_normal_defense_wait, + &gPlayerAnim_link_normal_defense_wait_free, + &gPlayerAnim_link_bow_defense_wait, + &gPlayerAnim_link_normal_defense_wait_free, + }, + // PLAYER_ANIMGROUP_21 + { + &gPlayerAnim_link_normal_defense_end_free, + &gPlayerAnim_link_normal_defense_end, + &gPlayerAnim_link_normal_defense_end, + &gPlayerAnim_link_normal_defense_end_free, + &gPlayerAnim_link_normal_defense_end_free, + &gPlayerAnim_link_normal_defense_end_free, + }, + // PLAYER_ANIMGROUP_22 + { + &gPlayerAnim_link_normal_side_walk_free, + &gPlayerAnim_link_normal_side_walk, + &gPlayerAnim_link_normal_side_walk, + &gPlayerAnim_link_fighter_side_walk_long, + &gPlayerAnim_link_normal_side_walk_free, + &gPlayerAnim_link_normal_side_walk_free, + }, + // PLAYER_ANIMGROUP_23 + { + &gPlayerAnim_link_normal_side_walkL_free, // Side walking + &gPlayerAnim_link_anchor_side_walkL, // Side walking with sword and shield in hands + &gPlayerAnim_link_anchor_side_walkL, // Side walking with sword and shield in hands + &gPlayerAnim_link_fighter_side_walkL_long, + &gPlayerAnim_link_normal_side_walkL_free, // Side walking + &gPlayerAnim_link_normal_side_walkL_free, // Side walking + }, + // PLAYER_ANIMGROUP_24 + { + &gPlayerAnim_link_normal_side_walkR_free, + &gPlayerAnim_link_anchor_side_walkR, + &gPlayerAnim_link_anchor_side_walkR, + &gPlayerAnim_link_fighter_side_walkR_long, + &gPlayerAnim_link_normal_side_walkR_free, + &gPlayerAnim_link_normal_side_walkR_free, + }, + // PLAYER_ANIMGROUP_25 + { + &gPlayerAnim_link_normal_45_turn_free, + &gPlayerAnim_link_normal_45_turn, + &gPlayerAnim_link_normal_45_turn, + &gPlayerAnim_link_normal_45_turn_free, + &gPlayerAnim_link_normal_45_turn_free, + &gPlayerAnim_link_normal_45_turn_free, + }, + // PLAYER_ANIMGROUP_26 + { + &gPlayerAnim_link_normal_waitL2wait, + &gPlayerAnim_link_normal_waitL2wait, + &gPlayerAnim_link_normal_waitL2wait, + &gPlayerAnim_link_fighter_waitL2wait_long, + &gPlayerAnim_link_fighter_waitL2wait_long, + &gPlayerAnim_link_fighter_waitL2wait_long, + }, + // PLAYER_ANIMGROUP_27 + { + &gPlayerAnim_link_normal_waitR2wait, + &gPlayerAnim_link_normal_waitR2wait, + &gPlayerAnim_link_normal_waitR2wait, + &gPlayerAnim_link_fighter_waitR2wait_long, + &gPlayerAnim_link_fighter_waitR2wait_long, + &gPlayerAnim_link_fighter_waitR2wait_long, + }, + // PLAYER_ANIMGROUP_28 + { + &gPlayerAnim_link_normal_throw_free, + &gPlayerAnim_link_normal_throw, + &gPlayerAnim_link_normal_throw, + &gPlayerAnim_link_normal_throw_free, + &gPlayerAnim_link_normal_throw_free, + &gPlayerAnim_link_normal_throw_free, + }, + // PLAYER_ANIMGROUP_29 + { + &gPlayerAnim_link_normal_put_free, + &gPlayerAnim_link_normal_put, + &gPlayerAnim_link_normal_put, + &gPlayerAnim_link_normal_put_free, + &gPlayerAnim_link_normal_put_free, + &gPlayerAnim_link_normal_put_free, + }, + // PLAYER_ANIMGROUP_30 + { + &gPlayerAnim_link_normal_back_walk, + &gPlayerAnim_link_normal_back_walk, + &gPlayerAnim_link_normal_back_walk, + &gPlayerAnim_link_normal_back_walk, + &gPlayerAnim_link_normal_back_walk, + &gPlayerAnim_link_normal_back_walk, + }, + // PLAYER_ANIMGROUP_31 + { + &gPlayerAnim_link_normal_check_free, + &gPlayerAnim_link_normal_check, + &gPlayerAnim_link_normal_check, + &gPlayerAnim_link_normal_check_free, + &gPlayerAnim_link_normal_check_free, + &gPlayerAnim_link_normal_check_free, + }, + // PLAYER_ANIMGROUP_32 + { + &gPlayerAnim_link_normal_check_wait_free, + &gPlayerAnim_link_normal_check_wait, + &gPlayerAnim_link_normal_check_wait, + &gPlayerAnim_link_normal_check_wait_free, + &gPlayerAnim_link_normal_check_wait_free, + &gPlayerAnim_link_normal_check_wait_free, + }, + // PLAYER_ANIMGROUP_33 + { + &gPlayerAnim_link_normal_check_end_free, + &gPlayerAnim_link_normal_check_end, + &gPlayerAnim_link_normal_check_end, + &gPlayerAnim_link_normal_check_end_free, + &gPlayerAnim_link_normal_check_end_free, + &gPlayerAnim_link_normal_check_end_free, + }, + // PLAYER_ANIMGROUP_34 + { + &gPlayerAnim_link_normal_pull_start_free, + &gPlayerAnim_link_normal_pull_start, + &gPlayerAnim_link_normal_pull_start, + &gPlayerAnim_link_normal_pull_start_free, + &gPlayerAnim_link_normal_pull_start_free, + &gPlayerAnim_link_normal_pull_start_free, + }, + // PLAYER_ANIMGROUP_35 + { + &gPlayerAnim_link_normal_pulling_free, + &gPlayerAnim_link_normal_pulling, + &gPlayerAnim_link_normal_pulling, + &gPlayerAnim_link_normal_pulling_free, + &gPlayerAnim_link_normal_pulling_free, + &gPlayerAnim_link_normal_pulling_free, + }, + // PLAYER_ANIMGROUP_36 + { + &gPlayerAnim_link_normal_pull_end_free, + &gPlayerAnim_link_normal_pull_end, + &gPlayerAnim_link_normal_pull_end, + &gPlayerAnim_link_normal_pull_end_free, + &gPlayerAnim_link_normal_pull_end_free, + &gPlayerAnim_link_normal_pull_end_free, + }, + // PLAYER_ANIMGROUP_37 + { + &gPlayerAnim_link_normal_fall_up_free, + &gPlayerAnim_link_normal_fall_up, + &gPlayerAnim_link_normal_fall_up, + &gPlayerAnim_link_normal_fall_up_free, + &gPlayerAnim_link_normal_fall_up_free, + &gPlayerAnim_link_normal_fall_up_free, + }, + // PLAYER_ANIMGROUP_38 + { + &gPlayerAnim_link_normal_jump_climb_hold_free, + &gPlayerAnim_link_normal_jump_climb_hold, + &gPlayerAnim_link_normal_jump_climb_hold, + &gPlayerAnim_link_normal_jump_climb_hold_free, + &gPlayerAnim_link_normal_jump_climb_hold_free, + &gPlayerAnim_link_normal_jump_climb_hold_free, + }, + // PLAYER_ANIMGROUP_39 + { + &gPlayerAnim_link_normal_jump_climb_wait_free, + &gPlayerAnim_link_normal_jump_climb_wait, + &gPlayerAnim_link_normal_jump_climb_wait, + &gPlayerAnim_link_normal_jump_climb_wait_free, + &gPlayerAnim_link_normal_jump_climb_wait_free, + &gPlayerAnim_link_normal_jump_climb_wait_free, + }, + // PLAYER_ANIMGROUP_40 + { + &gPlayerAnim_link_normal_jump_climb_up_free, + &gPlayerAnim_link_normal_jump_climb_up, + &gPlayerAnim_link_normal_jump_climb_up, + &gPlayerAnim_link_normal_jump_climb_up_free, + &gPlayerAnim_link_normal_jump_climb_up_free, + &gPlayerAnim_link_normal_jump_climb_up_free, + }, + // PLAYER_ANIMGROUP_41 + { + &gPlayerAnim_link_normal_down_slope_slip_end_free, + &gPlayerAnim_link_normal_down_slope_slip_end, + &gPlayerAnim_link_normal_down_slope_slip_end, + &gPlayerAnim_link_normal_down_slope_slip_end_long, + &gPlayerAnim_link_normal_down_slope_slip_end_free, + &gPlayerAnim_link_normal_down_slope_slip_end_free, + }, + // PLAYER_ANIMGROUP_42 + { + &gPlayerAnim_link_normal_up_slope_slip_end_free, + &gPlayerAnim_link_normal_up_slope_slip_end, + &gPlayerAnim_link_normal_up_slope_slip_end, + &gPlayerAnim_link_normal_up_slope_slip_end_long, + &gPlayerAnim_link_normal_up_slope_slip_end_free, + &gPlayerAnim_link_normal_up_slope_slip_end_free, + }, + // PLAYER_ANIMGROUP_43 + { + &gPlayerAnim_sude_nwait, + &gPlayerAnim_lkt_nwait, + &gPlayerAnim_lkt_nwait, + &gPlayerAnim_sude_nwait, + &gPlayerAnim_sude_nwait, + &gPlayerAnim_sude_nwait, + } +}; + +struct_8085C2A4 D_8085C2A4[] = { + /* 0 / Forward */ + { + &gPlayerAnim_link_fighter_front_jump, + &gPlayerAnim_link_fighter_front_jump_end, + &gPlayerAnim_link_fighter_front_jump_endR, + }, + /* 1 / Left */ + { + &gPlayerAnim_link_fighter_Lside_jump, + &gPlayerAnim_link_fighter_Lside_jump_end, + &gPlayerAnim_link_fighter_Lside_jump_endL, + }, + /* 2 / Back */ + { + &gPlayerAnim_link_fighter_backturn_jump, + &gPlayerAnim_link_fighter_backturn_jump_end, + &gPlayerAnim_link_fighter_backturn_jump_endR, + }, + /* 3 / Right */ + { + &gPlayerAnim_link_fighter_Rside_jump, + &gPlayerAnim_link_fighter_Rside_jump_end, + &gPlayerAnim_link_fighter_Rside_jump_endR, + }, + /* 4 / */ + { + &gPlayerAnim_link_normal_newroll_jump_20f, + &gPlayerAnim_link_normal_newroll_jump_end_20f, + &gPlayerAnim_link_normal_newroll_jump_end_20f, + }, + /* 5 / */ + { + &gPlayerAnim_link_normal_newside_jump_20f, + &gPlayerAnim_link_normal_newside_jump_end_20f, + &gPlayerAnim_link_normal_newside_jump_end_20f, + }, +}; + +// sCylinderInit +ColliderCylinderInit D_8085C2EC = { + { + COLTYPE_HIT5, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_PLAYER, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK1, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 12, 60, 0, { 0, 0, 0 } }, +}; + +// sShieldCylinderInit +ColliderCylinderInit D_8085C318 = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_HARD | AC_TYPE_ENEMY, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK2, + { 0x00100000, 0x00, 0x02 }, + { 0xD7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, + { 25, 60, 0, { 0, 0, 0 } }, +}; + +// sMeleeWeaponQuadInit +ColliderQuadInit D_8085C344 = { + { + COLTYPE_NONE, + AT_ON | AT_TYPE_PLAYER, + AC_NONE, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK2, + { 0x00000000, 0x00, 0x01 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +// sShieldQuadInit +ColliderQuadInit D_8085C394 = { + { + COLTYPE_METAL, + AT_ON | AT_TYPE_PLAYER, + AC_ON | AC_HARD | AC_TYPE_ENEMY, + OC1_NONE, + OC2_TYPE_PLAYER, + COLSHAPE_QUAD, + }, + { + ELEMTYPE_UNK2, + { 0x00100000, 0x00, 0x00 }, + { 0xD7CFFFFF, 0x00, 0x00 }, + TOUCH_ON | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_NONE, + }, + { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } } }, +}; + +f32 D_8085C3E4 = 1.0f; +f32 D_8085C3E8 = 1.0f; + +// ANIMSFX_TYPE_VOICE +void Player_AnimSfx_PlayVoice(Player* this, u16 sfxId) { + u16 sfxOffset; + + if (this->currentMask == PLAYER_MASK_GIANT) { + func_8019F830(&this->actor.projectedPos, sfxId); + } else if (this->actor.id == ACTOR_PLAYER) { + if (this->currentMask == PLAYER_MASK_SCENTS) { + sfxOffset = SFX_VOICE_BANK_SIZE * 7; + } else { + sfxOffset = this->ageProperties->voiceSfxIdOffset; + } + + Player_PlaySfx(this, sfxOffset + sfxId); + } +} + +u16 D_8085C3EC[] = { + NA_SE_VO_LI_SWEAT, + NA_SE_VO_LI_SNEEZE, + NA_SE_VO_LI_RELAX, + NA_SE_VO_LI_FALL_L, +}; + +void func_8082E00C(Player* this) { + s32 i; + u16* sfxIdPtr = D_8085C3EC; + + for (i = 0; i < ARRAY_COUNT(D_8085C3EC); i++) { + AudioSfx_StopById((u16)(*sfxIdPtr + this->ageProperties->voiceSfxIdOffset)); + sfxIdPtr++; + } +} + +u16 Player_GetFloorSfx(Player* this, u16 sfxId) { + return sfxId + this->floorSfxOffset; +} + +// ANIMSFX_TYPE_FLOOR +void Player_AnimSfx_PlayFloor(Player* this, u16 sfxId) { + Player_PlaySfx(this, Player_GetFloorSfx(this, sfxId)); +} + +u16 Player_GetFloorSfxByAge(Player* this, u16 sfxId) { + return sfxId + this->floorSfxOffset + this->ageProperties->surfaceSfxIdOffset; +} + +// ANIMSFX_TYPE_FLOOR_BY_AGE +void Player_AnimSfx_PlayFloorByAge(Player* this, u16 sfxId) { + Player_PlaySfx(this, Player_GetFloorSfxByAge(this, sfxId)); +} + +// ANIMSFX_TYPE_6 and ANIMSFX_TYPE_8 +void Player_AnimSfx_PlayFloorWalk(Player* this, f32 freqVolumeLerp) { + s32 sfxId; + + if (this->currentMask == PLAYER_MASK_GIANT) { + sfxId = NA_SE_PL_GIANT_WALK; + } else { + sfxId = Player_GetFloorSfxByAge(this, NA_SE_PL_WALK_GROUND); + } + + // Audio_PlaySfx_AtPosForMetalEffectsWithSyncedFreqAndVolume + func_8019F638(&this->actor.projectedPos, sfxId, freqVolumeLerp); +} + +// ANIMSFX_TYPE_FLOOR_JUMP +void Player_AnimSfx_PlayFloorJump(Player* this) { + Player_PlaySfx(this, Player_GetFloorSfxByAge(this, NA_SE_PL_JUMP_GROUND)); +} + +// ANIMSFX_TYPE_FLOOR_LAND +void Player_AnimSfx_PlayFloorLand(Player* this) { + Player_PlaySfx(this, Player_GetFloorSfxByAge(this, NA_SE_PL_LAND_GROUND)); +} + +void func_8082E1F0(Player* this, u16 sfxId) { + Player_PlaySfx(this, sfxId); + this->stateFlags2 |= PLAYER_STATE2_8; +} + +void Player_PlayAnimSfx(Player* this, AnimSfxEntry* entry) { + s32 cond; + + do { + s32 data = ABS_ALT(entry->flags); + s32 type = ANIMSFX_GET_TYPE(data); + + if (PlayerAnimation_OnFrame(&this->skelAnime, fabsf(ANIMSFX_GET_FRAME(data)))) { + if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_GENERAL)) { + Player_PlaySfx(this, entry->sfxId); + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_FLOOR)) { + Player_AnimSfx_PlayFloor(this, entry->sfxId); + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_FLOOR_BY_AGE)) { + Player_AnimSfx_PlayFloorByAge(this, entry->sfxId); + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_VOICE)) { + Player_AnimSfx_PlayVoice(this, entry->sfxId); + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_FLOOR_LAND)) { + Player_AnimSfx_PlayFloorLand(this); + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_6)) { + Player_AnimSfx_PlayFloorWalk(this, 6.0f); + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_FLOOR_JUMP)) { + Player_AnimSfx_PlayFloorJump(this); + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_8)) { + Player_AnimSfx_PlayFloorWalk(this, 0.0f); + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_9)) { + // Audio_PlaySfx_AtPosForMetalEffectsWithSyncedFreqAndVolume + func_8019F638(&this->actor.projectedPos, this->ageProperties->surfaceSfxIdOffset + NA_SE_PL_WALK_LADDER, + 0.0f); + } else if (type == ANIMSFX_SHIFT_TYPE(ANIMSFX_TYPE_SURFACE)) { + Player_PlaySfx(this, entry->sfxId + this->ageProperties->surfaceSfxIdOffset); + } + } + + cond = entry->flags >= 0; + entry++; + } while (cond); +} + +void func_8082E438(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + PlayerAnimation_Change(play, &this->skelAnime, anim, 3.0f / 3.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, + -6.0f); +} + +void func_8082E4A4(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + PlayerAnimation_Change(play, &this->skelAnime, anim, 2.0f / 3.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, + -6.0f); +} + +void func_8082E514(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + PlayerAnimation_Change(play, &this->skelAnime, anim, 3.0f / 3.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f); +} + +void func_8082E55C(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + PlayerAnimation_Change(play, &this->skelAnime, anim, 2.0f / 3.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -6.0f); +} + +void func_8082E5A8(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + PlayerAnimation_Change(play, &this->skelAnime, anim, 3.0f / 3.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); +} + +void func_8082E5EC(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + PlayerAnimation_Change(play, &this->skelAnime, anim, 2.0f / 3.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f); +} + +void func_8082E634(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + PlayerAnimation_Change(play, &this->skelAnime, anim, 3.0f / 3.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -16.0f); +} + +// Player_AnimationPlayLoopIfCurrentFinished +s32 func_8082E67C(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + Player_AnimationPlayLoop(play, this, anim); + return true; + } else { + return false; + } +} + +void func_8082E6D0(Player* this) { + this->skelAnime.prevTransl = this->skelAnime.baseTransl; + this->skelAnime.prevRot = this->actor.shape.rot.y; +} + +void func_8082E6F8(Player* this) { + func_8082E6D0(this); + this->skelAnime.prevTransl.x *= this->ageProperties->unk_08; + this->skelAnime.prevTransl.y *= this->ageProperties->unk_08; + this->skelAnime.prevTransl.z *= this->ageProperties->unk_08; +} + +void func_8082E784(Player* this) { + this->skelAnime.jointTable[PLAYER_LIMB_WAIST - 1].y = 0; +} + +void func_8082E794(Player* this) { + if (this->skelAnime.moveFlags) { + func_8082DC28(this); + this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1].x = this->skelAnime.baseTransl.x; + this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1].z = this->skelAnime.baseTransl.z; + + if (this->skelAnime.moveFlags & ANIM_FLAG_8) { + if (this->skelAnime.moveFlags & ANIM_FLAG_UPDATE_Y) { + this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1].y = this->skelAnime.prevTransl.y; + } + } else { + this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1].y = this->skelAnime.baseTransl.y; + } + func_8082E6D0(this); + this->skelAnime.moveFlags = 0; + } +} + +void func_8082E820(Player* this, s32 moveFlags) { + Vec3f pos; + + this->skelAnime.moveFlags = moveFlags; + this->skelAnime.prevTransl = this->skelAnime.baseTransl; + SkelAnime_UpdateTranslation(&this->skelAnime, &pos, this->actor.shape.rot.y); + + if (moveFlags & ANIM_FLAG_1) { + pos.x *= this->ageProperties->unk_08; + pos.z *= this->ageProperties->unk_08; + this->actor.world.pos.x += pos.x * this->actor.scale.x; + this->actor.world.pos.z += pos.z * this->actor.scale.z; + } + + if (moveFlags & ANIM_FLAG_UPDATE_Y) { + if (!(moveFlags & ANIM_FLAG_4)) { + pos.y *= this->ageProperties->unk_08; + } + this->actor.world.pos.y += pos.y * this->actor.scale.y; + } + + func_8082DC28(this); +} + +void func_8082E920(PlayState* play, Player* this, s32 moveFlags) { + if (moveFlags & ANIM_FLAG_200) { + func_8082E6F8(this); + } else if ((moveFlags & ANIM_FLAG_100) || this->skelAnime.moveFlags) { + func_8082E6D0(this); + } else { + this->skelAnime.prevTransl = this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1]; + this->skelAnime.prevRot = this->actor.shape.rot.y; + } + + this->skelAnime.moveFlags = moveFlags; + Player_StopHorizontalMovement(this); + AnimationContext_DisableQueue(play); +} + +void func_8082E9C8(PlayState* play, Player* this, PlayerAnimationHeader* anim, s32 moveFlags, f32 playSpeed) { + PlayerAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, playSpeed); + func_8082E920(play, this, moveFlags); +} + +void func_8082EA10(PlayState* play, Player* this, PlayerAnimationHeader* anim, s32 moveFlags) { + func_8082E9C8(play, this, anim, moveFlags, 3.0f / 3.0f); +} + +void func_8082EA38(PlayState* play, Player* this, PlayerAnimationHeader* anim, s32 moveFlags) { + func_8082E9C8(play, this, anim, moveFlags, 2.0f / 3.0f); +} + +void func_8082EA60(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + func_8082EA38(play, this, anim, ANIM_FLAG_4 | ANIM_FLAG_8 | ANIM_FLAG_200); +} + +void func_8082EA80(PlayState* play, Player* this, PlayerAnimationHeader* anim, s32 moveFlags, f32 playSpeed) { + PlayerAnimation_PlayLoopSetSpeed(play, &this->skelAnime, anim, playSpeed); + func_8082E920(play, this, moveFlags); +} + +void func_8082EAC8(PlayState* play, Player* this, PlayerAnimationHeader* anim, s32 moveFlags) { + func_8082EA80(play, this, anim, moveFlags, 3.0f / 3.0f); +} + +void func_8082EAF0(PlayState* play, Player* this, PlayerAnimationHeader* anim, s32 moveFlags) { + func_8082EA80(play, this, anim, moveFlags, 2.0f / 3.0f); +} + +void func_8082EB18(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + func_8082EAF0(play, this, anim, ANIM_FLAG_4 | ANIM_FLAG_8 | ANIM_FLAG_NOMOVE); +} + +void func_8082EB38(PlayState* play, Player* this) { + s8 var_v0; + s8 var_v1; + + this->unk_D60 = D_80862AFC; + this->unk_D64 = D_80862B00; + func_800FF3A0(&D_80862AFC, &D_80862B00, sPlayerControlInput); + + if (D_80862AFC < 8.0f) { + D_80862AFC = 0.0f; + } + + D_80862B02 = Camera_GetInputDirYaw(play->cameraPtrs[play->activeCamId]) + D_80862B00; + this->unk_ADE = (this->unk_ADE + 1) % ARRAY_COUNT(this->unk_ADF); + if (D_80862AFC < 55.0f) { + var_v0 = -1; + var_v1 = -1; + } else { + var_v1 = ((u16)(D_80862B00 + 0x2000)) >> 9; + var_v0 = ((u16)(BINANG_SUB(D_80862B02, this->actor.shape.rot.y) + 0x2000)) >> 14; + } + this->unk_ADF[this->unk_ADE] = var_v1; + this->unk_AE3[this->unk_ADE] = var_v0; +} + +void func_8082EC9C(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + PlayerAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, D_8085C3E4); +} + +s32 func_8082ECCC(Player* this) { + return this->stateFlags1 & PLAYER_STATE1_1000000; +} + +#define CHEST_ANIM_SHORT 0 +#define CHEST_ANIM_LONG 1 + +// TODO: consider what to do with the NONEs: cannot use a zero-argument macro like OoT since the text id is involved. +#define GET_ITEM(itemId, objectId, drawId, textId, field, chestAnim) \ + { itemId, field, (chestAnim != CHEST_ANIM_SHORT ? 1 : -1) * (drawId + 1), textId, objectId } + +#define GIFIELD_GET_DROP_TYPE(field) ((field)&0x1F) +#define GIFIELD_20 (1 << 5) +#define GIFIELD_40 (1 << 6) +#define GIFIELD_NO_COLLECTIBLE (1 << 7) +/** + * `flags` must be 0, GIFIELD_20, GIFIELD_40 or GIFIELD_NO_COLLECTIBLE (which can be or'ed together) + * `dropType` must be either a value from the `Item00Type` enum or 0 if the `GIFIELD_NO_COLLECTIBLE` flag was used + */ +#define GIFIELD(flags, dropType) ((flags) | (dropType)) + +GetItemEntry sGetItemTable[GI_MAX - 1] = { + // GI_RUPEE_GREEN + GET_ITEM(ITEM_RUPEE_GREEN, OBJECT_GI_RUPY, GID_RUPEE_GREEN, 0xC4, GIFIELD(0, ITEM00_RUPEE_GREEN), CHEST_ANIM_SHORT), + // GI_RUPEE_BLUE + GET_ITEM(ITEM_RUPEE_BLUE, OBJECT_GI_RUPY, GID_RUPEE_BLUE, 0x2, GIFIELD(0, ITEM00_RUPEE_BLUE), CHEST_ANIM_SHORT), + // GI_RUPEE_10 + GET_ITEM(ITEM_RUPEE_10, OBJECT_GI_RUPY, GID_RUPEE_RED, 0x3, GIFIELD(0, ITEM00_RUPEE_RED), CHEST_ANIM_SHORT), + // GI_RUPEE_RED + GET_ITEM(ITEM_RUPEE_RED, OBJECT_GI_RUPY, GID_RUPEE_RED, 0x4, GIFIELD(0, ITEM00_RUPEE_RED), CHEST_ANIM_SHORT), + // GI_RUPEE_PURPLE + GET_ITEM(ITEM_RUPEE_PURPLE, OBJECT_GI_RUPY, GID_RUPEE_PURPLE, 0x5, GIFIELD(0, ITEM00_RUPEE_PURPLE), + CHEST_ANIM_SHORT), + // GI_RUPEE_SILVER + GET_ITEM(ITEM_RUPEE_SILVER, OBJECT_GI_RUPY, GID_RUPEE_SILVER, 0x6, GIFIELD(0, ITEM00_RUPEE_PURPLE), + CHEST_ANIM_SHORT), + // GI_RUPEE_HUGE + GET_ITEM(ITEM_RUPEE_HUGE, OBJECT_GI_RUPY, GID_RUPEE_HUGE, 0x7, GIFIELD(0, ITEM00_RUPEE_HUGE), CHEST_ANIM_SHORT), + // GI_WALLET_ADULT + GET_ITEM(ITEM_WALLET_ADULT, OBJECT_GI_PURSE, GID_WALLET_ADULT, 0x8, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_WALLET_GIANT + GET_ITEM(ITEM_WALLET_GIANT, OBJECT_GI_PURSE, GID_WALLET_GIANT, 0x9, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_RECOVERY_HEART + GET_ITEM(ITEM_RECOVERY_HEART, OBJECT_GI_HEART, GID_RECOVERY_HEART, 0xA, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_0B + GET_ITEM(ITEM_RECOVERY_HEART, OBJECT_GI_HEART, GID_RECOVERY_HEART, 0xB, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_HEART_PIECE + GET_ITEM(ITEM_HEART_PIECE_2, OBJECT_GI_HEARTS, GID_HEART_PIECE, 0xC, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_HEART_CONTAINER + GET_ITEM(ITEM_HEART_CONTAINER, OBJECT_GI_HEARTS, GID_HEART_CONTAINER, 0xD, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MAGIC_SMALL + GET_ITEM(ITEM_MAGIC_SMALL, OBJECT_GI_MAGICPOT, GID_MAGIC_SMALL, 0xE, + GIFIELD(GIFIELD_20 | GIFIELD_40, ITEM00_MAGIC_SMALL), CHEST_ANIM_SHORT), + // GI_MAGIC_LARGE + GET_ITEM(ITEM_MAGIC_LARGE, OBJECT_GI_MAGICPOT, GID_MAGIC_LARGE, 0xF, + GIFIELD(GIFIELD_20 | GIFIELD_40, ITEM00_MAGIC_LARGE), CHEST_ANIM_SHORT), + // GI_10 + GET_ITEM(ITEM_RECOVERY_HEART, OBJECT_GI_HEART, GID_RECOVERY_HEART, 0x10, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_STRAY_FAIRY + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x11, 0, 0), + // GI_12 + GET_ITEM(ITEM_RECOVERY_HEART, OBJECT_GI_HEART, GID_RECOVERY_HEART, 0x12, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_13 + GET_ITEM(ITEM_RECOVERY_HEART, OBJECT_GI_HEART, GID_RECOVERY_HEART, 0x13, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_BOMBS_1 + GET_ITEM(ITEM_BOMB, OBJECT_GI_BOMB_1, GID_BOMB, 0x14, GIFIELD(GIFIELD_40, ITEM00_BOMBS_0), CHEST_ANIM_SHORT), + // GI_BOMBS_5 + GET_ITEM(ITEM_BOMBS_5, OBJECT_GI_BOMB_1, GID_BOMB, 0x15, GIFIELD(GIFIELD_40, ITEM00_BOMBS_0), CHEST_ANIM_SHORT), + // GI_BOMBS_10 + GET_ITEM(ITEM_BOMBS_10, OBJECT_GI_BOMB_1, GID_BOMB, 0x16, GIFIELD(GIFIELD_40, ITEM00_BOMBS_0), CHEST_ANIM_SHORT), + // GI_BOMBS_20 + GET_ITEM(ITEM_BOMBS_20, OBJECT_GI_BOMB_1, GID_BOMB, 0x17, GIFIELD(GIFIELD_40, ITEM00_BOMBS_0), CHEST_ANIM_SHORT), + // GI_BOMBS_30 + GET_ITEM(ITEM_BOMBS_30, OBJECT_GI_BOMB_1, GID_BOMB, 0x18, GIFIELD(GIFIELD_40, ITEM00_BOMBS_0), CHEST_ANIM_SHORT), + // GI_STICKS_1 + GET_ITEM(ITEM_STICK, OBJECT_GI_STICK, GID_STICK, 0x19, GIFIELD(0, ITEM00_STICK), CHEST_ANIM_SHORT), + // GI_BOMBCHUS_10 + GET_ITEM(ITEM_BOMBCHUS_10, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x1A, GIFIELD(GIFIELD_40 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_SHORT), + // GI_BOMB_BAG_20 + GET_ITEM(ITEM_BOMB_BAG_20, OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_20, 0x1B, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_BOMB_BAG_30 + GET_ITEM(ITEM_BOMB_BAG_30, OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_30, 0x1C, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_BOMB_BAG_40 + GET_ITEM(ITEM_BOMB_BAG_40, OBJECT_GI_BOMBPOUCH, GID_BOMB_BAG_40, 0x1D, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_ARROWS_10 + GET_ITEM(ITEM_ARROWS_10, OBJECT_GI_ARROW, GID_ARROWS_SMALL, 0x1E, GIFIELD(GIFIELD_40, ITEM00_ARROWS_30), + CHEST_ANIM_SHORT), + // GI_ARROWS_30 + GET_ITEM(ITEM_ARROWS_30, OBJECT_GI_ARROW, GID_ARROWS_MEDIUM, 0x1F, GIFIELD(GIFIELD_40, ITEM00_ARROWS_40), + CHEST_ANIM_SHORT), + // GI_ARROWS_40 + GET_ITEM(ITEM_ARROWS_40, OBJECT_GI_ARROW, GID_ARROWS_LARGE, 0x20, GIFIELD(GIFIELD_40, ITEM00_ARROWS_50), + CHEST_ANIM_SHORT), + // GI_ARROWS_50 + GET_ITEM(ITEM_ARROWS_40, OBJECT_GI_ARROW, GID_ARROWS_LARGE, 0x21, GIFIELD(GIFIELD_40, ITEM00_ARROWS_50), + CHEST_ANIM_SHORT), + // GI_QUIVER_30 + GET_ITEM(ITEM_BOW, OBJECT_GI_BOW, GID_BOW, 0x22, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_QUIVER_40 + GET_ITEM(ITEM_QUIVER_40, OBJECT_GI_ARROWCASE, GID_QUIVER_40, 0x23, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_QUIVER_50 + GET_ITEM(ITEM_QUIVER_50, OBJECT_GI_ARROWCASE, GID_QUIVER_50, 0x24, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_ARROW_FIRE + GET_ITEM(ITEM_ARROW_FIRE, OBJECT_GI_M_ARROW, GID_ARROW_FIRE, 0x25, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_ARROW_ICE + GET_ITEM(ITEM_ARROW_ICE, OBJECT_GI_M_ARROW, GID_ARROW_ICE, 0x26, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_ARROW_LIGHT + GET_ITEM(ITEM_ARROW_LIGHT, OBJECT_GI_M_ARROW, GID_ARROW_LIGHT, 0x27, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_NUTS_1 + GET_ITEM(ITEM_NUT, OBJECT_GI_NUTS, GID_NUTS, 0x28, GIFIELD(0, ITEM00_NUTS_1), CHEST_ANIM_SHORT), + // GI_NUTS_5 + GET_ITEM(ITEM_NUTS_5, OBJECT_GI_NUTS, GID_NUTS, 0x29, GIFIELD(0, ITEM00_NUTS_1), CHEST_ANIM_SHORT), + // GI_NUTS_10 + GET_ITEM(ITEM_NUTS_10, OBJECT_GI_NUTS, GID_NUTS, 0x2A, GIFIELD(0, ITEM00_NUTS_1), CHEST_ANIM_SHORT), + // GI_2B + GET_ITEM(ITEM_NUT_UPGRADE_30, OBJECT_GI_NUTS, GID_NUTS, 0x2B, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_SHORT), + // GI_2C + GET_ITEM(ITEM_NUT_UPGRADE_30, OBJECT_GI_NUTS, GID_NUTS, 0x2C, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_SHORT), + // GI_2D + GET_ITEM(ITEM_NUT_UPGRADE_40, OBJECT_GI_NUTS, GID_NUTS, 0x2D, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_SHORT), + // GI_BOMBCHUS_20 + GET_ITEM(ITEM_BOMBCHUS_20, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x2E, GIFIELD(GIFIELD_40 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_SHORT), + // GI_2F + GET_ITEM(ITEM_STICK_UPGRADE_20, OBJECT_GI_STICK, GID_STICK, 0x2F, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_SHORT), + // GI_30 + GET_ITEM(ITEM_STICK_UPGRADE_20, OBJECT_GI_STICK, GID_STICK, 0x30, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_SHORT), + // GI_31 + GET_ITEM(ITEM_STICK_UPGRADE_30, OBJECT_GI_STICK, GID_STICK, 0x31, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_SHORT), + // GI_SHIELD_HERO + GET_ITEM(ITEM_SHIELD_HERO, OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, 0x32, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_SHORT), + // GI_SHIELD_MIRROR + GET_ITEM(ITEM_SHIELD_MIRROR, OBJECT_GI_SHIELD_3, GID_SHIELD_MIRROR, 0x33, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_POWDER_KEG + GET_ITEM(ITEM_POWDER_KEG, OBJECT_GI_BIGBOMB, GID_POWDER_KEG, 0x34, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MAGIC_BEANS + GET_ITEM(ITEM_MAGIC_BEANS, OBJECT_GI_BEAN, GID_MAGIC_BEANS, 0x35, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_SHORT), + // GI_BOMBCHUS_1 + GET_ITEM(ITEM_BOMBCHUS_1, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x36, GIFIELD(GIFIELD_40 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_SHORT), + // GI_SWORD_KOKIRI + GET_ITEM(ITEM_SWORD_KOKIRI, OBJECT_GI_SWORD_1, GID_SWORD_KOKIRI, 0x37, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_SWORD_RAZOR + GET_ITEM(ITEM_SWORD_RAZOR, OBJECT_GI_SWORD_2, GID_SWORD_RAZOR, 0x38, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_SWORD_GILDED + GET_ITEM(ITEM_SWORD_GILDED, OBJECT_GI_SWORD_3, GID_SWORD_GILDED, 0x39, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_BOMBCHUS_5 + GET_ITEM(ITEM_BOMBCHUS_5, OBJECT_GI_BOMB_2, GID_BOMBCHU, 0x3A, GIFIELD(GIFIELD_40 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_SHORT), + // GI_SWORD_GREAT_FAIRY + GET_ITEM(ITEM_SWORD_GREAT_FAIRY, OBJECT_GI_SWORD_4, GID_SWORD_GREAT_FAIRY, 0x3B, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_KEY_SMALL + GET_ITEM(ITEM_KEY_SMALL, OBJECT_GI_KEY, GID_KEY_SMALL, 0x3C, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_SHORT), + // GI_KEY_BOSS + GET_ITEM(ITEM_KEY_BOSS, OBJECT_GI_BOSSKEY, GID_KEY_BOSS, 0x3D, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MAP + GET_ITEM(ITEM_DUNGEON_MAP, OBJECT_GI_MAP, GID_DUNGEON_MAP, 0x3E, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_COMPASS + GET_ITEM(ITEM_COMPASS, OBJECT_GI_COMPASS, GID_COMPASS, 0x3F, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_40 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x40, 0, 0), + // GI_HOOKSHOT + GET_ITEM(ITEM_HOOKSHOT, OBJECT_GI_HOOKSHOT, GID_HOOKSHOT, 0x41, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_LENS + GET_ITEM(ITEM_LENS, OBJECT_GI_GLASSES, GID_LENS, 0x42, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_PICTO_BOX + GET_ITEM(ITEM_PICTO_BOX, OBJECT_GI_CAMERA, GID_PICTO_BOX, 0x43, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_44 + GET_ITEM(ITEM_PICTO_BOX, OBJECT_UNSET_0, GID_NONE, 0x44, GIFIELD(0, ITEM00_RUPEE_GREEN), 0), + // GI_45 + GET_ITEM(ITEM_RECOVERY_HEART, OBJECT_GI_HEART, GID_RECOVERY_HEART, 0x45, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_46 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x46, 0, 0), + // GI_47 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x47, 0, 0), + // GI_48 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x48, 0, 0), + // GI_49 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x49, 0, 0), + // GI_4A + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x4A, 0, 0), + // GI_4B + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x4B, 0, 0), + // GI_OCARINA + GET_ITEM(ITEM_OCARINA, OBJECT_GI_OCARINA, GID_OCARINA, 0x4C, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_4D + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x4D, 0, 0), + // GI_4E + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x4E, 0, 0), + // GI_4F + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x4F, 0, 0), + // GI_BOMBERS_NOTEBOOK + GET_ITEM(ITEM_BOMBERS_NOTEBOOK, OBJECT_GI_SCHEDULE, GID_BOMBERS_NOTEBOOK, 0x50, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_51 + GET_ITEM(ITEM_NONE, OBJECT_GI_MAP, GID_STONE_OF_AGONY, 0x51, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_SKULL_TOKEN + GET_ITEM(ITEM_SKULL_TOKEN, OBJECT_GI_SUTARU, GID_SKULL_TOKEN, 0x52, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_SHORT), + // GI_53 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x53, 0, 0), + // GI_54 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x54, 0, 0), + // GI_REMAINS_ODOLWA + GET_ITEM(ITEM_REMAINS_ODOLWA, OBJECT_UNSET_0, GID_REMAINS_ODOLWA, 0x55, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_REMAINS_GOHT + GET_ITEM(ITEM_REMAINS_GOHT, OBJECT_UNSET_0, GID_REMAINS_GOHT, 0x56, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_REMAINS_GYORG + GET_ITEM(ITEM_REMAINS_GYORG, OBJECT_UNSET_0, GID_REMAINS_GYORG, 0x57, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_REMAINS_TWINMOLD + GET_ITEM(ITEM_REMAINS_TWINMOLD, OBJECT_UNSET_0, GID_REMAINS_TWINMOLD, 0x58, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_POTION_RED_BOTTLE + GET_ITEM(ITEM_LONGSHOT, OBJECT_GI_BOTTLE_RED, GID_57, GIFIELD(GIFIELD_40, ITEM00_BOMBS_0), + GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_BOTTLE + GET_ITEM(ITEM_BOTTLE, OBJECT_GI_BOTTLE, GID_BOTTLE, 0x5A, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_POTION_RED + GET_ITEM(ITEM_POTION_RED, OBJECT_GI_LIQUID, GID_POTION_RED, 0x5B, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_POTION_GREEN + GET_ITEM(ITEM_POTION_GREEN, OBJECT_GI_LIQUID, GID_POTION_GREEN, 0x5C, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_POTION_BLUE + GET_ITEM(ITEM_POTION_BLUE, OBJECT_GI_LIQUID, GID_POTION_BLUE, 0x5D, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_FAIRY + GET_ITEM(ITEM_FAIRY, OBJECT_GI_BOTTLE_04, GID_FAIRY, 0x5E, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_DEKU_PRINCESS + GET_ITEM(ITEM_FAIRY, OBJECT_GI_BOTTLE, GID_BOTTLE, 0x5F, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MILK_BOTTLE + GET_ITEM(ITEM_MILK_BOTTLE, OBJECT_GI_MILK, GID_MILK, 0x60, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MILK_HALF + GET_ITEM(ITEM_MILK_HALF, OBJECT_GI_MILK, GID_MILK, 0x61, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_FISH + GET_ITEM(ITEM_FISH, OBJECT_GI_FISH, GID_FISH, 0x62, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_BUG + GET_ITEM(ITEM_BUG, OBJECT_GI_INSECT, GID_BUG, 0x63, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_BLUE_FIRE + GET_ITEM(ITEM_BLUE_FIRE, OBJECT_UNSET_0, GID_NONE, 0x64, GIFIELD(0, ITEM00_RUPEE_GREEN), 0), + // GI_POE + GET_ITEM(ITEM_BOTTLE, OBJECT_GI_BOTTLE, GID_BOTTLE, 0x65, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_BIG_POE + GET_ITEM(ITEM_BIG_POE, OBJECT_GI_GHOST, GID_BIG_POE, 0x66, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_SPRING_WATER + GET_ITEM(ITEM_SPRING_WATER, OBJECT_UNSET_0, GID_NONE, 0x67, GIFIELD(0, ITEM00_RUPEE_GREEN), 0), + // GI_HOT_SPRING_WATER + GET_ITEM(ITEM_HOT_SPRING_WATER, OBJECT_UNSET_0, GID_NONE, 0x68, GIFIELD(0, ITEM00_RUPEE_GREEN), 0), + // GI_ZORA_EGG + GET_ITEM(ITEM_ZORA_EGG, OBJECT_GI_BOTTLE_15, GID_ZORA_EGG, 0x69, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_GOLD_DUST + GET_ITEM(ITEM_GOLD_DUST, OBJECT_GI_BOTTLE_16, GID_SEAHORSE, 0x6A, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MUSHROOM + GET_ITEM(ITEM_MUSHROOM, OBJECT_GI_MAGICMUSHROOM, GID_MUSHROOM, 0x6B, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_6C + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x6C, GIFIELD(0, ITEM00_RUPEE_GREEN), 0), + // GI_6D + GET_ITEM(ITEM_BOTTLE, OBJECT_GI_BOTTLE, GID_BOTTLE, 0x6D, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_SEAHORSE + GET_ITEM(ITEM_SEAHORSE, OBJECT_GI_BOTTLE_16, GID_SEAHORSE, 0x6E, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_CHATEAU_BOTTLE + GET_ITEM(ITEM_CHATEAU, OBJECT_GI_BOTTLE_21, GID_CHATEAU, 0x6F, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_HYLIAN_LOACH + GET_ITEM(ITEM_BOTTLE, OBJECT_GI_BOTTLE, GID_BOTTLE, 0x70, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_71 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x71, 0, 0), + // GI_72 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x72, 0, 0), + // GI_73 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x73, 0, 0), + // GI_74 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x74, 0, 0), + // GI_75 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x75, 0, 0), + // GI_ICE_TRAP + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x76, 0, 0), + // GI_77 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x77, 0, 0), + // GI_MASK_DEKU + GET_ITEM(ITEM_MASK_DEKU, OBJECT_GI_NUTSMASK, GID_MASK_DEKU, 0x78, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MASK_GORON + GET_ITEM(ITEM_MASK_GORON, OBJECT_GI_GOLONMASK, GID_MASK_GORON, 0x79, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MASK_ZORA + GET_ITEM(ITEM_MASK_ZORA, OBJECT_GI_ZORAMASK, GID_MASK_ZORA, 0x7A, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MASK_FIERCE_DEITY + GET_ITEM(ITEM_MASK_FIERCE_DEITY, OBJECT_GI_MASK03, GID_MASK_FIERCE_DEITY, 0x7B, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MASK_CAPTAIN + GET_ITEM(ITEM_MASK_CAPTAIN, OBJECT_GI_MASK18, GID_MASK_CAPTAIN, 0x7C, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MASK_GIANT + GET_ITEM(ITEM_MASK_GIANT, OBJECT_GI_MASK23, GID_MASK_GIANT, 0x7D, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MASK_ALL_NIGHT + GET_ITEM(ITEM_MASK_ALL_NIGHT, OBJECT_GI_MASK06, GID_MASK_ALL_NIGHT, 0x7E, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MASK_BUNNY + GET_ITEM(ITEM_MASK_BUNNY, OBJECT_GI_RABIT_MASK, GID_MASK_BUNNY, 0x7F, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MASK_KEATON + GET_ITEM(ITEM_MASK_KEATON, OBJECT_GI_KI_TAN_MASK, GID_MASK_KEATON, 0x80, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MASK_GARO + GET_ITEM(ITEM_MASK_GARO, OBJECT_GI_MASK09, GID_MASK_GARO, 0x81, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MASK_ROMANI + GET_ITEM(ITEM_MASK_ROMANI, OBJECT_GI_MASK10, GID_MASK_ROMANI, 0x82, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MASK_CIRCUS_LEADER + GET_ITEM(ITEM_MASK_CIRCUS_LEADER, OBJECT_GI_MASK11, GID_MASK_CIRCUS_LEADER, 0x83, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MASK_POSTMAN + GET_ITEM(ITEM_MASK_POSTMAN, OBJECT_GI_MASK12, GID_MASK_POSTMAN, 0x84, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MASK_COUPLE + GET_ITEM(ITEM_MASK_COUPLE, OBJECT_GI_MASK13, GID_MASK_COUPLE, 0x85, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MASK_GREAT_FAIRY + GET_ITEM(ITEM_MASK_GREAT_FAIRY, OBJECT_GI_MASK14, GID_MASK_GREAT_FAIRY, 0x86, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MASK_GIBDO + GET_ITEM(ITEM_MASK_GIBDO, OBJECT_GI_MASK15, GID_MASK_GIBDO, 0x87, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MASK_DON_GERO + GET_ITEM(ITEM_MASK_DON_GERO, OBJECT_GI_MASK16, GID_MASK_DON_GERO, 0x88, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MASK_KAMARO + GET_ITEM(ITEM_MASK_KAMARO, OBJECT_GI_MASK17, GID_MASK_KAMARO, 0x89, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MASK_TRUTH + GET_ITEM(ITEM_MASK_TRUTH, OBJECT_GI_TRUTH_MASK, GID_MASK_TRUTH, 0x8A, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MASK_STONE + GET_ITEM(ITEM_MASK_STONE, OBJECT_GI_STONEMASK, GID_MASK_STONE, 0x8B, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_MASK_BREMEN + GET_ITEM(ITEM_MASK_BREMEN, OBJECT_GI_MASK20, GID_MASK_BREMEN, 0x8C, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MASK_BLAST + GET_ITEM(ITEM_MASK_BLAST, OBJECT_GI_MASK21, GID_MASK_BLAST, 0x8D, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MASK_SCENTS + GET_ITEM(ITEM_MASK_SCENTS, OBJECT_GI_MASK22, GID_MASK_SCENTS, 0x8E, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MASK_KAFEIS_MASK + GET_ITEM(ITEM_MASK_KAFEIS_MASK, OBJECT_GI_MASK05, GID_MASK_KAFEIS_MASK, 0x8F, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_90 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0x90, 0, 0), + // GI_CHATEAU + GET_ITEM(ITEM_CHATEAU_2, OBJECT_GI_BOTTLE_21, GID_CHATEAU, 0x91, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MILK + GET_ITEM(ITEM_MILK, OBJECT_GI_MILK, GID_MILK, 0x92, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_GOLD_DUST_2 + GET_ITEM(ITEM_GOLD_DUST_2, OBJECT_GI_GOLD_DUST, GID_GOLD_DUST, 0x93, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_HYLIAN_LOACH_2 + GET_ITEM(ITEM_HYLIAN_LOACH_2, OBJECT_GI_LOACH, GID_HYLIAN_LOACH, 0x94, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_SEAHORSE_CAUGHT + GET_ITEM(ITEM_SEAHORSE_CAUGHT, OBJECT_GI_SEAHORSE, GID_SEAHORSE_CAUGHT, 0x95, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_MOON_TEAR + GET_ITEM(ITEM_MOON_TEAR, OBJECT_GI_RESERVE00, GID_MOON_TEAR, 0x96, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_DEED_LAND + GET_ITEM(ITEM_DEED_LAND, OBJECT_GI_RESERVE01, GID_DEED_LAND, 0x97, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_DEED_SWAMP + GET_ITEM(ITEM_DEED_SWAMP, OBJECT_GI_RESERVE01, GID_DEED_SWAMP, 0x98, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_DEED_MOUNTAIN + GET_ITEM(ITEM_DEED_MOUNTAIN, OBJECT_GI_RESERVE01, GID_DEED_MOUNTAIN, 0x99, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_DEED_OCEAN + GET_ITEM(ITEM_DEED_OCEAN, OBJECT_GI_RESERVE01, GID_DEED_OCEAN, 0x9A, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_SWORD_GREAT_FAIRY_STOLEN + GET_ITEM(ITEM_SWORD_GREAT_FAIRY, OBJECT_GI_SWORD_4, GID_SWORD_GREAT_FAIRY, 0x9B, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_SWORD_KOKIRI_STOLEN + GET_ITEM(ITEM_SWORD_KOKIRI, OBJECT_GI_SWORD_1, GID_SWORD_KOKIRI, 0x9C, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_SWORD_RAZOR_STOLEN + GET_ITEM(ITEM_SWORD_RAZOR, OBJECT_GI_SWORD_2, GID_SWORD_RAZOR, 0x9D, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_SWORD_GILDED_STOLEN + GET_ITEM(ITEM_SWORD_GILDED, OBJECT_GI_SWORD_3, GID_SWORD_GILDED, 0x9E, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_SHIELD_HERO_STOLEN + GET_ITEM(ITEM_SHIELD_HERO, OBJECT_GI_SHIELD_2, GID_SHIELD_HERO, 0x9F, + GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_SHORT), + // GI_ROOM_KEY + GET_ITEM(ITEM_ROOM_KEY, OBJECT_GI_RESERVE_B_00, GID_ROOM_KEY, 0xA0, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_LETTER_TO_MAMA + GET_ITEM(ITEM_LETTER_MAMA, OBJECT_GI_RESERVE_B_01, GID_LETTER_MAMA, 0xA1, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_A2 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0xA2, 0, 0), + // GI_A3 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0xA3, 0, 0), + // GI_A4 + GET_ITEM(ITEM_NONE, OBJECT_GI_KI_TAN_MASK, GID_MASK_KEATON, 0xA4, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_A5 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0xA5, 0, 0), + // GI_A6 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0xA6, 0, 0), + // GI_A7 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0xA7, 0, 0), + // GI_A8 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0xA8, 0, 0), + // GI_BOTTLE_STOLEN + GET_ITEM(ITEM_BOTTLE, OBJECT_GI_BOTTLE, GID_BOTTLE, 0xA9, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_LETTER_TO_KAFEI + GET_ITEM(ITEM_LETTER_TO_KAFEI, OBJECT_GI_RESERVE_C_00, GID_LETTER_TO_KAFEI, 0xAA, + GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_PENDANT_OF_MEMORIES + GET_ITEM(ITEM_PENDANT_OF_MEMORIES, OBJECT_GI_RESERVE_C_01, GID_PENDANT_OF_MEMORIES, 0xAB, + GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_AC + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0xAC, 0, 0), + // GI_AD + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0xAD, 0, 0), + // GI_AE + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0xAE, 0, 0), + // GI_AF + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0xAF, 0, 0), + // GI_B0 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0xB0, 0, 0), + // GI_B1 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0xB1, 0, 0), + // GI_B2 + GET_ITEM(ITEM_NONE, OBJECT_UNSET_0, GID_NONE, 0xB2, 0, 0), + // GI_B3 + GET_ITEM(ITEM_NONE, OBJECT_GI_MSSA, GID_MASK_SUN, 0xB3, GIFIELD(GIFIELD_NO_COLLECTIBLE, 0), CHEST_ANIM_LONG), + // GI_TINGLE_MAP_CLOCK_TOWN + GET_ITEM(ITEM_TINGLE_MAP, OBJECT_GI_FIELDMAP, GID_TINGLE_MAP, 0xB4, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_TINGLE_MAP_WOODFALL + GET_ITEM(ITEM_TINGLE_MAP, OBJECT_GI_FIELDMAP, GID_TINGLE_MAP, 0xB5, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_TINGLE_MAP_SNOWHEAD + GET_ITEM(ITEM_TINGLE_MAP, OBJECT_GI_FIELDMAP, GID_TINGLE_MAP, 0xB6, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_TINGLE_MAP_ROMANI_RANCH + GET_ITEM(ITEM_TINGLE_MAP, OBJECT_GI_FIELDMAP, GID_TINGLE_MAP, 0xB7, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_TINGLE_MAP_GREAT_BAY + GET_ITEM(ITEM_TINGLE_MAP, OBJECT_GI_FIELDMAP, GID_TINGLE_MAP, 0xB8, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), + // GI_TINGLE_MAP_STONE_TOWER + GET_ITEM(ITEM_TINGLE_MAP, OBJECT_GI_FIELDMAP, GID_TINGLE_MAP, 0xB9, GIFIELD(GIFIELD_20 | GIFIELD_NO_COLLECTIBLE, 0), + CHEST_ANIM_LONG), +}; + +// Player_UpdateCurrentGetItemDrawId? +void func_8082ECE0(Player* this) { + GetItemEntry* giEntry = &sGetItemTable[this->getItemId - 1]; + + this->getItemDrawIdPlusOne = ABS_ALT(giEntry->gid); +} + +PlayerAnimationHeader* func_8082ED20(Player* this) { + if ((this->transformation == PLAYER_FORM_ZORA) || (this->actor.id != ACTOR_PLAYER)) { + return &gPlayerAnim_pz_wait; + } + if (this->transformation == PLAYER_FORM_GORON) { + return &gPlayerAnim_pg_wait; + } + if (this->currentMask == PLAYER_MASK_SCENTS) { + return &gPlayerAnim_cl_msbowait; + } + return D_8085BE84[PLAYER_ANIMGROUP_0][this->modelAnimType]; +} + +PlayerAnimationHeader* sPlayerIdleAnimations[][2] = { + { &gPlayerAnim_link_normal_wait_typeA_20f, &gPlayerAnim_link_normal_waitF_typeA_20f }, // ROOM_BEHAVIOR_TYPE2_0 + { &gPlayerAnim_link_normal_wait_typeC_20f, &gPlayerAnim_link_normal_waitF_typeC_20f }, // ROOM_BEHAVIOR_TYPE2_1 + { &gPlayerAnim_link_normal_wait_typeB_20f, &gPlayerAnim_link_normal_waitF_typeB_20f }, // ROOM_BEHAVIOR_TYPE2_2 + { &gPlayerAnim_link_normal_wait_typeB_20f, &gPlayerAnim_link_normal_waitF_typeB_20f }, // ROOM_BEHAVIOR_TYPE2_HOT + { &gPlayerAnim_link_wait_typeD_20f, &gPlayerAnim_link_waitF_typeD_20f }, // ROOM_BEHAVIOR_TYPE2_4 + { &gPlayerAnim_link_wait_typeD_20f, &gPlayerAnim_link_waitF_typeD_20f }, // ROOM_BEHAVIOR_TYPE2_5 + { &gPlayerAnim_link_wait_typeD_20f, &gPlayerAnim_link_waitF_typeD_20f }, // ROOM_BEHAVIOR_TYPE2_6 + { &gPlayerAnim_link_wait_heat1_20f, &gPlayerAnim_link_waitF_heat1_20f }, + { &gPlayerAnim_link_wait_heat2_20f, &gPlayerAnim_link_waitF_heat2_20f }, + { &gPlayerAnim_link_wait_itemD1_20f, &gPlayerAnim_link_wait_itemD1_20f }, + { &gPlayerAnim_link_wait_itemA_20f, &gPlayerAnim_link_waitF_itemA_20f }, + { &gPlayerAnim_link_wait_itemB_20f, &gPlayerAnim_link_waitF_itemB_20f }, + { &gPlayerAnim_link_wait_itemC_20f, &gPlayerAnim_link_wait_itemC_20f }, + { &gPlayerAnim_link_wait_itemD2_20f, &gPlayerAnim_link_wait_itemD2_20f }, + { &gPlayerAnim_cl_msbowait, &gPlayerAnim_cl_msbowait }, +}; + +AnimSfxEntry D_8085C8C4[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 8, NA_SE_VO_LI_SNEEZE, STOP), +}; +AnimSfxEntry D_8085C8C8[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 18, NA_SE_VO_LI_SWEAT, STOP), +}; +AnimSfxEntry D_8085C8CC[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 13, NA_SE_VO_LI_BREATH_REST, STOP), +}; +AnimSfxEntry D_8085C8D0[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 10, NA_SE_VO_LI_BREATH_REST, STOP), +}; + +AnimSfxEntry D_8085C8D4[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 44, NA_SE_PL_CALM_HIT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 48, NA_SE_PL_CALM_HIT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 52, NA_SE_PL_CALM_HIT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 56, NA_SE_PL_CALM_HIT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 60, NA_SE_PL_CALM_HIT, STOP), +}; + +AnimSfxEntry D_8085C8E8[] = { + ANIMSFX(ANIMSFX_TYPE_8, 25, NA_SE_NONE, CONTINUE), ANIMSFX(ANIMSFX_TYPE_8, 30, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_8, 44, NA_SE_NONE, CONTINUE), ANIMSFX(ANIMSFX_TYPE_8, 48, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_8, 52, NA_SE_NONE, CONTINUE), ANIMSFX(ANIMSFX_TYPE_8, 56, NA_SE_NONE, STOP), +}; + +AnimSfxEntry D_8085C900[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 16, NA_SE_IT_SHIELD_SWING, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 20, NA_SE_IT_SHIELD_SWING, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 70, NA_SE_IT_SHIELD_SWING, STOP), +}; + +AnimSfxEntry D_8085C90C[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 10, NA_SE_IT_HAMMER_SWING, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_VOICE, 10, NA_SE_VO_LI_AUTO_JUMP, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 22, NA_SE_IT_SWORD_SWING, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_VOICE, 22, NA_SE_VO_LI_SWORD_N, STOP), +}; + +AnimSfxEntry D_8085C91C[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 39, NA_SE_IT_SWORD_SWING, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_VOICE, 39, NA_SE_VO_LI_SWORD_N, STOP), +}; +AnimSfxEntry D_8085C924[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 20, NA_SE_VO_LI_RELAX, STOP), +}; + +AnimSfxEntry D_8085C928[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 4, NA_SE_VO_LI_POO_WAIT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 12, NA_SE_VO_LI_POO_WAIT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 30, NA_SE_VO_LI_POO_WAIT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 61, NA_SE_VO_LI_POO_WAIT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 68, NA_SE_VO_LI_POO_WAIT, STOP), +}; + +AnimSfxEntry* D_8085C93C[] = { + D_8085C8C4, D_8085C8C8, D_8085C8CC, D_8085C8D0, D_8085C8D4, D_8085C8E8, + D_8085C900, D_8085C90C, D_8085C91C, D_8085C924, D_8085C928, NULL, +}; + +// Used to index into D_8085C93C +u8 D_8085C96C[] = { + 0, 0, 1, 1, 2, 2, 2, 2, 10, 10, 10, 10, 10, 10, 3, 3, 4, 4, 8, 8, 5, 5, 6, 6, 7, 7, 9, 9, 11, 11, +}; + +s32 func_8082ED94(Player* this) { + PlayerAnimationHeader** entry; + s32 i; + + if ((this->skelAnime.animation != &gPlayerAnim_link_normal_newroll_jump_end_20f) && + (this->skelAnime.animation != &gPlayerAnim_link_normal_newside_jump_end_20f)) { + if ((this->skelAnime.animation != func_8082ED20(this)) || + (this->skelAnime.animation == &gPlayerAnim_cl_msbowait)) { + for (i = 0, entry = &sPlayerIdleAnimations[0][0]; i < ARRAY_COUNT_2D(sPlayerIdleAnimations); i++) { + if (this->skelAnime.animation == *entry) { + return i + 1; + } + entry++; + } + + return 0; + } + } + + return -1; +} + +void func_8082EEA4(Player* this, s32 arg1) { + u8 temp_v0 = D_8085C96C[arg1]; + + if (temp_v0 != 0) { + Player_PlayAnimSfx(this, D_8085C93C[temp_v0 - 1]); + } +} + +PlayerAnimationHeader* func_8082EEE0(Player* this) { + if (this->unk_B64 != 0) { + return D_8085BE84[PLAYER_ANIMGROUP_3][this->modelAnimType]; + } else { + return D_8085BE84[PLAYER_ANIMGROUP_2][this->modelAnimType]; + } +} + +s32 func_8082EF20(Player* this) { + return func_8082ECCC(this) && (this->unk_ACC != 0); +} + +PlayerAnimationHeader* func_8082EF54(Player* this) { + if (func_8082EF20(this)) { + return &gPlayerAnim_link_boom_throw_waitR; + } else { + return D_8085BE84[PLAYER_ANIMGROUP_5][this->modelAnimType]; + } +} + +PlayerAnimationHeader* func_8082EF9C(Player* this) { + if (func_8082EF20(this)) { + return &gPlayerAnim_link_boom_throw_waitL; + } else { + return D_8085BE84[PLAYER_ANIMGROUP_4][this->modelAnimType]; + } +} + +PlayerAnimationHeader* func_8082EFE4(Player* this) { + if (func_800B7128(this)) { + return &gPlayerAnim_link_bow_side_walk; + } else { + return D_8085BE84[PLAYER_ANIMGROUP_22][this->modelAnimType]; + } +} + +void func_8082F02C(PlayState* play, struct_8082F02C_arg1* arg1, f32 arg2) { + func_800FD59C(play, &arg1->unk_0, arg2); + func_800FD5E0(play, &arg1->unk_3, arg2); + func_800FD654(play, &arg1->unk_6, arg2); + func_800FD698(play, arg1->unk_A, arg1->unk_C, arg2); +} + +/** + * Revert cylinder to normal properties + */ +void Player_ResetCylinder(Player* this) { + this->cylinder.base.colType = COLTYPE_HIT5; + this->cylinder.base.atFlags = AT_NONE; + this->cylinder.base.acFlags = AC_ON | AC_TYPE_ENEMY; + this->cylinder.base.ocFlags1 = OC1_ON | OC1_TYPE_ALL; + this->cylinder.info.elemType = ELEMTYPE_UNK1; + this->cylinder.info.toucher.dmgFlags = 0; + this->cylinder.info.bumper.dmgFlags = 0xF7CFFFFF; + this->cylinder.info.toucherFlags = TOUCH_NONE | TOUCH_SFX_NORMAL; + this->cylinder.dim.radius = 12; +} + +/** + * Give cylinder special properties for attacks, uses include + * - Normal roll + * - Deku spin + * - Deku launch + * - Goron pound + * - Goron spike roll + * - Zora barrier + * + * and possibly more. + * + * @param dmgFlags Damage flags (DMGFLAG defines) + * @param damage to do + * @param radius of cylinder + */ +void Player_SetCylinderForAttack(Player* this, u32 dmgFlags, s32 damage, s32 radius) { + this->cylinder.base.atFlags = AT_ON | AT_TYPE_PLAYER; + if (radius > 30) { + this->cylinder.base.ocFlags1 = OC1_NONE; + } else { + this->cylinder.base.ocFlags1 = OC1_ON | OC1_TYPE_ALL; + } + + this->cylinder.info.elemType = ELEMTYPE_UNK2; + this->cylinder.info.toucherFlags = TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_NORMAL; + this->cylinder.dim.radius = radius; + this->cylinder.info.toucher.dmgFlags = dmgFlags; + this->cylinder.info.toucher.damage = damage; + + if (dmgFlags & DMG_GORON_POUND) { + this->cylinder.base.acFlags = AC_NONE; + } else { + this->cylinder.base.colType = COLTYPE_NONE; + this->cylinder.info.bumper.dmgFlags = 0xF7CFFFFF; + + if (dmgFlags & DMG_ZORA_BARRIER) { + this->cylinder.base.acFlags = AC_NONE; + } else { + this->cylinder.base.acFlags = AC_ON | AC_TYPE_ENEMY; + } + } +} + +// Check for starting Zora barrier +void func_8082F164(Player* this, u16 button) { + if ((this->transformation == PLAYER_FORM_ZORA) && CHECK_BTN_ALL(sPlayerControlInput->cur.button, button)) { + this->stateFlags1 |= PLAYER_STATE1_10; + } +} + +struct_8082F02C_arg1 D_8085C98C = { + { 0, 0, 0 }, { 255, 255, 155 }, { 20, 20, 50 }, 940, 5000, +}; + +// Run Zora Barrier +void func_8082F1AC(PlayState* play, Player* this) { + s32 sp4C = this->unk_B62; + f32 temp; + s16 sp46; + s16 sp44; + f32 sp40; + f32 sp3C; + s32 var_v0; + + if ((gSaveContext.save.saveInfo.playerData.magic != 0) && (this->stateFlags1 & PLAYER_STATE1_10)) { + if (gSaveContext.magicState == MAGIC_STATE_IDLE) { + Magic_Consume(play, 0, MAGIC_CONSUME_GORON_ZORA); + } + + temp = 16.0f; + if (gSaveContext.save.saveInfo.playerData.magic >= 16) { + var_v0 = 255; + } else { + var_v0 = (gSaveContext.save.saveInfo.playerData.magic / temp) * 255.0f; + } + Math_StepToS(&this->unk_B62, var_v0, 50); + } else if (Math_StepToS(&this->unk_B62, 0, 50) && (gSaveContext.magicState != MAGIC_STATE_IDLE)) { + Magic_Reset(play); + } + + if ((this->unk_B62 != 0) || (sp4C != 0)) { + f32 sp34; + f32 new_var; + + sp46 = play->gameplayFrames * 7000; + sp44 = play->gameplayFrames * 14000; + func_8082F02C(play, &D_8085C98C, this->unk_B62 / 255.0f); + + sp34 = Math_SinS(sp44) * 40.0f; + sp40 = Math_CosS(sp44) * 40.0f; + sp3C = Math_SinS(sp46) * sp34; + new_var = Math_CosS(sp46) * sp34; + + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x + sp40, this->actor.world.pos.y + sp3C, + this->actor.world.pos.z + new_var, 100, 200, 255, 600); + + Player_PlaySfx(this, NA_SE_PL_ZORA_SPARK_BARRIER - SFX_FLAG); + Actor_SetPlayerImpact(play, PLAYER_IMPACT_ZORA_BARRIER, 2, 100.0f, &this->actor.world.pos); + } +} + +void func_8082F43C(PlayState* play, Player* this, PlayerFuncAC4 arg2) { + this->unk_AC4 = arg2; + this->unk_ACE = 0; + this->unk_AC8 = 0.0f; + func_8082E00C(this); +} + +#define GET_PLAYER_ANIM(group, type) ((PlayerAnimationHeader**)D_8085BE84)[group * PLAYER_ANIMTYPE_MAX + type] + +void func_8082F470(PlayState* play, Player* this, PlayerItemAction itemAction) { + PlayerAnimationHeader* curAnim = this->skelAnime.animation; + PlayerAnimationHeader*(*iter)[PLAYER_ANIMTYPE_MAX] = (void*)&D_8085BE84[0][this->modelAnimType]; + s32 i; + + this->stateFlags1 &= ~(PLAYER_STATE1_8 | PLAYER_STATE1_1000000); + + for (i = 0; i < PLAYER_ANIMGROUP_MAX; i++) { + if (curAnim == **iter) { + break; + } + iter++; + } + + func_8082F8BC(play, this, itemAction); + + if (i < PLAYER_ANIMGROUP_MAX) { + this->skelAnime.animation = GET_PLAYER_ANIM(i, this->modelAnimType); + } +} + +s8 sItemItemActions[] = { + PLAYER_IA_OCARINA, // ITEM_OCARINA, + PLAYER_IA_BOW, // ITEM_BOW, + PLAYER_IA_BOW_FIRE, // ITEM_ARROW_FIRE, + PLAYER_IA_BOW_ICE, // ITEM_ARROW_ICE, + PLAYER_IA_BOW_LIGHT, // ITEM_ARROW_LIGHT, + PLAYER_IA_PICTO_BOX, // ITEM_OCARINA_FAIRY, + PLAYER_IA_BOMB, // ITEM_BOMB, + PLAYER_IA_BOMBCHU, // ITEM_BOMBCHU, + PLAYER_IA_STICK, // ITEM_STICK, + PLAYER_IA_NUT, // ITEM_NUT, + PLAYER_IA_MAGIC_BEANS, // ITEM_MAGIC_BEANS, + PLAYER_IA_PICTO_BOX, // ITEM_SLINGSHOT, + PLAYER_IA_POWDER_KEG, // ITEM_POWDER_KEG, + PLAYER_IA_PICTO_BOX, // ITEM_PICTO_BOX, + PLAYER_IA_LENS, // ITEM_LENS, + PLAYER_IA_HOOKSHOT, // ITEM_HOOKSHOT, + PLAYER_IA_SWORD_TWO_HANDED, // ITEM_SWORD_GREAT_FAIRY, + PLAYER_IA_PICTO_BOX, // ITEM_LONGSHOT, // OoT Leftover + PLAYER_IA_BOTTLE_EMPTY, // ITEM_BOTTLE, + PLAYER_IA_BOTTLE_POTION_RED, // ITEM_POTION_RED, + PLAYER_IA_BOTTLE_POTION_GREEN, // ITEM_POTION_GREEN, + PLAYER_IA_BOTTLE_POTION_BLUE, // ITEM_POTION_BLUE, + PLAYER_IA_BOTTLE_FAIRY, // ITEM_FAIRY, + PLAYER_IA_BOTTLE_DEKU_PRINCESS, // ITEM_DEKU_PRINCESS, + PLAYER_IA_BOTTLE_MILK, // ITEM_MILK_BOTTLE, + PLAYER_IA_BOTTLE_MILK_HALF, // ITEM_MILK_HALF, + PLAYER_IA_BOTTLE_FISH, // ITEM_FISH, + PLAYER_IA_BOTTLE_BUG, // ITEM_BUG, + PLAYER_IA_BOTTLE_BUG, // ITEM_BLUE_FIRE, // ! + PLAYER_IA_BOTTLE_POE, // ITEM_POE, + PLAYER_IA_BOTTLE_BIG_POE, // ITEM_BIG_POE, + PLAYER_IA_BOTTLE_SPRING_WATER, // ITEM_SPRING_WATER, + PLAYER_IA_BOTTLE_HOT_SPRING_WATER, // ITEM_HOT_SPRING_WATER, + PLAYER_IA_BOTTLE_ZORA_EGG, // ITEM_ZORA_EGG, + PLAYER_IA_BOTTLE_GOLD_DUST, // ITEM_GOLD_DUST, + PLAYER_IA_BOTTLE_MUSHROOM, // ITEM_MUSHROOM, + PLAYER_IA_BOTTLE_SEAHORSE, // ITEM_SEA_HORSE, + PLAYER_IA_BOTTLE_CHATEAU, // ITEM_CHATEAU, + PLAYER_IA_BOTTLE_HYLIAN_LOACH, // ITEM_HYLIAN_LOACH, + PLAYER_IA_BOTTLE_POE, // ITEM_OBABA_DRINK, // ! + PLAYER_IA_MOON_TEAR, // ITEM_MOON_TEAR, + PLAYER_IA_DEED_LAND, // ITEM_DEED_LAND, + PLAYER_IA_DEED_SWAMP, // ITEM_DEED_SWAMP, + PLAYER_IA_DEED_MOUNTAIN, // ITEM_DEED_MOUNTAIN, + PLAYER_IA_DEED_OCEAN, // ITEM_DEED_OCEAN, + PLAYER_IA_ROOM_KEY, // ITEM_ROOM_KEY, + PLAYER_IA_LETTER_MAMA, // ITEM_LETTER_MAMA, + PLAYER_IA_LETTER_TO_KAFEI, // ITEM_LETTER_TO_KAFEI, + PLAYER_IA_PENDANT_OF_MEMORIES, // ITEM_PENDANT_MEMORIES, + PLAYER_IA_38, // ITEM_TINGLE_MAP, // ! + PLAYER_IA_MASK_DEKU, // ITEM_MASK_DEKU, + PLAYER_IA_MASK_GORON, // ITEM_MASK_GORON, + PLAYER_IA_MASK_ZORA, // ITEM_MASK_ZORA, + PLAYER_IA_MASK_FIERCE_DEITY, // ITEM_MASK_FIERCE_DEITY, + PLAYER_IA_MASK_TRUTH, // ITEM_MASK_TRUTH, + PLAYER_IA_MASK_KAFEIS_MASK, // ITEM_MASK_KAFEIS_MASK, + PLAYER_IA_MASK_ALL_NIGHT, // ITEM_MASK_ALL_NIGHT, + PLAYER_IA_MASK_BUNNY, // ITEM_MASK_BUNNY, + PLAYER_IA_MASK_KEATON, // ITEM_MASK_KEATON, + PLAYER_IA_MASK_GARO, // ITEM_MASK_GARO, + PLAYER_IA_MASK_ROMANI, // ITEM_MASK_ROMANI, + PLAYER_IA_MASK_CIRCUS_LEADER, // ITEM_MASK_CIRCUS_LEADER, + PLAYER_IA_MASK_POSTMAN, // ITEM_MASK_POSTMAN, + PLAYER_IA_MASK_COUPLE, // ITEM_MASK_COUPLE, + PLAYER_IA_MASK_GREAT_FAIRY, // ITEM_MASK_GREAT_FAIRY, + PLAYER_IA_MASK_GIBDO, // ITEM_MASK_GIBDO, + PLAYER_IA_MASK_DON_GERO, // ITEM_MASK_DON_GERO, + PLAYER_IA_MASK_KAMARO, // ITEM_MASK_KAMARO, + PLAYER_IA_MASK_CAPTAIN, // ITEM_MASK_CAPTAIN, + PLAYER_IA_MASK_STONE, // ITEM_MASK_STONE, + PLAYER_IA_MASK_BREMEN, // ITEM_MASK_BREMEN, + PLAYER_IA_MASK_BLAST, // ITEM_MASK_BLAST, + PLAYER_IA_MASK_SCENTS, // ITEM_MASK_SCENTS, + PLAYER_IA_MASK_GIANT, // ITEM_MASK_GIANT, + PLAYER_IA_BOW_FIRE, // ITEM_BOW_ARROW_FIRE, + PLAYER_IA_BOW_ICE, // ITEM_BOW_ARROW_ICE, + PLAYER_IA_BOW_LIGHT, // ITEM_BOW_ARROW_LIGHT, + PLAYER_IA_SWORD_KOKIRI, // ITEM_SWORD_KOKIRI, + PLAYER_IA_SWORD_RAZOR, // ITEM_SWORD_RAZOR, + PLAYER_IA_SWORD_GILDED, // ITEM_SWORD_GILDED, + PLAYER_IA_SWORD_TWO_HANDED, // ITEM_SWORD_DEITY, +}; + +PlayerItemAction Player_ItemToItemAction(Player* this, ItemId item) { + if (item >= ITEM_FD) { + return PLAYER_IA_NONE; + } else if (item == ITEM_FC) { + return PLAYER_IA_LAST_USED; + } else if (item == ITEM_FISHING_ROD) { + return PLAYER_IA_FISHING_ROD; + } else if ((item == ITEM_SWORD_KOKIRI) && (this->transformation == PLAYER_FORM_ZORA)) { + return PLAYER_IA_ZORA_FINS; + } else { + return sItemItemActions[item]; + } +} + +void func_8082F594(PlayState* play, Player* this) { +} + +void func_8082F5A4(PlayState* play, Player* this) { + this->unk_B28 = 0; + this->unk_B0C = 1.0f; +} + +void func_8082F5C0(PlayState* play, Player* this) { + this->stateFlags1 |= PLAYER_STATE1_8; + + if (this->heldItemAction == PLAYER_IA_NUT) { + this->unk_B28 = -2; + } else { + this->unk_B28 = -1; + } + this->unk_ACC = 0; +} + +PlayerFuncAC4 D_8085C9F0[PLAYER_IA_MAX] = { + func_80848780, // PLAYER_IA_NONE + func_80848780, // PLAYER_IA_LAST_USED + func_80848780, // PLAYER_IA_FISHING_ROD + func_808487B8, // PLAYER_IA_SWORD_KOKIRI + func_808487B8, // PLAYER_IA_SWORD_RAZOR + func_808487B8, // PLAYER_IA_SWORD_GILDED + func_808487B8, // PLAYER_IA_SWORD_TWO_HANDED + func_80848780, // PLAYER_IA_STICK + func_80848780, // PLAYER_IA_ZORA_FINS + func_80848B6C, // PLAYER_IA_BOW + func_80848B6C, // PLAYER_IA_BOW_FIRE + func_80848B6C, // PLAYER_IA_BOW_ICE + func_80848B6C, // PLAYER_IA_BOW_LIGHT + func_80848B6C, // PLAYER_IA_HOOKSHOT + func_808490B4, // PLAYER_IA_BOMB + func_808490B4, // PLAYER_IA_POWDER_KEG + func_808490B4, // PLAYER_IA_BOMBCHU + func_808491B4, // PLAYER_IA_11 + func_80848B6C, // PLAYER_IA_NUT + func_80848780, // PLAYER_IA_PICTO_BOX + func_80848780, // PLAYER_IA_OCARINA + func_80848780, // PLAYER_IA_BOTTLE_EMPTY + func_80848780, // PLAYER_IA_BOTTLE_FISH + func_80848780, // PLAYER_IA_BOTTLE_SPRING_WATER + func_80848780, // PLAYER_IA_BOTTLE_HOT_SPRING_WATER + func_80848780, // PLAYER_IA_BOTTLE_ZORA_EGG + func_80848780, // PLAYER_IA_BOTTLE_DEKU_PRINCESS + func_80848780, // PLAYER_IA_BOTTLE_GOLD_DUST + func_80848780, // PLAYER_IA_BOTTLE_1C + func_80848780, // PLAYER_IA_BOTTLE_SEA_HORSE + func_80848780, // PLAYER_IA_BOTTLE_MUSHROOM + func_80848780, // PLAYER_IA_BOTTLE_HYLIAN_LOACH + func_80848780, // PLAYER_IA_BOTTLE_BUG + func_80848780, // PLAYER_IA_BOTTLE_POE + func_80848780, // PLAYER_IA_BOTTLE_BIG_POE + func_80848780, // PLAYER_IA_BOTTLE_POTION_RED + func_80848780, // PLAYER_IA_BOTTLE_POTION_BLUE + func_80848780, // PLAYER_IA_BOTTLE_POTION_GREEN + func_80848780, // PLAYER_IA_BOTTLE_MILK + func_80848780, // PLAYER_IA_BOTTLE_MILK_HALF + func_80848780, // PLAYER_IA_BOTTLE_CHATEAU + func_80848780, // PLAYER_IA_BOTTLE_FAIRY + func_80848780, // PLAYER_IA_MOON_TEAR + func_80848780, // PLAYER_IA_DEED_LAND + func_80848780, // PLAYER_IA_ROOM_KEY + func_80848780, // PLAYER_IA_LETTER_TO_KAFEI + func_80848780, // PLAYER_IA_MAGIC_BEANS + func_80848780, // PLAYER_IA_DEED_SWAMP + func_80848780, // PLAYER_IA_DEED_MOUNTAIN + func_80848780, // PLAYER_IA_DEED_OCEAN + func_80848780, // PLAYER_IA_32 + func_80848780, // PLAYER_IA_LETTER_MAMA + func_80848780, // PLAYER_IA_34 + func_80848780, // PLAYER_IA_35 + func_80848780, // PLAYER_IA_PENDANT_MEMORIES + func_80848780, // PLAYER_IA_37 + func_80848780, // PLAYER_IA_38 + func_80848780, // PLAYER_IA_39 + func_80848780, // PLAYER_IA_MASK_TRUTH + func_80848780, // PLAYER_IA_MASK_KAFEIS_MASK + func_80848780, // PLAYER_IA_MASK_ALL_NIGHT + func_80848780, // PLAYER_IA_MASK_BUNNY + func_80848780, // PLAYER_IA_MASK_KEATON + func_80848780, // PLAYER_IA_MASK_GARO + func_80848780, // PLAYER_IA_MASK_ROMANI + func_80848780, // PLAYER_IA_MASK_CIRCUS_LEADER + func_80848780, // PLAYER_IA_MASK_POSTMAN + func_80848780, // PLAYER_IA_MASK_COUPLE + func_80848780, // PLAYER_IA_MASK_GREAT_FAIRY + func_80848780, // PLAYER_IA_MASK_GIBDO + func_80848780, // PLAYER_IA_MASK_DON_GERO + func_80848780, // PLAYER_IA_MASK_KAMARO + func_80848780, // PLAYER_IA_MASK_CAPTAIN + func_80848780, // PLAYER_IA_MASK_STONE + func_80848780, // PLAYER_IA_MASK_BREMEN + func_80848780, // PLAYER_IA_MASK_BLAST + func_80848780, // PLAYER_IA_MASK_SCENTS + func_80848780, // PLAYER_IA_MASK_GIANT + func_80848780, // PLAYER_IA_MASK_FIERCE_DEITY + func_80848780, // PLAYER_IA_MASK_GORON + func_80848780, // PLAYER_IA_MASK_ZORA + func_80848780, // PLAYER_IA_MASK_DEKU + func_80848780, // PLAYER_IA_LENS +}; + +// sPlayerItemActionInits? +void (*D_8085CB3C[PLAYER_IA_MAX])(PlayState*, Player*) = { + func_8082F594, // PLAYER_IA_NONE + func_8082F594, // PLAYER_IA_LAST_USED + func_8082F594, // PLAYER_IA_FISHING_ROD + func_8082F594, // PLAYER_IA_SWORD_KOKIRI + func_8082F594, // PLAYER_IA_SWORD_RAZOR + func_8082F594, // PLAYER_IA_SWORD_GILDED + func_8082F594, // PLAYER_IA_SWORD_TWO_HANDED + func_8082F5A4, // PLAYER_IA_STICK + func_8082F8A0, // PLAYER_IA_ZORA_FINS + func_8082F5C0, // PLAYER_IA_BOW + func_8082F5C0, // PLAYER_IA_BOW_FIRE + func_8082F5C0, // PLAYER_IA_BOW_ICE + func_8082F5C0, // PLAYER_IA_BOW_LIGHT + func_8082F7F4, // PLAYER_IA_HOOKSHOT + Player_SpawnExplosive, // PLAYER_IA_BOMB + Player_SpawnExplosive, // PLAYER_IA_POWDER_KEG + Player_SpawnExplosive, // PLAYER_IA_BOMBCHU + func_8082F8A0, // PLAYER_IA_11 + func_8082F5C0, // PLAYER_IA_NUT + func_8082F594, // PLAYER_IA_PICTO_BOX + func_8082F594, // PLAYER_IA_OCARINA + func_8082F594, // PLAYER_IA_BOTTLE_EMPTY + func_8082F594, // PLAYER_IA_BOTTLE_FISH + func_8082F594, // PLAYER_IA_BOTTLE_SPRING_WATER + func_8082F594, // PLAYER_IA_BOTTLE_HOT_SPRING_WATER + func_8082F594, // PLAYER_IA_BOTTLE_ZORA_EGG + func_8082F594, // PLAYER_IA_BOTTLE_DEKU_PRINCESS + func_8082F594, // PLAYER_IA_BOTTLE_GOLD_DUST + func_8082F594, // PLAYER_IA_BOTTLE_1C + func_8082F594, // PLAYER_IA_BOTTLE_SEA_HORSE + func_8082F594, // PLAYER_IA_BOTTLE_MUSHROOM + func_8082F594, // PLAYER_IA_BOTTLE_HYLIAN_LOACH + func_8082F594, // PLAYER_IA_BOTTLE_BUG + func_8082F594, // PLAYER_IA_BOTTLE_POE + func_8082F594, // PLAYER_IA_BOTTLE_BIG_POE + func_8082F594, // PLAYER_IA_BOTTLE_POTION_RED + func_8082F594, // PLAYER_IA_BOTTLE_POTION_BLUE + func_8082F594, // PLAYER_IA_BOTTLE_POTION_GREEN + func_8082F594, // PLAYER_IA_BOTTLE_MILK + func_8082F594, // PLAYER_IA_BOTTLE_MILK_HALF + func_8082F594, // PLAYER_IA_BOTTLE_CHATEAU + func_8082F594, // PLAYER_IA_BOTTLE_FAIRY + func_8082F594, // PLAYER_IA_MOON_TEAR + func_8082F594, // PLAYER_IA_DEED_LAND + func_8082F594, // PLAYER_IA_ROOM_KEY + func_8082F594, // PLAYER_IA_LETTER_TO_KAFEI + func_8082F594, // PLAYER_IA_MAGIC_BEANS + func_8082F594, // PLAYER_IA_DEED_SWAMP + func_8082F594, // PLAYER_IA_DEED_MOUNTAIN + func_8082F594, // PLAYER_IA_DEED_OCEAN + func_8082F594, // PLAYER_IA_32 + func_8082F594, // PLAYER_IA_LETTER_MAMA + func_8082F594, // PLAYER_IA_34 + func_8082F594, // PLAYER_IA_35 + func_8082F594, // PLAYER_IA_PENDANT_MEMORIES + func_8082F594, // PLAYER_IA_37 + func_8082F594, // PLAYER_IA_38 + func_8082F594, // PLAYER_IA_39 + func_8082F594, // PLAYER_IA_MASK_TRUTH + func_8082F594, // PLAYER_IA_MASK_KAFEIS_MASK + func_8082F594, // PLAYER_IA_MASK_ALL_NIGHT + func_8082F594, // PLAYER_IA_MASK_BUNNY + func_8082F594, // PLAYER_IA_MASK_KEATON + func_8082F594, // PLAYER_IA_MASK_GARO + func_8082F594, // PLAYER_IA_MASK_ROMANI + func_8082F594, // PLAYER_IA_MASK_CIRCUS_LEADER + func_8082F594, // PLAYER_IA_MASK_POSTMAN + func_8082F594, // PLAYER_IA_MASK_COUPLE + func_8082F594, // PLAYER_IA_MASK_GREAT_FAIRY + func_8082F594, // PLAYER_IA_MASK_GIBDO + func_8082F594, // PLAYER_IA_MASK_DON_GERO + func_8082F594, // PLAYER_IA_MASK_KAMARO + func_8082F594, // PLAYER_IA_MASK_CAPTAIN + func_8082F594, // PLAYER_IA_MASK_STONE + func_8082F594, // PLAYER_IA_MASK_BREMEN + func_8082F594, // PLAYER_IA_MASK_BLAST + func_8082F594, // PLAYER_IA_MASK_SCENTS + func_8082F594, // PLAYER_IA_MASK_GIANT + func_8082F594, // PLAYER_IA_MASK_FIERCE_DEITY + func_8082F594, // PLAYER_IA_MASK_GORON + func_8082F594, // PLAYER_IA_MASK_ZORA + func_8082F594, // PLAYER_IA_MASK_DEKU + func_8082F594, // PLAYER_IA_LENS +}; + +void func_8082F5FC(Player* this, Actor* actor) { + this->heldActor = actor; + this->interactRangeActor = actor; + this->getItemId = GI_NONE; + this->leftHandWorld.rot.y = actor->shape.rot.y - this->actor.shape.rot.y; + this->stateFlags1 |= PLAYER_STATE1_800; +} + +struct_8085CC88 D_8085CC88[] = { + { &gPlayerAnim_link_normal_free2free, 12 }, + { &gPlayerAnim_link_normal_normal2fighter, 6 }, + { &gPlayerAnim_link_hammer_normal2long, 8 }, + { &gPlayerAnim_link_normal_normal2free, 8 }, + { &gPlayerAnim_link_fighter_fighter2long, 8 }, + { &gPlayerAnim_link_normal_fighter2free, 10 }, + { &gPlayerAnim_link_hammer_long2free, 7 }, + { &gPlayerAnim_link_hammer_long2long, 11 }, + { &gPlayerAnim_link_normal_free2free, 12 }, + { &gPlayerAnim_link_normal_normal2bom, 4 }, + { &gPlayerAnim_link_normal_long2bom, 4 }, + { &gPlayerAnim_link_normal_free2bom, 4 }, + { &gPlayerAnim_link_anchor_anchor2fighter, 5 }, + { &gPlayerAnim_link_normal_free2freeB, 13 }, + { &gPlayerAnim_pz_bladeon, 4 }, +}; + +s8 D_8085CD00[PLAYER_ANIMTYPE_MAX][PLAYER_ANIMTYPE_MAX] = { + { 8, -5, -3, -6, 8, 0xB }, { 5, 0, -1, 4, 5, 9 }, { 3, 1, 0, 2, 3, 9 }, + { 6, -4, -2, 7, 6, 0xA }, { 8, -5, -3, -6, 8, 0xB }, { 8, -5, -3, -6, 8, 0xB }, +}; + +ExplosiveInfo sPlayerExplosiveInfo[PLAYER_EXPLOSIVE_MAX] = { + { ITEM_BOMB, ACTOR_EN_BOM }, // PLAYER_EXPLOSIVE_BOMB + { ITEM_POWDER_KEG, ACTOR_EN_BOM }, // PLAYER_EXPLOSIVE_POWDER_KEG + { ITEM_BOMBCHU, ACTOR_EN_BOM_CHU }, // PLAYER_EXPLOSIVE_BOMBCHU +}; + +void Player_SpawnExplosive(PlayState* play, Player* this) { + PlayerExplosive explosiveType; + ExplosiveInfo* explosiveInfo; + Actor* explosiveActor; + + if (this->stateFlags1 & PLAYER_STATE1_800) { + func_8082DE14(play, this); + return; + } + + explosiveType = Player_GetExplosiveHeld(this); + explosiveInfo = &sPlayerExplosiveInfo[explosiveType]; + if ((explosiveType == PLAYER_EXPLOSIVE_POWDER_KEG) && (gSaveContext.powderKegTimer == 0)) { + gSaveContext.powderKegTimer = 200; + } + + explosiveActor = Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, explosiveInfo->actorId, + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, + (explosiveType == PLAYER_EXPLOSIVE_POWDER_KEG) ? BOMB_EXPLOSIVE_TYPE_POWDER_KEG + : BOMB_EXPLOSIVE_TYPE_BOMB, + this->actor.shape.rot.y, 0, BOMB_TYPE_BODY); + if (explosiveActor != NULL) { + if ((explosiveType == PLAYER_EXPLOSIVE_BOMB) && (play->unk_1887E != 0)) { + play->unk_1887E--; + if (play->unk_1887E == 0) { + play->unk_1887E = -1; + } + } else if ((explosiveType == PLAYER_EXPLOSIVE_BOMBCHU) && (play->unk_1887D != 0)) { + play->unk_1887D--; + if (play->unk_1887D == 0) { + play->unk_1887D = -1; + } + } else { + Inventory_ChangeAmmo(explosiveInfo->itemId, -1); + } + func_8082F5FC(this, explosiveActor); + } else if (explosiveType == PLAYER_EXPLOSIVE_POWDER_KEG) { + gSaveContext.powderKegTimer = 0; + } +} + +// SpawnHookshot? +void func_8082F7F4(PlayState* play, Player* this) { + ArmsHook* armsHook; + + this->stateFlags1 |= PLAYER_STATE1_8; + this->unk_B28 = -3; + this->unk_B48 = 0.0f; + + this->heldActor = + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_ARMS_HOOK, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 0); + + if (this->heldActor == NULL) { + func_80831990(play, this, ITEM_NONE); + return; + } + armsHook = (ArmsHook*)this->heldActor; + armsHook->actor.objBankIndex = this->actor.objBankIndex; + armsHook->unk_208 = this->transformation; +} + +void func_8082F8A0(PlayState* play, Player* this) { + this->stateFlags1 |= PLAYER_STATE1_1000000; +} + +void func_8082F8BC(PlayState* play, Player* this, PlayerItemAction itemAction) { + this->itemAction = this->heldItemAction = itemAction; + this->modelGroup = this->nextModelGroup; + + this->stateFlags1 &= ~(PLAYER_STATE1_1000000 | PLAYER_STATE1_8); + + this->unk_B08 = 0.0f; + this->unk_B0C = 0.0f; + this->unk_B28 = 0; + + D_8085CB3C[itemAction](play, this); + Player_SetModelGroup(this, this->modelGroup); +} + +// AttackAnimInfo sMeleeAttackAnimInfo +AttackAnimInfo sMeleeAttackAnimInfo[PLAYER_MWA_MAX] = { + // PLAYER_MWA_FORWARD_SLASH_1H + { &gPlayerAnim_link_fighter_normal_kiru, &gPlayerAnim_link_fighter_normal_kiru_end, + &gPlayerAnim_link_fighter_normal_kiru_endR, 1, 4 }, + // PLAYER_MWA_FORWARD_SLASH_2H + { &gPlayerAnim_link_fighter_Lnormal_kiru, &gPlayerAnim_link_fighter_Lnormal_kiru_end, + &gPlayerAnim_link_anchor_Lnormal_kiru_endR, 1, 4 }, + // PLAYER_MWA_FORWARD_COMBO_1H + { &gPlayerAnim_link_fighter_normal_kiru_finsh, &gPlayerAnim_link_fighter_normal_kiru_finsh_end, + &gPlayerAnim_link_anchor_normal_kiru_finsh_endR, 0, 5 }, + // PLAYER_MWA_FORWARD_COMBO_2H + { &gPlayerAnim_link_fighter_Lnormal_kiru_finsh, &gPlayerAnim_link_fighter_Lnormal_kiru_finsh_end, + &gPlayerAnim_link_anchor_Lnormal_kiru_finsh_endR, 1, 7 }, + // PLAYER_MWA_RIGHT_SLASH_1H + { &gPlayerAnim_link_fighter_Lside_kiru, &gPlayerAnim_link_fighter_Lside_kiru_end, + &gPlayerAnim_link_anchor_Lside_kiru_endR, 1, 4 }, + // PLAYER_MWA_RIGHT_SLASH_2H + { &gPlayerAnim_link_fighter_LLside_kiru, &gPlayerAnim_link_fighter_LLside_kiru_end, + &gPlayerAnim_link_anchor_LLside_kiru_endL, 0, 5 }, + // PLAYER_MWA_RIGHT_COMBO_1H + { &gPlayerAnim_link_fighter_Lside_kiru_finsh, &gPlayerAnim_link_fighter_Lside_kiru_finsh_end, + &gPlayerAnim_link_anchor_Lside_kiru_finsh_endR, 2, 8 }, + // PLAYER_MWA_RIGHT_COMBO_2H + { &gPlayerAnim_link_fighter_LLside_kiru_finsh, &gPlayerAnim_link_fighter_LLside_kiru_finsh_end, + &gPlayerAnim_link_anchor_LLside_kiru_finsh_endR, 3, 8 }, + // PLAYER_MWA_LEFT_SLASH_1H + { &gPlayerAnim_link_fighter_Rside_kiru, &gPlayerAnim_link_fighter_Rside_kiru_end, + &gPlayerAnim_link_anchor_Rside_kiru_endR, 0, 4 }, + // PLAYER_MWA_LEFT_SLASH_2H + { &gPlayerAnim_link_fighter_LRside_kiru, &gPlayerAnim_link_fighter_LRside_kiru_end, + &gPlayerAnim_link_anchor_LRside_kiru_endR, 0, 5 }, + // PLAYER_MWA_LEFT_COMBO_1H + { &gPlayerAnim_link_fighter_Rside_kiru_finsh, &gPlayerAnim_link_fighter_Rside_kiru_finsh_end, + &gPlayerAnim_link_anchor_Rside_kiru_finsh_endR, 0, 6 }, + // PLAYER_MWA_LEFT_COMBO_2H + { &gPlayerAnim_link_fighter_LRside_kiru_finsh, &gPlayerAnim_link_fighter_LRside_kiru_finsh_end, + &gPlayerAnim_link_anchor_LRside_kiru_finsh_endL, 1, 5 }, + // PLAYER_MWA_STAB_1H + { &gPlayerAnim_link_fighter_pierce_kiru, &gPlayerAnim_link_fighter_pierce_kiru_end, + &gPlayerAnim_link_anchor_pierce_kiru_endR, 0, 3 }, + // PLAYER_MWA_STAB_2H + { &gPlayerAnim_link_fighter_Lpierce_kiru, &gPlayerAnim_link_fighter_Lpierce_kiru_end, + &gPlayerAnim_link_anchor_Lpierce_kiru_endL, 0, 3 }, + // PLAYER_MWA_STAB_COMBO_1H + { &gPlayerAnim_link_fighter_pierce_kiru_finsh, &gPlayerAnim_link_fighter_pierce_kiru_finsh_end, + &gPlayerAnim_link_anchor_pierce_kiru_finsh_endR, 1, 9 }, + // PLAYER_MWA_STAB_COMBO_2H + { &gPlayerAnim_link_fighter_Lpierce_kiru_finsh, &gPlayerAnim_link_fighter_Lpierce_kiru_finsh_end, + &gPlayerAnim_link_anchor_Lpierce_kiru_finsh_endR, 1, 8 }, + // PLAYER_MWA_FLIPSLASH_START + { &gPlayerAnim_link_fighter_jump_rollkiru, &gPlayerAnim_link_fighter_jump_kiru_finsh, + &gPlayerAnim_link_fighter_jump_kiru_finsh, 7, 99 }, + // PLAYER_MWA_JUMPSLASH_START + { &gPlayerAnim_link_fighter_Lpower_jump_kiru, &gPlayerAnim_link_fighter_Lpower_jump_kiru_hit, + &gPlayerAnim_link_fighter_Lpower_jump_kiru_hit, 7, 99 }, + // PLAYER_MWA_ZORA_JUMPKICK_START + { &gPlayerAnim_pz_jumpAT, &gPlayerAnim_pz_jumpATend, &gPlayerAnim_pz_jumpATend, 8, 99 }, + // PLAYER_MWA_FLIPSLASH_FINISH + { &gPlayerAnim_link_fighter_jump_kiru_finsh, &gPlayerAnim_link_fighter_jump_kiru_finsh_end, + &gPlayerAnim_link_fighter_jump_kiru_finsh_end, 1, 2 }, + // PLAYER_MWA_JUMPSLASH_FINISH + { &gPlayerAnim_link_fighter_Lpower_jump_kiru_hit, &gPlayerAnim_link_fighter_Lpower_jump_kiru_end, + &gPlayerAnim_link_fighter_Lpower_jump_kiru_end, 1, 2 }, + // PLAYER_MWA_ZORA_JUMPKICK_FINISH + { &gPlayerAnim_pz_jumpATend, &gPlayerAnim_pz_wait, &gPlayerAnim_link_normal_waitR_free, 1, 2 }, + // PLAYER_MWA_BACKSLASH_RIGHT + { &gPlayerAnim_link_fighter_turn_kiruR, &gPlayerAnim_link_fighter_turn_kiruR_end, + &gPlayerAnim_link_fighter_turn_kiruR_end, 1, 5 }, + // PLAYER_MWA_BACKSLASH_LEFT + { &gPlayerAnim_link_fighter_turn_kiruL, &gPlayerAnim_link_fighter_turn_kiruL_end, + &gPlayerAnim_link_fighter_turn_kiruL_end, 1, 4 }, + // PLAYER_MWA_GORON_PUNCH_LEFT + { &gPlayerAnim_pg_punchA, &gPlayerAnim_pg_punchAend, &gPlayerAnim_pg_punchAendR, 6, 8 }, + // PLAYER_MWA_GORON_PUNCH_RIGHT + { &gPlayerAnim_pg_punchB, &gPlayerAnim_pg_punchBend, &gPlayerAnim_pg_punchBendR, 12, 18 }, + // PLAYER_MWA_GORON_PUNCH_BUTT + { &gPlayerAnim_pg_punchC, &gPlayerAnim_pg_punchCend, &gPlayerAnim_pg_punchCendR, 8, 14 }, + // PLAYER_MWA_ZORA_PUNCH_LEFT + { &gPlayerAnim_pz_attackA, &gPlayerAnim_pz_attackAend, &gPlayerAnim_pz_attackAendR, 2, 5 }, + // PLAYER_MWA_ZORA_PUNCH_COMBO + { &gPlayerAnim_pz_attackB, &gPlayerAnim_pz_attackBend, &gPlayerAnim_pz_attackBendR, 3, 8 }, + // PLAYER_MWA_ZORA_PUNCH_KICK + { &gPlayerAnim_pz_attackC, &gPlayerAnim_pz_attackCend, &gPlayerAnim_pz_attackCendR, 3, 10 }, + // PLAYER_MWA_SPIN_ATTACK_1H + { &gPlayerAnim_link_fighter_rolling_kiru, &gPlayerAnim_link_fighter_rolling_kiru_end, + &gPlayerAnim_link_anchor_rolling_kiru_endR, 0, 12 }, + // PLAYER_MWA_SPIN_ATTACK_2H + { &gPlayerAnim_link_fighter_Lrolling_kiru, &gPlayerAnim_link_fighter_Lrolling_kiru_end, + &gPlayerAnim_link_anchor_Lrolling_kiru_endR, 0, 15 }, + // PLAYER_MWA_BIG_SPIN_1H + { &gPlayerAnim_link_fighter_Wrolling_kiru, &gPlayerAnim_link_fighter_Wrolling_kiru_end, + &gPlayerAnim_link_anchor_rolling_kiru_endR, 0, 16 }, + // PLAYER_MWA_BIG_SPIN_2H + { &gPlayerAnim_link_fighter_Wrolling_kiru, &gPlayerAnim_link_fighter_Wrolling_kiru_end, + &gPlayerAnim_link_anchor_Lrolling_kiru_endR, 0, 16 }, +}; + +PlayerAnimationHeader* D_8085CF50[] = { + &gPlayerAnim_link_fighter_power_kiru_start, + &gPlayerAnim_link_fighter_Lpower_kiru_start, +}; +PlayerAnimationHeader* D_8085CF58[] = { + &gPlayerAnim_link_fighter_power_kiru_startL, + &gPlayerAnim_link_fighter_Lpower_kiru_start, +}; +PlayerAnimationHeader* D_8085CF60[] = { + &gPlayerAnim_link_fighter_power_kiru_wait, + &gPlayerAnim_link_fighter_Lpower_kiru_wait, +}; +PlayerAnimationHeader* D_8085CF68[] = { + &gPlayerAnim_link_fighter_power_kiru_wait_end, + &gPlayerAnim_link_fighter_Lpower_kiru_wait_end, +}; +PlayerAnimationHeader* D_8085CF70[] = { + &gPlayerAnim_link_fighter_power_kiru_walk, + &gPlayerAnim_link_fighter_Lpower_kiru_walk, +}; +PlayerAnimationHeader* D_8085CF78[] = { + &gPlayerAnim_link_fighter_power_kiru_side_walk, + &gPlayerAnim_link_fighter_Lpower_kiru_side_walk, +}; + +u8 D_8085CF80[] = { + PLAYER_MWA_SPIN_ATTACK_1H, + PLAYER_MWA_SPIN_ATTACK_2H, +}; +u8 D_8085CF84[] = { + PLAYER_MWA_BIG_SPIN_1H, + PLAYER_MWA_BIG_SPIN_2H, +}; + +// sBlureColors +BlureColors D_8085CF88[] = { + { { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 } }, + { { 165, 185, 255, 185 }, { 205, 225, 255, 50 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 } }, +}; + +void Player_OverrideBlureColors(PlayState* play, Player* this, s32 colorType, s32 elemDuration) { + EffectBlure* blure0 = Effect_GetByIndex(this->meleeWeaponEffectIndex[0]); + EffectBlure* blure1 = Effect_GetByIndex(this->meleeWeaponEffectIndex[1]); + s32 i; + + for (i = 0; i < 4; i++) { + blure0->p1StartColor[i] = D_8085CF88[colorType].p1StartColor[i]; + blure0->p2StartColor[i] = D_8085CF88[colorType].p2StartColor[i]; + blure0->p1EndColor[i] = D_8085CF88[colorType].p1EndColor[i]; + blure0->p2EndColor[i] = D_8085CF88[colorType].p2EndColor[i]; + blure1->p1StartColor[i] = D_8085CF88[colorType].p1StartColor[i]; + blure1->p2StartColor[i] = D_8085CF88[colorType].p2StartColor[i]; + blure1->p1EndColor[i] = D_8085CF88[colorType].p1EndColor[i]; + blure1->p2EndColor[i] = D_8085CF88[colorType].p2EndColor[i]; + } + + if (this->transformation == PLAYER_FORM_DEKU) { + elemDuration = 8; + } + blure0->elemDuration = elemDuration; + blure1->elemDuration = elemDuration; +} + +void func_8082FA5C(PlayState* play, Player* this, PlayerMeleeWeaponState meleeWeaponState) { + u16 voiceSfxId; + u16 itemSfxId; + + if (this->meleeWeaponState == PLAYER_MELEE_WEAPON_STATE_0) { + voiceSfxId = NA_SE_VO_LI_SWORD_N; + if (this->transformation == PLAYER_FORM_GORON) { + itemSfxId = NA_SE_IT_GORON_PUNCH_SWING; + } else { + itemSfxId = NA_SE_NONE; + if (this->meleeWeaponAnimation >= PLAYER_MWA_SPIN_ATTACK_1H) { + voiceSfxId = NA_SE_VO_LI_SWORD_L; + } else if (this->meleeWeaponAnimation == PLAYER_MWA_ZORA_PUNCH_KICK) { + itemSfxId = NA_SE_IT_GORON_PUNCH_SWING; + } else { + itemSfxId = NA_SE_IT_SWORD_SWING_HARD; + if (this->unk_ADD >= 3) { + voiceSfxId = NA_SE_VO_LI_SWORD_L; + } else { + itemSfxId = (this->heldItemAction == PLAYER_IA_SWORD_TWO_HANDED) ? NA_SE_IT_HAMMER_SWING + : NA_SE_IT_SWORD_SWING; + } + } + } + + if (itemSfxId != NA_SE_NONE) { + func_8082E1F0(this, itemSfxId); + } + + if (!((this->meleeWeaponAnimation >= PLAYER_MWA_FLIPSLASH_START) && + (this->meleeWeaponAnimation <= PLAYER_MWA_ZORA_JUMPKICK_FINISH))) { + Player_AnimSfx_PlayVoice(this, voiceSfxId); + } + + Player_OverrideBlureColors(play, this, 0, 4); + } + + this->meleeWeaponState = meleeWeaponState; +} + +s32 func_8082FB68(Player* this) { + if ((this->targetedActor != NULL) && CHECK_FLAG_ALL(this->targetedActor->flags, ACTOR_FLAG_1 | ACTOR_FLAG_4)) { + this->stateFlags3 |= PLAYER_STATE3_80000000; + return true; + } + + if (this->stateFlags3 & PLAYER_STATE3_80000000) { + this->stateFlags3 &= ~PLAYER_STATE3_80000000; + if (this->linearVelocity == 0.0f) { + this->currentYaw = this->actor.shape.rot.y; + } + } + + return false; +} + +s32 func_8082FBE8(Player* this) { + return func_80123420(this) || func_80123434(this); +} + +s32 func_8082FC24(Player* this) { + return func_8082FB68(this) || func_80123434(this); +} + +void func_8082FC60(Player* this) { + this->unk_B44 = 0.0f; + this->unk_B40 = 0.0f; +} + +s32 func_8082FC78(Player* this, ItemId item) { + if ((item < ITEM_FD) && (Player_ItemToItemAction(this, item) == this->itemAction)) { + return true; + } else { + return false; + } +} + +s32 func_8082FCC4(Player* this, ItemId item, PlayerItemAction itemAction) { + if ((item < ITEM_FD) && (Player_ItemToItemAction(this, item) == itemAction)) { + return true; + } else { + return false; + } +} + +EquipSlot func_8082FD0C(Player* this, PlayerItemAction itemAction) { + s32 btn; + + for (btn = EQUIP_SLOT_C_LEFT; btn <= EQUIP_SLOT_C_RIGHT; btn++) { + if (func_8082FCC4(this, GET_CUR_FORM_BTN_ITEM(btn), itemAction)) { + return btn; + } + } + + return EQUIP_SLOT_NONE; +} + +u16 D_8085CFA8[] = { + BTN_B, + BTN_CLEFT, + BTN_CDOWN, + BTN_CRIGHT, +}; + +// Return currently-pressed button, in order of priority B, CLEFT, CDOWN, CRIGHT. +EquipSlot func_8082FDC4(void) { + EquipSlot i; + + for (i = 0; i < ARRAY_COUNT(D_8085CFA8); i++) { + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, D_8085CFA8[i])) { + break; + } + } + + return i; +} + +void func_8082FE0C(Player* this, PlayState* play) { + if (this->stateFlags1 & (PLAYER_STATE1_800 | PLAYER_STATE1_20000000)) { + return; + } + if (this->stateFlags2 & PLAYER_STATE2_2000000) { + return; + } + if (this->stateFlags3 & PLAYER_STATE3_20000000) { + return; + } + if (func_801240DC(this)) { + return; + } + + if (this->transformation == PLAYER_FORM_HUMAN) { + if (this->currentMask != PLAYER_MASK_NONE) { + PlayerItemAction maskItemAction = GET_IA_FROM_MASK(this->currentMask); + EquipSlot btn = func_8082FD0C(this, maskItemAction); + + if (btn <= EQUIP_SLOT_NONE) { + s32 maskIdMinusOne = + GET_MASK_FROM_IA(Player_ItemToItemAction(this, GET_CUR_FORM_BTN_ITEM(this->unk_154))) - 1; + + if ((maskIdMinusOne < PLAYER_MASK_TRUTH - 1) || (maskIdMinusOne >= PLAYER_MASK_MAX - 1)) { + maskIdMinusOne = this->currentMask - 1; + } + func_80831990(play, this, Player_MaskIdToItemId(maskIdMinusOne)); + return; + } + + if ((this->currentMask == PLAYER_MASK_GIANT) && (gSaveContext.save.saveInfo.playerData.magic == 0)) { + func_80838A20(play, this); + } + + this->unk_154 = btn; + } + } + + if (((this->actor.id == ACTOR_PLAYER) && (this->itemAction >= PLAYER_IA_FISHING_ROD)) && + !(((Player_GetHeldBButtonSword(this) == PLAYER_B_SWORD_NONE) || (gSaveContext.jinxTimer == 0)) && + (func_8082FC78(this, (IREG(1) != 0) ? ITEM_FISHING_ROD : Inventory_GetBtnBItem(play)) || + func_8082FC78(this, C_BTN_ITEM(EQUIP_SLOT_C_LEFT)) || func_8082FC78(this, C_BTN_ITEM(EQUIP_SLOT_C_DOWN)) || + func_8082FC78(this, C_BTN_ITEM(EQUIP_SLOT_C_RIGHT))))) { + func_80831990(play, this, ITEM_NONE); + } else { + s32 pad; + ItemId item; + EquipSlot i = func_8082FDC4(); + + i = ((i >= EQUIP_SLOT_A) && (this->transformation == PLAYER_FORM_FIERCE_DEITY) && + (this->heldItemAction != PLAYER_IA_SWORD_TWO_HANDED)) + ? EQUIP_SLOT_B + : i; + + item = func_8012364C(play, this, i); + if (item >= ITEM_FD) { + for (i = 0; i < ARRAY_COUNT(D_8085CFA8); i++) { + if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, D_8085CFA8[i])) { + break; + } + } + + item = func_8012364C(play, this, i); + if ((item < ITEM_FD) && (Player_ItemToItemAction(this, item) == this->heldItemAction)) { + D_80862B4C = 1; + } + } else if (item == ITEM_F0) { + if (this->blastMaskTimer == 0) { + EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.focus.pos.x, + this->actor.focus.pos.y, this->actor.focus.pos.z, + BOMB_EXPLOSIVE_TYPE_BOMB, 0, 0, BOMB_TYPE_BODY); + + if (bomb != NULL) { + bomb->timer = 0; + this->blastMaskTimer = 310; + } + } + } else if (item == ITEM_F1) { + func_80839978(play, this); + } else if (item == ITEM_F2) { + func_80839A10(play, this); + } else if ((Player_BButtonSwordFromIA(this, Player_ItemToItemAction(this, item)) != PLAYER_B_SWORD_NONE) && + (gSaveContext.jinxTimer != 0)) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + Message_StartTextbox(play, 0xF7, NULL); + } + } else { + this->heldItemButton = i; + func_80831990(play, this, item); + } + } +} + +void func_808302CC(Player* this, PlayState* play) { + PlayerAnimationHeader* anim; + s32 pad[3]; + u8 nextModelAnimType; + s32 var_v1; + s8 itemAction = Player_ItemToItemAction(this, this->heldItemId); + s32 pad3; + f32 startFrame; + f32 endFrame; + f32 frameSpeed; + + func_8082F43C(play, this, func_80848808); + + nextModelAnimType = gPlayerModelTypes[this->nextModelGroup].modelAnimType; + var_v1 = D_8085CD00[gPlayerModelTypes[this->modelGroup].modelAnimType][nextModelAnimType]; + + if ((itemAction == PLAYER_IA_ZORA_FINS) || (this->heldItemAction == PLAYER_IA_ZORA_FINS)) { + var_v1 = (itemAction == PLAYER_IA_NONE) ? -14 : 14; + } else if ((itemAction == PLAYER_IA_BOTTLE_EMPTY) || (itemAction == PLAYER_IA_11) || + ((itemAction == PLAYER_IA_NONE) && + ((this->heldItemAction == PLAYER_IA_BOTTLE_EMPTY) || (this->heldItemAction == PLAYER_IA_11)))) { + var_v1 = (itemAction == PLAYER_IA_NONE) ? -13 : 13; + } + + this->unk_14E = ABS_ALT(var_v1); + anim = D_8085CC88[this->unk_14E].anim; + if ((anim == &gPlayerAnim_link_normal_fighter2free) && (this->currentShield == PLAYER_SHIELD_NONE)) { + anim = &gPlayerAnim_link_normal_free2fighter_free; + } + + endFrame = Animation_GetLastFrame(anim); + + if (var_v1 >= 0) { + frameSpeed = 1.2f; + startFrame = 0.0f; + } else { + frameSpeed = -1.2f; + startFrame = endFrame; + endFrame = 0.0f; + } + + if (itemAction != PLAYER_IA_NONE) { + frameSpeed *= 2.0f; + } + + PlayerAnimation_Change(play, &this->unk_284, anim, frameSpeed, startFrame, endFrame, ANIMMODE_ONCE, 0.0f); + this->stateFlags3 &= ~PLAYER_STATE3_40000000; +} + +void func_808304BC(Player* this, PlayState* play) { + if ((this->actor.id == ACTOR_PLAYER) && !(this->stateFlags3 & PLAYER_STATE3_40000000)) { + if ((this->heldItemAction == this->itemAction) || (this->stateFlags1 & PLAYER_STATE1_400000)) { + if ((gSaveContext.save.saveInfo.playerData.health != 0) && (play->csCtx.state == CS_STATE_IDLE)) { + if ((this->csMode == PLAYER_CSMODE_0) && (play->unk_1887C == 0) && (play->activeCamId == CAM_ID_MAIN)) { + if (!func_8082DA90(play) && (gSaveContext.timerStates[TIMER_ID_MINIGAME_2] != TIMER_STATE_STOP)) { + func_8082FE0C(this, play); + } + } + } + } + } + + if (this->stateFlags3 & PLAYER_STATE3_40000000) { + func_808302CC(this, play); + } +} + +// EN_ARROW ammo related? +s32 func_808305BC(PlayState* play, Player* this, ItemId* item, ArrowType* typeParam) { + if (this->heldItemAction == PLAYER_IA_NUT) { + *item = ITEM_NUT; + *typeParam = (this->transformation == PLAYER_FORM_DEKU) ? ARROW_TYPE_DEKU_BUBBLE : ARROW_TYPE_SLINGSHOT; + } else { + *item = ITEM_BOW; + *typeParam = (this->stateFlags1 & PLAYER_STATE1_800000) + ? ARROW_TYPE_NORMAL_HORSE + : (this->heldItemAction - PLAYER_IA_BOW + ARROW_TYPE_NORMAL); + } + + if (this->transformation == PLAYER_FORM_DEKU) { + return ((gSaveContext.save.saveInfo.playerData.magic >= 2) || + (CHECK_WEEKEVENTREG(WEEKEVENTREG_08_01) && (play->sceneId == SCENE_BOWLING))) + ? 1 + : 0; + } + if (this->stateFlags3 & PLAYER_STATE3_400) { + return 1; + } + if (gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) { + return play->interfaceCtx.minigameAmmo; + } + if (play->unk_1887C != 0) { + return play->unk_1887C; + } + + return AMMO(*item); +} + +u16 D_8085CFB0[] = { + NA_SE_PL_BOW_DRAW, + NA_SE_NONE, + NA_SE_IT_HOOKSHOT_READY, +}; + +u8 sMagicArrowCosts[] = { + 4, // ARROW_MAGIC_FIRE + 4, // ARROW_MAGIC_ICE + 8, // ARROW_MAGIC_LIGHT + 2, // ARROW_MAGIC_DEKU_BUBBLE +}; + +// Draw bow or hookshot / first person items? +s32 func_808306F8(Player* this, PlayState* play) { + if ((this->heldItemAction >= PLAYER_IA_BOW_FIRE) && (this->heldItemAction <= PLAYER_IA_BOW_LIGHT) && + (gSaveContext.magicState != MAGIC_STATE_IDLE)) { + play_sound(NA_SE_SY_ERROR); + } else { + func_8082F43C(play, this, func_80848BF4); + + this->stateFlags3 |= PLAYER_STATE3_40; + this->unk_ACC = 14; + + if (this->unk_B28 >= 0) { + s32 var_v1 = ABS_ALT(this->unk_B28); + ItemId item; + ArrowType arrowType; + ArrowMagic magicArrowType; + + if (var_v1 != 2) { + Player_PlaySfx(this, D_8085CFB0[var_v1 - 1]); + } + + if (!Player_IsHoldingHookshot(this) && (func_808305BC(play, this, &item, &arrowType) > 0)) { + if (this->unk_B28 >= 0) { + magicArrowType = ARROW_GET_MAGIC_FROM_TYPE(arrowType); + + if ((ARROW_GET_MAGIC_FROM_TYPE(arrowType) >= ARROW_MAGIC_FIRE) && + (ARROW_GET_MAGIC_FROM_TYPE(arrowType) <= ARROW_MAGIC_LIGHT)) { + if (((void)0, gSaveContext.save.saveInfo.playerData.magic) < sMagicArrowCosts[magicArrowType]) { + arrowType = ARROW_TYPE_NORMAL; + magicArrowType = ARROW_MAGIC_INVALID; + } + } else if ((arrowType == ARROW_TYPE_DEKU_BUBBLE) && + (!CHECK_WEEKEVENTREG(WEEKEVENTREG_08_01) || (play->sceneId != SCENE_BOWLING))) { + magicArrowType = ARROW_MAGIC_DEKU_BUBBLE; + } else { + magicArrowType = ARROW_MAGIC_INVALID; + } + + this->heldActor = Actor_SpawnAsChild( + &play->actorCtx, &this->actor, play, ACTOR_EN_ARROW, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, arrowType); + + if ((this->heldActor != NULL) && (magicArrowType > ARROW_MAGIC_INVALID)) { + Magic_Consume(play, sMagicArrowCosts[magicArrowType], MAGIC_CONSUME_NOW); + } + } + } + } + + return true; + } + + return false; +} + +// Take out / put away sounds? +void func_808308DC(PlayState* play, Player* this) { + s32 isGoronOrDeku = (this->transformation == PLAYER_FORM_GORON) || (this->transformation == PLAYER_FORM_DEKU); + + if ((this->heldItemAction != PLAYER_IA_NONE) && !isGoronOrDeku) { + if (Player_SwordFromIA(this, this->heldItemAction) > PLAYER_SWORD_NONE) { + func_8082E1F0(this, NA_SE_IT_SWORD_PUTAWAY); + } else { + func_8082E1F0(this, NA_SE_PL_CHANGE_ARMS); + } + } + + func_80831990(play, this, this->heldItemId); + + if (!isGoronOrDeku) { + if (Player_SwordFromIA(this, this->heldItemAction) > PLAYER_SWORD_NONE) { + func_8082E1F0(this, NA_SE_IT_SWORD_PICKOUT); + } else if (this->heldItemAction != PLAYER_IA_NONE) { + func_8082E1F0(this, NA_SE_PL_CHANGE_ARMS); + } + } +} + +void func_808309CC(PlayState* play, Player* this) { + if (func_80848808 == this->unk_AC4) { + func_808308DC(play, this); + } + + func_8082F43C(play, this, D_8085C9F0[this->heldItemAction]); + this->unk_ACC = 0; + this->unk_AA4 = 0; + func_8082DCA0(play, this); + this->stateFlags3 &= ~PLAYER_STATE3_40000000; +} + +PlayerAnimationHeader* D_8085CFBC[2] = { + &gPlayerAnim_link_anchor_waitR2defense, + &gPlayerAnim_link_anchor_waitR2defense_long, +}; +PlayerAnimationHeader* D_8085CFC4[2] = { + &gPlayerAnim_link_anchor_waitL2defense, + &gPlayerAnim_link_anchor_waitL2defense_long, +}; +PlayerAnimationHeader* D_8085CFCC[2] = { + &gPlayerAnim_link_anchor_defense_hit, + &gPlayerAnim_link_anchor_defense_long_hitL, +}; +PlayerAnimationHeader* D_8085CFD4[2] = { + &gPlayerAnim_link_anchor_defense_hit, + &gPlayerAnim_link_anchor_defense_long_hitR, +}; +PlayerAnimationHeader* D_8085CFDC[2] = { + &gPlayerAnim_link_normal_defense_hit, + &gPlayerAnim_link_fighter_defense_long_hit, +}; + +PlayerAnimationHeader* func_80830A58(PlayState* play, Player* this) { + func_8082F43C(play, this, func_8084894C); + func_8082DCA0(play, this); + + if (this->unk_B40 < 0.5f) { + return D_8085CFBC[Player_IsHoldingTwoHandedWeapon(this)]; + } else { + return D_8085CFC4[Player_IsHoldingTwoHandedWeapon(this)]; + } +} + +void func_80830AE8(Player* this) { + s32 sfxId = (this->transformation == PLAYER_FORM_GORON) + ? NA_SE_PL_GORON_SQUAT + : ((this->transformation == PLAYER_FORM_DEKU) ? NA_SE_PL_CHANGE_ARMS : NA_SE_IT_SHIELD_SWING); + + Player_PlaySfx(this, sfxId); +} + +void func_80830B38(Player* this) { + s32 sfxId = (this->transformation == PLAYER_FORM_GORON) + ? NA_SE_PL_BALL_TO_GORON + : ((this->transformation == PLAYER_FORM_DEKU) ? NA_SE_PL_TAKE_OUT_SHIELD : NA_SE_IT_SHIELD_REMOVE); + + Player_PlaySfx(this, sfxId); +} + +s32 func_80830B88(PlayState* play, Player* this) { + if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_R)) { + if (!(this->stateFlags1 & (PLAYER_STATE1_400000 | PLAYER_STATE1_800000 | PLAYER_STATE1_20000000))) { + if (!(this->stateFlags1 & PLAYER_STATE1_8000000) || ((this->currentBoots >= PLAYER_BOOTS_ZORA_UNDERWATER) && + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND))) { + if ((play->unk_1887C == 0) && (this->heldItemAction == this->itemAction)) { + if ((this->transformation == PLAYER_FORM_FIERCE_DEITY) || + (!Player_IsGoronOrDeku(this) && + ((((this->transformation == PLAYER_FORM_ZORA)) && + !(this->stateFlags1 & PLAYER_STATE1_2000000)) || + ((this->transformation == PLAYER_FORM_HUMAN) && + (this->currentShield != PLAYER_SHIELD_NONE))) && + func_8082FBE8(this))) { + PlayerAnimationHeader* anim = func_80830A58(play, this); + f32 lastFrame = Animation_GetLastFrame(anim); + + PlayerAnimation_Change(play, &this->unk_284, anim, 3.0f / 3.0f, lastFrame, lastFrame, + ANIMMODE_ONCE, 0.0f); + func_80830AE8(this); + return true; + } + } + } + } + } + + return false; +} + +void func_80830CE8(PlayState* play, Player* this) { + func_8082F43C(play, this, func_80848AB0); + + if (this->itemAction <= PLAYER_IA_MINUS1) { + func_80123C58(this); + } + + Animation_Reverse(&this->unk_284); + func_80830B38(this); +} + +void func_80830D40(PlayState* play, Player* this) { + struct_8085CC88* entry = &D_8085CC88[this->unk_14E]; + f32 frame = entry->frame; + + if (this->unk_284.playSpeed < 0.0f) { + frame -= 1.0f; + } + if (PlayerAnimation_OnFrame(&this->unk_284, frame)) { + func_808308DC(play, this); + } + func_8082FB68(this); +} + +s32 func_80830DF0(Player* this, PlayState* play) { + if (this->stateFlags3 & PLAYER_STATE3_40000000) { + func_808302CC(this, play); + } else { + return false; + } + return true; +} + +s32 func_80830E30(Player* this, PlayState* play) { + if ((this->heldItemAction == PLAYER_IA_11) || (this->transformation == PLAYER_FORM_ZORA)) { + func_8082F43C(play, this, func_8084923C); + + PlayerAnimation_PlayOnce(play, &this->unk_284, + (this->meleeWeaponAnimation == PLAYER_MWA_ZORA_PUNCH_LEFT) + ? &gPlayerAnim_pz_cutterwaitA + : ((this->meleeWeaponAnimation == PLAYER_MWA_ZORA_PUNCH_COMBO) + ? &gPlayerAnim_pz_cutterwaitB + : &gPlayerAnim_pz_cutterwaitC)); + this->unk_ACC = 0xA; + } else { + if (!func_808306F8(this, play)) { + return false; + } + + PlayerAnimation_PlayOnce(play, &this->unk_284, + (Player_IsHoldingHookshot(this)) + ? &gPlayerAnim_link_hook_shot_ready + : ((this->transformation == PLAYER_FORM_DEKU) ? &gPlayerAnim_pn_tamahakidf + : &gPlayerAnim_link_bow_bow_ready)); + } + + if (this->stateFlags1 & PLAYER_STATE1_800000) { + Player_AnimationPlayLoop(play, this, &gPlayerAnim_link_uma_anim_walk); + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->transformation != PLAYER_FORM_ZORA)) { + Player_AnimationPlayLoop(play, this, func_8082ED20(this)); + } + + return true; +} + +s32 func_80830F9C(PlayState* play) { + return (play->unk_1887C > 0) && CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_B); +} + +s32 func_80830FD4(PlayState* play) { + return (play->unk_1887C != 0) && + (play->unk_1887C < 0 || CHECK_BTN_ANY(sPlayerControlInput->cur.button, + BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP | BTN_B | BTN_A)); +} + +s32 func_80831010(Player* this, PlayState* play) { + if ((this->unk_AA5 == PLAYER_UNKAA5_0) || (this->unk_AA5 == PLAYER_UNKAA5_3)) { + if (func_8082FBE8(this) || (this->targetedActor != NULL) || + (Camera_CheckValidMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_BOWARROW) == 0)) { + return true; + } + this->unk_AA5 = PLAYER_UNKAA5_3; + } + return false; +} + +s32 func_80831094(Player* this, PlayState* play) { + if ((this->doorType == PLAYER_DOORTYPE_NONE) && !(this->stateFlags1 & PLAYER_STATE1_2000000)) { + if ((D_80862B48 != 0) || func_80830F9C(play)) { + if (func_80830E30(this, play)) { + return func_80831010(this, play); + } + } + } + return false; +} + +s32 func_80831124(PlayState* play, Player* this) { + if (this->actor.child != NULL) { + if (this->heldActor == NULL) { + this->heldActor = this->actor.child; + Player_RequestRumble(play, this, 255, 10, 250, SQ(0)); + Player_PlaySfx(this, NA_SE_IT_HOOKSHOT_RECEIVE); + } + return true; + } + return false; +} + +s32 func_80831194(PlayState* play, Player* this) { + if (this->heldActor != NULL) { + if (!Player_IsHoldingHookshot(this)) { + ItemId item; + ArrowType arrowType; + + func_808305BC(play, this, &item, &arrowType); + if ((this->transformation != PLAYER_FORM_DEKU) && !(this->stateFlags3 & PLAYER_STATE3_400)) { + if (gSaveContext.minigameStatus == MINIGAME_STATUS_ACTIVE) { + if ((play->sceneId != SCENE_SYATEKI_MIZU) && (play->sceneId != SCENE_F01) && + (play->sceneId != SCENE_SYATEKI_MORI)) { + play->interfaceCtx.minigameAmmo--; + } + } else if (play->unk_1887C != 0) { + play->unk_1887C--; + } else { + Inventory_ChangeAmmo(item, -1); + } + } + + if (play->unk_1887C == 1) { + play->unk_1887C = -10; + } + + Player_RequestRumble(play, this, 150, 10, 150, SQ(0)); + } else { + Player_RequestRumble(play, this, 255, 20, 150, SQ(0)); + this->unk_B48 = 0.0f; + } + + this->unk_D57 = (this->transformation == PLAYER_FORM_DEKU) ? 20 : 4; + + this->heldActor->parent = NULL; + this->actor.child = NULL; + this->heldActor = NULL; + return true; + } + + return false; +} + +void func_8083133C(Player* this) { + this->stateFlags1 |= PLAYER_STATE1_20000; + + if (!(this->skelAnime.moveFlags & ANIM_FLAG_80) && (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && + (D_80862B20 < 0x2000)) { + this->currentYaw = this->actor.shape.rot.y = this->actor.wallYaw + 0x8000; + } + + this->targetYaw = this->actor.shape.rot.y; +} + +s32 func_808313A8(PlayState* play, Player* this, Actor* actor) { + if (actor == NULL) { + func_8082DE50(play, this); + func_80836988(this, play); + return true; + } + + return false; +} + +void func_808313F0(Player* this, PlayState* play) { + if (!func_808313A8(play, this, this->heldActor)) { + func_8082F43C(play, this, func_808490B4); + PlayerAnimation_PlayLoop(play, &this->unk_284, &gPlayerAnim_link_normal_carryB_wait); + } +} + +// Stops the current fanfare if a stateflag is set; these two are Kamaro Dancing and Bremen Marching. +void func_80831454(Player* this) { + if ((this->stateFlags3 & PLAYER_STATE3_20000000) || (this->stateFlags2 & PLAYER_STATE2_2000000)) { + SEQCMD_STOP_SEQUENCE(SEQ_PLAYER_FANFARE, 0); + } +} + +s32 Player_SetAction(PlayState* play, Player* this, PlayerActionFunc actionFunc, s32 arg3) { + s32 i; + f32* ptr; + + if (actionFunc == this->actionFunc) { + return false; + } + + play->actorCtx.flags &= ~ACTORCTX_FLAG_PICTO_BOX_ON; + + if (this->actor.flags & ACTOR_FLAG_20000000) { + AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); + this->actor.flags &= ~ACTOR_FLAG_20000000; + } else if ((func_80857BE8 == this->actionFunc) || (func_808561B0 == this->actionFunc)) { + this->actor.shape.shadowDraw = ActorShadow_DrawFeet; + this->actor.shape.shadowScale = this->ageProperties->shadowScale; + this->unk_ABC = 0.0f; + if (func_80857BE8 == this->actionFunc) { + if (this->stateFlags3 & PLAYER_STATE3_80000) { + Magic_Reset(play); + } + func_8082DD2C(play, this); + this->actor.shape.rot.x = 0; + this->actor.shape.rot.z = 0; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_PLAYER_800; + } else { + Actor_SetScale(&this->actor, 0.01f); + } + } else if ((this->transformation == PLAYER_FORM_GORON) && + (Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE)) { + func_80831990(play, this, ITEM_NONE); + } + + func_800AEF44(Effect_GetByIndex(this->meleeWeaponEffectIndex[2])); + this->actionFunc = actionFunc; + + if ((this->itemAction != this->heldItemAction) && (!(arg3 & 1) || !(this->stateFlags1 & PLAYER_STATE1_400000))) { + func_80123C58(this); + } + + if (!(arg3 & 1) && !(this->stateFlags1 & PLAYER_STATE1_800)) { + func_808309CC(play, this); + PlayerAnimation_PlayLoop(play, &this->unk_284, func_8082ED20(this)); + this->stateFlags1 &= ~PLAYER_STATE1_400000; + } + + func_80831454(this); + func_8082E794(this); + + this->stateFlags1 &= ~(PLAYER_STATE1_40 | PLAYER_STATE1_4000000 | PLAYER_STATE1_10000000 | PLAYER_STATE1_20000000 | + PLAYER_STATE1_80000000); + this->stateFlags2 &= ~(PLAYER_STATE2_80000 | PLAYER_STATE2_800000 | PLAYER_STATE2_2000000 | PLAYER_STATE2_8000000 | + PLAYER_STATE2_10000000); + this->stateFlags3 &= + ~(PLAYER_STATE3_2 | PLAYER_STATE3_8 | PLAYER_STATE3_80 | PLAYER_STATE3_200 | PLAYER_STATE3_2000 | + PLAYER_STATE3_8000 | PLAYER_STATE3_10000 | PLAYER_STATE3_20000 | PLAYER_STATE3_40000 | PLAYER_STATE3_80000 | + PLAYER_STATE3_200000 | PLAYER_STATE3_1000000 | PLAYER_STATE3_20000000); + + this->unk_AE7 = 0; + this->unk_AE8 = 0; + this->unk_AA4 = 0; + this->unk_B86[0] = 0; + this->unk_B86[1] = 0; + this->unk_B8A = 0; + this->unk_B8C = 0; + this->unk_B8E = 0; + + // TODO: Is there no other way to write this that works? + i = 0; + ptr = this->unk_B10; + do { + *ptr = 0.0f; + ptr++; + i++; + } while (i < ARRAY_COUNT(this->unk_B10)); + + this->actor.shape.rot.z = 0; + + Player_ResetCylinder(this); + func_8082E00C(this); + + return true; +} + +void func_8083172C(PlayState* play, Player* this, PlayerActionFunc actionFunc, s32 arg3) { + s32 moveFlags = this->skelAnime.moveFlags; + + this->skelAnime.moveFlags = 0; + Player_SetAction(play, this, actionFunc, arg3); + this->skelAnime.moveFlags = moveFlags; +} + +void func_80831760(PlayState* play, Player* this, PlayerActionFunc actionFunc, s32 arg3) { + if (this->itemAction > PLAYER_IA_MINUS1) { + PlayerItemAction heldItemAction = this->itemAction; + + this->itemAction = this->heldItemAction; + Player_SetAction(play, this, actionFunc, arg3); + this->itemAction = heldItemAction; + + Player_SetModels(this, Player_ActionToModelGroup(this, this->itemAction)); + } +} + +void func_808317C4(Player* this) { + if (Player_IsHoldingHookshot(this)) { + if (this->heldActor != NULL) { + Actor_Kill(this->heldActor); + this->actor.child = NULL; + this->heldActor = NULL; + } + } +} + +s32 func_80831814(Player* this, PlayState* play, PlayerUnkAA5 arg2) { + if (!(this->stateFlags1 & (PLAYER_STATE1_4 | PLAYER_STATE1_800 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000))) { + if (Camera_CheckValidMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_FIRSTPERSON) != 0) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + (func_801242B4(this) && (this->actor.depthInWater < this->ageProperties->unk_2C))) { + this->unk_AA5 = arg2; + return true; + } + } + } + return false; +} + +// Toggle Lens +void func_808318C0(PlayState* play) { + if (Magic_Consume(play, 0, MAGIC_CONSUME_LENS)) { + if (play->actorCtx.lensActive) { + Actor_DeactivateLens(play); + } else { + play->actorCtx.lensActive = true; + } + + play_sound(play->actorCtx.lensActive ? NA_SE_SY_GLASSMODE_ON : NA_SE_SY_GLASSMODE_OFF); + } else { + play_sound(NA_SE_SY_ERROR); + } +} + +// Toggle Lens from a button press +void func_80831944(PlayState* play, Player* this) { + if (func_8012364C(play, this, func_8082FDC4()) == ITEM_LENS) { + func_808318C0(play); + } +} + +// Proposed name: Player_UseItem +void func_80831990(PlayState* play, Player* this, ItemId item) { + PlayerItemAction itemAction = Player_ItemToItemAction(this, item); + + if ((((this->heldItemAction == this->itemAction) && + (!(this->stateFlags1 & PLAYER_STATE1_400000) || + (Player_MeleeWeaponFromIA(itemAction) != PLAYER_MELEEWEAPON_NONE) || (itemAction == PLAYER_IA_NONE))) || + ((this->itemAction <= PLAYER_IA_MINUS1) && + ((Player_MeleeWeaponFromIA(itemAction) != PLAYER_MELEEWEAPON_NONE) || (itemAction == PLAYER_IA_NONE)))) && + ((itemAction == PLAYER_IA_NONE) || !(this->stateFlags1 & PLAYER_STATE1_8000000) || + (itemAction == PLAYER_IA_MASK_ZORA) || + ((this->currentBoots >= PLAYER_BOOTS_ZORA_UNDERWATER) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)))) { + s32 var_v1 = ((itemAction >= PLAYER_IA_MASK_MIN) && (itemAction <= PLAYER_IA_MASK_MAX) && + ((this->transformation != PLAYER_FORM_HUMAN) || (itemAction >= PLAYER_IA_MASK_GIANT))); + CollisionPoly* sp5C; + s32 sp58; + f32 sp54; + PlayerExplosive explosiveType; + + if (var_v1 || + (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_TALK_REQUESTED) && (itemAction != PLAYER_IA_NONE)) || + (itemAction == PLAYER_IA_OCARINA) || + ((itemAction > PLAYER_IA_BOTTLE_MIN) && itemAction < PLAYER_IA_MASK_MIN) || + ((itemAction == PLAYER_IA_PICTO_BOX) && (this->talkActor != NULL) && + (this->exchangeItemId > PLAYER_IA_NONE))) { + if (var_v1) { + PlayerTransformation playerForm = (itemAction < PLAYER_IA_MASK_FIERCE_DEITY) + ? PLAYER_FORM_HUMAN + : itemAction - PLAYER_IA_MASK_FIERCE_DEITY; + + if (((this->currentMask != PLAYER_MASK_GIANT) && (itemAction == PLAYER_IA_MASK_GIANT) && + ((gSaveContext.magicState != MAGIC_STATE_IDLE) || + (gSaveContext.save.saveInfo.playerData.magic == 0))) || + (!(this->stateFlags1 & PLAYER_STATE1_8000000) && + BgCheck_EntityCheckCeiling(&play->colCtx, &sp54, &this->actor.world.pos, + sPlayerAgeProperties[playerForm].unk_00, &sp5C, &sp58, &this->actor))) { + play_sound(NA_SE_SY_ERROR); + return; + } + } + if ((itemAction == PLAYER_IA_MAGIC_BEANS) && (AMMO(ITEM_MAGIC_BEANS) == 0)) { + play_sound(NA_SE_SY_ERROR); + } else { + this->itemAction = itemAction; + this->unk_AA5 = PLAYER_UNKAA5_5; + } + } else if (((itemAction == PLAYER_IA_STICK) && (AMMO(ITEM_STICK) == 0)) || + (((play->unk_1887D != 0) || (play->unk_1887E != 0)) && + (play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].length >= 5)) || + ((play->unk_1887D == 0) && (play->unk_1887E == 0) && + ((explosiveType = Player_ExplosiveFromIA(this, itemAction)) > PLAYER_EXPLOSIVE_NONE) && + ((AMMO(sPlayerExplosiveInfo[explosiveType].itemId) == 0) || + (play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].length >= 3)))) { + play_sound(NA_SE_SY_ERROR); + } else if (itemAction == PLAYER_IA_LENS) { + func_808318C0(play); + } else if (itemAction == PLAYER_IA_PICTO_BOX) { + if (!func_80831814(this, play, PLAYER_UNKAA5_2)) { + play_sound(NA_SE_SY_ERROR); + } + } else if ((itemAction == PLAYER_IA_NUT) && + ((this->transformation != PLAYER_FORM_DEKU) || (this->heldItemButton != 0))) { + if (AMMO(ITEM_NUT) != 0) { + func_8083A658(play, this); + } else { + play_sound(NA_SE_SY_ERROR); + } + } else if ((this->transformation == PLAYER_FORM_HUMAN) && (itemAction >= PLAYER_IA_MASK_MIN) && + (itemAction < PLAYER_IA_MASK_GIANT)) { + PlayerMask maskId = GET_MASK_FROM_IA(itemAction); + + this->prevMask = this->currentMask; + if (maskId == this->currentMask) { + this->currentMask = PLAYER_MASK_NONE; + func_8082E1F0(this, NA_SE_PL_TAKE_OUT_SHIELD); + } else { + this->currentMask = maskId; + func_8082E1F0(this, NA_SE_PL_CHANGE_ARMS); + } + gSaveContext.save.equippedMask = this->currentMask; + } else if ((itemAction != this->heldItemAction) || + ((this->heldActor == NULL) && (Player_ExplosiveFromIA(this, itemAction) > PLAYER_EXPLOSIVE_NONE))) { + u8 nextAnimType; + + this->nextModelGroup = Player_ActionToModelGroup(this, itemAction); + nextAnimType = gPlayerModelTypes[this->nextModelGroup].modelAnimType; + var_v1 = ((this->transformation != PLAYER_FORM_GORON) || (itemAction == PLAYER_IA_POWDER_KEG)); + + if (var_v1 && (this->heldItemAction >= 0) && (item != this->heldItemId) && + (D_8085CD00[gPlayerModelTypes[this->modelGroup].modelAnimType][nextAnimType] != 0)) { + this->heldItemId = item; + this->stateFlags3 |= PLAYER_STATE3_40000000; + } else { + func_808317C4(this); + func_8082DCA0(play, this); + func_8082F470(play, this, itemAction); + if (!var_v1) { + D_80862B48 = 1; + D_80862B4C = 1; + } + } + } else { + D_80862B48 = 1; + D_80862B4C = 1; + } + } +} + +void func_80831F34(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + s32 sp24 = func_801242B4(this); + + func_8082DE50(play, this); + Player_SetAction(play, this, sp24 ? func_80851BD4 : func_8084BFDC, 0); + Player_AnimationPlayOnce(play, this, anim); + + if (anim == &gPlayerAnim_link_derth_rebirth) { + this->skelAnime.endFrame = 84.0f; + } + + this->stateFlags1 |= PLAYER_STATE1_80; + + func_8082DAD4(this); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_DOWN); + + if (this == GET_PLAYER(play)) { + this->csId = play->playerCsIds[PLAYER_CS_ID_DEATH]; + Audio_SetBgmVolumeOff(); + gSaveContext.powderKegTimer = 0; + gSaveContext.unk_1014 = 0; + gSaveContext.jinxTimer = 0; + + if (Inventory_ConsumeFairy(play)) { + play->gameOverCtx.state = GAMEOVER_REVIVE_START; + this->unk_AE7 = 1; + } else { + play->gameOverCtx.state = GAMEOVER_DEATH_START; + func_801A41F8(0); + Audio_PlayFanfare(NA_BGM_GAME_OVER); + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; + } + + ShrinkWindow_Letterbox_SetSizeTarget(32); + } +} + +s32 func_80832090(Player* this) { + return (!(func_8084D770 == this->actionFunc) || + (((this->stateFlags3 & PLAYER_STATE3_40000000)) && + ((this->heldItemId == ITEM_FC) || (this->heldItemId == ITEM_NONE)))) && + (!(func_80848808 == this->unk_AC4) || + Player_ItemToItemAction(this, this->heldItemId) == this->heldItemAction); +} + +// Whether action is Bremen marching or Kamaro dancing +s32 func_8083213C(Player* this) { + return (func_8084AC84 == this->actionFunc) || (func_8084AEEC == this->actionFunc); +} + +s32 func_8083216C(Player* this, PlayState* play) { + if (!(this->stateFlags1 & PLAYER_STATE1_800000) && (this->actor.parent != NULL) && Player_IsHoldingHookshot(this)) { + Player_SetAction(play, this, func_80855E08, 1); + this->stateFlags3 |= PLAYER_STATE3_80; + Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_hook_fly_start); + func_8082E920(play, this, (ANIM_FLAG_1 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_8 | ANIM_FLAG_NOMOVE | ANIM_FLAG_80)); + func_8082DAD4(this); + this->currentYaw = this->actor.shape.rot.y; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; + this->unk_AA6 |= 0x43; + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_LASH); + return true; + } + + if (func_80832090(this)) { + func_808304BC(this, play); + if (func_80852B28 == this->actionFunc) { + return true; + } + } + + if (!this->unk_AC4(this, play)) { + return false; + } + + if (this->unk_AC8 != 0.0f) { + if ((func_8082ED94(this) == 0) || (this->linearVelocity != 0.0f)) { + AnimationContext_SetCopyFalse(play, this->skelAnime.limbCount, this->unk_284.jointTable, + this->skelAnime.jointTable, D_8085B9F0); + } + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && !(this->skelAnime.moveFlags & ANIM_FLAG_8)) { + Math_StepToF(&this->unk_AC8, 0.0f, 0.25f); + AnimationContext_SetInterp(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->unk_284.jointTable, 1.0f - this->unk_AC8); + } + } else if ((func_8082ED94(this) == 0) || (this->linearVelocity != 0.0f) || + (this->skelAnime.moveFlags & ANIM_FLAG_8)) { + AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->unk_284.jointTable, D_8085B9F0); + } else { + AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->unk_284.jointTable); + } + + return true; +} + +s32 func_808323C0(Player* this, s16 csId) { + if ((csId > CS_ID_NONE) && (CutsceneManager_GetCurrentCsId() != csId)) { + if (!CutsceneManager_IsNext(csId)) { + CutsceneManager_Queue(csId); + + return false; + } + CutsceneManager_Start(csId, &this->actor); + } + this->csId = csId; + + return true; +} + +s32 func_80832444(Player* this) { + if (this->csId > CS_ID_NONE) { + if (!CutsceneManager_IsNext(this->csId)) { + CutsceneManager_Queue(this->csId); + return false; + } + + CutsceneManager_Start(this->csId, &this->actor); + } + return true; +} + +s32 func_8083249C(Player* this) { + if ((this->csId > CS_ID_NONE) && (CutsceneManager_GetCurrentCsId() != this->csId)) { + return func_80832444(this); + } + return true; +} + +s32 func_808324EC(PlayState* play, Player* this, PlayerFuncD58 arg2, s32 csId) { + this->unk_D58 = arg2; + this->csId = csId; + Player_SetAction(play, this, func_8084D770, 0); + func_8083249C(this); + this->stateFlags2 |= PLAYER_STATE2_40; + return func_8082DE14(play, this); +} + +s32 func_80832558(PlayState* play, Player* this, PlayerFuncD58 arg2) { + return func_808324EC(play, this, arg2, CS_ID_NONE); +} + +// To do with turning, related to targeting +void func_80832578(Player* this, PlayState* play) { + s16 previousYaw = this->actor.shape.rot.y; + + if (!(this->stateFlags2 & (PLAYER_STATE2_20 | PLAYER_STATE2_40))) { + Actor* targetedActor = this->targetedActor; + + if ((targetedActor != NULL) && ((play->actorCtx.targetContext.unk4B != 0) || (this != GET_PLAYER(play))) && + (targetedActor->id != ACTOR_OBJ_NOZOKI)) { + Math_ScaledStepToS(&this->actor.shape.rot.y, + Math_Vec3f_Yaw(&this->actor.world.pos, &targetedActor->focus.pos), 0xFA0); + } else if ((this->stateFlags1 & PLAYER_STATE1_20000) && + !(this->stateFlags2 & (PLAYER_STATE2_20 | PLAYER_STATE2_40))) { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->targetYaw, 0xFA0); + } + } else if (!(this->stateFlags2 & PLAYER_STATE2_40)) { + Math_ScaledStepToS(&this->actor.shape.rot.y, this->currentYaw, 0x7D0); + } + + this->unk_B4C = this->actor.shape.rot.y - previousYaw; +} + +s16 func_80832660(s16* pValue, s16 target, s16 step, s16 arg3, s16 arg4, s16 arg5) { + s16 temp1; + s16 temp2; + s16 temp3; + + temp1 = temp2 = arg4 - *pValue; + temp2 = CLAMP(temp2, -arg5, arg5); + *pValue += BINANG_SUB(temp1, temp2); + + Math_ScaledStepToS(pValue, target, step); + + temp3 = *pValue; + if (*pValue < -arg3) { + *pValue = -arg3; + } else if (arg3 < *pValue) { + *pValue = arg3; + } + return temp3 - *pValue; +} + +s16 func_80832754(Player* this, s32 arg1) { + s16 sp36; + s16 var_s1 = this->actor.shape.rot.y; + + if (arg1) { + this->upperLimbRot.x = this->actor.focus.rot.x; + var_s1 = this->actor.focus.rot.y; + this->unk_AA6 |= 0x41; + } else { + s16 temp = + func_80832660(&this->headLimbRot.x, this->actor.focus.rot.x, 0x258, 0x2710, this->actor.focus.rot.x, 0); + + func_80832660(&this->upperLimbRot.x, temp, 0xC8, 0xFA0, this->headLimbRot.x, 0x2710); + + sp36 = this->actor.focus.rot.y - var_s1; + func_80832660(&sp36, 0, 0xC8, 0x5DC0, this->upperLimbRot.y, 0x1F40); + var_s1 = this->actor.focus.rot.y - sp36; + func_80832660(&this->headLimbRot.y, (sp36 - this->upperLimbRot.y), 0xC8, 0x1F40, sp36, 0x1F40); + func_80832660(&this->upperLimbRot.y, sp36, 0xC8, 0x1F40, this->headLimbRot.y, 0x1F40); + this->unk_AA6 |= 0xD9; + } + + return var_s1; +} + +void func_80832888(Player* this, PlayState* play) { + s32 var_v1 = 0; + Actor* var_v1_2; + s32 heldZ = CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_Z); + s32 temp_v0_3; + s32 var_a1; + + if (!heldZ) { + this->stateFlags1 &= ~PLAYER_STATE1_40000000; + } + + if ((play->csCtx.state != CS_STATE_IDLE) || (this->csMode != PLAYER_CSMODE_0) || + (this->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_20000000)) || (this->stateFlags3 & PLAYER_STATE3_80)) { + this->unk_738 = 0; + } else if (heldZ || (this->stateFlags2 & PLAYER_STATE2_2000) || (this->unk_A78 != NULL)) { + if (this->unk_738 <= 5) { + this->unk_738 = 5; + } else { + this->unk_738--; + } + } else if (this->stateFlags1 & PLAYER_STATE1_20000) { + this->unk_738 = 0; + } else if (this->unk_738 != 0) { + this->unk_738--; + } + + if (this->unk_738 > 5) { + var_v1 = 1; + } + + temp_v0_3 = func_8082DAFC(play); + if (temp_v0_3 || (this->unk_738 != 0) || (this->stateFlags1 & (PLAYER_STATE1_1000 | PLAYER_STATE1_2000000))) { + if (!temp_v0_3) { + if (!(this->stateFlags1 & PLAYER_STATE1_2000000) && + ((this->heldItemAction != PLAYER_IA_FISHING_ROD) || (this->unk_B28 == 0)) && + CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_Z)) { + var_v1_2 = (this == GET_PLAYER(play)) ? play->actorCtx.targetContext.arrowPointedActor + : &GET_PLAYER(play)->actor; + var_a1 = (gSaveContext.options.zTargetSetting != 0) || (this != GET_PLAYER(play)); + this->stateFlags1 |= PLAYER_STATE1_8000; + if ((this->currentMask != PLAYER_MASK_GIANT) && (var_v1_2 != NULL) && + !(var_v1_2->flags & ACTOR_FLAG_CANT_LOCK_ON) && + !(this->stateFlags3 & (PLAYER_STATE3_200 | PLAYER_STATE3_2000))) { + if ((var_v1_2 == this->targetedActor) && (this == GET_PLAYER(play))) { + var_v1_2 = play->actorCtx.targetContext.unk_94; + } + + if ((var_v1_2 != NULL) && + (((var_v1_2 != this->targetedActor)) || (var_v1_2->flags & ACTOR_FLAG_80000))) { + var_v1_2->flags &= ~ACTOR_FLAG_80000; + if (!var_a1) { + this->stateFlags2 |= PLAYER_STATE2_2000; + } + this->targetedActor = var_v1_2; + this->unk_738 = 0xF; + this->stateFlags2 &= ~(PLAYER_STATE2_2 | PLAYER_STATE2_200000); + } else if (!var_a1) { + func_80123DA4(this); + } + this->stateFlags1 &= ~PLAYER_STATE1_40000000; + } else if (!(this->stateFlags1 & (PLAYER_STATE1_20000 | PLAYER_STATE1_40000000)) && + (func_808573A4 != this->actionFunc)) { + func_8083133C(this); + } + } + + if (this->targetedActor != NULL) { + if ((this == GET_PLAYER(play)) && (this->targetedActor != this->unk_A78) && + func_800B83F8(this->targetedActor, this, var_v1)) { + func_80123DA4(this); + this->stateFlags1 |= PLAYER_STATE1_40000000; + } else if (this->targetedActor != NULL) { + this->targetedActor->targetPriority = 0x28; + } + } else if (this->unk_A78 != NULL) { + this->targetedActor = this->unk_A78; + } + } + + if ((this->targetedActor != NULL) && !(this->stateFlags3 & (PLAYER_STATE3_200 | PLAYER_STATE3_2000))) { + this->stateFlags1 &= ~(PLAYER_STATE1_10000 | PLAYER_STATE1_20000); + if ((this->stateFlags1 & PLAYER_STATE1_800) || + !CHECK_FLAG_ALL(this->targetedActor->flags, ACTOR_FLAG_1 | ACTOR_FLAG_4)) { + this->stateFlags1 |= PLAYER_STATE1_10000; + } + } else if (this->stateFlags1 & PLAYER_STATE1_20000) { + this->stateFlags2 &= ~PLAYER_STATE2_2000; + } else { + func_80123DC0(this); + } + } else { + func_80123DC0(this); + } +} + +s32 func_80832CAC(PlayState* play, Player* this, f32* arg2, s16* outYaw, f32 arg4) { + f32 temp_fv1_2; + + if ((this->unk_AA5 != PLAYER_UNKAA5_0) || func_8082DA90(play) || (this->stateFlags1 & PLAYER_STATE1_1)) { + *arg2 = 0.0f; + *outYaw = this->actor.shape.rot.y; + } else { + *arg2 = D_80862AFC; + *outYaw = D_80862B00; + if (arg4 != 0.0f) { + *arg2 -= 20.0f; + if (*arg2 < 0.0f) { + *arg2 = 0.0f; + } else { + temp_fv1_2 = 1.0f - Math_CosS(*arg2 * 450.0f); + *arg2 = (SQ(temp_fv1_2) * 30.0f) + 7.0f; + } + } else { + *arg2 *= 0.8f; + } + + if (this->transformation == PLAYER_FORM_FIERCE_DEITY) { + *arg2 *= 1.5f; + } + + if (D_80862AFC != 0.0f) { + f32 temp_fv0 = Math_SinS(this->unk_B6C); + f32 var_fa0 = this->unk_B50; + f32 var_fa1; + + if (this->unk_AB8 != 0.0f) { + var_fa1 = (this->targetedActor != NULL) ? 0.002f : 0.008f; + + var_fa0 -= this->unk_AB8 * var_fa1; + var_fa0 = CLAMP_MIN(var_fa0, 2.0f); + } + *arg2 = (*arg2 * 0.14f) - (8.0f * temp_fv0 * temp_fv0); + *arg2 = CLAMP(*arg2, 0.0f, var_fa0); + if (temp_fv0) {} //! FAKE + return true; + } + } + + return false; +} + +s32 func_80832F24(Player* this) { + return Math_StepToF(&this->linearVelocity, 0.0f, REG(43) / 100.0f); +} + +s32 func_80832F78(Player* this, f32* arg1, s16* outYaw, f32 arg3, PlayState* play) { + if (!func_80832CAC(play, this, arg1, outYaw, arg3)) { + *outYaw = this->actor.shape.rot.y; + + if (this->targetedActor != NULL) { + if ((play->actorCtx.targetContext.unk4B != 0) && !(this->stateFlags2 & PLAYER_STATE2_40)) { + *outYaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->targetedActor->focus.pos); + } + } else if (func_80123434(this)) { + *outYaw = this->targetYaw; + } + + return false; + } + + *outYaw += Camera_GetInputDirYaw(play->cameraPtrs[play->activeCamId]); + return true; +} + +/** + * The values of following arrays are used as indices for the `D_8085D054` array. + * Each index correspond to a function which will be called sequentially until any of them return `true`. + * Negative marks the end of the array. + */ +s8 D_8085CFE4[] = { 13, 2, 4, 9, 10, 11, 8, -7 }; +s8 D_8085CFEC[] = { 13, 1, 2, 5, 3, 4, 9, 10, 11, 7, 8, -6 }; +s8 D_8085CFF8[] = { 13, 1, 2, 3, 4, 9, 10, 11, 8, 7, -6 }; +s8 D_8085D004[] = { 13, 2, 4, 9, 10, 11, 8, -7 }; +s8 D_8085D00C[] = { 13, 2, 4, 9, 10, 11, 12, 8, -7 }; +s8 D_8085D018[] = { -7 }; +s8 D_8085D01C[] = { 0, 11, 1, 2, 3, 5, 4, 9, 8, 7, -6 }; +s8 D_8085D028[] = { 0, 11, 1, 2, 3, 12, 5, 4, 9, 8, 7, -6 }; +s8 D_8085D034[] = { 13, 1, 2, 3, 12, 5, 4, 9, 10, 11, 8, 7, -6 }; +s8 D_8085D044[] = { 10, 8, -7 }; +s8 D_8085D048[] = { 0, 12, 5, 4, -14 }; +s8 D_8085D050[] = { 13, 2, -4 }; + +s32 (*D_8085D054[])(Player*, PlayState*) = { + func_80839518, func_808365DC, func_8083D23C, func_8083CCB4, func_808391D8, + func_8083DFC4, func_8083A114, func_80848570, func_8083A580, func_8083D78C, + func_80839B18, func_8083A274, func_80834DFC, func_80838A90, func_8083A0CC, +}; + +s32 func_80833058(PlayState* play, Player* this, s8* arg2, s32 arg3) { + if (!(this->stateFlags1 & (PLAYER_STATE1_1 | PLAYER_STATE1_80 | PLAYER_STATE1_20000000)) && !func_8082DA90(play)) { + if (arg3) { + D_80862B04 = func_8083216C(this, play); + if (func_80852B28 == this->actionFunc) { + return true; + } + } + + if (func_801240DC(this)) { + this->unk_AA6 |= 0x41; + return true; + } + + if (!(this->stateFlags3 & PLAYER_STATE3_40000000) && (func_80848808 != this->unk_AC4)) { + while (*arg2 >= 0) { + if (D_8085D054[*arg2](this, play)) { + return true; + } + arg2++; + } + + if (D_8085D054[-*arg2](this, play)) { + return true; + } + } + + if (func_8083213C(this)) { + return true; + } + } else if (this->stateFlags1 & PLAYER_STATE1_800) { + func_8083216C(this, play); + } + + return false; +} + +s32 func_808331FC(PlayState* play, Player* this, SkelAnime* skelAnime, f32 frame) { + if ((skelAnime->endFrame - frame) <= skelAnime->curFrame) { + f32 sp24; + s16 sp22; + + if (func_80833058(play, this, D_8085D01C, 1)) { + return 0; + } + + if (D_80862B04 || func_80832F78(this, &sp24, &sp22, 0.018f, play)) { + return 1; + } + } + return -1; +} + +void func_808332A0(PlayState* play, Player* this, s32 magicCost, s32 isSwordBeam) { + if (magicCost != 0) { + this->unk_B08 = 0.0f; + } else { + this->unk_B08 = 0.5f; + } + + this->stateFlags1 |= PLAYER_STATE1_1000; + if ((this->actor.id == ACTOR_PLAYER) && (isSwordBeam || (this->transformation == PLAYER_FORM_HUMAN))) { + s16 pitch = 0; + Actor* thunder; + + if (isSwordBeam) { + if (this->targetedActor != NULL) { + pitch = Math_Vec3f_Pitch(&this->bodyPartsPos[PLAYER_BODYPART_WAIST], &this->targetedActor->focus.pos); + } + if (gSaveContext.save.saveInfo.playerData.magic == 0) { + return; + } + } + + thunder = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_M_THUNDER, this->bodyPartsPos[PLAYER_BODYPART_WAIST].x, + this->bodyPartsPos[PLAYER_BODYPART_WAIST].y, this->bodyPartsPos[PLAYER_BODYPART_WAIST].z, + pitch, 0, 0, (this->heldItemAction - PLAYER_IA_SWORD_KOKIRI) | magicCost); + + if ((thunder != NULL) && isSwordBeam) { + Magic_Consume(play, 1, MAGIC_CONSUME_DEITY_BEAM); + this->unk_D57 = 4; + } + } +} + +// Check for inputs for quickspin +s32 func_808333CC(Player* this) { + s8 sp3C[4]; + s8* iter; + s8* iter2; + s8 temp1; + s8 temp2; + s32 i; + + if (this->heldItemAction == PLAYER_IA_STICK) { + return false; + } + + iter = &this->unk_ADF[0]; + iter2 = &sp3C[0]; + for (i = 0; i < 4; i++, iter++, iter2++) { + if ((*iter2 = *iter) < 0) { + return false; + } + *iter2 *= 2; + } + + temp1 = sp3C[0] - sp3C[1]; + if (ABS_ALT(temp1) < 10) { + return false; + } + + iter2 = &sp3C[1]; + for (i = 1; i < 3; i++, iter2++) { + temp2 = *iter2 - *(iter2 + 1); + if ((ABS_ALT(temp2) < 10) || (temp2 * temp1 < 0)) { + return false; + } + } + + return true; +} + +void func_808334D4(PlayState* play, Player* this) { + PlayerAnimationHeader* anim; + + if ((this->meleeWeaponAnimation >= PLAYER_MWA_RIGHT_SLASH_1H) && + (this->meleeWeaponAnimation <= PLAYER_MWA_RIGHT_COMBO_2H)) { + anim = D_8085CF58[Player_IsHoldingTwoHandedWeapon(this)]; + } else { + anim = D_8085CF50[Player_IsHoldingTwoHandedWeapon(this)]; + } + + func_8082DC38(this); + PlayerAnimation_Change(play, &this->skelAnime, anim, 1.0f, 8.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, + -9.0f); + func_808332A0(play, this, 2 << 8, false); +} + +void func_808335B0(PlayState* play, Player* this) { + Player_SetAction(play, this, func_8084CCEC, 1); + func_808334D4(play, this); +} + +s8 D_8085D090[] = { + PLAYER_MWA_STAB_1H, + PLAYER_MWA_RIGHT_SLASH_1H, + PLAYER_MWA_RIGHT_SLASH_1H, + PLAYER_MWA_LEFT_SLASH_1H, +}; + +s8 D_8085D094[][3] = { + { PLAYER_MWA_ZORA_PUNCH_LEFT, PLAYER_MWA_ZORA_PUNCH_COMBO, PLAYER_MWA_ZORA_PUNCH_KICK }, + { PLAYER_MWA_GORON_PUNCH_LEFT, PLAYER_MWA_GORON_PUNCH_RIGHT, PLAYER_MWA_GORON_PUNCH_BUTT }, +}; + +PlayerMeleeWeaponAnimation func_808335F4(Player* this) { + s32 temp_a1; + PlayerMeleeWeaponAnimation meleeWeaponAnim; + + temp_a1 = this->unk_AE3[this->unk_ADE]; + if ((this->transformation == PLAYER_FORM_ZORA) || (this->transformation == PLAYER_FORM_GORON)) { + s32 requiredScopeTemp; + + // yikes + meleeWeaponAnim = ((this->transformation == PLAYER_FORM_ZORA) ? D_8085D094[0] : D_8085D094[1])[this->unk_ADD]; + + if (this->unk_ADD != 0) { + this->meleeWeaponAnimation = meleeWeaponAnim; + if (this->unk_ADD >= 2) { + this->unk_ADD = -1; + } + } + } else { + if (func_808333CC(this)) { + meleeWeaponAnim = PLAYER_MWA_SPIN_ATTACK_1H; + } else { + if (temp_a1 < 0) { + meleeWeaponAnim = func_8082FBE8(this) ? PLAYER_MWA_FORWARD_SLASH_1H : PLAYER_MWA_RIGHT_SLASH_1H; + } else { + meleeWeaponAnim = D_8085D090[temp_a1]; + if (meleeWeaponAnim == PLAYER_MWA_STAB_1H) { + this->stateFlags2 |= PLAYER_STATE2_40000000; + if (!func_8082FBE8(this)) { + meleeWeaponAnim = PLAYER_MWA_FORWARD_SLASH_1H; + } + } + } + + if (this->heldItemAction == PLAYER_IA_STICK) { + meleeWeaponAnim = PLAYER_MWA_FORWARD_SLASH_1H; + } + } + + if (Player_IsHoldingTwoHandedWeapon(this)) { + meleeWeaponAnim++; + } + } + return meleeWeaponAnim; +} + +void func_80833728(Player* this, s32 index, u32 dmgFlags, s32 damage) { + this->meleeWeaponQuads[index].info.toucher.dmgFlags = dmgFlags; + this->meleeWeaponQuads[index].info.toucher.damage = damage; + + if (dmgFlags == DMG_DEKU_STICK) { + this->meleeWeaponQuads[index].info.toucherFlags = (TOUCH_ON | TOUCH_NEAREST | TOUCH_SFX_WOOD); + } else { + this->meleeWeaponQuads[index].info.toucherFlags = (TOUCH_ON | TOUCH_NEAREST); + } +} + +MeleeWeaponDamageInfo D_8085D09C[PLAYER_MELEEWEAPON_MAX] = { + { DMG_GORON_PUNCH, 2, 2, 0, 0 }, // PLAYER_MELEEWEAPON_NONE + { DMG_SWORD, 4, 8, 1, 2 }, // PLAYER_MELEEWEAPON_SWORD_KOKIRI + { DMG_SWORD, 4, 8, 2, 4 }, // PLAYER_MELEEWEAPON_SWORD_RAZOR + { DMG_SWORD, 4, 8, 3, 6 }, // PLAYER_MELEEWEAPON_SWORD_GILDED + { DMG_SWORD, 4, 8, 4, 8 }, // PLAYER_MELEEWEAPON_SWORD_TWO_HANDED + { DMG_DEKU_STICK, 0, 0, 2, 4 }, // PLAYER_MELEEWEAPON_STICK + { DMG_ZORA_PUNCH, 1, 2, 0, 0 }, // PLAYER_MELEEWEAPON_ZORA_FINS +}; + +// New function in NE0: split out of func_80833864 to be able to call it to patch Power Crouch Stab. +void func_8083375C(Player* this, PlayerMeleeWeaponAnimation meleeWeaponAnim) { + MeleeWeaponDamageInfo* dmgInfo = &D_8085D09C[0]; + s32 damage; + + if (this->actor.id == ACTOR_EN_TEST3) { + // Was Kafei originally intended to be able to punch? + meleeWeaponAnim = PLAYER_MWA_GORON_PUNCH_LEFT; + this->meleeWeaponAnimation = -1; + } else { + //! @bug Quick Put Away Damage: Since 0 is also the "no weapon" value, producing a weapon quad without a weapon + //! in hand, such as during Quick Put Away, produced a quad with the Goron punch properties, which does 0 damage + //! as human. + dmgInfo = &D_8085D09C[(this->transformation == PLAYER_FORM_GORON) ? PLAYER_MELEEWEAPON_NONE + : Player_GetMeleeWeaponHeld(this)]; + } + + //! @bug Great Deku Sword: Presumably the dmgTransformed fields are intended for Fierce Deity, but also work for + //! Deku if it is able to equip a sword (such as with the "0th day" glitch), giving Great Fairy's Sword damage. + damage = + ((meleeWeaponAnim >= PLAYER_MWA_FLIPSLASH_START) && (meleeWeaponAnim <= PLAYER_MWA_ZORA_JUMPKICK_FINISH)) + ? ((this->transformation == PLAYER_FORM_HUMAN) ? dmgInfo->dmgHumanStrong : dmgInfo->dmgTransformedStrong) + : ((this->transformation == PLAYER_FORM_HUMAN) ? dmgInfo->dmgHumanNormal : dmgInfo->dmgTransformedNormal); + + func_80833728(this, 0, dmgInfo->dmgFlags, damage); + func_80833728(this, 1, dmgInfo->dmgFlags, damage); +} + +void func_80833864(PlayState* play, Player* this, PlayerMeleeWeaponAnimation meleeWeaponAnim) { + func_8083375C(this, meleeWeaponAnim); + Player_SetAction(play, this, func_808548B8, 0); + this->unk_AE8 = 0; + + if ((meleeWeaponAnim < PLAYER_MWA_FLIPSLASH_FINISH) || (meleeWeaponAnim > PLAYER_MWA_ZORA_JUMPKICK_FINISH)) { + func_8082DC38(this); + } + + // Accumulate consecutive slashes to do the "third slash" types + if ((meleeWeaponAnim != this->meleeWeaponAnimation) || (this->unk_ADD >= 3)) { + this->unk_ADD = 0; + } + + this->unk_ADD++; + if (this->unk_ADD >= 3) { + meleeWeaponAnim += 2; + } + + this->meleeWeaponAnimation = meleeWeaponAnim; + func_8082DB90(play, this, sMeleeAttackAnimInfo[meleeWeaponAnim].unk_0); + this->unk_ADC = this->skelAnime.animLength + 4.0f; + + if ((meleeWeaponAnim < PLAYER_MWA_FLIPSLASH_START) || (meleeWeaponAnim > PLAYER_MWA_ZORA_JUMPKICK_START)) { + func_8082E920(play, this, (ANIM_FLAG_1 | ANIM_FLAG_8 | ANIM_FLAG_NOMOVE)); + } + this->currentYaw = this->actor.shape.rot.y; +} + +void func_80833998(Player* this, s32 invincibilityTimer) { + if (this->invincibilityTimer >= 0) { + this->invincibilityTimer = invincibilityTimer; + this->unk_B5F = 0; + } +} + +void func_808339B4(Player* this, s32 invincibilityTimer) { + if (this->invincibilityTimer > invincibilityTimer) { + this->invincibilityTimer = invincibilityTimer; + } + this->unk_B5F = 0; +} + +// Player_InflictDamageImpl? +s32 func_808339D4(PlayState* play, Player* this, s32 damage) { + if ((this->invincibilityTimer != 0) || (this->stateFlags3 & PLAYER_STATE3_400000) || + (this->actor.id != ACTOR_PLAYER)) { + return 1; + } + + if (this->actor.category != ACTORCAT_PLAYER) { + this->actor.colChkInfo.damage = -damage; + return Actor_ApplyDamage(&this->actor); + } + + if (this->currentMask == PLAYER_MASK_GIANT) { + damage >>= 2; + } + + return Health_ChangeBy(play, damage); +} + +void func_80833A64(Player* this) { + this->skelAnime.prevTransl = this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1]; + func_8082E820(this, 1 | ANIM_FLAG_UPDATE_Y); +} + +void func_80833AA0(Player* this, PlayState* play) { + if (Player_SetAction(play, this, func_8084C16C, 0)) { + Player_AnimationPlayLoop(play, this, &gPlayerAnim_link_normal_landing_wait); + this->unk_AE8 = 1; + } + if (this->unk_AA5 != PLAYER_UNKAA5_4) { + this->unk_AA5 = PLAYER_UNKAA5_0; + } +} + +// TODO: this can be one array, but should it be? +PlayerAnimationHeader* D_8085D0D4[] = { + &gPlayerAnim_link_normal_front_shit, + &gPlayerAnim_link_normal_front_shitR, + &gPlayerAnim_link_normal_back_shit, + &gPlayerAnim_link_normal_back_shitR, + // }; + // PlayerAnimationHeader* D_8085D0E4[] = { + &gPlayerAnim_link_normal_front_hit, + &gPlayerAnim_link_anchor_front_hitR, + &gPlayerAnim_link_normal_back_hit, + &gPlayerAnim_link_anchor_back_hitR, +}; + +void func_80833B18(PlayState* play, Player* this, s32 arg2, f32 speed, f32 velocityY, s16 arg5, + s32 invincibilityTimer) { + PlayerAnimationHeader* anim = NULL; + + if (this->stateFlags1 & PLAYER_STATE1_2000) { + func_80833A64(this); + } + + this->unk_B64 = 0; + + Player_PlaySfx(this, NA_SE_PL_DAMAGE); + + if (func_808339D4(play, this, -this->actor.colChkInfo.damage) == 0) { + this->stateFlags2 &= ~PLAYER_STATE2_80; + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->stateFlags1 & PLAYER_STATE1_8000000)) { + return; + } + } + + if (this->actor.colChkInfo.damage != 0) { + func_80833998(this, invincibilityTimer); + } + + if (this->stateFlags2 & PLAYER_STATE2_10) { + return; + } + + if (arg2 == 3) { + Player_SetAction(play, this, func_808546D0, 0); + anim = &gPlayerAnim_link_normal_ice_down; + func_8082DAD4(this); + this->actor.velocity.y = 0.0f; + + Player_RequestRumble(play, this, 255, 10, 40, SQ(0)); + + Player_PlaySfx(this, NA_SE_PL_FREEZE_S); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_FREEZE); + } else if (arg2 == 4) { + Player_SetAction(play, this, func_80854800, 0); + func_8082DB60(play, this, &gPlayerAnim_link_normal_electric_shock); + func_8082DAD4(this); + + this->unk_AE8 = 20; + this->actor.velocity.y = 0.0f; + + Player_RequestRumble(play, this, 255, 80, 150, SQ(0)); + } else { + arg5 -= this->actor.shape.rot.y; + + if (this->stateFlags1 & PLAYER_STATE1_8000000) { + Player_SetAction(play, this, func_80851B58, 0); + Player_RequestRumble(play, this, 180, 20, 50, SQ(0)); + + if (arg2 == 1) { + this->linearVelocity = speed * 1.5f; + this->actor.velocity.y = velocityY * 0.7f; + } else { + this->linearVelocity = 4.0f; + this->actor.velocity.y = 0.0f; + } + + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_DAMAGE_S); + anim = &gPlayerAnim_link_swimer_swim_hit; + } else if ((arg2 == 1) || (arg2 == 2) || !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + (this->stateFlags1 & + (PLAYER_STATE1_4 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_200000))) { + Player_SetAction(play, this, func_8084BC64, 0); + + this->stateFlags3 |= PLAYER_STATE3_2; + + Player_RequestRumble(play, this, 255, 20, 150, SQ(0)); + func_8082DAD4(this); + + if (arg2 == 2) { + this->unk_AE8 = 4; + + this->actor.speed = 3.0f; + this->linearVelocity = 3.0f; + this->actor.velocity.y = 6.0f; + + func_8082E5A8(play, this, D_8085BE84[PLAYER_ANIMGROUP_3][this->modelAnimType]); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_DAMAGE_S); + } else { + this->actor.speed = speed; + this->linearVelocity = speed; + this->actor.velocity.y = velocityY; + + if (ABS_ALT(arg5) > 0x4000) { + anim = &gPlayerAnim_link_normal_front_downA; + } else { + anim = &gPlayerAnim_link_normal_back_downA; + } + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_FALL_L); + } + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; + } else if ((this->linearVelocity > 4.0f) && !func_80123420(this)) { + this->unk_B64 = 20; + + Player_RequestRumble(play, this, 120, 20, 10, SQ(0)); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_DAMAGE_S); + + return; + } else { + PlayerAnimationHeader** animPtr = D_8085D0D4; + + Player_SetAction(play, this, func_8084BBF0, 0); + func_8082FC60(this); + + if (this->actor.colChkInfo.damage < 5) { + Player_RequestRumble(play, this, 120, 20, 10, SQ(0)); + } else { + Player_RequestRumble(play, this, 180, 20, 100, SQ(0)); + this->linearVelocity = 23.0f; + + animPtr += 4; + } + + if (ABS_ALT(arg5) <= 0x4000) { + animPtr += 2; + } + + if (func_80123420(this)) { + animPtr++; + } + + anim = *animPtr; + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_DAMAGE_S); + } + + this->actor.shape.rot.y += arg5; + this->currentYaw = this->actor.shape.rot.y; + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (ABS_ALT(arg5) > 0x4000) { + this->actor.shape.rot.y += 0x8000; + } + } + + func_8082DE50(play, this); + + this->stateFlags1 |= PLAYER_STATE1_4000000; + + if (anim != NULL) { + func_8082DB90(play, this, anim); + } +} + +s32 func_808340AC(FloorType floorType) { + s32 temp_v0 = floorType - FLOOR_TYPE_2; + + if ((temp_v0 >= FLOOR_TYPE_2 - FLOOR_TYPE_2) && (temp_v0 <= FLOOR_TYPE_3 - FLOOR_TYPE_2)) { + return temp_v0; + } + return -1; +} + +s32 func_808340D4(FloorType floorType) { + return (floorType == FLOOR_TYPE_4) || (floorType == FLOOR_TYPE_7) || (floorType == FLOOR_TYPE_12); +} + +void func_80834104(PlayState* play, Player* this) { + Player_SetAction(play, this, func_8085421C, 0); + this->stateFlags1 |= PLAYER_STATE1_20000000 | PLAYER_STATE1_80000000; +} + +void func_80834140(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + if (!(this->stateFlags1 & PLAYER_STATE1_80)) { + func_80834104(play, this); + if (func_8082DA90(play)) { + this->unk_AE8 = -30; + } + this->stateFlags1 |= PLAYER_STATE1_80; + PlayerAnimation_Change(play, &this->skelAnime, anim, 1.0f, 0.0f, 84.0f, ANIMMODE_ONCE, -6.0f); + this->unk_AE7 = 1; + this->linearVelocity = 0.0f; + } +} + +s32 func_808341F4(PlayState* play, Player* this) { + f32 temp_fv0; + f32 flameScale; + f32 flameIntensity; + s32 i; + s32 timerStep; + s32 spawnedFlame = false; + s32 var_v0; + s32 var_v1; + u8* timerPtr = this->flameTimers; + + if ((this->transformation == PLAYER_FORM_ZORA) || (this->transformation == PLAYER_FORM_DEKU)) { + timerStep = 0; + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + if (this->cylinder.base.ocFlags1 & OC1_HIT) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + this->linearVelocity = 0.0f; + } + func_80834140(play, this, &gPlayerAnim_link_derth_rebirth); + } + } else { + if (this->transformation == PLAYER_FORM_GORON) { + var_v1 = 20; + } else { + var_v1 = (s32)(this->linearVelocity * 0.4f) + 1; + } + + if (this->stateFlags2 & PLAYER_STATE2_8) { + var_v0 = 100; + } else { + var_v0 = 0; + } + + timerStep = var_v0 + var_v1; + } + + for (i = 0; i < PLAYER_BODYPART_MAX; i++, timerPtr++) { + if (*timerPtr <= timerStep) { + *timerPtr = 0; + } else { + spawnedFlame = true; + *timerPtr -= timerStep; + if (*timerPtr > 20.0f) { + temp_fv0 = (*timerPtr - 20.0f) * 0.01f; + flameScale = CLAMP(temp_fv0, 0.19999999f, 0.2f); + } else { + flameScale = *timerPtr * 0.01f; + } + + flameIntensity = (*timerPtr - 25.0f) * 0.02f; + flameIntensity = CLAMP(flameIntensity, 0.0f, 1.0f); + EffectSsFireTail_SpawnFlameOnPlayer(play, flameScale, i, flameIntensity); + } + } + + if (spawnedFlame) { + Player_PlaySfx(this, NA_SE_EV_TORCH - SFX_FLAG); + if ((play->gameplayFrames % 4) == 0) { + Player_InflictDamage(play, -1); + } + } else { + this->isBurning = false; + } + + return this->stateFlags1 & PLAYER_STATE1_80; +} + +s32 func_808344C0(PlayState* play, Player* this) { + s32 i = 0; + + while (i < ARRAY_COUNT(this->flameTimers)) { + this->flameTimers[i] = Rand_S16Offset(0, 200); + i++; + } + + this->isBurning = true; + return func_808341F4(play, this); +} + +s32 func_80834534(PlayState* play, Player* this) { + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_FALL_L); + return func_808344C0(play, this); +} + +s32 func_8083456C(PlayState* play, Player* this) { + if (this->actor.colChkInfo.acHitEffect == 1) { + return func_80834534(play, this); + } + return false; +} + +void func_808345A8(Player* this) { + if ((this->invincibilityTimer > 0) && (this->invincibilityTimer < 20)) { + this->invincibilityTimer = 20; + } +} + +void func_808345C8(void) { + if (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU) { + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; + } +} + +s32 func_80834600(Player* this, PlayState* play) { + s32 pad74; + s32 var_v0; + + if (this->unk_D6A != 0) { + if (!Player_InBlockingCsMode(play, this)) { + Player_InflictDamage(play, -16); + this->unk_D6A = 0; + } + } else if ((var_v0 = ((Player_GetHeight(this) - 8.0f) < (this->unk_AB8 * this->actor.scale.y))) || + (this->actor.bgCheckFlags & BGCHECKFLAG_CRUSHED) || (sPlayerCurrentFloorType == FLOOR_TYPE_9) || + (this->stateFlags2 & PLAYER_STATE2_80000000)) { + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_DAMAGE_S); + + if (var_v0) { + func_80169FDC(&play->state); + func_808345C8(); + Scene_SetExitFade(play); + } else { + func_80169EFC(&play->state); + func_808345C8(); + } + + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_TAKEN_AWAY); + play->haltAllActors = true; + play_sound(NA_SE_OC_ABYSS); + } else if ((this->unk_B75 != 0) && ((this->unk_B75 >= 3) || (this->invincibilityTimer == 0))) { + u8 sp6C[] = { 0, 2, 1, 1 }; + + if (!func_8083456C(play, this)) { + if (this->unk_B75 == 4) { + this->shockTimer = 40; + } + + this->actor.colChkInfo.damage += this->unk_B74; + func_80833B18(play, this, sp6C[this->unk_B75 - 1], this->unk_B78, this->unk_B7C, this->unk_B76, 20); + } + } else if ((this->shieldQuad.base.acFlags & AC_BOUNCED) || (this->shieldCylinder.base.acFlags & AC_BOUNCED) || + ((this->invincibilityTimer < 0) && (this->cylinder.base.acFlags & AC_HIT) && + (this->cylinder.info.acHitInfo != NULL) && + (this->cylinder.info.acHitInfo->toucher.dmgFlags != DMG_UNBLOCKABLE))) { + PlayerAnimationHeader* var_a2; + s32 sp64; + + Player_RequestRumble(play, this, 180, 20, 100, SQ(0)); + if ((this->invincibilityTimer >= 0) && !Player_IsGoronOrDeku(this)) { + sp64 = (func_8084B5C0 == this->actionFunc); + if (!func_801242B4(this)) { + Player_SetAction(play, this, func_8084BAA4, 0); + } + + this->unk_AE7 = sp64; + if ((s8)sp64 == 0) { + func_8082F43C(play, this, func_80848A0C); + var_a2 = (this->unk_B40 < 0.5f) ? D_8085CFD4[Player_IsHoldingTwoHandedWeapon(this)] + : D_8085CFCC[Player_IsHoldingTwoHandedWeapon(this)]; + PlayerAnimation_PlayOnce(play, &this->unk_284, var_a2); + } else { + Player_AnimationPlayOnce(play, this, D_8085CFDC[Player_IsHoldingTwoHandedWeapon(this)]); + } + } + + if (!(this->stateFlags1 & (PLAYER_STATE1_4 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_200000))) { + this->linearVelocity = -18.0f; + this->currentYaw = this->actor.shape.rot.y; + } + + return false; + } else if ((this->unk_D6B != 0) || (this->invincibilityTimer > 0) || (this->stateFlags1 & PLAYER_STATE1_4000000) || + (this->csMode != PLAYER_CSMODE_0) || (this->meleeWeaponQuads[0].base.atFlags & AT_HIT) || + (this->meleeWeaponQuads[1].base.atFlags & AT_HIT) || (this->cylinder.base.atFlags & AT_HIT) || + (this->shieldCylinder.base.atFlags & AT_HIT)) { + return false; + } else if (this->cylinder.base.acFlags & AC_HIT) { + Actor* sp60 = this->cylinder.base.ac; + s32 var_a2_2; + + if (sp60->flags & ACTOR_FLAG_1000000) { + Player_PlaySfx(this, NA_SE_PL_BODY_HIT); + } + + if (this->actor.colChkInfo.acHitEffect == 2) { + var_a2_2 = 3; + } else if (this->actor.colChkInfo.acHitEffect == 3) { + var_a2_2 = 4; + } else if (this->actor.colChkInfo.acHitEffect == 7) { + var_a2_2 = 1; + this->shockTimer = 40; + } else if (this->actor.colChkInfo.acHitEffect == 9) { + var_a2_2 = 1; + if (func_80834534(play, this)) { + return true; + } + + } else if (((this->actor.colChkInfo.acHitEffect == 4) && (this->currentMask != PLAYER_MASK_GIANT)) || + (this->stateFlags3 & PLAYER_STATE3_1000)) { + var_a2_2 = 1; + } else { + var_a2_2 = 0; + if (func_8083456C(play, this)) { + return true; + } + } + func_80833B18(play, this, var_a2_2, 4.0f, 5.0f, Actor_WorldYawTowardActor(sp60, &this->actor), 20); + } else if (this->invincibilityTimer != 0) { + return false; + } else { + s32 sp58 = func_808340AC(sPlayerCurrentFloorType); + u32 sp54 = SurfaceType_IsWallDamage(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + s32 var_a1 = 0; + s32 var_v1_2; + s32 pad48; + + if ((sp58 < 0) || + ((sp54 == 0) && (this->transformation == PLAYER_FORM_GORON) && !(this->actor.depthInWater > 0.0f))) { + var_a1 = (this->actor.wallPoly != NULL) && + SurfaceType_IsWallDamage(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId); + if (var_a1 == 0) { + //! FAKE? + goto label; + } + } + var_v1_2 = (var_a1 != 0) ? this->actor.wallBgId : this->actor.floorBgId; + if (((this->transformation == PLAYER_FORM_DEKU) || (this->transformation == PLAYER_FORM_ZORA)) && + ((sp58 >= 0) && (sp54 == 0) && !(this->stateFlags1 & PLAYER_STATE1_8000000) && + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.depthInWater < -30.0f))) { + func_80834534(play, this); + } else { + this->actor.colChkInfo.damage = 4; + func_80833B18(play, this, (var_v1_2 == BGCHECK_SCENE) ? 0 : 1, 4.0f, 5.0f, + (var_a1 != 0) ? this->actor.wallYaw : this->actor.shape.rot.y, 20); + return true; + } + } + + //! FAKE? + if (0) { + label: + return false; + } + + return true; +} + +void func_80834CD0(Player* this, f32 arg1, u16 sfxId) { + this->actor.velocity.y = arg1 * D_8085C3E4; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; + + if (sfxId != NA_SE_NONE) { + Player_AnimSfx_PlayFloorJump(this); + Player_AnimSfx_PlayVoice(this, sfxId); + } + + this->stateFlags1 |= PLAYER_STATE1_40000; + this->fallStartHeight = this->actor.world.pos.y; +} + +void func_80834D50(PlayState* play, Player* this, PlayerAnimationHeader* anim, f32 speed, u16 sfxId) { + Player_SetAction(play, this, func_8084C16C, 1); + if (anim != NULL) { + func_8082DB90(play, this, anim); + } + func_80834CD0(this, speed, sfxId); +} + +void func_80834DB8(Player* this, PlayerAnimationHeader* anim, f32 speed, PlayState* play) { + func_80834D50(play, this, anim, speed, NA_SE_VO_LI_SWORD_N); +} + +s32 func_80834DFC(Player* this, PlayState* play) { + if ((this->transformation != PLAYER_FORM_GORON) && + ((this->transformation != PLAYER_FORM_DEKU) || func_801242B4(this) || (this->unk_B5C < 4)) && + !(this->stateFlags1 & PLAYER_STATE1_800) && (this->unk_B5C >= 2) && + (!(this->stateFlags1 & PLAYER_STATE1_8000000) || (this->wallHeight < this->ageProperties->unk_14))) { + s32 var_v1 = false; + PlayerAnimationHeader* anim; + f32 wallHeight; + + if (func_801242B4(this)) { + f32 depth = (this->transformation == PLAYER_FORM_FIERCE_DEITY) ? 80.0f : 50.0f; + + if (this->actor.depthInWater < depth) { + if ((this->unk_B5C < 2) || (this->ageProperties->unk_10 < this->wallHeight)) { + return false; + } + } else if ((this->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER) || (this->unk_B5C >= 3)) { + return false; + } + } else if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + ((this->ageProperties->unk_14 <= this->wallHeight) && (this->stateFlags1 & PLAYER_STATE1_8000000))) { + return false; + } + + if ((this->actor.wallBgId != BGCHECK_SCENE) && (sPlayerCurrentWallFlags & WALL_FLAG_6)) { + if (this->unk_B5D >= 6) { + this->stateFlags2 |= PLAYER_STATE2_4; + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A)) { + var_v1 = true; + } + } + } else if ((this->unk_B5D >= 6) || CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A)) { + var_v1 = true; + } + + if (var_v1) { + Player_SetAction(play, this, func_8084D4EC, 0); + wallHeight = this->wallHeight; + + if (this->ageProperties->unk_14 <= wallHeight) { + anim = &gPlayerAnim_link_normal_250jump_start; + this->linearVelocity = 1.0f; + } else { + CollisionPoly* poly; + s32 bgId; + f32 wallPolyNormalX = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); + f32 wallPolyNormalZ = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); + f32 var_fv1 = this->wallDistance + 0.5f; // wallDistance + f32 yIntersect; + s32 pad; + + this->stateFlags1 |= PLAYER_STATE1_4; + + if (func_801242B4(this)) { + wallHeight -= 60.0f * this->ageProperties->unk_08; + anim = &gPlayerAnim_link_swimer_swim_15step_up; + this->stateFlags1 &= ~PLAYER_STATE1_8000000; + } else if (this->ageProperties->unk_18 <= wallHeight) { + wallHeight -= 59.0f * this->ageProperties->unk_08; + anim = &gPlayerAnim_link_normal_150step_up; + } else { + wallHeight -= 41.0f * this->ageProperties->unk_08; + anim = &gPlayerAnim_link_normal_100step_up; + } + + this->unk_ABC -= wallHeight * 100.0f; + + this->actor.world.pos.x -= var_fv1 * wallPolyNormalX; + this->actor.world.pos.y += this->wallHeight + 10.0f; + this->actor.world.pos.z -= var_fv1 * wallPolyNormalZ; + + yIntersect = + BgCheck_EntityRaycastFloor5(&play->colCtx, &poly, &bgId, &this->actor, &this->actor.world.pos); + if ((this->actor.world.pos.y - yIntersect) <= 20.0f) { + this->actor.world.pos.y = yIntersect; + if (bgId != BGCHECK_SCENE) { + DynaPoly_SetPlayerOnTop(&play->colCtx, bgId); + } + } + + func_8082DAD4(this); + this->actor.velocity.y = 0.0f; + } + + this->actor.bgCheckFlags |= BGCHECKFLAG_GROUND; + PlayerAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, 1.3f); + AnimationContext_DisableQueue(play); + this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw + 0x8000; + return true; + } + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->unk_B5C == 1) && (this->unk_B5D >= 3)) { + f32 temp = (this->wallHeight * 0.08f) + 5.5f; + + func_80834DB8(this, &gPlayerAnim_link_normal_jump, temp, play); + this->linearVelocity = 2.5f; + return true; + } + + return false; +} + +void func_80835324(PlayState* play, Player* this, f32 arg2, s16 arg3) { + Player_SetAction(play, this, func_8084D820, 0); + func_8082DD2C(play, this); + + this->csId = CS_ID_NONE; + this->unk_AE7 = 1; + this->unk_AE8 = 1; + + this->unk_3A0.x = Math_SinS(arg3) * arg2 + this->actor.world.pos.x; + this->unk_3A0.z = Math_CosS(arg3) * arg2 + this->actor.world.pos.z; + + Player_AnimationPlayOnce(play, this, func_8082ED20(this)); +} + +void func_808353DC(PlayState* play, Player* this) { + Player_SetAction(play, this, func_808508C8, 0); + func_8082E634(play, this, &gPlayerAnim_link_swimer_swim_wait); +} + +s32 func_80835428(PlayState* play, Player* this) { + if (!func_8082DA90(play) && (this->stateFlags1 & PLAYER_STATE1_80000000)) { + func_80834104(play, this); + Player_AnimationPlayLoop(play, this, &gPlayerAnim_link_normal_landing_wait); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_FALL_S); + func_8019F128(NA_SE_OC_SECRET_WARP_IN); + return true; + } + return false; +} + +/** + * The actual entrances each "return entrance" value can map to. + * This is used by scenes that are shared between locations. + * + * This 1D array is split into groups of entrances. + * The start of each group is indexed by `sReturnEntranceGroupIndices` values. + * The resulting groups are then indexed by the spawn value. + * + * The spawn value (`PlayState.curSpawn`) is set to a different value depending on the entrance used to enter the + * scene, which allows these dynamic "return entrances" to link back to the previous scene. + * + * Seems unused in MM + */ +u16 sReturnEntranceGroupData[] = { + // 0xFE00 + /* 0 */ 0x1000, +}; + +/** + * The values are indices into `sReturnEntranceGroupData` marking the start of each group + */ +u8 sReturnEntranceGroupIndices[] = { + 0, // 0xFE00 +}; + +// subfunction of OoT's func_80839034 +void func_808354A4(PlayState* play, s32 arg1, s32 arg2) { + play->nextEntrance = play->setupExitList[arg1]; + + if (play->nextEntrance == 0xFFFF) { + gSaveContext.respawnFlag = 4; + play->nextEntrance = gSaveContext.respawn[RESPAWN_MODE_UNK_3].entrance; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; + } else if (play->nextEntrance >= 0xFE00) { + play->nextEntrance = + sReturnEntranceGroupData[sReturnEntranceGroupIndices[play->nextEntrance - 0xFE00] + play->curSpawn]; + + Scene_SetExitFade(play); + } else { + if (arg2) { + gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = play->nextEntrance; + func_80169EFC(&play->state); + gSaveContext.respawnFlag = -2; + } + + gSaveContext.unk_3DBB = 1; + Scene_SetExitFade(play); + } + + play->transitionTrigger = TRANS_TRIGGER_START; +} + +void func_808355D8(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + func_80833AA0(this, play); + this->unk_AE8 = -2; + func_8082E5EC(play, this, anim); + func_8082E1F0(this, NA_SE_IT_DEKUNUTS_FLOWER_CLOSE); +} + +// related to grottos (?) +s32 func_8083562C(PlayState* play, Player* this, CollisionPoly* poly, s32 bgId) { + s32 var_a3; + FloorType floorType; + s32 sp34; + s32 sp30; + + if ((this == GET_PLAYER(play)) && !(this->stateFlags1 & PLAYER_STATE1_80) && !func_8082DA90(play) && + (this->csMode == PLAYER_CSMODE_0) && !(this->stateFlags1 & PLAYER_STATE1_1)) { + var_a3 = 0; + if (((poly != NULL) && (var_a3 = SurfaceType_GetSceneExitIndex(&play->colCtx, poly, bgId), (var_a3 != 0)) && + (((play->sceneId != SCENE_GORONRACE) && (play->sceneId != SCENE_DEKU_KING)) || (var_a3 < 3)) && + (((play->sceneId != SCENE_20SICHITAI) && (play->sceneId != SCENE_20SICHITAI2)) || (var_a3 < 0x15)) && + ((play->sceneId != SCENE_11GORONNOSATO) || (var_a3 < 6))) || + (func_808340D4(sPlayerCurrentFloorType) && (this->floorProperty == FLOOR_PROPERTY_12))) { + sp34 = this->unk_D68 - (s32)this->actor.world.pos.y; + if (!(this->stateFlags1 & (PLAYER_STATE1_800000 | PLAYER_STATE1_8000000 | PLAYER_STATE1_20000000)) && + !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (sp34 < 400) && (D_80862B18 > 100.0f)) { + if ((this->floorProperty != FLOOR_PROPERTY_5) && (this->floorProperty != FLOOR_PROPERTY_12)) { + this->linearVelocity = 0.0f; + } + + return false; + } else { + if (this->stateFlags3 & PLAYER_STATE3_1000000) { + func_808355D8(play, this, &gPlayerAnim_pn_kakkufinish); + } + + if (var_a3 == 0) { + func_80169EFC(&play->state); + Scene_SetExitFade(play); + } else { + func_808354A4(play, var_a3 - 1, + SurfaceType_GetFloorEffect(&play->colCtx, poly, bgId) == FLOOR_EFFECT_2); + if ((this->stateFlags1 & PLAYER_STATE1_8000000) && (this->floorProperty == FLOOR_PROPERTY_5)) { + func_8019F128(NA_SE_OC_TUNAMI); + func_801A4058(5); + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; + } else if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + (this->floorProperty == FLOOR_PROPERTY_12)) { + func_8019F128(NA_SE_OC_SECRET_WARP_IN); + } + + if (this->stateFlags1 & PLAYER_STATE1_800000) { + if (D_801BDAA0) { + D_801BDAA0 = false; + } else { + D_801BDA9C = true; + } + } + } + + if (!(this->stateFlags1 & (PLAYER_STATE1_800000 | PLAYER_STATE1_8000000 | PLAYER_STATE1_20000000)) && + ((floorType = SurfaceType_GetFloorType(&play->colCtx, poly, bgId)) != FLOOR_TYPE_10) && + ((sp34 < 100) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND))) { + if (floorType == FLOOR_TYPE_11) { + func_8019F128(NA_SE_OC_SECRET_HOLE_OUT); + func_801A4058(5); + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; + } else { + func_8085B74C(play); + } + } else if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + Player_StopHorizontalMovement(this); + } + + Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_SCENE0); + this->stateFlags1 |= PLAYER_STATE1_1 | PLAYER_STATE1_20000000; + return true; + } + } else { + if ((this->stateFlags1 & PLAYER_STATE1_8000000) && (this->actor.floorPoly == NULL)) { + BgCheck_EntityRaycastFloor7(&play->colCtx, &this->actor.floorPoly, &sp30, &this->actor, + &this->actor.world.pos); + if (this->actor.floorPoly == NULL) { + func_80169EFC(&play->state); + return false; + } + //! FAKE + if (1) {} + } + + if (!(this->stateFlags1 & PLAYER_STATE1_80000000)) { + if (((this->actor.world.pos.y < -4000.0f) || + (((this->floorProperty == FLOOR_PROPERTY_5) || (this->floorProperty == FLOOR_PROPERTY_12) || + (this->floorProperty == FLOOR_PROPERTY_13)) && + ((D_80862B18 < 100.0f) || (this->fallDistance > 400))))) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + if (this->floorProperty == FLOOR_PROPERTY_5) { + func_80169FDC(&play->state); + func_808345C8(); + } else { + func_80169EFC(&play->state); + } + if (!SurfaceType_IsWallDamage(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + gSaveContext.respawnFlag = -5; + } + + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + play_sound(NA_SE_OC_ABYSS); + } else { + if (this->stateFlags3 & PLAYER_STATE3_1000000) { + func_808355D8(play, this, &gPlayerAnim_pn_kakkufinish); + } + + if (this->floorProperty == FLOOR_PROPERTY_13) { + Player_SetAction(play, this, func_808497A0, 0); + this->stateFlags1 |= PLAYER_STATE1_20000000; + } else { + func_80834104(play, this); + this->unk_AE8 = 9999; + if (this->floorProperty == FLOOR_PROPERTY_5) { + this->unk_AE7 = -1; + } else { + this->unk_AE7 = 1; + } + } + } + } + } + + this->unk_D68 = this->actor.world.pos.y; + } + } + + return false; +} + +void Player_TranslateAndRotateY(Player* this, Vec3f* translation, Vec3f* src, Vec3f* dst) { + Lib_Vec3f_TranslateAndRotateY(translation, this->actor.shape.rot.y, src, dst); +} + +// Player_GetPosInACertainDirectionFromARadiusAway +void func_80835BF8(Vec3f* srcPos, s16 rotY, f32 radius, Vec3f* dstPos) { + dstPos->x = Math_SinS(rotY) * radius + srcPos->x; + dstPos->z = Math_CosS(rotY) * radius + srcPos->z; +} + +Actor* Player_SpawnFairy(PlayState* play, Player* this, Vec3f* translation, Vec3f* arg3, s32 elfParams) { + Vec3f pos; + + Player_TranslateAndRotateY(this, translation, arg3, &pos); + + return Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, pos.x, pos.y, pos.z, 0, 0, 0, elfParams); +} + +f32 func_80835CD8(PlayState* play, Player* this, Vec3f* arg2, Vec3f* pos, CollisionPoly** outPoly, s32* outBgId) { + Player_TranslateAndRotateY(this, &this->actor.world.pos, arg2, pos); + return BgCheck_EntityRaycastFloor5(&play->colCtx, outPoly, outBgId, &this->actor, pos); +} + +f32 func_80835D2C(PlayState* play, Player* this, Vec3f* arg2, Vec3f* pos) { + CollisionPoly* poly; + s32 bgId; + + return func_80835CD8(play, this, arg2, pos, &poly, &bgId); +} + +s32 func_80835D58(PlayState* play, Player* this, Vec3f* arg2, CollisionPoly** outPoly, s32* bgId, Vec3f* posResult) { + Vec3f posA; + Vec3f posB; + + posA.x = this->actor.world.pos.x; + posA.y = this->actor.world.pos.y + arg2->y; + posA.z = this->actor.world.pos.z; + Player_TranslateAndRotateY(this, &this->actor.world.pos, arg2, &posB); + + return BgCheck_EntityLineTest2(&play->colCtx, &posA, &posB, posResult, outPoly, true, false, false, true, bgId, + &this->actor); +} + +Vec3f D_8085D100 = { 0.0f, 50.0f, 0.0f }; + +s32 func_80835DF8(PlayState* play, Player* this, CollisionPoly** outPoly, s32* outBgId) { + Vec3f pos; + f32 yIntersect = func_80835CD8(play, this, &D_8085D100, &pos, outPoly, outBgId); + + if ((*outBgId == BGCHECK_SCENE) && (fabsf(this->actor.world.pos.y - yIntersect) < 10.0f)) { + func_800FAAB4(play, SurfaceType_GetLightSettingIndex(&play->colCtx, *outPoly, *outBgId)); + return true; + } + return false; +} + +/** + * PLAYER_DOORTYPE_STAIRCASE: DoorSpiral + */ +void Player_Door_Staircase(PlayState* play, Player* this, Actor* door) { + static Vec3f D_8085D10C = { 20.0f, 0.0f, 20.0f }; + DoorSpiral* doorStaircase = (DoorSpiral*)door; + + this->currentYaw = doorStaircase->actor.home.rot.y + 0x8000; + this->actor.shape.rot.y = this->currentYaw; + if (this->linearVelocity <= 0.0f) { + this->linearVelocity = 0.1f; + } + func_80835324(play, this, 50.0f, this->actor.shape.rot.y); + + this->unk_397 = this->doorType; + this->unk_AE7 = 0; + this->stateFlags1 |= PLAYER_STATE1_20000000; + func_80835BF8(&doorStaircase->actor.world.pos, doorStaircase->actor.shape.rot.y, -140.0f, &this->unk_3A0); + + D_8085D10C.x = (this->doorDirection != 0) ? -400.0f : 400.0f; + D_8085D10C.z = 200.0f; + Player_TranslateAndRotateY(this, &this->unk_3A0, &D_8085D10C, &this->unk_3AC); + + doorStaircase->shouldClimb = true; + + func_8082DAD4(this); + + if (this->doorTimer != 0) { + this->unk_AE8 = 0; + func_8082E438(play, this, func_8082ED20(this)); + this->skelAnime.endFrame = 0.0f; + } else { + this->linearVelocity = 0.1f; + } + + Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_SCENE0); + this->doorBgCamIndex = + play->doorCtx.transitionActorList[DOOR_GET_TRANSITION_ID(&doorStaircase->actor)].sides[0].bgCamIndex; + Actor_DeactivateLens(play); + this->floorSfxOffset = NA_SE_PL_WALK_CONCRETE - SFX_FLAG; +} + +/** + * PLAYER_DOORTYPE_SLIDING: DoorShutter, BgOpenShutter + */ +void Player_Door_Sliding(PlayState* play, Player* this, Actor* door) { + SlidingDoorActor* doorSliding = (SlidingDoorActor*)door; + Vec3f sp38; + + this->currentYaw = doorSliding->dyna.actor.home.rot.y; + if (this->doorDirection > 0) { + this->currentYaw -= 0x8000; + } + this->actor.shape.rot.y = this->currentYaw; + if (this->linearVelocity <= 0.0f) { + this->linearVelocity = 0.1f; + } + + func_80835324(play, this, 50.0f, this->actor.shape.rot.y); + this->unk_AE7 = 0; + this->unk_397 = this->doorType; + this->stateFlags1 |= PLAYER_STATE1_20000000; + Actor_OffsetOfPointInActorCoords(&doorSliding->dyna.actor, &sp38, &this->actor.world.pos); + + func_80835BF8(&this->actor.world.pos, doorSliding->dyna.actor.shape.rot.y, + (42.0f - fabsf(sp38.z)) * this->doorDirection, &this->actor.world.pos); + func_80835BF8(&this->actor.world.pos, doorSliding->dyna.actor.shape.rot.y, this->doorDirection * 20.0f, + &this->unk_3A0); + func_80835BF8(&this->actor.world.pos, doorSliding->dyna.actor.shape.rot.y, this->doorDirection * -120.0f, + &this->unk_3AC); + + doorSliding->unk_15C = 1; + func_8082DAD4(this); + + if (this->doorTimer != 0) { + this->unk_AE8 = 0; + func_8082E438(play, this, func_8082ED20(this)); + this->skelAnime.endFrame = 0.0f; + } else { + this->linearVelocity = 0.1f; + } + + if (doorSliding->dyna.actor.category == ACTORCAT_DOOR) { + this->doorBgCamIndex = play->doorCtx.transitionActorList[DOOR_GET_TRANSITION_ID(&doorSliding->dyna.actor)] + .sides[this->doorDirection > 0 ? 0 : 1] + .bgCamIndex; + Actor_DeactivateLens(play); + } +} + +// sPlayerOpenDoorLeftAnimPerForm +PlayerAnimationHeader* D_8085D118[] = { + &gPlayerAnim_pg_doorA_open, // PLAYER_FORM_GORON + &gPlayerAnim_pz_doorA_open, // PLAYER_FORM_ZORA + &gPlayerAnim_pn_doorA_open, // PLAYER_FORM_DEKU +}; +// sPlayerOpenDoorRightAnimPerForm +PlayerAnimationHeader* D_8085D124[] = { + &gPlayerAnim_pg_doorB_open, // PLAYER_FORM_GORON + &gPlayerAnim_pz_doorB_open, // PLAYER_FORM_ZORA + &gPlayerAnim_pn_doorB_open, // PLAYER_FORM_DEKU +}; + +/** + * PLAYER_DOORTYPE_TALKING: EnDoorEtc + * PLAYER_DOORTYPE_HANDLE: EnDoor + * PLAYER_DOORTYPE_FAKE: + * PLAYER_DOORTYPE_PROXIMITY: EnDoor + */ +void Player_Door_Knob(PlayState* play, Player* this, Actor* door) { + s32 temp = this->transformation - 1; + PlayerAnimationHeader* anim; + f32 temp_fv0; // sp5C + KnobDoorActor* doorHandle = (KnobDoorActor*)door; + + doorHandle->animIndex = this->transformation; + + if (this->doorDirection < 0) { + if (this->transformation == PLAYER_FORM_FIERCE_DEITY) { + anim = D_8085BE84[PLAYER_ANIMGROUP_8][this->modelAnimType]; + } else if (this->transformation == PLAYER_FORM_HUMAN) { + anim = D_8085BE84[PLAYER_ANIMGROUP_9][this->modelAnimType]; + } else { + anim = D_8085D118[temp]; + } + } else { + doorHandle->animIndex += 5; + + if (this->transformation == PLAYER_FORM_FIERCE_DEITY) { + anim = D_8085BE84[PLAYER_ANIMGROUP_10][this->modelAnimType]; + } else if (this->transformation == PLAYER_FORM_HUMAN) { + anim = D_8085BE84[PLAYER_ANIMGROUP_11][this->modelAnimType]; + } else { + anim = D_8085D124[temp]; + } + } + + Player_SetAction(play, this, func_8084E034, 0); + this->stateFlags2 |= PLAYER_STATE2_800000; + func_8082DE14(play, this); + if (this->doorDirection < 0) { + this->actor.shape.rot.y = doorHandle->dyna.actor.shape.rot.y; + } else { + this->actor.shape.rot.y = doorHandle->dyna.actor.shape.rot.y - 0x8000; + } + + this->currentYaw = this->actor.shape.rot.y; + temp_fv0 = this->doorDirection * 22.0f; + func_80835BF8(&doorHandle->dyna.actor.world.pos, doorHandle->dyna.actor.shape.rot.y, temp_fv0, + &this->actor.world.pos); + func_8082EC9C(play, this, anim); + + if (this->doorTimer != 0) { + this->skelAnime.endFrame = 0.0f; + } + + func_8082DAD4(this); + func_8082E920(play, this, + ANIM_FLAG_1 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_4 | ANIM_FLAG_8 | ANIM_FLAG_80 | ANIM_FLAG_200); + doorHandle->playOpenAnim = true; + if (this->doorType != PLAYER_DOORTYPE_FAKE) { + CollisionPoly* poly; + s32 bgId; + Vec3f pos; + s32 enDoorType = ENDOOR_GET_TYPE(&doorHandle->dyna.actor); + + this->stateFlags1 |= PLAYER_STATE1_20000000; + + if (this->actor.category == ACTORCAT_PLAYER) { + Actor_DeactivateLens(play); + func_80835BF8(&doorHandle->dyna.actor.world.pos, doorHandle->dyna.actor.shape.rot.y, -temp_fv0, &pos); + pos.y = doorHandle->dyna.actor.world.pos.y + 10.0f; + BgCheck_EntityRaycastFloor5(&play->colCtx, &poly, &bgId, &this->actor, &pos); + + if (func_8083562C(play, this, poly, BGCHECK_SCENE)) { + gSaveContext.entranceSpeed = 2.0f; + } else if (enDoorType != ENDOOR_TYPE_7) { + Camera* mainCam; + + this->unk_AE7 = 38.0f * D_8085C3E8; + mainCam = Play_GetCamera(play, CAM_ID_MAIN); + + Camera_ChangeDoorCam(mainCam, &doorHandle->dyna.actor, + play->doorCtx.transitionActorList[DOOR_GET_TRANSITION_ID(&doorHandle->dyna.actor)] + .sides[(this->doorDirection > 0) ? 0 : 1] + .bgCamIndex, + 0.0f, this->unk_AE7, 26.0f * D_8085C3E8, 10.0f * D_8085C3E8); + } + } + } +} + +// door stuff +s32 func_808365DC(Player* this, PlayState* play) { + if ((gSaveContext.save.saveInfo.playerData.health != 0) && (this->doorType != PLAYER_DOORTYPE_NONE)) { + if ((this->actor.category != ACTORCAT_PLAYER) || + ((((this->doorType <= PLAYER_DOORTYPE_TALKING) && CutsceneManager_IsNext(CS_ID_GLOBAL_TALK)) || + ((this->doorType >= PLAYER_DOORTYPE_HANDLE) && CutsceneManager_IsNext(CS_ID_GLOBAL_DOOR))) && + (!(this->stateFlags1 & PLAYER_STATE1_800) && + (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A) || (func_8085437C == this->actionFunc) || + (this->doorType == PLAYER_DOORTYPE_STAIRCASE) || (this->doorType == PLAYER_DOORTYPE_PROXIMITY))))) { + Actor* doorActor = this->doorActor; + Actor* var_v0_3; + + if (this->doorType <= PLAYER_DOORTYPE_TALKING) { + Player_TalkWithPlayer(play, doorActor); + if (doorActor->textId == 0x1821) { + doorActor->flags |= ACTOR_FLAG_TALK_REQUESTED; + } + return true; + } + + gSaveContext.respawn[RESPAWN_MODE_DOWN].data = 0; + + if (this->doorType == PLAYER_DOORTYPE_STAIRCASE) { + Player_Door_Staircase(play, this, doorActor); + } else if (this->doorType == PLAYER_DOORTYPE_SLIDING) { + Player_Door_Sliding(play, this, doorActor); + } else { + Player_Door_Knob(play, this, doorActor); + } + + if (this->actor.category == ACTORCAT_PLAYER) { + this->csId = CS_ID_GLOBAL_DOOR; + CutsceneManager_Start(this->csId, &this->actor); + } + + if (this->actor.category == ACTORCAT_PLAYER) { + if ((this->doorType < PLAYER_DOORTYPE_FAKE) && (doorActor->category == ACTORCAT_DOOR) && + ((this->doorType != PLAYER_DOORTYPE_HANDLE) || (ENDOOR_GET_TYPE(doorActor) != ENDOOR_TYPE_7))) { + s8 roomNum = play->doorCtx.transitionActorList[DOOR_GET_TRANSITION_ID(doorActor)] + .sides[(this->doorDirection > 0) ? 0 : 1] + .room; + + if ((roomNum >= 0) && (roomNum != play->roomCtx.curRoom.num)) { + Room_StartRoomTransition(play, &play->roomCtx, roomNum); + } + } + } + + doorActor->room = play->roomCtx.curRoom.num; + if (((var_v0_3 = doorActor->child) != NULL) || ((var_v0_3 = doorActor->parent) != NULL)) { + var_v0_3->room = play->roomCtx.curRoom.num; + } + return true; + } + } + + return false; +} + +void func_80836888(Player* this, PlayState* play) { + PlayerAnimationHeader* anim; + + Player_SetAction(play, this, func_80849A9C, 1); + + if (this->unk_B40 < 0.5f) { + anim = func_8082EF54(this); + this->unk_B40 = 0.0f; + } else { + anim = func_8082EF9C(this); + this->unk_B40 = 1.0f; + } + + this->unk_B44 = this->unk_B40; + Player_AnimationPlayLoop(play, this, anim); + this->currentYaw = this->actor.shape.rot.y; +} + +void func_8083692C(Player* this, PlayState* play) { + Player_SetAction(play, this, func_80849DD0, 1); + func_8082E438(play, this, func_8082ED20(this)); + this->currentYaw = this->actor.shape.rot.y; +} + +void func_80836988(Player* this, PlayState* play) { + if (func_80123420(this)) { + func_80836888(this, play); + } else if (func_80123434(this)) { + func_8083692C(this, play); + } else { + func_8085B384(this, play); + } +} + +void func_808369F4(Player* this, PlayState* play) { + PlayerActionFunc actionFunc; + + if (func_80123420(this)) { + actionFunc = func_80849A9C; + } else if (func_80123434(this)) { + actionFunc = func_80849DD0; + } else { + actionFunc = func_80849FE0; + } + Player_SetAction(play, this, actionFunc, 1); +} + +void func_80836A5C(Player* this, PlayState* play) { + func_808369F4(this, play); + if (func_80123420(this)) { + this->unk_AE8 = 1; + } +} + +void func_80836A98(Player* this, PlayerAnimationHeader* anim, PlayState* play) { + func_80836A5C(this, play); + func_8082EC9C(play, this, anim); +} + +void func_80836AD8(PlayState* play, Player* this) { + Player_SetAction(play, this, func_80857BE8, 0); + this->unk_B28 = 0; + this->unk_B86[1] = 0; + this->unk_AF0[0].x = 0.0f; + this->unk_AF0[0].y = 0.0f; + this->unk_AF0[0].z = 0.0f; + this->unk_B08 = 0.0f; + this->unk_B0C = 0.0f; + Player_PlaySfx(this, NA_SE_PL_GORON_TO_BALL); +} + +void func_80836B3C(PlayState* play, Player* this, f32 arg2) { + this->currentYaw = this->actor.shape.rot.y; + this->actor.world.rot.y = this->actor.shape.rot.y; + + if (this->transformation == PLAYER_FORM_GORON) { + func_80836AD8(play, this); + PlayerAnimation_Change(play, &this->skelAnime, D_8085BE84[PLAYER_ANIMGROUP_15][this->modelAnimType], + 1.5f * D_8085C3E4, 0.0f, 6.0f, ANIMMODE_ONCE, 0.0f); + } else { + PlayerAnimationHeader* anim = D_8085BE84[PLAYER_ANIMGROUP_15][this->modelAnimType]; + + Player_SetAction(play, this, func_8084C6EC, 0); + PlayerAnimation_Change(play, &this->skelAnime, anim, 1.25f * D_8085C3E4, arg2, Animation_GetLastFrame(anim), + ANIMMODE_ONCE, 0.0f); + } +} + +void func_80836C70(PlayState* play, Player* this, PlayerBodyPart bodyPartIndex) { + static Vec3f D_8085D130 = { 0, 0, 0 }; + s32 i; + + for (i = 0; i < 4; i++) { + Vec3f velocity; + + velocity.x = randPlusMinusPoint5Scaled(4.0f); + velocity.y = Rand_ZeroFloat(2.0f); + velocity.z = randPlusMinusPoint5Scaled(4.0f); + D_8085D130.y = -0.2f; + EffectSsHahen_Spawn(play, &this->bodyPartsPos[bodyPartIndex], &velocity, &D_8085D130, 0, 10, OBJECT_LINK_NUTS, + 16, object_link_nuts_DL_008860); + } +} + +void func_80836D8C(Player* this) { + this->actor.focus.rot.x = 0; + this->actor.focus.rot.z = 0; + this->headLimbRot.x = 0; + this->headLimbRot.y = 0; + this->headLimbRot.z = 0; + this->upperLimbRot.x = 0; + this->upperLimbRot.y = 0; + this->upperLimbRot.z = 0; + this->actor.shape.rot.y = this->actor.focus.rot.y; + this->currentYaw = this->actor.focus.rot.y; +} + +s32 func_80836DC0(PlayState* play, Player* this) { + if ((MREG(48) != 0) || func_800C9DDC(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + Player_SetAction(play, this, func_808561B0, 0); + this->stateFlags1 &= ~(PLAYER_STATE1_20000 | PLAYER_STATE1_40000000); + func_8082E438(play, this, &gPlayerAnim_pn_attack); + Player_StopHorizontalMovement(this); + func_80836D8C(this); + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->unk_B48 = -2000.0f; + this->actor.shape.shadowScale = 13.0f; + func_8082E1F0(this, NA_SE_PL_DEKUNUTS_IN_GRD); + return true; + } + + return false; +} + +void Player_RequestQuake(PlayState* play, u16 speed, s16 y, s16 duration) { + s16 quakeIndex = Quake_Request(Play_GetCamera(play, CAM_ID_MAIN), QUAKE_TYPE_3); + + Quake_SetSpeed(quakeIndex, speed); + Quake_SetPerturbations(quakeIndex, y, 0, 0, 0); + Quake_SetDuration(quakeIndex, duration); +} + +FallImpactInfo sFallImpactInfos[] = { + { -8, 180, 40, 100, NA_SE_VO_LI_LAND_DAMAGE_S }, + { -16, 255, 140, 150, NA_SE_VO_LI_LAND_DAMAGE_S }, +}; + +// Player_FallAgainstTheFloor, Player_LetTheBodiesHitTheFloor, Player_ImpactFloor, Player_ProcessFallDamage, +// Player_DamageOnFloorImpact, Player_CalculateFallDamage +s32 func_80836F10(PlayState* play, Player* this) { + s32 fallDistance; + + if ((sPlayerCurrentFloorType == FLOOR_TYPE_6) || (sPlayerCurrentFloorType == FLOOR_TYPE_9) || + (this->csMode != PLAYER_CSMODE_0)) { + fallDistance = 0; + } else { + fallDistance = this->fallDistance; + } + + Math_StepToF(&this->linearVelocity, 0.0f, 1.0f); + this->stateFlags1 &= ~(PLAYER_STATE1_40000 | PLAYER_STATE1_80000); + + // Height enough for fall damage + if (fallDistance >= 400) { + s32 index; + FallImpactInfo* entry; + + if (this->fallDistance < 800) { + // small fall + index = 0; + } else { + // big fall + index = 1; + } + + Player_PlaySfx(this, NA_SE_PL_BODY_HIT); + + entry = &sFallImpactInfos[index]; + Player_AnimSfx_PlayVoice(this, entry->sfxId); + + if (Player_InflictDamage(play, entry->damage)) { + // Player's dead + return -1; + } + + func_80833998(this, 40); + Player_RequestQuake(play, 32967, 2, 30); + Player_RequestRumble(play, this, entry->sourceIntensity, entry->decayTimer, entry->decayStep, SQ(0)); + + return index + 1; + } + + // Tiny fall, won't damage player + if (fallDistance > 200) { + fallDistance = fallDistance * 2; + fallDistance = CLAMP_MAX(fallDistance, 255); + + Player_RequestRumble(play, this, fallDistance, fallDistance * 0.1f, fallDistance, SQ(0)); + if (sPlayerCurrentFloorType == FLOOR_TYPE_6) { + //! @bug unreachable code: When sPlayerCurrentFloorType is equal to FLOOR_TYPE_6 then fallDistance is + //! ignored (set to zero), so the previous check based on said variable will always fail, producing this + //! current check to always be false. + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_CLIMB_END); + } + } + + Player_AnimSfx_PlayFloorLand(this); + return 0; +} + +s32 func_808370D4(PlayState* play, Player* this) { + if ((this->fallDistance < 800) && (this->unk_AE3[this->unk_ADE] == 0) && !(this->stateFlags1 & PLAYER_STATE1_800)) { + func_80836B3C(play, this, 0.0f); + + return true; + } + return false; +} + +void func_80837134(PlayState* play, Player* this) { + PlayerAnimationHeader* anim = D_8085BE84[PLAYER_ANIMGROUP_13][this->modelAnimType]; + s32 temp_v0_2; // sp28 + + this->stateFlags1 &= ~(PLAYER_STATE1_40000 | PLAYER_STATE1_80000); + + if (this->transformation == PLAYER_FORM_DEKU) { + s32 var_v1 = false; + + if ((this->skelAnime.animation == &gPlayerAnim_pn_rakkafinish) || + (this->skelAnime.animation == &gPlayerAnim_pn_kakkufinish)) { + func_80836C70(play, this, PLAYER_BODYPART_LEFT_HAND); + func_80836C70(play, this, PLAYER_BODYPART_RIGHT_HAND); + var_v1 = true; + } + + if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A) && func_80836DC0(play, this)) { + return; + } + + if (var_v1) { + func_80836A98(this, anim, play); + Player_AnimSfx_PlayFloorLand(this); + return; + } + } else if (this->stateFlags2 & PLAYER_STATE2_80000) { + if (func_80123420(this)) { + anim = D_8085C2A4[this->unk_AE7].unk_8; + } else { + anim = D_8085C2A4[this->unk_AE7].unk_4; + } + } else if (this->skelAnime.animation == &gPlayerAnim_link_normal_run_jump) { + anim = &gPlayerAnim_link_normal_run_jump_end; + } else if (func_80123420(this)) { + anim = &gPlayerAnim_link_anchor_landingR; + func_8082FC60(this); + } else if (this->fallDistance <= 80) { + anim = D_8085BE84[PLAYER_ANIMGROUP_14][this->modelAnimType]; + } else if (func_808370D4(play, this)) { + return; + } + + temp_v0_2 = func_80836F10(play, this); + if (temp_v0_2 > 0) { // Player suffered damage because of this fall + func_80836A98(this, D_8085BE84[PLAYER_ANIMGROUP_13][this->modelAnimType], play); + this->skelAnime.endFrame = 8.0f; + + if (temp_v0_2 == 1) { + this->unk_AE8 = 0xA; + } else { + this->unk_AE8 = 0x14; + } + } else if (temp_v0_2 == 0) { + func_80836A98(this, anim, play); + } +} + +void func_808373A4(PlayState* play, Player* this) { + func_8082E438(play, this, &gPlayerAnim_pn_attack); + this->unk_B10[0] = 20000.0f; + this->unk_B10[1] = 0x30000; + Player_PlaySfx(this, NA_SE_PL_DEKUNUTS_ATTACK); +} + +s32 func_808373F8(PlayState* play, Player* this, u16 sfxId) { + PlayerAnimationHeader* anim; + f32 speed; + s16 yawDiff = this->currentYaw - this->actor.shape.rot.y; + + if ((IREG(66) / 100.0f) < this->linearVelocity) { + speed = IREG(67) / 100.0f; + } else { + speed = (IREG(68) / 100.0f + (IREG(69) * this->linearVelocity) / 1000.0f); + + if ((this->transformation == PLAYER_FORM_DEKU) && (speed < 8.0f)) { + speed = 8.0f; + } else if (speed < 5.0f) { + speed = 5.0f; + } + } + + if ((ABS_ALT(yawDiff) >= 0x1000) || (this->linearVelocity <= 4.0f)) { + anim = &gPlayerAnim_link_normal_jump; + } else { + s32 var_v1; + + if ((this->transformation != PLAYER_FORM_DEKU) && + (((sPlayerPrevFloorProperty == FLOOR_PROPERTY_1)) || (sPlayerPrevFloorProperty == FLOOR_PROPERTY_2))) { + if (sPlayerPrevFloorProperty == FLOOR_PROPERTY_1) { + var_v1 = 4; + } else { + var_v1 = 5; + } + + func_80834D50(play, this, D_8085C2A4[var_v1].unk_0, speed, ((var_v1 == 4) ? NA_SE_VO_LI_SWORD_N : sfxId)); + this->unk_AE8 = -1; + this->stateFlags2 |= PLAYER_STATE2_80000; + this->unk_AE7 = var_v1; + return true; + } + anim = &gPlayerAnim_link_normal_run_jump; + } + + // Deku hopping + if (this->transformation == PLAYER_FORM_DEKU) { + speed *= 0.3f + ((5 - this->remainingHopsCounter) * 0.18f); + if (speed < 4.0f) { + speed = 4.0f; + } + + if ((this->actor.depthInWater > 0.0f) && (this->remainingHopsCounter != 0)) { + this->actor.world.pos.y += this->actor.depthInWater; + func_80834D50(play, this, anim, speed, NA_SE_NONE); + this->unk_AE8 = 1; + this->stateFlags3 |= PLAYER_STATE3_200000; + Player_PlaySfx(this, (NA_SE_PL_DEKUNUTS_JUMP5 + 1 - this->remainingHopsCounter)); + Player_AnimSfx_PlayVoice(this, sfxId); + this->remainingHopsCounter--; + if (this->remainingHopsCounter == 0) { + this->stateFlags2 |= PLAYER_STATE2_80000; + func_808373A4(play, this); + } + + return true; + } + + if (this->actor.velocity.y > 0.0f) { + sfxId = NA_SE_NONE; + } + } + + func_80834D50(play, this, anim, speed, sfxId); + this->unk_AE8 = 1; + + return true; +} + +s32 func_80837730(PlayState* play, Player* this, f32 arg2, s32 scale) { + f32 sp3C = fabsf(arg2); + + if (sp3C > 2.0f) { + WaterBox* waterBox; + f32 sp34; + Vec3f pos; + + Math_Vec3f_Copy(&pos, &this->bodyPartsPos[PLAYER_BODYPART_WAIST]); + pos.y += 20.0f; + if (WaterBox_GetSurface1(play, &play->colCtx, pos.x, pos.z, &pos.y, &waterBox)) { + sp34 = pos.y - this->bodyPartsPos[PLAYER_BODYPART_LEFT_FOOT].y; + if ((sp34 > -2.0f) && (sp34 < 100.0f)) { + EffectSsGSplash_Spawn(play, &pos, NULL, NULL, + (sp3C <= 10.0f) ? EFFSSGSPLASH_TYPE_0 : EFFSSGSPLASH_TYPE_1, scale); + return true; + } + } + } + + return false; +} + +s32 func_8083784C(Player* this) { + if (this->actor.velocity.y < 0.0f) { + if ((this->actor.depthInWater > 0.0f) && + ((this->ageProperties->unk_2C - this->actor.depthInWater) < D_80862B18)) { + if ((this->remainingHopsCounter != 0) && (gSaveContext.save.saveInfo.playerData.health != 0) && + !(this->stateFlags1 & PLAYER_STATE1_4000000)) { + if (((this->talkActor == NULL) || !(this->talkActor->flags & ACTOR_FLAG_10000))) { + return true; + } + } + } + } + + return false; +} + +void func_808378FC(PlayState* play, Player* this) { + if (!func_8082FC24(this)) { + this->stateFlags2 |= PLAYER_STATE2_20; + } + + if (func_8083784C(this) && func_808373F8(play, this, NA_SE_VO_LI_AUTO_JUMP)) { + func_80837730(play, this, 20.0f, this->actor.velocity.y * 50.0f); + } +} + +s32 func_8083798C(Player* this) { + return (this->interactRangeActor != NULL) && (this->heldActor == NULL) && + (this->transformation != PLAYER_FORM_DEKU); +} + +void func_808379C0(PlayState* play, Player* this) { + if (func_8083798C(this)) { + Actor* interactRangeActor = this->interactRangeActor; + PlayerAnimationHeader* anim; + + if ((interactRangeActor->id == ACTOR_EN_ISHI) && (ENISHI_GET_1(interactRangeActor) != 0)) { + Player_SetAction(play, this, func_8084E334, 0); + anim = &gPlayerAnim_link_silver_carry; + } else if (((interactRangeActor->id == ACTOR_EN_BOMBF) || (interactRangeActor->id == ACTOR_EN_KUSA) || + (interactRangeActor->id == ACTOR_EN_KUSA2) || (interactRangeActor->id == ACTOR_OBJ_GRASS_CARRY)) && + (Player_GetStrength() <= PLAYER_STRENGTH_DEKU)) { + Player_SetAction(play, this, func_8084E4E4, 0); + anim = &gPlayerAnim_link_normal_nocarry_free; + + this->actor.world.pos.x = + (Math_SinS(interactRangeActor->yawTowardsPlayer) * 20.0f) + interactRangeActor->world.pos.x; + this->actor.world.pos.z = + (Math_CosS(interactRangeActor->yawTowardsPlayer) * 20.0f) + interactRangeActor->world.pos.z; + + this->currentYaw = this->actor.shape.rot.y = interactRangeActor->yawTowardsPlayer + 0x8000; + } else { + Player_SetAction(play, this, func_8084E25C, 0); + anim = D_8085BE84[PLAYER_ANIMGROUP_12][this->modelAnimType]; + } + + Player_AnimationPlayOnce(play, this, anim); + } else { + func_80836988(this, play); + this->stateFlags1 &= ~PLAYER_STATE1_800; + } +} + +void func_80837B60(PlayState* play, Player* this) { + func_8083172C(play, this, func_8084E980, 0); + + this->exchangeItemId = PLAYER_IA_NONE; + this->stateFlags1 |= (PLAYER_STATE1_40 | PLAYER_STATE1_20000000); + if (this->actor.textId != 0) { + Message_StartTextbox(play, this->actor.textId, this->talkActor); + } + this->targetedActor = this->talkActor; +} + +void func_80837BD0(PlayState* play, Player* this) { + func_8083172C(play, this, func_8084FE7C, 0); +} + +void func_80837BF8(PlayState* play, Player* this) { + Player_SetAction(play, this, func_8084ED9C, 0); +} + +void func_80837C20(PlayState* play, Player* this) { + s32 sp1C = this->unk_AE8; + s32 sp18 = this->unk_AE7; + + func_8083172C(play, this, func_8084F4E8, 0); + this->actor.velocity.y = 0.0f; + + this->unk_AE8 = sp1C; + this->unk_AE7 = sp18; +} + +void func_80837C78(PlayState* play, Player* this) { + func_8083172C(play, this, func_80852C04, 0); + this->stateFlags1 |= (PLAYER_STATE1_400 | PLAYER_STATE1_20000000); + + if (this->getItemId == GI_HEART_CONTAINER) { + this->unk_AE8 = 20; + } else if (this->getItemId >= GI_NONE) { + this->unk_AE8 = 1; + } else { + this->getItemId = -this->getItemId; + } +} + +void func_80837CEC(PlayState* play, Player* this, CollisionPoly* arg2, f32 arg3, PlayerAnimationHeader* anim) { + f32 nx = COLPOLY_GET_NORMAL(arg2->normal.x); + f32 nz = COLPOLY_GET_NORMAL(arg2->normal.z); + + Player_SetAction(play, this, func_8084F1B8, 0); + func_8082DE50(play, this); + Player_AnimationPlayOnce(play, this, anim); + + this->actor.world.pos.x -= (arg3 + 1.0f) * nx; + this->actor.world.pos.z -= (arg3 + 1.0f) * nz; + this->actor.shape.rot.y = Math_Atan2S_XY(nz, nx); + this->currentYaw = this->actor.shape.rot.y; + + func_8082DAD4(this); + this->actor.velocity.y = 0.0f; + func_8082E6D0(this); +} + +s32 func_80837DEC(Player* this, PlayState* play) { + if ((this->transformation != PLAYER_FORM_GORON) && (this->transformation != PLAYER_FORM_DEKU) && + (this->actor.depthInWater < -80.0f)) { + if ((ABS_ALT(this->unk_B6C)) < 0xAAA && (ABS_ALT(this->unk_B6E) < 0xAAA)) { + CollisionPoly* entityPoly; + CollisionPoly* sp90; + s32 entityBgId; + s32 sp88; + Vec3f sp7C; + Vec3f sp70; + f32 temp_fv1_2; + f32 entityNormalX; + f32 entityNormalY; + f32 entityNormalZ; + f32 temp_fv0_2; + f32 var_fv1; + + sp7C.x = this->actor.prevPos.x - this->actor.world.pos.x; + sp7C.z = this->actor.prevPos.z - this->actor.world.pos.z; + + var_fv1 = sqrtf(SQXZ(sp7C)); + if (var_fv1 != 0.0f) { + var_fv1 = 5.0f / var_fv1; + } else { + var_fv1 = 0.0f; + } + + sp7C.x = this->actor.prevPos.x + (sp7C.x * var_fv1); + sp7C.y = this->actor.world.pos.y; + sp7C.z = this->actor.prevPos.z + (sp7C.z * var_fv1); + + if (BgCheck_EntityLineTest2(&play->colCtx, &this->actor.world.pos, &sp7C, &sp70, &entityPoly, true, false, + false, true, &entityBgId, &this->actor)) { + if (ABS_ALT(entityPoly->normal.y) < 0x258) { + s32 var_v1_2; // sp54 + + entityNormalX = COLPOLY_GET_NORMAL(entityPoly->normal.x); + entityNormalY = COLPOLY_GET_NORMAL(entityPoly->normal.y); + entityNormalZ = COLPOLY_GET_NORMAL(entityPoly->normal.z); + + temp_fv0_2 = Math3D_UDistPlaneToPos(entityNormalX, entityNormalY, entityNormalZ, entityPoly->dist, + &this->actor.world.pos); + + sp70.x = this->actor.world.pos.x - ((temp_fv0_2 + 1.0f) * entityNormalX); + sp70.z = this->actor.world.pos.z - ((temp_fv0_2 + 1.0f) * entityNormalZ); + sp70.y = this->actor.world.pos.y + 268 * 0.1f; + + temp_fv1_2 = this->actor.world.pos.y - + BgCheck_EntityRaycastFloor5(&play->colCtx, &sp90, &sp88, &this->actor, &sp70); + if ((temp_fv1_2 >= -11.0f) && (temp_fv1_2 <= 0.0f)) { + var_v1_2 = sPlayerPrevFloorProperty == FLOOR_PROPERTY_6; + if (!var_v1_2) { + if (SurfaceType_GetWallFlags(&play->colCtx, entityPoly, entityBgId) & WALL_FLAG_3) { + var_v1_2 = true; + } + } + + func_80837CEC(play, this, entityPoly, temp_fv0_2, + var_v1_2 ? &gPlayerAnim_link_normal_Fclimb_startB + : &gPlayerAnim_link_normal_fall); + if (var_v1_2) { + func_80832558(play, this, func_80837C20); + + this->actor.shape.rot.y = this->currentYaw += 0x8000; + this->stateFlags1 |= PLAYER_STATE1_200000; + func_8082E920(play, this, + ANIM_FLAG_1 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_4 | ANIM_FLAG_8 | + ANIM_FLAG_NOMOVE | ANIM_FLAG_80); + this->unk_AE8 = -1; + this->unk_AE7 = var_v1_2; + } else { + this->stateFlags1 |= PLAYER_STATE1_2000; + this->stateFlags1 &= ~PLAYER_STATE1_20000; + } + + Player_PlaySfx(this, NA_SE_PL_SLIPDOWN); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_HANG); + return true; + } + } + } + } + } + + return false; +} + +void func_808381A0(Player* this, PlayerAnimationHeader* anim, PlayState* play) { + Player_SetAction(play, this, func_8084F3DC, 0); + PlayerAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, 1.3f); +} + +Vec3f D_8085D148 = { 0.0f, 50.0f, 0.0f }; + +s32 func_808381F8(PlayState* play, Player* this) { + CollisionPoly* poly; + s32 bgId; + Vec3f pos; + f32 yIntersect; + + Player_TranslateAndRotateY(this, &this->actor.prevPos, &D_8085D148, &pos); + + yIntersect = BgCheck_EntityRaycastFloor5(&play->colCtx, &poly, &bgId, &this->actor, &pos); + + return fabsf(yIntersect - this->actor.world.pos.y) < 10.0f; +} + +Vec3f D_8085D154 = { 0.0f, 0.0f, 100.0f }; + +void func_8083827C(Player* this, PlayState* play) { + s32 temp_t0; // sp64 + CollisionPoly* sp60; + s32 sp5C; + WaterBox* sp58; + Vec3f sp4C; + f32 sp48; + f32 sp44; + + this->fallDistance = this->fallStartHeight - (s32)this->actor.world.pos.y; + if (!(this->stateFlags1 & (PLAYER_STATE1_8000000 | PLAYER_STATE1_20000000)) && + ((this->stateFlags1 & PLAYER_STATE1_80000000) || + !(this->stateFlags3 & (PLAYER_STATE3_200 | PLAYER_STATE3_2000))) && + !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + if (func_80835428(play, this)) { + return; + } + + if (sPlayerPrevFloorProperty == FLOOR_PROPERTY_8) { + this->actor.world.pos.x = this->actor.prevPos.x; + this->actor.world.pos.z = this->actor.prevPos.z; + return; + } + + if ((this->stateFlags3 & PLAYER_STATE3_2) || (this->skelAnime.moveFlags & ANIM_FLAG_80)) { + return; + } + + if ((func_8084C16C == this->actionFunc) || (func_8084C94C == this->actionFunc) || + (func_8084CA24 == this->actionFunc) || (func_80857BE8 == this->actionFunc) || + (func_808546D0 == this->actionFunc) || (func_80854800 == this->actionFunc)) { + return; + } + + if ((sPlayerPrevFloorProperty == FLOOR_PROPERTY_7) || (this->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) || + ((this->skelAnime.moveFlags & ANIM_FLAG_8) && func_808381F8(play, this))) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + if (this->linearVelocity > 0.0f) { + Player_StopHorizontalMovement(this); + } + this->actor.bgCheckFlags |= BGCHECKFLAG_GROUND_TOUCH; + return; + } + + temp_t0 = BINANG_SUB(this->currentYaw, this->actor.shape.rot.y); + Player_SetAction(play, this, func_8084C16C, 1); + func_8082DD2C(play, this); + + this->floorSfxOffset = this->unk_D66; + if ((this->transformation != PLAYER_FORM_GORON) && + ((this->transformation != PLAYER_FORM_DEKU) || (this->remainingHopsCounter != 0)) && + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_LEAVE)) { + if (!(this->stateFlags1 & PLAYER_STATE1_8000000)) { + if ((sPlayerPrevFloorProperty != FLOOR_PROPERTY_6) && (sPlayerPrevFloorProperty != FLOOR_PROPERTY_9) && + (D_80862B18 > 20.0f) && (this->meleeWeaponState == PLAYER_MELEE_WEAPON_STATE_0)) { + if ((ABS_ALT(temp_t0) < 0x2000) && (this->linearVelocity > 3.0f)) { + if (!(this->stateFlags1 & PLAYER_STATE1_800)) { + if (((this->transformation == PLAYER_FORM_ZORA) && + CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A)) || + ((sPlayerPrevFloorProperty == FLOOR_PROPERTY_11) && + (this->transformation != PLAYER_FORM_GORON) && + (this->transformation != PLAYER_FORM_DEKU))) { + + sp48 = func_80835CD8(play, this, &D_8085D154, &sp4C, &sp60, &sp5C); + sp44 = this->actor.world.pos.y; + + if (WaterBox_GetSurface1(play, &play->colCtx, sp4C.x, sp4C.z, &sp44, &sp58) && + ((sp44 - sp48) > 50.0f)) { + func_80834DB8(this, &gPlayerAnim_link_normal_run_jump_water_fall, 6.0f, play); + Player_SetAction(play, this, func_8084C94C, 0); + return; + } + } + } + func_808373F8(play, this, NA_SE_VO_LI_AUTO_JUMP); + return; + } + } + } + } + + // Checking if the ledge is tall enough for Player to hang from + if ((sPlayerPrevFloorProperty == FLOOR_PROPERTY_9) || (D_80862B18 <= this->ageProperties->unk_34) || + !func_80837DEC(this, play)) { + Player_AnimationPlayLoop(play, this, &gPlayerAnim_link_normal_landing_wait); + } + } else { + this->fallStartHeight = this->actor.world.pos.y; + this->remainingHopsCounter = 5; + } +} + +s32 func_8083868C(PlayState* play, Player* this) { + s32 camMode; + Camera* camera; + + if (this->unk_AA5 == PLAYER_UNKAA5_3) { + if (func_800B7118(this)) { + if (this->transformation == PLAYER_FORM_HUMAN) { + camMode = CAM_MODE_SLINGSHOT; + } else if (this->transformation == PLAYER_FORM_DEKU) { + camMode = CAM_MODE_DEKUSHOOT; + } else { + camMode = CAM_MODE_BOWARROW; + } + } else { + camMode = CAM_MODE_ZORAFIN; + } + } else { + camMode = CAM_MODE_FIRSTPERSON; + } + + camera = (this->actor.id == ACTOR_PLAYER) ? Play_GetCamera(play, CAM_ID_MAIN) + : Play_GetCamera(play, ((EnTest3*)this)->subCamId); + + return Camera_ChangeMode(camera, camMode); +} + +void Player_StopCutscene(Player* this) { + if (this->csId > CS_ID_NONE) { + CutsceneManager_Stop(this->csId); + this->csId = CS_ID_NONE; + } +} + +s32 func_808387A0(PlayState* play, Player* this) { + if (this->unk_AA5 == PLAYER_UNKAA5_4) { + Player_StopCutscene(this); + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; + Player_SetAction(play, this, func_8085B08C, 0); + if (this->doorBgCamIndex != 0) { + this->stateFlags1 |= PLAYER_STATE1_20000000; + } + func_8082DC38(this); + + return true; + } + return false; +} + +void func_80838830(Player* this, s16 objectId) { + s32 pad[2]; + + if (objectId != OBJECT_UNSET_0) { + this->giObjectLoading = true; + osCreateMesgQueue(&this->giObjectLoadQueue, &this->giObjectLoadMsg, 1); + DmaMgr_SendRequestImpl(&this->giObjectDmaRequest, this->giObjectSegment, gObjectTable[objectId].vromStart, + gObjectTable[objectId].vromEnd - gObjectTable[objectId].vromStart, 0, + &this->giObjectLoadQueue, NULL); + } +} + +PlayerAnimationHeader* D_8085D160[PLAYER_FORM_MAX] = { + &gPlayerAnim_pz_maskoffstart, // PLAYER_FORM_FIERCE_DEITY + &gPlayerAnim_pg_maskoffstart, // PLAYER_FORM_GORON + &gPlayerAnim_pz_maskoffstart, // PLAYER_FORM_ZORA + &gPlayerAnim_pn_maskoffstart, // PLAYER_FORM_DEKU + &gPlayerAnim_cl_setmask, // PLAYER_FORM_HUMAN +}; + +void func_808388B8(PlayState* play, Player* this, PlayerTransformation playerForm) { + func_8082DE50(play, this); + func_80831760(play, this, func_808553F4, 0); + func_8082E4A4(play, this, D_8085D160[this->transformation]); + gSaveContext.save.playerForm = playerForm; + this->stateFlags1 |= PLAYER_STATE1_2; + + D_80862B50 = play->envCtx.lightSettings; + this->actor.velocity.y = 0.0f; + Actor_DeactivateLens(play); +} + +void func_808389BC(PlayState* play, Player* this) { + func_80831760(play, this, func_80855AF4, 0); + func_8082E4A4(play, this, &gPlayerAnim_cl_setmask); + this->stateFlags1 |= (PLAYER_STATE1_100 | PLAYER_STATE1_20000000); + func_8082DAD4(this); +} + +void func_80838A20(PlayState* play, Player* this) { + func_80831760(play, this, func_80855B9C, 0); + func_8082DB90(play, this, &gPlayerAnim_cl_maskoff); + this->currentMask = PLAYER_MASK_NONE; + this->stateFlags1 |= (PLAYER_STATE1_100 | PLAYER_STATE1_20000000); + func_8082DAD4(this); + Magic_Reset(play); +} + +u8 sPlayerMass[PLAYER_FORM_MAX] = { + 100, // PLAYER_FORM_FIERCE_DEITY + 200, // PLAYER_FORM_GORON + 80, // PLAYER_FORM_ZORA + 20, // PLAYER_FORM_DEKU + 50, // PLAYER_FORM_HUMAN +}; + +PlayerAnimationHeader* D_8085D17C[PLAYER_FORM_MAX] = { + &gPlayerAnim_link_normal_okarina_start, // PLAYER_FORM_FIERCE_DEITY + &gPlayerAnim_pg_gakkistart, // PLAYER_FORM_GORON + &gPlayerAnim_pz_gakkistart, // PLAYER_FORM_ZORA + &gPlayerAnim_pn_gakkistart, // PLAYER_FORM_DEKU + &gPlayerAnim_link_normal_okarina_start, // PLAYER_FORM_HUMAN +}; +PlayerAnimationHeader* D_8085D190[PLAYER_FORM_MAX] = { + &gPlayerAnim_link_normal_okarina_swing, // PLAYER_FORM_FIERCE_DEITY + &gPlayerAnim_pg_gakkiplay, // PLAYER_FORM_GORON + &gPlayerAnim_pz_gakkiplay, // PLAYER_FORM_ZORA + &gPlayerAnim_pn_gakkiplay, // PLAYER_FORM_DEKU + &gPlayerAnim_link_normal_okarina_swing, // PLAYER_FORM_HUMAN +}; + +u8 D_8085D1A4[PLAYER_IA_MAX] = { + GI_NONE, // PLAYER_IA_NONE + GI_NONE, // PLAYER_IA_LAST_USED + GI_NONE, // PLAYER_IA_FISHING_ROD + GI_SWORD_KOKIRI, // PLAYER_IA_SWORD_KOKIRI + GI_SWORD_RAZOR, // PLAYER_IA_SWORD_RAZOR + GI_SWORD_GILDED, // PLAYER_IA_SWORD_GILDED + GI_SWORD_GREAT_FAIRY, // PLAYER_IA_SWORD_TWO_HANDED + GI_STICKS_1, // PLAYER_IA_STICK + GI_SWORD_KOKIRI, // PLAYER_IA_ZORA_FINS + GI_QUIVER_30, // PLAYER_IA_BOW + GI_ARROW_FIRE, // PLAYER_IA_BOW_FIRE + GI_ARROW_ICE, // PLAYER_IA_BOW_ICE + GI_ARROW_LIGHT, // PLAYER_IA_BOW_LIGHT + GI_HOOKSHOT, // PLAYER_IA_HOOKSHOT + GI_BOMBS_1, // PLAYER_IA_BOMB + GI_POWDER_KEG, // PLAYER_IA_POWDER_KEG + GI_BOMBCHUS_10, // PLAYER_IA_BOMBCHU + GI_40, // PLAYER_IA_11 + GI_NUTS_1, // PLAYER_IA_NUT + GI_PICTO_BOX, // PLAYER_IA_PICTO_BOX + GI_OCARINA, // PLAYER_IA_OCARINA + GI_BOTTLE, // PLAYER_IA_BOTTLE_EMPTY + GI_FISH, // PLAYER_IA_BOTTLE_FISH + GI_75, // PLAYER_IA_BOTTLE_SPRING_WATER + GI_ICE_TRAP, // PLAYER_IA_BOTTLE_HOT_SPRING_WATER + GI_ZORA_EGG, // PLAYER_IA_BOTTLE_ZORA_EGG + GI_GOLD_DUST, // PLAYER_IA_BOTTLE_DEKU_PRINCESS + GI_6C, // PLAYER_IA_BOTTLE_GOLD_DUST + GI_SEAHORSE, // PLAYER_IA_BOTTLE_1C + GI_MUSHROOM, // PLAYER_IA_BOTTLE_SEAHORSE + GI_HYLIAN_LOACH, // PLAYER_IA_BOTTLE_MUSHROOM + GI_DEKU_PRINCESS, // PLAYER_IA_BOTTLE_HYLIAN_LOACH + GI_BUG, // PLAYER_IA_BOTTLE_BUG + GI_POE, // PLAYER_IA_BOTTLE_POE + GI_BIG_POE, // PLAYER_IA_BOTTLE_BIG_POE + GI_POTION_RED, // PLAYER_IA_BOTTLE_POTION_RED + GI_POTION_BLUE, // PLAYER_IA_BOTTLE_POTION_BLUE + GI_POTION_GREEN, // PLAYER_IA_BOTTLE_POTION_GREEN + GI_MILK_HALF, // PLAYER_IA_BOTTLE_MILK + GI_MILK_HALF, // PLAYER_IA_BOTTLE_MILK_HALF + GI_CHATEAU, // PLAYER_IA_BOTTLE_CHATEAU + GI_FAIRY, // PLAYER_IA_BOTTLE_FAIRY + GI_MOON_TEAR, // PLAYER_IA_MOON_TEAR + GI_DEED_LAND, // PLAYER_IA_DEED_LAND + GI_ROOM_KEY, // PLAYER_IA_ROOM_KEY + GI_LETTER_TO_KAFEI, // PLAYER_IA_LETTER_TO_KAFEI + GI_MAGIC_BEANS, // PLAYER_IA_MAGIC_BEANS + GI_DEED_SWAMP, // PLAYER_IA_DEED_SWAMP + GI_DEED_MOUNTAIN, // PLAYER_IA_DEED_MOUNTAIN + GI_DEED_OCEAN, // PLAYER_IA_DEED_OCEAN + GI_MOON_TEAR, // PLAYER_IA_32 + GI_LETTER_TO_MAMA, // PLAYER_IA_LETTER_MAMA + GI_A7, // PLAYER_IA_34 + GI_A8, // PLAYER_IA_35 + GI_PENDANT_OF_MEMORIES, // PLAYER_IA_PENDANT_OF_MEMORIES + GI_PENDANT_OF_MEMORIES, // PLAYER_IA_37 + GI_PENDANT_OF_MEMORIES, // PLAYER_IA_38 + GI_PENDANT_OF_MEMORIES, // PLAYER_IA_39 + GI_MASK_TRUTH, // PLAYER_IA_MASK_TRUTH + GI_MASK_KAFEIS_MASK, // PLAYER_IA_MASK_KAFEIS_MASK + GI_MASK_ALL_NIGHT, // PLAYER_IA_MASK_ALL_NIGHT + GI_MASK_BUNNY, // PLAYER_IA_MASK_BUNNY + GI_MASK_KEATON, // PLAYER_IA_MASK_KEATON + GI_MASK_GARO, // PLAYER_IA_MASK_GARO + GI_MASK_ROMANI, // PLAYER_IA_MASK_ROMANI + GI_MASK_CIRCUS_LEADER, // PLAYER_IA_MASK_CIRCUS_LEADER + GI_MASK_POSTMAN, // PLAYER_IA_MASK_POSTMAN + GI_MASK_COUPLE, // PLAYER_IA_MASK_COUPLE + GI_MASK_GREAT_FAIRY, // PLAYER_IA_MASK_GREAT_FAIRY + GI_MASK_GIBDO, // PLAYER_IA_MASK_GIBDO + GI_MASK_DON_GERO, // PLAYER_IA_MASK_DON_GERO + GI_MASK_KAMARO, // PLAYER_IA_MASK_KAMARO + GI_MASK_CAPTAIN, // PLAYER_IA_MASK_CAPTAIN + GI_MASK_STONE, // PLAYER_IA_MASK_STONE + GI_MASK_BREMEN, // PLAYER_IA_MASK_BREMEN + GI_MASK_BLAST, // PLAYER_IA_MASK_BLAST + GI_MASK_SCENTS, // PLAYER_IA_MASK_SCENTS + GI_MASK_GIANT, // PLAYER_IA_MASK_GIANT + GI_MASK_FIERCE_DEITY, // PLAYER_IA_MASK_FIERCE_DEITY + GI_MASK_GORON, // PLAYER_IA_MASK_GORON + GI_MASK_ZORA, // PLAYER_IA_MASK_ZORA + GI_MASK_DEKU, // PLAYER_IA_MASK_DEKU + GI_LENS, // PLAYER_IA_LENS +}; + +PlayerAnimationHeader* D_8085D1F8[] = { + &gPlayerAnim_link_normal_give_other, + &gPlayerAnim_link_normal_take_out, // Hold up cutscene item; "this item doesn't work here" +}; + +s32 func_80838A90(Player* this, PlayState* play) { + PlayerBottle bottleAction; + + if (this->unk_AA5 != PLAYER_UNKAA5_0) { + if (!(this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) && + !(this->stateFlags1 & PLAYER_STATE1_8000000) && !(this->stateFlags1 & PLAYER_STATE1_800000) && + !(this->stateFlags3 & PLAYER_STATE3_8) && !(this->skelAnime.moveFlags & ANIM_FLAG_8)) { + Player_StopCutscene(this); + func_80833AA0(this, play); + return true; + } + if (!func_808387A0(play, this)) { + if (this->unk_AA5 == PLAYER_UNKAA5_5) { + if ((this->itemAction >= PLAYER_IA_MASK_MIN) && (this->itemAction <= PLAYER_IA_MASK_MAX)) { + PlayerMask maskId = GET_MASK_FROM_IA(this->itemAction); + + this->prevMask = this->currentMask; + if (((maskId == this->currentMask) != 0) || (this->itemAction < PLAYER_IA_MASK_GIANT) || + ((this->itemAction == PLAYER_IA_MASK_GIANT) && (this->transformation != PLAYER_FORM_HUMAN))) { + if (maskId == this->currentMask) { + this->currentMask = PLAYER_MASK_NONE; + } else { + this->currentMask = maskId; + } + + if (this->transformation == PLAYER_FORM_HUMAN) { + func_80838A20(play, this); + return true; + } + + func_808388B8(play, this, PLAYER_FORM_HUMAN); + } else { + this->currentMask = maskId; + if (this->currentMask == PLAYER_MASK_GIANT) { + func_808389BC(play, this); + return true; + } + func_808388B8(play, this, this->itemAction - PLAYER_IA_MASK_FIERCE_DEITY); + } + gSaveContext.save.equippedMask = this->currentMask; + } else if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_TALK_REQUESTED) || + (this->itemAction == PLAYER_IA_PICTO_BOX) || + ((this->itemAction != this->unk_B2B) && + ((this->itemAction == PLAYER_IA_BOTTLE_BIG_POE) || + ((this->itemAction >= PLAYER_IA_BOTTLE_ZORA_EGG) && + (this->itemAction <= PLAYER_IA_BOTTLE_HYLIAN_LOACH)) || + (this->itemAction > PLAYER_IA_BOTTLE_FAIRY) || + ((this->talkActor != NULL) && (this->exchangeItemId > PLAYER_IA_NONE) && + (((this->exchangeItemId == PLAYER_IA_MAGIC_BEANS) && + (this->itemAction == PLAYER_IA_MAGIC_BEANS)) || + ((this->exchangeItemId != PLAYER_IA_MAGIC_BEANS) && + (Player_BottleFromIA(this, this->itemAction) > PLAYER_BOTTLE_NONE))))))) { + Actor* talkActor; + s32 heldItemTemp = this->itemAction; + + Player_StopCutscene(this); + this->itemAction = PLAYER_IA_NONE; + func_80831760(play, this, func_80853A5C, 0); + talkActor = this->talkActor; + this->itemAction = heldItemTemp; + this->csId = CS_ID_NONE; + + if ((talkActor != NULL) && (((this->exchangeItemId == PLAYER_IA_MAGIC_BEANS) && + (this->itemAction == PLAYER_IA_MAGIC_BEANS)) || + ((this->exchangeItemId != PLAYER_IA_MAGIC_BEANS) && + (this->exchangeItemId > PLAYER_IA_NONE)))) { + this->stateFlags1 |= (PLAYER_STATE1_20000000 | PLAYER_STATE1_40); + if (this->exchangeItemId == PLAYER_IA_MAGIC_BEANS) { + Inventory_ChangeAmmo(ITEM_MAGIC_BEANS, -1); + func_80831760(play, this, func_8084B4A8, 0); + this->currentYaw = talkActor->yawTowardsPlayer + 0x8000; + this->actor.shape.rot.y = this->currentYaw; + if (talkActor->xzDistToPlayer < 40.0f) { + func_8082DB90(play, this, &gPlayerAnim_link_normal_backspace); + func_8082E920(play, this, ANIM_FLAG_1 | ANIM_FLAG_8 | ANIM_FLAG_NOMOVE); + } else { + func_8082E438(play, this, D_8085BE84[31][this->modelAnimType]); + } + this->stateFlags1 |= PLAYER_STATE1_20000000; + this->unk_AE8 = 80; + this->unk_AE7 = -1; + this->targetedActor = this->talkActor; + } else { + this->csId = CS_ID_GLOBAL_TALK; + } + + talkActor->flags |= ACTOR_FLAG_TALK_REQUESTED; + this->actor.textId = 0; + this->targetedActor = this->talkActor; + } else { + this->stateFlags1 |= (PLAYER_STATE1_20000000 | PLAYER_STATE1_10000000 | PLAYER_STATE1_40); + this->csId = play->playerCsIds[PLAYER_CS_ID_ITEM_SHOW]; + this->unk_AE7 = 1; + this->actor.textId = 0xFE; + } + this->actor.flags |= ACTOR_FLAG_TALK_REQUESTED; + this->exchangeItemId = this->itemAction; + if (this->unk_AE7 >= 0) { + Player_AnimationPlayOnce(play, this, D_8085D1F8[this->unk_AE7]); + } + func_8082DAD4(this); + return true; + } else { + bottleAction = Player_BottleFromIA(this, this->itemAction); + + if (bottleAction > PLAYER_BOTTLE_NONE) { + Player_StopCutscene(this); + if (bottleAction >= PLAYER_BOTTLE_FAIRY) { + func_80831760(play, this, func_80853754, 0); + func_8082DB90(play, this, &gPlayerAnim_link_bottle_bug_out); + } else if ((bottleAction > PLAYER_BOTTLE_EMPTY) && (bottleAction < PLAYER_BOTTLE_POE)) { + func_80831760(play, this, func_80853850, 0); + func_8082DB90(play, this, &gPlayerAnim_link_bottle_fish_out); + this->csId = play->playerCsIds[PLAYER_CS_ID_ITEM_BOTTLE]; + } else { + func_80831760(play, this, func_80853194, 0); + func_8082E4A4(play, this, + (this->transformation == PLAYER_FORM_DEKU) + ? &gPlayerAnim_pn_drinkstart + : &gPlayerAnim_link_bottle_drink_demo_start); + } + } else { + Actor* actorUnkA90 = this->unk_A90; + + if ((actorUnkA90 == NULL) || (actorUnkA90->id == ACTOR_EN_ZOT) || + (actorUnkA90->csId == CS_ID_NONE)) { + if (!func_808323C0(this, play->playerCsIds[PLAYER_CS_ID_ITEM_OCARINA])) { + return false; + } + } else { + this->csId = CS_ID_NONE; + } + func_80831760(play, this, func_8085269C, 0); + if ((this->skelAnime.playSpeed < 0.0f) || + ((this->skelAnime.animation != D_8085D17C[this->transformation]) && + (this->skelAnime.animation != D_8085D190[this->transformation]))) { + func_8082DB90(play, this, D_8085D17C[this->transformation]); + } + this->stateFlags2 |= PLAYER_STATE2_8000000; + if (actorUnkA90 != NULL) { + this->actor.flags |= ACTOR_FLAG_20000000; + if (actorUnkA90->id == ACTOR_EN_ZOT) { + this->unk_A94 = -1.0f; + } else { + actorUnkA90->flags |= ACTOR_FLAG_20000000; + } + } + } + } + } else { + if (func_8083868C(play, this) != CAM_MODE_NORMAL) { + Player_StopCutscene(this); + if (!(this->stateFlags1 & PLAYER_STATE1_800000)) { + Player_SetAction(play, this, func_8084E724, 1); + this->unk_AE8 = 13; + func_80836D8C(this); + if (this->unk_AA5 == PLAYER_UNKAA5_2) { + play->actorCtx.flags |= ACTORCTX_FLAG_PICTO_BOX_ON; + } + } + this->stateFlags1 |= PLAYER_STATE1_100000; + play_sound(NA_SE_SY_CAMERA_ZOOM_UP); + Player_StopHorizontalMovement(this); + return true; + } + this->unk_AA5 = PLAYER_UNKAA5_0; + play_sound(NA_SE_SY_ERROR); + return false; + } + this->stateFlags1 |= (PLAYER_STATE1_20000000 | PLAYER_STATE1_10000000); + func_8082DAD4(this); + } + return true; + } + return false; +} + +s32 func_808391D8(Player* this, PlayState* play) { + if (gSaveContext.save.saveInfo.playerData.health != 0) { + Actor* talkActor = this->talkActor; + Actor* targetedActor = this->targetedActor; + Actor* var_a1 = NULL; + s32 var_t1 = false; + s32 var_t2 = false; + + if (this->tatlActor != NULL) { + var_t2 = + (targetedActor != NULL) && (CHECK_FLAG_ALL(targetedActor->flags, ACTOR_FLAG_1 | ACTOR_FLAG_40000) || + (targetedActor->hintId != TATL_HINT_ID_NONE)); + + if (var_t2 || (this->tatlTextId != 0)) { + //! @bug The comparison `((ABS_ALT(this->tatlTextId) & 0xFF00) != 0x10000)` always evaluates to `true` + var_t1 = (this->tatlTextId < 0) && ((ABS_ALT(this->tatlTextId) & 0xFF00) != 0x10000); + + if (var_t1 || !var_t2) { + var_a1 = this->tatlActor; + if (var_t1) { + targetedActor = NULL; + talkActor = NULL; + } + } else { + var_a1 = targetedActor; + } + } + } + + if ((talkActor != NULL) || (var_a1 != NULL)) { + if ((targetedActor == NULL) || (targetedActor == talkActor) || (targetedActor == var_a1)) { + if (!(this->stateFlags1 & PLAYER_STATE1_800) || + ((this->heldActor != NULL) && + (var_t1 || (talkActor == this->heldActor) || (var_a1 == this->heldActor) || + ((talkActor != NULL) && (talkActor->flags & ACTOR_FLAG_10000))))) { + if (((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + (this->stateFlags1 & PLAYER_STATE1_800000) || func_801242B4(this))) { + if (talkActor != NULL) { + if ((targetedActor == NULL) || (targetedActor == talkActor)) { + this->stateFlags2 |= PLAYER_STATE2_2; + } + + if (!CutsceneManager_IsNext(CS_ID_GLOBAL_TALK)) { + return false; + } + + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A) || + (talkActor->flags & ACTOR_FLAG_10000)) { + var_a1 = NULL; + } else if (var_a1 == NULL) { + return false; + } + } + + if (var_a1 != NULL) { + if (!var_t1) { + this->stateFlags2 |= PLAYER_STATE2_200000; + if (!CutsceneManager_IsNext(CS_ID_GLOBAL_TALK) || + !CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_CUP)) { + return false; + } + } + + talkActor = var_a1; + this->talkActor = NULL; + + if (var_t1 || !var_t2) { + var_a1->textId = ABS_ALT(this->tatlTextId); + } else if (var_a1->hintId != 0xFF) { + var_a1->textId = var_a1->hintId + 0x1900; + } + } + + this->currentMask = D_80862B2C; + gSaveContext.save.equippedMask = this->currentMask; + Player_TalkWithPlayer(play, talkActor); + return true; + } + } + } + } + } + + return false; +} + +s32 func_80839518(Player* this, PlayState* play) { + if (this->unk_AA5 != PLAYER_UNKAA5_0) { + func_80838A90(this, play); + return true; + } else if ((this->targetedActor != NULL) && + (CHECK_FLAG_ALL(this->targetedActor->flags, ACTOR_FLAG_1 | ACTOR_FLAG_40000) || + (this->targetedActor->hintId != TATL_HINT_ID_NONE))) { + this->stateFlags2 |= PLAYER_STATE2_200000; + } else if ((this->tatlTextId == 0) && !func_80123420(this) && + CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_CUP) && + !func_80831814(this, play, PLAYER_UNKAA5_1)) { + play_sound(NA_SE_SY_ERROR); + } + return false; +} + +// Jumpslash/Jumpkick start +void func_808395F0(PlayState* play, Player* this, PlayerMeleeWeaponAnimation meleeWeaponAnim, f32 linearVelocity, + f32 yVelocity) { + if (this->transformation == PLAYER_FORM_ZORA) { + linearVelocity *= 1.1f; + meleeWeaponAnim = PLAYER_MWA_ZORA_JUMPKICK_START; + yVelocity *= 0.9f; + } + + func_80833864(play, this, meleeWeaponAnim); + Player_SetAction(play, this, func_8084CB58, 0); + this->stateFlags3 |= PLAYER_STATE3_2; + this->linearVelocity = linearVelocity; + this->currentYaw = this->actor.shape.rot.y; + this->actor.velocity.y = yVelocity; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; + Player_AnimSfx_PlayFloorJump(this); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_SWORD_L); +} + +s32 func_808396B8(PlayState* play, Player* this) { + if (!(this->stateFlags1 & PLAYER_STATE1_400000) && + (((this->actor.id != ACTOR_PLAYER) && CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_B)) || + ((Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE) && + ((this->transformation != PLAYER_FORM_GORON) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) && + ((this->transformation != PLAYER_FORM_ZORA) || !(this->stateFlags1 & PLAYER_STATE1_2000000)) && + (D_80862B48 != 0)))) { + return true; + } + + return false; +} + +s32 func_80839770(Player* this, PlayState* play) { + if (func_808396B8(play, this)) { + if ((this->transformation != PLAYER_FORM_GORON) && (sPlayerCurrentFloorType != FLOOR_TYPE_7)) { + func_808395F0(play, this, + (this->transformation == PLAYER_FORM_ZORA) ? PLAYER_MWA_ZORA_JUMPKICK_START + : PLAYER_MWA_JUMPSLASH_START, + 3.0f, 4.5f); + return true; + } + } + return false; +} + +s32 func_80839800(Player* this, PlayState* play) { + if ((this->unk_AE3[this->unk_ADE] == 0) && (sPlayerCurrentFloorType != FLOOR_TYPE_7)) { + func_80836B3C(play, this, 0.0f); + return true; + } + return false; +} + +void func_80839860(Player* this, PlayState* play, s32 arg2) { + s32 pad; + f32 speed = (!(arg2 & 1) ? 5.8f : 3.5f); + + if (this->currentBoots == PLAYER_BOOTS_GIANT) { + speed /= 2.0f; + } + + //! FAKE + if (arg2 == 2) {} + + func_80834D50(play, this, D_8085C2A4[arg2].unk_0, speed, NA_SE_VO_LI_SWORD_N); + + this->unk_AE8 = 1; + this->unk_AE7 = arg2; + + this->currentYaw = this->actor.shape.rot.y + (arg2 << 0xE); + this->linearVelocity = !(arg2 & 1) ? 6.0f : 8.5f; + + this->stateFlags2 |= PLAYER_STATE2_80000; + Player_PlaySfx(this, ((arg2 << 0xE) == 0x8000) ? NA_SE_PL_ROLL : NA_SE_PL_SKIP); +} + +void func_80839978(PlayState* play, Player* this) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->itemAction = PLAYER_IA_OCARINA; + func_80831760(play, this, func_8084AC84, 0); + func_8082DB60(play, this, &gPlayerAnim_clink_normal_okarina_walk); + func_8082E920(play, this, ANIM_FLAG_4 | ANIM_FLAG_200); + this->stateFlags3 |= PLAYER_STATE3_20000000; + this->unk_B48 = this->linearVelocity; + Audio_PlayFanfare(NA_BGM_BREMEN_MARCH); + } +} + +void func_80839A10(PlayState* play, Player* this) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->itemAction = PLAYER_IA_NONE; + func_80831760(play, this, func_8084AEEC, 0); + func_8082DB60(play, this, &gPlayerAnim_alink_dance_loop); + this->stateFlags2 |= PLAYER_STATE2_2000000; + Audio_PlayFanfare(NA_BGM_KAMARO_DANCE); + } +} + +s32 func_80839A84(PlayState* play, Player* this) { + if (this->transformation == PLAYER_FORM_DEKU) { + if (func_80836DC0(play, this)) { + return true; + } + } else { + return false; + } + + Player_SetAction(play, this, func_808573A4, 0); + this->stateFlags1 &= ~(PLAYER_STATE1_20000 | PLAYER_STATE1_40000000); + this->unk_ADC = 4; + func_808373A4(play, this); + return true; +} + +s32 func_80839B18(Player* this, PlayState* play) { + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A) && + (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && (sPlayerCurrentFloorType != FLOOR_TYPE_7) && + (D_80862B40 != FLOOR_EFFECT_1)) { + s32 temp_a2 = this->unk_AE3[this->unk_ADE]; + + if (temp_a2 <= 0) { + if (func_8082FBE8(this)) { + if (this->actor.category != ACTORCAT_PLAYER) { + if (temp_a2 < 0) { + func_80834DB8(this, &gPlayerAnim_link_normal_jump, REG(69) / 100.0f, play); + } else { + func_80836B3C(play, this, 0.0f); + } + } else if (!(this->stateFlags1 & PLAYER_STATE1_8000000) && + (Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE) && func_80832090(this) && + (this->transformation != PLAYER_FORM_GORON)) { + func_808395F0(play, this, PLAYER_MWA_JUMPSLASH_START, 5.0f, 5.0f); + } else if (!func_80839A84(play, this)) { + func_80836B3C(play, this, 0.0f); + } + + return true; + } + } else { + func_80839860(this, play, temp_a2); + return true; + } + } + + return false; +} + +void func_80839CD8(Player* this, PlayState* play) { + PlayerAnimationHeader* anim; + f32 var_fv0 = this->unk_B38 - 3.0f; + + if (var_fv0 < 0.0f) { + var_fv0 += 29.0f; + } + + if (var_fv0 < 14.0f) { + anim = D_8085BE84[PLAYER_ANIMGROUP_17][this->modelAnimType]; + var_fv0 = 11.0f - var_fv0; + if (var_fv0 < 0.0f) { + var_fv0 = -var_fv0 * 1.375f; + } + var_fv0 = var_fv0 / 11.0f; + } else { + anim = D_8085BE84[PLAYER_ANIMGROUP_18][this->modelAnimType]; + var_fv0 = 26.0f - var_fv0; + if (var_fv0 < 0.0f) { + var_fv0 = -var_fv0 * 2; + } + var_fv0 = var_fv0 / 12.0f; + } + + PlayerAnimation_Change(play, &this->skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, + 4.0f * var_fv0); + this->currentYaw = this->actor.shape.rot.y; +} + +void func_80839E3C(Player* this, PlayState* play) { + func_808369F4(this, play); + func_80839CD8(this, play); +} + +void func_80839E74(Player* this, PlayState* play) { + Player_SetAction(play, this, func_80849FE0, 1); + Player_AnimationPlayOnce(play, this, func_8082ED20(this)); + this->currentYaw = this->actor.shape.rot.y; +} + +void func_80839ED0(Player* this, PlayState* play) { + if (!(this->stateFlags3 & PLAYER_STATE3_80) && (func_80852B28 != this->actionFunc) && !func_8083213C(this)) { + func_80836D8C(this); + if (!(this->stateFlags1 & PLAYER_STATE1_40)) { + if (func_801242B4(this)) { + func_808353DC(play, this); + } else { + func_80836988(this, play); + } + } + if (this->unk_AA5 < PLAYER_UNKAA5_5) { + this->unk_AA5 = PLAYER_UNKAA5_0; + } + } + this->stateFlags1 &= ~(PLAYER_STATE1_4 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_100000); +} + +s32 func_80839F98(PlayState* play, Player* this) { + if (!(this->stateFlags1 & PLAYER_STATE1_8000000)) { + if (this->linearVelocity != 0.0f) { + func_80836B3C(play, this, 0.0f); + return true; + } + func_80836AD8(play, this); + PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_pg_maru_change, 2.0f / 3.0f, 0.0f, 7.0f, + ANIMMODE_ONCE, 0.0f); + return true; + } + return false; +} + +// Toggles swimming/walking underwater as Zora +void func_8083A04C(Player* this) { + if (this->currentBoots == PLAYER_BOOTS_ZORA_UNDERWATER) { + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A)) { + this->currentBoots = PLAYER_BOOTS_ZORA_LAND; + } + if (func_808508C8 == this->actionFunc) { + this->unk_AE8 = 20; + } + } else { + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_B)) { + this->currentBoots = PLAYER_BOOTS_ZORA_UNDERWATER; + } + } +} + +s32 func_8083A0CC(Player* this, PlayState* play) { + if (!D_80862B04 && (this->transformation == PLAYER_FORM_ZORA)) { + func_8083A04C(this); + } + return false; +} + +s32 func_8083A114(Player* this, PlayState* play) { + if (!D_80862B04 && !(this->stateFlags1 & PLAYER_STATE1_800000) && !func_8082FB68(this)) { + if ((this->transformation == PLAYER_FORM_ZORA) && (this->stateFlags1 & PLAYER_STATE1_8000000)) { + func_8083A04C(this); + } else if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A) && !func_8082FB68(this)) { + if (this->transformation == PLAYER_FORM_GORON) { + if (func_80839F98(play, this)) { + return true; + } + } else if (func_80839A84(play, this) || func_80839800(this, play)) { + return true; + } + + if ((this->putAwayCountdown == 0) && (this->heldItemAction >= PLAYER_IA_SWORD_KOKIRI) && + (this->transformation != PLAYER_FORM_FIERCE_DEITY)) { + func_80831990(play, this, ITEM_NONE); + } else { + this->stateFlags2 ^= PLAYER_STATE2_100000; + } + } + } + + return false; +} + +s32 func_8083A274(Player* this, PlayState* play) { + if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_R) && (this->unk_AA5 == PLAYER_UNKAA5_0) && + (play->unk_1887C == 0)) { + if (Player_IsGoronOrDeku(this) || + ((((this->transformation == PLAYER_FORM_ZORA) && !(this->stateFlags1 & PLAYER_STATE1_2000000)) || + ((this->transformation == PLAYER_FORM_HUMAN) && (this->currentShield != PLAYER_SHIELD_NONE))) && + !func_80123434(this) && (this->targetedActor == NULL))) { + func_8082DC38(this); + func_8082DCA0(play, this); + if (Player_SetAction(play, this, func_8084B5C0, 0)) { + this->stateFlags1 |= PLAYER_STATE1_400000; + if (this->transformation != PLAYER_FORM_GORON) { + PlayerAnimationHeader* anim; + f32 endFrame; + + if (!Player_IsGoronOrDeku(this)) { + Player_SetModelsForHoldingShield(this); + anim = D_8085BE84[PLAYER_ANIMGROUP_19][this->modelAnimType]; + } else { + anim = (this->transformation == PLAYER_FORM_DEKU) ? &gPlayerAnim_pn_gurd + : &gPlayerAnim_clink_normal_defense_ALL; + } + + if (anim != this->skelAnime.animation) { + if (func_80123420(this)) { + this->unk_B3C = 1.0f; + } else { + this->unk_B3C = 0.0f; + func_8082FC60(this); + } + this->upperLimbRot.x = 0; + this->upperLimbRot.y = 0; + this->upperLimbRot.z = 0; + } + + endFrame = Animation_GetLastFrame(anim); + PlayerAnimation_Change(play, &this->skelAnime, anim, 2.0f / 3.0f, + (anim == &gPlayerAnim_pn_gurd) ? 0.0f : endFrame, endFrame, ANIMMODE_ONCE, + 0.0f); + } + func_80830AE8(this); + } + + return true; + } + } + + return false; +} + +s32 func_8083A4A4(Player* this, f32* arg1, s16* arg2, f32 arg3) { + s16 yaw = this->currentYaw - *arg2; + + if (ABS_ALT(yaw) > 0x6000) { + if (Math_StepToF(&this->linearVelocity, 0.0f, arg3)) { + *arg1 = 0.0f; + *arg2 = this->currentYaw; + } else { + return true; + } + } + return false; +} + +void func_8083A548(Player* this) { + if ((this->unk_ADC > 0) && !CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_B)) { + this->unk_ADC = -this->unk_ADC; + } +} + +s32 func_8083A580(Player* this, PlayState* play) { + if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_B)) { + if (!(this->stateFlags1 & PLAYER_STATE1_400000) && + (Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE)) { + if ((this->unk_ADC > 0) && (((this->transformation == PLAYER_FORM_ZORA)) || + ((this->unk_ADC == 1) && (this->heldItemAction != PLAYER_IA_STICK)))) { + if (this->transformation == PLAYER_FORM_ZORA) { + func_80830E30(this, play); + } else { + func_808335B0(play, this); + } + return true; + } + } + } else { + func_8083A548(this); + } + return false; +} + +s32 func_8083A658(PlayState* play, Player* this) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + Player_SetAction(play, this, func_80852B28, 0); + Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_normal_light_bom); + this->unk_AA5 = PLAYER_UNKAA5_0; + return true; + } + return false; +} + +struct_8085D200 D_8085D200[] = { + { &gPlayerAnim_link_bottle_bug_miss, &gPlayerAnim_link_bottle_bug_in, 2, 3 }, + { &gPlayerAnim_link_bottle_fish_miss, &gPlayerAnim_link_bottle_fish_in, 5, 3 }, +}; + +s32 func_8083A6C0(PlayState* play, Player* this) { + if (D_80862B48 != 0) { + if (Player_GetBottleHeld(this) > PLAYER_BOTTLE_NONE) { + Player_SetAction(play, this, func_808534C0, 0); + if (this->actor.depthInWater > 12.0f) { + this->unk_AE8 = 1; + } + func_8082DB90(play, this, D_8085D200[this->unk_AE8].unk_0); + Player_PlaySfx(this, NA_SE_IT_SWORD_SWING); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_AUTO_JUMP); + return true; + } + return false; + } + return false; +} + +void func_8083A794(Player* this, PlayState* play) { + if ((func_8084AF9C != this->actionFunc) && (func_8084B0EC != this->actionFunc)) { + this->unk_B70 = 0; + this->unk_B34 = 0.0f; + this->unk_B38 = 0.0f; + func_8082E514(play, this, D_8085BE84[PLAYER_ANIMGROUP_2][this->modelAnimType]); + } + + Player_SetAction(play, this, func_8082FBE8(this) ? func_8084B0EC : func_8084AF9C, 1); +} + +void func_8083A844(Player* this, PlayState* play, s16 currentYaw) { + this->currentYaw = currentYaw; + this->actor.shape.rot.y = this->currentYaw; + func_8083A794(this, play); +} + +s32 func_8083A878(PlayState* play, Player* this, f32 arg2) { + WaterBox* waterBox; + f32 ySurface = this->actor.world.pos.y; + + if (WaterBox_GetSurface1(play, &play->colCtx, this->actor.world.pos.x, this->actor.world.pos.z, &ySurface, + &waterBox)) { + ySurface -= this->actor.world.pos.y; + if (this->ageProperties->unk_24 <= ySurface) { + Player_SetAction(play, this, func_80850B18, 0); + func_8082E634(play, this, &gPlayerAnim_link_swimer_swim); + this->stateFlags1 |= (PLAYER_STATE1_8000000 | PLAYER_STATE1_20000000); + this->unk_AE8 = 20; + this->linearVelocity = 2.0f; + func_80123140(play, this); + return false; + } + } + func_80835324(play, this, arg2, this->actor.shape.rot.y); + this->stateFlags1 |= PLAYER_STATE1_20000000; + return true; +} + +/** + * Update for using telescopes. SCENE_AYASHIISHOP acts quite differently: it has a different camera mode and cannot use + * zooming. + * + * - Stick inputs move the view; shape.rot.y is used as a base position which cannot be looked too far away from. (This + * is not necessarily the same as the original angle of the spawn.) + * - A can be used to zoom (except in SCENE_AYASHIISHOP) + * - B exits, using the RESPAWN_MODE_DOWN entrance + */ +void func_8083A98C(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + Player* this = THIS; + s32 camMode; + + if (play->csCtx.state != CS_STATE_IDLE) { + return; + } + + if (DECR(this->unk_AE8) != 0) { + camMode = (play->sceneId != SCENE_AYASHIISHOP) ? CAM_MODE_FIRSTPERSON : CAM_MODE_DEKUHIDE; + + // Show controls overlay. SCENE_AYASHIISHOP does not have Zoom, so has a different one. + if (this->unk_AE8 == 1) { + Message_StartTextbox(play, (play->sceneId == SCENE_AYASHIISHOP) ? 0x2A00 : 0x5E6, NULL); + } + } else { + sPlayerControlInput = play->state.input; + if (play->view.fovy >= 25.0f) { + s16 prevFocusX = thisx->focus.rot.x; + s16 prevFocusY = thisx->focus.rot.y; + s16 inputY; + s16 inputX; + s16 newYaw; // from base position shape.rot.y + + // Pitch: + inputY = sPlayerControlInput->rel.stick_y * 4; + // Add input, clamped to prevent turning too fast + thisx->focus.rot.x += CLAMP(inputY, -0x12C, 0x12C); + // Prevent looking too far up or down + thisx->focus.rot.x = CLAMP(thisx->focus.rot.x, -0x2EE0, 0x2EE0); + + // Yaw: shape.rot.y is used as a fixed starting position + inputX = sPlayerControlInput->rel.stick_x * -4; + // Start from current position: no input -> no change + newYaw = thisx->focus.rot.y - thisx->shape.rot.y; + // Add input, clamped to prevent turning too fast + newYaw += CLAMP(inputX, -0x12C, 0x12C); + // Prevent looking too far left or right of base position + newYaw = CLAMP(newYaw, -0x3E80, 0x3E80); + thisx->focus.rot.y = thisx->shape.rot.y + newYaw; + + if (play->sceneId == SCENE_00KEIKOKU) { + f32 focusDeltaX = (s16)(thisx->focus.rot.x - prevFocusX); + f32 focusDeltaY = (s16)(thisx->focus.rot.y - prevFocusY); + + func_8019FAD8(&gSfxDefaultPos, NA_SE_PL_TELESCOPE_MOVEMENT - SFX_FLAG, + sqrtf(SQ(focusDeltaX) + SQ(focusDeltaY)) / 300.0f); + } + } + + if (play->sceneId == SCENE_AYASHIISHOP) { + camMode = CAM_MODE_DEKUHIDE; + } else if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A)) { // Zoom + camMode = CAM_MODE_TARGET; + } else { + camMode = CAM_MODE_NORMAL; + } + + // Exit + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_B)) { + Message_CloseTextbox(play); + + if (play->sceneId == SCENE_00KEIKOKU) { + gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = ENTRANCE(ASTRAL_OBSERVATORY, 2); + } else { + u16 entrance; + + if (play->sceneId == SCENE_AYASHIISHOP) { + entrance = ENTRANCE(CURIOSITY_SHOP, 3); + } else { + entrance = ENTRANCE(PIRATES_FORTRESS_INTERIOR, 8); + } + gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = entrance; + } + + func_80169EFC(&play->state); + gSaveContext.respawnFlag = -2; + play->transitionType = TRANS_TYPE_CIRCLE; + } + } + + Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_TELESCOPE); + Camera_ChangeMode(Play_GetCamera(play, CAM_ID_MAIN), camMode); +} + +// Set up using a telescope +void Player_InitMode_Telescope(PlayState* play, Player* this) { + this->actor.update = func_8083A98C; + this->actor.draw = NULL; + if (play->sceneId == SCENE_00KEIKOKU) { + this->actor.focus.rot.x = 0xBD8; + this->actor.focus.rot.y = -0x4D74; + this->unk_AE8 = 20; + } else if (play->sceneId == SCENE_AYASHIISHOP) { + this->actor.focus.rot.x = 0x9A6; + this->actor.focus.rot.y = 0x2102; + this->unk_AE8 = 2; + } else { + this->actor.focus.rot.x = 0x9A6; + this->actor.focus.rot.y = 0x2102; + this->unk_AE8 = 20; + } + play->actorCtx.flags |= ACTORCTX_FLAG_1; +} + +void Player_InitMode_B(PlayState* play, Player* this) { + func_8085B384(this, play); +} + +void Player_InitMode_D(PlayState* play, Player* this) { + if (func_8083A878(play, this, 180.0f)) { + this->unk_AE8 = -20; + } +} + +// InitModes 0xA and 0xE +void func_8083ADF0(PlayState* play, Player* this) { + this->linearVelocity = 2.0f; + gSaveContext.entranceSpeed = 2.0f; + + if (func_8083A878(play, this, 120.0f)) { + this->unk_AE8 = -15; + } +} + +void Player_InitMode_F(PlayState* play, Player* this) { + if (gSaveContext.entranceSpeed < 0.1f) { + gSaveContext.entranceSpeed = 0.1f; + } + + this->linearVelocity = gSaveContext.entranceSpeed; + if (func_8083A878(play, this, 800.0f)) { + this->unk_AE8 = -80.0f / this->linearVelocity; + if (this->unk_AE8 < -20) { + this->unk_AE8 = -20; + } + } +} + +void func_8083AECC(Player* this, s16 currentYaw, PlayState* play) { + Player_SetAction(play, this, func_8084A5C0, 1); + PlayerAnimation_CopyJointToMorph(play, &this->skelAnime); + this->unk_B38 = 0.0f; + this->unk_B34 = 0.0f; + this->currentYaw = currentYaw; +} + +void func_8083AF30(Player* this, PlayState* play) { + Player_SetAction(play, this, func_8084A26C, 1); + func_8082E514(play, this, D_8085BE84[PLAYER_ANIMGROUP_1][this->modelAnimType]); +} + +void func_8083AF8C(Player* this, s16 currentYaw, PlayState* play) { + Player_SetAction(play, this, func_8084B288, 1); + PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_anchor_back_walk, 1.0f, 0.0f, + Animation_GetLastFrame(&gPlayerAnim_link_anchor_back_walk), ANIMMODE_ONCE, -6.0f); + this->linearVelocity = 8.0f; + this->currentYaw = currentYaw; +} + +void func_8083B030(Player* this, PlayState* play) { + Player_SetAction(play, this, func_8084A8E8, 1); + func_8082E514(play, this, D_8085BE84[PLAYER_ANIMGROUP_24][this->modelAnimType]); + this->unk_B38 = 0.0f; +} + +void func_8083B090(Player* this, PlayState* play) { + Player_SetAction(play, this, func_8084B3B8, 1); + PlayerAnimation_PlayOnceSetSpeed(play, &this->skelAnime, &gPlayerAnim_link_anchor_back_brake, 6.0f / 3.0f); +} + +void func_8083B0E4(PlayState* play, Player* this, s16 currentYaw) { + this->currentYaw = currentYaw; + Player_SetAction(play, this, func_8084AB4C, 1); + this->unk_B4E = 1200; + this->unk_B4E *= D_8085C3E4; + PlayerAnimation_Change(play, &this->skelAnime, D_8085BE84[PLAYER_ANIMGROUP_25][this->modelAnimType], 1.0f, 0.0f, + 0.0f, ANIMMODE_LOOP, -6.0f); +} + +void func_8083B1A0(Player* this, PlayState* play) { + PlayerAnimationHeader* anim; + + Player_SetAction(play, this, func_80849FE0, 1); + if (this->unk_B40 < 0.5f) { + anim = D_8085BE84[PLAYER_ANIMGROUP_27][this->modelAnimType]; + } else { + anim = D_8085BE84[PLAYER_ANIMGROUP_26][this->modelAnimType]; + } + Player_AnimationPlayOnce(play, this, anim); + this->currentYaw = this->actor.shape.rot.y; +} + +void func_8083B23C(Player* this, PlayState* play) { + Player_SetAction(play, this, func_80849A9C, 1); + func_8082E438(play, this, D_8085BE84[PLAYER_ANIMGROUP_6][this->modelAnimType]); + this->unk_AE8 = 1; +} + +void func_8083B29C(Player* this, PlayState* play) { + if (this->linearVelocity != 0.0f) { + func_8083A794(this, play); + } else { + func_8083B1A0(this, play); + } +} + +void func_8083B2E4(Player* this, PlayState* play) { + if (this->linearVelocity != 0.0f) { + func_8083A794(this, play); + } else { + func_80836988(this, play); + } +} + +void func_8083B32C(PlayState* play, Player* this, f32 arg2) { + this->stateFlags1 |= PLAYER_STATE1_40000; + this->stateFlags1 &= ~PLAYER_STATE1_8000000; + func_8082DC64(play, this); + + if (func_80837730(play, this, arg2, 500)) { + Player_PlaySfx(this, NA_SE_EV_JUMP_OUT_WATER); + } + func_80123140(play, this); +} + +s32 func_8083B3B4(PlayState* play, Player* this, Input* input) { + if ((!(this->stateFlags1 & PLAYER_STATE1_400) && !(this->stateFlags2 & PLAYER_STATE2_400) && + (this->transformation != PLAYER_FORM_ZORA)) && + ((input == NULL) || + ((((this->interactRangeActor == NULL) || (this->interactRangeActor->id != ACTOR_EN_ZOG)) && + CHECK_BTN_ALL(input->press.button, BTN_A)) && + ((ABS_ALT(this->unk_AAA) < 0x2EE0) && (this->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER) && + ((s32)SurfaceType_GetConveyorSpeed(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) <= + CONVEYOR_SPEED_SLOW))))) { + if (func_8085B08C != this->actionFunc) { + Player_SetAction(play, this, func_808516B4, 0); + } + + Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_swimer_swim_deep_start); + this->unk_AAA = 0; + this->stateFlags2 |= PLAYER_STATE2_400; + this->actor.velocity.y = 0.0f; + if (input != NULL) { + this->stateFlags2 |= PLAYER_STATE2_800; + Player_PlaySfx(this, NA_SE_PL_DIVE_BUBBLE); + } + + return true; + } + + if ((this->transformation != PLAYER_FORM_DEKU) && + ((this->stateFlags1 & PLAYER_STATE1_400) || + ((this->stateFlags2 & PLAYER_STATE2_400) && + (((func_80850D68 != this->actionFunc) && !(this->stateFlags3 & PLAYER_STATE3_8000)) || + (this->unk_AAA < -0x1555)))) && + ((this->actor.depthInWater - this->actor.velocity.y) < this->ageProperties->unk_30)) { + s32 temp_v0_3; + s16 sp2A; + f32 sp24; + + this->stateFlags2 &= ~PLAYER_STATE2_400; + func_8082DC64(play, this); + temp_v0_3 = func_80837730(play, this, this->actor.velocity.y, 0x1F4); + if (this->stateFlags3 & PLAYER_STATE3_8000) { + sp2A = this->unk_B86[1]; + sp24 = this->unk_B48 * 1.5f; + Player_SetAction(play, this, func_8084CA24, 1); + this->stateFlags3 |= PLAYER_STATE3_8000; + this->stateFlags1 &= ~PLAYER_STATE1_8000000; + sp24 = CLAMP_MAX(sp24, 13.5f); + this->linearVelocity = Math_CosS(this->unk_AAA) * sp24; + this->actor.velocity.y = -Math_SinS(this->unk_AAA) * sp24; + this->unk_B86[1] = sp2A; + Player_PlaySfx(this, NA_SE_EV_JUMP_OUT_WATER); + return true; + } + + if (temp_v0_3) { + Player_PlaySfx(this, NA_SE_PL_FACE_UP); + } else { + Player_PlaySfx(this, NA_SE_PL_FACE_UP); + } + + if (input != NULL) { + Player_SetAction(play, this, func_808519FC, 1); + if (this->stateFlags1 & PLAYER_STATE1_400) { + this->stateFlags1 |= (PLAYER_STATE1_400 | PLAYER_STATE1_800 | PLAYER_STATE1_20000000); + } + this->unk_AE8 = 2; + } + + func_8082E438(play, this, + (this->stateFlags1 & PLAYER_STATE1_800) ? &gPlayerAnim_link_swimer_swim_get + : &gPlayerAnim_link_swimer_swim_deep_end); + return true; + } + + return false; +} + +void func_8083B73C(PlayState* play, Player* this, s16 currentYaw) { + Player_SetAction(play, this, func_808513EC, 0); + func_8082E634(play, this, &gPlayerAnim_link_swimer_swim); + this->actor.shape.rot.y = currentYaw; + this->currentYaw = currentYaw; +} + +void func_8083B798(PlayState* play, Player* this) { + if (this->transformation == PLAYER_FORM_ZORA) { + Player_SetAction(play, this, func_808513EC, 0); + PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_swimer_swim, 1.0f, + Animation_GetLastFrame(&gPlayerAnim_link_swimer_swim), 0.0f, ANIMMODE_LOOP, 0.0f); + this->unk_B48 = 2.0f; + } else { + Player_AnimationPlayLoop(play, this, &gPlayerAnim_link_swimer_swim); + this->unk_AE8 = 1; + } + + this->unk_AAA = 0x3E80; +} + +void func_8083B850(PlayState* play, Player* this) { + this->currentBoots = PLAYER_BOOTS_ZORA_LAND; + this->prevBoots = PLAYER_BOOTS_ZORA_LAND; + Player_SetAction(play, this, func_80850D68, 0); + this->unk_B48 = sqrtf(SQ(this->linearVelocity) + SQ(this->actor.velocity.y)); + Player_OverrideBlureColors(play, this, 1, 8); + this->currentBoots = PLAYER_BOOTS_ZORA_LAND; + this->prevBoots = PLAYER_BOOTS_ZORA_LAND; +} + +void func_8083B8D0(PlayState* play, Player* this) { + if (func_80837730(play, this, this->actor.velocity.y, 500)) { + Player_PlaySfx(this, NA_SE_EV_DIVE_INTO_WATER); + if (this->fallDistance > 800) { + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_CLIMB_END); + } + } +} + +void func_8083B930(PlayState* play, Player* this) { + PlayerAnimationHeader* var_a2; + + if ((this->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER) || !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + (func_80857BE8 == this->actionFunc)) { + func_8082DE50(play, this); + + if (func_8084CA24 == this->actionFunc) { + func_8083B850(play, this); + this->stateFlags3 |= PLAYER_STATE3_8000; + } else if ((this->transformation == PLAYER_FORM_ZORA) && (func_8084C94C == this->actionFunc)) { + func_8083B850(play, this); + this->stateFlags3 |= PLAYER_STATE3_8000; + func_8082DB60(play, this, &gPlayerAnim_pz_fishswim); + } else if ((this->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER) && (this->stateFlags2 & PLAYER_STATE2_400)) { + this->stateFlags2 &= ~PLAYER_STATE2_400; + func_8083B3B4(play, this, NULL); + this->unk_AE7 = 1; + } else if (func_8084C94C == this->actionFunc) { + Player_SetAction(play, this, func_808516B4, 0); + func_8083B798(play, this); + } else { + Player_SetAction(play, this, func_808508C8, 1); + func_8082E438(play, this, + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) ? &gPlayerAnim_link_swimer_wait2swim_wait + : &gPlayerAnim_link_swimer_land2swim_wait); + } + } + if (!(this->stateFlags1 & PLAYER_STATE1_8000000) || (this->actor.depthInWater < this->ageProperties->unk_2C)) { + func_8083B8D0(play, this); + } + + this->stateFlags1 |= PLAYER_STATE1_8000000; + this->stateFlags2 |= PLAYER_STATE2_400; + this->stateFlags1 &= ~(PLAYER_STATE1_40000 | PLAYER_STATE1_80000); + + this->unk_AEC = 0.0f; + func_80123140(play, this); +} + +void func_8083BB4C(PlayState* play, Player* this) { + f32 sp1C = this->actor.depthInWater - this->ageProperties->unk_2C; + + if (sp1C < 0.0f) { + this->underwaterTimer = 0; + if ((this->transformation == PLAYER_FORM_ZORA) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + this->currentBoots = PLAYER_BOOTS_ZORA_LAND; + } + func_801A3E38(0); + } else { + func_801A3E38(0x20); + if ((this->transformation == PLAYER_FORM_ZORA) || (sp1C < 10.0f)) { + this->underwaterTimer = 0; + } else if (this->underwaterTimer < 300) { + this->underwaterTimer++; + } + } + + if ((this->actor.parent == NULL) && (func_8084D4EC != this->actionFunc) && (func_8084F3DC != this->actionFunc) && + ((func_8084CA24 != this->actionFunc) || (this->actor.velocity.y < -2.0f))) { + if (this->ageProperties->unk_2C < this->actor.depthInWater) { + if (this->transformation == PLAYER_FORM_GORON) { + func_80834140(play, this, &gPlayerAnim_link_swimer_swim_down); + func_808345C8(); + func_8083B8D0(play, this); + } else if (this->transformation == PLAYER_FORM_DEKU) { + if (this->remainingHopsCounter != 0) { + func_808373F8(play, this, NA_SE_VO_LI_AUTO_JUMP); + } else { + if ((play->sceneId == SCENE_20SICHITAI) && (this->unk_3CF == 0)) { + if (CHECK_EVENTINF(EVENTINF_50)) { + play->nextEntrance = ENTRANCE(TOURIST_INFORMATION, 2); + } else { + play->nextEntrance = ENTRANCE(TOURIST_INFORMATION, 1); + } + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + this->stateFlags1 |= PLAYER_STATE1_200; + play_sound(NA_SE_SY_DEKUNUTS_JUMP_FAILED); + } else if ((this->unk_3CF == 0) && + ((play->sceneId == SCENE_30GYOSON) || (play->sceneId == SCENE_31MISAKI) || + (play->sceneId == SCENE_TORIDE))) { + func_80169EFC(&play->state); + func_808345C8(); + } else { + Player_SetAction(play, this, func_808497A0, 0); + this->stateFlags1 |= PLAYER_STATE1_20000000; + } + func_8083B8D0(play, this); + } + } else if (!(this->stateFlags1 & PLAYER_STATE1_8000000) || + (((this->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER) || + !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) && + (func_8084E724 != this->actionFunc) && (func_80851B58 != this->actionFunc) && + (func_80851BD4 != this->actionFunc) && (func_808508C8 != this->actionFunc) && + (func_808513EC != this->actionFunc) && (func_80851588 != this->actionFunc) && + (func_808516B4 != this->actionFunc) && (func_808519FC != this->actionFunc) && + (func_80850B18 != this->actionFunc) && (func_80850D68 != this->actionFunc))) { + func_8083B930(play, this); + } + } else if ((this->stateFlags1 & PLAYER_STATE1_8000000) && + (this->actor.depthInWater < this->ageProperties->unk_24) && + (((func_80850D68 != this->actionFunc) && !(this->stateFlags3 & PLAYER_STATE3_8000)) || + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND))) { + if (this->skelAnime.moveFlags == 0) { + func_8083B0E4(play, this, this->actor.shape.rot.y); + } + func_8083B32C(play, this, this->actor.velocity.y); + } + } +} + +void func_8083BF54(PlayState* play, Player* this) { + Vec3f sp84; + s32 temp_v0; + s32 var_a2; + + this->actor.terminalVelocity = -20.0f; + this->actor.gravity = REG(68) / 100.0f; + + var_a2 = false; + temp_v0 = func_808340D4(sPlayerCurrentFloorType); + + if (temp_v0 || + (((var_a2 = (sPlayerCurrentFloorType == FLOOR_TYPE_14) || (sPlayerCurrentFloorType == FLOOR_TYPE_15))) || + (sPlayerCurrentFloorType == FLOOR_TYPE_13))) { + f32 temp_fv1_2; + f32 var_fa1; + f32 var_ft4; + f32 var_fv0; + u16 sfxId; + + var_ft4 = fabsf(this->linearVelocity + D_80862B3C) * 20.0f; + if (temp_v0) { + if (sPlayerCurrentFloorType == FLOOR_TYPE_4) { + var_fa1 = 1300.0f; + } else if (sPlayerCurrentFloorType == FLOOR_TYPE_7) { + var_fa1 = 20000.0f; + var_ft4 = 0.0f; + } else { + var_fa1 = 10000.0f; + var_ft4 *= 1.6f; + } + sfxId = NA_SE_PL_SINK_ON_SAND - SFX_FLAG; + } else if (var_a2) { + if (sPlayerCurrentFloorType == FLOOR_TYPE_14) { + var_fa1 = 400.0f; + var_ft4 *= 10.0f; + } else { + var_fa1 = 1300.0f; + var_ft4 = 0.0f; + } + sfxId = NA_SE_PL_SINK_ON_SNOW - SFX_FLAG; + } else { + var_fa1 = (this->transformation == PLAYER_FORM_GORON) ? 10000.0f : 1000.0f; + var_ft4 = 0.0f; + sfxId = NA_SE_PL_SINK_ON_SAND - SFX_FLAG; + } + + var_fa1 = CLAMP_MIN(var_fa1, this->unk_AB8); + + var_fv0 = (sPlayerCurrentFloorType == FLOOR_TYPE_14) ? 200.0f : (var_fa1 - this->unk_AB8) * 0.02f; + var_fv0 = CLAMP(var_fv0, 0.0f, 300.0f); + + temp_fv1_2 = this->unk_AB8; + this->unk_AB8 += var_fv0 - var_ft4; + this->unk_AB8 = CLAMP(this->unk_AB8, 0.0f, var_fa1); + + if ((this->linearVelocity == 0.0f) && (fabsf(this->unk_AB8 - temp_fv1_2) > 2.0f)) { + func_800B8F98(&this->actor, sfxId); + } + + this->actor.gravity -= this->unk_AB8 * 0.004f; + } else { + this->unk_AB8 = 0.0f; + } + + if ((this->stateFlags3 & PLAYER_STATE3_10) && (this->actor.bgCheckFlags & BGCHECKFLAG_WATER)) { + if (this->actor.depthInWater < 50.0f) { + f32 temp_fv1_5; + Vec3f* bodyPartsPos; + f32 var_fa0_3; + f32 var_ft4_2; + + var_ft4_2 = fabsf(this->bodyPartsPos[PLAYER_BODYPART_WAIST].x - this->unk_D6C.x) + + fabsf(this->bodyPartsPos[PLAYER_BODYPART_WAIST].y - this->unk_D6C.y) + + fabsf(this->bodyPartsPos[PLAYER_BODYPART_WAIST].z - this->unk_D6C.z); + var_ft4_2 = CLAMP_MAX(var_ft4_2, 4.0f); + + this->unk_AEC += var_ft4_2; + if (this->unk_AEC > 15.0f) { + this->unk_AEC = 0.0f; + sp84.x = (Rand_ZeroOne() * 10.0f) + this->actor.world.pos.x; + sp84.y = this->actor.world.pos.y + this->actor.depthInWater; + sp84.z = (Rand_ZeroOne() * 10.0f) + this->actor.world.pos.z; + + EffectSsGRipple_Spawn(play, &sp84, 100, 500, 0); + + if ((this->linearVelocity > 4.0f) && !func_801242B4(this) && + ((this->actor.world.pos.y + this->actor.depthInWater) < + this->bodyPartsPos[PLAYER_BODYPART_WAIST].y)) { + func_80837730(play, this, 20.0f, + (fabsf(this->linearVelocity) * 50.0f) + (this->actor.depthInWater * 5.0f)); + } else if (this->stateFlags3 & PLAYER_STATE3_8000) { + s32 i; + + var_fa0_3 = (this->actor.world.pos.y + this->actor.depthInWater) - 5.0f; + bodyPartsPos = this->bodyPartsPos; + + for (i = 0; i < PLAYER_BODYPART_MAX; i++, bodyPartsPos++) { + temp_fv1_5 = bodyPartsPos->y - var_fa0_3; + + if (temp_fv1_5 > 0.0f) { + func_80837730(play, this, 20.0f, + fabsf(this->linearVelocity) * 20.0f + (temp_fv1_5 * 10.0f)); + } + } + } + } + } + + if (this->ageProperties->unk_2C < this->actor.depthInWater) { + s32 numBubbles = 0; + s32 i; + f32 var_fv1; + + var_fv1 = (this->stateFlags1 & PLAYER_STATE1_4000000) + ? -fabsf(this->linearVelocity) + : ((func_80850D68 == this->actionFunc) + ? (ABS_ALT(this->unk_B8A) * -0.004f) + (this->unk_B48 * -0.38f) + : this->actor.velocity.y); + + if ((var_fv1 > -1.0f) || ((this->currentBoots == PLAYER_BOOTS_ZORA_UNDERWATER) && + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND))) { + if (Rand_ZeroOne() < 0.2f) { + numBubbles = 1; + } + } else { + numBubbles = var_fv1 * -0.3f; + if (numBubbles > 8) { + numBubbles = 8; + } + } + + for (i = 0; i < numBubbles; i++) { + EffectSsBubble_Spawn(play, &this->actor.world.pos, 20.0f, 10.0f, 20.0f, 0.13f); + } + } + } +} + +s32 func_8083C62C(Player* this, s32 arg1) { + Actor* targetedActor = this->targetedActor; + Vec3f headPos; + s16 pitchTarget; + s16 yawTarget; + + headPos.x = this->actor.world.pos.x; + headPos.y = this->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 3.0f; + headPos.z = this->actor.world.pos.z; + + pitchTarget = Math_Vec3f_Pitch(&headPos, &targetedActor->focus.pos); + yawTarget = Math_Vec3f_Yaw(&headPos, &targetedActor->focus.pos); + + Math_SmoothStepToS(&this->actor.focus.rot.y, yawTarget, 4, 0x2710, 0); + Math_SmoothStepToS(&this->actor.focus.rot.x, pitchTarget, 4, 0x2710, 0); + + this->unk_AA6 |= 2; + + return func_80832754(this, arg1); +} + +Vec3f D_8085D218 = { 0.0f, 100.0f, 40.0f }; + +void func_8083C6E8(Player* this, PlayState* play) { + if (this->targetedActor != NULL) { + if (func_800B7128(this) || func_8082EF20(this)) { + func_8083C62C(this, true); + } else { + func_8083C62C(this, false); + } + return; + } + + if (sPlayerCurrentFloorType == FLOOR_TYPE_11) { + Math_SmoothStepToS(&this->actor.focus.rot.x, -20000, 10, 4000, 800); + } else { + s16 sp46 = 0; + f32 yIntersect; + Vec3f pos; + s16 temp_v0; + + yIntersect = func_80835D2C(play, this, &D_8085D218, &pos); + if (yIntersect > BGCHECK_Y_MIN) { + temp_v0 = Math_Atan2S_XY(40.0f, this->actor.world.pos.y - yIntersect); + sp46 = CLAMP(temp_v0, -4000, 4000); + } + this->actor.focus.rot.y = this->actor.shape.rot.y; + Math_SmoothStepToS(&this->actor.focus.rot.x, sp46, 14, 4000, 30); + } + + func_80832754(this, func_800B7128(this) || func_8082EF20(this)); +} + +void func_8083C85C(Player* this) { + Math_ScaledStepToS(&this->upperLimbRot.x, D_80862B3C * -500.0f, 900); + this->headLimbRot.x = (-(f32)this->upperLimbRot.x * 0.5f); + this->unk_AA6 |= 0x48; +} + +void func_8083C8E8(Player* this, PlayState* play) { + if ((func_800B7128(this) == 0) && (func_8082EF20(this) == 0) && + ((this->linearVelocity > 5.0f) || (D_80862B3C != 0.0f))) { + s16 temp1; + s16 temp2; + + temp1 = this->linearVelocity * 200.0f; + temp2 = BINANG_SUB(this->currentYaw, this->actor.shape.rot.y) * this->linearVelocity * 0.1f; + + temp1 = CLAMP(temp1, -0xFA0, 0xFA0); + + temp1 += (s16)(s32)(D_80862B3C * -500.0f); + + temp1 = CLAMP(temp1, -0x2EE0, 0x2EE0); + + temp2 = CLAMP(-temp2, -0xFA0, 0xFA0); + + Math_ScaledStepToS(&this->upperLimbRot.x, temp1, 0x384); + this->headLimbRot.x = -(f32)this->upperLimbRot.x * 0.5f; + Math_ScaledStepToS(&this->headLimbRot.z, temp2, 0x12C); + Math_ScaledStepToS(&this->upperLimbRot.z, temp2, 0xC8); + this->unk_AA6 |= 0x168; + } else { + func_8083C6E8(this, play); + } +} + +void func_8083CB04(Player* this, f32 arg1, s16 arg2, f32 arg3, f32 arg4, s16 arg5) { + Math_AsymStepToF(&this->linearVelocity, arg1, arg3, arg4); + Math_ScaledStepToS(&this->currentYaw, arg2, arg5); +} + +void func_8083CB58(Player* this, f32 arg1, s16 arg2) { + func_8083CB04(this, arg1, arg2, REG(19) / 100.0f, 1.5f, REG(27)); +} + +s32 func_8083CBC4(Player* this, f32 arg1, s16 arg2, f32 arg3, f32 arg4, f32 arg5, s16 arg6) { + s16 temp_v0 = this->currentYaw - arg2; + + if ((this->unk_B50 * 1.5f) < fabsf(this->linearVelocity)) { + arg5 *= 4.0f; + arg3 *= 4.0f; + } + + if (ABS_ALT(temp_v0) > 0x6000) { + if (Math_StepToF(&this->linearVelocity, 0.0f, arg3) == 0) { + return false; + } + + this->currentYaw = arg2; + } else { + Math_AsymStepToF(&this->linearVelocity, arg1, arg4, arg5); + Math_ScaledStepToS(&this->currentYaw, arg2, arg6); + } + + return true; +} + +struct_8085D224 D_8085D224[][2] = { + { + { &gPlayerAnim_link_uma_left_up, 35.17f, 6.6099997f }, + { &gPlayerAnim_link_uma_right_up, -34.16f, 7.91f }, + }, + { + { &gPlayerAnim_cl_uma_leftup, 22.718237f, 2.3294117f }, + { &gPlayerAnim_cl_uma_rightup, -22.0f, 1.9800001f }, + }, +}; + +u16 D_8085D254[] = { + 0x1804, // PLAYER_FORM_GORON + 0x1805, // PLAYER_FORM_ZORA + 0x1806, // PLAYER_FORM_DEKU + 0x1806, // PLAYER_FORM_HUMAN +}; + +u16 D_8085D25C[] = { + 0x1804, // PLAYER_FORM_FIERCE_DEITY + 0x1804, // PLAYER_FORM_GORON + 0x1805, // PLAYER_FORM_ZORA + 0x1806, // PLAYER_FORM_DEKU +}; + +// Player_MountHorse +s32 func_8083CCB4(Player* this, PlayState* play) { + EnHorse* rideActor = (EnHorse*)this->rideActor; + + if (rideActor != NULL) { + if ((rideActor->type != HORSE_TYPE_2) && (this->transformation != PLAYER_FORM_FIERCE_DEITY)) { + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A)) { + if (CutsceneManager_IsNext(CS_ID_GLOBAL_TALK)) { + rideActor->actor.textId = D_8085D254[this->transformation - 1]; + Player_TalkWithPlayer(play, &rideActor->actor); + return true; + } + } + + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); + } else if ((rideActor->type == HORSE_TYPE_2) && (this->transformation != PLAYER_FORM_HUMAN)) { + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A)) { + if (CutsceneManager_IsNext(CS_ID_GLOBAL_TALK)) { + rideActor->actor.textId = D_8085D25C[this->transformation]; + Player_TalkWithPlayer(play, &rideActor->actor); + return true; + } + } + + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); + } else { + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A)) { + s32 pad[2]; + f32 sp28 = Math_CosS(rideActor->actor.shape.rot.y); + f32 sp24 = Math_SinS(rideActor->actor.shape.rot.y); + struct_8085D224* entry; + f32 temp_fv0; + f32 temp_fv1; + + func_80832558(play, this, func_80837BD0); + + this->stateFlags1 |= PLAYER_STATE1_800000; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER; + this->isBurning = false; + + if (this->transformation == PLAYER_FORM_FIERCE_DEITY) { + entry = D_8085D224[0]; + } else { + entry = D_8085D224[1]; + } + if (this->mountSide >= 0) { + entry++; + } + + temp_fv0 = entry->unk_4; + temp_fv1 = entry->unk_8; + this->actor.world.pos.x = + rideActor->actor.world.pos.x + rideActor->riderPos.x + ((temp_fv0 * sp28) + (temp_fv1 * sp24)); + this->actor.world.pos.z = + rideActor->actor.world.pos.z + rideActor->riderPos.z + ((temp_fv1 * sp28) - (temp_fv0 * sp24)); + this->unk_B48 = rideActor->actor.world.pos.y - this->actor.world.pos.y; + + this->currentYaw = this->actor.shape.rot.y = rideActor->actor.shape.rot.y; + + Actor_MountHorse(play, this, &rideActor->actor); + Player_AnimationPlayOnce(play, this, entry->anim); + func_8082E920(play, this, + ANIM_FLAG_1 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_8 | ANIM_FLAG_NOMOVE | ANIM_FLAG_80); + this->actor.parent = this->rideActor; + func_8082DAD4(this); + Actor_DeactivateLens(play); + + return true; + } + } + } + + return false; +} + +PlayerAnimationHeader* D_8085D264[] = { + &gPlayerAnim_link_normal_down_slope_slip, + &gPlayerAnim_link_normal_up_slope_slip, +}; + +s32 func_8083CF68(PlayState* play, Player* this) { + if (!Player_InBlockingCsMode(play, this) && !(this->cylinder.base.ocFlags1 & OC1_HIT)) { + if ((func_80853D68 != this->actionFunc) && (func_80857BE8 != this->actionFunc) && + (D_80862B40 == FLOOR_EFFECT_1)) { + s16 playerVelYaw = Math_Atan2S_XY(this->actor.velocity.z, this->actor.velocity.x); + Vec3f slopeNormal; + s16 downwardSlopeYaw; + s16 velYawToDownwardSlope; + f32 slopeSlowdownSpeed; + f32 temp_fv1; + f32 var_fa1; + f32 slopeSlowdownSpeedStep; + + Actor_GetSlopeDirection(this->actor.floorPoly, &slopeNormal, &downwardSlopeYaw); + velYawToDownwardSlope = downwardSlopeYaw - playerVelYaw; + + if (ABS_ALT(velYawToDownwardSlope) > 0x3E80) { // 87.9 degrees + var_fa1 = (func_80857BE8 == this->actionFunc) ? Math_CosS(this->unk_B6C) : slopeNormal.y; + slopeSlowdownSpeed = (1.0f - var_fa1) * 40.0f; + temp_fv1 = fabsf(this->actor.speed) + slopeSlowdownSpeed; + slopeSlowdownSpeedStep = SQ(temp_fv1) * 0.011f; + slopeSlowdownSpeedStep = CLAMP_MIN(slopeSlowdownSpeedStep, 2.2f); + + // slows down speed as player is climbing a slope + this->pushedYaw = downwardSlopeYaw; + Math_StepToF(&this->pushedSpeed, slopeSlowdownSpeed, slopeSlowdownSpeedStep); + } else { + Player_SetAction(play, this, func_80853D68, 0); + func_8082DE50(play, this); + func_8082E514(play, this, D_8085D264[this->unk_AE7]); + this->linearVelocity = sqrtf(SQXZ(this->actor.velocity)); + this->currentYaw = downwardSlopeYaw; + if (D_80862B28 >= 0) { + this->unk_AE7 = 1; + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_HANG); + } + + return true; + } + } + } + + return false; +} + +void func_8083D168(PlayState* play, Player* this, GetItemEntry* giEntry) { + Item00Type dropType = GIFIELD_GET_DROP_TYPE(giEntry->field); + + if (!(giEntry->field & GIFIELD_NO_COLLECTIBLE)) { + Item_DropCollectible(play, &this->actor.world.pos, dropType | 0x8000); + + if ((dropType == ITEM00_BOMBS_A) || (dropType == ITEM00_ARROWS_30) || (dropType == ITEM00_ARROWS_40) || + (dropType == ITEM00_ARROWS_50) || (dropType == ITEM00_RUPEE_GREEN) || (dropType == ITEM00_RUPEE_BLUE) || + (dropType == ITEM00_RUPEE_RED) || (dropType == ITEM00_RUPEE_PURPLE) || (dropType == ITEM00_RUPEE_HUGE)) { + return; + } + } + + Item_Give(play, giEntry->itemId); + play_sound((this->getItemId < GI_NONE) ? NA_SE_SY_GET_BOXITEM : NA_SE_SY_GET_ITEM); +} + +s32 func_8083D23C(Player* this, PlayState* play) { + if (gSaveContext.save.saveInfo.playerData.health != 0) { + Actor* interactRangeActor = this->interactRangeActor; + + if (interactRangeActor != NULL) { + if (this->getItemId > GI_NONE) { + if (this->getItemId < GI_MAX) { + GetItemEntry* giEntry = &sGetItemTable[this->getItemId - 1]; + + interactRangeActor->parent = &this->actor; + if ((Item_CheckObtainability(giEntry->itemId) == ITEM_NONE) || + ((s16)giEntry->objectId == OBJECT_GI_BOMB_2)) { + func_8082DCA0(play, this); + func_80838830(this, giEntry->objectId); + + if (!(this->stateFlags2 & PLAYER_STATE2_400) || + (this->currentBoots == PLAYER_BOOTS_ZORA_UNDERWATER)) { + Player_StopCutscene(this); + func_808324EC(play, this, func_80837C78, play->playerCsIds[PLAYER_CS_ID_ITEM_GET]); + func_8082DB90(play, this, + (this->transformation == PLAYER_FORM_DEKU) + ? &gPlayerAnim_pn_getB + : &gPlayerAnim_link_demo_get_itemB); + } + + this->stateFlags1 |= (PLAYER_STATE1_400 | PLAYER_STATE1_800 | PLAYER_STATE1_20000000); + func_8082DAD4(this); + + return true; + } + + func_8083D168(play, this, giEntry); + this->getItemId = GI_NONE; + } + } else if (this->csMode == PLAYER_CSMODE_0) { + if (!(this->stateFlags1 & PLAYER_STATE1_800)) { + if (this->getItemId != GI_NONE) { + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A)) { + GetItemEntry* giEntry = &sGetItemTable[-this->getItemId - 1]; + EnBox* chest = (EnBox*)interactRangeActor; + + if ((giEntry->itemId != ITEM_NONE) && + (((Item_CheckObtainability(giEntry->itemId) == ITEM_NONE) && + (giEntry->field & GIFIELD_40)) || + (((Item_CheckObtainability(giEntry->itemId) != ITEM_NONE)) && + (giEntry->field & GIFIELD_20)))) { + this->getItemId = + (giEntry->itemId == ITEM_MASK_CAPTAIN) ? -GI_RECOVERY_HEART : -GI_RUPEE_BLUE; + giEntry = &sGetItemTable[-this->getItemId - 1]; + } + + func_80832558(play, this, func_80837C78); + this->stateFlags1 |= (PLAYER_STATE1_400 | PLAYER_STATE1_800 | PLAYER_STATE1_20000000); + func_80838830(this, giEntry->objectId); + + this->actor.world.pos.x = + interactRangeActor->world.pos.x - + (Math_SinS(interactRangeActor->shape.rot.y) * this->ageProperties->unk_9C); + this->actor.world.pos.z = + interactRangeActor->world.pos.z - + (Math_CosS(interactRangeActor->shape.rot.y) * this->ageProperties->unk_9C); + this->actor.world.pos.y = interactRangeActor->world.pos.y; + this->currentYaw = this->actor.shape.rot.y = interactRangeActor->shape.rot.y; + + func_8082DAD4(this); + if ((giEntry->itemId != ITEM_NONE) && (giEntry->gid >= 0) && + (Item_CheckObtainability(giEntry->itemId) == ITEM_NONE)) { + this->csId = chest->csId2; + func_8082DB90(play, this, this->ageProperties->openChestAnim); + func_8082E920(play, this, + ANIM_FLAG_1 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_4 | ANIM_FLAG_8 | + ANIM_FLAG_NOMOVE | ANIM_FLAG_80); + this->actor.bgCheckFlags &= ~BGCHECKFLAG_WATER; + chest->unk_1EC = 1; + } else { + Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_normal_box_kick); + chest->unk_1EC = -1; + } + + return true; + } + } else if (!(this->stateFlags1 & PLAYER_STATE1_8000000) && + (this->transformation != PLAYER_FORM_DEKU)) { + if ((this->heldActor == NULL) || Player_IsHoldingHookshot(this)) { + EnBom* bomb = (EnBom*)interactRangeActor; + + if (((this->transformation != PLAYER_FORM_GORON) && + (((bomb->actor.id == ACTOR_EN_BOM) && bomb->isPowderKeg) || + ((interactRangeActor->id == ACTOR_EN_ISHI) && (interactRangeActor->params & 1)) || + (interactRangeActor->id == ACTOR_EN_MM)))) { + return false; + } + + this->stateFlags2 |= PLAYER_STATE2_10000; + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A)) { + func_80832558(play, this, func_808379C0); + func_8082DAD4(this); + this->stateFlags1 |= PLAYER_STATE1_800; + + return true; + } + } + } + } + } + } + } + + return false; +} + +// Player_SetAction_Throwing +void func_8083D6DC(Player* this, PlayState* play) { + Player_SetAction(play, this, func_8084E65C, 1); + Player_AnimationPlayOnce(play, this, D_8085BE84[PLAYER_ANIMGROUP_28][this->modelAnimType]); +} + +// Determines whether a held actor should be dropped or thrown: false implies droppable. +s32 func_8083D738(Player* this, Actor* heldActor) { + if ((heldActor != NULL) && !(heldActor->flags & ACTOR_FLAG_800000) && + ((this->linearVelocity < 1.1f) || (heldActor->id == ACTOR_EN_BOM_CHU))) { + return false; + } + return true; +} + +s32 func_8083D78C(Player* this, PlayState* play) { + if (this->stateFlags1 & PLAYER_STATE1_800) { + if ((this->heldActor != NULL) && + CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_B | BTN_A)) { + if (!func_808313A8(play, this, this->heldActor)) { + if (!func_8083D738(this, this->heldActor)) { + Player_SetAction(play, this, func_8084E58C, 1); + Player_AnimationPlayOnce(play, this, D_8085BE84[PLAYER_ANIMGROUP_29][this->modelAnimType]); + return true; + } + func_8083D6DC(this, play); + } + + return true; + } + } + return false; +} + +s32 func_8083D860(Player* this, PlayState* play) { + if ((this->wallHeight >= 79.0f) && + (!(this->stateFlags1 & PLAYER_STATE1_8000000) || (this->currentBoots == PLAYER_BOOTS_ZORA_UNDERWATER) || + (this->actor.depthInWater < this->ageProperties->unk_2C))) { + s32 var_t0 = (sPlayerCurrentWallFlags & WALL_FLAG_3) ? 2 : 0; + s32 temp_t2 = sPlayerCurrentWallFlags & WALL_FLAG_1; + + if ((var_t0 != 0) || temp_t2 || + SurfaceType_CheckWallFlag2(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId)) { + CollisionPoly* wallPoly = this->actor.wallPoly; + f32 sp78; + f32 sp74; + f32 zOut; + f32 yOut; + Vec3f sp48[3]; + s32 i; + f32 sp40; + Vec3f* sp3C; + f32 xOut; + + yOut = xOut = 0.0f; + if (var_t0 != 0) { + sp78 = this->actor.world.pos.x; + sp74 = this->actor.world.pos.z; + } else { + sp3C = sp48; + CollisionPoly_GetVerticesByBgId(wallPoly, this->actor.wallBgId, &play->colCtx, sp48); + sp78 = xOut = sp48[0].x; + sp74 = zOut = sp48[0].z; + yOut = sp48[0].y; + + for (i = 1; i < ARRAY_COUNT(sp48); i++) { + sp3C++; + + if (sp78 > sp3C->x) { + sp78 = sp3C->x; + } else if (xOut < sp3C->x) { + xOut = sp3C->x; + } + + if (sp74 > sp3C->z) { + sp74 = sp3C->z; + } else if (zOut < sp3C->z) { + zOut = sp3C->z; + } + + if (yOut > sp3C->y) { + yOut = sp3C->y; + } + } + + sp78 = (sp78 + xOut) * 0.5f; + sp74 = (sp74 + zOut) * 0.5f; + + xOut = ((this->actor.world.pos.x - sp78) * COLPOLY_GET_NORMAL(wallPoly->normal.z)) - + ((this->actor.world.pos.z - sp74) * COLPOLY_GET_NORMAL(wallPoly->normal.x)); + + sp40 = this->actor.world.pos.y - yOut; + yOut = ((s32)((sp40 / 15.0f) + 0.5f) * 15.0f) - sp40; + xOut = fabsf(xOut); + } + + if (xOut < 8.0f) { + f32 wallPolyNormalX = COLPOLY_GET_NORMAL(wallPoly->normal.x); + f32 wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z); + f32 wallDistance = this->wallDistance; + PlayerAnimationHeader* anim; + + func_80832558(play, this, func_80837C20); + + this->stateFlags1 |= PLAYER_STATE1_200000; + this->stateFlags1 &= ~PLAYER_STATE1_8000000; + + if ((var_t0 != 0) || temp_t2) { + if ((this->unk_AE7 = var_t0) != 0) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + anim = &gPlayerAnim_link_normal_Fclimb_startA; + + } else { + anim = &gPlayerAnim_link_normal_Fclimb_hold2upL; + } + wallDistance = (this->ageProperties->unk_3C + 4.0f) - wallDistance; + } else { + anim = this->ageProperties->unk_AC; + wallDistance = 20.5f; + } + + this->unk_AE8 = -2; + this->actor.world.pos.y += yOut; + + this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw + 0x8000; + } else { + anim = this->ageProperties->unk_B0; + wallDistance = (this->ageProperties->unk_38 - this->ageProperties->unk_3C) + 17.0f; + this->unk_AE8 = -4; + + this->actor.shape.rot.y = this->currentYaw = i = this->actor.wallYaw; //! FAKE + } + + this->actor.world.pos.x = (wallDistance * wallPolyNormalX) + sp78; + this->actor.world.pos.z = (wallDistance * wallPolyNormalZ) + sp74; + func_8082DAD4(this); + Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); + Player_AnimationPlayOnce(play, this, anim); + func_8082E920(play, this, + ANIM_FLAG_1 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_4 | ANIM_FLAG_8 | ANIM_FLAG_NOMOVE | + ANIM_FLAG_80); + return true; + } + } + } + + return false; +} + +void func_8083DCC4(Player* this, PlayerAnimationHeader* anim, PlayState* play) { + func_8083172C(play, this, func_8084FC0C, 0); + PlayerAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, 4.0f / 3.0f); +} + +s32 func_8083DD1C(PlayState* play, Player* this, f32 arg2, f32 arg3, f32 arg4, f32 arg5) { + CollisionPoly* wallPoly; + s32 bgId; + Vec3f sp74; + Vec3f sp68; + Vec3f sp5C; + f32 cos = Math_CosS(this->actor.shape.rot.y); + f32 sin = Math_SinS(this->actor.shape.rot.y); + + sp74.x = this->actor.world.pos.x + (arg5 * sin); + sp74.z = this->actor.world.pos.z + (arg5 * cos); + sp68.x = this->actor.world.pos.x + (arg4 * sin); + sp68.z = this->actor.world.pos.z + (arg4 * cos); + sp74.y = sp68.y = this->actor.world.pos.y + arg2; + + if (BgCheck_EntityLineTest2(&play->colCtx, &sp74, &sp68, &sp5C, &this->actor.wallPoly, true, false, false, true, + &bgId, &this->actor)) { + f32 wallPolyNormalX; + f32 wallPolyNormalZ; + + wallPoly = this->actor.wallPoly; + this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_WALL_INTERACT; + this->actor.wallBgId = bgId; + sPlayerCurrentWallFlags = SurfaceType_GetWallFlags(&play->colCtx, wallPoly, bgId); + + wallPolyNormalX = COLPOLY_GET_NORMAL(wallPoly->normal.x); + wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z); + + Math_ScaledStepToS(&this->actor.shape.rot.y, Math_Atan2S_XY(-wallPolyNormalZ, -wallPolyNormalX), 0x320); + + this->currentYaw = this->actor.shape.rot.y; + this->actor.world.pos.x = sp5C.x - (Math_SinS(this->actor.shape.rot.y) * arg3); + this->actor.world.pos.z = sp5C.z - (Math_CosS(this->actor.shape.rot.y) * arg3); + + return true; + } + + this->actor.bgCheckFlags &= ~BGCHECKFLAG_PLAYER_WALL_INTERACT; + return false; +} + +void func_8083DEE4(PlayState* play, Player* this) { + f32 temp_fv0 = this->ageProperties->unk_38; + + func_8083DD1C(play, this, 268 * 0.1f, temp_fv0 + 5.0f, temp_fv0 + 15.0f, 0.0f); +} + +void func_8083DF38(Player* this, PlayerAnimationHeader* anim, PlayState* play) { + if (!func_80832558(play, this, func_80837BF8)) { + Player_SetAction(play, this, func_8084ED9C, 0); + } + + Player_AnimationPlayOnce(play, this, anim); + func_8082DAD4(this); + + this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw + 0x8000; +} + +s32 func_8083DFC4(Player* this, PlayState* play) { + if (!(this->stateFlags1 & PLAYER_STATE1_800) && (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && + (D_80862B20 < 0x3000)) { + if ((this->linearVelocity > 0.0f) && func_8083D860(this, play)) { + return true; + } + + if (!func_801242B4(this) && ((this->linearVelocity == 0.0f) || !(this->stateFlags2 & PLAYER_STATE2_4)) && + (sPlayerCurrentWallFlags & WALL_FLAG_6) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + (this->wallHeight >= 39.0f)) { + this->stateFlags2 |= PLAYER_STATE2_1; + + if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A)) { + DynaPolyActor* dyna; + + if ((this->actor.wallBgId != BGCHECK_SCENE) && + ((dyna = DynaPoly_GetActor(&play->colCtx, this->actor.wallBgId)) != NULL)) { + this->rightHandActor = &dyna->actor; + } else { + this->rightHandActor = NULL; + } + + func_8083DF38(this, &gPlayerAnim_link_normal_push_wait, play); + return true; + } + } + } + + return false; +} + +s32 func_8083E14C(PlayState* play, Player* this) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && + ((this->stateFlags2 & PLAYER_STATE2_10) || CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A))) { + DynaPolyActor* var_v1 = NULL; + + if (this->actor.wallBgId != BGCHECK_SCENE) { + var_v1 = DynaPoly_GetActor(&play->colCtx, this->actor.wallBgId); + } + + if (&var_v1->actor == this->rightHandActor) { + if (this->stateFlags2 & PLAYER_STATE2_10) { + return true; + } + return false; + } + } + + func_808369F4(this, play); + Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_normal_push_wait_end); + this->stateFlags2 &= ~PLAYER_STATE2_10; + return true; +} + +void func_8083E234(Player* this, PlayState* play) { + Player_SetAction(play, this, func_8084EE50, 0); + Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_normal_push_start); + this->stateFlags2 |= PLAYER_STATE2_10; +} + +void func_8083E28C(Player* this, PlayState* play) { + Player_SetAction(play, this, func_8084EF9C, 0); + Player_AnimationPlayOnce(play, this, D_8085BE84[PLAYER_ANIMGROUP_34][this->modelAnimType]); + this->stateFlags2 |= PLAYER_STATE2_10; +} + +void func_8083E2F4(Player* this, PlayState* play) { + this->stateFlags1 &= ~(PLAYER_STATE1_200000 | PLAYER_STATE1_8000000); + func_80833AA0(this, play); + + if (this->transformation == PLAYER_FORM_DEKU) { + this->linearVelocity = -1.7f; + } else { + this->linearVelocity = -0.4f; + } +} + +s32 func_8083E354(Player* this, PlayState* play) { + if (!CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A) && + (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT)) { + if ((sPlayerCurrentWallFlags & WALL_FLAG_3) || (sPlayerCurrentWallFlags & WALL_FLAG_1) || + SurfaceType_CheckWallFlag2(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId)) { + return false; + } + } + + func_8083E2F4(this, play); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_AUTO_JUMP); + return true; +} + +s32 func_8083E404(Player* this, f32 arg1, s16 arg2) { + f32 sp1C = BINANG_SUB(arg2, this->actor.shape.rot.y); + f32 temp_fv1; + + if (this->targetedActor != NULL) { + func_8083C62C(this, func_800B7128(this) || func_8082EF20(this)); + } + + temp_fv1 = fabsf(sp1C) / 0x8000; + if (((SQ(temp_fv1) * 50.0f) + 6.0f) < arg1) { + return 1; + } + + if ((((1.0f - temp_fv1) * 10.0f) + 6.8f) < arg1) { + return -1; + } + return 0; +} + +s32 func_8083E514(Player* this, f32* arg2, s16* arg3, PlayState* play) { + s16 temp_v1 = *arg3 - this->targetYaw; + u16 var_a2 = ABS_ALT(temp_v1); + + if ((func_800B7128(this) || func_8082EF20(this)) && (this->targetedActor == NULL)) { + *arg2 *= Math_SinS(var_a2); + + if (*arg2 != 0.0f) { + *arg3 = (((temp_v1 >= 0) ? 1 : -1) * 0x4000) + this->actor.shape.rot.y; + } else { + *arg3 = this->actor.shape.rot.y; + } + + if (this->targetedActor != NULL) { + func_8083C62C(this, true); + } else { + Math_SmoothStepToS(&this->actor.focus.rot.x, (sPlayerControlInput->rel.stick_y * 240.0f), 0xE, 0xFA0, 0x1E); + func_80832754(this, true); + } + } else { + if (this->targetedActor != NULL) { + return func_8083E404(this, *arg2, *arg3); + } + + func_8083C6E8(this, play); + if ((*arg2 != 0.0f) && (var_a2 < 0x1770)) { + return 1; + } + + if ((Math_SinS(0x4000 - (var_a2 >> 1)) * 200.0f) < *arg2) { + return -1; + } + } + return 0; +} + +s32 func_8083E758(Player* this, f32* arg1, s16* arg2) { + f32 temp_fv0; + u16 temp_v0; + s16 var_v1; + + var_v1 = *arg2 - this->actor.shape.rot.y; + temp_v0 = ABS_ALT(var_v1); + temp_fv0 = Math_CosS(temp_v0); + *arg1 *= temp_fv0; + + // Can't be (*arg1 != 0.0f) + if (*arg1 != 0) { + if (temp_fv0 > 0.0f) { + return 1; + } + return -1; + } + return 0; +} + +s32 func_8083E7F8(Player* this, f32* arg1, s16* arg2, PlayState* play) { + func_8083C6E8(this, play); + + if ((*arg1 != 0.0f) || (ABS_ALT(this->unk_B4C) > 0x190)) { + s16 temp_a0 = *arg2 - (u16)Camera_GetInputDirYaw(play->cameraPtrs[play->activeCamId]); + u16 temp; + + temp = (ABS_ALT(temp_a0) - 0x2000); + if ((temp < 0x4000) || (this->unk_B4C != 0)) { + return -1; + } + return 1; + } + + return 0; +} + +void func_8083E8E0(Player* this, f32 arg1, s16 arg2) { + s16 temp = arg2 - this->actor.shape.rot.y; + + if (arg1 > 0.0f) { + if (temp < 0) { + this->unk_B44 = 0.0f; + } else { + this->unk_B44 = 1.0f; + } + } + + Math_StepToF(&this->unk_B40, this->unk_B44, 0.3f); +} + +void func_8083E958(PlayState* play, Player* this) { + PlayerAnimation_BlendToJoint(play, &this->skelAnime, func_8082EF54(this), this->unk_B38, func_8082EF9C(this), + this->unk_B38, this->unk_B40, this->blendTableBuffer); +} + +s32 func_8083E9C4(f32 arg0, f32 arg1, f32 arg2, f32 arg3) { + f32 temp_fv0; + + if ((arg3 == 0.0f) && (arg1 > 0.0f)) { + arg3 = arg2; + } + temp_fv0 = (arg0 + arg1) - arg3; + if (((temp_fv0 * arg1) >= 0.0f) && (((temp_fv0 - arg1) * arg1) < 0.0f)) { + return true; + } + return false; +} + +void func_8083EA44(Player* this, f32 arg1) { + s32 sp24; + f32 updateScale = R_UPDATE_RATE / 2.0f; + + arg1 *= updateScale; + if (arg1 < -7.25f) { + arg1 = -7.25f; + } else if (arg1 > 7.25f) { + arg1 = 7.25f; + } + + sp24 = func_8083E9C4(this->unk_B38, arg1, 29.0f, 10.0f); + + if (sp24 || func_8083E9C4(this->unk_B38, arg1, 29.0f, 24.0f)) { + Player_AnimSfx_PlayFloorWalk(this, this->linearVelocity); + if (this->linearVelocity > 4.0f) { + this->stateFlags2 |= PLAYER_STATE2_8; + } + this->actor.shape.unk_17 = sp24 ? 1 : 2; + } + + this->unk_B38 += arg1; + if (this->unk_B38 < 0.0f) { + this->unk_B38 += 29.0f; + } else if (this->unk_B38 >= 29.0f) { + this->unk_B38 -= 29.0f; + } +} + +void Player_ChooseIdleAnim(PlayState* play, Player* this) { + PlayerAnimationHeader* anim; + u32 healthIsCritical; + PlayerAnimationHeader** animPtr; + s32 animIndex; + s32 rand; + f32 morphFrames; + s16 lastFrame; + + if (((this->actor.id != ACTOR_PLAYER) && !(healthIsCritical = (this->actor.colChkInfo.health < 0x64))) || + ((this->actor.id == ACTOR_PLAYER) && + (((this->targetedActor != NULL) || + ((this->transformation != PLAYER_FORM_FIERCE_DEITY) && (this->transformation != PLAYER_FORM_HUMAN)) || + (this->currentMask == PLAYER_MASK_SCENTS)) || + (!(healthIsCritical = LifeMeter_IsCritical()) && (this->unk_AA4 = ((this->unk_AA4 + 1) & 1)))))) { + this->stateFlags2 &= ~PLAYER_STATE2_10000000; + anim = func_8082ED20(this); + } else { + this->stateFlags2 |= PLAYER_STATE2_10000000; + + if (this->stateFlags1 & PLAYER_STATE1_800) { + anim = func_8082ED20(this); + } else { + animIndex = play->roomCtx.curRoom.behaviorType2; + + if (healthIsCritical) { + if (this->unk_AA4 >= 0) { + animIndex = 7; + this->unk_AA4 = -1; + } else { + animIndex = 8; + } + } else { + rand = Rand_ZeroOne() * 5.0f; + if (rand < 4) { + if (((rand != 0) && (rand != 3)) || + ((this->rightHandType == PLAYER_MODELTYPE_RH_SHIELD) && + ((rand == 3) || (Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE)))) { + if ((rand == 0) && Player_IsHoldingTwoHandedWeapon(this)) { + rand = 4; + } + animIndex = rand + 9; + } + } + } + + animPtr = &sPlayerIdleAnimations[animIndex][0]; + if (this->modelAnimType != PLAYER_ANIMTYPE_1) { + animPtr = &sPlayerIdleAnimations[animIndex][1]; + } + anim = *animPtr; + } + } + + lastFrame = Animation_GetLastFrame(anim); + if ((this->skelAnime.animation == anim) || (this->skelAnime.animation == &gPlayerAnim_pz_attackAend) || + (this->skelAnime.animation == &gPlayerAnim_pz_attackBend) || + (this->skelAnime.animation == &gPlayerAnim_pz_attackCend)) { + morphFrames = 0.0f; + } else { + morphFrames = -6.0f; + } + + PlayerAnimation_Change(play, &this->skelAnime, anim, (2.0f / 3.0f) * D_8085C3E4, 0.0f, lastFrame, ANIMMODE_ONCE, + morphFrames); +} + +void func_8083EE60(Player* this, PlayState* play) { + f32 temp_fv0; + f32 var_fs0; + + if (this->unk_B34 < 1.0f) { + f32 temp_fs0 = R_UPDATE_RATE / 2.0f; + + func_8083EA44(this, REG(35) / 1000.0f); + PlayerAnimation_LoadToJoint(play, &this->skelAnime, D_8085BE84[PLAYER_ANIMGROUP_30][this->modelAnimType], + this->unk_B38); + this->unk_B34 += (1.0f * 1.0f) * temp_fs0; + if (this->unk_B34 >= 1.0f) { + this->unk_B34 = 1.0f; + } + var_fs0 = this->unk_B34; + } else { + temp_fv0 = this->linearVelocity - (REG(48) / 100.0f); + + if (temp_fv0 < 0.0f) { + var_fs0 = 1.0f; + func_8083EA44(this, ((REG(35)) / 1000.0f) + (((REG(36)) / 1000.0f) * this->linearVelocity)); + + PlayerAnimation_LoadToJoint(play, &this->skelAnime, D_8085BE84[PLAYER_ANIMGROUP_30][this->modelAnimType], + this->unk_B38); + } else { + var_fs0 = (REG(37) / 1000.0f) * temp_fv0; + if (var_fs0 < 1.0f) { + func_8083EA44(this, (REG(35) / 1000.0f) + ((REG(36) / 1000.0f) * this->linearVelocity)); + } else { + var_fs0 = 1.0f; + func_8083EA44(this, (REG(39) / 100.0f) + ((REG(38) / 1000.0f) * temp_fv0)); + } + + PlayerAnimation_LoadToMorph(play, &this->skelAnime, D_8085BE84[PLAYER_ANIMGROUP_30][this->modelAnimType], + this->unk_B38); + PlayerAnimation_LoadToJoint(play, &this->skelAnime, &gPlayerAnim_link_normal_back_run, + this->unk_B38 * (16.0f / 29.0f)); + } + } + if (var_fs0 < 1.0f) { + PlayerAnimation_InterpJointMorph(play, &this->skelAnime, 1.0f - var_fs0); + } +} + +void func_8083F144(Player* this, PlayState* play) { + Player_SetAction(play, this, func_8084A794, 1); + func_8082E438(play, this, &gPlayerAnim_link_normal_back_brake); +} + +s32 func_8083F190(Player* this, f32* arg1, s16* arg2, PlayState* play) { + if (this->linearVelocity > 6.0f) { + func_8083F144(this, play); + return true; + } + + if (*arg1 != 0.0f) { + if (func_80832F24(this)) { + *arg1 = 0.0f; + *arg2 = this->currentYaw; + } else { + return true; + } + } + return false; +} + +void func_8083F230(Player* this, PlayState* play) { + Player_SetAction(play, this, func_8084A884, 1); + Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_normal_back_brake_end); +} + +void func_8083F27C(PlayState* play, Player* this) { + f32 temp_fv0; + PlayerAnimationHeader* sp38; + PlayerAnimationHeader* sp34; + + sp38 = D_8085BE84[PLAYER_ANIMGROUP_23][this->modelAnimType]; + sp34 = D_8085BE84[PLAYER_ANIMGROUP_24][this->modelAnimType]; + + this->skelAnime.animation = sp38; + + func_8083EA44(this, (REG(30) / 1000.0f) + ((REG(32) / 1000.0f) * this->linearVelocity)); + + temp_fv0 = this->unk_B38 * (16.0f / 29.0f); + PlayerAnimation_BlendToJoint(play, &this->skelAnime, sp34, temp_fv0, sp38, temp_fv0, this->unk_B40, + this->blendTableBuffer); +} + +void func_8083F358(Player* this, s32 arg1, PlayState* play) { + PlayerAnimationHeader* var_v0; + f32 var_fv1; + s16 var_a1; + + if (ABS_ALT(D_80862B28) < 0xE38) { + var_a1 = 0; + } else { + var_a1 = CLAMP(D_80862B28, -0x2AAA, 0x2AAA); + } + + Math_ScaledStepToS(&this->unk_B70, var_a1, 0x190); + if ((this->modelAnimType == PLAYER_ANIMTYPE_3) || ((this->unk_B70 == 0) && (this->unk_AB8 <= 0.0f))) { + if (arg1 == 0) { + PlayerAnimation_LoadToJoint(play, &this->skelAnime, D_8085BE84[PLAYER_ANIMGROUP_1][this->modelAnimType], + this->unk_B38); + } else { + PlayerAnimation_LoadToMorph(play, &this->skelAnime, D_8085BE84[PLAYER_ANIMGROUP_1][this->modelAnimType], + this->unk_B38); + } + return; + } + + if (this->unk_B70 != 0) { + var_fv1 = this->unk_B70 / (f32)0x2AAA; + } else { + var_fv1 = this->unk_AB8 * 0.0006f; + } + + var_fv1 *= fabsf(this->linearVelocity) * 0.5f; + if (var_fv1 > 1.0f) { + var_fv1 = 1.0f; + } + + if (var_fv1 < 0.0f) { + var_v0 = &gPlayerAnim_link_normal_climb_down; + var_fv1 = -var_fv1; + } else { + var_v0 = &gPlayerAnim_link_normal_climb_up; + } + + if (arg1 == 0) { + PlayerAnimation_BlendToJoint(play, &this->skelAnime, D_8085BE84[PLAYER_ANIMGROUP_1][this->modelAnimType], + this->unk_B38, var_v0, this->unk_B38, var_fv1, this->blendTableBuffer); + } else { + PlayerAnimation_BlendToMorph(play, &this->skelAnime, D_8085BE84[PLAYER_ANIMGROUP_1][this->modelAnimType], + this->unk_B38, var_v0, this->unk_B38, var_fv1, this->blendTableBuffer); + } +} + +void func_8083F57C(Player* this, PlayState* play) { + f32 temp_fv0; + f32 var_fs0; + + if (this->unk_B34 < 1.0f) { + f32 temp_fs0; + + temp_fs0 = R_UPDATE_RATE / 2.0f; + func_8083EA44(this, REG(35) / 1000.0f); + PlayerAnimation_LoadToJoint(play, &this->skelAnime, D_8085BE84[PLAYER_ANIMGROUP_1][this->modelAnimType], + this->unk_B38); + + // required + this->unk_B34 += 1 * temp_fs0; + if (this->unk_B34 >= 1.0f) { + this->unk_B34 = 1.0f; + } + var_fs0 = this->unk_B34; + } else { + temp_fv0 = (this->linearVelocity - (REG(48) / 100.0f)); + if (temp_fv0 < 0.0f) { + var_fs0 = 1.0f; + func_8083EA44(this, (REG(35) / 1000.0f) + ((REG(36) / 1000.0f) * this->linearVelocity)); + func_8083F358(this, 0, play); + } else { + var_fs0 = (REG(37) / 1000.0f) * temp_fv0; + if (var_fs0 < 1.0f) { + func_8083EA44(this, (REG(35) / 1000.0f) + ((REG(36) / 1000.0f) * this->linearVelocity)); + } else { + var_fs0 = 1.0f; + func_8083EA44(this, (REG(39) / 100.0f) + ((REG(38) / 1000.0f) * temp_fv0)); + } + func_8083F358(this, 1, play); + PlayerAnimation_LoadToJoint(play, &this->skelAnime, func_8082EEE0(this), this->unk_B38 * (20.0f / 29.0f)); + } + } + + if (var_fs0 < 1.0f) { + PlayerAnimation_InterpJointMorph(play, &this->skelAnime, 1.0f - var_fs0); + } +} + +void func_8083F828(Vec3f* arg0, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4) { + arg1->x = randPlusMinusPoint5Scaled(arg3) + arg0->x; + arg1->y = randPlusMinusPoint5Scaled(arg4) + (arg0->y + arg2); + arg1->z = randPlusMinusPoint5Scaled(arg3) + arg0->z; +} + +Color_RGBA8 D_8085D26C = { 255, 255, 255, 255 }; +Vec3f D_8085D270 = { 0.0f, 0.04f, 0.0f }; + +s32 func_8083F8A8(PlayState* play, Player* this, f32 radius, s32 countMax, f32 randAccelWeight, s32 scale, + s32 scaleStep, s32 useLighting) { + static Vec3f D_8085D27C = { 0.0f, 0.0f, 0.0f }; + static Vec3f D_8085D288 = { 0.0f, 0.0f, 0.0f }; + + if ((countMax < 0) || (this->floorSfxOffset == NA_SE_PL_WALK_SNOW - SFX_FLAG)) { + s32 count = func_80173B48(&play->state) / 20000000; + Vec3f pos; + s32 i; + + count = (count >= ABS_ALT(countMax)) ? ABS_ALT(countMax) : count; + for (i = 0; i < count; i++) { + func_8083F828(&this->actor.world.pos, &pos, 0.0f, 40.0f, 10.0f); + D_8085D27C.x = randPlusMinusPoint5Scaled(3.0f); + D_8085D27C.z = randPlusMinusPoint5Scaled(3.0f); + EffectSsDust_Spawn(play, 0, &pos, &D_8085D27C, &D_8085D270, &D_8085D26C, &D_8085D26C, scale, scaleStep, 42, + 0); + } + + return true; + } else if ((this->floorSfxOffset == NA_SE_PL_WALK_GROUND - SFX_FLAG) || + (this->floorSfxOffset == NA_SE_PL_WALK_SAND - SFX_FLAG)) { + s32 count = func_80173B48(&play->state) / 12000000; + + if (count > 0) { + Actor_SpawnFloorDustRing(play, &this->actor, &this->actor.world.pos, radius, + (count < countMax) ? count : countMax, randAccelWeight, scale, scaleStep, + useLighting); + + return true; + } + } else if (this->floorSfxOffset == NA_SE_PL_WALK_GRASS - SFX_FLAG) { + s32 count = func_80173B48(&play->state) / 12000000; + Vec3f velocity; + Vec3f pos; + s32 i; + + count = (count >= countMax) ? countMax : count; + for (i = 0; i < count; i++) { + func_8083F828(&this->actor.world.pos, &pos, 0.0f, 20.0f, 20.0f); + velocity.x = randPlusMinusPoint5Scaled(3.0f); + velocity.y = Rand_ZeroFloat(2.0f); + velocity.z = randPlusMinusPoint5Scaled(3.0f); + D_8085D288.y = -0.1f; + EffectSsHahen_Spawn(play, &pos, &velocity, &D_8085D288, 0, 0x96, 1, 0x10, gKakeraLeafTip); + } + } + + return false; +} + +s32 func_8083FBC4(PlayState* play, Player* this) { + if ((this->floorSfxOffset == NA_SE_PL_WALK_GROUND - SFX_FLAG) || + (this->floorSfxOffset == NA_SE_PL_WALK_SAND - SFX_FLAG)) { + Vec3f* feetPos = this->actor.shape.feetPos; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->actor.shape.feetPos); i++) { + func_800B1210(play, feetPos, &gZeroVec3f, &gZeroVec3f, 50, 30); + feetPos++; + } + + return true; + } + + if (this->floorSfxOffset == NA_SE_PL_WALK_SNOW - SFX_FLAG) { + Vec3f* feetPos = this->actor.shape.feetPos; + s32 i; + + for (i = 0; i < ARRAY_COUNT(this->actor.shape.feetPos); i++) { + EffectSsDust_Spawn(play, 0, feetPos, &gZeroVec3f, &D_8085D270, &D_8085D26C, &D_8085D26C, 100, 40, 17, 0); + feetPos++; + } + + return true; + } + + return false; +} + +s32 func_8083FCF0(PlayState* play, Player* this, f32 arg2, f32 arg3, f32 arg4) { + if (arg4 < this->skelAnime.curFrame) { + func_8082DC38(this); + } else if (arg2 <= this->skelAnime.curFrame) { + this->stateFlags3 |= PLAYER_STATE3_2000000; + func_8082FA5C(play, this, + (arg3 <= this->skelAnime.curFrame) ? PLAYER_MELEE_WEAPON_STATE_1 + : PLAYER_MELEE_WEAPON_STATE_MINUS_1); + return true; + } + return false; +} + +// Crouch-stabbing +s32 func_8083FD80(Player* this, PlayState* play) { + if (!Player_IsGoronOrDeku(this) && (Player_GetMeleeWeaponHeld(this) != PLAYER_MELEEWEAPON_NONE) && + (this->transformation != PLAYER_FORM_ZORA) && (D_80862B48 != 0)) { + //! Calling this function sets the meleeWeaponQuads' damage properties correctly, patching "Power Crouch Stab". + func_8083375C(this, PLAYER_MWA_STAB_1H); + Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_normal_defense_kiru); + this->unk_AE7 = 1; + this->meleeWeaponAnimation = PLAYER_MWA_STAB_1H; + this->currentYaw = this->actor.shape.rot.y + this->upperLimbRot.y; + this->unk_ADD = 0; + return true; + } + return false; +} + +s32 func_8083FE38(Player* this, PlayState* play) { + return func_80838A90(this, play) || func_808391D8(this, play) || func_8083D23C(this, play); +} + +void Player_RequestQuakeAndRumble(PlayState* play, Player* this, u16 sfxId) { + Player_RequestQuake(play, 27767, 7, 20); + Player_RequestRumble(play, this, 255, 20, 150, SQ(0)); + Player_PlaySfx(this, sfxId); +} + +void func_8083FEF4(PlayState* play, Player* this) { + Inventory_ChangeAmmo(ITEM_STICK, -1); + func_80831990(play, this, ITEM_NONE); +} + +s32 func_8083FF30(PlayState* play, Player* this) { + if ((this->heldItemAction == PLAYER_IA_STICK) && (this->unk_B0C > 0.5f)) { + if (AMMO(ITEM_STICK) != 0) { + EffectSsStick_Spawn(play, &this->bodyPartsPos[PLAYER_BODYPART_RIGHT_HAND], + BINANG_ADD(this->actor.shape.rot.y, 0x8000)); + this->unk_B0C = 0.5f; + func_8083FEF4(play, this); + Player_PlaySfx(this, NA_SE_IT_WOODSTICK_BROKEN); + } + return true; + } + + return false; +} + +// handles razor sword health and breaking +s32 func_8083FFEC(PlayState* play, Player* this) { + if (this->heldItemAction == PLAYER_IA_SWORD_RAZOR) { + if (gSaveContext.save.saveInfo.playerData.swordHealth > 0) { + gSaveContext.save.saveInfo.playerData.swordHealth--; + if (gSaveContext.save.saveInfo.playerData.swordHealth <= 0) { + Item_Give(play, ITEM_SWORD_KOKIRI); + func_80831990(play, this, ITEM_SWORD_KOKIRI); + Player_PlaySfx(this, NA_SE_IT_MAJIN_SWORD_BROKEN); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + Message_StartTextbox(play, 0xF9, NULL); + } + } + } + return true; + } + return false; +} + +// Could return the last function, but never used as such +void func_80840094(PlayState* play, Player* this) { + func_8083FF30(play, this); + func_8083FFEC(play, this); +} + +PlayerAnimationHeader* D_8085D294[] = { + &gPlayerAnim_link_fighter_rebound, + &gPlayerAnim_link_fighter_rebound_long, + &gPlayerAnim_link_fighter_reboundR, + &gPlayerAnim_link_fighter_rebound_longR, +}; + +void func_808400CC(PlayState* play, Player* this) { + if (func_8084B5C0 != this->actionFunc) { + func_8082DD2C(play, this); + if ((this->transformation != PLAYER_FORM_HUMAN) && (this->transformation != PLAYER_FORM_FIERCE_DEITY)) { + u8 moveFlags = this->skelAnime.moveFlags; + s32 pad; + + this->skelAnime.moveFlags = 0; + Player_SetAction(play, this, func_80854C70, 0); + this->skelAnime.moveFlags = moveFlags; + } else { + s32 var_v1; + s32 pad; + + Player_SetAction(play, this, func_80854C70, 0); + if (func_80123420(this)) { + var_v1 = 2; + } else { + var_v1 = 0; + } + func_8082DB90(play, this, D_8085D294[Player_IsHoldingTwoHandedWeapon(this) + var_v1]); + } + } + + Player_RequestRumble(play, this, 180, 20, 100, SQ(0)); + this->linearVelocity = -18.0f; + func_80840094(play, this); +} + +s32 func_808401F4(PlayState* play, Player* this) { + if (this->meleeWeaponState >= PLAYER_MELEE_WEAPON_STATE_1) { + s32 temp_v0_3; + + if (this->meleeWeaponAnimation < PLAYER_MWA_SPIN_ATTACK_1H) { + if (!(this->meleeWeaponQuads[0].base.atFlags & AT_BOUNCED) && + !(this->meleeWeaponQuads[1].base.atFlags & AT_BOUNCED)) { + if (this->skelAnime.curFrame >= 2.0f) { + CollisionPoly* poly; + s32 bgId; + Vec3f spC8; + Vec3f pos; + Vec3f spB0; + Vec3f* var_a1; + Vec3f* temp_a0 = &this->meleeWeaponInfo[0].tip; + f32 var_fv1; + + if (this->linearVelocity >= 0.0f) { + var_a1 = &this->meleeWeaponInfo[0].base; + if ((this->transformation == PLAYER_FORM_GORON) || (this->actor.id == ACTOR_EN_TEST3)) { + var_a1 = &this->unk_AF0[1]; + } + + var_fv1 = Math_Vec3f_DistXYZAndStoreDiff(temp_a0, var_a1, &spB0); + if (var_fv1 != 0.0f) { + var_fv1 = (var_fv1 + 10.0f) / var_fv1; + } + + spC8.x = temp_a0->x + (spB0.x * var_fv1); + spC8.y = temp_a0->y + (spB0.y * var_fv1); + spC8.z = temp_a0->z + (spB0.z * var_fv1); + if (BgCheck_EntityLineTest2(&play->colCtx, &spC8, temp_a0, &pos, &poly, 1, 0, 0, 1, &bgId, + &this->actor)) { + if (!SurfaceType_IsIgnoredByEntities(&play->colCtx, poly, bgId) && + (SurfaceType_GetFloorType(&play->colCtx, poly, bgId) != FLOOR_TYPE_6) && + !func_800B90AC(play, &this->actor, poly, bgId, &pos)) { + if (this->transformation == PLAYER_FORM_GORON) { + MtxF sp64; + Vec3s actorRot; + DynaPolyActor* temp_v0; + + func_8082DF2C(play); + Player_RequestQuakeAndRumble(play, this, NA_SE_IT_HAMMER_HIT); + if (this->transformation == PLAYER_FORM_GORON) { + Actor_SetPlayerImpact(play, PLAYER_IMPACT_BONK, 2, 100.0f, + &this->actor.world.pos); + func_800C0094(poly, pos.x, pos.y, pos.z, &sp64); + Matrix_MtxFToYXZRot(&sp64, &actorRot, true); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_TEST, pos.x, pos.y, pos.z, + actorRot.x, actorRot.y, actorRot.z, 500); + } + + if (bgId != BGCHECK_SCENE) { + temp_v0 = DynaPoly_GetActor(&play->colCtx, bgId); + + if (((this->meleeWeaponQuads[0].base.atFlags & AT_HIT) && + (&temp_v0->actor == this->meleeWeaponQuads[0].base.at)) || + ((this->meleeWeaponQuads[1].base.atFlags & AT_HIT) && + (&temp_v0->actor == this->meleeWeaponQuads[1].base.at))) { + return false; + } + } + + func_808400CC(play, this); + if (this->transformation != PLAYER_FORM_GORON) { + return true; + } + return false; + } + + if (this->linearVelocity >= 0.0f) { + SurfaceMaterial surfaceMaterial = + SurfaceType_GetMaterial(&play->colCtx, poly, bgId); + + if (surfaceMaterial == SURFACE_MATERIAL_WOOD) { + CollisionCheck_SpawnShieldParticlesWood(play, &pos, &this->actor.projectedPos); + } else { + pos.x += 8.0f * COLPOLY_GET_NORMAL(poly->normal.x); + pos.y += 8.0f * COLPOLY_GET_NORMAL(poly->normal.y); + pos.x += 8.0f * COLPOLY_GET_NORMAL(poly->normal.z); + CollisionCheck_SpawnShieldParticles(play, &pos); + + if (surfaceMaterial == SURFACE_MATERIAL_DIRT_SOFT) { + Player_PlaySfx(this, NA_SE_IT_WALL_HIT_SOFT); + } else { + Player_PlaySfx(this, NA_SE_IT_WALL_HIT_HARD); + } + } + + func_80840094(play, this); + Player_RequestRumble(play, this, 180, 20, 100, SQ(0)); + this->linearVelocity = -14.0f; + } + } + } + } + } + } else { + func_808400CC(play, this); + func_8082DF2C(play); + return true; + } + } + + temp_v0_3 = (this->meleeWeaponQuads[0].base.atFlags & AT_HIT) != 0; + if (temp_v0_3 || (this->meleeWeaponQuads[1].base.atFlags & AT_HIT)) { + if ((this->meleeWeaponAnimation < PLAYER_MWA_SPIN_ATTACK_1H) && + (this->transformation != PLAYER_FORM_GORON)) { + Actor* temp_v1 = this->meleeWeaponQuads[temp_v0_3 ? 0 : 1].base.at; + + if ((temp_v1 != NULL) && (temp_v1->id != ACTOR_EN_KANBAN)) { + func_8082DF2C(play); + } + } + + if (!func_8083FF30(play, this)) { + func_8083FFEC(play, this); + if (this->actor.colChkInfo.atHitEffect == 1) { + this->actor.colChkInfo.damage = 8; + func_80833B18(play, this, 4, 0.0f, 0.0f, this->actor.shape.rot.y, 20); + return true; + } + } + } + } + + return false; +} + +Vec3f D_8085D2A4 = { 0.0f, 0.0f, 5.0f }; + +void func_80840770(PlayState* play, Player* this) { + if (this->unk_AE8 != 0) { + if (this->unk_AE8 > 0) { + this->unk_AE8--; + if (this->unk_AE8 == 0) { + if (this->stateFlags1 & PLAYER_STATE1_8000000) { + PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_swimer_swim_wait, 1.0f, 0.0f, + Animation_GetLastFrame(&gPlayerAnim_link_swimer_swim_wait), ANIMMODE_ONCE, + -16.0f); + } else { + PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_derth_rebirth, 1.0f, 99.0f, + Animation_GetLastFrame(&gPlayerAnim_link_derth_rebirth), ANIMMODE_ONCE, + 0.0f); + } + gSaveContext.healthAccumulator = 0xA0; + this->unk_AE8 = -1; + } + } else if (gSaveContext.healthAccumulator == 0) { + Player_StopCutscene(this); + + this->stateFlags1 &= ~PLAYER_STATE1_80; + if (this->stateFlags1 & PLAYER_STATE1_8000000) { + func_808353DC(play, this); + } else { + func_8085B384(this, play); + } + + this->unk_D6B = 20; + func_808339B4(this, -20); + Audio_SetBgmVolumeOn(); + } + } else if (this->unk_AE7 != 0) { + Player_StopCutscene(this); + this->csId = play->playerCsIds[PLAYER_CS_ID_REVIVE]; + this->unk_AE8 = 60; + Player_SpawnFairy(play, this, &this->actor.world.pos, &D_8085D2A4, 5); + Player_PlaySfx(this, NA_SE_EV_FIATY_HEAL - SFX_FLAG); + } else if (play->gameOverCtx.state == GAMEOVER_DEATH_WAIT_GROUND) { + play->gameOverCtx.state = GAMEOVER_DEATH_FADE_OUT; + } +} + +void func_80840980(Player* this, u16 sfxId) { + Player_AnimSfx_PlayVoice(this, sfxId); +} + +void func_808409A8(PlayState* play, Player* this, f32 speed, f32 yVelocity) { + Actor* heldActor = this->heldActor; + + if (!func_808313A8(play, this, heldActor)) { + heldActor->world.rot.y = this->actor.shape.rot.y; + heldActor->speed = speed; + heldActor->velocity.y = yVelocity; + func_808309CC(play, this); + Player_PlaySfx(this, NA_SE_PL_THROW); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_SWORD_N); + } +} + +// Check if bonked and if so, rumble, play sound, etc. +s32 func_80840A30(PlayState* play, Player* this, f32* arg2, f32 arg3) { + Actor* cylinderOc = NULL; + + if (arg3 <= *arg2) { + // If interacting with a wall and close to facing it + if (((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (D_80862B24 < 0x1C00)) || + // or, impacting something's cylinder + (((this->cylinder.base.ocFlags1 & OC1_HIT) && (cylinderOc = this->cylinder.base.oc) != NULL) && + // and that something is a Beaver Race ring, + ((cylinderOc->id == ACTOR_EN_TWIG) || + // or something is a tree and `this` is close to facing it (note the this actor's facing direction would + // be antiparallel to the cylinder's actor's yaw if this was directly facing it) + (((cylinderOc->id == ACTOR_EN_WOOD02) || (cylinderOc->id == ACTOR_EN_SNOWWD) || + (cylinderOc->id == ACTOR_OBJ_TREE)) && + (ABS_ALT(BINANG_SUB(this->actor.world.rot.y, cylinderOc->yawTowardsPlayer)) > 0x6000))))) { + + if (!func_8082DA90(play)) { + if (this->doorType == PLAYER_DOORTYPE_STAIRCASE) { + func_8085B384(this, play); + return true; + } + + if (cylinderOc != NULL) { + cylinderOc->home.rot.y = 1; + } else if (this->actor.wallBgId != BGCHECK_SCENE) { // i.e. was an actor + DynaPolyActor* wallPolyActor = DynaPoly_GetActor(&play->colCtx, this->actor.wallBgId); + + // Large crates, barrels and palm trees + if ((wallPolyActor != NULL) && + ((wallPolyActor->actor.id == ACTOR_OBJ_KIBAKO2) || + (wallPolyActor->actor.id == ACTOR_OBJ_TARU) || (wallPolyActor->actor.id == ACTOR_OBJ_YASI))) { + wallPolyActor->actor.home.rot.z = 1; + } + } + + if (!(this->stateFlags3 & PLAYER_STATE3_1000)) { + if ((this->stateFlags3 & PLAYER_STATE3_8000) && (func_8084CA24 != this->actionFunc)) { + Player_SetAction(play, this, func_80851B58, 0); + func_8082DB90(play, this, &gPlayerAnim_link_swimer_swim_hit); + func_8082DD2C(play, this); + this->linearVelocity *= 0.2f; + } else { + Player_SetAction(play, this, func_8084C6EC, 0); + Player_AnimationPlayOnce(play, this, D_8085BE84[PLAYER_ANIMGROUP_16][this->modelAnimType]); + this->unk_AE8 = 1; + } + } + + this->linearVelocity = -this->linearVelocity; + Player_RequestQuake(play, 33267, 3, 12); + Player_RequestRumble(play, this, 255, 20, 150, SQ(0)); + Actor_SetPlayerImpact(play, PLAYER_IMPACT_BONK, 2, 100.0f, &this->actor.world.pos); + Player_PlaySfx(this, NA_SE_PL_BODY_HIT); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_CLIMB_END); + return true; + } + } + } + return false; +} + +s32 func_80840CD4(Player* this, PlayState* play) { + if (func_808387A0(play, this)) { + this->stateFlags2 |= PLAYER_STATE2_20000; + } else if (!CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_B)) { + PlayerMeleeWeaponAnimation meleeWeaponAnim; + + if ((this->unk_B08 >= 0.85f) || func_808333CC(this)) { + meleeWeaponAnim = D_8085CF84[Player_IsHoldingTwoHandedWeapon(this)]; + } else { + meleeWeaponAnim = D_8085CF80[Player_IsHoldingTwoHandedWeapon(this)]; + } + func_80833864(play, this, meleeWeaponAnim); + func_808339B4(this, -8); + this->stateFlags2 |= PLAYER_STATE2_20000; + if (this->unk_AE3[this->unk_ADE] == 0) { + this->stateFlags2 |= PLAYER_STATE2_40000000; + } + } else { + return false; + } + + return true; +} + +void func_80840DEC(Player* this, PlayState* play) { + Player_SetAction(play, this, func_8084CE84, 1); +} + +void func_80840E24(Player* this, PlayState* play) { + Player_SetAction(play, this, func_8084D18C, 1); +} + +void func_80840E5C(Player* this, PlayState* play) { + func_808369F4(this, play); + func_8082DC38(this); + func_8082E438(play, this, D_8085CF68[Player_IsHoldingTwoHandedWeapon(this)]); + this->currentYaw = this->actor.shape.rot.y; +} + +void func_80840EC0(Player* this, PlayState* play) { + Player_SetAction(play, this, func_8084CCEC, 1); + Player_AnimationPlayLoop(play, this, D_8085CF60[Player_IsHoldingTwoHandedWeapon(this)]); + this->unk_AE8 = 1; + this->unk_B38 = 0.0f; +} + +// Spin attack size +void func_80840F34(Player* this) { + Math_StepToF(&this->unk_B08, (CHECK_WEEKEVENTREG(WEEKEVENTREG_23_02)) ? 1.0f : 0.5f, 0.02f); +} + +s32 func_80840F90(PlayState* play, Player* this, CsCmdActorCue* playerAction, f32 arg3, s16 arg4, s32 arg5) { + if ((arg5 != 0) && (this->linearVelocity == 0.0f)) { + return PlayerAnimation_Update(play, &this->skelAnime); + } + + if (arg5 != 2) { + f32 halfUpdateRate = R_UPDATE_RATE / 2.0f; + f32 curDiffX = playerAction->endPos.x - this->actor.world.pos.x; + f32 curDiffZ = playerAction->endPos.z - this->actor.world.pos.z; + f32 scaledCurDist = sqrtf(SQ(curDiffX) + SQ(curDiffZ)) / halfUpdateRate; + s32 framesLeft = (playerAction->endFrame - play->csCtx.curFrame) + 1; + + arg4 = Math_Atan2S_XY(curDiffZ, curDiffX); + + if (arg5 == 1) { + f32 distX = playerAction->endPos.x - playerAction->startPos.x; + f32 distZ = playerAction->endPos.z - playerAction->startPos.z; + s32 temp = (((sqrtf(SQ(distX) + SQ(distZ)) / halfUpdateRate) / + (playerAction->endFrame - playerAction->startFrame)) / + 1.5f) * + 4.0f; + if (temp >= framesLeft) { + arg3 = 0.0f; + arg4 = this->actor.shape.rot.y; + } else { + arg3 = scaledCurDist / ((framesLeft - temp) + 1); + } + } else { + arg3 = scaledCurDist / framesLeft; + } + } + + this->stateFlags2 |= PLAYER_STATE2_20; + func_8083F57C(this, play); + func_8083CB58(this, arg3, arg4); + if ((arg3 == 0.0f) && (this->linearVelocity == 0.0f)) { + func_80839CD8(this, play); + } + + return false; +} + +s32 func_808411D4(PlayState* play, Player* this, f32* arg2, s32 arg3) { + f32 xDiff = this->unk_3A0.x - this->actor.world.pos.x; + f32 yDiff = this->unk_3A0.z - this->actor.world.pos.z; + s32 sp2C; + s32 pad2; + s16 var_v1; + + sp2C = sqrtf(SQ(xDiff) + SQ(yDiff)); + var_v1 = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_3A0); + if (sp2C < arg3) { + *arg2 = 0.0f; + var_v1 = this->actor.shape.rot.y; + } + if (func_80840F90(play, this, NULL, *arg2, var_v1, 2)) { + return 0; + } + return sp2C; +} + +void Player_InitMode_0(PlayState* play, Player* this) { + this->actor.update = func_801229EC; + this->actor.draw = NULL; +} + +void Player_InitMode_2(PlayState* play, Player* this) { + Player_SetAction(play, this, func_80854118, 0); + this->stateFlags1 |= PLAYER_STATE1_20000000; + PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_okarina_warp_goal, 2.0f / 3.0f, 0.0f, 24.0f, + ANIMMODE_ONCE, 0.0f); + this->actor.world.pos.y += 800.0f; +} + +u8 D_8085D2B0[] = { + ITEM_SWORD_RAZOR, + ITEM_SWORD_KOKIRI, +}; + +// OoT leftover? +void func_80841358(PlayState* play, Player* this, s32 arg2) { + ItemId item; + PlayerItemAction itemAction; + + //! @bug OoB read if player is goron, deku or human + item = D_8085D2B0[this->transformation]; + itemAction = sItemItemActions[item]; + func_808317C4(this); + func_8082DCA0(play, this); + this->heldItemId = item; + this->nextModelGroup = Player_ActionToModelGroup(this, itemAction); + func_8082F8BC(play, this, itemAction); + func_808309CC(play, this); + if (arg2) { + Player_PlaySfx(this, NA_SE_IT_SWORD_PICKOUT); + } +} + +Vec3f D_8085D2B4 = { -1.0f, 69.0f, 20.0f }; + +void Player_InitMode_1(PlayState* play, Player* this) { + Player_SetAction(play, this, func_80852FD4, 0); + this->stateFlags1 |= PLAYER_STATE1_20000000; + Math_Vec3f_Copy(&this->actor.world.pos, &D_8085D2B4); + this->currentYaw = this->actor.shape.rot.y = -0x8000; + PlayerAnimation_Change(play, &this->skelAnime, this->ageProperties->unk_A8, 2.0f / 3.0f, 0.0f, 0.0f, ANIMMODE_ONCE, + 0.0f); + func_8082E920(play, this, + ANIM_FLAG_1 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_4 | ANIM_FLAG_8 | ANIM_FLAG_80 | ANIM_FLAG_200); + if (this->transformation == PLAYER_FORM_FIERCE_DEITY) { + func_80841358(play, this, false); + } + this->unk_AE8 = 20; +} + +void Player_InitMode_3(PlayState* play, Player* this) { + Player_SetAction(play, this, func_8085437C, 0); + func_8082E920(play, this, ANIM_FLAG_1 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_8 | ANIM_FLAG_NOMOVE | ANIM_FLAG_80); +} + +void Player_InitMode_4(PlayState* play, Player* this) { + func_80834DB8(this, &gPlayerAnim_link_normal_jump, 12.0f, play); + Player_SetAction(play, this, func_8085439C, 0); + this->stateFlags1 |= PLAYER_STATE1_20000000; + this->fallStartHeight = this->actor.world.pos.y; +} + +void Player_InitMode_7(PlayState* play, Player* this) { + func_80833B18(play, this, 1, 2.0f, 2.0f, this->actor.shape.rot.y + 0x8000, 0); +} + +void Player_InitMode_5(PlayState* play, Player* this) { + Player_SetAction(play, this, func_808540A0, 0); + this->actor.draw = NULL; + this->stateFlags1 |= PLAYER_STATE1_20000000; +} + +void Player_InitMode_6(PlayState* play, Player* this) { + if (gSaveContext.save.isOwlSave) { + Player_SetAction(play, this, func_808496AC, 0); + func_8082E514(play, this, D_8085BE84[PLAYER_ANIMGROUP_43][this->modelAnimType]); + this->stateFlags1 |= PLAYER_STATE1_20000000; + this->unk_AE8 = 0x28; + gSaveContext.save.isOwlSave = false; + } else { + Player_SetAction(play, this, func_80849FE0, 0); + func_8082E514(play, this, D_8085BE84[PLAYER_ANIMGROUP_43][this->modelAnimType]); + this->stateFlags1 |= PLAYER_STATE1_20000000; + this->stateFlags2 |= PLAYER_STATE2_20000000; + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_TEST7, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, ENTEST7_MINUS1); + } +} + +// InitModes 0x8 and 0x9 +void func_80841744(PlayState* play, Player* this) { + Player_SetAction(play, this, func_80855C28, 0); + if (PLAYER_GET_INITMODE(&this->actor) == PLAYER_INITMODE_8) { + Player_AnimationPlayOnceReverse(play, this, D_8085D17C[this->transformation]); + this->itemAction = PLAYER_IA_OCARINA; + Player_SetModels(this, Player_ActionToModelGroup(this, this->itemAction)); + } else { + func_8082DB60(play, this, D_8085BE84[PLAYER_ANIMGROUP_43][this->modelAnimType]); + } + this->stateFlags1 |= PLAYER_STATE1_20000000; + this->unk_ABC = -10000.0f; + this->unk_AE8 = 0x2710; + this->unk_B10[5] = 8.0f; +} + +static InitChainEntry sInitChain[] = { + ICHAIN_F32(targetArrowOffset, 500, ICHAIN_STOP), +}; + +Vec3s D_8085D2C4 = { -57, 3377, 0 }; + +void Player_InitCommon(Player* this, PlayState* play, FlexSkeletonHeader* skelHeader) { + Actor_ProcessInitChain(&this->actor, sInitChain); + this->currentYaw = this->actor.world.rot.y; + + if ((PLAYER_GET_INITMODE(&this->actor) != PLAYER_INITMODE_TELESCOPE) && + ((gSaveContext.respawnFlag != 2) || + (gSaveContext.respawn[RESPAWN_MODE_RETURN].playerParams != PLAYER_PARAMS(0xFF, PLAYER_INITMODE_TELESCOPE)))) { + func_808309CC(play, this); + SkelAnime_InitPlayer(play, &this->skelAnime, skelHeader, D_8085BE84[PLAYER_ANIMGROUP_0][this->modelAnimType], + 1 | 8, this->jointTableBuffer, this->morphTableBuffer, PLAYER_LIMB_MAX); + this->skelAnime.baseTransl = D_8085D2C4; + + SkelAnime_InitPlayer(play, &this->unk_284, skelHeader, func_8082ED20(this), 1 | 8, this->unk_929, this->unk_9C8, + PLAYER_LIMB_MAX); + this->unk_284.baseTransl = D_8085D2C4; + + if (this->transformation == PLAYER_FORM_GORON) { + SkelAnime_InitFlex(play, &this->unk_2C8, &gLinkGoronShieldingSkel, &gLinkGoronShieldingAnim, + this->jointTable, this->morphTable, LINK_GORON_SHIELDING_LIMB_MAX); + } + + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFeet, this->ageProperties->shadowScale); + } + + this->subCamId = CAM_ID_NONE; + Collider_InitAndSetCylinder(play, &this->cylinder, &this->actor, &D_8085C2EC); + Collider_InitAndSetCylinder(play, &this->shieldCylinder, &this->actor, &D_8085C318); + Collider_InitAndSetQuad(play, &this->meleeWeaponQuads[0], &this->actor, &D_8085C344); + Collider_InitAndSetQuad(play, &this->meleeWeaponQuads[1], &this->actor, &D_8085C344); + Collider_InitAndSetQuad(play, &this->shieldQuad, &this->actor, &D_8085C394); +} + +void func_80841A50(PlayState* play, Player* this) { + if ((play->roomCtx.curRoom.num >= 0) && (play->roomCtx.prevRoom.num < 0)) { + Math_Vec3f_Copy(&this->unk_3C0, &this->actor.world.pos); + this->unk_3CC = this->actor.shape.rot.y; + this->unk_3CE = play->roomCtx.curRoom.num; + this->unk_3CF = 1; + } +} + +typedef void (*PlayerInitModeFunc)(PlayState*, Player*); + +// Initialisation functions for various gameplay modes depending on spawn params. There may be at most 0x10 due to it +// using a single nybble. +// sInitModeFuncs +PlayerInitModeFunc D_8085D2CC[0x10] = { + /* 0x0 */ Player_InitMode_0, + /* 0x1 */ Player_InitMode_1, + /* 0x2 */ Player_InitMode_2, + /* 0x3 */ Player_InitMode_3, + /* 0x4 */ Player_InitMode_4, + /* 0x5 */ Player_InitMode_5, + /* 0x6 */ Player_InitMode_6, + /* 0x7 */ Player_InitMode_7, + /* 0x8 */ func_80841744, + /* 0x9 */ func_80841744, + /* 0xA */ func_8083ADF0, + /* 0xB */ Player_InitMode_B, + /* 0xC */ Player_InitMode_Telescope, + /* 0xD */ Player_InitMode_D, + /* 0xE */ func_8083ADF0, + /* 0xF */ Player_InitMode_F, +}; + +// sBlureInit +EffectBlureInit2 D_8085D30C = { + 0, 8, 0, { 255, 255, 255, 255 }, { 255, 255, 255, 64 }, { 255, 255, 255, 0 }, { 255, 255, 255, 0 }, 4, + 0, 2, 0, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, +}; + +// sTireMarkInit ? +EffectTireMarkInit D_8085D330 = { 0, 63, { 0, 0, 15, 100 } }; + +// sTireMarkGoronColor ? +Color_RGBA8 D_8085D338 = { 0, 0, 15, 100 }; +// sTireMarkOtherColor ? +Color_RGBA8 D_8085D33C = { 0, 0, 0, 150 }; +Vec3f D_8085D340 = { 0.0f, 50.0f, 0.0f }; + +void Player_Init(Actor* thisx, PlayState* play) { + s32 pad; + Player* this = THIS; + s8 objBankIndex; + s32 respawnFlag; + s32 var_a1; + PlayerInitMode initMode; + + play->playerInit = Player_InitCommon; + play->playerUpdate = Player_UpdateCommon; + play->unk_18770 = func_8085B170; + play->startPlayerFishing = Player_StartFishing; + play->grabPlayer = Player_GrabPlayer; + play->startPlayerCutscene = func_8085B28C; + play->func_18780 = func_8085B384; + play->damagePlayer = Player_InflictDamage; + play->talkWithPlayer = Player_TalkWithPlayer; + play->unk_1878C = func_8085B74C; + play->unk_18790 = func_8085B820; + play->unk_18794 = func_8085B854; + play->setPlayerTalkAnim = func_8085B930; + + gActorOverlayTable[ACTOR_PLAYER].initInfo->objectId = GAMEPLAY_KEEP; + + this->actor.room = -1; + this->csId = CS_ID_NONE; + + if (this->actor.shape.rot.x != 0) { + this->transformation = this->actor.shape.rot.x - 1; + + objBankIndex = Object_GetIndex(&play->objectCtx, gPlayerFormObjectIndices[this->transformation]); + this->actor.objBankIndex = objBankIndex; + if (objBankIndex < 0) { + Actor_Kill(&this->actor); + return; + } + + Actor_SetObjectDependency(play, &this->actor); + } else { + this->transformation = gSaveContext.save.playerForm; + if (this->transformation == PLAYER_FORM_HUMAN) { + if (gSaveContext.save.equippedMask == PLAYER_MASK_GIANT) { + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; + } + this->currentMask = gSaveContext.save.equippedMask; + } else { + this->currentMask = this->transformation + PLAYER_MASK_FIERCE_DEITY; + gSaveContext.save.equippedMask = PLAYER_MASK_NONE; + } + + Inventory_UpdateDeitySwordEquip(play); + + this->unk_B28 = 0; + this->unk_B90 = 0; + this->unk_B92 = 0; + this->unk_B94 = 0; + this->unk_B96 = 0; + this->stateFlags1 &= ~(PLAYER_STATE1_8 | PLAYER_STATE1_1000 | PLAYER_STATE1_1000000 | PLAYER_STATE1_2000000); + this->stateFlags2 &= ~(PLAYER_STATE2_20000 | PLAYER_STATE2_1000000 | PLAYER_STATE2_40000000); + this->stateFlags3 &= + ~(PLAYER_STATE3_8 | PLAYER_STATE3_40 | PLAYER_STATE3_80 | PLAYER_STATE3_100 | PLAYER_STATE3_200 | + PLAYER_STATE3_800 | PLAYER_STATE3_1000 | PLAYER_STATE3_2000 | PLAYER_STATE3_8000 | PLAYER_STATE3_10000 | + PLAYER_STATE3_40000 | PLAYER_STATE3_80000 | PLAYER_STATE3_100000 | PLAYER_STATE3_200000 | + PLAYER_STATE3_800000 | PLAYER_STATE3_1000000 | PLAYER_STATE3_2000000); + this->unk_B08 = 0.0f; + this->unk_B0C = 0.0f; + } + + if (this->transformation == PLAYER_FORM_ZORA) { + if (this->stateFlags1 & PLAYER_STATE1_8000000) { + this->unk_B10[0] = 1.0f; + } else { + this->unk_B10[0] = 0.0f; + } + } + + this->actor.flags &= ~(ACTOR_FLAG_CAN_PRESS_HEAVY_SWITCH | ACTOR_FLAG_CAN_PRESS_SWITCH); + if (this->transformation != PLAYER_FORM_DEKU) { + this->actor.flags |= ACTOR_FLAG_CAN_PRESS_SWITCH; + if (this->transformation == PLAYER_FORM_GORON) { + this->actor.flags |= ACTOR_FLAG_CAN_PRESS_HEAVY_SWITCH; + } + } + + this->ageProperties = &sPlayerAgeProperties[this->transformation]; + + this->itemAction = PLAYER_IA_NONE; + this->heldItemAction = PLAYER_IA_NONE; + this->heldItemId = ITEM_NONE; + + func_80831990(play, this, ITEM_NONE); + Player_SetEquipmentData(play, this); + this->prevBoots = this->currentBoots; + Player_InitCommon(this, play, gPlayerSkeletons[this->transformation]); + + if (this->actor.shape.rot.z != 0) { + EffectTireMark* tireMark; + + this->actor.shape.rot.z = 0; + Player_OverrideBlureColors(play, this, 0, 4); + + tireMark = Effect_GetByIndex(this->meleeWeaponEffectIndex[2]); + if (this->transformation == PLAYER_FORM_GORON) { + tireMark->color = D_8085D338; + } else { + tireMark->color = D_8085D33C; + } + + if ((this->csMode == PLAYER_CSMODE_9) || (this->csMode == PLAYER_CSMODE_93)) { + Player_SetAction(play, this, func_8085B08C, 0); + this->stateFlags1 |= PLAYER_STATE1_20000000; + } else { + Player_SetAction(play, this, func_80855818, 0); + this->actor.shape.rot.y = this->currentYaw; + + if (this->prevMask != PLAYER_MASK_NONE) { + func_8082DB90(play, this, &gPlayerAnim_cl_maskoff); + } else if (this->transformation == PLAYER_FORM_HUMAN) { + PlayerAnimation_Change(play, &this->skelAnime, D_8085D160[this->transformation], -2.0f / 3.0f, 9.0f, + 0.0f, ANIMMODE_ONCE, 0.0f); + } else { + func_8082DB60(play, this, &gPlayerAnim_cl_setmaskend); + } + + this->stateFlags1 |= (PLAYER_STATE1_10000000 | PLAYER_STATE1_20000000); + this->stateFlags3 |= PLAYER_STATE3_20000; + this->unk_B10[5] = 3.0f; + } + return; + } + + this->prevMask = this->currentMask; + + Effect_Add(play, &this->meleeWeaponEffectIndex[0], EFFECT_BLURE2, 0, 0, &D_8085D30C); + Effect_Add(play, &this->meleeWeaponEffectIndex[1], EFFECT_BLURE2, 0, 0, &D_8085D30C); + + Player_OverrideBlureColors(play, this, 0, 4); + if (this->transformation == PLAYER_FORM_GORON) { + D_8085D330.color = D_8085D338; + } else { + D_8085D330.color = D_8085D33C; + } + Effect_Add(play, &this->meleeWeaponEffectIndex[2], EFFECT_TIRE_MARK, 0, 0, &D_8085D330); + + if (this->actor.shape.rot.x != 0) { + this->actor.shape.rot.x = 0; + this->csMode = PLAYER_CSMODE_68; + Player_SetAction(play, this, func_8085B08C, 0); + this->stateFlags1 |= PLAYER_STATE1_20000000; + return; + } + + play->unk_1887C = 0; + play->unk_1887D = 0; + play->unk_1887E = 0; + this->giObjectSegment = ZeldaArena_Malloc(0x2000); + this->maskObjectSegment = ZeldaArena_Malloc(0x3800); + + Lights_PointNoGlowSetInfo(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 255, 128, 0, -1); + this->lightNode = LightContext_InsertLight(play, &play->lightCtx, &this->lightInfo); + Play_AssignPlayerCsIdsFromScene(&play->state, this->actor.csId); + + respawnFlag = gSaveContext.respawnFlag; + if (respawnFlag != 0) { + if (respawnFlag == -3) { + this->actor.params = gSaveContext.respawn[RESPAWN_MODE_UNK_3].playerParams; + } else { + if ((respawnFlag == 1) || (respawnFlag == -1)) { + this->unk_D6A = -2; + } + + if (respawnFlag != -7) { + s32 respawnIndex; + + if ((respawnFlag == -8) || (respawnFlag == -5) || (respawnFlag == -4)) { + respawnFlag = 1; + } + + if ((respawnFlag < 0) && (respawnFlag != -1) && (respawnFlag != -6)) { + respawnIndex = RESPAWN_MODE_DOWN; + } else { + respawnIndex = (respawnFlag < 0) ? RESPAWN_MODE_TOP : respawnFlag - 1; + + Math_Vec3f_Copy(&this->actor.world.pos, &gSaveContext.respawn[respawnIndex].pos); + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); + Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); + Math_Vec3f_Copy(&this->actor.focus.pos, &this->actor.world.pos); + + this->fallStartHeight = this->actor.world.pos.y; + + this->currentYaw = this->actor.shape.rot.y = gSaveContext.respawn[respawnIndex].yaw; + this->actor.params = gSaveContext.respawn[respawnIndex].playerParams; + } + + play->actorCtx.sceneFlags.switches[2] = gSaveContext.respawn[respawnIndex].tempSwitchFlags; + play->actorCtx.sceneFlags.collectible[1] = gSaveContext.respawn[respawnIndex].unk_18; + play->actorCtx.sceneFlags.collectible[2] = gSaveContext.respawn[respawnIndex].tempCollectFlags; + } + } + } + + var_a1 = ((respawnFlag == 4) || (gSaveContext.respawnFlag == -4)) ? 1 : 0; + if (func_801226E0(play, var_a1) == 0) { + gSaveContext.respawn[RESPAWN_MODE_DOWN].playerParams = PLAYER_PARAMS(thisx->params, PLAYER_INITMODE_D); + } + + gSaveContext.respawn[RESPAWN_MODE_DOWN].data = 1; + if (respawnFlag == 0) { + gSaveContext.respawn[RESPAWN_MODE_TOP] = gSaveContext.respawn[RESPAWN_MODE_DOWN]; + } + gSaveContext.respawn[RESPAWN_MODE_TOP].playerParams = + PLAYER_PARAMS(gSaveContext.respawn[RESPAWN_MODE_TOP].playerParams, PLAYER_INITMODE_D); + + initMode = PLAYER_GET_INITMODE(&this->actor); + if (((initMode == PLAYER_INITMODE_5) || (initMode == PLAYER_INITMODE_6)) && + (gSaveContext.save.cutsceneIndex >= 0xFFF0)) { + initMode = PLAYER_INITMODE_D; + } + + D_8085D2CC[initMode](play, this); + + if ((this->actor.draw != NULL) && gSaveContext.save.hasTatl && + ((gSaveContext.gameMode == GAMEMODE_NORMAL) || (gSaveContext.gameMode == GAMEMODE_END_CREDITS)) && + (play->sceneId != SCENE_SPOT00)) { + this->tatlActor = Player_SpawnFairy(play, this, &this->actor.world.pos, &D_8085D340, 0); + + if (gSaveContext.dogParams != 0) { + gSaveContext.dogParams |= 0x8000; + } + + if (gSaveContext.powderKegTimer != 0) { + this->nextModelGroup = Player_ActionToModelGroup(this, PLAYER_IA_POWDER_KEG); + this->heldItemId = ITEM_POWDER_KEG; + func_8082F8BC(play, this, PLAYER_IA_POWDER_KEG); + func_808313F0(this, play); + } else if (gSaveContext.unk_1014 != 0) { + func_8082F5FC(this, Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_MM, + this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, 0x8000)); + func_808313F0(this, play); + } + } + + Minimap_SavePlayerRoomInitInfo(play); + func_80841A50(play, this); + this->unk_3CF = 0; + R_PLAY_FILL_SCREEN_ON = 0; +} + +void func_80842510(s16* arg0) { + s16 temp_ft0; + + temp_ft0 = (ABS_ALT(*arg0) * 100.0f) / 1000.0f; + temp_ft0 = CLAMP(temp_ft0, 0x190, 0xFA0); + + Math_ScaledStepToS(arg0, 0, temp_ft0); +} + +void func_808425B4(Player* this) { + if (!(this->unk_AA6 & 2)) { + s16 sp26 = this->actor.focus.rot.y - this->actor.shape.rot.y; + + func_80842510(&sp26); + this->actor.focus.rot.y = this->actor.shape.rot.y + sp26; + } + if (!(this->unk_AA6 & 1)) { + func_80842510(&this->actor.focus.rot.x); + } + if (!(this->unk_AA6 & 8)) { + func_80842510(&this->headLimbRot.x); + } + if (!(this->unk_AA6 & 0x40)) { + func_80842510(&this->upperLimbRot.x); + } + if (!(this->unk_AA6 & 4)) { + func_80842510(&this->actor.focus.rot.z); + } + if (!(this->unk_AA6 & 0x10)) { + func_80842510(&this->headLimbRot.y); + } + if (!(this->unk_AA6 & 0x20)) { + func_80842510(&this->headLimbRot.z); + } + if (!(this->unk_AA6 & 0x80)) { + if (this->unk_AA8 != 0) { + func_80842510(&this->unk_AA8); + } else { + func_80842510(&this->upperLimbRot.y); + } + } + if (!(this->unk_AA6 & 0x100)) { + func_80842510(&this->upperLimbRot.z); + } + + this->unk_AA6 = 0; +} + +/** + * Sets the DoAction for the interface A/B buttons, depending on a significant number of things + */ +void Player_SetDoAction(PlayState* play, Player* this) { + DoAction doActionB; + s32 sp38; + + if (this != GET_PLAYER(play)) { + return; + } + + doActionB = -1; + sp38 = func_801242B4(this) || (func_8084CA24 == this->actionFunc); + + // Set B do action + if (this->transformation == PLAYER_FORM_GORON) { + if (this->stateFlags3 & PLAYER_STATE3_80000) { + doActionB = DO_ACTION_NONE; + } else if (this->stateFlags3 & PLAYER_STATE3_1000) { + doActionB = DO_ACTION_POUND; + } else { + doActionB = DO_ACTION_PUNCH; + } + } else if (this->transformation == PLAYER_FORM_ZORA) { + if ((!(this->stateFlags1 & PLAYER_STATE1_8000000)) || + (!sp38 && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND))) { + doActionB = DO_ACTION_PUNCH; + } else { + doActionB = DO_ACTION_DIVE; + } + } else if (this->transformation == PLAYER_FORM_DEKU) { + doActionB = DO_ACTION_SHOOT; + } else { // PLAYER_FORM_HUMAN + if (this->currentMask == PLAYER_MASK_BLAST) { + doActionB = DO_ACTION_EXPLODE; + } else if (this->currentMask == PLAYER_MASK_BREMEN) { + doActionB = DO_ACTION_MARCH; + } else if (this->currentMask == PLAYER_MASK_KAMARO) { + doActionB = DO_ACTION_DANCE; + } + } + + if (doActionB > -1) { + func_801155B4(play, doActionB); + } else if (play->interfaceCtx.unk_21C != 0) { + play->interfaceCtx.unk_21C = 0; + play->interfaceCtx.bButtonDoAction = 0; + } + + // Set A do action + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) || + ((play->msgCtx.currentTextId >= 0x100) && (play->msgCtx.currentTextId <= 0x200)) || + ((play->msgCtx.currentTextId >= 0x1BB2) && (play->msgCtx.currentTextId < 0x1BB7))) { + Actor* heldActor = this->heldActor; + Actor* interactRangeActor = this->interactRangeActor; + s32 pad; + s32 sp28 = this->unk_AE3[this->unk_ADE]; + s32 sp24; + DoAction doActionA = + ((this->transformation == PLAYER_FORM_GORON) && !(this->stateFlags1 & PLAYER_STATE1_400000)) + ? DO_ACTION_CURL + : DO_ACTION_NONE; + + if (play->actorCtx.flags & ACTORCTX_FLAG_PICTO_BOX_ON) { + doActionA = DO_ACTION_SNAP; + } else if (Player_InBlockingCsMode(play, this) || (this->actor.flags & ACTOR_FLAG_20000000) || + (this->stateFlags1 & PLAYER_STATE1_1000) || (this->stateFlags3 & PLAYER_STATE3_80000) || + (func_80854430 == this->actionFunc)) { + doActionA = DO_ACTION_NONE; + } else if (this->stateFlags1 & PLAYER_STATE1_100000) { + doActionA = DO_ACTION_RETURN; + } else if ((this->heldItemAction == PLAYER_IA_FISHING_ROD) && (this->unk_B28 != 0)) { + doActionA = (this->unk_B28 == 2) ? DO_ACTION_REEL : DO_ACTION_NONE; + doActionA = (this->unk_B28 == 2) ? DO_ACTION_REEL : DO_ACTION_NONE; //! FAKE: duplicated statement + } else if (this->stateFlags3 & PLAYER_STATE3_2000) { + doActionA = DO_ACTION_DOWN; + } else if ((this->doorType != PLAYER_DOORTYPE_NONE) && (this->doorType != PLAYER_DOORTYPE_STAIRCASE) && + !(this->stateFlags1 & PLAYER_STATE1_800)) { + doActionA = DO_ACTION_OPEN; + } else if (this->stateFlags3 & PLAYER_STATE3_200000) { + static u8 D_8085D34C[] = { + DO_ACTION_1, DO_ACTION_2, DO_ACTION_3, DO_ACTION_4, DO_ACTION_5, DO_ACTION_6, DO_ACTION_7, DO_ACTION_8, + }; + + doActionA = D_8085D34C[this->remainingHopsCounter]; + } else if ((!(this->stateFlags1 & PLAYER_STATE1_800) || (heldActor == NULL)) && (interactRangeActor != NULL) && + (this->getItemId < GI_NONE)) { + doActionA = DO_ACTION_OPEN; + } else if (!sp38 && (this->stateFlags2 & PLAYER_STATE2_1)) { + doActionA = DO_ACTION_GRAB; + } else if ((this->stateFlags2 & PLAYER_STATE2_4) || + (!(this->stateFlags1 & PLAYER_STATE1_800000) && (this->rideActor != NULL))) { + doActionA = DO_ACTION_CLIMB; + } else if ((this->stateFlags1 & PLAYER_STATE1_800000) && + (!EN_HORSE_CHECK_4((EnHorse*)this->rideActor) && (func_808505D0 != this->actionFunc))) { + if ((this->stateFlags2 & PLAYER_STATE2_2) && (this->talkActor != NULL)) { + if ((this->talkActor->category == ACTORCAT_NPC) || (this->talkActor->id == ACTOR_DM_CHAR08)) { + doActionA = DO_ACTION_SPEAK; + } else { + doActionA = DO_ACTION_CHECK; + } + } else if (!func_8082DA90(play) && !func_800B7128(this) && !(this->stateFlags1 & PLAYER_STATE1_100000)) { + doActionA = DO_ACTION_FASTER; + } else { + doActionA = DO_ACTION_NONE; + } + } else if ((this->stateFlags2 & PLAYER_STATE2_2) && (this->talkActor != NULL)) { + if ((this->talkActor->category == ACTORCAT_NPC) || (this->talkActor->category == ACTORCAT_ENEMY) || + (this->talkActor->id == ACTOR_DM_CHAR08)) { + doActionA = DO_ACTION_SPEAK; + } else { + doActionA = DO_ACTION_CHECK; + } + } else if ((this->stateFlags1 & (PLAYER_STATE1_2000 | PLAYER_STATE1_200000)) || + ((this->stateFlags1 & PLAYER_STATE1_800000) && (this->stateFlags2 & PLAYER_STATE2_400000))) { + doActionA = DO_ACTION_DOWN; + } else if ((this->stateFlags1 & PLAYER_STATE1_800) && (this->getItemId == GI_NONE) && (heldActor != NULL)) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (heldActor->id == ACTOR_EN_NIW)) { + if (!func_8083D738(this, heldActor)) { + doActionA = DO_ACTION_DROP; + } else { + doActionA = DO_ACTION_THROW; + } + } else { + doActionA = DO_ACTION_NONE; + } + } else if (this->stateFlags2 & PLAYER_STATE2_10000) { + doActionA = DO_ACTION_GRAB; + } else if (this->stateFlags2 & PLAYER_STATE2_800) { + static u8 D_8085D354[] = { DO_ACTION_1, DO_ACTION_2 }; + s32 var_v0; + + var_v0 = ((120.0f - this->actor.depthInWater) / 40.0f); + var_v0 = CLAMP(var_v0, 0, ARRAY_COUNT(D_8085D354) - 1); + + doActionA = D_8085D354[var_v0]; + } else if (this->stateFlags3 & PLAYER_STATE3_100) { + doActionA = DO_ACTION_JUMP; + } else if (this->stateFlags3 & PLAYER_STATE3_1000) { + doActionA = DO_ACTION_RETURN; + } else if (!func_8082FBE8(this) && (this->stateFlags1 & PLAYER_STATE1_8000000) && !sp38) { + doActionA = DO_ACTION_SURFACE; + } else if (((this->transformation != PLAYER_FORM_DEKU) && + (sp38 || ((this->stateFlags1 & PLAYER_STATE1_8000000) && + !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)))) || + ((this->transformation == PLAYER_FORM_DEKU) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + func_800C9DDC(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { + doActionA = (this->transformation == PLAYER_FORM_ZORA) ? DO_ACTION_SWIM + : ((this->stateFlags1 & PLAYER_STATE1_8000000) && (interactRangeActor != NULL) && + (interactRangeActor->id == ACTOR_EN_ZOG)) + ? DO_ACTION_GRAB + : DO_ACTION_DIVE; + } else { + sp24 = func_8082FBE8(this); + if ((sp24 && (this->transformation != PLAYER_FORM_DEKU)) || !(this->stateFlags1 & PLAYER_STATE1_400000) || + !Player_IsGoronOrDeku(this)) { + if ((this->transformation != PLAYER_FORM_GORON) && + !(this->stateFlags1 & (PLAYER_STATE1_4 | PLAYER_STATE1_4000)) && (sp28 <= 0) && + ((func_80123420(this)) || + ((sPlayerCurrentFloorType != FLOOR_TYPE_7) && + ((func_80123434(this)) || ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && + !(this->stateFlags1 & PLAYER_STATE1_400000) && (sp28 == 0)))))) { + doActionA = DO_ACTION_ATTACK; + } else if ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && sp24 && (sp28 > 0)) { + doActionA = DO_ACTION_JUMP; + } else if ((this->transformation == PLAYER_FORM_DEKU) && !(this->stateFlags1 & PLAYER_STATE1_8000000) && + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + doActionA = DO_ACTION_ATTACK; + } else if (((this->transformation == PLAYER_FORM_HUMAN) || + (this->transformation == PLAYER_FORM_ZORA)) && + ((this->heldItemAction >= PLAYER_IA_SWORD_KOKIRI) || + ((this->stateFlags2 & PLAYER_STATE2_100000) && + (play->actorCtx.targetContext.arrowPointedActor == NULL)))) { + doActionA = DO_ACTION_PUTAWAY; + + if (play->msgCtx.currentTextId == 0) {} //! FAKE + } + } + } + + if (doActionA != DO_ACTION_PUTAWAY) { + this->putAwayCountdown = 20; + } else if (this->putAwayCountdown != 0) { + doActionA = DO_ACTION_NONE; + this->putAwayCountdown--; + } + + func_8011552C(play, doActionA); + + // Set Tatl state + if (!Play_InCsMode(play) && (this->stateFlags2 & PLAYER_STATE2_200000) && + !(this->stateFlags3 & PLAYER_STATE3_100)) { + if (this->targetedActor != NULL) { + func_80115764(play, 0x2B); + } else { + func_80115764(play, 0x2A); + } + CutsceneManager_Queue(CS_ID_GLOBAL_TALK); + } else { + func_80115764(play, 0x2C); + } + } +} + +s32 func_808430E0(Player* this) { + if ((this->transformation == PLAYER_FORM_DEKU) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + func_8083784C(this)) { + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; + } + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + return false; + } + + if (!(this->stateFlags1 & PLAYER_STATE1_8000000)) { + sPlayerCurrentFloorType = FLOOR_TYPE_0; + } + this->unk_B6C = 0; + this->unk_B6E = 0; + D_80862B28 = 0; + return true; +} + +void func_80843178(PlayState* play, Player* this) { + u8 spC7 = 0; + CollisionPoly* floorPoly; + f32 temp_fv0; + f32 temp_fv0_3; + f32 temp_fv1; + u32 updBgCheckInfoFlags; + s32 spAC = (func_8084D820 == this->actionFunc) && (this->unk_397 == 4); + + sPlayerPrevFloorProperty = this->floorProperty; + + temp_fv0 = this->ageProperties->unk_38; + temp_fv1 = this->ageProperties->unk_00; + + if (this->stateFlags1 & (PLAYER_STATE1_20000000 | PLAYER_STATE1_80000000)) { + if ((!(this->stateFlags1 & PLAYER_STATE1_80) && !(this->stateFlags2 & PLAYER_STATE2_4000) && + (this->stateFlags1 & PLAYER_STATE1_80000000)) || + spAC) { + updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10 | UPDBGCHECKINFO_FLAG_20; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; + } else { + if ((this->stateFlags1 & 1) && (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_1) && + ((this->unk_D68 - (s32)this->actor.world.pos.y) >= 100)) { + updBgCheckInfoFlags = + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10 | UPDBGCHECKINFO_FLAG_20; + } else if (!(this->stateFlags1 & PLAYER_STATE1_1) && + ((func_8084E034 == this->actionFunc) || (func_8084D820 == this->actionFunc))) { + updBgCheckInfoFlags = + UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10 | UPDBGCHECKINFO_FLAG_20; + this->actor.bgCheckFlags &= ~(BGCHECKFLAG_WALL | BGCHECKFLAG_PLAYER_WALL_INTERACT); + } else { + updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10 | UPDBGCHECKINFO_FLAG_20; + } + } + } else { + if (func_808561B0 == this->actionFunc) { + updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_4 | UPDBGCHECKINFO_FLAG_10 | UPDBGCHECKINFO_FLAG_800; + } else if ((this->stateFlags3 & (PLAYER_STATE3_1000 | PLAYER_STATE3_80000)) && (this->linearVelocity >= 8.0f)) { + updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_10 | UPDBGCHECKINFO_FLAG_20 | UPDBGCHECKINFO_FLAG_100 | + UPDBGCHECKINFO_FLAG_200; + } else { + updBgCheckInfoFlags = UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4 | + UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10 | UPDBGCHECKINFO_FLAG_20; + } + } + + if (this->stateFlags3 & PLAYER_STATE3_1) { + updBgCheckInfoFlags &= ~(UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); + } + if (updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_4) { + this->stateFlags3 |= PLAYER_STATE3_10; + } + + if (func_801242B4(this)) { + updBgCheckInfoFlags &= ~(UPDBGCHECKINFO_FLAG_8 | UPDBGCHECKINFO_FLAG_10); + } + + Actor_UpdateBgCheckInfo(play, &this->actor, 268 * 0.1f, temp_fv0, temp_fv1, updBgCheckInfoFlags); + + this->unk_AC0 -= (this->actor.world.pos.y - this->actor.prevPos.y) / this->actor.scale.y; + this->unk_AC0 = CLAMP(this->unk_AC0, -1000.0f, 1000.0f); + + if (this->actor.bgCheckFlags & BGCHECKFLAG_CEILING) { + this->actor.velocity.y = 0.0f; + } + + D_80862B18 = this->actor.world.pos.y - this->actor.floorHeight; + sPlayerConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; + floorPoly = this->actor.floorPoly; + + if ((floorPoly != NULL) && (updBgCheckInfoFlags & UPDBGCHECKINFO_FLAG_4)) { + this->floorProperty = SurfaceType_GetFloorProperty(&play->colCtx, floorPoly, this->actor.floorBgId); + if (this == GET_PLAYER(play)) { + func_801A3CF4(SurfaceType_GetEcho(&play->colCtx, floorPoly, this->actor.floorBgId)); + if (this->actor.floorBgId == BGCHECK_SCENE) { + func_800FAAB4(play, SurfaceType_GetLightSettingIndex(&play->colCtx, floorPoly, this->actor.floorBgId)); + } else { + DynaPoly_SetPlayerAbove(&play->colCtx, this->actor.floorBgId); + } + } + + sPlayerConveyorSpeedIndex = SurfaceType_GetConveyorSpeed(&play->colCtx, floorPoly, this->actor.floorBgId); + if (sPlayerConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) { + sPlayerIsOnFloorConveyor = SurfaceType_IsFloorConveyor(&play->colCtx, floorPoly, this->actor.floorBgId); + if ((!sPlayerIsOnFloorConveyor && (this->actor.depthInWater > 20.0f)) || + (sPlayerIsOnFloorConveyor && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND))) { + D_80862B16 = SurfaceType_GetConveyorDirection(&play->colCtx, floorPoly, this->actor.floorBgId) << 0xA; + } else { + sPlayerConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; + } + } + } + + this->actor.bgCheckFlags &= ~BGCHECKFLAG_PLAYER_WALL_INTERACT; + if (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) { + static Vec3f D_8085D358 = { 0.0f, 0.0f, 0.0f }; + CollisionPoly* spA8; + s32 spA4; + s16 temp_v1_3; + f32 sp9C; + + D_8085D358.y = 178.0f * 0.1f; + D_8085D358.z = this->ageProperties->unk_38 + 10.0f; + + if (func_80835D58(play, this, &D_8085D358, &spA8, &spA4, &D_80862B30)) { + this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_WALL_INTERACT; + if (spA8 != this->actor.wallPoly) { + this->actor.wallPoly = spA8; + this->actor.wallBgId = spA4; + this->actor.wallYaw = Math_Atan2S_XY(spA8->normal.z, spA8->normal.x); + } + } + + temp_v1_3 = this->actor.shape.rot.y - BINANG_ADD(this->actor.wallYaw, 0x8000); + sPlayerCurrentWallFlags = SurfaceType_GetWallFlags(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId); + D_80862B20 = ABS_ALT(temp_v1_3); + temp_v1_3 = BINANG_SUB(this->currentYaw, BINANG_ADD(this->actor.wallYaw, 0x8000)); + D_80862B24 = ABS_ALT(temp_v1_3); + + temp_fv0_3 = D_80862B24 * 0.00008f; + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (temp_fv0_3 >= 1.0f)) { + this->unk_B50 = R_RUN_SPEED_LIMIT / 100.0f; + } else { + temp_fv1 = (R_RUN_SPEED_LIMIT / 100.0f) * temp_fv0_3; + + this->unk_B50 = temp_fv1; + if (temp_fv1 < 0.1f) { + this->unk_B50 = 0.1f; + } + } + + if ((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && (D_80862B20 < 0x3000)) { + CollisionPoly* wallPoly = this->actor.wallPoly; + + if (ABS_ALT(wallPoly->normal.y) < 0x258) { + f32 wallPolyNormalX = COLPOLY_GET_NORMAL(wallPoly->normal.x); + f32 wallPolyNormalY = COLPOLY_GET_NORMAL(wallPoly->normal.y); + f32 wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z); + f32 temp_fv1_3; + CollisionPoly* sp84; + CollisionPoly* sp80; + s32 sp7C; + Vec3f sp70; + f32 temp_fv0_5; + f32 sp68; + s32 temp_v1_6; + + this->wallDistance = Math3D_UDistPlaneToPos(wallPolyNormalX, wallPolyNormalY, wallPolyNormalZ, + wallPoly->dist, &this->actor.world.pos); + temp_fv1_3 = this->wallDistance + 10.0f; + sp70.x = this->actor.world.pos.x - (temp_fv1_3 * wallPolyNormalX); + sp70.z = this->actor.world.pos.z - (temp_fv1_3 * wallPolyNormalZ); + sp70.y = this->actor.world.pos.y + this->ageProperties->unk_0C; + temp_fv0_5 = BgCheck_EntityRaycastFloor5(&play->colCtx, &sp84, &sp7C, &this->actor, &sp70); + + this->wallHeight = temp_fv0_5 - this->actor.world.pos.y; + if ((this->wallHeight < 178.0f * 0.1f) || + ((BgCheck_EntityCheckCeiling(&play->colCtx, &sp68, &this->actor.world.pos, + (temp_fv0_5 - this->actor.world.pos.y) + 20.0f, &sp80, &sp7C, + &this->actor) != 0))) { + this->wallHeight = 399.96002f; + } else { + D_8085D358.y = (temp_fv0_5 + 5.0f) - this->actor.world.pos.y; + + if ((func_80835D58(play, this, &D_8085D358, &sp80, &sp7C, &D_80862B30)) && + (temp_v1_6 = this->actor.wallYaw - Math_Atan2S_XY(sp80->normal.z, sp80->normal.x), + ABS_ALT(temp_v1_6) < 0x4000) && + !(SurfaceType_CheckWallFlag1(&play->colCtx, sp80, sp7C))) { + this->wallHeight = 399.96002f; + } else if (SurfaceType_CheckWallFlag0(&play->colCtx, wallPoly, this->actor.wallBgId) == 0) { + if (this->ageProperties->unk_1C <= this->wallHeight) { + if (ABS_ALT(sp84->normal.y) > 0x5DC0) { + if ((this->ageProperties->unk_14 <= this->wallHeight) || func_801242B4(this)) { + spC7 = 4; + } else if (this->ageProperties->unk_18 <= this->wallHeight) { + spC7 = 3; + } else { + spC7 = 2; + } + } + } else { + spC7 = 1; + } + } + } + } + } + } else { + this->unk_B50 = R_RUN_SPEED_LIMIT / 100.0f; + this->wallHeight = 0.0f; + this->unk_B5D = 0; + } + + if (spC7 == this->unk_B5C) { + if (this->linearVelocity != 0.0f) { + if (this->unk_B5D < 0x64) { + this->unk_B5D++; + } + } + } else { + this->unk_B5C = spC7; + this->unk_B5D = 0; + } + + sPlayerCurrentFloorType = SurfaceType_GetFloorType(&play->colCtx, floorPoly, this->actor.floorBgId); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + f32 floorPolyNormalX; + f32 floorPolyNormalY; + f32 floorPolyNormalZ; + f32 sp54; + s32 pad; + f32 sp4C; + + D_80862B40 = SurfaceType_GetFloorEffect(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + if (func_808430E0(this) == 0) { + floorPolyNormalY = COLPOLY_GET_NORMAL(floorPoly->normal.y); + + if (this->actor.floorBgId != BGCHECK_SCENE) { + DynaPoly_SetPlayerOnTop(&play->colCtx, this->actor.floorBgId); + } else if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) && (this->actor.depthInWater <= 24.0f) && + (D_80862B40 != FLOOR_EFFECT_1) && (sPlayerConveyorSpeedIndex == CONVEYOR_SPEED_DISABLED) && + (floorPolyNormalY > 0.5f)) { + if (CutsceneManager_GetCurrentCsId() != play->playerCsIds[PLAYER_CS_ID_SONG_WARP]) { + func_80841A50(play, this); + } + } + + floorPolyNormalX = COLPOLY_GET_NORMAL(floorPoly->normal.x); + floorPolyNormalY = 1.0f / floorPolyNormalY; + floorPolyNormalZ = COLPOLY_GET_NORMAL(floorPoly->normal.z); + + sp54 = Math_SinS(this->currentYaw); + sp4C = Math_CosS(this->currentYaw); + this->unk_B6C = + Math_Atan2S_XY(1.0f, (-(floorPolyNormalX * sp54) - (floorPolyNormalZ * sp4C)) * floorPolyNormalY); + this->unk_B6E = + Math_Atan2S_XY(1.0f, (-(floorPolyNormalX * sp4C) - (floorPolyNormalZ * sp54)) * floorPolyNormalY); + sp54 = Math_SinS(this->actor.shape.rot.y); + sp4C = Math_CosS(this->actor.shape.rot.y); + D_80862B28 = + Math_Atan2S_XY(1.0f, (-(floorPolyNormalX * sp54) - (floorPolyNormalZ * sp4C)) * floorPolyNormalY); + func_8083CF68(play, this); + } + } else { + func_808430E0(this); + D_80862B40 = FLOOR_EFFECT_0; + } + + if (floorPoly != NULL) { + this->unk_D66 = this->floorSfxOffset; + if (spAC != 0) { + this->floorSfxOffset = NA_SE_PL_WALK_CONCRETE - SFX_FLAG; + return; + } + + if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { + if (this->actor.depthInWater < 50.0f) { + if (this->actor.depthInWater < 20.0f) { + this->floorSfxOffset = (sPlayerCurrentFloorType == FLOOR_TYPE_13) ? NA_SE_PL_WALK_DIRT - SFX_FLAG + : NA_SE_PL_WALK_WATER0 - SFX_FLAG; + } else { + this->floorSfxOffset = (sPlayerCurrentFloorType == FLOOR_TYPE_13) ? NA_CODE_DIRT_DEEP - SFX_FLAG + : NA_SE_PL_WALK_WATER1 - SFX_FLAG; + } + + return; + } + } + + if (this->stateFlags2 & PLAYER_STATE2_200) { + this->floorSfxOffset = NA_SE_PL_WALK_SAND - SFX_FLAG; + } else if (COLPOLY_GET_NORMAL(floorPoly->normal.y) > 0.5f) { + this->floorSfxOffset = SurfaceType_GetSfxOffset(&play->colCtx, floorPoly, this->actor.floorBgId); + } + } +} + +void Player_UpdateCamAndSeqModes(PlayState* play, Player* this) { + u8 seqMode; + s32 pad[2]; + Camera* camera; + s32 camMode; + + if (this == GET_PLAYER(play)) { + seqMode = SEQ_MODE_DEFAULT; + if (this->stateFlags1 & PLAYER_STATE1_100000) { + seqMode = SEQ_MODE_STILL; + } else if (this->csMode != PLAYER_CSMODE_0) { + Camera_ChangeMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_NORMAL); + } else { + camera = (this->actor.id == ACTOR_PLAYER) ? Play_GetCamera(play, CAM_ID_MAIN) + : Play_GetCamera(play, ((EnTest3*)this)->subCamId); + if ((this->actor.parent != NULL) && (this->stateFlags3 & PLAYER_STATE3_80)) { + camMode = CAM_MODE_HOOKSHOT; + Camera_SetViewParam(camera, CAM_VIEW_TARGET, this->actor.parent); + } else if (func_8084BC64 == this->actionFunc) { + camMode = CAM_MODE_STILL; + } else if (this->stateFlags3 & PLAYER_STATE3_8000) { + if (this->stateFlags1 & PLAYER_STATE1_8000000) { + camMode = CAM_MODE_GORONDASH; + } else { + camMode = CAM_MODE_FREEFALL; + } + } else if (this->stateFlags3 & PLAYER_STATE3_80000) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + camMode = CAM_MODE_GORONDASH; + } else { + camMode = CAM_MODE_GORONJUMP; + } + } else if (this->stateFlags2 & PLAYER_STATE2_100) { + camMode = CAM_MODE_PUSHPULL; + } else if (this->targetedActor != NULL) { + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_TALK_REQUESTED)) { + camMode = CAM_MODE_TALK; + } else if (this->stateFlags1 & PLAYER_STATE1_10000) { + if (this->stateFlags1 & PLAYER_STATE1_2000000) { + camMode = CAM_MODE_FOLLOWBOOMERANG; + } else { + camMode = CAM_MODE_FOLLOWTARGET; + } + } else { + camMode = CAM_MODE_BATTLE; + } + Camera_SetViewParam(camera, CAM_VIEW_TARGET, this->targetedActor); + } else if (this->stateFlags1 & PLAYER_STATE1_1000) { + camMode = CAM_MODE_CHARGE; + } else if (this->stateFlags3 & PLAYER_STATE3_100) { + camMode = CAM_MODE_DEKUHIDE; + } else if (this->stateFlags1 & PLAYER_STATE1_2000000) { + camMode = CAM_MODE_FOLLOWBOOMERANG; + Camera_SetViewParam(camera, CAM_VIEW_TARGET, this->boomerangActor); + } else if (this->stateFlags1 & (PLAYER_STATE1_4 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000)) { + if (func_80123434(this)) { + camMode = CAM_MODE_HANGZ; + } else { + camMode = CAM_MODE_HANG; + } + } else if ((this->stateFlags3 & PLAYER_STATE3_2000) && (this->actor.velocity.y < 0.0f)) { + if (this->stateFlags1 & (PLAYER_STATE1_20000 | PLAYER_STATE1_40000000)) { + camMode = CAM_MODE_DEKUFLYZ; + } else { + camMode = CAM_MODE_DEKUFLY; + } + } else if (this->stateFlags1 & (PLAYER_STATE1_20000 | PLAYER_STATE1_40000000)) { + if (func_800B7128(this) || func_8082EF20(this)) { + camMode = CAM_MODE_BOWARROWZ; + } else if (this->stateFlags1 & PLAYER_STATE1_200000) { + camMode = CAM_MODE_CLIMBZ; + } else { + camMode = CAM_MODE_TARGET; + } + } else if ((this->stateFlags1 & PLAYER_STATE1_400000) && (this->transformation != 0)) { + camMode = CAM_MODE_STILL; + } else if (this->stateFlags1 & PLAYER_STATE1_40000) { + camMode = CAM_MODE_JUMP; + } else if (this->stateFlags1 & PLAYER_STATE1_200000) { + camMode = CAM_MODE_CLIMB; + } else if (this->stateFlags1 & PLAYER_STATE1_80000) { + camMode = CAM_MODE_FREEFALL; + } else if (((func_808548B8 == this->actionFunc) && + (this->meleeWeaponAnimation >= PLAYER_MWA_FORWARD_SLASH_1H) && + (this->meleeWeaponAnimation <= PLAYER_MWA_ZORA_PUNCH_KICK)) || + (this->stateFlags3 & PLAYER_STATE3_8) || + ((func_8084FE7C == this->actionFunc) && (this->unk_AE8 == 0)) || + (func_808505D0 == this->actionFunc)) { + camMode = CAM_MODE_STILL; + } else { + camMode = CAM_MODE_NORMAL; + if ((this->linearVelocity == 0.0f) && + (!(this->stateFlags1 & PLAYER_STATE1_800000) || (this->rideActor->speed == 0.0f))) { + seqMode = SEQ_MODE_STILL; + } + } + + Camera_ChangeMode(camera, camMode); + } + + if (play->actorCtx.targetContext.bgmEnemy != NULL) { + seqMode = SEQ_MODE_ENEMY; + Audio_UpdateEnemyBgmVolume(sqrtf(play->actorCtx.targetContext.bgmEnemy->xyzDistToPlayerSq)); + } + + Audio_SetSequenceMode(seqMode); + } +} + +Vec3f D_8085D364 = { 0.0f, 0.5f, 0.0f }; +Vec3f D_8085D370 = { 0.0f, 0.5f, 0.0f }; +Color_RGBA8 D_8085D37C = { 255, 255, 100, 255 }; +Color_RGBA8 D_8085D380 = { 255, 50, 0, 0 }; + +void func_808442D8(PlayState* play, Player* this) { + f32 var_fa0; + f32 temp_fv1; + + if (this->unk_B0C == 0.0f) { + func_80831990(play, this, ITEM_NONE); + return; + } + + var_fa0 = 1.0f; + if (DECR(this->unk_B28) == 0) { + Inventory_ChangeAmmo(ITEM_STICK, -1); + this->unk_B28 = 1; + this->unk_B0C = 0.0f; + var_fa0 = 0.0f; + } else if (this->unk_B28 >= 0xC9) { + var_fa0 = (0xD2 - this->unk_B28) / 10.0f; + } else if (this->unk_B28 < 0x14) { + var_fa0 = this->unk_B28 / 20.0f; + this->unk_B0C = var_fa0; + } + + if (var_fa0 > 0.0f) { + func_800B0EB0(play, &this->meleeWeaponInfo[0].tip, &D_8085D364, &D_8085D370, &D_8085D37C, &D_8085D380, + (var_fa0 * 200.0f), 0, 8); + if (((play->roomCtx.curRoom.enablePosLights != 0)) || (MREG(93) != 0)) { + temp_fv1 = (Rand_ZeroOne() * 30.0f) + 225.0f; + Lights_PointSetColorAndRadius(&this->lightInfo, temp_fv1, temp_fv1 * 0.7f, 0, var_fa0 * 300.0f); + } + } +} + +void func_808445C4(PlayState* play, Player* this) { + this->shockTimer--; + this->unk_B66 += this->shockTimer; + if (this->unk_B66 > 20) { + Vec3f pos; + Vec3f* bodyPartsPos; + s32 scale; + s32 randIndex; + + this->unk_B66 -= 20; + scale = this->shockTimer * 2; + if (scale > 40) { + scale = 40; + } + + randIndex = Rand_ZeroFloat(PLAYER_BODYPART_MAX - 0.1f); + bodyPartsPos = randIndex + this->bodyPartsPos; + + pos.x = (randPlusMinusPoint5Scaled(5.0f) + bodyPartsPos->x) - this->actor.world.pos.x; + pos.y = (randPlusMinusPoint5Scaled(5.0f) + bodyPartsPos->y) - this->actor.world.pos.y; + pos.z = (randPlusMinusPoint5Scaled(5.0f) + bodyPartsPos->z) - this->actor.world.pos.z; + EffectSsFhgFlash_SpawnShock(play, &this->actor, &pos, scale, 1); + func_800B8F98(&this->actor, NA_SE_PL_SPARK - SFX_FLAG); + } +} + +/** + * Rumbles the controller when close to a secret. + */ +void Player_DetectSecrets(PlayState* play, Player* this) { + f32 step = (SQ(200.0f) * 5.0f) - (this->closestSecretDistSq * 5.0f); + + if (step < 0.0f) { + step = 0.0f; + } + + this->secretRumbleCharge += step; + if (this->secretRumbleCharge > SQ(2000.0f)) { + this->secretRumbleCharge = 0.0f; + Player_RequestRumble(play, this, 120, 20, 10, SQ(0)); + } +} + +s8 D_8085D384[92] = { + /* 0 */ PLAYER_CSMODE_0, + /* 1 */ PLAYER_CSMODE_2, + /* 2 */ PLAYER_CSMODE_2, + /* 3 */ PLAYER_CSMODE_4, + /* 4 */ PLAYER_CSMODE_3, + /* 5 */ PLAYER_CSMODE_56, + /* 6 */ PLAYER_CSMODE_8, + /* 7 */ PLAYER_CSMODE_0, + /* 8 */ PLAYER_CSMODE_0, + /* 9 */ PLAYER_CSMODE_135, + /* 10 */ PLAYER_CSMODE_21, + /* 11 */ PLAYER_CSMODE_61, + /* 12 */ PLAYER_CSMODE_62, + /* 13 */ PLAYER_CSMODE_60, + /* 14 */ PLAYER_CSMODE_63, + /* 15 */ PLAYER_CSMODE_64, + /* 16 */ PLAYER_CSMODE_65, + /* 17 */ PLAYER_CSMODE_66, + /* 18 */ PLAYER_CSMODE_70, + /* 19 */ PLAYER_CSMODE_19, + /* 20 */ PLAYER_CSMODE_71, + /* 21 */ PLAYER_CSMODE_72, + /* 22 */ PLAYER_CSMODE_67, + /* 23 */ PLAYER_CSMODE_73, + /* 24 */ PLAYER_CSMODE_74, + /* 25 */ PLAYER_CSMODE_75, + /* 26 */ PLAYER_CSMODE_68, + /* 27 */ PLAYER_CSMODE_69, + /* 28 */ PLAYER_CSMODE_76, + /* 29 */ PLAYER_CSMODE_116, + /* 30 */ PLAYER_CSMODE_0, + /* 31 */ PLAYER_CSMODE_40, + /* 32 */ PLAYER_CSMODE_0, + /* 33 */ -PLAYER_CSMODE_52, // the only negative one + /* 34 */ PLAYER_CSMODE_42, + /* 35 */ PLAYER_CSMODE_43, + /* 36 */ PLAYER_CSMODE_57, + /* 37 */ PLAYER_CSMODE_81, + /* 38 */ PLAYER_CSMODE_41, + /* 39 */ PLAYER_CSMODE_53, + /* 40 */ PLAYER_CSMODE_54, + /* 41 */ PLAYER_CSMODE_44, + /* 42 */ PLAYER_CSMODE_55, + /* 43 */ PLAYER_CSMODE_45, + /* 44 */ PLAYER_CSMODE_46, + /* 45 */ PLAYER_CSMODE_47, + /* 46 */ PLAYER_CSMODE_48, + /* 47 */ PLAYER_CSMODE_49, + /* 48 */ PLAYER_CSMODE_50, + /* 49 */ PLAYER_CSMODE_51, + /* 50 */ PLAYER_CSMODE_77, + /* 51 */ PLAYER_CSMODE_78, + /* 52 */ PLAYER_CSMODE_79, + /* 53 */ PLAYER_CSMODE_80, + /* 54 */ PLAYER_CSMODE_81, + /* 55 */ PLAYER_CSMODE_82, + /* 56 */ PLAYER_CSMODE_83, + /* 57 */ PLAYER_CSMODE_84, + /* 58 */ PLAYER_CSMODE_85, + /* 59 */ PLAYER_CSMODE_86, + /* 60 */ PLAYER_CSMODE_87, + /* 61 */ PLAYER_CSMODE_88, + /* 62 */ PLAYER_CSMODE_89, + /* 63 */ PLAYER_CSMODE_90, + /* 64 */ PLAYER_CSMODE_91, + /* 65 */ PLAYER_CSMODE_92, + /* 66 */ PLAYER_CSMODE_94, + /* 67 */ PLAYER_CSMODE_95, + /* 68 */ PLAYER_CSMODE_100, + /* 69 */ PLAYER_CSMODE_101, + /* 70 */ PLAYER_CSMODE_98, + /* 71 */ PLAYER_CSMODE_99, + /* 72 */ PLAYER_CSMODE_102, + /* 73 */ PLAYER_CSMODE_103, + /* 74 */ PLAYER_CSMODE_104, + /* 75 */ PLAYER_CSMODE_112, + /* 76 */ PLAYER_CSMODE_113, + /* 77 */ PLAYER_CSMODE_117, + /* 78 */ PLAYER_CSMODE_104, + /* 79 */ PLAYER_CSMODE_104, + /* 80 */ PLAYER_CSMODE_105, + /* 81 */ PLAYER_CSMODE_106, + /* 82 */ PLAYER_CSMODE_107, + /* 83 */ PLAYER_CSMODE_108, + /* 84 */ PLAYER_CSMODE_109, + /* 85 */ PLAYER_CSMODE_110, + /* 86 */ PLAYER_CSMODE_118, + /* 87 */ PLAYER_CSMODE_119, + /* 88 */ PLAYER_CSMODE_120, + /* 89 */ PLAYER_CSMODE_114, + /* 90 */ PLAYER_CSMODE_111, + /* 91 */ PLAYER_CSMODE_122, +}; + +f32 D_8085D3E0[PLAYER_FORM_MAX] = { + 0.8f, // PLAYER_FORM_FIERCE_DEITY + 0.6f, // PLAYER_FORM_GORON + 0.8f, // PLAYER_FORM_ZORA + 1.5f, // PLAYER_FORM_DEKU + 1.0f, // PLAYER_FORM_HUMAN +}; + +void func_80844784(PlayState* play, Player* this) { + f32 var_fv0; + s16 var_a3; + f32 temp_ft4; + s32 temp_ft2; + f32 temp_fv1_2; + f32 sp58; + f32 sp54; + f32 sp50; + f32 sp4C; + f32 sp48; + f32 sp44; + f32 temp_fa0; + f32 temp_fa1; + s16 temp_v0; + f32 temp_fv0_2; + + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (sPlayerCurrentFloorType == FLOOR_TYPE_5) && + (this->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER)) { + var_a3 = this->currentYaw; + var_fv0 = this->linearVelocity; + temp_v0 = this->actor.world.rot.y - var_a3; + + if ((ABS_ALT(temp_v0) > 0x6000) && (this->actor.speed != 0.0f)) { + var_fv0 = 0.0f; + var_a3 += 0x8000; + } + + if ((Math_StepToF(&this->actor.speed, var_fv0, 0.35f) != 0) && (var_fv0 == 0.0f)) { + this->actor.world.rot.y = this->currentYaw; + } + + if (this->linearVelocity != 0.0f) { + temp_ft2 = (fabsf(this->linearVelocity) * 700.0f) - (fabsf(this->actor.speed) * 100.0f); + temp_ft2 = CLAMP(temp_ft2, 0, 0x546); + + Math_ScaledStepToS(&this->actor.world.rot.y, var_a3, temp_ft2); + } + if ((this->linearVelocity == 0.0f) && (this->actor.speed != 0.0f)) { + func_8019F780(&this->actor.projectedPos, Player_GetFloorSfx(this, NA_SE_PL_SLIP_LEVEL - SFX_FLAG), + this->actor.speed); + } + } else { + this->actor.speed = this->linearVelocity; + this->actor.world.rot.y = this->currentYaw; + } + + Actor_UpdateVelocityWithGravity(&this->actor); + D_80862B3C = 0.0f; + if ((gSaveContext.save.saveInfo.playerData.health != 0) && + ((this->pushedSpeed != 0.0f) || (this->windSpeed != 0.0f) || (play->envCtx.windSpeed >= 50.0f)) && + (!Player_InCsMode(play)) && + !(this->stateFlags1 & (PLAYER_STATE1_4 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_200000)) && + !(this->stateFlags3 & PLAYER_STATE3_100) && (func_8084D4EC != this->actionFunc) && + (this->actor.id == ACTOR_PLAYER)) { + this->actor.velocity.x += this->pushedSpeed * Math_SinS(this->pushedYaw); + this->actor.velocity.z += this->pushedSpeed * Math_CosS(this->pushedYaw); + temp_fv1_2 = 10.0f - this->actor.velocity.y; + if (temp_fv1_2 > 0.0f) { + sp58 = D_8085D3E0[this->transformation]; + sp54 = this->windSpeed * sp58; + sp50 = Math_SinS(this->windAngleX) * sp54; + sp4C = Math_CosS(this->windAngleX) * sp54; + sp48 = Math_SinS(this->windAngleY) * sp4C; + sp44 = Math_CosS(this->windAngleY) * sp4C; + + if ((sp50 > 0.0f) && (this->transformation == PLAYER_FORM_DEKU) && + !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + if (Player_SetAction(play, this, func_80856918, 1)) { + this->stateFlags3 |= PLAYER_STATE3_2000 | PLAYER_STATE3_1000000; + func_8082E1F0(this, NA_SE_IT_DEKUNUTS_FLOWER_OPEN); + func_8019FD90(4, 2); + } + + this->unk_AE8 = 0x270F; + Math_Vec3f_Copy(this->unk_AF0, &this->actor.world.pos); + } + + if (play->envCtx.windSpeed >= 50.0f) { + temp_fa0 = play->envCtx.windDir.x; + temp_fa1 = play->envCtx.windDir.y; + temp_ft4 = play->envCtx.windDir.z; + + temp_fv0_2 = sqrtf(SQ(temp_fa0) + SQ(temp_fa1) + SQ(temp_ft4)); + if (temp_fv0_2 != 0.0f) { + temp_fv0_2 = ((play->envCtx.windSpeed - 50.0f) * 0.1f * sp58) / temp_fv0_2; + + sp48 -= temp_fa0 * temp_fv0_2; + sp50 -= temp_fa1 * temp_fv0_2; + sp44 -= temp_ft4 * temp_fv0_2; + } + } + + if (temp_fv1_2 < sp50) { + temp_fv1_2 /= sp50; + + sp48 *= temp_fv1_2; + sp50 *= temp_fv1_2; + sp44 *= temp_fv1_2; + } + + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + D_80862B3C = (sp44 * Math_CosS(this->currentYaw)) + (Math_SinS(this->currentYaw) * sp48); + if (fabsf(D_80862B3C) > 4.0f) { + func_8083FBC4(play, this); + } + + func_8019F780(&this->actor.projectedPos, Player_GetFloorSfx(this, NA_SE_PL_SLIP_LEVEL - SFX_FLAG), + fabsf(D_80862B3C)); + } + + this->actor.velocity.x += sp48; + this->actor.velocity.z += sp44; + this->actor.velocity.y += sp50; + } + } + + Actor_UpdatePos(&this->actor); +} + +Color_RGBA8 D_8085D3F4 = { 100, 255, 255, 0 }; +Color_RGBA8 D_8085D3F8 = { 0, 100, 100, 0 }; + +void func_80844D80(PlayState* play, Player* this) { + Vec3f pos; + Vec3f spA0; + Vec3f velocity; + Vec3f accel; + Vec3f sp7C; + s32 i; + + Math_Vec3f_Diff(&this->meleeWeaponInfo[0].tip, &this->meleeWeaponInfo[0].base, &sp7C); + Math_Vec3f_SumScaled(&this->meleeWeaponInfo[0].base, &sp7C, 0.3f, &spA0); + + for (i = 0; i < 2; i++) { + Math_Vec3f_SumScaled(&this->meleeWeaponInfo[0].base, &sp7C, Rand_ZeroOne(), &pos); + Math_Vec3f_AddRand(&pos, 15.0f, &pos); + Math_Vec3f_DistXYZAndStoreNormDiff(&spA0, &pos, 1.7f, &velocity); + Math_Vec3f_ScaleAndStore(&velocity, 0.01f, &accel); + EffectSsKirakira_SpawnDispersed(play, &pos, &velocity, &accel, &D_8085D3F4, &D_8085D3F8, + Rand_S16Offset(-20, -120), 15); + } +} + +f32 D_8085D3FC[] = { 0.005f, 0.05f }; + +f32 sWaterConveyorSpeeds[CONVEYOR_SPEED_MAX - 1] = { + 2.0f, // CONVEYOR_SPEED_SLOW + 4.0f, // CONVEYOR_SPEED_MEDIUM + 11.0f, // CONVEYOR_SPEED_FAST +}; +f32 sFloorConveyorSpeeds[CONVEYOR_SPEED_MAX - 1] = { + 0.5f, // CONVEYOR_SPEED_SLOW + 1.0f, // CONVEYOR_SPEED_MEDIUM + 3.0f, // CONVEYOR_SPEED_FAST +}; + +void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { + f32 temp_fv0; + f32 temp_fv1; + + sPlayerControlInput = input; + if (this->unk_D6A < 0) { + this->unk_D6A++; + if (this->unk_D6A == 0) { + this->unk_D6A = 1; + play_sound(NA_SE_OC_REVENGE); + } + } + + Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.home.pos); + + temp_fv1 = fabsf(this->linearVelocity) * (fabsf(Math_SinS(this->unk_B6C) * 800.0f) + 100.0f); + + Math_StepToF(&this->unk_AC0, 0.0f, CLAMP_MIN(temp_fv1, 300.0f)); + + if (this->unk_D57 != 0) { + this->unk_D57--; + } + + if (this->unk_B5E != 0) { + this->unk_B5E--; + } + + if (this->unk_D6B != 0) { + this->unk_D6B--; + } + + if (this->invincibilityTimer < 0) { + this->invincibilityTimer++; + } else if (this->invincibilityTimer > 0) { + this->invincibilityTimer--; + } + + if (this->unk_B64 != 0) { + this->unk_B64--; + } + + if (this->blastMaskTimer != 0) { + this->blastMaskTimer--; + } + + if (gSaveContext.jinxTimer != 0) { + gSaveContext.jinxTimer--; + } + + func_80122C20(play, &this->unk_3D0); + if ((this->transformation == PLAYER_FORM_FIERCE_DEITY) && func_8082FBE8(this)) { + func_80844D80(play, this); + } + if (this->transformation == PLAYER_FORM_ZORA) { + s32 var_v0 = (this->stateFlags1 & PLAYER_STATE1_8000000) ? 1 : 0; + + Math_StepToF(&this->unk_B10[0], var_v0, D_8085D3FC[var_v0]); + } + func_80832888(this, play); + if (play->roomCtx.curRoom.enablePosLights != 0) { + Lights_PointSetColorAndRadius(&this->lightInfo, 255, 255, 255, 60); + } else { + this->lightInfo.params.point.radius = -1; + } + + if ((this->heldItemAction == PLAYER_IA_STICK) && (this->unk_B28 != 0)) { + func_808442D8(play, this); + } else if (this->heldItemAction == PLAYER_IA_FISHING_ROD) { + if (this->unk_B28 < 0) { + this->unk_B28++; + } + } + + if (this->shockTimer != 0) { + func_808445C4(play, this); + } + if (this->isBurning) { + func_808341F4(play, this); + } + + if (this->stateFlags2 & PLAYER_STATE2_8000) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + Player_StopHorizontalMovement(this); + Actor_MoveWithGravity(&this->actor); + } + func_80843178(play, this); + } else { + f32 temp_fa0; + f32 var_fv1_2; + s32 var_v1; + s32 pad; + + if (this->currentBoots != this->prevBoots) { + if (this->currentBoots == PLAYER_BOOTS_ZORA_UNDERWATER) { + if (this->stateFlags1 & PLAYER_STATE1_8000000) { + func_8082DC64(play, this); + if (this->ageProperties->unk_2C < this->actor.depthInWater) { + this->stateFlags2 |= PLAYER_STATE2_400; + } + } + } else if ((this->stateFlags1 & PLAYER_STATE1_8000000) && + ((this->prevBoots == PLAYER_BOOTS_ZORA_UNDERWATER) || + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND))) { + func_8083B930(play, this); + this->stateFlags2 &= ~PLAYER_STATE2_400; + if (func_808508C8 == this->actionFunc) { + this->unk_AE8 = 20; + } + } + this->prevBoots = this->currentBoots; + } + if ((this->actor.parent == NULL) && (this->stateFlags1 & PLAYER_STATE1_800000)) { + this->actor.parent = this->rideActor; + func_80837BD0(play, this); + this->unk_AE8 = -1; + Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_uma_wait_1); + func_8082E920(play, this, ANIM_FLAG_1 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_8 | ANIM_FLAG_NOMOVE | ANIM_FLAG_80); + } + + if (this->unk_ADC == 0) { + this->unk_ADD = 0; + } else if (this->unk_ADC < 0) { + this->unk_ADC++; + } else { + this->unk_ADC--; + } + + if (!(this->stateFlags3 & PLAYER_STATE3_2000)) { + Math_ScaledStepToS(&this->unk_AAA, 0, 0x190); + } + + if ((this->transformation >= PLAYER_FORM_GORON) && (this->transformation <= PLAYER_FORM_DEKU)) { + func_800BBB74(&this->blinkInfo, 20, 80, 3); + } else { + func_800BBAC0(&this->blinkInfo, 20, 80, 6); + } + + this->actor.shape.face = ((play->gameplayFrames & 0x20) ? 0 : 3) + this->blinkInfo.eyeTexIndex; + + if (this->currentMask == PLAYER_MASK_BUNNY) { + Player_UpdateBunnyEars(this); + } + + if (func_800B7118(this)) { + func_808484F0(this); + } + + if ((play->unk_18844 == 0) && !(this->skelAnime.moveFlags & ANIM_FLAG_80)) { + if (!(this->stateFlags1 & PLAYER_STATE1_2) && (this->actor.parent == NULL)) { + func_80844784(play, this); + } + func_80843178(play, this); + } else { + sPlayerCurrentFloorType = FLOOR_TYPE_0; + this->floorProperty = FLOOR_PROPERTY_0; + if (this->stateFlags1 & PLAYER_STATE1_800000) { + this->actor.floorPoly = this->rideActor->floorPoly; + this->actor.floorBgId = this->rideActor->floorBgId; + } + sPlayerConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; + this->pushedSpeed = 0.0f; + } + + func_8083562C(play, this, this->actor.floorPoly, this->actor.floorBgId); + if (sPlayerConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) { + f32 conveyorSpeed; + s32 pad2; + + sPlayerConveyorSpeedIndex--; + if (!sPlayerIsOnFloorConveyor) { + conveyorSpeed = sWaterConveyorSpeeds[sPlayerConveyorSpeedIndex]; + if (!(this->stateFlags1 & PLAYER_STATE1_8000000)) { + conveyorSpeed /= 4.0f; + } + } else { + conveyorSpeed = sFloorConveyorSpeeds[sPlayerConveyorSpeedIndex]; + } + + Math_StepToF(&this->pushedSpeed, conveyorSpeed, conveyorSpeed * 0.1f); + Math_ScaledStepToS(&this->pushedYaw, D_80862B16, + ((this->stateFlags1 & PLAYER_STATE1_8000000) ? 400.0f : 800.0f) * conveyorSpeed); + } else if (this->pushedSpeed != 0.0f) { + Math_StepToF(&this->pushedSpeed, 0.0f, (this->stateFlags1 & PLAYER_STATE1_8000000) ? 0.5f : 2.0f); + } + if (!(this->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_20000000)) && + !(this->stateFlags3 & PLAYER_STATE3_80) && (func_80854430 != this->actionFunc)) { + func_8083BB4C(play, this); + if (!Play_InCsMode(play)) { + if ((this->actor.id == ACTOR_PLAYER) && !(this->stateFlags1 & PLAYER_STATE1_80000000) && + (gSaveContext.save.saveInfo.playerData.health == 0) && + func_808323C0(this, play->playerCsIds[PLAYER_CS_ID_DEATH])) { + if (this->stateFlags3 & PLAYER_STATE3_1000000) { + func_808355D8(play, this, &gPlayerAnim_pn_kakkufinish); + } else if (this->stateFlags1 & + (PLAYER_STATE1_4 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_200000)) { + func_8082DD2C(play, this); + func_80833AA0(this, play); + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || + (this->stateFlags1 & PLAYER_STATE1_8000000)) { + func_80831F34(play, this, + func_801242B4(this) + ? &gPlayerAnim_link_swimer_swim_down + : ((this->shockTimer != 0) ? &gPlayerAnim_link_normal_electric_shock_end + : &gPlayerAnim_link_derth_rebirth)); + } + } else { + if ((this->actor.parent == NULL) && + (func_8082DA90(play) || (this->unk_D6B != 0) || !func_80834600(this, play))) { + func_8083827C(this, play); + } else { + this->fallStartHeight = this->actor.world.pos.y; + } + + Player_DetectSecrets(play, this); + } + } + } else if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (func_8084D820 == this->actionFunc) && + (this->unk_397 == 4)) { + this->actor.world.pos.y = this->actor.prevPos.y; + } + + if (play->csCtx.state != CS_STATE_IDLE) { + if ((this->csMode != PLAYER_CSMODE_5) && !(this->stateFlags1 & PLAYER_STATE1_800000)) { + if (!(this->stateFlags2 & PLAYER_STATE2_80) && (this->actor.id == ACTOR_PLAYER)) { + if ((play->csCtx.playerCue != NULL) && (D_8085D384[play->csCtx.playerCue->id] != 0)) { + func_800B7298(play, NULL, PLAYER_CSMODE_5); + Player_StopHorizontalMovement(this); + } else if (((u32)this->csMode == PLAYER_CSMODE_0) && + !(this->stateFlags2 & (PLAYER_STATE2_400 | PLAYER_STATE2_8000000)) && + (play->csCtx.state != CS_STATE_STOP)) { + func_800B7298(play, NULL, PLAYER_CSMODE_20); + Player_StopHorizontalMovement(this); + } + } + } + } + + if ((u32)this->csMode != PLAYER_CSMODE_0) { + if ((this->csMode != PLAYER_CSMODE_END) || + !(this->stateFlags1 & (PLAYER_STATE1_4 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | + PLAYER_STATE1_200000 | PLAYER_STATE1_4000000))) { + if (func_8085B08C != this->actionFunc) { + this->unk_AA5 = PLAYER_UNKAA5_4; + if (this->csMode == PLAYER_CSMODE_5) { + func_808387A0(play, this); + func_8082DAD4(this); + } + } + } else if (func_8085B08C != this->actionFunc) { + func_8085AACC(play, this, 0); + } + } else { + this->prevCsMode = PLAYER_CSMODE_0; + } + + func_8083BF54(play, this); + Lights_PointSetPosition(&this->lightInfo, this->actor.world.pos.x, this->actor.world.pos.y + 40.0f, + this->actor.world.pos.z); + + if (((this->targetedActor == NULL) || (this->targetedActor == this->talkActor) || + (this->targetedActor->hintId == TATL_HINT_ID_NONE)) && + (this->tatlTextId == 0)) { + this->stateFlags2 &= ~(PLAYER_STATE2_2 | PLAYER_STATE2_200000); + } + + this->stateFlags1 &= ~(PLAYER_STATE1_10 | PLAYER_STATE1_1000 | PLAYER_STATE1_400000); + this->stateFlags2 &= ~(PLAYER_STATE2_1 | PLAYER_STATE2_4 | PLAYER_STATE2_8 | PLAYER_STATE2_20 | + PLAYER_STATE2_40 | PLAYER_STATE2_100 | PLAYER_STATE2_200 | PLAYER_STATE2_1000 | + PLAYER_STATE2_4000 | PLAYER_STATE2_10000 | PLAYER_STATE2_400000 | PLAYER_STATE2_4000000); + this->stateFlags3 &= ~(PLAYER_STATE3_10 | PLAYER_STATE3_40 | PLAYER_STATE3_100 | PLAYER_STATE3_800 | + PLAYER_STATE3_1000 | PLAYER_STATE3_100000 | PLAYER_STATE3_2000000 | + PLAYER_STATE3_4000000 | PLAYER_STATE3_8000000 | PLAYER_STATE3_10000000); + func_808425B4(this); + func_8082EB38(play, this); + + D_8085C3E4 = (this->stateFlags1 & PLAYER_STATE1_8000000) ? 0.5f : 1.0f; + D_8085C3E8 = 1.0f / D_8085C3E4; + + D_80862B48 = D_80862B4C = 0; + + var_v1 = Play_InCsMode(play); + D_80862B2C = this->currentMask; + if (!(this->stateFlags3 & PLAYER_STATE3_4)) { + this->actionFunc(this, play); + } + + if (!var_v1) { + Player_SetDoAction(play, this); + } + + Player_UpdateCamAndSeqModes(play, this); + + if (this->skelAnime.moveFlags & ANIM_FLAG_8) { + AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, + (this->skelAnime.moveFlags & ANIM_FLAG_4) ? 1.0f + : this->ageProperties->unk_08); + } + + func_80832578(this, play); + if (this->actor.flags & ACTOR_FLAG_TALK_REQUESTED) { + this->talkActorDistance = 0.0f; + } else { + this->talkActor = NULL; + this->exchangeItemId = PLAYER_IA_NONE; + this->talkActorDistance = FLT_MAX; + } + if (!(this->actor.flags & ACTOR_FLAG_20000000) && (this->unk_AA5 != PLAYER_UNKAA5_5)) { + this->unk_A90 = NULL; + this->unk_A94 = FLT_MAX; + } + if (!(this->stateFlags1 & PLAYER_STATE1_800)) { + this->interactRangeActor = NULL; + this->getItemDirection = 0x6000; + } + if (this->actor.parent == NULL) { + this->rideActor = NULL; + } + + this->tatlTextId = 0; + this->unk_B2B = -1; + this->closestSecretDistSq = FLT_MAX; + this->doorType = PLAYER_DOORTYPE_NONE; + this->unk_B75 = 0; + this->unk_A78 = NULL; + + Math_StepToF(&this->windSpeed, 0.0f, 0.5f); + if ((this->unk_B62 != 0) || + ((gSaveContext.magicState == MAGIC_STATE_IDLE) && (gSaveContext.save.saveInfo.playerData.magic != 0) && + (this->stateFlags1 & PLAYER_STATE1_10))) { + func_8082F1AC(play, this); + } + + temp_fv0 = this->actor.world.pos.y - this->actor.prevPos.y; + var_fv1_2 = + temp_fv0 + + ((this->bodyPartsPos[PLAYER_BODYPART_LEFT_FOOT].y + this->bodyPartsPos[PLAYER_BODYPART_RIGHT_FOOT].y) * + 0.5f); + temp_fv0 += this->bodyPartsPos[PLAYER_BODYPART_HEAD].y + 10.0f; + + if (this->cylinder.info.toucher.dmgFlags == 0x80000) { + this->cylinder.dim.height = 80; + var_fv1_2 = ((temp_fv0 + var_fv1_2) * 0.5f) - 40.0f; + } else { + this->cylinder.dim.height = temp_fv0 - var_fv1_2; + + if (this->cylinder.dim.height < 0) { + temp_fa0 = temp_fv0; + temp_fv0 = var_fv1_2; + var_fv1_2 = temp_fa0; + this->cylinder.dim.height = -this->cylinder.dim.height; + } + } + + this->cylinder.dim.yShift = var_fv1_2 - this->actor.world.pos.y; + + if (this->unk_B62 != 0) { + this->shieldCylinder.base.acFlags = AC_NONE; + this->shieldCylinder.info.toucher.dmgFlags = 0x80000; + this->shieldCylinder.info.toucherFlags = TOUCH_ON; + this->shieldCylinder.info.bumperFlags = BUMP_NONE; + this->shieldCylinder.dim.height = 80; + this->shieldCylinder.dim.radius = 50; + this->shieldCylinder.dim.yShift = ((temp_fv0 + var_fv1_2) * 0.5f - 40.0f) - this->actor.world.pos.y; + + Collider_UpdateCylinder(&this->actor, &this->shieldCylinder); + CollisionCheck_SetAT(play, &play->colChkCtx, &this->shieldCylinder.base); + } else if (this->stateFlags1 & PLAYER_STATE1_400000) { + if ((this->transformation == PLAYER_FORM_GORON) || (this->transformation == PLAYER_FORM_DEKU)) { + this->shieldCylinder.base.acFlags = AC_ON | AC_HARD | AC_TYPE_ENEMY; + this->shieldCylinder.info.toucher.dmgFlags = 0x100000; + this->shieldCylinder.info.toucherFlags = TOUCH_NONE; + this->shieldCylinder.info.bumperFlags = BUMP_ON; + + if (this->transformation == PLAYER_FORM_GORON) { + this->shieldCylinder.dim.height = 35; + } else { + this->shieldCylinder.dim.height = 30; + } + + if (this->transformation == PLAYER_FORM_GORON) { + this->shieldCylinder.dim.radius = 30; + } else { + this->shieldCylinder.dim.radius = 20; + } + + this->shieldCylinder.dim.yShift = 0; + Collider_UpdateCylinder(&this->actor, &this->shieldCylinder); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->shieldCylinder.base); + this->cylinder.dim.yShift = 0; + this->cylinder.dim.height = this->shieldCylinder.dim.height; + } else { + this->cylinder.dim.height = this->cylinder.dim.height * 0.8f; + } + } + + Collider_UpdateCylinder(&this->actor, &this->cylinder); + if (!(this->stateFlags2 & PLAYER_STATE2_4000)) { + if (!(this->stateFlags1 & (PLAYER_STATE1_4 | PLAYER_STATE1_80 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | + PLAYER_STATE1_800000)) && + !(this->stateFlags3 & PLAYER_STATE3_10000000)) { + if ((func_808561B0 != this->actionFunc) && (func_80853D68 != this->actionFunc) && + (this->actor.draw != NULL)) { + if ((this->actor.id != ACTOR_PLAYER) && (this->csMode == PLAYER_CSMODE_110)) { + this->cylinder.dim.radius = 8; + } + CollisionCheck_SetOC(play, &play->colChkCtx, &this->cylinder.base); + } + } + if (!(this->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_4000000)) && (this->invincibilityTimer <= 0)) { + if ((func_808561B0 != this->actionFunc) && + ((func_80857BE8 != this->actionFunc) || (this->unk_AE7 != 1))) { + if (this->cylinder.base.atFlags != AT_NONE) { + CollisionCheck_SetAT(play, &play->colChkCtx, &this->cylinder.base); + } + CollisionCheck_SetAC(play, &play->colChkCtx, &this->cylinder.base); + } + } + } + + AnimationContext_SetNextQueue(play); + } + + func_801229FC(this); + Math_Vec3f_Copy(&this->actor.home.pos, &this->actor.world.pos); + + if ((this->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_10000000 | PLAYER_STATE1_20000000)) || + (this != GET_PLAYER(play))) { + this->actor.colChkInfo.mass = MASS_IMMOVABLE; + } else { + this->actor.colChkInfo.mass = sPlayerMass[this->transformation]; + } + + this->stateFlags3 &= ~(PLAYER_STATE3_4 | PLAYER_STATE3_400); + Collider_ResetCylinderAC(play, &this->cylinder.base); + Collider_ResetCylinderAC(play, &this->shieldCylinder.base); + Collider_ResetCylinderAT(play, &this->shieldCylinder.base); + Collider_ResetQuadAT(play, &this->meleeWeaponQuads[0].base); + Collider_ResetQuadAT(play, &this->meleeWeaponQuads[1].base); + Collider_ResetQuadAC(play, &this->shieldQuad.base); + + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) || + (this->actor.floorBgId != BGCHECK_SCENE)) { + this->unk_AC0 = 0.0f; + } + this->actor.shape.yOffset = this->unk_ABC + this->unk_AC0; +} + +Vec3f D_8085D41C = { 0.0f, 0.0f, -30.0f }; + +void Player_Update(Actor* thisx, PlayState* play) { + static Vec3f sDogSpawnPos; + Player* this = (Player*)thisx; + s32 dogParams; + s32 pad; + Input input; + s32 pad2; + + this->stateFlags3 &= ~PLAYER_STATE3_10; + + // This block is a leftover dog-following mechanic from OoT + if (gSaveContext.dogParams < 0) { + if (Object_GetIndex(&play->objectCtx, OBJECT_DOG) < 0) { + gSaveContext.dogParams = 0; + } else { + Actor* dog; + + gSaveContext.dogParams &= (u16)~0x8000; + Player_TranslateAndRotateY(this, &this->actor.world.pos, &D_8085D41C, &sDogSpawnPos); + + dogParams = gSaveContext.dogParams; + + dog = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_DG, sDogSpawnPos.x, sDogSpawnPos.y, sDogSpawnPos.z, 0, + this->actor.shape.rot.y, 0, dogParams | 0x8000); + if (dog != NULL) { + dog->room = -1; + } + } + } + + if ((this->interactRangeActor != NULL) && (this->interactRangeActor->update == NULL)) { + this->interactRangeActor = NULL; + } + + if ((this->heldActor != NULL) && (this->heldActor->update == NULL)) { + func_8082DCA0(play, this); + } + + if ((play->actorCtx.unk268 != 0) && (this == GET_PLAYER(play))) { + input = play->actorCtx.unk_26C; + } else if ((this->csMode == PLAYER_CSMODE_5) || (this->stateFlags1 & (PLAYER_STATE1_20 | PLAYER_STATE1_20000000)) || + (this != GET_PLAYER(play)) || func_8082DA90(play) || + (gSaveContext.save.saveInfo.playerData.health == 0)) { + bzero(&input, sizeof(Input)); + this->fallStartHeight = this->actor.world.pos.y; + } else { + input = *CONTROLLER1(&play->state); + if (this->unk_B5E != 0) { + input.cur.button &= ~(BTN_CUP | BTN_B | BTN_A); + input.press.button &= ~(BTN_CUP | BTN_B | BTN_A); + } + } + + Player_UpdateCommon(this, play, &input); + play->actorCtx.unk268 = 0; + bzero(&play->actorCtx.unk_26C, sizeof(Input)); + + MREG(52) = this->actor.world.pos.x; + MREG(53) = this->actor.world.pos.y; + MREG(54) = this->actor.world.pos.z; + MREG(55) = this->actor.world.rot.y; +} + +void Player_DrawGameplay(PlayState* play, Player* this, s32 lod, Gfx* cullDList, + OverrideLimbDrawFlex overrideLimbDraw) { + OPEN_DISPS(play->state.gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x0C, cullDList); + gSPSegment(POLY_XLU_DISP++, 0x0C, cullDList); + + Player_DrawImpl(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, lod, + this->transformation, 0, this->actor.shape.face, overrideLimbDraw, Player_PostLimbDrawGameplay, + &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); +} + +void func_80846460(Player* this) { + Vec3f* pos; + Vec3f* bodyPartsPos; + s32 i; + + this->actor.focus.pos.x = this->actor.world.pos.x; + this->actor.focus.pos.z = this->actor.world.pos.z; + this->actor.focus.pos.y = this->actor.world.pos.y + 24.0f; + + pos = &this->actor.world.pos; + bodyPartsPos = this->bodyPartsPos; + for (i = 0; i < ARRAY_COUNT(this->bodyPartsPos); i++) { + Math_Vec3f_Copy(bodyPartsPos, pos); + bodyPartsPos++; + } + + this->bodyPartsPos[PLAYER_BODYPART_HEAD].y = this->actor.world.pos.y + 24.0f; + this->bodyPartsPos[PLAYER_BODYPART_WAIST].y = this->actor.world.pos.y + 60.0f; + Math_Vec3f_Copy(this->actor.shape.feetPos, pos); + Math_Vec3f_Copy(&this->actor.shape.feetPos[1], pos); +} + +struct_80124618 D_8085D428[] = { + { 0, { 0, 0, 0 } }, { 1, { 80, 170, 80 } }, { 3, { 100, 80, 100 } }, + { 7, { 100, 100, 100 } }, { 8, { 100, 100, 100 } }, +}; +struct_80124618 D_8085D450[] = { + { 0, { 0, 0, 0 } }, { 1, { 80, 170, 80 } }, { 3, { 100, 80, 100 } }, + { 7, { 100, 100, 100 } }, { 8, { 100, 100, 100 } }, +}; +struct_80124618 D_8085D478[] = { + { 0, { 0, 0, 0 } }, + { 8, { 0, 0, 0 } }, +}; +struct_80124618 D_8085D488[] = { + { 0, { 100, 100, 100 } }, { 1, { 100, 60, 100 } }, { 3, { 100, 140, 100 } }, + { 7, { 100, 80, 100 } }, { 9, { 100, 100, 100 } }, +}; +struct_80124618 D_8085D4B0[] = { + { 0, { 100, 100, 100 } }, { 1, { 100, 70, 100 } }, { 3, { 100, 120, 100 } }, + { 6, { 100, 80, 100 } }, { 8, { 100, 100, 100 } }, { 9, { 100, 100, 100 } }, +}; +struct_80124618 D_8085D4E0[] = { + { 0, { 0, 0, 0 } }, { 1, { 0, 0, 0 } }, { 3, { 100, 130, 100 } }, + { 5, { 130, 130, 130 } }, { 7, { 80, 90, 80 } }, { 9, { 100, 100, 100 } }, +}; +struct_80124618 D_8085D510[] = { + { 0, { 0, 50, 0 } }, + { 1, { 0, 50, 0 } }, +}; +struct_80124618 D_8085D520[] = { + { 0, { 100, 120, 100 } }, + { 1, { 100, 120, 100 } }, +}; +struct_80124618 D_8085D530[] = { + { 0, { 160, 120, 160 } }, + { 1, { 160, 120, 160 } }, +}; +struct_80124618 D_8085D540[] = { + { 0, { 0, 0, 0 } }, + { 2, { 100, 100, 100 } }, +}; + +struct_80124618* D_8085D550[3] = { + D_8085D488, + D_8085D4B0, + D_8085D4E0, +}; +struct_80124618* D_8085D55C[3] = { + D_8085D428, + D_8085D450, + D_8085D478, +}; +struct_80124618* D_8085D568[3] = { + D_8085D510, + D_8085D520, + D_8085D530, +}; + +Gfx* D_8085D574[] = { + object_link_nuts_DL_009C48, + object_link_nuts_DL_009AB8, + object_link_nuts_DL_009DB8, +}; + +Color_RGB8 D_8085D580 = { 255, 255, 255 }; +Color_RGB8 D_8085D584 = { 80, 80, 200 }; + +void Player_Draw(Actor* thisx, PlayState* play) { + Player* this = THIS; + f32 one = 1.0f; + s32 spEC = false; + + Math_Vec3f_Copy(&this->unk_D6C, &this->bodyPartsPos[PLAYER_BODYPART_WAIST]); + if (this->stateFlags3 & (PLAYER_STATE3_100 | PLAYER_STATE3_40000)) { + struct_80124618** spE8 = D_8085D550; + struct_80124618** spE4; + f32 spE0; + Gfx** spDC; + s32 i; + + OPEN_DISPS(play->state.gfxCtx); + + Matrix_Push(); + func_8012C268(&play->state); + spEC = true; + if (this->stateFlags3 & PLAYER_STATE3_40000) { + Matrix_SetTranslateRotateYXZ(this->unk_AF0[0].x, this->unk_AF0[0].y, this->unk_AF0[0].z, &gZeroVec3s); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + spE8 = D_8085D568; + spE0 = 0.0f; + } else { + Matrix_Translate(0.0f, -this->unk_ABC, 0.0f, MTXMODE_APPLY); + spE0 = this->unk_AE8 - 6; + if (spE0 < 0.0f) { + spE8 = D_8085D55C; + spE0 = this->unk_B86[0]; + } + } + + spE4 = spE8; + spDC = D_8085D574; + + for (i = 0; i < 3; i++, spE4++, spDC++) { + Matrix_Push(); + func_80124618(*spE4, spE0, &this->unk_AF0[1]); + Matrix_Scale(this->unk_AF0[1].x, this->unk_AF0[1].y, this->unk_AF0[1].z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, *spDC); + + Matrix_Pop(); + } + Matrix_Pop(); + + CLOSE_DISPS(play->state.gfxCtx); + } + + if (!(this->stateFlags2 & PLAYER_STATE2_20000000) && (this->unk_ABC > -3900.0f)) { + OPEN_DISPS(play->state.gfxCtx); + + if (!spEC) { + func_8012C268(&play->state); + } + + func_8012C2DC(play->state.gfxCtx); + + func_800B8050(&this->actor, play, 0); + func_800B8118(&this->actor, play, 0); + func_80122868(play, this); + + if (this->stateFlags3 & PLAYER_STATE3_1000) { + Color_RGB8 spBC; + f32 spB8 = this->unk_ABC + 1.0f; + f32 spB4 = 1.0f - (this->unk_ABC * 0.5f); + + func_80846460(this); + Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y + (1200.0f * this->actor.scale.y * spB8), + this->actor.world.pos.z, MTXMODE_NEW); + + if (this->unk_B86[0] != 0) { + Matrix_RotateYS(this->unk_B28, MTXMODE_APPLY); + Matrix_RotateXS(this->unk_B86[0], MTXMODE_APPLY); + Matrix_RotateYS(-this->unk_B28, MTXMODE_APPLY); + } + + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + + Matrix_Scale(this->actor.scale.x * spB4 * 1.15f, this->actor.scale.y * spB8 * 1.15f, + CLAMP_MIN(spB8, spB4) * this->actor.scale.z * 1.15f, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Scene_SetRenderModeXlu(play, 0, 1); + Lib_LerpRGB(&D_8085D580, &D_8085D584, this->unk_B10[0], &spBC); + + gDPSetEnvColor(POLY_OPA_DISP++, spBC.r, spBC.g, spBC.b, 255); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, gLinkGoronCurledDL); + + if (this->unk_B86[1] != 0) { + if (this->unk_B86[1] < 3) { + func_80124618(D_8085D540, this->unk_B86[1], this->unk_AF0); + Matrix_Scale(this->unk_AF0[0].x, this->unk_AF0[0].y, this->unk_AF0[0].z, MTXMODE_APPLY); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + + gSPDisplayList(POLY_OPA_DISP++, object_link_goron_DL_00C540); + } + + func_80122BA4(play, &this->unk_3D0, 1, 255); + func_80122BA4(play, &this->unk_3D0, 2, 255); + + if (this->unk_B86[1] < 3) { + if (this->unk_AE7 >= 5) { + f32 var_fa1; + u8 sp9B; + + var_fa1 = (this->unk_AE7 - 4) * 0.02f; + + if (this->unk_B86[1] != 0) { + sp9B = (-this->unk_B86[1] * 0x55) + 0xFF; + } else { + sp9B = (200.0f * var_fa1); + } + + if (this->unk_B86[1] != 0) { + var_fa1 = 0.65f; + } else { + var_fa1 *= one; + } + + Matrix_Scale(1.0f, var_fa1, var_fa1, MTXMODE_APPLY); + + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(&object_link_goron_Matanimheader_013138)); + gDPSetEnvColor(POLY_XLU_DISP++, 155, 0, 0, sp9B); + gSPDisplayList(POLY_XLU_DISP++, object_link_goron_DL_0127B0); + AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(&object_link_goron_Matanimheader_014684)); + gSPDisplayList(POLY_XLU_DISP++, object_link_goron_DL_0134D0); + } + } + } else if ((this->transformation == PLAYER_FORM_GORON) && (this->stateFlags1 & PLAYER_STATE1_400000)) { + func_80846460(this); + SkelAnime_DrawFlexOpa(play, this->unk_2C8.skeleton, this->unk_2C8.jointTable, this->unk_2C8.dListCount, + NULL, NULL, NULL); + } else { + OverrideLimbDrawFlex sp84 = Player_OverrideLimbDrawGameplayDefault; + s32 lod = ((this->csMode != PLAYER_CSMODE_0) || (this->actor.projectedPos.z < 320.0f)) ? 0 : 1; + Vec3f sp74; + + //! FAKE + if (this->transformation == PLAYER_FORM_FIERCE_DEITY) {} + + if (this->stateFlags1 & PLAYER_STATE1_100000) { + SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &this->actor.focus.pos, &sp74); + if (sp74.z < -4.0f) { + sp84 = Player_OverrideLimbDrawGameplayFirstPerson; + } + } + + if (this->stateFlags2 & PLAYER_STATE2_4000000) { + s16 temp_s0_2 = play->gameplayFrames * 600; + s16 sp70 = (play->gameplayFrames * 1000) & 0xFFFF; + + Matrix_Push(); + + this->actor.scale.y = -this->actor.scale.y; + Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, + this->actor.world.pos.y + (2.0f * this->actor.depthInWater) + + (this->unk_ABC * this->actor.scale.y), + this->actor.world.pos.z, &this->actor.shape.rot); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + Matrix_RotateXS(temp_s0_2, MTXMODE_APPLY); + Matrix_RotateYS(sp70, MTXMODE_APPLY); + Matrix_Scale(1.1f, 0.95f, 1.05f, MTXMODE_APPLY); + Matrix_RotateYS(-sp70, MTXMODE_APPLY); + Matrix_RotateXS(-temp_s0_2, MTXMODE_APPLY); + Player_DrawGameplay(play, this, lod, gCullFrontDList, sp84); + this->actor.scale.y = -this->actor.scale.y; + + Matrix_Pop(); + } + + gSPClearGeometryMode(POLY_OPA_DISP++, G_CULL_BOTH); + + gSPClearGeometryMode(POLY_XLU_DISP++, G_CULL_BOTH); + + if ((this->transformation == PLAYER_FORM_ZORA) && (this->unk_B62 != 0) && + !(this->stateFlags3 & PLAYER_STATE3_8000)) { + Matrix_Push(); + Matrix_RotateXS(-0x4000, MTXMODE_APPLY); + Matrix_Translate(0.0f, 0.0f, -1800.0f, MTXMODE_APPLY); + Player_DrawZoraShield(play, this); + Matrix_Pop(); + } + + Player_DrawGameplay(play, this, lod, gCullBackDList, sp84); + } + + func_801229A0(play, this); + if (this->stateFlags2 & PLAYER_STATE2_4000) { + f32 temp_fa0 = this->unk_B48; + + gSPSegment(POLY_XLU_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, -(s32)play->gameplayFrames & 0x7F, 0x20, 0x20, 1, 0, + ((s32)play->gameplayFrames * -2) & 0x7F, 0x20, 0x20)); + + Matrix_Scale(temp_fa0, temp_fa0, temp_fa0, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + gDPSetEnvColor(POLY_XLU_DISP++, 0, 50, 100, 255); + + gSPDisplayList(POLY_XLU_DISP++, gEffIceFragment3DL); + } + + if (this->getItemDrawIdPlusOne > GID_NONE + 1) { + Player_DrawGetItem(play, this); + } + + func_80122D44(play, &this->unk_3D0); + + CLOSE_DISPS(play->state.gfxCtx); + } + + play->actorCtx.flags &= ~ACTORCTX_FLAG_3; +} + +void Player_Destroy(Actor* thisx, PlayState* play) { + Player* this = (Player*)thisx; + + Effect_Destroy(play, this->meleeWeaponEffectIndex[0]); + Effect_Destroy(play, this->meleeWeaponEffectIndex[1]); + Effect_Destroy(play, this->meleeWeaponEffectIndex[2]); + LightContext_RemoveLight(play, &play->lightCtx, this->lightNode); + Collider_DestroyCylinder(play, &this->cylinder); + Collider_DestroyCylinder(play, &this->shieldCylinder); + Collider_DestroyQuad(play, &this->meleeWeaponQuads[0]); + Collider_DestroyQuad(play, &this->meleeWeaponQuads[1]); + Collider_DestroyQuad(play, &this->shieldQuad); + ZeldaArena_Free(this->giObjectSegment); + ZeldaArena_Free(this->maskObjectSegment); + Magic_Reset(play); + func_80831454(this); +} + +s32 func_80847190(PlayState* play, Player* this, s32 arg2) { + s32 pad; + s16 var_s0; + + if (!func_800B7128(this) && !func_8082EF20(this) && !arg2) { + var_s0 = sPlayerControlInput->rel.stick_y * 0xF0; + Math_SmoothStepToS(&this->actor.focus.rot.x, var_s0, 0xE, 0xFA0, 0x1E); + + var_s0 = sPlayerControlInput->rel.stick_x * -0x10; + var_s0 = CLAMP(var_s0, -0xBB8, 0xBB8); + this->actor.focus.rot.y += var_s0; + } else { + s16 temp3; + + temp3 = ((sPlayerControlInput->rel.stick_y >= 0) ? 1 : -1) * + (s32)((1.0f - Math_CosS(sPlayerControlInput->rel.stick_y * 0xC8)) * 1500.0f); + this->actor.focus.rot.x += temp3; + + if (this->stateFlags1 & PLAYER_STATE1_800000) { + this->actor.focus.rot.x = CLAMP(this->actor.focus.rot.x, -0x1F40, 0xFA0); + } else { + this->actor.focus.rot.x = CLAMP(this->actor.focus.rot.x, -0x36B0, 0x36B0); + } + + var_s0 = this->actor.focus.rot.y - this->actor.shape.rot.y; + temp3 = ((sPlayerControlInput->rel.stick_x >= 0) ? 1 : -1) * + (s32)((1.0f - Math_CosS(sPlayerControlInput->rel.stick_x * 0xC8)) * -1500.0f); + var_s0 += temp3; + + this->actor.focus.rot.y = CLAMP(var_s0, -0x4AAA, 0x4AAA) + this->actor.shape.rot.y; + } + + this->unk_AA6 |= 2; + + return func_80832754(this, (play->unk_1887C != 0) || func_800B7128(this) || func_8082EF20(this)); +} + +void func_8084748C(Player* this, f32* speed, f32 speedTarget, s16 yawTarget) { + f32 incrStep = this->skelAnime.curFrame - 10.0f; + f32 maxSpeed = (R_RUN_SPEED_LIMIT / 100.0f) * 0.8f; + + if (*speed > maxSpeed) { + *speed = maxSpeed; + } + + if ((0.0f < incrStep) && (incrStep < 16.0f)) { + incrStep = fabsf(incrStep) * 0.5f; + } else { + speedTarget = 0.0f; + incrStep = 0.0f; + } + + Math_AsymStepToF(speed, speedTarget * 0.8f, incrStep, (fabsf(*speed) * 0.02f) + 0.05f); + Math_ScaledStepToS(&this->currentYaw, yawTarget, 1600); // 1 ESS turn, also one frame of first-person rotation +} + +void func_808475B4(Player* this) { + f32 sp4; + f32 temp_fa1; + f32 temp_fv0; + f32 var_ft4 = -5.0f; + f32 var_ft5 = this->ageProperties->unk_28; + f32 var_ft5_4; + + temp_fv0 = this->actor.depthInWater - var_ft5; + if (this->actor.velocity.y < 0.0f) { + var_ft5 += 1.0f; + } + + if (this->actor.depthInWater < var_ft5) { + temp_fv0 = CLAMP(temp_fv0, -0.4f, -0.1f); + sp4 = temp_fv0 - ((this->actor.velocity.y <= 0.0f) ? 0.0f : this->actor.velocity.y * 0.5f); + } else { + if (!(this->stateFlags1 & PLAYER_STATE1_80) && (this->currentBoots >= PLAYER_BOOTS_ZORA_UNDERWATER) && + (this->actor.velocity.y >= -5.0f)) { + sp4 = -0.3f; + } else if ((this->transformation == PLAYER_FORM_DEKU) && (this->actor.velocity.y < 0.0f)) { + var_ft4 = 0.0f; + sp4 = -this->actor.velocity.y; + } else { + var_ft4 = 2.0f; + var_ft5_4 = CLAMP(temp_fv0, 0.1f, 0.4f); + sp4 = ((this->actor.velocity.y >= 0.0f) ? 0.0f : this->actor.velocity.y * -0.3f) + var_ft5_4; + } + + if (this->actor.depthInWater > 100.0f) { + this->stateFlags2 |= PLAYER_STATE2_400; + } + } + + this->actor.velocity.y += sp4; + if (((this->actor.velocity.y - var_ft4) * sp4) > 0.0f) { + this->actor.velocity.y = var_ft4; + } + this->actor.gravity = 0.0f; +} + +void func_808477D0(PlayState* play, Player* this, Input* input, f32 arg3) { + f32 var_fv0; + + if ((input != NULL) && CHECK_BTN_ANY(input->press.button, BTN_B | BTN_A)) { + var_fv0 = 1.0f; + } else { + var_fv0 = 0.5f; + } + + var_fv0 = var_fv0 * arg3; + var_fv0 = CLAMP(var_fv0, 1.0f, 2.5f); + this->skelAnime.playSpeed = var_fv0; + + PlayerAnimation_Update(play, &this->skelAnime); +} + +s32 func_80847880(PlayState* play, Player* this) { + if (play->unk_1887C != 0) { + if (play->sceneId == SCENE_20SICHITAI) { + Player_SetAction(play, this, func_80854430, 0); + play->unk_1887C = 0; + this->csMode = PLAYER_CSMODE_0; + return true; + } + + func_8082DE50(play, this); + Player_SetAction(play, this, func_80854614, 0); + if (!func_800B7118(this) || Player_IsHoldingHookshot(this)) { + func_80831990(play, this, ITEM_BOW); + } + Player_AnimationPlayOnce(play, this, func_8082ED20(this)); + this->csMode = PLAYER_CSMODE_0; + this->stateFlags1 |= PLAYER_STATE1_100000; + Player_StopHorizontalMovement(this); + func_80836D8C(this); + + return true; + } + return false; +} + +s32 func_80847994(PlayState* play, Player* this) { + if (this->stateFlags3 & PLAYER_STATE3_20) { + this->stateFlags3 &= ~PLAYER_STATE3_20; + this->itemAction = PLAYER_IA_OCARINA; + this->unk_AA5 = PLAYER_UNKAA5_5; + func_80838A90(this, play); + return true; + } + return false; +} + +void func_808479F4(PlayState* play, Player* this, f32 arg2) { + if (this->actor.wallBgId != BGCHECK_SCENE) { + DynaPolyActor* actor = DynaPoly_GetActor(&play->colCtx, this->actor.wallBgId); + + if (actor != NULL) { + func_800B72F8(actor, arg2, this->actor.world.rot.y); + } + } +} + +void func_80847A50(Player* this) { + Player_PlaySfx(this, ((this->unk_AE7 != 0) ? NA_SE_PL_WALK_METAL1 : NA_SE_PL_WALK_LADDER) + + this->ageProperties->surfaceSfxIdOffset); +} + +Vec3f D_8085D588[] = { + { 30.0f, 0.0f, 0.0f }, + { -30.0f, 0.0f, 0.0f }, +}; +Vec3f D_8085D5A0[] = { + { 60.0f, 20.0f, 0.0f }, + { -60.0f, 20.0f, 0.0f }, +}; +Vec3f D_8085D5B8[] = { + { 60.0f, -20.0f, 0.0f }, + { -60.0f, -20.0f, 0.0f }, +}; +Vec3f D_8085D5D0 = { 0.0f, 0.0f, -30.0f }; + +// related to mounting/unmounting the horse +s32 func_80847A94(PlayState* play, Player* this, s32 arg2, f32* arg3) { + Actor* rideActor = this->rideActor; + f32 sp60 = rideActor->world.pos.y + 20.0f; + f32 sp5C = rideActor->world.pos.y - 20.0f; + Vec3f sp50; + Vec3f sp44; + CollisionPoly* sp40; + CollisionPoly* sp3C; + s32 sp38; + s32 sp34; + + *arg3 = func_80835CD8(play, this, &D_8085D588[arg2], &sp50, &sp3C, &sp34); + + if ((sp5C < *arg3) && (*arg3 < sp60)) { + if (!func_80835D58(play, this, &D_8085D5A0[arg2], &sp40, &sp38, &sp44)) { + if (!func_80835D58(play, this, &D_8085D5B8[arg2], &sp40, &sp38, &sp44)) { + this->actor.floorPoly = sp3C; + this->actor.floorBgId = sp38; + this->floorSfxOffset = SurfaceType_GetSfxOffset(&play->colCtx, sp3C, sp34); + return true; + } + } + } + return false; +} + +s32 func_80847BF0(Player* this, PlayState* play) { + EnHorse* rideActor = (EnHorse*)this->rideActor; + s32 var_a2; + f32 sp34; + + if (this->unk_AE8 < 0) { + this->unk_AE8 = 0x63; + } else { + var_a2 = (this->mountSide < 0) ? 0 : 1; + + if (!func_80847A94(play, this, var_a2, &sp34)) { + var_a2 ^= 1; + if (!func_80847A94(play, this, var_a2, &sp34)) { + return false; + } + + this->mountSide = -this->mountSide; + } + + if (play->csCtx.state == CS_STATE_IDLE) { + if (!func_8082DA90(play)) { + if (EN_HORSE_CHECK_1(rideActor) || EN_HORSE_CHECK_4(rideActor)) { + this->stateFlags2 |= PLAYER_STATE2_400000; + + if (EN_HORSE_CHECK_1(rideActor) || + (EN_HORSE_CHECK_4(rideActor) && CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A))) { + rideActor->actor.child = NULL; + + func_8083172C(play, this, func_808505D0, 0); + this->unk_B48 = sp34 - rideActor->actor.world.pos.y; + + Player_AnimationPlayOnce(play, this, + (this->mountSide < 0) ? &gPlayerAnim_link_uma_left_down + : &gPlayerAnim_link_uma_right_down); + + return true; + } + } + } + } + } + + return false; +} + +// Used in 2 horse-related functions +void func_80847E2C(Player* this, f32 arg1, f32 minFrame) { + f32 addend; + f32 dir; + + if ((this->unk_B48 != 0.0f) && (minFrame <= this->skelAnime.curFrame)) { + if (arg1 < fabsf(this->unk_B48)) { + dir = (this->unk_B48 >= 0.0f) ? 1 : -1; + addend = dir * arg1; + } else { + addend = this->unk_B48; + } + this->actor.world.pos.y += addend; + this->unk_B48 -= addend; + } +} + +s32 func_80847ED4(Player* this) { + return (this->interactRangeActor != NULL) && (this->interactRangeActor->id == ACTOR_EN_ZOG) && + CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A); +} + +void func_80847F1C(Player* this) { + s32 pad; + f32 yPos; + s16 yaw; + Actor* interactRangeActor = this->interactRangeActor; + + if (func_80847ED4(this)) { + yPos = this->actor.world.pos.y; + yaw = this->currentYaw - interactRangeActor->shape.rot.y; + Lib_Vec3f_TranslateAndRotateY(&interactRangeActor->world.pos, interactRangeActor->shape.rot.y, &D_8085D5D0, + &this->actor.world.pos); + this->actor.world.pos.y = yPos; + this->actor.shape.rot.y = interactRangeActor->shape.rot.y; + + interactRangeActor->speed = Math_CosS(ABS_ALT(yaw)) * this->linearVelocity * 0.5f; + if (interactRangeActor->speed < 0.0f) { + interactRangeActor->speed = 0.0f; + } + func_8083133C(this); + } +} + +AnimSfxEntry D_8085D5DC[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 0, NA_SE_PL_SWIM, STOP), +}; + +void func_80847FF8(Player* this, f32* arg1, f32 arg2, s16 arg3) { + func_8084748C(this, arg1, arg2, arg3); + Player_PlayAnimSfx(this, D_8085D5DC); + func_80847F1C(this); +} + +void func_80848048(PlayState* play, Player* this) { + Player_SetAction(play, this, func_80851588, 0); + func_8082E634(play, this, &gPlayerAnim_link_swimer_swim); +} + +s32 func_80848094(PlayState* play, Player* this, f32* arg2, s16* arg3) { + PlayerAnimationHeader* anim; + s16 temp_v0 = this->currentYaw - *arg3; + s32 temp_v0_2; + + if (ABS_ALT(temp_v0) > 0x6000) { + anim = &gPlayerAnim_link_swimer_swim_wait; + if (Math_StepToF(&this->linearVelocity, 0.0f, 1.0f)) { + this->currentYaw = *arg3; + } else { + *arg2 = 0.0f; + *arg3 = this->currentYaw; + } + } else { + temp_v0_2 = func_8083E514(this, arg2, arg3, play); + if (temp_v0_2 > 0) { + anim = &gPlayerAnim_link_swimer_swim; + } else if (temp_v0_2 < 0) { + anim = &gPlayerAnim_link_swimer_back_swim; + } else { + s16 diff = BINANG_SUB(this->actor.shape.rot.y, *arg3); + + if (diff > 0) { + anim = &gPlayerAnim_link_swimer_Rside_swim; + } else { + anim = &gPlayerAnim_link_swimer_Lside_swim; + } + } + } + + if (anim != this->skelAnime.animation) { + func_8082E634(play, this, anim); + return true; + } + return false; +} + +void func_808481CC(PlayState* play, Player* this, f32 arg2) { + f32 sp2C; + s16 sp2A; + + func_80832F78(this, &sp2C, &sp2A, 0.0f, play); + func_8084748C(this, &this->linearVelocity, sp2C / 2.0f, sp2A); + func_8084748C(this, &this->actor.velocity.y, arg2, this->currentYaw); +} + +void func_80848250(PlayState* play, Player* this) { + this->getItemDrawIdPlusOne = GID_NONE + 1; + this->stateFlags1 &= ~(PLAYER_STATE1_400 | PLAYER_STATE1_800); + this->getItemId = GI_NONE; + func_800E0238(Play_GetCamera(play, CAM_ID_MAIN)); +} + +void func_80848294(PlayState* play, Player* this) { + func_80848250(play, this); + func_8082DC28(this); + func_80839E74(this, play); + this->currentYaw = this->actor.shape.rot.y; +} + +// Player_GetItem? +s32 func_808482E0(PlayState* play, Player* this) { + if (this->getItemId == GI_NONE) { + return true; + } + + if (this->unk_AE7 == 0) { + GetItemEntry* giEntry = &sGetItemTable[this->getItemId - 1]; + + this->unk_AE7 = 1; + Message_StartTextbox(play, giEntry->textId, &this->actor); + Item_Give(play, giEntry->itemId); + + if ((this->getItemId >= GI_MASK_DEKU) && (this->getItemId <= GI_MASK_KAFEIS_MASK)) { + Audio_PlayFanfare(NA_BGM_GET_NEW_MASK); + } else if (((this->getItemId >= GI_RUPEE_GREEN) && (this->getItemId <= GI_RUPEE_10)) || + (this->getItemId == GI_RECOVERY_HEART)) { + play_sound(NA_SE_SY_GET_BOXITEM); + } else { + s32 seqId; + + if ((this->getItemId == GI_HEART_CONTAINER) || + ((this->getItemId == GI_HEART_PIECE) && EQ_MAX_QUEST_HEART_PIECE_COUNT)) { + seqId = NA_BGM_GET_HEART | 0x900; + } else { + s32 var_v1; + + if ((this->getItemId == GI_HEART_PIECE) || + ((this->getItemId >= GI_RUPEE_PURPLE) && (this->getItemId <= GI_RUPEE_HUGE))) { + var_v1 = NA_BGM_GET_SMALL_ITEM; + } else { + var_v1 = NA_BGM_GET_ITEM | 0x900; + } + seqId = var_v1; + } + + Audio_PlayFanfare(seqId); + } + } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { + if (this->getItemId == GI_OCARINA) { + // zelda teaching song of time cs? + play->nextEntrance = ENTRANCE(CUTSCENE, 0); + gSaveContext.nextCutsceneIndex = 0xFFF2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; + this->stateFlags1 &= ~PLAYER_STATE1_20000000; + func_8085B28C(play, NULL, PLAYER_CSMODE_WAIT); + } + this->getItemId = GI_NONE; + } + + return false; +} + +AnimSfxEntry D_8085D5E0[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 60, NA_SE_IT_MASTER_SWORD_SWING, STOP), +}; + +void func_808484CC(Player* this) { + Player_PlayAnimSfx(this, D_8085D5E0); +} + +void func_808484F0(Player* this) { + this->unk_B08 += this->unk_B0C; + this->unk_B0C -= this->unk_B08 * 5.0f; + this->unk_B0C *= 0.3f; + + if (fabsf(this->unk_B0C) < 0.00001f) { + this->unk_B0C = 0.0f; + if (fabsf(this->unk_B08) < 0.00001f) { + this->unk_B08 = 0.0f; + } + } +} + +s32 func_80848570(Player* this, PlayState* play) { + if (!func_8083A6C0(play, this)) { + if (func_808396B8(play, this)) { + PlayerMeleeWeaponAnimation meleeWeaponAnim = func_808335F4(this); + + func_80833864(play, this, meleeWeaponAnim); + if ((meleeWeaponAnim >= PLAYER_MWA_SPIN_ATTACK_1H) || + ((this->transformation == PLAYER_FORM_FIERCE_DEITY) && func_8082FBE8(this))) { + this->stateFlags2 |= PLAYER_STATE2_20000; + func_808332A0(play, this, 0, meleeWeaponAnim < PLAYER_MWA_SPIN_ATTACK_1H); + } + } else { + return false; + } + } + return true; +} + +// elegy of emptiness +void func_80848640(PlayState* play, Player* this) { + EnTorch2* torch2; + Actor* effChange; + + torch2 = play->actorCtx.elegyShells[this->transformation]; + if (torch2 != NULL) { + Math_Vec3f_Copy(&torch2->actor.home.pos, &this->actor.world.pos); + torch2->actor.home.rot.y = this->actor.shape.rot.y; + torch2->state = 0; + torch2->framesUntilNextState = 20; + } else { + torch2 = (EnTorch2*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_TORCH2, this->actor.world.pos.x, + this->actor.world.pos.y, this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, + this->transformation); + } + + if (torch2 != NULL) { + play->actorCtx.elegyShells[this->transformation] = torch2; + Play_SetupRespawnPoint(&play->state, this->transformation + 3, PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B)); + } + + effChange = Actor_Spawn(&play->actorCtx, play, ACTOR_EFF_CHANGE, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, this->actor.shape.rot.y, 0, + (GET_PLAYER_FORM << 3) | this->transformation); + if (effChange != NULL) { + //! @bug: This function should only pass Player*: it uses *(this + 0x153), which is meant to be + //! player->currentMask, but in this case is garbage in the skelAnime + Player_PlaySfx((Player*)effChange, NA_SE_PL_TRANSFORM); + } +} + +s32 func_80848780(Player* this, PlayState* play) { + if (func_80830B88(play, this)) { + return true; + } + return false; +} + +s32 func_808487B8(Player* this, PlayState* play) { + if (func_80830B88(play, this) || func_80830DF0(this, play)) { + return true; + } + return false; +} + +s32 func_80848808(Player* this, PlayState* play) { + if (PlayerAnimation_Update(play, &this->unk_284) || + ((Player_ItemToItemAction(this, this->heldItemId) == this->heldItemAction) && + (D_80862B48 = D_80862B48 || ((this->modelAnimType != PLAYER_ANIMTYPE_3) && + (this->heldItemAction != PLAYER_IA_STICK) && (play->unk_1887C == 0))))) { + func_8082F43C(play, this, D_8085C9F0[this->heldItemAction]); + this->unk_ACC = 0; + this->unk_AA4 = 0; + D_80862B4C = D_80862B48; + return this->unk_AC4(this, play); + } + + if (func_8082ED94(this) != 0) { + func_80830D40(play, this); + Player_AnimationPlayOnce(play, this, func_8082ED20(this)); + this->unk_AA4 = 0; + } else { + func_80830D40(play, this); + } + return true; +} + +s32 func_8084894C(Player* this, PlayState* play) { + PlayerAnimation_Update(play, &this->unk_284); + if (!CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_R)) { + func_80830CE8(play, this); + } else { + this->stateFlags1 |= PLAYER_STATE1_400000; + Player_SetModelsForHoldingShield(this); + if ((this->transformation == PLAYER_FORM_ZORA) && CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_B)) { + func_8082F164(this, BTN_R | BTN_B); + } + } + return true; +} + +s32 func_80848A0C(Player* this, PlayState* play) { + if (PlayerAnimation_Update(play, &this->unk_284)) { + PlayerAnimationHeader* anim; + f32 lastFrame; + + anim = func_80830A58(play, this); + lastFrame = Animation_GetLastFrame(anim); + PlayerAnimation_Change(play, &this->unk_284, anim, 1.0f, lastFrame, lastFrame, ANIMMODE_ONCE, 0.0f); + } + + this->stateFlags1 |= PLAYER_STATE1_400000; + Player_SetModelsForHoldingShield(this); + return true; +} + +s32 func_80848AB0(Player* this, PlayState* play) { + // possibly a case of if ((D_80862B48 = D_80862B4C) || PlayerAnimation_Update(play, &this->unk_284)) + D_80862B48 = D_80862B4C; + if ((D_80862B48 != 0) || PlayerAnimation_Update(play, &this->unk_284)) { + func_8082F43C(play, this, D_8085C9F0[this->heldItemAction]); + PlayerAnimation_PlayLoop(play, &this->unk_284, D_8085BE84[PLAYER_ANIMGROUP_0][this->modelAnimType]); + this->unk_AA4 = 0; + this->unk_AC4(this, play); + return false; + } + return true; +} + +s32 func_80848B6C(Player* this, PlayState* play) { + if (this->unk_B28 >= 0) { + this->unk_B28 = -this->unk_B28; + } + + if (!Player_IsHoldingHookshot(this) || func_80831124(play, this)) { + if (!func_80830B88(play, this) && !func_80831094(this, play)) { + return false; + } + } + return true; +} + +PlayerAnimationHeader* D_8085D5E4[] = { + &gPlayerAnim_link_hook_walk2ready, + &gPlayerAnim_link_bow_walk2ready, + &gPlayerAnim_pn_tamahakidf, +}; + +PlayerAnimationHeader* D_8085D5F0[] = { + &gPlayerAnim_link_hook_wait, + &gPlayerAnim_link_bow_bow_wait, + &gPlayerAnim_pn_tamahakidf, +}; + +u16 D_8085D5FC[] = { + NA_SE_IT_BOW_FLICK, + NA_SE_PL_DEKUNUTS_MISS_FIRE, + NA_SE_NONE, + NA_SE_NONE, +}; + +s32 func_80848BF4(Player* this, PlayState* play) { + s32 index; + s32 temp; + + if (Player_IsHoldingHookshot(this)) { + index = 0; + } else { + temp = (this->transformation != PLAYER_FORM_DEKU) ? 1 : 2; + index = temp; + } + + if (this->transformation != PLAYER_FORM_DEKU) { + Math_ScaledStepToS(&this->upperLimbRot.z, 0x4B0, 0x190); + this->unk_AA6 |= 0x100; + } + + if ((this->unk_ACE == 0) && (func_8082ED94(this) == 0) && + (this->skelAnime.animation == &gPlayerAnim_link_bow_side_walk)) { + PlayerAnimation_PlayOnce(play, &this->unk_284, D_8085D5E4[index]); + this->unk_ACE = -1; + } else if (PlayerAnimation_Update(play, &this->unk_284)) { + PlayerAnimation_PlayLoop(play, &this->unk_284, D_8085D5F0[index]); + this->unk_ACE = 1; + } else if (this->unk_ACE == 1) { + this->unk_ACE = 2; + } + + if (this->unk_ACC >= 0xB) { + this->unk_ACC--; + } + + func_80831010(this, play); + if ((this->unk_ACE > 0) && ((this->unk_B28 < 0) || ((D_80862B4C == 0) && !func_80830FD4(play)))) { + func_8082F43C(play, this, func_80848E4C); + if (this->unk_B28 >= 0) { + if (index != 0) { + if (!func_80831194(play, this)) { + Player_PlaySfx(this, D_8085D5FC[this->unk_B28 - 1]); + } + + if (this->transformation == PLAYER_FORM_DEKU) { + PlayerAnimation_PlayOnceSetSpeed(play, &this->unk_284, &gPlayerAnim_pn_tamahaki, 2.0f / 3.0f); + } + } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + func_80831194(play, this); + } + } + this->unk_ACC = 0xA; + Player_StopHorizontalMovement(this); + } else { + this->stateFlags3 |= PLAYER_STATE3_40; + } + + return 1; +} + +s32 func_80848E4C(Player* this, PlayState* play) { + s32 animFinished = PlayerAnimation_Update(play, &this->unk_284); + + if (Player_IsHoldingHookshot(this) && !func_80831124(play, this)) { + return true; + } + + if (!func_80830B88(play, this) && + ((((this->unk_B28 < 0) && (D_80862B4C != 0)) || + ((animFinished || (this->transformation != PLAYER_FORM_DEKU)) && (D_80862B48 != 0))) || + func_80830F9C(play))) { + + this->unk_B28 = ABS_ALT(this->unk_B28); + if (func_808306F8(this, play)) { + if (Player_IsHoldingHookshot(this)) { + this->unk_ACE = 1; + } else { + PlayerAnimation_PlayOnce(play, &this->unk_284, + (this->transformation == PLAYER_FORM_DEKU) + ? &gPlayerAnim_pn_tamahakidf + : &gPlayerAnim_link_bow_bow_shoot_next); + } + } + } else { + if (this->unk_ACC != 0) { + this->unk_ACC--; + } + + if ((func_8082FBE8(this)) || (this->unk_AA5 != PLAYER_UNKAA5_0) || (this->stateFlags1 & PLAYER_STATE1_100000)) { + if (this->unk_ACC == 0) { + this->unk_ACC++; + } + return true; + } + + if (Player_IsHoldingHookshot(this)) { + func_8082F43C(play, this, func_80848B6C); + } else { + func_8082F43C(play, this, func_80849054); + PlayerAnimation_PlayOnce(play, &this->unk_284, + (this->transformation == PLAYER_FORM_DEKU) ? &gPlayerAnim_pn_tamahakidf + : &gPlayerAnim_link_bow_bow_shoot_end); + } + this->unk_ACC = 0; + } + + return true; +} + +s32 func_80849054(Player* this, PlayState* play) { + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || PlayerAnimation_Update(play, &this->unk_284)) { + func_8082F43C(play, this, func_80848B6C); + } + return true; +} + +s32 func_808490B4(Player* this, PlayState* play) { + Actor* heldActor = this->heldActor; + + if (heldActor == NULL) { + func_808309CC(play, this); + } + + if (func_80830B88(play, this)) { + return true; + } + + if (this->stateFlags1 & PLAYER_STATE1_800) { + if (PlayerAnimation_Update(play, &this->unk_284)) { + PlayerAnimation_PlayLoop(play, &this->unk_284, &gPlayerAnim_link_normal_carryB_wait); + } + + if ((heldActor->id == ACTOR_EN_NIW) && (this->actor.velocity.y <= 0.0f)) { + this->actor.terminalVelocity = -2.0f; + this->actor.gravity = -0.5f; + this->fallStartHeight = this->actor.world.pos.y; + } + return true; + } + return func_80848780(this, play); +} + +s32 func_808491B4(Player* this, PlayState* play) { + if (func_80830B88(play, this)) { + return true; + } + + if (this->stateFlags1 & PLAYER_STATE1_2000000) { + func_8082F43C(play, this, func_80849570); + } else if (func_80831094(this, play)) { + return true; + } + + return false; +} + +s32 func_8084923C(Player* this, PlayState* play) { + if (PlayerAnimation_Update(play, &this->unk_284)) { + func_8082F43C(play, this, func_808492C4); + PlayerAnimation_PlayLoop(play, &this->unk_284, &gPlayerAnim_pz_cutterwaitanim); + } + if (this->unk_284.animation == &gPlayerAnim_pz_cutterwaitanim) { + func_80831010(this, play); + } + return true; +} + +s32 func_808492C4(Player* this, PlayState* play) { + PlayerAnimation_Update(play, &this->unk_284); + func_80831010(this, play); + if (D_80862B4C == 0) { + func_8082F43C(play, this, func_8084933C); + PlayerAnimation_PlayOnce(play, &this->unk_284, &gPlayerAnim_pz_cutterattack); + } + return true; +} + +s32 func_8084933C(Player* this, PlayState* play) { + if (PlayerAnimation_Update(play, &this->unk_284)) { + func_8082F43C(play, this, func_80849570); + this->unk_ACC = 0; + } else if (PlayerAnimation_OnFrame(&this->unk_284, 6.0f)) { + Vec3f pos; + s16 untargetedRotY; + + func_80835BF8(&this->bodyPartsPos[PLAYER_BODYPART_LEFT_HAND], this->actor.shape.rot.y, 0.0f, &pos); + pos.y = this->actor.world.pos.y + 50.0f; + + untargetedRotY = this->actor.shape.rot.y - 0x190; + this->boomerangActor = Actor_Spawn( + &play->actorCtx, play, ACTOR_EN_BOOM, pos.x, pos.y, pos.z, this->actor.focus.rot.x, + (this->targetedActor != NULL) ? this->actor.shape.rot.y + 0x36B0 : untargetedRotY, 0, ZORA_BOOMERANG_LEFT); + + if (this->boomerangActor != NULL) { + EnBoom* leftBoomerang = (EnBoom*)this->boomerangActor; + EnBoom* rightBoomerang; + + leftBoomerang->moveTo = this->targetedActor; + if (leftBoomerang->moveTo != NULL) { + leftBoomerang->unk_1CF = 0x10; + } + leftBoomerang->unk_1CC = leftBoomerang->unk_1CF + 0x24; + + func_80835BF8(&this->bodyPartsPos[PLAYER_BODYPART_RIGHT_HAND], this->actor.shape.rot.y, 0.0f, &pos); + + untargetedRotY = (this->actor.shape.rot.y + 0x190); + rightBoomerang = + (EnBoom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOOM, pos.x, pos.y, pos.z, this->actor.focus.rot.x, + (this->targetedActor != NULL) ? this->actor.shape.rot.y - 0x36B0 : untargetedRotY, + 0, ZORA_BOOMERANG_RIGHT); + + if (rightBoomerang != NULL) { + rightBoomerang->moveTo = this->targetedActor; + if (rightBoomerang->moveTo != NULL) { + rightBoomerang->unk_1CF = 0x10; + } + + rightBoomerang->unk_1CC = rightBoomerang->unk_1CF + 0x24; + leftBoomerang->actor.child = &rightBoomerang->actor; + rightBoomerang->actor.parent = &leftBoomerang->actor; + } + + this->stateFlags1 |= PLAYER_STATE1_2000000; + this->stateFlags3 &= ~PLAYER_STATE3_800000; + if (!func_80123420(this)) { + func_8083133C(this); + } + + this->unk_D57 = 20; + + Player_PlaySfx(this, NA_SE_IT_BOOMERANG_THROW); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_SWORD_N); + } + } + + return true; +} + +s32 func_80849570(Player* this, PlayState* play) { + if (func_80830B88(play, this)) { + return true; + } + + if (this->stateFlags3 & PLAYER_STATE3_800000) { + func_8082F43C(play, this, func_80849620); + PlayerAnimation_PlayOnce(play, &this->unk_284, &gPlayerAnim_pz_cuttercatch); + this->stateFlags3 &= ~PLAYER_STATE3_800000; + Player_PlaySfx(this, NA_SE_PL_CATCH_BOOMERANG); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_SWORD_N); + return true; + } + + return false; +} + +s32 func_80849620(Player* this, PlayState* play) { + if (!func_808491B4(this, play) && PlayerAnimation_Update(play, &this->unk_284)) { + if (this->stateFlags1 & PLAYER_STATE1_2000000) { + func_8082F43C(play, this, func_80849570); + this->unk_ACC = 0; + } else { + func_8082F43C(play, this, func_80848780); + } + } + return true; +} + +void func_808496AC(Player* this, PlayState* play) { + PlayerAnimation_Update(play, &this->skelAnime); + func_808323C0(this, play->playerCsIds[PLAYER_CS_ID_ITEM_BOTTLE]); + + if (DECR(this->unk_AE8) == 0) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { + Player_StopCutscene(this); + Player_SetAction(play, this, func_80849FE0, 0); + this->stateFlags1 &= ~PLAYER_STATE1_20000000; + } + } else if (this->unk_AE8 == 30) { + if (Message_GetState(&play->msgCtx) != TEXT_STATE_NONE) { + this->unk_AE8++; + } else { + Message_StartTextbox(play, 0xC03, NULL); + } + } +} + +void func_808497A0(Player* this, PlayState* play) { + this->stateFlags3 |= PLAYER_STATE3_10000000; + PlayerAnimation_Update(play, &this->skelAnime); + func_8083216C(this, play); + + if (R_PLAY_FILL_SCREEN_ON == 0) { + R_PLAY_FILL_SCREEN_ON = 20; + R_PLAY_FILL_SCREEN_ALPHA = 0; + R_PLAY_FILL_SCREEN_R = R_PLAY_FILL_SCREEN_G = R_PLAY_FILL_SCREEN_B = R_PLAY_FILL_SCREEN_ALPHA; + play_sound(NA_SE_SY_DEKUNUTS_JUMP_FAILED); + } else if (R_PLAY_FILL_SCREEN_ON > 0) { + R_PLAY_FILL_SCREEN_ALPHA += R_PLAY_FILL_SCREEN_ON; + if (R_PLAY_FILL_SCREEN_ALPHA > 255) { + R_PLAY_FILL_SCREEN_ALPHA = 255; + if (this->unk_B86[0] == 0) { + this->unk_B86[0] = 1; + func_8082DE50(play, this); + } else { + R_PLAY_FILL_SCREEN_ON = -20; + this->stateFlags1 &= ~PLAYER_STATE1_8000000; + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; + Player_SetEquipmentData(play, this); + this->prevBoots = this->currentBoots; + + if (this->unk_3CF != 0) { + Math_Vec3f_Copy(&this->actor.world.pos, &this->unk_3C0); + this->actor.shape.rot.y = this->unk_3CC; + } else { + Math_Vec3f_Copy(&this->actor.world.pos, &gSaveContext.respawn[RESPAWN_MODE_DOWN].pos); + this->actor.shape.rot.y = gSaveContext.respawn[RESPAWN_MODE_DOWN].yaw; + } + + Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); + this->linearVelocity = 0.0f; + this->currentYaw = this->actor.shape.rot.y; + this->actor.velocity.y = 0.0f; + Player_AnimationPlayOnce(play, this, func_8082ED20(this)); + + if ((play->roomCtx.curRoom.num == this->unk_3CE) && (play->roomCtx.prevRoom.num < 0)) { + this->unk_AE8 = 5; + } else { + play->roomCtx.curRoom.num = -1; + play->roomCtx.prevRoom.num = -1; + play->roomCtx.curRoom.segment = NULL; + play->roomCtx.prevRoom.segment = NULL; + + func_8012EBF8(play, &play->roomCtx); + this->unk_AE8 = -1; + this->unk_AE7 = this->unk_3CE; + } + } + } + } else if (this->unk_AE8 < 0) { + if (Room_StartRoomTransition(play, &play->roomCtx, this->unk_AE7)) { + Map_InitRoomData(play, play->roomCtx.curRoom.num); + Minimap_SavePlayerRoomInitInfo(play); + this->unk_AE8 = 5; + } + } else if (this->unk_AE8 > 0) { + this->unk_AE8--; + } else { + R_PLAY_FILL_SCREEN_ALPHA += R_PLAY_FILL_SCREEN_ON; + if (R_PLAY_FILL_SCREEN_ALPHA < 0) { + R_PLAY_FILL_SCREEN_ALPHA = 0; + R_PLAY_FILL_SCREEN_ON = 0; + func_808339B4(this, -40); + func_8085B384(this, play); + this->actor.bgCheckFlags |= BGCHECKFLAG_GROUND; + } + } +} + +void func_80849A9C(Player* this, PlayState* play) { + f32 sp44; + s16 sp42; + s32 temp_v0; + + if (this->unk_AE8 != 0) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_8082E794(this); + Player_AnimationPlayLoop(play, this, func_8082EF54(this)); + this->unk_AE8 = 0; + this->stateFlags3 &= ~PLAYER_STATE3_8; + } + func_8082FC60(this); + } else { + func_8083E958(play, this); + } + + func_80832F24(this); + if (func_80833058(play, this, D_8085CFE4, 1)) { + return; + } + + if (!func_8082FB68(this) && (!func_80123434(this) || (func_8084894C != this->unk_AC4))) { + func_8083B29C(this, play); + return; + } + + func_80832F78(this, &sp44, &sp42, 0.0f, play); + + temp_v0 = func_8083E404(this, sp44, sp42); + if (temp_v0 > 0) { + func_8083A844(this, play, sp42); + } else if (temp_v0 < 0) { + func_8083AF8C(this, sp42, play); + } else if (sp44 > 4.0f) { + func_8083B030(this, play); + } else { + u32 temp_v0_2; + + func_8083EA44(this, this->linearVelocity * 0.3f + 1.0f); + func_8083E8E0(this, sp44, sp42); + + temp_v0_2 = this->unk_B38; + if ((temp_v0_2 < 6) || ((temp_v0_2 - 0xE) < 6)) { + Math_StepToF(&this->linearVelocity, 0.0f, 1.5f); + } else { + s16 temp_v0_3 = sp42 - this->currentYaw; + s32 var_v1 = ABS_ALT(temp_v0_3); + + if (var_v1 > 0x4000) { + if (Math_StepToF(&this->linearVelocity, 0.0f, 1.5f)) { + this->currentYaw = sp42; + } + } else { + Math_AsymStepToF(&this->linearVelocity, sp44 * 0.3f, 2.0f, 1.5f); + Math_ScaledStepToS(&this->currentYaw, sp42, var_v1 * 0.1f); + } + } + } +} + +void func_80849DD0(Player* this, PlayState* play) { + f32 sp3C; + s16 sp3A; + s32 temp_v0; + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_8082E794(this); + Player_AnimationPlayOnce(play, this, func_8082ED20(this)); + this->stateFlags3 &= ~PLAYER_STATE3_8; + } + + func_80832F24(this); + if (func_80833058(play, this, D_8085CFEC, 1)) { + return; + } + + if (func_8082FB68(this)) { + func_8083B23C(this, play); + return; + } + if (!func_80123434(this)) { + func_8083172C(play, this, func_80849FE0, 1); + this->currentYaw = this->actor.shape.rot.y; + return; + } + if (func_8084894C == this->unk_AC4) { + func_8083B23C(this, play); + return; + } + + func_80832F78(this, &sp3C, &sp3A, 0.0f, play); + + temp_v0 = func_8083E514(this, &sp3C, &sp3A, play); + if (temp_v0 > 0) { + func_8083A844(this, play, sp3A); + } else if (temp_v0 < 0) { + func_8083AECC(this, sp3A, play); + } else if (sp3C > 4.9f) { + func_8083B030(this, play); + func_8082FC60(this); + } else if (sp3C != 0.0f) { + func_8083AF30(this, play); + } else { + s16 temp_v0_2 = sp3A - this->actor.shape.rot.y; + + if (ABS_ALT(temp_v0_2) > 0x320) { + func_8083B0E4(play, this, sp3A); + } + } +} + +void func_80849FE0(Player* this, PlayState* play) { + s32 temp_v0 = func_8082ED94(this); + s32 animFinished = PlayerAnimation_Update(play, &this->skelAnime); + f32 sp3C; + s16 sp3A; + s16 temp_v1_2; + + func_8083C85C(this); + if (temp_v0 > 0) { + func_8082EEA4(this, temp_v0 - 1); + } + + if (animFinished || + ((this->currentMask == PLAYER_MASK_SCENTS) && (this->skelAnime.animation != &gPlayerAnim_cl_msbowait)) || + ((this->currentMask != PLAYER_MASK_SCENTS) && (this->skelAnime.animation == &gPlayerAnim_cl_msbowait))) { + if (this->unk_AE8 != 0) { + if (DECR(this->unk_AE8) == 0) { + this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; + } + + this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1].y = + (this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1].y + ((this->unk_AE8 & 1) * 0x50)) - 0x28; + } else { + func_8082E794(this); + Player_ChooseIdleAnim(play, this); + } + this->stateFlags3 &= ~PLAYER_STATE3_8; + } + + func_80832F24(this); + if ((this->unk_AE8 == 0) && !func_80847880(play, this) && !func_80833058(play, this, D_8085D01C, 1)) { + if (func_8082FB68(this)) { + func_8083B23C(this, play); + return; + } + if (func_80123434(this)) { + func_8083692C(this, play); + return; + } + func_80832F78(this, &sp3C, &sp3A, 0.018f, play); + if (sp3C != 0.0f) { + func_8083A844(this, play, sp3A); + return; + } + temp_v1_2 = sp3A - this->actor.shape.rot.y; + + if (ABS_ALT(temp_v1_2) > 0x320) { + func_8083B0E4(play, this, sp3A); + } else { + Math_ScaledStepToS(&this->actor.shape.rot.y, sp3A, 0x4B0); + this->currentYaw = this->actor.shape.rot.y; + if (func_8082ED20(this) == this->skelAnime.animation) { + func_8083C6E8(this, play); + } + } + } +} + +void func_8084A26C(Player* this, PlayState* play) { + f32 var_fv0; + s16 temp_v0_3; + f32 sp44; + s16 sp42; + s32 var_v0; + s32 temp_v0_2; + s32 var_v1; + f32 var_fv1; + + this->skelAnime.mode = 0; + PlayerAnimation_SetUpdateFunction(&this->skelAnime); + + this->skelAnime.animation = func_8082EFE4(this); + if (this->skelAnime.animation == &gPlayerAnim_link_bow_side_walk) { + var_fv0 = 24.0f; + var_fv1 = -(MREG(95) / 100.0f); + } else { + var_fv0 = 29.0f; + var_fv1 = MREG(95) / 100.0f; + } + + this->skelAnime.animLength = var_fv0; + this->skelAnime.endFrame = var_fv0 - 1.0f; + if (BINANG_SUB(this->currentYaw, this->actor.shape.rot.y) >= 0) { + var_v0 = 1; + } else { + var_v0 = -1; + } + + this->skelAnime.playSpeed = var_v0 * (this->linearVelocity * var_fv1); + + PlayerAnimation_Update(play, &this->skelAnime); + if (PlayerAnimation_OnFrame(&this->skelAnime, 0.0f) || PlayerAnimation_OnFrame(&this->skelAnime, var_fv0 / 2.0f)) { + Player_AnimSfx_PlayFloorWalk(this, this->linearVelocity); + } + + if (func_80833058(play, this, D_8085CFF8, 1)) { + return; + } + + if (func_8082FB68(this)) { + func_8083B23C(this, play); + return; + } + if (!func_80123434(this)) { + func_8085B384(this, play); + return; + } + func_80832F78(this, &sp44, &sp42, 0.0f, play); + + temp_v0_2 = func_8083E514(this, &sp44, &sp42, play); + if (temp_v0_2 > 0) { + func_8083A844(this, play, sp42); + return; + } + if (temp_v0_2 < 0) { + func_8083AECC(this, sp42, play); + return; + } + if (sp44 > 4.9f) { + func_8083B030(this, play); + func_8082FC60(this); + return; + } + if ((sp44 == 0.0f) && (this->linearVelocity == 0.0f)) { + func_8083692C(this, play); + return; + } + + temp_v0_3 = sp42 - this->currentYaw; + var_v1 = ABS_ALT(temp_v0_3); + if (var_v1 > 0x4000) { + if (Math_StepToF(&this->linearVelocity, 0.0f, 1.5f)) { + this->currentYaw = sp42; + } + } else { + Math_AsymStepToF(&this->linearVelocity, sp44 * 0.4f, 1.5f, 1.5f); + Math_ScaledStepToS(&this->currentYaw, sp42, var_v1 * 0.1f); + } +} + +void func_8084A5C0(Player* this, PlayState* play) { + f32 sp34; + s16 sp32; + s32 sp2C; + + func_8083EE60(this, play); + if (func_80833058(play, this, D_8085D004, 1)) { + return; + } + + if (func_8082FC24(this) == 0) { + func_8083A844(this, play, this->currentYaw); + return; + } + + func_80832F78(this, &sp34, &sp32, 0.0f, play); + + sp2C = func_8083E514(this, &sp34, &sp32, play); + if (sp2C >= 0) { + if (!func_8083F190(this, &sp34, &sp32, play)) { + if (sp2C != 0) { + func_8083A794(this, play); + } else if (sp34 > 4.9f) { + func_8083B030(this, play); + } else { + func_8083AF30(this, play); + } + } + } else { + s16 sp2A = sp32 - this->currentYaw; + + Math_AsymStepToF(&this->linearVelocity, sp34 * 1.5f, 1.5f, 2.0f); + Math_ScaledStepToS(&this->currentYaw, sp32, sp2A * 0.1f); + if ((sp34 == 0.0f) && (this->linearVelocity == 0.0f)) { + func_8083692C(this, play); + } + } +} + +void func_8084A794(Player* this, PlayState* play) { + s32 animFinished = PlayerAnimation_Update(play, &this->skelAnime); + f32 sp30; + s16 sp2E; + + func_80832F24(this); + + if (func_80833058(play, this, D_8085D004, 1)) { + return; + } + + func_80832F78(this, &sp30, &sp2E, 0.0f, play); + if (this->linearVelocity != 0.0f) { + return; + } + + this->currentYaw = this->actor.shape.rot.y; + if (func_8083E514(this, &sp30, &sp2E, play) > 0) { + func_8083A794(this, play); + } else if ((sp30 != 0.0f) || animFinished) { + func_8083F230(this, play); + } +} + +void func_8084A884(Player* this, PlayState* play) { + s32 animFinished = PlayerAnimation_Update(play, &this->skelAnime); + + if (func_80833058(play, this, D_8085D004, 1)) { + return; + } + + if (animFinished) { + func_8083692C(this, play); + } +} + +void func_8084A8E8(Player* this, PlayState* play) { + f32 sp3C; + s16 sp3A; + s32 var_v0; + + func_8083F27C(play, this); + if (func_80833058(play, this, D_8085D00C, 1)) { + return; + } + + if (!func_8082FC24(this)) { + func_8083A794(this, play); + return; + } + + func_80832F78(this, &sp3C, &sp3A, 0.0f, play); + if (func_80123434(this)) { + var_v0 = func_8083E514(this, &sp3C, &sp3A, play); + } else { + var_v0 = func_8083E404(this, sp3C, sp3A); + } + + if (var_v0 > 0) { + func_8083A794(this, play); + } else if (var_v0 < 0) { + if (func_80123434(this)) { + func_8083AECC(this, sp3A, play); + } else { + func_8083AF8C(this, sp3A, play); + } + } else if ((this->linearVelocity < 3.6f) && (sp3C < 4.0f)) { + if ((func_80123420(this) == 0) && (func_80123434(this))) { + func_8083AF30(this, play); + } else { + func_80836988(this, play); + } + } else { + s16 temp_v0; + s32 var_v1; + s32 pad; + + func_8083E8E0(this, sp3C, sp3A); + + temp_v0 = sp3A - this->currentYaw; + var_v1 = ABS_ALT(temp_v0); + if (var_v1 > 0x4000) { + if (Math_StepToF(&this->linearVelocity, 0.0f, 3.0f)) { + this->currentYaw = sp3A; + } + } else { + sp3C = sp3C * 0.9f; + Math_AsymStepToF(&this->linearVelocity, sp3C, 2.0f, 3.0f); + Math_ScaledStepToS(&this->currentYaw, sp3A, var_v1 * 0.1f); + } + } +} + +void func_8084AB4C(Player* this, PlayState* play) { + f32 sp34; + s16 sp32; + + PlayerAnimation_Update(play, &this->skelAnime); + if (Player_IsHoldingTwoHandedWeapon(this)) { + AnimationContext_SetLoadFrame(play, func_8082ED20(this), 0, this->skelAnime.limbCount, + this->skelAnime.morphTable); + AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->skelAnime.morphTable, D_8085B9F0); + } + + func_80832F78(this, &sp34, &sp32, 0.018f, play); + if ((this != GET_PLAYER(play)) && (this->targetedActor == NULL)) { + sp32 = this->actor.home.rot.y; + } + + if (func_80833058(play, this, D_8085D018, 1)) { + return; + } + + if (sp34 != 0.0f) { + this->actor.shape.rot.y = sp32; + func_8083A794(this, play); + } else if (Math_ScaledStepToS(&this->actor.shape.rot.y, sp32, this->unk_B4E)) { + func_80839E74(this, play); + } + this->currentYaw = this->actor.shape.rot.y; +} + +void func_8084AC84(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_20; + + if (this->linearVelocity < 1.0f) { + this->skelAnime.animation = &gPlayerAnim_clink_normal_okarina_walk; + } else { + this->skelAnime.animation = &gPlayerAnim_clink_normal_okarina_walkB; + } + PlayerAnimation_Update(play, &this->skelAnime); + + if (!func_80847880(play, this) && + (!func_80833058(play, this, D_8085D01C, 1) || (func_8084AC84 == this->actionFunc))) { + f32 sp3C; + f32 temp_fv0; + f32 temp_fv1; + s16 sp32; + s16 sp30; + + if (!CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_B)) { + func_80839E74(this, play); + return; + } + + this->linearVelocity = this->unk_B48; + func_80832F78(this, &sp3C, &sp32, 0.018f, play); + sp30 = sp32; + + if (!func_8083A4A4(this, &sp3C, &sp32, REG(43) / 100.0f)) { + func_8083CB04(this, sp3C, sp32, REG(19) / 100.0f, 1.5f, 0x3E8); + func_8083C8E8(this, play); + if ((this->linearVelocity == 0.0f) && (sp3C == 0.0f)) { + this->currentYaw = sp30; + this->actor.shape.rot.y = this->currentYaw; + } + } + + this->unk_B48 = this->linearVelocity; + temp_fv0 = this->skelAnime.curFrame + 5.0f; + temp_fv1 = this->skelAnime.animLength / 2.0f; + + // effectively an fmodf + temp_fv0 -= temp_fv1 * (s32)(temp_fv0 / temp_fv1); + this->linearVelocity *= Math_CosS(temp_fv0 * 1000.0f) * 0.4f; + } +} + +void func_8084AEEC(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_20; + PlayerAnimation_Update(play, &this->skelAnime); + func_80832F24(this); + if (!func_80847880(play, this)) { + if (!func_80833058(play, this, D_8085D01C, 0) || (func_8084AEEC == this->actionFunc)) { + if (!CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_B)) { + func_80839E74(this, play); + } + } + } +} + +void func_8084AF9C(Player* this, PlayState* play) { + f32 sp2C; // player speed? + s16 sp2A; + + this->stateFlags2 |= PLAYER_STATE2_20; + func_8083F57C(this, play); + if (func_80833058(play, this, D_8085D028, 1)) { + return; + } + + if (func_8082FC24(this)) { + func_8083A794(this, play); + return; + } + + func_80832F78(this, &sp2C, &sp2A, 0.018f, play); + if (this->currentMask == PLAYER_MASK_BUNNY) { + sp2C *= 1.5f; + } + + if (!func_8083A4A4(this, &sp2C, &sp2A, REG(43) / 100.0f)) { + func_8083CB58(this, sp2C, sp2A); + func_8083C8E8(this, play); + if ((this->linearVelocity == 0.0f) && (sp2C == 0.0f)) { + func_80839E3C(this, play); + } + } +} + +void func_8084B0EC(Player* this, PlayState* play) { + f32 sp2C; + s16 sp2A; + + this->stateFlags2 |= PLAYER_STATE2_20; + + func_8083F57C(this, play); + if (func_80833058(play, this, D_8085D034, 1)) { + return; + } + + if (!func_8082FC24(this)) { + func_8083A794(this, play); + return; + } + + func_80832F78(this, &sp2C, &sp2A, 0.0f, play); + if (!func_8083A4A4(this, &sp2C, &sp2A, REG(43) / 100.0f)) { + if (((func_80123434(this) != 0) && (sp2C != 0) && (func_8083E514(this, &sp2C, &sp2A, play) <= 0)) || + (!func_80123434(this) && (func_8083E404(this, sp2C, sp2A) <= 0))) { + func_80836988(this, play); + } else { + func_8083CB58(this, sp2C, sp2A); + func_8083C8E8(this, play); + if ((this->linearVelocity == 0.0f) && (sp2C == 0.0f)) { + func_80836988(this, play); + } + } + } +} + +void func_8084B288(Player* this, PlayState* play) { + s32 animFinished = PlayerAnimation_Update(play, &this->skelAnime); + f32 sp30; + s16 sp2E; + + if (func_80833058(play, this, D_8085D00C, 1)) { + return; + } + + if (!func_8082FC24(this)) { + func_8083A794(this, play); + return; + } + + func_80832F78(this, &sp30, &sp2E, 0.0f, play); + if ((this->skelAnime.morphWeight == 0.0f) && (this->skelAnime.curFrame > 5.0f)) { + func_80832F24(this); + if ((this->skelAnime.curFrame > 10.0f) && (func_8083E404(this, sp30, sp2E) < 0)) { + func_8083AF8C(this, sp2E, play); + } else if (animFinished) { + func_8083B090(this, play); + } + } +} + +void func_8084B3B8(Player* this, PlayState* play) { + s32 animFinished = PlayerAnimation_Update(play, &this->skelAnime); + f32 sp30; + s16 sp2E; + + func_80832F24(this); + if (func_80833058(play, this, D_8085D044, 1)) { + return; + } + + func_80832F78(this, &sp30, &sp2E, 0.0f, play); + if (this->linearVelocity == 0.0f) { + this->currentYaw = this->actor.shape.rot.y; + if (func_8083E404(this, sp30, sp2E) > 0) { + func_8083A794(this, play); + } else if ((sp30 != 0.0f) || animFinished) { + func_80836988(this, play); + } + } +} + +void func_8084B4A8(Player* this, PlayState* play) { + if (this->skelAnime.animation == &gPlayerAnim_link_normal_backspace) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_8082E794(this); + func_8082E438(play, this, D_8085BE84[PLAYER_ANIMGROUP_31][this->modelAnimType]); + } + } else { + func_8082E67C(play, this, D_8085BE84[PLAYER_ANIMGROUP_32][this->modelAnimType]); + } + + if (DECR(this->unk_AE8) == 0) { + if (!func_80838A90(this, play)) { + func_80836A98(this, D_8085BE84[PLAYER_ANIMGROUP_33][this->modelAnimType], play); + } + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; + func_800E0238(Play_GetCamera(play, CAM_ID_MAIN)); + } +} + +// Player_Action_Shielding +void func_8084B5C0(Player* this, PlayState* play) { + func_80832F24(this); + + if (this->transformation == PLAYER_FORM_GORON) { + SkelAnime_Update(&this->unk_2C8); + + if (!func_8083FE38(this, play)) { + if (!func_8083A274(this, play)) { + this->stateFlags1 &= ~PLAYER_STATE1_400000; + + if (this->itemAction <= PLAYER_IA_MINUS1) { + func_80123C58(this); + } + + func_80836A98(this, D_8085BE84[PLAYER_ANIMGROUP_21][this->modelAnimType], play); + func_80830B38(this); + } else { + this->stateFlags1 |= PLAYER_STATE1_400000; + } + } + + return; + } + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + if (!Player_IsGoronOrDeku(this)) { + Player_AnimationPlayLoop(play, this, D_8085BE84[PLAYER_ANIMGROUP_20][this->modelAnimType]); + } + + this->unk_AE8 = 1; + this->unk_AE7 = 0; + } + + if (!Player_IsGoronOrDeku(this)) { + this->stateFlags1 |= PLAYER_STATE1_400000; + func_8083216C(this, play); + this->stateFlags1 &= ~PLAYER_STATE1_400000; + if (this->transformation == PLAYER_FORM_ZORA) { + func_8082F164(this, BTN_R | BTN_B); + } + } + + if (this->unk_AE8 != 0) { + f32 yStick = sPlayerControlInput->rel.stick_y * 180; + f32 xStick = sPlayerControlInput->rel.stick_x * -120; + s16 temp_a0 = this->actor.shape.rot.y - Camera_GetInputDirYaw(play->cameraPtrs[play->activeCamId]); + s16 var_a1; + s16 temp_ft5; + s16 var_a2; + s16 var_a3; + + var_a1 = (yStick * Math_CosS(temp_a0)) + (Math_SinS(temp_a0) * xStick); + temp_ft5 = (xStick * Math_CosS(temp_a0)) - (Math_SinS(temp_a0) * yStick); + + var_a1 = CLAMP_MAX(var_a1, 0xDAC); + var_a2 = ABS_ALT(var_a1 - this->actor.focus.rot.x) * 0.25f; + var_a2 = CLAMP_MIN(var_a2, 0x64); + + var_a3 = ABS_ALT(temp_ft5 - this->upperLimbRot.y) * 0.25f; + var_a3 = CLAMP_MIN(var_a3, 0x32); + Math_ScaledStepToS(&this->actor.focus.rot.x, var_a1, var_a2); + + this->upperLimbRot.x = this->actor.focus.rot.x; + Math_ScaledStepToS(&this->upperLimbRot.y, temp_ft5, var_a3); + + if (this->unk_AE7 != 0) { + if (!func_808401F4(play, this)) { + if (this->skelAnime.curFrame < 2.0f) { + func_8082FA5C(play, this, PLAYER_MELEE_WEAPON_STATE_1); + } + } else { + this->unk_AE8 = 1; + this->unk_AE7 = 0; + } + } else if (!func_8083FE38(this, play)) { + if (func_8083A274(this, play) != 0) { + func_8083FD80(this, play); + } else { + this->stateFlags1 &= ~PLAYER_STATE1_400000; + func_8082DC38(this); + + if (Player_IsGoronOrDeku(this)) { + func_80836A5C(this, play); + PlayerAnimation_Change(play, &this->skelAnime, this->skelAnime.animation, 1.0f, + Animation_GetLastFrame(this->skelAnime.animation), 0.0f, 2, 0.0f); + } else { + if (this->itemAction <= PLAYER_IA_MINUS1) { + func_80123C58(this); + } + + func_80836A98(this, D_8085BE84[PLAYER_ANIMGROUP_21][this->modelAnimType], play); + } + + Player_PlaySfx(this, NA_SE_IT_SHIELD_REMOVE); + return; + } + } else { + return; + } + } + + this->stateFlags1 |= PLAYER_STATE1_400000; + Player_SetModelsForHoldingShield(this); + this->unk_AA6 |= 0xC1; +} + +void func_8084BAA4(Player* this, PlayState* play) { + func_80832F24(this); + if (this->unk_AE7 == 0) { + D_80862B04 = func_8083216C(this, play); + if ((func_8084894C == this->unk_AC4) || (func_808331FC(play, this, &this->unk_284, 4.0f) > 0)) { + Player_SetAction(play, this, func_80849A9C, 1); + } + } else { + s32 temp_v0; + + this->stateFlags1 |= PLAYER_STATE1_400000; + temp_v0 = func_808331FC(play, this, &this->skelAnime, 4.0f); + if ((temp_v0 != 0) && ((temp_v0 > 0) || PlayerAnimation_Update(play, &this->skelAnime))) { + PlayerAnimationHeader* anim; + f32 lastFrame; + + Player_SetAction(play, this, func_8084B5C0, 1); + Player_SetModelsForHoldingShield(this); + anim = D_8085BE84[PLAYER_ANIMGROUP_19][this->modelAnimType]; + lastFrame = Animation_GetLastFrame(anim); + PlayerAnimation_Change(play, &this->skelAnime, anim, 1.0f, lastFrame, lastFrame, ANIMMODE_ONCE, 0.0f); + } + } +} + +void func_8084BBF0(Player* this, PlayState* play) { + s32 temp_v0; + + func_80832F24(this); + temp_v0 = func_808331FC(play, this, &this->skelAnime, 16.0f); + if (temp_v0 != 0) { + if (PlayerAnimation_Update(play, &this->skelAnime) || (temp_v0 > 0)) { + func_80836988(this, play); + } + } +} + +void func_8084BC64(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_20 | PLAYER_STATE2_40; + func_808345A8(this); + + if (!(this->stateFlags1 & PLAYER_STATE1_20000000) && (this->unk_AE8 == 0) && (this->unk_B75 != 0)) { + s16 temp_v0 = this->unk_B76; + s16 temp_v1 = this->actor.shape.rot.y - temp_v0; + + this->actor.shape.rot.y = temp_v0; + this->currentYaw = temp_v0; + this->linearVelocity = this->unk_B78; + + if (ABS_ALT(temp_v1) > 0x4000) { + this->actor.shape.rot.y = temp_v0 + 0x8000; + } + + if (this->actor.velocity.y < 0.0f) { + this->actor.gravity = 0.0f; + this->actor.velocity.y = 0.0f; + } + } + + if (PlayerAnimation_Update(play, &this->skelAnime) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + if (this->unk_AE8 != 0) { + this->unk_AE8--; + if (this->unk_AE8 == 0) { + func_8085B384(this, play); + } + } else if ((this->stateFlags1 & PLAYER_STATE1_20000000) || + (!(this->cylinder.base.acFlags & AC_HIT) && (this->unk_B75 == 0))) { + if (this->stateFlags1 & PLAYER_STATE1_20000000) { + this->unk_AE8++; + } else { + Player_SetAction(play, this, func_8084BE40, 0); + this->stateFlags1 |= PLAYER_STATE1_4000000; + } + + Player_AnimationPlayOnce(play, this, + (this->currentYaw != this->actor.shape.rot.y) + ? &gPlayerAnim_link_normal_front_downB + : &gPlayerAnim_link_normal_back_downB); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_FREEZE); + } + } + + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + Player_AnimSfx_PlayFloor(this, NA_SE_PL_BOUND); + } +} + +void func_8084BE40(Player* this, PlayState* play) { + this->stateFlags2 |= (PLAYER_STATE2_20 | PLAYER_STATE2_40); + func_808345A8(this); + func_80832F24(this); + if (PlayerAnimation_Update(play, &this->skelAnime) && (this->linearVelocity == 0.0f)) { + if (this->stateFlags1 & PLAYER_STATE1_20000000) { + this->unk_AE8++; + } else { + Player_SetAction(play, this, func_8084BF28, 0); + this->stateFlags1 |= PLAYER_STATE1_4000000; + } + + func_8082DB90(play, this, + (this->currentYaw != this->actor.shape.rot.y) ? &gPlayerAnim_link_normal_front_down_wake + : &gPlayerAnim_link_normal_back_down_wake); + this->currentYaw = this->actor.shape.rot.y; + } +} + +AnimSfxEntry D_8085D604[] = { + ANIMSFX(ANIMSFX_TYPE_8, 20, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_8, 30, NA_SE_NONE, STOP), +}; + +void func_8084BF28(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_20; + + func_808345A8(this); + if (this->stateFlags1 & PLAYER_STATE1_20000000) { + PlayerAnimation_Update(play, &this->skelAnime); + } else { + s32 temp_v0 = func_808331FC(play, this, &this->skelAnime, 16.0f); + + if (temp_v0 != 0) { + if (PlayerAnimation_Update(play, &this->skelAnime) || (temp_v0 > 0)) { + func_80836988(this, play); + } + } + } + + Player_PlayAnimSfx(this, D_8085D604); +} + +AnimSfxEntry D_8085D60C[] = { + ANIMSFX(ANIMSFX_TYPE_FLOOR, 60, NA_SE_PL_BOUND, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_8, 140, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_8, 164, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_8, 170, NA_SE_NONE, STOP), +}; + +void func_8084BFDC(Player* this, PlayState* play) { + if ((this->transformation != PLAYER_FORM_GORON) && (this->actor.depthInWater <= 0.0f)) { + if ((play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_HOT) || + (sPlayerCurrentFloorType == FLOOR_TYPE_9) || + ((func_808340AC(sPlayerCurrentFloorType) >= 0) && + !SurfaceType_IsWallDamage(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { + func_808344C0(play, this); + } + } + + func_80832F24(this); + if (PlayerAnimation_Update(play, &this->skelAnime)) { + if (this == GET_PLAYER(play)) { + func_80840770(play, this); + } + } else if (this->skelAnime.animation == &gPlayerAnim_link_derth_rebirth) { + Player_PlayAnimSfx(this, D_8085D60C); + } else if ((this->skelAnime.animation == &gPlayerAnim_link_normal_electric_shock_end) && + PlayerAnimation_OnFrame(&this->skelAnime, 88.0f)) { + Player_AnimSfx_PlayFloor(this, NA_SE_PL_BOUND); + } +} + +s32 func_8084C124(PlayState* play, Player* this) { + if (func_80837730(play, this, 3.0f, 500)) { + Player_PlaySfx(this, NA_SE_EV_DIVE_INTO_WATER); + return true; + } + return false; +} + +void func_8084C16C(Player* this, PlayState* play) { + f32 sp44; + s16 sp42; + Actor* heldActor; + + if (func_80123420(this) != 0) { + this->actor.gravity = -1.2f; + } + + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + func_80832F78(this, &sp44, &sp42, 0.0f, play); + if (this->stateFlags1 & PLAYER_STATE1_800) { + heldActor = this->heldActor; + if (!func_808313A8(play, this, heldActor) && (heldActor->id == ACTOR_EN_NIW) && + CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_B | BTN_A)) { + func_808409A8(play, this, this->linearVelocity + 2.0f, this->actor.velocity.y + 2.0f); + } + } + + PlayerAnimation_Update(play, &this->skelAnime); + if ((this->skelAnime.animation == &gPlayerAnim_link_normal_newroll_jump_20f) && + PlayerAnimation_OnFrame(&this->skelAnime, 4.0f)) { + Player_PlaySfx(this, NA_SE_PL_ROLL); + } + + if (this->transformation == PLAYER_FORM_DEKU) { + s16 prevYaw = this->currentYaw; + + func_808378FC(play, this); + func_8083CBC4(this, sp44 * 0.5f, sp42, 2.0f, 0.2f, 0.1f, 0x190); + + if (this->skelAnime.animation == &gPlayerAnim_pn_attack) { + this->stateFlags2 |= (PLAYER_STATE2_20 | PLAYER_STATE2_40); + + this->unk_B10[0] += -800.0f; + this->actor.shape.rot.y += BINANG_ADD((s16)this->unk_B10[0], BINANG_SUB(this->currentYaw, prevYaw)); + Math_StepToF(&this->unk_B10[1], 0.0f, this->unk_B10[0]); + } + } else { + func_8083CBC4(this, sp44, sp42, 1.0f, 0.05f, 0.1f, 0xC8); + } + + func_8083216C(this, play); + if ((((this->stateFlags2 & PLAYER_STATE2_80000) && ((this->unk_AE7 == 2) || (this->unk_AE7 >= 4))) || + !func_80839770(this, play)) && + (this->actor.velocity.y < 0.0f)) { + if (this->unk_AE8 >= 0) { + if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) || (this->unk_AE8 == 0) || (this->fallDistance > 0)) { + if ((D_80862B18 > 800.0f) || (this->stateFlags3 & PLAYER_STATE3_10000)) { + func_80840980(this, NA_SE_VO_LI_FALL_S); + this->stateFlags3 &= ~PLAYER_STATE3_10000; + } + PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_normal_landing, 1.0f, 0.0f, 0.0f, + ANIMMODE_ONCE, 8.0f); + this->unk_AE8 = -1; + } + } else { + if ((this->unk_AE8 == -1) && (this->fallDistance > 120) && (D_80862B18 > 280.0f)) { + this->unk_AE8 = -2; + func_80840980(this, NA_SE_VO_LI_FALL_L); + } + + if ((this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && + !(this->stateFlags1 & (PLAYER_STATE1_800 | PLAYER_STATE1_8000000)) && + (this->linearVelocity > 0.0f)) { + if ((this->transformation != PLAYER_FORM_GORON) && + ((this->transformation != PLAYER_FORM_DEKU) || (this->remainingHopsCounter != 0))) { + if ((this->wallHeight >= 150.0f) && (this->unk_AE3[this->unk_ADE] == 0)) { + if (func_8083D860(this, play)) { + func_8084C124(play, this); + } + } else if ((this->unk_B5C >= 2) && + ((this->wallHeight < (150.0f * this->ageProperties->unk_08)) && + (((this->actor.world.pos.y - this->actor.floorHeight) + this->wallHeight)) > + (70.0f * this->ageProperties->unk_08))) { + AnimationContext_DisableQueue(play); + if (this->stateFlags3 & PLAYER_STATE3_10000) { + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_HOOKSHOT_HANG); + } else { + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_HANG); + } + + this->actor.world.pos.y += this->wallHeight; + func_80837CEC(play, this, this->actor.wallPoly, this->wallDistance, + GET_PLAYER_ANIM(PLAYER_ANIMGROUP_38, this->modelAnimType)); + this->currentYaw += 0x8000; + this->actor.shape.rot.y = this->currentYaw; + this->stateFlags1 |= PLAYER_STATE1_2000; + + func_8084C124(play, this); + } + } + } + } + } + } else { + func_80837134(play, this); + func_8083216C(this, play); + } + + func_80838A90(this, play); +} + +// sPlayerRollingAnimSfx +AnimSfxEntry D_8085D61C[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 1, NA_SE_VO_LI_SWORD_N, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR_BY_AGE, 6, NA_SE_PL_WALK_GROUND, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 6, NA_SE_PL_ROLL, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR_LAND, 18, NA_SE_NONE, STOP), +}; + +// Player_Action_Rolling // Handles bonking too? +void func_8084C6EC(Player* this, PlayState* play) { + s32 animFinished; + + this->stateFlags2 |= PLAYER_STATE2_20; + this->stateFlags3 |= PLAYER_STATE3_8000000; + + animFinished = PlayerAnimation_Update(play, &this->skelAnime); + if (PlayerAnimation_OnFrame(&this->skelAnime, 8.0f)) { + func_808339B4(this, -10); + } + + if (this->skelAnime.curFrame >= 8.0f) { + if (this->skelAnime.curFrame < 18.0f) { + Player_SetCylinderForAttack(this, DMG_NORMAL_ROLL, 1, 12); + } else { + Player_ResetCylinder(this); + } + } + + if (func_8083FE38(this, play)) { + return; + } + + if (this->unk_AE8 != 0) { + s32 temp_v0; + + Math_StepToF(&this->linearVelocity, 0.0f, 2.0f); + temp_v0 = func_808331FC(play, this, &this->skelAnime, 5.0f); + if (temp_v0 != 0) { + if ((temp_v0 > 0) || animFinished) { + func_80836A5C(this, play); + } + } + } else if (!func_80840A30(play, this, &this->linearVelocity, 6.0f)) { + if ((this->skelAnime.curFrame < 15.0f) || !func_80848570(this, play)) { + f32 sp3C; + s16 yaw; + + if (this->skelAnime.curFrame >= 20.0f) { + func_80836A5C(this, play); + return; + } + + func_80832F78(this, &sp3C, &yaw, 0.018f, play); + sp3C *= 1.5f; + if ((sp3C < 3.0f) || (this->unk_AE3[this->unk_ADE] != 0)) { + sp3C = 3.0f; + } + func_8083CB58(this, sp3C, this->actor.shape.rot.y); + + if (func_8083FBC4(play, this)) { + func_800B8F98(&this->actor, (this->floorSfxOffset == NA_SE_PL_WALK_SNOW - SFX_FLAG) + ? NA_SE_PL_ROLL_SNOW_DUST - SFX_FLAG + : NA_SE_PL_ROLL_DUST - SFX_FLAG); + } + + Player_PlayAnimSfx(this, D_8085D61C); + } + } +} + +void func_8084C94C(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_20; + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + Player_AnimationPlayLoop(play, this, &gPlayerAnim_link_normal_run_jump_water_fall_wait); + } + + Math_StepToF(&this->linearVelocity, 0.0f, 0.05f); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + if (this->fallDistance >= 400) { + this->actor.colChkInfo.damage = 0x10; + func_80833B18(play, this, 1, 4.0f, 5.0f, this->actor.shape.rot.y, 20); + } else { + func_80836B3C(play, this, 4.0f); + } + } +} + +void func_8084CA24(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_20; + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_8082DB60(play, this, &gPlayerAnim_pz_fishswim); + } + + Math_SmoothStepToS(&this->unk_B86[1], 0, 6, 0x7D0, 0x190); + if (!func_80840A30(play, this, &this->linearVelocity, 0.0f)) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + if (this->unk_AAA > 0x36B0) { + this->actor.colChkInfo.damage = 0x10; + func_80833B18(play, this, 1, 4.0f, 5.0f, this->actor.shape.rot.y, 20); + } else { + func_80836B3C(play, this, 4.0f); + } + } else { + this->actor.gravity = -1.0f; + this->unk_AAA = Math_Atan2S_XY(this->actor.speed, -this->actor.velocity.y); + func_8082F164(this, BTN_R); + } + } +} + +void func_8084CB58(Player* this, PlayState* play) { + AttackAnimInfo* attackInfoEntry = &sMeleeAttackAnimInfo[this->meleeWeaponAnimation]; + f32 sp38; + s16 sp36; + + this->stateFlags2 |= PLAYER_STATE2_20; + + if (this->transformation == PLAYER_FORM_ZORA) { + this->actor.gravity = -0.8f; + } else { + this->actor.gravity = -1.2f; + } + + PlayerAnimation_Update(play, &this->skelAnime); + + if (!func_808401F4(play, this)) { + func_8083FCF0(play, this, 6.0f, attackInfoEntry->unk_C, attackInfoEntry->unk_D); + if (!(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + func_80832F78(this, &sp38, &sp36, 0.0f, play); + func_8083CBC4(this, sp38, this->currentYaw, 1.0f, 0.05f, 0.1f, 200); + } else if (func_80836F10(play, this) >= 0) { // Player didn't die because of this fall + this->meleeWeaponAnimation += 3; + func_80833864(play, this, this->meleeWeaponAnimation); + this->unk_ADD = 3; + this->meleeWeaponState = PLAYER_MELEE_WEAPON_STATE_0; + Player_AnimSfx_PlayFloorLand(this); + } + } +} + +void func_8084CCEC(Player* this, PlayState* play) { + f32 sp34; + s16 sp32; + s32 temp_v0; + + this->stateFlags1 |= PLAYER_STATE1_1000; + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_8082E794(this); + func_8083133C(this); + this->stateFlags1 &= ~PLAYER_STATE1_20000; + Player_AnimationPlayLoop(play, this, D_8085CF60[Player_IsHoldingTwoHandedWeapon(this)]); + this->unk_AE8 = -1; + } + + func_80832F24(this); + if (!func_8083FE38(this, play) && (this->unk_AE8 != 0)) { + func_80840F34(this); + if (this->unk_AE8 < 0) { + if (this->unk_B08 >= 0.1f) { + this->unk_ADD = 0; + this->unk_AE8 = 1; + } else if (!CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_B)) { + func_80840E5C(this, play); + } + } else if (!func_80840CD4(this, play)) { + func_80832F78(this, &sp34, &sp32, 0.0f, play); + temp_v0 = func_8083E7F8(this, &sp34, &sp32, play); + if (temp_v0 > 0) { + func_80840DEC(this, play); + } else if (temp_v0 < 0) { + func_80840E24(this, play); + } + } + } +} + +void func_8084CE84(Player* this, PlayState* play) { + s32 var_v1; + s32 temp_v0_2; + f32 temp_ft4; + f32 var_fa0; + f32 sp54; + s16 sp52; + s16 temp_v0; + f32 temp_fv1; + s32 pad; + s32 sp44; + + temp_v0 = this->currentYaw - this->actor.shape.rot.y; + var_v1 = ABS_ALT(temp_v0); + + temp_ft4 = fabsf(this->linearVelocity); + this->stateFlags1 |= PLAYER_STATE1_1000; + + var_fa0 = temp_ft4 * 1.5f; + var_fa0 = CLAMP_MIN(var_fa0, 1.5f); + + var_fa0 = ((var_v1 < 0x4000) ? -1.0f : 1.0f) * var_fa0; + + func_8083EA44(this, var_fa0); + + var_fa0 = CLAMP(temp_ft4 * 0.5f, 0.5f, 1.0f); + + PlayerAnimation_BlendToJoint(play, &this->skelAnime, D_8085CF60[Player_IsHoldingTwoHandedWeapon(this)], 0.0f, + D_8085CF70[Player_IsHoldingTwoHandedWeapon(this)], this->unk_B38 * 0.7241379f, var_fa0, + this->blendTableBuffer); + if (!func_8083FE38(this, play) && !func_80840CD4(this, play)) { + func_80840F34(this); + func_80832F78(this, &sp54, &sp52, 0.0f, play); + + temp_v0_2 = func_8083E7F8(this, &sp54, &sp52, play); + if (temp_v0_2 < 0) { + func_80840E24(this, play); + return; + } + + if (temp_v0_2 == 0) { + sp54 = 0.0f; + sp52 = this->currentYaw; + } + + sp44 = ABS_ALT(BINANG_SUB(sp52, this->currentYaw)); + if (sp44 > 0x4000) { + if (Math_StepToF(&this->linearVelocity, 0.0f, 1.0f)) { + this->currentYaw = sp52; + } + } else { + Math_AsymStepToF(&this->linearVelocity, sp54 * 0.2f, 1.0f, 0.5f); + Math_ScaledStepToS(&this->currentYaw, sp52, sp44 * 0.1f); + if ((sp54 == 0.0f) && (this->linearVelocity == 0.0f)) { + func_80840EC0(this, play); + } + } + } +} + +void func_8084D18C(Player* this, PlayState* play) { + f32 sp5C = fabsf(this->linearVelocity); + f32 var_fa0; + + this->stateFlags1 |= PLAYER_STATE1_1000; + + if (sp5C == 0.0f) { + sp5C = ABS_ALT(this->unk_B4C) * 0.0015f; + if (sp5C < 400.0f) { + sp5C = 0.0f; + } + + func_8083EA44(this, ((this->unk_B4C >= 0) ? 1 : -1) * sp5C); + } else { + var_fa0 = sp5C * 1.5f; + var_fa0 = CLAMP_MIN(var_fa0, 1.5f); + func_8083EA44(this, var_fa0); + } + + var_fa0 = CLAMP(sp5C * 0.5f, 0.5f, 1.0f); + + PlayerAnimation_BlendToJoint(play, &this->skelAnime, D_8085CF60[Player_IsHoldingTwoHandedWeapon(this)], 0.0f, + D_8085CF78[Player_IsHoldingTwoHandedWeapon(this)], this->unk_B38 * 0.7241379f, var_fa0, + this->blendTableBuffer); + if (!func_8083FE38(this, play) && !func_80840CD4(this, play)) { + f32 sp54; + s16 sp52; + s32 temp_v0; + s16 temp_v0_2; + s32 var_v1; + + func_80840F34(this); + func_80832F78(this, &sp54, &sp52, 0.0f, play); + temp_v0 = func_8083E7F8(this, &sp54, &sp52, play); + if (temp_v0 > 0) { + func_80840DEC(this, play); + return; + } + + if (temp_v0 == 0) { + sp54 = 0.0f; + sp52 = this->currentYaw; + } + + var_v1 = ABS_ALT(BINANG_SUB(sp52, this->currentYaw)); + if (var_v1 > 0x4000) { + if (Math_StepToF(&this->linearVelocity, 0.0f, 1.0f)) { + this->currentYaw = sp52; + } + } else { + Math_AsymStepToF(&this->linearVelocity, sp54 * 0.2f, 1.0f, 0.5f); + Math_ScaledStepToS(&this->currentYaw, sp52, var_v1 * 0.1f); + if ((sp54 == 0.0f) && (this->linearVelocity == 0.0f) && (sp5C == 0.0f)) { + func_80840EC0(this, play); + } + } + } +} + +void func_8084D4EC(Player* this, PlayState* play) { + s32 animFinished; + f32 frame; + s32 temp_v0; + + this->stateFlags2 |= PLAYER_STATE2_20; + animFinished = PlayerAnimation_Update(play, &this->skelAnime); + + if (this->skelAnime.animation == &gPlayerAnim_link_normal_250jump_start) { + this->linearVelocity = 1.0f; + if (PlayerAnimation_OnFrame(&this->skelAnime, 8.0f)) { + f32 speed = this->wallHeight; + + speed = CLAMP_MAX(speed, this->ageProperties->unk_0C); + if (this->stateFlags1 & PLAYER_STATE1_8000000) { + speed *= 0.085f; + } else { + speed *= 0.072f; + } + + if (this->transformation == PLAYER_FORM_HUMAN) { + speed += 1.0f; + } + + func_80834D50(play, this, NULL, speed, NA_SE_VO_LI_AUTO_JUMP); + this->unk_AE8 = -1; + } + } else { + temp_v0 = func_808331FC(play, this, &this->skelAnime, 4.0f); + if (temp_v0 == 0) { + this->stateFlags1 &= ~(PLAYER_STATE1_4 | PLAYER_STATE1_4000 | PLAYER_STATE1_40000); + return; + } + if (animFinished || (temp_v0 > 0)) { + func_80839E74(this, play); + this->stateFlags1 &= ~(PLAYER_STATE1_4 | PLAYER_STATE1_4000 | PLAYER_STATE1_40000); + this->unk_ABC = 0.0f; + return; + } + + frame = 0.0f; + if (this->skelAnime.animation == &gPlayerAnim_link_swimer_swim_15step_up) { + if (PlayerAnimation_OnFrame(&this->skelAnime, 30.0f)) { + func_8083B32C(play, this, 10.0f); + } + frame = 50.0f; + } else if (this->skelAnime.animation == &gPlayerAnim_link_normal_150step_up) { + frame = 30.0f; + } else if (this->skelAnime.animation == &gPlayerAnim_link_normal_100step_up) { + frame = 16.0f; + } + + if (PlayerAnimation_OnFrame(&this->skelAnime, frame)) { + Player_AnimSfx_PlayFloorLand(this); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_CLIMB_END); + } + + if ((this->skelAnime.animation == &gPlayerAnim_link_normal_100step_up) || (this->skelAnime.curFrame > 5.0f)) { + if (this->unk_AE8 == 0) { + Player_AnimSfx_PlayFloorJump(this); + this->unk_AE8 = 1; + } + Math_SmoothStepToF(&this->unk_ABC, 0.0f, 0.1f, 400.0f, 150.0f); + } + } +} + +void func_8084D770(Player* this, PlayState* play) { + s32 temp_v0; + + this->stateFlags2 |= (PLAYER_STATE2_20 | PLAYER_STATE2_40); + if (this->unk_D58 == func_80837BF8) { + this->stateFlags2 |= PLAYER_STATE2_1; + } + + PlayerAnimation_Update(play, &this->skelAnime); + func_8083249C(this); + + temp_v0 = func_8083216C(this, play); + if (((this->stateFlags1 & PLAYER_STATE1_800) && (this->heldActor != NULL) && (this->getItemId == GI_NONE)) || + (temp_v0 == 0)) { + this->unk_D58(play, this); + } +} + +void func_8084D820(Player* this, PlayState* play) { + if (func_80838A90(this, play) == 0) { + if ((this->stateFlags3 & PLAYER_STATE3_10) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + func_80833AA0(this, play); + this->stateFlags1 |= PLAYER_STATE1_20000000; + } else if (this->unk_AE8 == 0) { + PlayerAnimation_Update(play, &this->skelAnime); + if (DECR(this->doorTimer) == 0) { + this->linearVelocity = 0.1f; + this->unk_AE8 = 1; + } + } else if (this->unk_AE7 == 0) { + f32 sp6C = 5.0f * D_8085C3E4; + s32 var_t0 = func_808411D4(play, this, &sp6C, -1); + + if (this->unk_397 == 4) { + if (R_PLAY_FILL_SCREEN_ON < 0) { + if (play->roomCtx.status != 1) { + R_PLAY_FILL_SCREEN_ALPHA += R_PLAY_FILL_SCREEN_ON; + if (R_PLAY_FILL_SCREEN_ALPHA < 0) { + R_PLAY_FILL_SCREEN_ALPHA = 0; + } + + this->actor.world.pos.y += (this->doorDirection != 0) ? 3.0f : -3.0f; + this->actor.prevPos.y = this->actor.world.pos.y; + } + } else if (R_PLAY_FILL_SCREEN_ON == 0) { + CollisionPoly* sp64; + s32 sp60; + + if (func_80835DF8(play, this, &sp64, &sp60)) { + this->actor.floorPoly = sp64; + this->actor.floorBgId = sp60; + } + } + } + + if (var_t0 < 0x1E) { + this->unk_AE7 = 1; + this->stateFlags1 |= PLAYER_STATE1_20000000; + this->unk_3A0.x = this->unk_3AC.x; + this->unk_3A0.z = this->unk_3AC.z; + } + } else { + f32 sp5C = 5.0f; + s32 sp58 = 0x14; + s32 temp_v0_8; + + if (this->stateFlags1 & PLAYER_STATE1_1) { + sp5C = gSaveContext.entranceSpeed; + if (sPlayerConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) { + this->unk_3A0.x = (Math_SinS(D_80862B16) * 400.0f) + this->actor.world.pos.x; + this->unk_3A0.z = (Math_CosS(D_80862B16) * 400.0f) + this->actor.world.pos.z; + } + } else { + if (this->unk_AE8 < 0) { + this->unk_AE8++; + sp5C = gSaveContext.entranceSpeed; + sp58 = -1; + } else if (this->unk_397 == 4) { + if (R_PLAY_FILL_SCREEN_ON == 0) { + R_PLAY_FILL_SCREEN_ON = 16; + R_PLAY_FILL_SCREEN_ALPHA = 0; + + R_PLAY_FILL_SCREEN_R = R_PLAY_FILL_SCREEN_G = R_PLAY_FILL_SCREEN_B = R_PLAY_FILL_SCREEN_ALPHA; + } else if (R_PLAY_FILL_SCREEN_ON >= 0) { + R_PLAY_FILL_SCREEN_ALPHA += R_PLAY_FILL_SCREEN_ON; + if (R_PLAY_FILL_SCREEN_ALPHA > 255) { + TransitionActorEntry* temp_v1_4; // sp50 + s32 roomNum; + + temp_v1_4 = &play->doorCtx.transitionActorList[this->doorNext]; + roomNum = temp_v1_4->sides[0].room; + R_PLAY_FILL_SCREEN_ALPHA = 255; + + if ((roomNum != play->roomCtx.curRoom.num) && (play->roomCtx.curRoom.num >= 0)) { + play->roomCtx.prevRoom = play->roomCtx.curRoom; + + play->roomCtx.curRoom.num = -1; + play->roomCtx.curRoom.segment = NULL; + func_8012EBF8(play, &play->roomCtx); + } else { + static Vec3f D_8085D62C = { 0.0f, 0.0f, 0.0f }; + static Vec3f D_8085D638 = { 0.0f, 0.0f, 0.0f }; + static Vec3f D_8085D644 = { 0.0f, 0.0f, 0.0f }; + + R_PLAY_FILL_SCREEN_ON = -16; + if (play->roomCtx.curRoom.num < 0) { + Room_StartRoomTransition(play, &play->roomCtx, temp_v1_4->sides[0].room); + play->roomCtx.prevRoom.num = -1; + play->roomCtx.prevRoom.segment = NULL; + } + + this->actor.world.pos.x = temp_v1_4->pos.x; + this->actor.world.pos.y = temp_v1_4->pos.y; + this->actor.world.pos.z = temp_v1_4->pos.z; + + this->actor.shape.rot.y = ((((temp_v1_4->rotY >> 7) & 0x1FF) / 180.0f) * 0x8000); + + D_8085D62C.x = (this->doorDirection != 0) ? -120.0f : 120.0f; + D_8085D62C.y = (this->doorDirection != 0) ? -75.0f : 75.0f; + D_8085D62C.z = -240.0f; + if (this->doorDirection != 0) { + Camera_ChangeDoorCam(play->cameraPtrs[0], &this->actor, -2, 0.0f, + temp_v1_4->pos.x + 0x32, temp_v1_4->pos.y + 0x5F, + temp_v1_4->pos.z - 0x32); + } else { + Camera_ChangeDoorCam(play->cameraPtrs[0], &this->actor, -2, 0.0f, + temp_v1_4->pos.x - 0x32, temp_v1_4->pos.y + 5, + temp_v1_4->pos.z - 0x32); + } + + Player_TranslateAndRotateY(this, &this->actor.world.pos, &D_8085D62C, + &this->actor.world.pos); + + D_8085D638.x = (this->doorDirection != 0) ? 130.0f : -130.0f; + D_8085D638.z = 160.0f; + Player_TranslateAndRotateY(this, &this->actor.world.pos, &D_8085D638, &this->unk_3A0); + D_8085D644.z = 160.0f; + Player_TranslateAndRotateY(this, &this->unk_3A0, &D_8085D644, &this->unk_3AC); + + this->actor.shape.rot.y += (this->doorDirection != 0) ? 0x4000 : -0x4000; + this->unk_AE7 = 0; + + this->actor.world.rot.y = this->currentYaw = this->actor.shape.rot.y; + } + } + + this->actor.world.pos.y += (this->doorDirection != 0) ? 3.0f : -3.0f; + this->actor.prevPos.y = this->actor.world.pos.y; + } + } + } + + temp_v0_8 = func_808411D4(play, this, &sp5C, sp58); + if ((this->unk_AE8 == 0) || ((temp_v0_8 == 0) && (this->linearVelocity == 0.0f) && + (Play_GetCamera(play, CAM_ID_MAIN)->stateFlags & CAM_STATE_4))) { + if (this->unk_397 == 4) { + Map_InitRoomData(play, play->roomCtx.curRoom.num); + Minimap_SavePlayerRoomInitInfo(play); + } + + R_PLAY_FILL_SCREEN_ON = 0; + func_800E0238(Play_GetCamera(play, CAM_ID_MAIN)); + Player_StopCutscene(this); + if (!(this->stateFlags3 & PLAYER_STATE3_20000)) { + func_801226E0(play, ((void)0, gSaveContext.respawn[RESPAWN_MODE_DOWN].data)); + } + + if (play->unk_1887C != 0) { + play->func_18780(this, play); + Player_SetAction(play, this, func_80854430, 0); + if (play->sceneId == 0x45) { + play->unk_1887C = 0; + } + } else if (!func_808391D8(this, play)) { + func_8083B2E4(this, play); + } + } + } + } + + if (this->stateFlags1 & PLAYER_STATE1_800) { + func_8083216C(this, play); + } +} + +// door stuff +void func_8084E034(Player* this, PlayState* play) { + EnDoor* doorActor = (EnDoor*)this->doorActor; + s32 sp38 = (doorActor != NULL) && (doorActor->doorType == ENDOOR_TYPE_7); + s32 animFinished; + CollisionPoly* poly; + s32 bgId; + + this->stateFlags2 |= PLAYER_STATE2_20; + + if (DECR(this->unk_AE7) == 0) { + func_80835DF8(play, this, &poly, &bgId); + } + + animFinished = PlayerAnimation_Update(play, &this->skelAnime); + func_8083216C(this, play); + + if (animFinished) { + if (this->unk_AE8 == 0) { + if (DECR(this->doorTimer) == 0) { + this->unk_AE8 = 1; + this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; + } + } else { + Player_StopCutscene(this); + func_80839E74(this, play); + + if ((this->actor.category == ACTORCAT_PLAYER) && !sp38) { + if (play->roomCtx.prevRoom.num >= 0) { + func_8012EBF8(play, &play->roomCtx); + } + + func_800E0238(Play_GetCamera(play, CAM_ID_MAIN)); + Play_SetupRespawnPoint(&play->state, RESPAWN_MODE_DOWN, PLAYER_PARAMS(0xFF, PLAYER_INITMODE_B)); + } + } + } else if (!(this->stateFlags1 & PLAYER_STATE1_20000000) && PlayerAnimation_OnFrame(&this->skelAnime, 15.0f)) { + Player_StopCutscene(this); + play->func_18780(this, play); + } else if (sp38 && PlayerAnimation_OnFrame(&this->skelAnime, 15.0f)) { + s16 doorRot = (this->doorDirection < 0) ? doorActor->knobDoor.dyna.actor.world.rot.x + : doorActor->knobDoor.dyna.actor.world.rot.z; + + if (doorRot != 0) { + func_808354A4(play, doorRot - 1, false); + } + } +} + +// grab/hold an actor (?) +void func_8084E25C(Player* this, PlayState* play) { + func_80832F24(this); + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_80836988(this, play); + func_808313F0(this, play); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 4.0f)) { + Actor* interactRangeActor = this->interactRangeActor; + + if (!func_808313A8(play, this, interactRangeActor)) { + this->actor.child = interactRangeActor; + this->heldActor = interactRangeActor; + interactRangeActor->parent = &this->actor; + interactRangeActor->bgCheckFlags &= + ~(BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_GROUND_LEAVE | BGCHECKFLAG_WALL | + BGCHECKFLAG_CEILING | BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH | BGCHECKFLAG_GROUND_STRICT); + this->leftHandWorld.rot.y = interactRangeActor->shape.rot.y - this->actor.shape.rot.y; + } + } else { + Math_ScaledStepToS(&this->leftHandWorld.rot.y, 0, 0xFA0); + } +} + +// grab/hold an actor (?) +void func_8084E334(Player* this, PlayState* play) { + func_80832F24(this); + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + Player_AnimationPlayLoop(play, this, &gPlayerAnim_link_silver_wait); + this->unk_AE8 = 1; + } else if (this->unk_AE8 == 0) { + if (PlayerAnimation_OnFrame(&this->skelAnime, 27.0f)) { + Actor* interactRangeActor = this->interactRangeActor; + + this->heldActor = interactRangeActor; + this->actor.child = interactRangeActor; + interactRangeActor->parent = &this->actor; + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 25.0f)) { + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_SWORD_L); + } + } else if (CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_B | BTN_A)) { + Player_SetAction(play, this, func_8084E434, 1); + Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_silver_throw); + } +} + +// throw held actor (?) +void func_8084E434(Player* this, PlayState* play) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_80836988(this, play); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 6.0f)) { + Actor* heldActor = this->heldActor; + + heldActor->world.rot.y = this->actor.shape.rot.y; + heldActor->speed = 10.0f; + heldActor->velocity.y = 20.0f; + func_808309CC(play, this); + Player_PlaySfx(this, NA_SE_PL_THROW); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_SWORD_N); + } +} + +void func_8084E4E4(Player* this, PlayState* play) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + Player_AnimationPlayLoop(play, this, &gPlayerAnim_link_normal_nocarry_free_wait); + this->unk_AE8 = 15; + } else if (this->unk_AE8 != 0) { + this->unk_AE8--; + if (this->unk_AE8 == 0) { + func_80836A98(this, &gPlayerAnim_link_normal_nocarry_free_end, play); + this->stateFlags1 &= ~PLAYER_STATE1_800; + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_DAMAGE_S); + } + } +} + +// Player_Action_PutDownObject? +void func_8084E58C(Player* this, PlayState* play) { + func_80832F24(this); + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_80836988(this, play); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 4.0f)) { + Actor* heldActor = this->heldActor; + + if (!func_808313A8(play, this, heldActor)) { + heldActor->velocity.y = 0.0f; + heldActor->speed = 0.0f; + func_808309CC(play, this); + if (heldActor->id == ACTOR_EN_BOM_CHU) { + func_80831814(this, play, PLAYER_UNKAA5_0); + } + } + } +} + +// Player_Action_Throwing +void func_8084E65C(Player* this, PlayState* play) { + f32 sp34; + s16 yaw; + + func_80832F24(this); + + if (PlayerAnimation_Update(play, &this->skelAnime) || + ((this->skelAnime.curFrame >= 8.0f) && func_80832F78(this, &sp34, &yaw, 0.018f, play))) { + func_80836988(this, play); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 3.0f)) { + func_808409A8(play, this, this->linearVelocity + 8.0f, 12.0f); + } +} + +void func_8084E724(Player* this, PlayState* play) { + u8 temp_v1; + u32 new_var; + + if (this->stateFlags1 & PLAYER_STATE1_8000000) { + func_808475B4(this); + func_8084748C(this, &this->linearVelocity, 0.0f, this->actor.shape.rot.y); + } else { + func_80832F24(this); + } + + if (this->unk_AA5 == PLAYER_UNKAA5_3) { + if (func_800B7118(this) || func_8082ECCC(this)) { + func_8083216C(this, play); + } + } + + temp_v1 = this->unk_AA5; + new_var = temp_v1; + + if (((temp_v1 == PLAYER_UNKAA5_2) && !(play->actorCtx.flags & ACTORCTX_FLAG_PICTO_BOX_ON)) || + ((temp_v1 != PLAYER_UNKAA5_2) && + (((((((((this->csMode != PLAYER_CSMODE_0) || (new_var == 0)) || (temp_v1 >= PLAYER_UNKAA5_5)) || + (func_8082FB68(this) != 0)) || + (this->targetedActor != NULL)) || + (func_8083868C(play, this) == 0)) || + ((this->unk_AA5 == PLAYER_UNKAA5_3) && + (((((Player_ItemToItemAction(this, Inventory_GetBtnBItem(play)) != this->heldItemAction) && + CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_B)) || + CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_R | BTN_A)) || + (func_80123434(this) != 0)) || + (!func_800B7128(this) && (func_8082EF20(this) == 0))))) || + ((this->unk_AA5 == PLAYER_UNKAA5_1) && + CHECK_BTN_ANY(sPlayerControlInput->press.button, + BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP | BTN_R | BTN_B | BTN_A))) || + func_808391D8(this, play)))) { + func_80839ED0(this, play); + play_sound(NA_SE_SY_CAMERA_ZOOM_UP); + } else if ((DECR(this->unk_AE8) == 0) || (this->unk_AA5 != PLAYER_UNKAA5_3)) { + if (func_801240DC(this)) { + this->unk_AA6 |= 0x43; + } else { + this->actor.shape.rot.y = func_80847190(play, this, 0); + } + } + + this->currentYaw = this->actor.shape.rot.y; +} + +void func_8084E980(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_20; + + func_8083249C(this); + func_8083216C(this, play); + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; + if (!CHECK_FLAG_ALL(this->talkActor->flags, ACTOR_FLAG_1 | ACTOR_FLAG_4)) { + this->stateFlags2 &= ~PLAYER_STATE2_2000; + } + + func_800E0238(Play_GetCamera(play, CAM_ID_MAIN)); + CutsceneManager_Stop(CS_ID_GLOBAL_TALK); + if (this->stateFlags1 & PLAYER_STATE1_800000) { + s32 sp44 = this->unk_AE8; + + func_80837BD0(play, this); + this->unk_AE8 = sp44; + } else if (!func_80847994(play, this) && !func_80847880(play, this) && !func_808387A0(play, this) && + ((this->talkActor != this->interactRangeActor) || !func_8083D23C(this, play))) { + if (func_801242B4(this)) { + func_808353DC(play, this); + } else { + func_8085B384(this, play); + } + } + + this->unk_B5E = 0xA; + return; + } + + if (this->stateFlags1 & PLAYER_STATE1_800000) { + func_8084FE7C(this, play); + } else if (func_801242B4(this)) { + func_808508C8(this, play); + if (this->actor.depthInWater > 100.0f) { + this->actor.velocity.y = 0.0f; + this->actor.gravity = 0.0f; + } + } else if (!func_80123420(this) && PlayerAnimation_Update(play, &this->skelAnime)) { + if (this->skelAnime.moveFlags != 0) { + func_8082E794(this); + if ((this->talkActor->category == ACTORCAT_NPC) && (this->heldItemAction != PLAYER_IA_FISHING_ROD)) { + func_8082DB90(play, this, &gPlayerAnim_link_normal_talk_free); + } else { + Player_AnimationPlayLoop(play, this, func_8082ED20(this)); + } + } else { + func_8082DB60(play, this, &gPlayerAnim_link_normal_talk_free_wait); + } + } + + if (this->targetedActor != NULL) { + this->currentYaw = func_8083C62C(this, false); + this->actor.shape.rot.y = this->currentYaw; + if (this->unk_AE7 != 0) { + if (!(this->stateFlags1 & PLAYER_STATE1_800)) { + if (PlayerAnimation_Update(play, &this->unk_284)) { + this->unk_AE7--; + if (this->unk_AE7 != 0) { + PlayerAnimation_Change(play, &this->unk_284, &gPlayerAnim_link_normal_talk_free, 1.0f, 0.0f, + Animation_GetLastFrame(&gPlayerAnim_link_normal_talk_free), + ANIMMODE_ONCE, -6.0f); + } + } + } + AnimationContext_SetCopyFalse(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->unk_284.jointTable, D_8085B9F0); + } else if (!(this->stateFlags1 & PLAYER_STATE1_800) && + (this->skelAnime.animation == &gPlayerAnim_link_normal_talk_free_wait)) { + s32 temp_v0 = this->actor.focus.rot.y - this->actor.shape.rot.y; + + if (ABS_ALT(temp_v0) > 0xFA0) { + PlayerAnimation_Change( + play, &this->unk_284, D_8085BE84[PLAYER_ANIMGROUP_25][this->modelAnimType], 0.4f, 0.0f, + Animation_GetLastFrame(D_8085BE84[PLAYER_ANIMGROUP_25][this->modelAnimType]), ANIMMODE_ONCE, -6.0f); + this->unk_AE7 = 2; + } + } + } +} + +void func_8084ED9C(Player* this, PlayState* play) { + f32 sp34; + s16 sp32; + s32 temp_v0; + + this->stateFlags2 |= (PLAYER_STATE2_1 | PLAYER_STATE2_40 | PLAYER_STATE2_100); + func_8083DEE4(play, this); + + if (PlayerAnimation_Update(play, &this->skelAnime) && !func_8083E14C(play, this)) { + func_80832F78(this, &sp34, &sp32, 0.0f, play); + temp_v0 = func_8083E758(this, &sp34, &sp32); + if (temp_v0 > 0) { + func_8083E234(this, play); + } else if (temp_v0 < 0) { + func_8083E28C(this, play); + } + } +} + +AnimSfxEntry D_8085D650[] = { + ANIMSFX(ANIMSFX_TYPE_FLOOR, 3, NA_SE_PL_SLIP, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR, 21, NA_SE_PL_SLIP, STOP), +}; + +void func_8084EE50(Player* this, PlayState* play) { + this->stateFlags2 |= (PLAYER_STATE2_1 | PLAYER_STATE2_40 | PLAYER_STATE2_100); + + if (func_8082E67C(play, this, &gPlayerAnim_link_normal_pushing)) { + this->unk_AE8 = 1; + } else if ((this->unk_AE8 == 0) && PlayerAnimation_OnFrame(&this->skelAnime, 11.0f)) { + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_PUSH); + } + + Player_PlayAnimSfx(this, D_8085D650); + func_8083DEE4(play, this); + + if (!func_8083E14C(play, this)) { + f32 sp34; + s16 sp32; + s32 temp_v0; + + func_80832F78(this, &sp34, &sp32, 0.0f, play); + temp_v0 = func_8083E758(this, &sp34, &sp32); + if (temp_v0 < 0) { + func_8083E28C(this, play); + } else if (temp_v0 == 0) { + func_8083DF38(this, &gPlayerAnim_link_normal_push_end, play); + } else { + this->stateFlags2 |= PLAYER_STATE2_10; + } + } + + if (this->stateFlags2 & PLAYER_STATE2_10) { + func_808479F4(play, this, 2.0f); + this->linearVelocity = 2.0f; + } +} + +AnimSfxEntry D_8085D658[] = { + ANIMSFX(ANIMSFX_TYPE_FLOOR, 4, NA_SE_PL_SLIP, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR, 24, NA_SE_PL_SLIP, STOP), +}; + +Vec3f D_8085D660 = { 0.0f, 268 * 0.1f, -60.0f }; + +void func_8084EF9C(Player* this, PlayState* play) { + PlayerAnimationHeader* anim = D_8085BE84[PLAYER_ANIMGROUP_35][this->modelAnimType]; + + this->stateFlags2 |= (PLAYER_STATE2_1 | PLAYER_STATE2_40 | PLAYER_STATE2_100); + + if (func_8082E67C(play, this, anim)) { + this->unk_AE8 = 1; + } else if (this->unk_AE8 == 0) { + if (PlayerAnimation_OnFrame(&this->skelAnime, 11.0f)) { + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_PUSH); + } + + //! FAKE + if (1) {} + } else { + Player_PlayAnimSfx(this, D_8085D658); + } + + func_8083DEE4(play, this); + if (!func_8083E14C(play, this)) { + f32 sp78; + s16 sp76; + s32 temp_v0; + + func_80832F78(this, &sp78, &sp76, 0.0f, play); + + temp_v0 = func_8083E758(this, &sp78, &sp76); + if (temp_v0 > 0) { + func_8083E234(this, play); + } else if (temp_v0 == 0) { + func_8083DF38(this, D_8085BE84[PLAYER_ANIMGROUP_36][this->modelAnimType], play); + } else { + this->stateFlags2 |= PLAYER_STATE2_10; + } + } + + if (this->stateFlags2 & PLAYER_STATE2_10) { + Vec3f sp64; + f32 yIntersect = func_80835D2C(play, this, &D_8085D660, &sp64) - this->actor.world.pos.y; + CollisionPoly* poly; + s32 bgId; + Vec3f sp4C; + Vec3f sp40; + + if (fabsf(yIntersect) < 268 * 0.1f) { + sp64.y -= 7.0f; + sp4C.x = this->actor.world.pos.x; + sp4C.z = this->actor.world.pos.z; + sp4C.y = sp64.y; + if (!BgCheck_EntityLineTest2(&play->colCtx, &sp4C, &sp64, &sp40, &poly, 1, 0, 0, 1, &bgId, &this->actor)) { + func_808479F4(play, this, -2.0f); + return; + } + } + this->stateFlags2 &= ~PLAYER_STATE2_10; + } +} + +void func_8084F1B8(Player* this, PlayState* play) { + f32 sp3C; + s16 sp3A; + + this->stateFlags2 |= PLAYER_STATE2_40; + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + Player_AnimationPlayLoop(play, this, + (this->unk_AE7 > 0) ? &gPlayerAnim_link_normal_fall_wait + : D_8085BE84[PLAYER_ANIMGROUP_39][this->modelAnimType]); + } else if (this->unk_AE7 == 0) { + f32 frame; + + if (this->skelAnime.animation == &gPlayerAnim_link_normal_fall) { + frame = 11.0f; + } else { + frame = 1.0f; + } + + if (PlayerAnimation_OnFrame(&this->skelAnime, frame)) { + Player_AnimSfx_PlayFloor(this, NA_SE_PL_WALK_GROUND); + if (this->skelAnime.animation == &gPlayerAnim_link_normal_fall) { + this->unk_AE7 = 1; + } else { + this->unk_AE7 = -1; + } + } + } + + Math_ScaledStepToS(&this->actor.shape.rot.y, this->currentYaw, 0x800); + if (this->unk_AE7 != 0) { + func_80832F78(this, &sp3C, &sp3A, 0.0f, play); + if (this->unk_ADF[this->unk_ADE] >= 0) { + func_808381A0(this, + (this->unk_AE7 > 0) ? D_8085BE84[PLAYER_ANIMGROUP_37][this->modelAnimType] + : D_8085BE84[PLAYER_ANIMGROUP_40][this->modelAnimType], + play); + } else if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A) || (this->actor.shape.feetFloorFlags != 0)) { + func_80833A64(this); + + if (this->unk_AE7 < 0) { + this->linearVelocity = -0.8f; + } else { + this->linearVelocity = 0.8f; + } + + func_80833AA0(this, play); + this->stateFlags1 &= ~(PLAYER_STATE1_4 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000); + this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND; + } + } +} + +void func_8084F3DC(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_40; + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + this->currentYaw = this->skelAnime.jointTable[PLAYER_LIMB_WAIST - 1].y + this->actor.shape.rot.y; + func_8082E820(this, 1); + this->actor.shape.rot.y = this->currentYaw; + func_80839E74(this, play); + this->stateFlags1 &= ~(PLAYER_STATE1_4 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, this->skelAnime.endFrame - 6.0f)) { + Player_AnimSfx_PlayFloorLand(this); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, this->skelAnime.endFrame - 34.0f)) { + Player_PlaySfx(this, NA_SE_PL_CLIMB_CLIFF); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_CLIMB_END); + func_8084C124(play, this); + } +} + +void func_8084F4E8(Player* this, PlayState* play) { + s32 yStick = sPlayerControlInput->rel.stick_y; + s32 xStick = sPlayerControlInput->rel.stick_x; + f32 var_fv0; + f32 var_fv1; + Vec3f sp7C; + s32 sp78; + Vec3f sp6C; + Vec3f sp60; + DynaPolyActor* dyna; + PlayerAnimationHeader* anim1; + PlayerAnimationHeader* anim2; + + this->fallStartHeight = this->actor.world.pos.y; + + this->stateFlags2 |= PLAYER_STATE2_40; + + if ((this->unk_AE7 != 0) && (ABS_ALT(yStick) < ABS_ALT(xStick))) { + var_fv0 = ABS_ALT(xStick) * 0.0325f; + yStick = 0; + } else { + var_fv0 = ABS_ALT(yStick) * 0.05f; + xStick = 0; + } + + if (var_fv0 < 1.0f) { + var_fv0 = 1.0f; + } else if (var_fv0 > 3.35f) { + var_fv0 = 3.35f; + } + + if (this->skelAnime.playSpeed >= 0.0f) { + var_fv1 = 1.0f; + } else { + var_fv1 = -1.0f; + } + + this->skelAnime.playSpeed = var_fv1 * var_fv0; + + if (this->unk_AE8 >= 0) { + if ((this->actor.wallPoly != NULL) && (this->actor.wallBgId != BGCHECK_SCENE)) { + dyna = DynaPoly_GetActor(&play->colCtx, this->actor.wallBgId); + + if (dyna != NULL) { + Math_Vec3f_Diff(&dyna->actor.world.pos, &dyna->actor.prevPos, &sp7C); + Math_Vec3f_Sum(&this->actor.world.pos, &sp7C, &this->actor.world.pos); + } + } + + Actor_UpdateBgCheckInfo(play, &this->actor, 268 * 0.1f, 6.0f, this->ageProperties->unk_00 + 15.0f, + UPDBGCHECKINFO_FLAG_1 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_4); + func_8083DD1C(play, this, 268 * 0.1f, this->ageProperties->unk_3C, 50.0f, -20.0f); + } + + func_80831944(play, this); + + if ((this->unk_AE8 < 0) || !func_8083E354(this, play)) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + if (this->unk_AE8 < 0) { + this->unk_AE8 = ABS_ALT(this->unk_AE8) & 1; + } else if (yStick != 0) { + f32 yIntersect; + + sp78 = this->unk_AE7 + this->unk_AE8; + + if (yStick > 0) { + sp6C.x = 0.0f; + sp6C.y = this->ageProperties->unk_40; + sp6C.z = this->ageProperties->unk_3C + 10.0f; + + yIntersect = func_80835D2C(play, this, &sp6C, &sp60); + + if (this->actor.world.pos.y < yIntersect) { + if (this->unk_AE7 != 0) { + this->actor.world.pos.y = yIntersect; + this->stateFlags1 &= ~PLAYER_STATE1_200000; + func_80837CEC(play, this, this->actor.wallPoly, this->ageProperties->unk_3C, + &gPlayerAnim_link_normal_jump_climb_up_free); + this->currentYaw += 0x8000; + this->actor.shape.rot.y = this->currentYaw; + func_808381A0(this, &gPlayerAnim_link_normal_jump_climb_up_free, play); + this->stateFlags1 |= PLAYER_STATE1_4000; + } else { + func_8083DCC4(this, this->ageProperties->unk_D4[this->unk_AE8], play); + } + } else { + this->skelAnime.prevTransl = this->ageProperties->unk_4A[sp78]; + Player_AnimationPlayOnce(play, this, this->ageProperties->unk_B4[sp78]); + } + } else if ((this->actor.world.pos.y - this->actor.floorHeight) < 15.0f) { + if (this->unk_AE7 != 0) { + func_8083E2F4(this, play); + } else { + if (this->unk_AE8 != 0) { + this->skelAnime.prevTransl = this->ageProperties->unk_44; + } + + func_8083DCC4(this, this->ageProperties->unk_CC[this->unk_AE8], play); + this->unk_AE8 = 1; + } + } else { + sp78 ^= 1; + this->skelAnime.prevTransl = this->ageProperties->unk_62[sp78]; + anim1 = this->ageProperties->unk_B4[sp78]; + PlayerAnimation_Change(play, &this->skelAnime, anim1, -1.0f, Animation_GetLastFrame(anim1), 0.0f, 2, + 0.0f); + } + + this->unk_AE8 ^= 1; + } else if ((this->unk_AE7 != 0) && (xStick != 0)) { + anim2 = this->ageProperties->unk_C4[this->unk_AE8]; + + if (xStick > 0) { + this->skelAnime.prevTransl = this->ageProperties->unk_7A[this->unk_AE8]; + Player_AnimationPlayOnce(play, this, anim2); + } else { + this->skelAnime.prevTransl = this->ageProperties->unk_7A[this->unk_AE8 + 2]; + PlayerAnimation_Change(play, &this->skelAnime, anim2, -1.0f, Animation_GetLastFrame(anim2), 0.0f, 2, + 0.0f); + } + } else { + this->stateFlags2 |= PLAYER_STATE2_1000; + } + + return; + } + } + + if (this->unk_AE8 < 0) { + if (((this->unk_AE8 == -2) && + (PlayerAnimation_OnFrame(&this->skelAnime, 14.0f) || PlayerAnimation_OnFrame(&this->skelAnime, 29.0f))) || + ((this->unk_AE8 == -4) && + (PlayerAnimation_OnFrame(&this->skelAnime, 22.0f) || PlayerAnimation_OnFrame(&this->skelAnime, 35.0f) || + PlayerAnimation_OnFrame(&this->skelAnime, 49.0f) || PlayerAnimation_OnFrame(&this->skelAnime, 55.0f)))) { + func_80847A50(this); + } + } else if (PlayerAnimation_OnFrame(&this->skelAnime, (this->skelAnime.playSpeed > 0.0f) ? 20.0f : 0.0f)) { + func_80847A50(this); + } +} + +f32 D_8085D66C[] = { 11.0f, 21.0f }; +f32 D_8085D674[] = { 40.0f, 50.0f }; + +AnimSfxEntry D_8085D67C[] = { + ANIMSFX(ANIMSFX_TYPE_SURFACE, 10, NA_SE_PL_WALK_LADDER, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_SURFACE, 20, NA_SE_PL_WALK_LADDER, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_SURFACE, 30, NA_SE_PL_WALK_LADDER, STOP), +}; + +void func_8084FC0C(Player* this, PlayState* play) { + s32 temp_v0; + + this->stateFlags2 |= PLAYER_STATE2_40; + + temp_v0 = func_808331FC(play, this, &this->skelAnime, 4.0f); + if (temp_v0 == 0) { + this->stateFlags1 &= ~PLAYER_STATE1_200000; + } else if ((temp_v0 > 0) || PlayerAnimation_Update(play, &this->skelAnime)) { + func_80839E74(this, play); + this->stateFlags1 &= ~PLAYER_STATE1_200000; + } else { + f32* var_v1 = D_8085D66C; + + if (this->unk_AE8 != 0) { + Player_PlayAnimSfx(this, D_8085D67C); + var_v1 = D_8085D674; + } + + if (PlayerAnimation_OnFrame(&this->skelAnime, var_v1[0]) || + PlayerAnimation_OnFrame(&this->skelAnime, var_v1[1])) { + CollisionPoly* poly; + s32 bgId; + Vec3f pos; + + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + 20.0f; + pos.z = this->actor.world.pos.z; + if (BgCheck_EntityRaycastFloor5(&play->colCtx, &poly, &bgId, &this->actor, &pos) != 0.0f) { + this->floorSfxOffset = SurfaceType_GetSfxOffset(&play->colCtx, poly, bgId); + Player_AnimSfx_PlayFloorLand(this); + } + } + } +} + +void func_8084FD7C(PlayState* play, Player* this, Actor* actor) { + s16 var_a3; + + if (this->unk_B86[0] != 0) { + this->unk_B86[0]--; + return; + } + + this->upperLimbRot.y = func_80847190(play, this, 1) - this->actor.shape.rot.y; + + var_a3 = ABS_ALT(this->upperLimbRot.y) - 0x4000; + if (var_a3 > 0) { + var_a3 = CLAMP_MAX(var_a3, 0x15E); + actor->shape.rot.y += var_a3 * ((this->upperLimbRot.y >= 0) ? 1 : -1); + actor->world.rot.y = actor->shape.rot.y; + } + + this->upperLimbRot.y += 0x2710; + this->unk_AA8 = -0x1388; +} + +s32 func_8084FE48(Player* this) { + return this->targetedActor == NULL && !func_8082FC24(this); +} + +PlayerAnimationHeader* D_8085D688[] = { + &gPlayerAnim_link_uma_anim_stop, &gPlayerAnim_link_uma_anim_stand, &gPlayerAnim_link_uma_anim_walk, + &gPlayerAnim_link_uma_anim_slowrun, &gPlayerAnim_link_uma_anim_fastrun, &gPlayerAnim_link_uma_anim_jump100, + &gPlayerAnim_link_uma_anim_jump200, +}; + +PlayerAnimationHeader* D_8085D6A4[] = { + NULL, + NULL, + &gPlayerAnim_link_uma_anim_walk_muti, + &gPlayerAnim_link_uma_anim_walk_muti, + &gPlayerAnim_link_uma_anim_walk_muti, + &gPlayerAnim_link_uma_anim_slowrun_muti, + &gPlayerAnim_link_uma_anim_fastrun_muti, + &gPlayerAnim_link_uma_anim_fastrun_muti, + &gPlayerAnim_link_uma_anim_fastrun_muti, + NULL, + NULL, +}; + +PlayerAnimationHeader* D_8085D6D0[] = { + &gPlayerAnim_link_uma_wait_3, + &gPlayerAnim_link_uma_wait_1, + &gPlayerAnim_link_uma_wait_2, +}; + +u8 D_8085D6DC[][2] = { + { 32, 58 }, + { 25, 42 }, +}; + +Vec3s D_8085D6E0 = { -0x45, 0x1BEA, -0x10A }; + +AnimSfxEntry D_8085D6E8[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 48, NA_SE_PL_CALM_HIT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 58, NA_SE_PL_CALM_HIT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 68, NA_SE_PL_CALM_HIT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 92, NA_SE_PL_CALM_PAT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 110, NA_SE_PL_CALM_PAT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 126, NA_SE_PL_CALM_PAT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 132, NA_SE_PL_CALM_PAT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 136, NA_SE_PL_CALM_PAT, STOP), +}; + +void func_8084FE7C(Player* this, PlayState* play) { + EnHorse* rideActor = (EnHorse*)this->rideActor; + + this->stateFlags2 |= PLAYER_STATE2_40; + + func_80847E2C(this, 1.0f, 10.0f); + if (this->unk_AE8 == 0) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + this->skelAnime.animation = &gPlayerAnim_link_uma_wait_1; + this->unk_AE8 = 0x63; + } else { + s32 var_v0 = (this->mountSide < 0) ? 0 : 1; + + if (PlayerAnimation_OnFrame(&this->skelAnime, D_8085D6DC[var_v0][0])) { + Actor_SetCameraHorseSetting(play, this); + Player_PlaySfx(this, NA_SE_PL_CLIMB_CLIFF); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, D_8085D6DC[var_v0][1])) { + Player_PlaySfx(this, NA_SE_PL_SIT_ON_HORSE); + } + } + } else { + if (rideActor->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + func_80841A50(play, this); + } + + Actor_SetCameraHorseSetting(play, this); + + this->skelAnime.prevTransl = D_8085D6E0; + + if ((this->unk_AE8 < 0) || ((rideActor->animIndex != (this->unk_AE8 & 0xFFFF)) && + ((rideActor->animIndex >= ENHORSE_ANIM_STOPPING) || (this->unk_AE8 >= 2)))) { + s32 animIndex = rideActor->animIndex; + + if (animIndex < ENHORSE_ANIM_STOPPING) { + f32 temp_fv0 = Rand_ZeroOne(); + s32 index = 0; + + animIndex = ENHORSE_ANIM_WHINNY; + if (temp_fv0 < 0.1f) { + index = 2; + } else if (temp_fv0 < 0.2f) { + index = 1; + } + + Player_AnimationPlayOnce(play, this, D_8085D6D0[index]); + } else { + this->skelAnime.animation = D_8085D688[animIndex - 2]; + if (this->unk_AE8 >= 0) { + Animation_SetMorph(play, &this->skelAnime, 8.0f); + } + + if (animIndex < ENHORSE_ANIM_WALK) { + func_808309CC(play, this); + this->unk_AE7 = 0; + } + } + + this->unk_AE8 = animIndex; + } + + if (this->unk_AE8 == 1) { + if (D_80862B04 || func_8082DAFC(play)) { + Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_uma_wait_3); + } else if (PlayerAnimation_Update(play, &this->skelAnime)) { + this->unk_AE8 = 0x63; + } else if (this->skelAnime.animation == &gPlayerAnim_link_uma_wait_1) { + Player_PlayAnimSfx(this, D_8085D6E8); + } + } else { + this->skelAnime.curFrame = rideActor->curFrame; + PlayerAnimation_AnimateFrame(play, &this->skelAnime); + } + + AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnime.morphTable, + this->skelAnime.jointTable); + + if ((play->csCtx.state != CS_STATE_IDLE) || (this->csMode != PLAYER_CSMODE_0)) { + this->unk_AA5 = PLAYER_UNKAA5_0; + this->unk_AE7 = 0; + } else if ((this->unk_AE8 < 2) || (this->unk_AE8 >= 4)) { + D_80862B04 = func_8083216C(this, play); + if (D_80862B04) { + this->unk_AE7 = 0; + } + } + + this->actor.world.pos.x = rideActor->actor.world.pos.x + rideActor->riderPos.x; + this->actor.world.pos.y = rideActor->actor.world.pos.y + rideActor->riderPos.y - 27.0f; + this->actor.world.pos.z = rideActor->actor.world.pos.z + rideActor->riderPos.z; + + this->currentYaw = this->actor.shape.rot.y = rideActor->actor.shape.rot.y; + + if (!D_80862B04) { + if (this->unk_AE7 != 0) { + if (PlayerAnimation_Update(play, &this->unk_284)) { + rideActor->stateFlags &= ~ENHORSE_FLAG_8; + this->unk_AE7 = 0; + } + + if (this->unk_284.animation == &gPlayerAnim_link_uma_stop_muti) { + if (PlayerAnimation_OnFrame(&this->unk_284, 23.0f)) { + Player_PlaySfx(this, NA_SE_IT_LASH); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_LASH); + } + + AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->unk_284.jointTable); + } else { + if (PlayerAnimation_OnFrame(&this->unk_284, 10.0f)) { + Player_PlaySfx(this, NA_SE_IT_LASH); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_LASH); + } + + AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->unk_284.jointTable, D_8085B9F0); + } + } else if (!CHECK_FLAG_ALL(this->actor.flags, 0x100)) { + PlayerAnimationHeader* anim = NULL; + + if (EN_HORSE_CHECK_3(rideActor)) { + anim = &gPlayerAnim_link_uma_stop_muti; + } else if (EN_HORSE_CHECK_2(rideActor)) { + if ((this->unk_AE8 >= 2) && (this->unk_AE8 != 0x63)) { + anim = D_8085D6A4[this->unk_AE8]; + } + } + + if (anim != NULL) { + PlayerAnimation_PlayOnce(play, &this->unk_284, anim); + this->unk_AE7 = 1; + } + } + } + + if (this->stateFlags1 & PLAYER_STATE1_100000) { + if (CHECK_BTN_ANY(sPlayerControlInput->press.button, BTN_A) || !func_8084FE48(this)) { + this->unk_AA5 = PLAYER_UNKAA5_0; + this->stateFlags1 &= ~PLAYER_STATE1_100000; + } else { + func_8084FD7C(play, this, &rideActor->actor); + } + } else if ((this->csMode != PLAYER_CSMODE_0) || + (!func_8082DAFC(play) && ((rideActor->actor.speed != 0.0f) || !func_808391D8(this, play)) && + !func_80847BF0(this, play) && !func_80838A90(this, play))) { + if (this->targetedActor != NULL) { + if (func_800B7128(this)) { + this->upperLimbRot.y = func_8083C62C(this, true) - this->actor.shape.rot.y; + this->upperLimbRot.y = CLAMP(this->upperLimbRot.y, -0x4AAA, 0x4AAA); + this->actor.focus.rot.y = this->actor.shape.rot.y + this->upperLimbRot.y; + this->upperLimbRot.y += 0xFA0; + this->unk_AA6 |= 0x80; + } else { + func_8083C62C(this, false); + } + + this->unk_AA8 = 0; + } else if (func_8084FE48(this)) { + if (func_800B7128(this)) { + func_80831010(this, play); + } + + this->unk_B86[0] = 0xC; + } else if (func_800B7128(this)) { + func_8084FD7C(play, this, &rideActor->actor); + } + } + } + + if (this->csMode == PLAYER_CSMODE_END) { + this->csMode = PLAYER_CSMODE_0; + } +} + +AnimSfxEntry D_8085D708[] = { + ANIMSFX(ANIMSFX_TYPE_FLOOR_LAND, 0, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 10, NA_SE_PL_GET_OFF_HORSE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 25, NA_SE_PL_SLIPDOWN, STOP), +}; + +void func_808505D0(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_40; + func_80847E2C(this, 1.0f, 10.0f); + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + Actor* rideActor = this->rideActor; + + Camera_ChangeSetting(Play_GetCamera(play, CAM_ID_MAIN), CAM_SET_NORMAL0); + func_80839E74(this, play); + + this->stateFlags1 &= ~PLAYER_STATE1_800000; + this->actor.parent = NULL; + D_801BDA9C = false; + + if (CHECK_QUEST_ITEM(QUEST_SONG_EPONA) || (DREG(1) != 0)) { + gSaveContext.save.saveInfo.horseData.sceneId = play->sceneId; + gSaveContext.save.saveInfo.horseData.pos.x = rideActor->world.pos.x; + gSaveContext.save.saveInfo.horseData.pos.y = rideActor->world.pos.y; + gSaveContext.save.saveInfo.horseData.pos.z = rideActor->world.pos.z; + gSaveContext.save.saveInfo.horseData.yaw = rideActor->shape.rot.y; + } + } else { + if (this->mountSide < 0) { + D_8085D708[0].flags = ANIMSFX_FLAGS(ANIMSFX_TYPE_FLOOR_LAND, 40, CONTINUE); + } else { + D_8085D708[0].flags = ANIMSFX_FLAGS(ANIMSFX_TYPE_FLOOR_LAND, 29, CONTINUE); + } + + Player_PlayAnimSfx(this, D_8085D708); + } +} + +s32 func_80850734(PlayState* play, Player* this) { + if ((this->transformation == PLAYER_FORM_ZORA) && (this->windSpeed == 0.0f) && + (this->currentBoots < PLAYER_BOOTS_ZORA_UNDERWATER) && CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A)) { + func_8083B850(play, this); + this->stateFlags2 |= PLAYER_STATE2_400; + PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_pz_waterroll, 2.0f / 3.0f, 4.0f, + Animation_GetLastFrame(&gPlayerAnim_pz_waterroll), ANIMMODE_ONCE, -6.0f); + this->unk_AE8 = 5; + this->unk_B86[0] = 0; + this->unk_B48 = this->linearVelocity; + this->actor.velocity.y = 0.0f; + Player_PlaySfx(this, NA_SE_PL_ZORA_SWIM_DASH); + return true; + } + return false; +} + +s32 func_80850854(PlayState* play, Player* this) { + if ((this->transformation == PLAYER_FORM_DEKU) && (this->remainingHopsCounter != 0) && + (gSaveContext.save.saveInfo.playerData.health != 0) && (D_80862AFC != 0.0f)) { + func_808373F8(play, this, 0); + return true; + } + return false; +} + +void func_808508C8(Player* this, PlayState* play) { + f32 sp34; + s16 sp32; + + this->stateFlags2 |= PLAYER_STATE2_20; + + func_8082E67C(play, this, &gPlayerAnim_link_swimer_swim_wait); + func_808475B4(this); + + if (this->unk_AE8 != 0) { + this->unk_AE8--; + } + + func_8082F164(this, BTN_R); + + if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A)) { + this->unk_AE8 = 0; + } + + if (!func_8082DAFC(play) && !func_80833058(play, this, D_8085D048, 1) && + !func_8083B3B4(play, this, sPlayerControlInput) && ((this->unk_AE8 != 0) || !func_80850734(play, this))) { + sp34 = 0.0f; + sp32 = this->actor.shape.rot.y; + + if (this->unk_AA5 > PLAYER_UNKAA5_2) { + this->unk_AA5 = PLAYER_UNKAA5_0; + } + + if (this->currentBoots >= PLAYER_BOOTS_ZORA_UNDERWATER) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + func_80836A98(this, D_8085BE84[PLAYER_ANIMGROUP_14][this->modelAnimType], play); + Player_AnimSfx_PlayFloorLand(this); + } + } else if ((func_80850854(play, this) == 0) && + (func_80832F78(this, &sp34, &sp32, 0.0f, play), (sp34 != 0.0f))) { + if ((ABS_ALT(BINANG_SUB(this->actor.shape.rot.y, sp32)) > 0x6000) && + !Math_StepToF(&this->linearVelocity, 0.0f, 1.0f)) { + return; + } + + if (func_8082FC24(this) || func_80847ED4(this)) { + func_80848048(play, this); + } else { + func_8083B73C(play, this, sp32); + } + } + + func_8084748C(this, &this->linearVelocity, sp34, sp32); + func_80847F1C(this); + } +} + +void func_80850B18(Player* this, PlayState* play) { + if (!func_80838A90(this, play)) { + this->stateFlags2 |= PLAYER_STATE2_20; + func_808477D0(play, this, NULL, this->linearVelocity); + func_808475B4(this); + + if (DECR(this->unk_AE8) == 0) { + func_808353DC(play, this); + } + } +} + +void func_80850BA8(Player* this) { + this->linearVelocity = Math_CosS(this->unk_AAA) * this->unk_B48; + this->actor.velocity.y = -Math_SinS(this->unk_AAA) * this->unk_B48; +} + +void func_80850BF8(Player* this, f32 arg1) { + f32 temp_fv0; + s16 temp_ft0; + + Math_AsymStepToF(&this->unk_B48, arg1, 1.0f, (fabsf(this->unk_B48) * 0.01f) + 0.4f); + temp_fv0 = Math_CosS(sPlayerControlInput->rel.stick_x * 0x10E); + + temp_ft0 = (((sPlayerControlInput->rel.stick_x >= 0) ? 1 : -1) * (1.0f - temp_fv0) * -1100.0f); + temp_ft0 = CLAMP(temp_ft0, -0x1F40, 0x1F40); + + this->currentYaw += temp_ft0; +} + +void func_80850D20(PlayState* play, Player* this) { + func_8083F8A8(play, this, 12.0f, -1, 1.0f, 160, 20, true); +} + +void func_80850D68(Player* this, PlayState* play) { + f32 sp44; + s16 sp42; + s16 sp40; + s16 sp3E; + s16 sp3C; + s16 sp3A; + + this->stateFlags2 |= PLAYER_STATE2_20; + + func_808475B4(this); + func_8082F164(this, BTN_R); + + if (func_80833058(play, this, D_8085D048, false)) { + return; + } + + if (func_8083B3B4(play, this, sPlayerControlInput)) { + return; + } + + if (func_80840A30(play, this, &this->linearVelocity, 0.0f)) { + return; + } + + sp44 = 0.0f; + + if (this->unk_AE8 != 0) { + if ((!func_8082DA90(play) && !CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A)) || + (this->currentBoots != PLAYER_BOOTS_ZORA_LAND)) { + this->unk_B86[0] = 1; + } + + if (PlayerAnimation_Update(play, &this->skelAnime) && (DECR(this->unk_AE8) == 0)) { + if (this->unk_B86[0] != 0) { + this->stateFlags3 &= ~PLAYER_STATE3_8000; + func_8082DB90(play, this, &gPlayerAnim_pz_swimtowait); + } else { + func_8082DB60(play, this, &gPlayerAnim_pz_fishswim); + } + } else { + func_80832F78(this, &sp44, &sp40, 0.0f, play); + Math_ScaledStepToS(&this->currentYaw, sp40, 0x640); + + if (this->skelAnime.curFrame >= 13.0f) { + sp44 = 12.0f; + + if (PlayerAnimation_OnFrame(&this->skelAnime, 13.0f)) { + this->unk_B48 = 16.0f; + } + this->stateFlags3 |= PLAYER_STATE3_8000; + } else { + sp44 = 0.0f; + } + } + + Math_SmoothStepToS(&this->unk_B86[1], sPlayerControlInput->rel.stick_x * 0xC8, 0xA, 0x3E8, 0x64); + Math_SmoothStepToS(&this->unk_B8E, this->unk_B86[1], IREG(40) + 1, IREG(41), IREG(42)); + } else if (this->unk_B86[0] == 0) { + PlayerAnimation_Update(play, &this->skelAnime); + + if ((!func_8082DA90(play) && !CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A)) || + (this->currentBoots != PLAYER_BOOTS_ZORA_LAND) || (this->windSpeed > 9.0f)) { + this->stateFlags3 &= ~PLAYER_STATE3_8000; + func_8082DB90(play, this, &gPlayerAnim_pz_swimtowait); + this->unk_B86[0] = 1; + } else { + sp44 = 9.0f; + func_800B8F98(&this->actor, NA_SE_PL_ZORA_SWIM_LV - SFX_FLAG); + } + + // Y + sp3E = sPlayerControlInput->rel.stick_y * 0xC8; + if (this->unk_B8C != 0) { + this->unk_B8C--; + sp3E = CLAMP_MAX(sp3E, (s16)(this->unk_B6C - 0xFA0)); + } + + if ((this->unk_AAA >= -0x1555) && (this->actor.depthInWater < (this->ageProperties->unk_24 + 10.0f))) { + sp3E = CLAMP_MIN(sp3E, 0x7D0); + } + Math_SmoothStepToS(&this->unk_AAA, sp3E, 4, 0xFA0, 0x190); + + // X + sp42 = sPlayerControlInput->rel.stick_x * 0x64; + if (Math_ScaledStepToS(&this->unk_B8A, sp42, 0x384) && (sp42 == 0)) { + Math_SmoothStepToS(&this->unk_B86[1], 0, 4, 0x5DC, 0x64); + Math_SmoothStepToS(&this->unk_B8E, this->unk_B86[1], IREG(44) + 1, IREG(45), IREG(46)); + } else { + sp3C = this->unk_B86[1]; + sp3A = (this->unk_B8A < 0) ? -0x3A98 : 0x3A98; + this->unk_B86[1] += this->unk_B8A; + Math_SmoothStepToS(&this->unk_B8E, this->unk_B86[1], IREG(47) + 1, IREG(48), IREG(49)); + + if ((ABS_ALT(this->unk_B8A) > 0xFA0) && ((((sp3C + this->unk_B8A) - sp3A) * (sp3C - sp3A)) <= 0)) { + Player_PlaySfx(this, NA_SE_PL_ZORA_SWIM_ROLL); + } + } + + if (D_80862B18 < 20.0f) { + func_80850D20(play, this); + } + } else { + Math_SmoothStepToS(&this->unk_B86[1], 0, 4, 0xFA0, 0x190); + if ((this->skelAnime.curFrame <= 5.0f) || !func_80850734(play, this)) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_808353DC(play, this); + } + } + + Player_ResetCylinder(this); + } + + if ((this->unk_B8C < 8) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + DynaPolyActor* dynaActor; + + if ((this->actor.floorBgId == BGCHECK_SCENE) || + ((dynaActor = DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId)) == NULL) || + (dynaActor->actor.id != ACTOR_EN_TWIG)) { + this->unk_AAA += (s16)((-this->unk_B6C - this->unk_AAA) * 2); + this->unk_B8C = 0xF; + } + + func_80850D20(play, this); + Player_PlaySfx(this, NA_SE_PL_BODY_BOUND); + } + + func_80850BF8(this, sp44); + func_80850BA8(this); +} + +void func_808513EC(Player* this, PlayState* play) { + f32 sp34; + s16 sp32; + s16 sp30; + s16 var_v0; + + this->stateFlags2 |= PLAYER_STATE2_20; + func_808475B4(this); + func_8082F164(this, BTN_R); + if (!func_80833058(play, this, D_8085D048, 1) && !func_8083B3B4(play, this, sPlayerControlInput) && + !func_80850854(play, this)) { + func_808477D0(play, this, sPlayerControlInput, this->linearVelocity); + if (func_8082DA90(play)) { + sp34 = this->linearVelocity; + sp32 = this->actor.shape.rot.y; + } else { + func_80832F78(this, &sp34, &sp32, 0.0f, play); + } + sp30 = this->actor.shape.rot.y - sp32; + if (!func_80850734(play, this)) { + if (func_8082FC24(this) || func_80847ED4(this)) { + func_80848048(play, this); + } else { + if ((sp34 == 0.0f) || (ABS_ALT(sp30) > 0x6000) || + (this->currentBoots >= PLAYER_BOOTS_ZORA_UNDERWATER)) { + func_808353DC(play, this); + } + } + func_80847FF8(this, &this->linearVelocity, sp34, sp32); + } + } +} + +void func_80851588(Player* this, PlayState* play) { + f32 sp2C; + s16 sp2A; + + func_808477D0(play, this, sPlayerControlInput, this->linearVelocity); + func_808475B4(this); + func_8082F164(this, BTN_R); + + if (!func_80833058(play, this, D_8085D048, 1) && !func_8083B3B4(play, this, sPlayerControlInput)) { + func_80832F78(this, &sp2C, &sp2A, 0.0f, play); + + if (sp2C == 0.0f) { + func_808353DC(play, this); + } else if (!func_8082FC24(this) && !func_80847ED4(this)) { + func_8083B73C(play, this, sp2A); + } else { + func_80848094(play, this, &sp2C, &sp2A); + } + + func_80847FF8(this, &this->linearVelocity, sp2C, sp2A); + } +} + +void func_808516B4(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_20; + + this->actor.gravity = 0.0f; + func_8083216C(this, play); + func_8082F164(this, BTN_R); + + if (func_80838A90(this, play)) { + return; + } + + if (this->currentBoots >= PLAYER_BOOTS_ZORA_UNDERWATER) { + func_808353DC(play, this); + } else if (this->unk_AE7 == 0) { + f32 temp_fv0; + + if (this->unk_AE8 == 0) { + if (PlayerAnimation_Update(play, &this->skelAnime) || + ((this->skelAnime.curFrame >= 22.0f) && !CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A))) { + func_8083B798(play, this); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 20.0f)) { + this->actor.velocity.y = -2.0f; + } + func_80832F24(this); + } else { + func_808477D0(play, this, sPlayerControlInput, this->actor.velocity.y); + this->unk_AAA = 0x3E80; + + if (CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A) && !func_8083D23C(this, play) && + !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->actor.depthInWater < 120.0f)) { + func_808481CC(play, this, -2.0f); + } else { + this->unk_AE7++; + func_8082E634(play, this, &gPlayerAnim_link_swimer_swim_wait); + } + } + + temp_fv0 = (this->actor.depthInWater - this->ageProperties->unk_30) * 0.04f; + if (temp_fv0 < this->actor.velocity.y) { + this->actor.velocity.y = temp_fv0; + } + } else if (this->unk_AE7 == 1) { + PlayerAnimation_Update(play, &this->skelAnime); + func_808475B4(this); + if (this->unk_AAA < 0x2710) { + this->unk_AE7++; + this->unk_AE8 = this->actor.depthInWater; + func_8082E634(play, this, &gPlayerAnim_link_swimer_swim); + } + } else if (!func_8083B3B4(play, this, sPlayerControlInput)) { + f32 var_fv1 = (this->unk_AE8 * 0.018f) + 4.0f; + + if (this->stateFlags1 & PLAYER_STATE1_800) { + sPlayerControlInput = NULL; + } + + func_808477D0(play, this, sPlayerControlInput, fabsf(this->actor.velocity.y)); + Math_ScaledStepToS(&this->unk_AAA, -0x2710, 0x320); + + var_fv1 = CLAMP_MAX(var_fv1, 8.0f); + func_808481CC(play, this, var_fv1); + } +} + +void func_808519FC(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_20; + + func_8082F164(this, BTN_R); + if (((this->stateFlags1 & PLAYER_STATE1_400) || (this->skelAnime.curFrame <= 1.0f) || !func_80850734(play, this)) && + PlayerAnimation_Update(play, &this->skelAnime)) { + if (!(this->stateFlags1 & PLAYER_STATE1_400) || func_808482E0(play, this)) { + func_80848250(play, this); + func_808353DC(play, this); + func_8082DC64(play, this); + } + } else { + if ((this->stateFlags1 & PLAYER_STATE1_400) && PlayerAnimation_OnFrame(&this->skelAnime, 10.0f)) { + func_8082ECE0(this); + func_8082DC64(play, this); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 5.0f)) { + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_BREATH_DRINK); + } + } + + func_808475B4(this); + func_8084748C(this, &this->linearVelocity, 0.0f, this->actor.shape.rot.y); +} + +void func_80851B58(Player* this, PlayState* play) { + func_808475B4(this); + Math_StepToF(&this->linearVelocity, 0.0f, 0.4f); + if (PlayerAnimation_Update(play, &this->skelAnime) && (this->linearVelocity < 10.0f)) { + func_808353DC(play, this); + } +} + +void func_80851BD4(Player* this, PlayState* play) { + func_808475B4(this); + if (PlayerAnimation_Update(play, &this->skelAnime) && (this == GET_PLAYER(play))) { + func_80840770(play, this); + } + func_8084748C(this, &this->linearVelocity, 0.0f, this->actor.shape.rot.y); +} + +s32 func_80851C40(PlayState* play, Player* this) { + return ((play->sceneId == SCENE_MILK_BAR) && Audio_IsSequencePlaying(NA_BGM_BALLAD_OF_THE_WIND_FISH)) || + (((play->sceneId != SCENE_MILK_BAR) && (this->csMode == PLAYER_CSMODE_68)) || + ((play->msgCtx.msgMode == 0x12) || (play->msgCtx.msgMode == 0x13) || (play->msgCtx.msgMode == 0x14) || + ((play->msgCtx.ocarinaMode != 1) && + ((this->csMode == PLAYER_CSMODE_5) || (play->msgCtx.ocarinaMode == 3) || + play->msgCtx.ocarinaAction == 0x32)))); +} + +// Deku playing the pipes? The loops both overwrite unk_AF0[0].y,z and unk_AF0[1].x,y,z +void func_80851D30(PlayState* play, Player* this) { + f32* var_s0 = &this->unk_AF0[0].y; // TODO: what is going on around here in the struct? + Vec3f sp50; + + if (func_80851C40(play, this)) { + s32 i; + + if (this->skelAnime.mode != ANIMMODE_LOOP) { + func_8082DB60(play, this, D_8085D190[this->transformation]); + } + func_80124618(D_801C03A0, this->skelAnime.curFrame, &sp50); + + for (i = 0; i < 5; i++) { + *var_s0 = sp50.x; + var_s0++; + } + } else if (play->msgCtx.ocarinaMode == 1) { + if (play->msgCtx.unk12048 != 0xFF) { + var_s0[play->msgCtx.unk12048] = 1.2f; + func_8082DB90(play, this, D_8085D190[this->transformation]); + } else { + s32 i; + + for (i = 0; i < 5; i++) { + Math_StepToF(var_s0++, 1.0f, 0.04000001f); + } + } + } +} + +void func_80851EAC(Player* this) { + this->unk_B86[0] = -1; + this->unk_B86[1] = -1; + this->unk_B10[0] = 0.0f; +} + +struct_8085D714 D_8085D714[] = { + { 1, &gPlayerAnim_pg_gakkiplayA }, { 1, &gPlayerAnim_pg_gakkiplayL }, { 1, &gPlayerAnim_pg_gakkiplayD }, + { 0, &gPlayerAnim_pg_gakkiplayU }, { 0, &gPlayerAnim_pg_gakkiplayR }, +}; + +void func_80851EC8(PlayState* play, Player* this) { + struct_8085D714* temp3 = &D_8085D714[play->msgCtx.unk12048]; + f32* temp2 = &this->unk_B10[play->msgCtx.unk12048]; + s16* temp_a3 = &this->unk_B86[temp3->unk_0]; + + temp_a3[0] = play->msgCtx.unk12048; + temp2[0] = 3.0f; +} + +void func_80851F18(PlayState* play, Player* this) { + struct_8085D714* temp; + f32* temp_v0; + s32 i; + + i = this->unk_B86[0]; + if (i >= 0) { + temp = &D_8085D714[i]; + i = 0; + temp_v0 = &this->unk_B10[this->unk_B86[i]]; + + AnimationContext_SetLoadFrame(play, temp->unk_4, *temp_v0, this->skelAnime.limbCount, + this->skelAnime.morphTable); + AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->skelAnime.morphTable, D_8085BA08); + } + i = this->unk_B86[1]; + if (i >= 0) { + temp = &D_8085D714[i]; + i = 1; + temp_v0 = &this->unk_B10[this->unk_B86[i]]; + + AnimationContext_SetLoadFrame(play, temp->unk_4, *temp_v0, this->skelAnime.limbCount, + ALIGN16((uintptr_t)this->blendTableBuffer)); + AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + ALIGN16((uintptr_t)this->blendTableBuffer), D_8085BA20); + } + + temp_v0 = this->unk_B10; + for (i = 0; i < 5; i++) { + *temp_v0 += 1.0f; + if (*temp_v0 >= 9.0f) { + *temp_v0 = 8.0f; + if (this->unk_B86[0] == i) { + this->unk_B86[0] = -1; + } else if (this->unk_B86[1] == i) { + this->unk_B86[1] = -1; + } + } + temp_v0++; + } +} + +// Goron playing the drums? +void func_808521E0(PlayState* play, Player* this) { + if (func_80851C40(play, this)) { + if (this->skelAnime.animation != &gPlayerAnim_pg_gakkiplay) { + func_8082DB60(play, this, &gPlayerAnim_pg_gakkiplay); + } + + func_80124618(D_801C0490, this->skelAnime.curFrame, &this->unk_AF0[1]); + } else if (play->msgCtx.ocarinaMode == 1) { + if (play->msgCtx.unk12048 != 0xFF) { + func_80851EC8(play, this); + } + + func_80851F18(play, this); + } +} + +// Zora playing the guitar? +void func_80852290(PlayState* play, Player* this) { + if (func_80851C40(play, this)) { + if (this->skelAnime.mode != ANIMMODE_LOOP) { + func_8082DB60(play, this, D_8085D190[this->transformation]); + } + + this->unk_B8A = 8; + } else { + f32 sp3C; + s16 var_a1_3; + s16 sp38; + + if ((play->msgCtx.ocarinaMode == 1) && (play->msgCtx.unk12048 != 0xFF)) { + if ((this->unk_A90 != NULL) && (this->unk_A94 < 0.0f)) { + this->unk_A90->flags |= ACTOR_FLAG_20000000; + this->unk_A94 = 0.0f; + } + + func_8082DB90(play, this, D_8085D190[this->transformation]); + this->unk_B8A = 8; + } + + sPlayerControlInput = play->state.input; + func_800FF3A0(&sp3C, &sp38, sPlayerControlInput); + + if (BINANG_ADD(sp38, 0x4000) < 0) { + sp38 -= 0x8000; + sp3C = -sp3C; + } + + if (sp38 < -0x1F40) { + sp38 = -0x1F40; + } else if (sp38 > 0x2EE0) { + sp38 = 0x2EE0; + } + + var_a1_3 = (sp3C * -100.0f); + var_a1_3 = CLAMP_MAX(var_a1_3, 0xFA0); + Math_SmoothStepToS(&this->upperLimbRot.x, var_a1_3, 4, 0x7D0, 0); + Math_SmoothStepToS(&this->upperLimbRot.y, sp38, 4, 0x7D0, 0); + this->headLimbRot.x = -this->upperLimbRot.x; + this->unk_AA6 |= 0xC8; + + var_a1_3 = ABS_ALT(this->upperLimbRot.x); + if (var_a1_3 < 0x7D0) { + this->actor.shape.face = 0; + } else if (var_a1_3 < 0xFA0) { + this->actor.shape.face = 13; + } else { + this->actor.shape.face = 8; + } + } + + if (DECR(this->unk_B8A) != 0) { + this->unk_B86[0] += (s16)(this->upperLimbRot.x * 2.5f); + this->unk_B86[1] += (s16)(this->upperLimbRot.y * 3.0f); + } else { + this->unk_B86[0] = 0; + this->unk_B86[1] = 0; + } +} + +void func_8085255C(PlayState* play, Player* this) { + if (this->transformation == PLAYER_FORM_DEKU) { + func_80851D30(play, this); + } else if (this->transformation == PLAYER_FORM_GORON) { + func_808521E0(play, this); + } else if (this->transformation == PLAYER_FORM_ZORA) { + func_80852290(play, this); + } +} + +void func_808525C4(PlayState* play, Player* this) { + if (this->unk_AE8++ >= 3) { + if ((this->transformation == PLAYER_FORM_ZORA) || (this->transformation == PLAYER_FORM_DEKU)) { + func_8082E5A8(play, this, D_8085D190[this->transformation]); + } else if (this->transformation == PLAYER_FORM_GORON) { + func_80851EAC(this); + func_8082DB60(play, this, &gPlayerAnim_pg_gakkiwait); + } else { + func_8082DB60(play, this, D_8085D190[this->transformation]); + } + + this->unk_B48 = 1.0f; + } +} + +void func_8085269C(Player* this, PlayState* play) { + if ((this->unk_AA5 != PLAYER_UNKAA5_4) && ((PlayerAnimation_Update(play, &this->skelAnime) && + (this->skelAnime.animation == D_8085D17C[this->transformation])) || + ((this->skelAnime.mode == 0) && (this->unk_AE8 == 0)))) { + func_808525C4(play, this); + if (!(this->actor.flags & ACTOR_FLAG_20000000) || (this->unk_A90->id == ACTOR_EN_ZOT)) { + func_80152434(play, 1); + } + } else if (this->unk_AE8 != 0) { + if (play->msgCtx.ocarinaMode == 4) { + play->interfaceCtx.unk_222 = 0; + CutsceneManager_Stop(play->playerCsIds[PLAYER_CS_ID_ITEM_OCARINA]); + this->actor.flags &= ~ACTOR_FLAG_20000000; + + if ((this->talkActor != NULL) && (this->talkActor == this->unk_A90) && (this->unk_A94 >= 0.0f)) { + Player_TalkWithPlayer(play, this->talkActor); + } else if (this->tatlTextId < 0) { + this->talkActor = this->tatlActor; + this->tatlActor->textId = -this->tatlTextId; + Player_TalkWithPlayer(play, this->talkActor); + } else if (!func_80838A90(this, play)) { + func_80836A5C(this, play); + Player_AnimationPlayOnceReverse(play, this, D_8085D17C[this->transformation]); + } + } else { + s32 var_v1 = (play->msgCtx.ocarinaMode >= 0x1C) && (play->msgCtx.ocarinaMode < 0x27); + s32 pad[2]; + + if (var_v1 || (play->msgCtx.ocarinaMode == 0x16) || (play->msgCtx.ocarinaMode == 0x1A) || + (play->msgCtx.ocarinaMode == 0x18) || (play->msgCtx.ocarinaMode == 0x19)) { + if (play->msgCtx.ocarinaMode == 0x16) { + if (!func_8082DA90(play)) { + if (gSaveContext.save.saveInfo.playerData.deaths == 1) { + play->nextEntrance = ENTRANCE(CUTSCENE, 1); + } else { + play->nextEntrance = ENTRANCE(CUTSCENE, 0); + } + + gSaveContext.nextCutsceneIndex = 0xFFF7; + play->transitionTrigger = TRANS_TRIGGER_START; + } + } else { + Actor* actor; + + play->interfaceCtx.unk_222 = 0; + CutsceneManager_Stop(play->playerCsIds[PLAYER_CS_ID_ITEM_OCARINA]); + this->actor.flags &= ~ACTOR_FLAG_20000000; + + actor = Actor_Spawn(&play->actorCtx, play, var_v1 ? ACTOR_EN_TEST7 : ACTOR_EN_TEST6, + this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, + 0, play->msgCtx.ocarinaMode); + if (actor != NULL) { + this->stateFlags1 &= ~PLAYER_STATE1_20000000; + this->csMode = PLAYER_CSMODE_0; + func_8085B28C(play, NULL, PLAYER_CSMODE_19); + this->stateFlags1 |= PLAYER_STATE1_10000000 | PLAYER_STATE1_20000000; + } else { + func_80836A5C(this, play); + Player_AnimationPlayOnceReverse(play, this, D_8085D17C[this->transformation]); + } + } + } else if ((play->msgCtx.ocarinaMode == 3) && (play->msgCtx.lastPlayedSong == OCARINA_SONG_ELEGY)) { + play->interfaceCtx.unk_222 = 0; + CutsceneManager_Stop(play->playerCsIds[PLAYER_CS_ID_ITEM_OCARINA]); + + this->actor.flags &= ~ACTOR_FLAG_20000000; + func_80831760(play, this, func_80855A7C, 0); + this->stateFlags1 |= PLAYER_STATE1_10000000 | PLAYER_STATE1_20000000; + } else if (this->unk_AA5 == PLAYER_UNKAA5_4) { + f32 temp_fa0 = this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1].x; + f32 temp_fa1 = this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1].z; + f32 var_fv1; + + var_fv1 = sqrtf(SQ(temp_fa0) + SQ(temp_fa1)); + if (var_fv1 != 0.0f) { + var_fv1 = (var_fv1 - 100.0f) / var_fv1; + var_fv1 = CLAMP_MIN(var_fv1, 0.0f); + } + + this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1].x = temp_fa0 * var_fv1; + this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1].z = temp_fa1 * var_fv1; + } else { + func_8085255C(play, this); + } + } + } +} + +void func_80852B28(Player* this, PlayState* play) { + func_80832F24(this); + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_80836A98(this, &gPlayerAnim_link_normal_light_bom_end, play); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 3.0f)) { + if (Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ARROW, this->bodyPartsPos[PLAYER_BODYPART_RIGHT_HAND].x, + this->bodyPartsPos[PLAYER_BODYPART_RIGHT_HAND].y, + this->bodyPartsPos[PLAYER_BODYPART_RIGHT_HAND].z, 0xFA0, this->actor.shape.rot.y, 0, + ARROW_TYPE_DEKU_NUT) != NULL) { + Inventory_ChangeAmmo(ITEM_NUT, -1); + this->unk_D57 = 4; + } + + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_SWORD_N); + } +} + +AnimSfxEntry D_8085D73C[] = { + ANIMSFX(ANIMSFX_TYPE_FLOOR_JUMP, 87, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_VOICE, 87, NA_SE_VO_LI_CLIMB_END, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_VOICE, 69, NA_SE_VO_LI_AUTO_JUMP, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR_LAND, 123, NA_SE_NONE, STOP), +}; + +AnimSfxEntry D_8085D74C[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 13, NA_SE_VO_LI_AUTO_JUMP, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR_JUMP, 13, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR_LAND, 73, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR_LAND, 120, NA_SE_NONE, STOP), +}; + +void func_80852C04(Player* this, PlayState* play) { + func_8083249C(this); + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + if (this->unk_AE8 != 0) { + if (this->unk_AE8 > 1) { + this->unk_AE8--; + } + + if (func_808482E0(play, this) && (this->unk_AE8 == 1)) { + Player_SetModels(this, Player_ActionToModelGroup(this, this->itemAction)); + + if ((this->getItemDrawIdPlusOne == GID_REMAINS_ODOLWA + 1) || + (this->getItemDrawIdPlusOne == GID_REMAINS_GOHT + 1) || + (this->getItemDrawIdPlusOne == GID_REMAINS_GYORG + 1) || + (this->getItemDrawIdPlusOne == GID_REMAINS_TWINMOLD + 1)) { + Player_StopCutscene(this); + func_80848250(play, this); + this->stateFlags1 &= ~PLAYER_STATE1_20000000; + func_8085B28C(play, NULL, PLAYER_CSMODE_93); + } else { + s32 var_a2 = ((this->talkActor != NULL) && (this->exchangeItemId <= PLAYER_IA_MINUS1)) || + (this->stateFlags3 & PLAYER_STATE3_20); + + if (var_a2 || (gSaveContext.healthAccumulator == 0)) { + Player_StopCutscene(this); + if (var_a2) { + func_80848250(play, this); + this->exchangeItemId = PLAYER_IA_NONE; + if (!func_80847994(play, this)) { + Player_TalkWithPlayer(play, this->talkActor); + } + } else { + func_80848294(play, this); + } + } + } + } + } else { + func_8082E794(this); + + if ((this->getItemId == GI_STRAY_FAIRY) || (this->getItemId == GI_SKULL_TOKEN) || + (this->getItemId == GI_ICE_TRAP)) { + Player_StopCutscene(this); + this->stateFlags1 &= ~(PLAYER_STATE1_400 | PLAYER_STATE1_800); + if (this->getItemId == GI_STRAY_FAIRY) { + func_80839E74(this, play); + } else { + this->actor.colChkInfo.damage = 0; + func_80833B18(play, this, 3, 0.0f, 0.0f, 0, 20); + } + } else { + if (this->skelAnime.animation == &gPlayerAnim_link_normal_box_kick) { + func_8082DB90(play, this, + (this->transformation == PLAYER_FORM_DEKU) ? &gPlayerAnim_pn_getB + : &gPlayerAnim_link_demo_get_itemB); + } else { + func_8082DB90(play, this, + (this->transformation == PLAYER_FORM_DEKU) ? &gPlayerAnim_pn_getA + : &gPlayerAnim_link_demo_get_itemA); + } + + func_8082E920(play, this, + ANIM_FLAG_1 | ANIM_FLAG_UPDATE_Y | ANIM_FLAG_4 | ANIM_FLAG_8 | ANIM_FLAG_NOMOVE | + ANIM_FLAG_80); + Player_StopCutscene(this); + this->csId = play->playerCsIds[PLAYER_CS_ID_ITEM_GET]; + this->unk_AE8 = 2; + } + } + } else if (this->unk_AE8 == 0) { + if (this->transformation == PLAYER_FORM_HUMAN) { + Player_PlayAnimSfx(this, D_8085D73C); + } else if (this->transformation == PLAYER_FORM_DEKU) { + Player_PlayAnimSfx(this, D_8085D74C); + } + } else { + if ((this->skelAnime.animation == &gPlayerAnim_link_demo_get_itemB) || + (this->skelAnime.animation == &gPlayerAnim_pn_getB)) { + Math_ScaledStepToS(&this->actor.shape.rot.y, + BINANG_ADD(Camera_GetCamDirYaw(play->cameraPtrs[play->activeCamId]), 0x8000), 0xFA0); + } else if ((this->skelAnime.animation == &gPlayerAnim_pn_getA) && + PlayerAnimation_OnFrame(&this->skelAnime, 10.0f)) { + Player_AnimSfx_PlayFloorLand(this); + } + + if (PlayerAnimation_OnFrame(&this->skelAnime, 21.0f)) { + func_8082ECE0(this); + } + } +} + +AnimSfxEntry D_8085D75C[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 5, NA_SE_VO_LI_AUTO_JUMP, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR_LAND, 15, NA_SE_NONE, STOP), +}; + +void func_80852FD4(Player* this, PlayState* play) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + if (this->unk_AE7 == 0) { + if (DECR(this->unk_AE8) == 0) { + this->unk_AE7 = 1; + this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; + } + } else { + func_80839E74(this, play); + } + } else if ((this->transformation == PLAYER_FORM_FIERCE_DEITY) && + PlayerAnimation_OnFrame(&this->skelAnime, 158.0f)) { + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_SWORD_N); + } else if (this->transformation != PLAYER_FORM_FIERCE_DEITY) { + Player_PlayAnimSfx(this, D_8085D75C); + } else { + func_808484CC(this); + } +} + +Vec3f D_8085D764 = { 0.0f, 24.0f, 19.0f }; +Vec3f D_8085D770 = { 0.0f, 0.0f, 2.0f }; +Vec3f D_8085D77C = { 0.0f, 0.0f, -0.2f }; + +Color_RGBA8 D_8085D788 = { 255, 255, 255, 255 }; +Color_RGBA8 D_8085D78C = { 255, 255, 255, 255 }; + +void func_808530E0(PlayState* play, Player* this) { + Vec3f pos; + Vec3f velocity; + Vec3f accel; + + Player_TranslateAndRotateY(this, &this->actor.world.pos, &D_8085D764, &pos); + Player_TranslateAndRotateY(this, &gZeroVec3f, &D_8085D770, &velocity); + Player_TranslateAndRotateY(this, &gZeroVec3f, &D_8085D77C, &accel); + func_800B0EB0(play, &pos, &velocity, &accel, &D_8085D788, &D_8085D78C, 40, 10, 10); +} + +u8 D_8085D790[] = { + 1, // PLAYER_IA_BOTTLE_POTION_RED + 1 | 2, // PLAYER_IA_BOTTLE_POTION_BLUE + 2, // PLAYER_IA_BOTTLE_POTION_GREEN + 4, // PLAYER_IA_BOTTLE_MILK + 4, // PLAYER_IA_BOTTLE_MILK_HALF + 1 | 2, // PLAYER_IA_BOTTLE_CHATEAU +}; + +void func_80853194(Player* this, PlayState* play) { + func_808323C0(this, play->playerCsIds[PLAYER_CS_ID_ITEM_BOTTLE]); + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + if (this->unk_AE8 == 0) { + if (this->itemAction == PLAYER_IA_BOTTLE_POE) { + s32 health = Rand_S16Offset(-1, 3); + + if (health == 0) { + health = 3; + } + if ((health < 0) && (gSaveContext.save.saveInfo.playerData.health <= 0x10)) { + health = 3; + } + + if (health < 0) { + Health_ChangeBy(play, -0x10); + } else { + gSaveContext.healthAccumulator = health * 0x10; + } + } else { + s32 temp_v1 = D_8085D790[this->itemAction - PLAYER_IA_BOTTLE_POTION_RED]; + + if (temp_v1 & 1) { + gSaveContext.healthAccumulator = 0x140; + } + if (temp_v1 & 2) { + Magic_Add(play, MAGIC_FILL_TO_CAPACITY); + } + if (temp_v1 & 4) { + gSaveContext.healthAccumulator = 0x50; + } + + if (this->itemAction == PLAYER_IA_BOTTLE_CHATEAU) { + SET_WEEKEVENTREG(WEEKEVENTREG_DRANK_CHATEAU_ROMANI); + } + + gSaveContext.jinxTimer = 0; + } + + func_8082DB60(play, this, + (this->transformation == PLAYER_FORM_DEKU) ? &gPlayerAnim_pn_drink + : &gPlayerAnim_link_bottle_drink_demo_wait); + this->unk_AE8 = 1; + + //! FAKE + dummy_label_235515:; + } else if (this->unk_AE8 < 0) { + this->unk_AE8++; + if (this->unk_AE8 == 0) { + this->unk_AE8 = 3; + this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; + } else if (this->unk_AE8 == -6) { + func_808530E0(play, this); + } + } else { + Player_StopCutscene(this); + func_80839E74(this, play); + } + } else if (this->unk_AE8 == 1) { + if ((gSaveContext.healthAccumulator == 0) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { + if (this->transformation == PLAYER_FORM_DEKU) { + PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_pn_drinkend, 2.0f / 3.0f, 0.0f, 5.0f, 2, + -6.0f); + this->unk_AE8 = -7; + } else { + func_8082E4A4(play, this, &gPlayerAnim_link_bottle_drink_demo_end); + this->unk_AE8 = 2; + } + + Player_UpdateBottleHeld(play, this, + (this->itemAction == PLAYER_IA_BOTTLE_MILK) ? ITEM_MILK_HALF : ITEM_BOTTLE, + PLAYER_IA_BOTTLE_EMPTY); + } + + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_DRINK - SFX_FLAG); + } else if ((this->unk_AE8 == 2) && PlayerAnimation_OnFrame(&this->skelAnime, 29.0f)) { + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_BREATH_DRINK); + } +} + +struct_8085D798 D_8085D798[] = { + { ACTOR_EN_ELF, 2, ITEM_FAIRY, PLAYER_IA_BOTTLE_FAIRY, 0x5E }, + { ACTOR_EN_FISH, -1, ITEM_FISH, PLAYER_IA_BOTTLE_FISH, 0x62 }, + { ACTOR_EN_INSECT, -1, ITEM_BUG, PLAYER_IA_BOTTLE_BUG, 0x63 }, + { ACTOR_EN_MUSHI2, -1, ITEM_BUG, PLAYER_IA_BOTTLE_BUG, 0x63 }, + { ACTOR_EN_TEST5, 0, ITEM_SPRING_WATER, PLAYER_IA_BOTTLE_SPRING_WATER, 0x67 }, + { ACTOR_EN_TEST5, 1, ITEM_HOT_SPRING_WATER, PLAYER_IA_BOTTLE_HOT_SPRING_WATER, 0x68 }, + { ACTOR_BG_GORON_OYU, -1, ITEM_HOT_SPRING_WATER, PLAYER_IA_BOTTLE_HOT_SPRING_WATER, 0x68 }, + { ACTOR_EN_ZORAEGG, -1, ITEM_ZORA_EGG, PLAYER_IA_BOTTLE_ZORA_EGG, 0x69 }, + { ACTOR_EN_DNP, -1, ITEM_DEKU_PRINCESS, PLAYER_IA_BOTTLE_DEKU_PRINCESS, 0x5F }, + { ACTOR_EN_OT, -1, ITEM_SEAHORSE, PLAYER_IA_BOTTLE_SEAHORSE, 0x6E }, + { ACTOR_OBJ_KINOKO, -1, ITEM_MUSHROOM, PLAYER_IA_BOTTLE_SEAHORSE, 0x6B }, + { ACTOR_EN_POH, -1, ITEM_POE, PLAYER_IA_BOTTLE_POE, 0x65 }, + { ACTOR_EN_BIGPO, -1, ITEM_BIG_POE, PLAYER_IA_BOTTLE_BIG_POE, 0x66 }, + { ACTOR_EN_ELF, 6, ITEM_FAIRY, PLAYER_IA_BOTTLE_FAIRY, 0x5E }, +}; + +void func_808534C0(Player* this, PlayState* play) { + struct_8085D200* sp24 = &D_8085D200[this->unk_AE8]; + + func_80832F24(this); + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + if (this->unk_AE7 != 0) { + func_808323C0(this, play->playerCsIds[PLAYER_CS_ID_ITEM_SHOW]); + + if (this->unk_AE8 == 0) { + Message_StartTextbox(play, D_8085D798[this->unk_AE7 - 1].textId, &this->actor); + + Audio_PlayFanfare(NA_BGM_GET_ITEM | 0x900); + this->unk_AE8 = 1; + } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { + Actor* talkActor; + + this->unk_AE7 = 0; + Player_StopCutscene(this); + func_800E0238(Play_GetCamera(play, CAM_ID_MAIN)); + + talkActor = this->talkActor; + if ((talkActor != NULL) && (this->exchangeItemId <= PLAYER_IA_MINUS1)) { + Player_TalkWithPlayer(play, talkActor); + } + } + } else { + func_80839E74(this, play); + } + } else { + if (this->unk_AE7 == 0) { + s32 temp_ft5 = this->skelAnime.curFrame - sp24->unk_8; + + if ((temp_ft5 >= 0) && (sp24->unk_9 >= temp_ft5)) { + if ((this->unk_AE8 != 0) && (temp_ft5 == 0)) { + Player_PlaySfx(this, NA_SE_IT_SCOOP_UP_WATER); + } + + if (func_8012364C(play, this, this->heldItemButton) == ITEM_BOTTLE) { + Actor* interactRangeActor = this->interactRangeActor; + + if (interactRangeActor != NULL) { + struct_8085D798* entry = D_8085D798; + s32 i; + + for (i = 0; i < ARRAY_COUNT(D_8085D798); i++) { + if (((interactRangeActor->id == entry->actorId) && + ((entry->actorParams < 0) || (interactRangeActor->params == entry->actorParams)))) { + break; + } + entry++; + } + + if (i < ARRAY_COUNT(D_8085D798)) { + this->unk_AE7 = i + 1; + this->unk_AE8 = 0; + this->stateFlags1 |= PLAYER_STATE1_10000000 | PLAYER_STATE1_20000000; + interactRangeActor->parent = &this->actor; + Player_UpdateBottleHeld(play, this, entry->itemId, entry->itemAction); + func_8082DB90(play, this, sp24->unk_4); + } + } + } + } + } + + if (this->skelAnime.curFrame <= 7.0f) { + this->stateFlags3 |= PLAYER_STATE3_800; + } + } +} + +Vec3f D_8085D7EC = { 0.0f, 0.0f, 5.0f }; + +void func_80853754(Player* this, PlayState* play) { + func_808323C0(this, play->playerCsIds[PLAYER_CS_ID_ITEM_BOTTLE]); + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + Player_StopCutscene(this); + func_80839E74(this, play); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 37.0f)) { + s32 sp2C = 8; + + Player_PlaySfx(this, NA_SE_EV_BOTTLE_CAP_OPEN); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_AUTO_JUMP); + if (this->itemAction == PLAYER_IA_BOTTLE_FAIRY) { + Player_UpdateBottleHeld(play, this, ITEM_BOTTLE, PLAYER_IA_BOTTLE_EMPTY); + Player_PlaySfx(this, NA_SE_EV_FIATY_HEAL - SFX_FLAG); + sp2C = 1; + } + + Player_SpawnFairy(play, this, &this->leftHandWorld.pos, &D_8085D7EC, sp2C); + } +} + +void func_80853850(Player* this, PlayState* play) { + static Vec3f D_8085D7F8 = { 10.0f, 268 * 0.1f, 30.0f }; + static s8 D_8085D804[PLAYER_FORM_MAX] = { + 0x2D, // PLAYER_FORM_FIERCE_DEITY + 0x4B, // PLAYER_FORM_GORON + 0x37, // PLAYER_FORM_ZORA + 0x23, // PLAYER_FORM_DEKU + 0x28, // PLAYER_FORM_HUMAN + }; + static struct_8085D80C D_8085D80C[] = { + { ACTOR_EN_FISH, 0 }, // PLAYER_BOTTLE_FISH + { ACTOR_OBJ_AQUA, 0 }, // PLAYER_BOTTLE_SPRING_WATER + { ACTOR_OBJ_AQUA, 1 }, // PLAYER_BOTTLE_HOT_SPRING_WATER + { ACTOR_EN_ZORAEGG, 0x11 }, // PLAYER_BOTTLE_ZORA_EGG + { ACTOR_EN_DNP, 1 }, // PLAYER_BOTTLE_DEKU_PRINCESS + { ACTOR_EN_MUSHI2, 0 }, // PLAYER_BOTTLE_GOLD_DUST + { ACTOR_EN_MUSHI2, 0 }, // PLAYER_BOTTLE_1C + { ACTOR_EN_OT, 0x8000 }, // PLAYER_BOTTLE_SEAHORSE + { ACTOR_EN_MUSHI2, 0 }, // PLAYER_BOTTLE_MUSHROOM + { ACTOR_EN_MUSHI2, 0 }, // PLAYER_BOTTLE_HYLIAN_LOACH + { ACTOR_EN_MUSHI2, 0 }, // PLAYER_BOTTLE_BUG + }; + static AnimSfxEntry D_8085D838[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 38, NA_SE_VO_LI_AUTO_JUMP, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 40, NA_SE_EV_BOTTLE_CAP_OPEN, STOP), + }; + + CollisionPoly* sp6C; + s32 sp68; + Vec3f sp5C; + f32 temp_fa0; + f32 temp_fv0; + f32 temp_fv1; + struct_8085D80C* sp4C; + + D_8085D7F8.z = D_8085D804[this->transformation]; + if (func_80835D58(play, this, &D_8085D7F8, &sp6C, &sp68, &sp5C)) { + temp_fv1 = this->actor.world.pos.x - sp5C.x; + temp_fa0 = this->actor.world.pos.z - sp5C.z; + temp_fv0 = sqrtf(SQ(temp_fv1) + SQ(temp_fa0)); + + if (temp_fv0 != 0.0f) { + temp_fv0 = 3.0f / temp_fv0; + + this->actor.world.pos.x = this->actor.world.pos.x + (temp_fv1 * temp_fv0); + this->actor.world.pos.z = this->actor.world.pos.z + (temp_fa0 * temp_fv0); + } + } + + func_80832F24(this); + func_8083249C(this); + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + Player_StopCutscene(this); + if (!func_80838A90(this, play)) { + func_80839E74(this, play); + } + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 76.0f)) { + sp4C = &D_8085D80C[GET_BOTTLE_FROM_IA(this->itemAction) - 1]; + + Actor_Spawn(&play->actorCtx, play, sp4C->actorId, + (Math_SinS(this->actor.shape.rot.y) * 5.0f) + this->leftHandWorld.pos.x, this->leftHandWorld.pos.y, + (Math_CosS(this->actor.shape.rot.y) * 5.0f) + this->leftHandWorld.pos.z, 0x4000, + this->actor.shape.rot.y, 0, sp4C->params); + Player_UpdateBottleHeld(play, this, ITEM_BOTTLE, PLAYER_IA_BOTTLE_EMPTY); + } else { + Player_PlayAnimSfx(this, D_8085D838); + } +} + +AnimSfxEntry D_8085D840[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 30, NA_SE_PL_PUT_OUT_ITEM, STOP), +}; + +void func_80853A5C(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_20; + this->stateFlags3 |= PLAYER_STATE3_4000000; + + func_8083249C(this); + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + if (this->exchangeItemId == PLAYER_IA_NONE) { + Actor* talkActor = this->talkActor; + + Player_StopCutscene(this); + this->getItemDrawIdPlusOne = GID_NONE + 1; + + if ((talkActor->textId != 0) && (talkActor->textId != 0xFFFF)) { + this->actor.flags |= ACTOR_FLAG_TALK_REQUESTED; + } + Player_TalkWithPlayer(play, talkActor); + } else { + GetItemEntry* giEntry = &sGetItemTable[D_8085D1A4[this->exchangeItemId] - 1]; + + if (Player_BottleFromIA(this, this->itemAction) <= PLAYER_BOTTLE_NONE) { + this->getItemDrawIdPlusOne = ABS_ALT(giEntry->gid); + } + + if (this->unk_AE8 == 0) { + if ((this->actor.textId != 0) && (this->actor.textId != 0xFFFF)) { + Message_StartTextbox(play, this->actor.textId, &this->actor); + } + + this->unk_AE8 = 1; + } else if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { + Player_StopCutscene(this); + this->getItemDrawIdPlusOne = GID_NONE + 1; + this->actor.flags &= ~ACTOR_FLAG_TALK_REQUESTED; + func_80839E74(this, play); + this->unk_B5E = 0xA; + } + } + } else if (this->unk_AE8 >= 0) { + if ((Player_BottleFromIA(this, this->itemAction) > PLAYER_BOTTLE_NONE) && + PlayerAnimation_OnFrame(&this->skelAnime, 36.0f)) { + Player_SetModels(this, PLAYER_MODELGROUP_BOTTLE); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 2.0f)) { + GetItemEntry* giEntry = &sGetItemTable[D_8085D1A4[this->itemAction] - 1]; + + func_80838830(this, giEntry->objectId); + } + Player_PlayAnimSfx(this, D_8085D840); + } + + if ((this->unk_AE7 == 0) && (this->targetedActor != NULL)) { + this->currentYaw = func_8083C62C(this, 0); + this->actor.shape.rot.y = this->currentYaw; + } +} + +void func_80853CC0(Player* this, PlayState* play) { + this->stateFlags2 |= (PLAYER_STATE2_20 | PLAYER_STATE2_40); + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + Player_AnimationPlayLoop(play, this, &gPlayerAnim_link_normal_re_dead_attack_wait); + } + + if (play->sceneId != SCENE_SEA_BS) { + func_8082F164(this, BTN_R); + } + + if (func_8082DE88(this, 0, 0x64)) { + func_80836988(this, play); + this->stateFlags2 &= ~PLAYER_STATE2_80; + } +} + +void func_80853D68(Player* this, PlayState* play) { + CollisionPoly* floorPoly; + f32 var_fv0; + f32 temp_fv1; + f32 var_fa0; + s16 downwardSlopeYaw; + s16 var_v0; + Vec3f slopeNormal; + + this->stateFlags2 |= (PLAYER_STATE2_20 | PLAYER_STATE2_40); + PlayerAnimation_Update(play, &this->skelAnime); + func_8083FBC4(play, this); + func_8019F780(&this->actor.projectedPos, Player_GetFloorSfx(this, NA_SE_PL_SLIP_LEVEL - SFX_FLAG), + this->actor.speed); + + if (func_80838A90(this, play)) { + return; + } + + if ((this->transformation == PLAYER_FORM_GORON) && func_8083A114(this, play)) { + return; + } + + floorPoly = this->actor.floorPoly; + if (floorPoly == NULL) { + func_80833AA0(this, play); + return; + } + + Actor_GetSlopeDirection(floorPoly, &slopeNormal, &downwardSlopeYaw); + var_v0 = downwardSlopeYaw; + if (this->unk_AE7 != 0) { + var_v0 = downwardSlopeYaw + 0x8000; + } + if (this->linearVelocity < 0.0f) { + downwardSlopeYaw += 0x8000; + } + + var_fv0 = (1.0f - slopeNormal.y) * 40.0f; + var_fv0 = CLAMP(var_fv0, 0.0f, 10.0f); + + temp_fv1 = var_fv0 * var_fv0 * 0.015f; + var_fa0 = slopeNormal.y * 0.01f; + if (SurfaceType_GetFloorEffect(&play->colCtx, floorPoly, this->actor.floorBgId) != FLOOR_EFFECT_1) { + var_fv0 = 0.0f; + var_fa0 = slopeNormal.y * 10.0f; + } + temp_fv1 = CLAMP_MIN(temp_fv1, 1.0f); + + if (Math_AsymStepToF(&this->linearVelocity, var_fv0, temp_fv1, var_fa0) && (var_fv0 == 0.0f)) { + func_80836A98(this, + (this->unk_AE7 == 0) ? D_8085BE84[PLAYER_ANIMGROUP_41][this->modelAnimType] + : D_8085BE84[PLAYER_ANIMGROUP_42][this->modelAnimType], + play); + } + + Math_SmoothStepToS(&this->currentYaw, downwardSlopeYaw, 0xA, 0xFA0, 0x320); + Math_ScaledStepToS(&this->actor.shape.rot.y, var_v0, 0x7D0); +} + +void func_80859CE0(PlayState* play, Player* this, s32 arg2); + +void func_80854010(Player* this, PlayState* play) { + if ((DECR(this->unk_AE8) == 0) && func_808387A0(play, this)) { + func_80859CE0(play, this, 0); + Player_SetAction(play, this, func_8085B08C, 0); + func_8085B08C(this, play); + } +} + +void func_808540A0(Player* this, PlayState* play) { + Player_SetAction(play, this, func_80854010, 0); + this->unk_AE8 = 0x28; + Actor_Spawn(&play->actorCtx, play, ACTOR_DEMO_KANKYO, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0x10); +} + +void Player_Cutscene_SetPosAndYawToStart(Player* this, CsCmdActorCue* playerAction); + +void func_80854118(Player* this, PlayState* play) { + if (D_80862B18 < 150.0f) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + if (this->unk_AE8 == 0) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->skelAnime.endFrame = this->skelAnime.animLength - 1.0f; + Player_AnimSfx_PlayFloorLand(this); + this->unk_AE8 = 1; + } + } else { + func_8085B384(this, play); + } + } + + Math_SmoothStepToF(&this->actor.velocity.y, 2.0f, 0.3f, 8.0f, 0.5f); + } + + if (play->csCtx.state != CS_STATE_IDLE) { + if (play->csCtx.playerCue != NULL) { + s32 pad; + f32 sp28 = this->actor.world.pos.y; + + Player_Cutscene_SetPosAndYawToStart(this, play->csCtx.playerCue); + this->actor.world.pos.y = sp28; + } + } +} + +void func_8085421C(Player* this, PlayState* play) { + if (this->skelAnime.animation == NULL) { + this->stateFlags2 |= PLAYER_STATE2_4000; + } else { + PlayerAnimation_Update(play, &this->skelAnime); + if ((this->skelAnime.animation == &gPlayerAnim_link_derth_rebirth) && + PlayerAnimation_OnFrame(&this->skelAnime, 60.0f)) { + Player_AnimSfx_PlayFloor(this, NA_SE_PL_BOUND); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_DAMAGE_S); + } + } + + if ((this->unk_AE8++ >= 9) && !func_8082DA90(play)) { + if (this->unk_AE7 != 0) { + if (this->unk_AE7 < 0) { + func_80169FDC(&play->state); + } else { + func_80169EFC(&play->state); + } + if (!SurfaceType_IsWallDamage(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId)) { + gSaveContext.respawnFlag = -5; + } + + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + play_sound(NA_SE_OC_ABYSS); + } else { + play->transitionType = TRANS_TYPE_FADE_BLACK; + gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; + gSaveContext.seqId = (u8)NA_BGM_DISABLED; + gSaveContext.ambienceId = AMBIENCE_ID_DISABLED; + } + + play->transitionTrigger = TRANS_TRIGGER_START; + } +} + +void func_8085437C(Player* this, PlayState* play) { + func_808365DC(this, play); +} + +void func_8085439C(Player* this, PlayState* play) { + this->actor.gravity = -1.0f; + PlayerAnimation_Update(play, &this->skelAnime); + + if (this->actor.velocity.y < 0.0f) { + func_80833AA0(this, play); + } else if (this->actor.velocity.y < 6.0f) { + Math_StepToF(&this->linearVelocity, 3.0f, 0.5f); + } +} + +void func_80854430(Player* this, PlayState* play) { + if (play->unk_1887C < 0) { + play->unk_1887C = 0; + func_80839ED0(this, play); + } else if (this->unk_AE7 == 0) { + if ((play->sceneId != SCENE_20SICHITAI) && CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_B)) { + play->unk_1887C = 10; + func_80847880(play, this); + Player_SetAction(play, this, func_80854430, 1); + this->unk_AE7 = 1; + } else { + play->unk_1887C = 0; + func_80847190(play, this, 0); + + if (play->actorCtx.flags & ACTORCTX_FLAG_PICTO_BOX_ON) { + this->stateFlags1 |= PLAYER_STATE1_100000; + func_8083868C(play, this); + } else { + this->stateFlags1 &= ~PLAYER_STATE1_100000; + if ((play->sceneId == SCENE_20SICHITAI) && + (func_8012364C(play, this, func_8082FDC4()) == ITEM_PICTO_BOX)) { + s32 requiredScopeTemp; + + play->actorCtx.flags |= ACTORCTX_FLAG_PICTO_BOX_ON; + } + } + } + } else if (CHECK_BTN_ANY(sPlayerControlInput->press.button, + BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP | BTN_R | BTN_A)) { + play->unk_1887C = -1; + func_80854614(this, play); + Player_SetAction(play, this, func_80854430, 0); + this->unk_AE7 = 0; + } else { + play->unk_1887C = 10; + func_80854614(this, play); + } +} + +void func_80854614(Player* this, PlayState* play) { + this->unk_AA5 = PLAYER_UNKAA5_3; + func_8083868C(play, this); + PlayerAnimation_Update(play, &this->skelAnime); + func_8083216C(this, play); + this->upperLimbRot.y = func_80847190(play, this, 1) - this->actor.shape.rot.y; + this->unk_AA6 |= 0x80; + + if (play->unk_1887C < 0) { + play->unk_1887C++; + if (play->unk_1887C == 0) { + func_80839ED0(this, play); + } + } +} + +void func_808546D0(Player* this, PlayState* play) { + if (this->unk_AE7 >= 0) { + if (this->unk_AE7 < 6) { + this->unk_AE7++; + } else { + this->unk_B48 = (this->unk_AE7 >> 1) * 22.0f; + if (func_8082DE88(this, 1, 0x64)) { + this->unk_AE7 = -1; + EffectSsIcePiece_SpawnBurst(play, &this->actor.world.pos, this->actor.scale.x); + Player_PlaySfx(this, NA_SE_PL_ICE_BROKEN); + } + + if (this->transformation == PLAYER_FORM_ZORA) { + func_80834104(play, this); + this->skelAnime.animation = NULL; + this->unk_AE8 = -0x28; + this->unk_AE7 = 1; + this->linearVelocity = 0.0f; + } else if (play->gameplayFrames % 4 == 0) { + Player_InflictDamage(play, -1); + } + } + + this->stateFlags2 |= PLAYER_STATE2_4000; + } else if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_80836988(this, play); + func_808339B4(this, 20); + } +} + +void func_80854800(Player* this, PlayState* play) { + PlayerAnimation_Update(play, &this->skelAnime); + func_808345A8(this); + + if (((this->unk_AE8 % 25) != 0) || (func_808339D4(play, this, -1) != 0)) { + if (DECR(this->unk_AE8) == 0) { + func_80836988(this, play); + } + } + + this->shockTimer = 40; + func_800B8F98(&this->actor, this->ageProperties->voiceSfxIdOffset + (NA_SE_VO_LI_TAKEN_AWAY - SFX_FLAG)); +} + +void func_808548B8(Player* this, PlayState* play) { + AttackAnimInfo* attackInfoEntry = &sMeleeAttackAnimInfo[this->meleeWeaponAnimation]; + + if (this->skelAnime.curFrame < (this->skelAnime.endFrame - 6.0f)) { + this->stateFlags2 |= PLAYER_STATE2_20; + } + + if (func_808401F4(play, this)) { + return; + } + + if (this->linearVelocity >= 0.0f) { + func_8083FCF0(play, this, (this->transformation == PLAYER_FORM_GORON) ? 5.0f : 0.0f, attackInfoEntry->unk_C, + attackInfoEntry->unk_D); + } + + if ((this->meleeWeaponAnimation == PLAYER_MWA_GORON_PUNCH_LEFT) || + (this->meleeWeaponAnimation == PLAYER_MWA_GORON_PUNCH_RIGHT)) { + this->unk_3D0.unk_00 = 3; + } + + //! @bug Lunge Storage: If this block is prevented from running at the end of an animation that produces a lunge, + //! the prepared lunge will be retained until next time execution passes through here, which usually means the next + //! sword slash. + if ((this->stateFlags2 & PLAYER_STATE2_40000000) && PlayerAnimation_OnFrame(&this->skelAnime, 0.0f)) { + this->linearVelocity = 15.0f; + this->stateFlags2 &= ~PLAYER_STATE2_40000000; + } + + if (this->linearVelocity > 12.0f) { + func_8083FBC4(play, this); + } + + Math_StepToF(&this->linearVelocity, 0.0f, 5.0f); + func_8083A548(this); + + if (PlayerAnimation_Update(play, &this->skelAnime) || + ((this->meleeWeaponAnimation >= PLAYER_MWA_FLIPSLASH_FINISH) && + (this->meleeWeaponAnimation <= PLAYER_MWA_ZORA_JUMPKICK_FINISH) && (this->skelAnime.curFrame > 2.0f) && + func_808333CC(this))) { + D_80862B48 = this->unk_AE8; + + if (!func_80848570(this, play)) { + PlayerAnimationHeader* anim = func_80123420(this) ? attackInfoEntry->unk_8 : attackInfoEntry->unk_4; + + func_8082DC38(this); + + if (anim == NULL) { + this->skelAnime.moveFlags &= ~8; + func_8085B384(this, play); + } else { + u8 moveFlags = this->skelAnime.moveFlags; + + if (this->transformation == PLAYER_FORM_ZORA) { + if (func_8083A580(this, play)) { + anim = this->unk_284.animation; + } + this->unk_ADC = 0; + } else if ((anim == &gPlayerAnim_link_fighter_Lpower_jump_kiru_end) && + (this->modelAnimType != PLAYER_ANIMTYPE_3)) { + anim = &gPlayerAnim_link_fighter_power_jump_kiru_end; + } + + this->skelAnime.moveFlags = 0; + Player_SetAction(play, this, func_80849FE0, 1); + func_8082EC9C(play, this, anim); + this->currentYaw = this->actor.shape.rot.y; + this->skelAnime.moveFlags = moveFlags; + } + this->stateFlags3 |= PLAYER_STATE3_8; + } + } else if (((this->transformation == PLAYER_FORM_ZORA) && + (this->meleeWeaponAnimation != PLAYER_MWA_ZORA_PUNCH_KICK) && + (this->meleeWeaponAnimation != PLAYER_MWA_ZORA_JUMPKICK_FINISH)) || + ((this->transformation == PLAYER_FORM_GORON) && + (this->meleeWeaponAnimation != PLAYER_MWA_GORON_PUNCH_BUTT))) { + this->unk_AE8 |= CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_B) ? 1 : 0; + } +} + +void func_80854C70(Player* this, PlayState* play) { + PlayerAnimation_Update(play, &this->skelAnime); + func_80832F24(this); + + if (this->skelAnime.curFrame >= 6.0f) { + func_80836988(this, play); + } +} + +// Array colour interpolation +// arg0 is the interpolation parameter +// arg1,5,9 are out colours +// arg2,6,0xA are first values +// arg3,7,0xB are second values +// arg4,8,0xC are subtracted after interpolation +void func_80854CD0(f32 arg0, s16* arg1, u8* arg2, u8* arg3, u8* arg4, s16* arg5, u8* arg6, u8* arg7, u8* arg8, + s16* arg9, u8* argA, u8* argB, u8* argC) { + s32 i; + + for (i = 0; i < 3; i++) { + *arg1 = ((s32)((*arg2 - *arg3) * arg0) + *arg3) - *arg4; + *arg5 = ((s32)((*arg6 - *arg7) * arg0) + *arg7) - *arg8; + *arg9 = ((s32)((*argA - *argB) * arg0) + *argB) - *argC; + + arg1++; + arg2++; + arg3++; + arg4++; + arg5++; + arg6++; + arg7++; + arg8++; + arg9++; + argA++; + argB++; + argC++; + } +} + +// Black, probably in-function static +u8 D_8085D844[] = { 0, 0, 0 }; + +// arg1 is the colour interpolation parameter +void func_80854EFC(PlayState* play, f32 arg1, struct_8085D848_unk_00* arg2) { + struct_8085D848_unk_00 sp70; + struct_8085D848_unk_00* var_t0; + struct_8085D848_unk_00* var_v1; + u8* var_t3; + u8* var_t4; + u8* new_var; + s32 pad[4]; + + new_var = play->envCtx.unk_C4.diffuseColor1; + sp70.fogNear = play->envCtx.unk_C4.fogNear; + sp70.fogColor[0] = play->envCtx.unk_C4.fogColor[0]; + sp70.fogColor[1] = play->envCtx.unk_C4.fogColor[1]; + sp70.fogColor[2] = play->envCtx.unk_C4.fogColor[2]; + sp70.ambientColor[0] = play->envCtx.unk_C4.ambientColor[0]; + sp70.ambientColor[1] = play->envCtx.unk_C4.ambientColor[1]; + sp70.ambientColor[2] = play->envCtx.unk_C4.ambientColor[2]; + + if (arg1 <= 1.0f) { + arg1 -= 0.0f; + + var_v1 = &arg2[0]; + var_t0 = &sp70; + var_t3 = D_8085D844; + var_t4 = new_var; + } else if (arg1 <= 2.0f) { + arg1 -= 1.0f; + var_v1 = &arg2[1]; + var_t0 = &arg2[0]; + var_t3 = D_8085D844; + var_t4 = D_8085D844; + + } else if (arg1 <= 3.0f) { + arg1 -= 2.0f; + var_v1 = &arg2[2]; + var_t0 = &arg2[1]; + var_t3 = D_8085D844; + var_t4 = D_8085D844; + + } else { + arg1 -= 3.0f; + var_v1 = &sp70; + var_t0 = &arg2[2]; + var_t3 = new_var; + var_t4 = D_8085D844; + } + + play->envCtx.lightSettings.fogNear = + ((s16)((var_v1->fogNear - var_t0->fogNear) * arg1) + var_t0->fogNear) - play->envCtx.unk_C4.fogNear; + + func_80854CD0(arg1, play->envCtx.lightSettings.fogColor, var_v1->fogColor, var_t0->fogColor, + play->envCtx.unk_C4.fogColor, play->envCtx.lightSettings.ambientColor, var_v1->ambientColor, + var_t0->ambientColor, play->envCtx.unk_C4.ambientColor, play->envCtx.lightSettings.diffuseColor1, + var_t3, var_t4, new_var); +} + +struct_8085D848 D_8085D848[] = { + { + { + { 650, { 0, 0, 0 }, { 10, 0, 30 } }, + { 300, { 200, 200, 255 }, { 0, 0, 0 } }, + { 600, { 0, 0, 0 }, { 0, 0, 200 } }, + }, + { + { { -40.0f, 20.0f, -10.0f }, { 120, 200, 255 }, 1000 }, + { { 0.0f, -10.0f, 0.0f }, { 255, 255, 255 }, 5000 }, + { { -10.0f, 4.0f, 3.0f }, { 200, 200, 255 }, 5000 }, + }, + }, + { + { + { 650, { 0, 0, 0 }, { 10, 0, 30 } }, + { 300, { 200, 200, 255 }, { 0, 0, 0 } }, + { 600, { 0, 0, 0 }, { 0, 0, 200 } }, + }, + { + { { 0.0f, 0.0f, 5.0f }, { 155, 255, 255 }, 100 }, + { { 0.0f, 0.0f, 5.0f }, { 155, 255, 255 }, 100 }, + { { 0.0f, 0.0f, 5.0f }, { 155, 255, 255 }, 100 }, + }, + }, +}; + +// arg2 is the colour interpolation parameter +// arg3 both selects the light to use and scales the radius +// arg4 selects the env fog/colour info +void func_808550D0(PlayState* play, Player* this, f32 arg2, f32 arg3, s32 arg4) { + struct_8085D848* temp_a2 = &D_8085D848[arg4]; + struct_8085D848_unk_18* lightInit = temp_a2->light; + Vec3f pos; + + func_80854EFC(play, arg2, temp_a2->unk_00); + + if (arg3 > 2.0f) { + arg3 -= 2.0f; + lightInit += 2; + } else if (arg3 > 1.0f) { + arg3 -= 1.0f; + lightInit++; + } + + Player_TranslateAndRotateY(this, &this->actor.world.pos, &lightInit->pos, &pos); + Lights_PointNoGlowSetInfo(&this->lightInfo, pos.x, pos.y, pos.z, lightInit->color[0], lightInit->color[1], + lightInit->color[2], lightInit->radius * arg3); +} + +AnimSfxEntry D_8085D8F0[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 2, NA_SE_PL_PUT_OUT_ITEM, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 4, NA_SE_IT_SET_TRANSFORM_MASK, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 11, NA_SE_PL_FREEZE_S, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 30, NA_SE_PL_TRANSFORM_VOICE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 20, NA_SE_IT_TRANSFORM_MASK_BROKEN, STOP), +}; + +AnimSfxEntry D_8085D904[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 8, NA_SE_IT_SET_TRANSFORM_MASK, STOP), +}; + +void func_80855218(PlayState* play, Player* this, struct_8085D910** arg2) { + if (PlayerAnimation_Update(play, &this->skelAnime) && (this->skelAnime.animation == &gPlayerAnim_cl_setmask)) { + func_8082DB60(play, this, &gPlayerAnim_cl_setmaskend); + } else if ((this->skelAnime.animation == &gPlayerAnim_cl_setmask) || + (this->skelAnime.animation == &gPlayerAnim_cl_setmaskend)) { + if (this->unk_AE7 >= 58) { + Math_StepToS(&this->unk_AE8, 255, 50); + } + + if (this->unk_AE7 >= 64) { + Math_StepToF(&this->unk_B10[2], 0.0f, 0.015f); + } else if (this->unk_AE7 >= 0xE) { + Math_StepToF(&this->unk_B10[2], 0.3f, 0.3f); + } + + if (this->unk_AE7 > 65) { + Math_StepToF(&this->unk_B10[3], 0.0f, 0.02f); + } else if (this->unk_AE7 >= 0x10) { + Math_StepToF(&this->unk_B10[3], -0.1f, 0.1f); + } + + if ((R_PLAY_FILL_SCREEN_ON == 0) && (this->skelAnime.animation == &gPlayerAnim_cl_setmask)) { + Player_PlayAnimSfx(this, D_8085D8F0); + } + } else { + if (this->unk_AE7 >= 20) { + Math_StepToS(&this->unk_AE8, 255, 20); + } + + if (R_PLAY_FILL_SCREEN_ON == 0) { + Player_PlayAnimSfx(this, D_8085D904); + if (this->unk_AE7 == 15) { + Player_PlaySfx(this, NA_SE_PL_FACE_CHANGE); + } + } + } +} + +u16 D_8085D908[] = { + WEEKEVENTREG_30_80, // PLAYER_FORM_FIERCE_DEITY + WEEKEVENTREG_30_20, // PLAYER_FORM_GORON + WEEKEVENTREG_30_40, // PLAYER_FORM_ZORA + WEEKEVENTREG_30_10, // PLAYER_FORM_DEKU +}; +struct_8085D910 D_8085D910[] = { + { 0x10, 0xA, 0x3B, 0x3F }, + { 9, 0x32, 0xA, 0xD }, +}; + +void func_808553F4(Player* this, PlayState* play) { + struct_8085D910* sp4C = D_8085D910; + s32 sp48 = false; + + func_808323C0(this, play->playerCsIds[PLAYER_CS_ID_MASK_TRANSFORMATION]); + sPlayerControlInput = play->state.input; + + Camera_ChangeMode(play->cameraPtrs[play->activeCamId], + (this->transformation == PLAYER_FORM_HUMAN) ? CAM_MODE_NORMAL : CAM_MODE_JUMP); + this->stateFlags2 |= PLAYER_STATE2_40; + this->actor.shape.rot.y = Camera_GetCamDirYaw(play->cameraPtrs[play->activeCamId]) + 0x8000; + + func_80855218(play, this, &sp4C); + + if (this->unk_AE7 == 0x14) { + Play_EnableMotionBlurPriority(100); + } + + if (R_PLAY_FILL_SCREEN_ON != 0) { + R_PLAY_FILL_SCREEN_ALPHA += R_PLAY_FILL_SCREEN_ON; + if (R_PLAY_FILL_SCREEN_ALPHA > 255) { + R_PLAY_FILL_SCREEN_ALPHA = 255; + this->actor.update = func_8012301C; + this->actor.draw = NULL; + this->unk_AE7 = 0; + Play_DisableMotionBlurPriority(); + SET_WEEKEVENTREG(D_8085D908[gSaveContext.save.playerForm]); + } + } else if ((this->unk_AE7++ > ((this->transformation == PLAYER_FORM_HUMAN) ? 0x53 : 0x37)) || + ((this->unk_AE7 >= 5) && + (sp48 = ((this->transformation != PLAYER_FORM_HUMAN) || + CHECK_WEEKEVENTREG(D_8085D908[gSaveContext.save.playerForm])) && + CHECK_BTN_ANY(sPlayerControlInput->press.button, + BTN_CRIGHT | BTN_CLEFT | BTN_CDOWN | BTN_CUP | BTN_B | BTN_A)))) { + R_PLAY_FILL_SCREEN_ON = 45; + R_PLAY_FILL_SCREEN_R = 220; + R_PLAY_FILL_SCREEN_G = 220; + R_PLAY_FILL_SCREEN_B = 220; + R_PLAY_FILL_SCREEN_ALPHA = 0; + + if (sp48) { + if (CutsceneManager_GetCurrentCsId() == this->csId) { + func_800E0348(Play_GetCamera(play, CutsceneManager_GetCurrentSubCamId(this->csId))); + } + + if (this->transformation == PLAYER_FORM_HUMAN) { + AudioSfx_StopById(NA_SE_PL_TRANSFORM_VOICE); + AudioSfx_StopById(NA_SE_IT_TRANSFORM_MASK_BROKEN); + } else { + AudioSfx_StopById(NA_SE_PL_FACE_CHANGE); + } + } + + Player_PlaySfx(this, NA_SE_SY_TRANSFORM_MASK_FLASH); + } + + if (this->unk_AE7 >= sp4C->unk_0) { + if (this->unk_AE7 < sp4C->unk_2) { + Math_StepToF(&this->unk_B10[4], 1.0f, sp4C->unk_1 / 100.0f); + } else if (this->unk_AE7 < sp4C->unk_3) { + if (this->unk_AE7 == sp4C->unk_2) { + func_801000CC(NA_SE_EV_LIGHTNING_HARD); + } + + Math_StepToF(&this->unk_B10[4], 2.0f, 0.5f); + } else { + Math_StepToF(&this->unk_B10[4], 3.0f, 0.2f); + } + } + + if (this->unk_AE7 >= 0x10) { + if (this->unk_AE7 < 0x40) { + Math_StepToF(&this->unk_B10[5], 1.0f, 0.2f); + } else if (this->unk_AE7 < 0x37) { + Math_StepToF(&this->unk_B10[5], 2.0f, 1.0f); + } else { + Math_StepToF(&this->unk_B10[5], 3.0f, 0.55f); + } + } + + func_808550D0(play, this, this->unk_B10[4], this->unk_B10[5], (this->transformation == PLAYER_FORM_HUMAN) ? 0 : 1); +} + +void func_80855818(Player* this, PlayState* play) { + Camera_ChangeMode(play->cameraPtrs[play->activeCamId], + (this->prevMask == PLAYER_MASK_NONE) ? CAM_MODE_NORMAL : CAM_MODE_JUMP); + + if (R_PLAY_FILL_SCREEN_ON != 0) { + R_PLAY_FILL_SCREEN_ALPHA -= R_PLAY_FILL_SCREEN_ON; + if (R_PLAY_FILL_SCREEN_ALPHA < 0) { + R_PLAY_FILL_SCREEN_ON = 0; + R_PLAY_FILL_SCREEN_ALPHA = 0; + } + } + + if (this->unk_AE7++ < 4) { + if ((this->prevMask == PLAYER_MASK_NONE) && (this->unk_AE7 == 4)) { + PlayerAnimation_Change(play, &this->skelAnime, func_8082ED20(this), 1.0f, 0.0f, 20.0f, ANIMMODE_ONCE, + 20.0f); + } + } else { + s32 pad; + f32 dist; + s16 angle; + + func_800FF3A0(&dist, &angle, play->state.input); + if (PlayerAnimation_Update(play, &this->skelAnime) || ((this->unk_AE7 > 10) && (dist != 0.0f))) { + if (R_PLAY_FILL_SCREEN_ON == 0) { + this->stateFlags1 &= ~PLAYER_STATE1_2; + this->prevMask = this->currentMask; + this->csId = play->playerCsIds[PLAYER_CS_ID_MASK_TRANSFORMATION]; + Player_StopCutscene(this); + play->envCtx.lightSettings = D_80862B50; + func_8085B384(this, play); + return; + } + } + + Math_StepToF(&this->unk_B10[5], 4.0f, 0.2f); + } + + func_808550D0(play, this, 0, this->unk_B10[5], (this->prevMask == PLAYER_MASK_NONE) ? 0 : 1); +} + +void func_80855A7C(Player* this, PlayState* play) { + if (this->unk_AE8++ > 90) { + play->msgCtx.ocarinaMode = 4; + func_8085B384(this, play); + } else if (this->unk_AE8 == 10) { + func_80848640(play, this); + } +} + +// Giant's Mask +void func_80855AF4(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_40; + + func_80855218(play, this, NULL); + this->unk_AE7++; + + if (!(this->stateFlags1 & PLAYER_STATE1_100)) { + this->prevMask = this->currentMask; + gSaveContext.save.equippedMask = this->currentMask = PLAYER_MASK_GIANT; + Magic_Consume(play, 0, MAGIC_CONSUME_GIANTS_MASK); + this->currentBoots = PLAYER_BOOTS_GIANT; + this->prevBoots = PLAYER_BOOTS_GIANT; + func_80123140(play, this); + func_8085B384(this, play); + } +} + +void func_80855B9C(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_40; + + PlayerAnimation_Update(play, &this->skelAnime); + + if (!(this->stateFlags1 & PLAYER_STATE1_100)) { + this->prevMask = this->currentMask; + + gSaveContext.save.equippedMask = this->currentMask = PLAYER_MASK_NONE; + + this->currentBoots = PLAYER_BOOTS_HYLIAN; + this->prevBoots = PLAYER_BOOTS_HYLIAN; + func_80123140(play, this); + func_8085B384(this, play); + } +} + +void func_80855C28(Player* this, PlayState* play) { + s16 sp3E; + s32 pad; + PlayerAnimationHeader* sp34; + s32 var_a0; + + func_808323C0(this, play->playerCsIds[PLAYER_CS_ID_WARP_PAD_MOON]); + sp3E = BINANG_SUB(this->actor.shape.rot.y, this->actor.world.rot.y); + + var_a0 = 0; + if ((this->actor.floorHeight - this->actor.world.pos.y) < 60.0f) { + Math_StepToF(&this->unk_B10[5], 200.0f, 150.0f); + var_a0 = Math_StepToS(&this->unk_AE8, 0xFA0, 0x15E); + } + + this->actor.shape.rot.y += this->unk_AE8; + this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1].x = 0; + this->skelAnime.jointTable[PLAYER_LIMB_ROOT - 1].z = 0; + this->unk_ABC += this->unk_B10[5]; + + if (this->unk_ABC >= 0.0f) { + this->unk_ABC = 0.0f; + if ((var_a0 != 0) && (sp3E < 0)) { + if (BINANG_SUB(this->actor.shape.rot.y, this->actor.world.rot.y) >= 0) { + this->actor.shape.rot.y = this->actor.world.rot.y; + Player_StopCutscene(this); + if (PLAYER_GET_INITMODE(&this->actor) == PLAYER_INITMODE_8) { + sp34 = D_8085D17C[this->transformation]; + func_80836A5C(this, play); + PlayerAnimation_Change(play, &this->skelAnime, sp34, -2.0f / 3.0f, Animation_GetLastFrame(sp34), + 0.0f, ANIMMODE_ONCE, -6.0f); + } else { + func_80839E74(this, play); + } + } + } + } else if (this->unk_AE7 == 0) { + Player_PlaySfx(this, NA_SE_PL_WARP_PLATE_OUT); + this->unk_AE7 = 1; + } +} + +void func_80855E08(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_20; + + if (PlayerAnimation_Update(play, &this->skelAnime)) { + Player_AnimationPlayLoop(play, this, &gPlayerAnim_link_hook_fly_wait); + } + + Math_Vec3f_Sum(&this->actor.world.pos, &this->actor.velocity, &this->actor.world.pos); + if (func_80831124(play, this)) { + f32 var_fv0; + + Math_Vec3f_Copy(&this->actor.prevPos, &this->actor.world.pos); + func_80843178(play, this); + + var_fv0 = this->actor.world.pos.y - this->actor.floorHeight; + var_fv0 = CLAMP_MAX(var_fv0, 20.0f); + + this->actor.world.pos.y = this->actor.world.pos.y - var_fv0; + this->actor.shape.rot.x = 0; + this->linearVelocity = 1.0f; + this->actor.velocity.y = 0.0f; + this->actor.world.rot.x = this->actor.shape.rot.x; + func_80833AA0(this, play); + this->stateFlags2 &= ~PLAYER_STATE2_400; + this->actor.bgCheckFlags |= BGCHECKFLAG_GROUND; + this->stateFlags3 |= PLAYER_STATE3_10000; + } else if ((this->skelAnime.animation != &gPlayerAnim_link_hook_fly_start) || (this->skelAnime.curFrame >= 4.0f)) { + this->actor.gravity = 0.0f; + Math_ScaledStepToS(&this->actor.shape.rot.x, this->actor.world.rot.x, 0x800); + Player_RequestRumble(play, this, 100, 2, 100, SQ(0)); + } +} + +void func_80855F9C(PlayState* play, Player* this) { + f32 sp24; + s16 sp22; + + this->stateFlags2 |= PLAYER_STATE2_20; + func_80832F78(this, &sp24, &sp22, 0.018f, play); + Math_ScaledStepToS(&this->currentYaw, sp22, 0x258); +} + +s32 func_80856000(PlayState* play, Player* this) { + CollisionPoly* poly; + s32 bgId; + Vec3f pos; + f32 sp28; + + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y - 20.0f; + pos.z = this->actor.world.pos.z; + return BgCheck_EntityCheckCeiling(&play->colCtx, &sp28, &pos, 30.0f, &poly, &bgId, &this->actor); +} + +void func_80856074(PlayState* play, Player* this) { + if (func_8083F8A8(play, this, 12.0f, 4, 0.0f, 10, 50, true)) { + EffectSsHahen_SpawnBurst(play, &this->actor.world.pos, 3.0f, 0, 4, 8, 2, -1, 10, NULL); + } +} + +void func_80856110(PlayState* play, Player* this, f32 arg2, f32 arg3, f32 arg4, s16 scale, s16 scaleStep, s16 life) { + static Vec3f D_8085D918 = { 0.0f, 0.5f, 0.0f }; // velocity + static Vec3f D_8085D924 = { 0.0f, 0.5f, 0.0f }; // accel + static Color_RGBA8 D_8085D930 = { 255, 255, 55, 255 }; // primColor + static Color_RGBA8 D_8085D934 = { 100, 50, 0, 0 }; // envColor + Vec3f pos; + + pos.x = this->actor.world.pos.x; + pos.y = this->actor.world.pos.y + arg2; + pos.z = this->actor.world.pos.z; + + D_8085D918.y = arg3; + D_8085D924.y = arg4; + + func_800B0EB0(play, &pos, &D_8085D918, &D_8085D924, &D_8085D930, &D_8085D934, scale, scaleStep, life); +} + +// Deku Flower related +void func_808561B0(Player* this, PlayState* play) { + DynaPolyActor* dyna; + s32 aux = 0xAE; + f32 temp_fv0_2; + s32 sp38; + s32 var_v1; + + PlayerAnimation_Update(play, &this->skelAnime); + + if (func_80838A90(this, play)) { + return; + } + + if (this->unk_AE7 == 0) { + this->unk_ABC += this->unk_B48; + if (this->unk_ABC < -1000.0f) { + this->unk_ABC = -1000.0f; + this->unk_AE7 = 1; + this->unk_B48 = 0.0f; + } + func_80856074(play, this); + } else if (this->unk_AE7 == 1) { + this->unk_B48 += -22.0f; + if (this->unk_B48 < -170.0f) { + this->unk_B48 = -170.0f; + } + this->unk_ABC += this->unk_B48; + if (this->unk_ABC < -3900.0f) { + this->unk_ABC = -3900.0f; + this->unk_AE7 = 2; + this->actor.shape.rot.y = Camera_GetInputDirYaw(play->cameraPtrs[play->activeCamId]); + this->actor.scale.y = 0.01f; + this->currentYaw = this->actor.world.rot.y = this->actor.shape.rot.y; + } else { + temp_fv0_2 = Math_SinS((1000.0f + this->unk_ABC) * (-30.0f)) * 0.004f; + this->actor.scale.y = 0.01f + temp_fv0_2; + this->actor.scale.z = this->actor.scale.x = 0.01f - (this->unk_B48 * -0.000015f); + + this->actor.shape.rot.y += (s16)(this->unk_B48 * 130.0f); + if (this->actor.floorBgId != BGCHECK_SCENE) { + dyna = DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId); + + if (dyna != NULL) { + Math_Vec3f_StepToXZ(&this->actor.world.pos, &dyna->actor.world.pos, 1.0f); + } + } + } + + func_80856074(play, this); + } else if (this->unk_AE7 == 2) { + if (!CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A)) { + if (func_80856000(play, this)) { + this->unk_AE8 = 0; + } else { + this->unk_AE7 = 3; + if (this->unk_AE8 >= 10) { + this->unk_B48 = 2700.0f; + } else { + this->unk_B48 = 1450.0f; + } + func_8082E1F0(this, NA_SE_PL_DEKUNUTS_OUT_GRD); + } + } else if (this->unk_AE8 < 15) { + this->unk_AE8++; + if (this->unk_AE8 == 10) { + func_80856110(play, this, 20.0f, 3.8f, -0.1f, 140, 23, 15); + } + } + func_80855F9C(play, this); + } else { + this->unk_ABC += this->unk_B48; + + temp_fv0_2 = this->unk_ABC; + if (temp_fv0_2 >= 0.0f) { + f32 speed; + + sp38 = (this->unk_AE8 >= 10); + var_v1 = -1; + speed = this->unk_B48 * this->actor.scale.y; + if (this->actor.floorBgId != BGCHECK_SCENE) { + dyna = DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId); + var_v1 = 0; + if ((dyna != NULL) && (dyna->actor.id == ACTOR_OBJ_ETCETERA) && (dyna->actor.params & 0x100)) { + var_v1 = 1; + speed *= aux / 100.0f; + } + } + + Math_Vec3f_Copy(this->unk_AF0, &this->actor.world.pos); + this->unk_ABC = 0.0f; + this->actor.world.pos.y += temp_fv0_2 * this->actor.scale.y; + func_80834DB8(this, &gPlayerAnim_pn_kakku, speed, play); + Player_SetAction(play, this, func_80856918, 1); + this->boomerangActor = NULL; + + this->stateFlags3 |= PLAYER_STATE3_200; + if (sp38 != 0) { + this->stateFlags3 |= PLAYER_STATE3_2000; + } + if (var_v1 < 0) { + this->stateFlags3 |= PLAYER_STATE3_40000; + } + + this->unk_AE7 = var_v1; + this->unk_AE8 = 9999; + Player_SetCylinderForAttack(this, DMG_DEKU_LAUNCH, 2, 20); + } else if (this->unk_ABC < 0.0f) { + func_80856074(play, this); + } + } + + if (this->unk_ABC < -1500.0f) { + this->stateFlags3 |= PLAYER_STATE3_100; + if (this->unk_B86[0] < 8) { + this->unk_B86[0]++; + if (this->unk_B86[0] == 8) { + func_8082E1F0(this, NA_SE_PL_DEKUNUTS_BUD); + } + } + } +} + +void func_808566C0(PlayState* play, Player* this, PlayerBodyPart bodyPartIndex, f32 arg3, f32 arg4, f32 arg5, + s32 life) { + Color_RGBA8 primColor = { 255, 200, 200, 0 }; + Color_RGBA8 envColor = { 255, 255, 0, 0 }; + static Vec3f D_8085D940 = { 0.0f, 0.3f, 0.0f }; + static Vec3f D_8085D94C = { 0.0f, -0.025f, 0.0f }; + Vec3f pos; + s32 scale; + f32 sp34; + Vec3f* temp_v0; + + if (Rand_ZeroOne() < 0.5f) { + sp34 = -1.0f; + } else { + sp34 = 1.0f; + } + + D_8085D940.x = (Rand_ZeroFloat(arg4) + arg3) * sp34; + D_8085D94C.x = arg5 * sp34; + if (Rand_ZeroOne() < 0.5f) { + sp34 = -1.0f; + } else { + sp34 = 1.0f; + } + + temp_v0 = &this->bodyPartsPos[bodyPartIndex]; + D_8085D940.z = (Rand_ZeroFloat(arg4) + arg3) * sp34; + D_8085D94C.z = arg5 * sp34; + pos.x = temp_v0->x; + pos.y = Rand_ZeroFloat(15.0f) + temp_v0->y; + pos.z = temp_v0->z; + if (Rand_ZeroOne() < 0.5f) { + scale = 2000; + } else { + scale = -150; + } + + EffectSsKirakira_SpawnDispersed(play, &pos, &D_8085D940, &D_8085D94C, &primColor, &envColor, scale, life); +} + +void func_8085687C(Player* this) { +} + +s32 func_80856888(f32* arg0, f32 arg1, f32 arg2) { + if (arg2 != 0.0f) { + if (arg1 < *arg0) { + arg2 = -arg2; + } + + *arg0 += arg2; + if (((*arg0 - arg1) * arg2) >= 0.0f) { + *arg0 = arg1; + return true; + } + } else if (arg1 == *arg0) { + return true; + } + + return false; +} + +f32 D_8085D958[] = { 600.0f, 960.0f }; +Vec3f D_8085D960 = { -30.0f, 50.0f, 0.0f }; +Vec3f D_8085D96C = { 30.0f, 50.0f, 0.0f }; + +// Flying as Deku? +void func_80856918(Player* this, PlayState* play) { + if ((this->boomerangActor != NULL) && (this->boomerangActor->update == NULL)) { + this->boomerangActor = NULL; + } + + if (func_80838A90(this, play)) { + return; + } + + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + func_80837134(play, this); + return; + } + + if ((this->actor.velocity.y > 0.0f) && (this->stateFlags3 & PLAYER_STATE3_200)) { + this->actor.terminalVelocity = -20.0f; + this->actor.gravity = -5.5f; + Player_SetCylinderForAttack(this, DMG_DEKU_LAUNCH, 2, 20); + func_80856110(play, this, 0.0f, 0.0f, -1.0f, 500, 0, 8); + + if (this->actor.bgCheckFlags & BGCHECKFLAG_CEILING) { + func_80833AA0(this, play); + } + } else if (!(this->stateFlags3 & PLAYER_STATE3_2000)) { + func_80833AA0(this, play); + } else if (this->stateFlags3 & PLAYER_STATE3_200) { + if (this->actor.velocity.y < 0.0f) { + if (this->unk_AE7 < 0) { + func_80833AA0(this, play); + } else { + PlayerAnimation_Update(play, &this->skelAnime); + if (this->skelAnime.curFrame > 6.0f) { + this->actor.velocity.y = 6.0f; + this->stateFlags3 &= ~PLAYER_STATE3_200; + this->stateFlags3 |= PLAYER_STATE3_1000000; + func_8082E1F0(this, NA_SE_IT_DEKUNUTS_FLOWER_OPEN); + func_8019FD90(4, 2); + } + } + } + + this->actor.terminalVelocity = -10.0f; + this->actor.gravity = -0.5f; + Player_ResetCylinder(this); + } else if (CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_A)) { + func_808355D8(play, this, &gPlayerAnim_pn_kakkufinish); + } else { + s16 temp_a0; + f32 temp_fv1; + s16 sp76; + s16 var_v1; + s16 var_a1; + f32 sp6C; + f32 sp68; + s16 sp66; + s16 temp_ft0; + s32 temp; + s16 var_v1_4; + + this->linearVelocity = sqrtf(SQXZ(this->actor.velocity)); + if (this->linearVelocity != 0.0f) { + var_a1 = Math_Atan2S_XY(this->actor.velocity.z, this->actor.velocity.x); + + temp_a0 = this->actor.shape.rot.y - var_a1; + if (ABS_ALT(temp_a0) > 0x4000) { + this->linearVelocity = -this->linearVelocity; + var_a1 = var_a1 + 0x8000; + } + this->currentYaw = var_a1; + } + + if (this->windSpeed != 0.0f) { + Math_SmoothStepToS(&this->unk_B8C, this->windAngleX, 3, 0x1F40, 0x190); + } + + func_8085687C(this); + + if (this->unk_AE8 != 0) { + this->unk_AE8--; + } + + temp_fv1 = D_8085D958[this->unk_AE7] - Math_Vec3f_DistXZ(&this->actor.world.pos, this->unk_AF0); + PlayerAnimation_Update(play, &this->skelAnime); + + if ((this->unk_AE8 != 0) && (temp_fv1 > 300.0f)) { + sp76 = 0x1770; + if (this->skelAnime.animation != &gPlayerAnim_pn_kakku) { + func_8082E5EC(play, this, &gPlayerAnim_pn_kakkufinish); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 8.0f)) { + s32 i; + + Player_TranslateAndRotateY(this, &this->actor.world.pos, &D_8085D960, + &this->bodyPartsPos[PLAYER_BODYPART_LEFT_HAND]); + Player_TranslateAndRotateY(this, &this->actor.world.pos, &D_8085D96C, + &this->bodyPartsPos[PLAYER_BODYPART_RIGHT_HAND]); + + for (i = 0; i < 13; i++) { + func_808566C0(play, this, PLAYER_BODYPART_LEFT_HAND, 0.6f, 1.0f, 0.8f, 17); + func_808566C0(play, this, PLAYER_BODYPART_RIGHT_HAND, 0.6f, 1.0f, 0.8f, 17); + } + } + } else if ((this->unk_AE8 == 0) || (temp_fv1 < 0.0f)) { + sp76 = 0; + func_808355D8(play, this, &gPlayerAnim_pn_rakkafinish); + } else { + sp76 = 0x1770 - (s32)((300.0f - temp_fv1) * 10.0f); + + if (this->skelAnime.animation != &gPlayerAnim_pn_batabata) { + func_8082E55C(play, this, &gPlayerAnim_pn_batabata); + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 6.0f)) { + Player_PlaySfx(this, NA_SE_PL_DEKUNUTS_STRUGGLE); + } + } + + Math_AsymStepToS(&this->unk_B86[1], sp76, 0x190, 0x190); + + this->unk_B8A += this->unk_B86[1]; + temp = ABS_ALT(this->unk_B86[1]); + if (temp > 0xFA0) { + this->unk_B66 += (u8)(ABS_ALT(this->unk_B86[1]) * 0.01f); + } + + if (this->unk_B66 > 200) { + this->unk_B66 -= 200; + func_808566C0(play, this, PLAYER_BODYPART_LEFT_HAND, 0.0f, 1.0f, 0.0f, 32); + func_808566C0(play, this, PLAYER_BODYPART_RIGHT_HAND, 0.0f, 1.0f, 0.0f, 32); + } + + func_8019FCB8(&this->actor.projectedPos, 0x1851, 2.0f * (this->unk_B86[1] * (1.0f / 6000.0f))); + if ((this->boomerangActor == NULL) && CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_B)) { + if (AMMO(ITEM_NUT) == 0) { + play_sound(NA_SE_SY_ERROR); + } else { + this->boomerangActor = + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ARROW, this->bodyPartsPos[PLAYER_BODYPART_WAIST].x, + this->bodyPartsPos[PLAYER_BODYPART_WAIST].y, + this->bodyPartsPos[PLAYER_BODYPART_WAIST].z, -1, 0, 0, ARROW_TYPE_DEKU_NUT); + if (this->boomerangActor != NULL) { + this->boomerangActor->velocity.x = this->actor.velocity.x * 1.5f; + this->boomerangActor->velocity.z = this->actor.velocity.z * 1.5f; + Inventory_ChangeAmmo(ITEM_NUT, -1); + Actor_PlaySfx(this->boomerangActor, NA_SE_PL_DEKUNUTS_DROP_BOMB); + } + } + } + + if (this->actor.velocity.y < 0.0f) { + if (sp76 != 0) { + this->actor.terminalVelocity = -0.38f; + this->actor.gravity = -0.2f; + } else { + this->actor.terminalVelocity = (this->unk_B86[1] * 0.0033f) + -20.0f; + this->actor.gravity = (this->unk_B86[1] * 0.00004f) + (REG(68) / 100.0f); + } + } + + this->fallStartHeight = this->actor.world.pos.y; + func_80832F78(this, &sp6C, &sp66, 0.0f, play); + if (sp6C == 0.0f) { + sp68 = 0.1f; + } else { + s16 temp_v0_6 = this->currentYaw - sp66; + + if (ABS_ALT(temp_v0_6) > 0x4000) { + sp6C = -sp6C; + sp66 += 0x8000; + } + sp68 = 0.25f; + } + + Math_SmoothStepToS(&this->unk_B8C, sp6C * 600.0f, 8, 0xFA0, 0x64); + Math_ScaledStepToS(&this->currentYaw, sp66, 0xFA); + + temp_ft0 = BINANG_SUB(sp66, this->currentYaw) * -2.0f; + temp_ft0 = CLAMP(temp_ft0, -0x1F40, 0x1F40); + Math_SmoothStepToS(&this->unk_B8E, temp_ft0, 0x14, 0x320, 0x14); + sp6C = (sp6C * (this->unk_B86[1] * 0.0004f)) * fabsf(Math_SinS(this->unk_B8C)); + func_80856888(&this->linearVelocity, sp6C, sp68); + + sp6C = sqrtf(SQ(this->linearVelocity) + SQ(this->actor.velocity.y)); + if (sp6C > 8.0f) { + sp6C = 8.0f / sp6C; + this->linearVelocity *= sp6C; + this->actor.velocity.y *= sp6C; + } + } + + func_808378FC(play, this); +} + +// Deku spinning related +void func_808573A4(Player* this, PlayState* play) { + this->stateFlags2 |= PLAYER_STATE2_20 | PLAYER_STATE2_40; + + PlayerAnimation_Update(play, &this->skelAnime); + Player_SetCylinderForAttack(this, DMG_DEKU_SPIN, 1, 30); + + if (!func_80838A90(this, play)) { + s16 prevYaw = this->currentYaw; + f32 sp40; + s16 sp3E; + + func_80832F78(this, &sp40, &sp3E, 0.018f, play); + sp40 *= 1.0f - (0.9f * ((11100.0f - this->unk_B10[0]) / 11100.0f)); + if (!func_8083A4A4(this, &sp40, &sp3E, REG(43) / 100.0f)) { + func_8083CB58(this, sp40, sp3E); + } + + this->unk_B10[0] += -800.0f; + this->actor.shape.rot.y += BINANG_ADD((s16)this->unk_B10[0], BINANG_SUB(this->currentYaw, prevYaw)); + + if (Math_StepToF(&this->unk_B10[1], 0.0f, this->unk_B10[0])) { + this->actor.shape.rot.y = this->currentYaw; + func_8083B2E4(this, play); + } else if (this->skelAnime.animation == &gPlayerAnim_pn_attack) { + this->stateFlags3 |= PLAYER_STATE3_100000; + + if (this->unk_B10[1] < 0.0f) { + func_8082E438(play, this, func_8082ED20(this)); + } + } + + func_808566C0(play, this, PLAYER_BODYPART_WAIST, 1.0f, 0.5f, 0.0f, 32); + + if (this->unk_B10[0] > 9500.0f) { + func_8083F8A8(play, this, 2.0f, 1, 2.5f, 10, 18, true); + } + + func_800AE930(&play->colCtx, Effect_GetByIndex(this->meleeWeaponEffectIndex[2]), &this->actor.world.pos, 2.0f, + this->currentYaw, this->actor.floorPoly, this->actor.floorBgId); + func_800B8F98(&this->actor, Player_GetFloorSfx(this, NA_SE_PL_SLIP_LEVEL - SFX_FLAG)); + } +} + +void func_80857640(Player* this, f32 arg1, s32 arg2) { + func_80834CD0(this, arg1, NA_SE_VO_LI_SWORD_N); + Player_PlaySfx(this, NA_SE_PL_GORON_BALLJUMP); + Player_StopHorizontalMovement(this); + if (this->unk_AE8 < arg2) { + this->unk_AE8 = arg2; + } + this->unk_AE7 = 1; + this->unk_B48 = 1.0f; +} + +void func_808576BC(PlayState* play, Player* this) { + s32 var_v0 = ((this->actor.velocity.z * Math_CosS(this->currentYaw)) + + (this->actor.velocity.x * Math_SinS(this->currentYaw))) * + 800.0f; + + var_v0 -= this->unk_AE8; + var_v0 = ABS_ALT(var_v0); + + if (var_v0 <= 0x7D0) { + return; + } + + if (var_v0 > 0x1770) { + func_800B8F98(&this->actor, NA_SE_PL_GORON_SLIP - SFX_FLAG); + } + + if (func_8083F8A8(play, this, 12.0f, -1 - (var_v0 >> 0xC), (var_v0 >> 0xA) + 1.0f, (var_v0 >> 7) + 160, 20, true)) { + Player_PlaySfx(this, (this->floorSfxOffset == NA_SE_PL_WALK_SNOW - SFX_FLAG) + ? NA_SE_PL_ROLL_SNOW_DUST - SFX_FLAG + : NA_SE_PL_ROLL_DUST - SFX_FLAG); + } +} + +void func_808577E0(Player* this) { + f32 temp_fa1 = ABS_ALT(this->unk_AE8) * 0.00004f; + + if (this->unk_ABC < temp_fa1) { + this->unk_B48 += 0.08f; + } else { + this->unk_B48 += -0.07f; + } + + this->unk_B48 = CLAMP(this->unk_B48, -0.2f, 0.14f); + if (fabsf(this->unk_B48) < 0.12f) { + if (Math_StepUntilF(&this->unk_ABC, temp_fa1, this->unk_B48)) { + this->unk_B48 = 0.0f; + } + } else { + this->unk_ABC += this->unk_B48; + this->unk_ABC = CLAMP(this->unk_ABC, -0.7f, 0.3f); + } +} + +s32 func_80857950(PlayState* play, Player* this) { + if (((this->unk_B86[1] == 0) && !CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A)) || + ((this->unk_AE7 == 3) && (this->actor.velocity.y < 0.0f))) { + Player_SetAction(play, this, func_80849FE0, 1); + Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); + PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_pg_maru_change, -2.0f / 3.0f, 7.0f, 0.0f, + ANIMMODE_ONCE, 0.0f); + Player_PlaySfx(this, NA_SE_PL_BALL_TO_GORON); + return true; + } + + return false; +} + +s32 func_80857A44(PlayState* play, Player* this) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_8082E794(this); + + this->actor.shape.shadowDraw = ActorShadow_DrawCircle; + this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_800; + this->unk_AE7 = 4; + this->actor.shape.shadowScale = 30.0f; + this->unk_AE8 = this->linearVelocity * 500.0f; + this->unk_B08 = this->linearVelocity; + this->unk_B0C = 0.0f; + this->actor.home.rot.y = this->currentYaw; + + return true; + } + + return false; +} + +void func_80857AEC(PlayState* play, Player* this) { + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { + this->unk_B0C += this->unk_B08 * 0.05f; + + if (this->unk_B86[1] == 0) { + if (this->unk_AE7 == 1) { + this->unk_AE7 = 2; + Player_RequestQuakeAndRumble(play, this, NA_SE_PL_GORON_PUNCH); + play->actorCtx.unk2 = 4; + EffectSsBlast_SpawnWhiteShockwave(play, &this->actor.world.pos, &gZeroVec3f, &gZeroVec3f); + this->unk_AE8 = 0; + this->unk_B08 = 0.0f; + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_TEST, this->actor.world.pos.x, this->actor.world.pos.y, + this->actor.world.pos.z, 0, 0, 0, 0); + } else { + this->unk_AE7 = 4; + } + } + + Player_AnimSfx_PlayFloorLand(this); + } +} + +// Goron rolling related +void func_80857BE8(Player* this, PlayState* play) { + if (func_80833058(play, this, D_8085D050, 0)) { + return; + } + + if ((this->unk_AE7 == 0) && !func_80857A44(play, this)) { + return; + } + + this->stateFlags3 |= PLAYER_STATE3_1000; + func_808577E0(this); + + if (!func_80857950(play, this)) { + f32 spE4 = 0.0f; + s16 spE2 = this->currentYaw; + u16 spE0; + s32 spDC; + s32 spD8; + + if (func_80840A30(play, this, &this->unk_B08, (this->doorType == PLAYER_DOORTYPE_STAIRCASE) ? 0.0f : 12.0f)) { + if (func_80857BE8 != this->actionFunc) { + return; + } + + this->linearVelocity *= 0.1f; + func_80834CD0(this, 10.0f, 0); + if (this->unk_B86[1] != 0) { + this->unk_B86[1] = 0; + this->unk_AE7 = 3; + } + } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (this->unk_B08 >= 12.0f)) { + s16 temp_v0 = this->currentYaw - BINANG_ADD(this->actor.wallYaw, 0x8000); + s16 temp_v2; + s32 var_a2 = ABS_ALT(temp_v0); + + this->unk_B0C += this->unk_B08 * 0.05f; + temp_v2 = ((temp_v0 >= 0) ? 1 : -1) * ((var_a2 + 0x100) & ~0x1FF); + this->currentYaw += BINANG_SUB(0x8000, (s16)(temp_v2 * 2)); + this->actor.home.rot.y = this->currentYaw; + this->actor.shape.rot.y = this->currentYaw; + + this->unk_B8C = 4; + Player_PlaySfx(this, NA_SE_IT_GORON_ROLLING_REFLECTION); + } + + this->stateFlags2 |= (PLAYER_STATE2_20 | PLAYER_STATE2_40); + + if (this->unk_B8E != 0) { + this->unk_B8E--; + } else { + func_80832F78(this, &spE4, &spE2, 0.0f, play); + spE4 *= 2.6f; + } + + if (this->unk_B8C != 0) { + this->unk_B8C--; + spE2 = this->currentYaw; + } + + if (this->unk_B86[1] != 0) { + spE4 = 18.0f; + Math_StepToC(&this->unk_AE7, 4, 1); + + if ((this->stateFlags3 & PLAYER_STATE3_80000) && (!CHECK_BTN_ALL(sPlayerControlInput->cur.button, BTN_A) || + (gSaveContext.save.saveInfo.playerData.magic == 0) || + ((this->unk_AE7 == 4) && (this->unk_B08 < 12.0f)))) { + if (Math_StepToS(&this->unk_B86[1], 0, 1) != 0) { + this->stateFlags3 &= ~PLAYER_STATE3_80000; + Magic_Reset(play); + Player_PlaySfx(this, NA_SE_PL_GORON_BALL_CHARGE_FAILED); + } + this->unk_AE7 = 4; + } else if (this->unk_B86[1] < 7) { + if (!(this->stateFlags3 & PLAYER_STATE3_80000)) { + this->unk_3D0.unk_00 = 2; + } + this->unk_B86[1]++; + } + } + + spDC = spE4 * 900.0f; + + Math_AsymStepToF(&this->unk_B10[0], (this->unk_B8A != 0) ? 1.0f : 0.0f, 0.8f, 0.05f); + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + func_80857AEC(play, this); + if (this->unk_AE7 == 2) { + if (this->unk_B8A == 0) { + this->unk_AE7 = 4; + } else { + this->unk_B8A--; + this->unk_ABC = 0.0f; + this->unk_B48 = 0.14f; + } + } else if ((this->unk_B86[1] == 0) && CHECK_BTN_ALL(sPlayerControlInput->press.button, BTN_B) && + (Inventory_GetBtnBItem(play) < ITEM_FD)) { + func_80857640(this, 14.0f, 0x1F40); + } else { + f32 spCC; + s16 spCA; + s16 spC8; + s32 var_a0; + s32 spC0; + f32 spBC; + f32 spB8; + f32 spB4; + f32 spB0; + f32 spAC; + f32 spA8; + f32 spA4; + f32 spA0; + Vec3f slopeNormal; + s16 downwardSlopeYaw; + s16 sp90 = this->currentYaw; + s16 sp8E = this->currentYaw - this->actor.home.rot.y; + f32 sp88 = Math_CosS(sp8E); + + if (this->unk_B86[1] == 0) { + this->unk_B0C = 0.0f; + if (this->unk_AE7 >= 0x36) { + Magic_Consume(play, 2, MAGIC_CONSUME_GORON_ZORA); + this->unk_B08 = 18.0f; + this->unk_B86[1] = 1; + this->stateFlags3 |= PLAYER_STATE3_80000; + func_8082E1F0(this, NA_SE_PL_GORON_BALL_CHARGE_DASH); + } + } else { + this->unk_B0C = CLAMP(this->unk_B0C, 0.0f, 0.9f); + } + + spBC = (1.0f - this->unk_B0C) * this->unk_B08 * sp88; + if ((spBC < 0.0f) || ((spE4 == 0.0f) && (ABS_ALT(sp8E) > 0xFA0))) { + spBC = 0.0f; + } + + Math_StepToF(&this->unk_B0C, 0.0f, fabsf(sp88) * 20.0f); + var_a0 = spBC * 500.0f; + var_a0 = CLAMP_MIN(var_a0, 0); + + spC0 = (s32)(spE4 * 400.0f) - var_a0; + spC0 = CLAMP_MIN(spC0, 0); + + spDC = CLAMP_MIN(spDC, var_a0); + + spAC = spBC * Math_SinS(this->actor.home.rot.y); + spA8 = spBC * Math_CosS(this->actor.home.rot.y); + spB4 = this->unk_B08 * Math_SinS(this->currentYaw); + spB0 = this->unk_B08 * Math_CosS(this->currentYaw); + + spA4 = spB4 - spAC; + spA0 = spB0 - spA8; + this->linearVelocity = spBC; + this->currentYaw = this->actor.home.rot.y; + spCC = spE4; + spCA = spE2; + + if (func_8083A4A4(this, &spCC, &spCA, (this->unk_AE7 >= 5) ? 0.0f : 1.0f)) { + if (this->unk_B86[1] == 0) { + this->unk_AE7 = 4; + } + + if (this->unk_AE7 == 4) { + spDC = -0xFA0; + } + } else { + static Vec3f D_8085D978 = { -30.0f, 60.0f, 0.0f }; + static Vec3f D_8085D984 = { 30.0f, 60.0f, 0.0f }; + f32 sp84 = (((this->floorSfxOffset == NA_SE_PL_WALK_SNOW - SFX_FLAG) || + (this->floorSfxOffset == NA_SE_PL_WALK_ICE - SFX_FLAG) || + (this->floorSfxOffset == NA_SE_PL_WALK_SAND - SFX_FLAG) || + (sPlayerCurrentFloorType == FLOOR_TYPE_5)) && + (spC0 >= 0x7D0)) + ? 0.08f + : this->unk_AE8 * 0.0003f; + f32 sp80 = (Math_SinS(this->unk_B6C) * 8.0f) + 0.6f; + s16 var_a3; + s16 sp7C; + Vec3f sp70; + f32 sp6C; + f32 var_fa1; + + if (this->unk_B86[1] == 0) { + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) && + (gSaveContext.save.saveInfo.playerData.magic >= 2) && (this->unk_AE8 >= 0x36B0)) { + this->unk_AE7++; + func_800B8F98(&this->actor, NA_SE_PL_GORON_BALL_CHARGE - SFX_FLAG); + } else { + this->unk_AE7 = 4; + } + } + + if (spE4 != spCC) { + this->currentYaw = spE2; + } + + sp84 = CLAMP_MIN(sp84, 0.0f); + sp80 = CLAMP_MIN(sp80, 0.0f); + + Math_AsymStepToF(&this->linearVelocity, spE4, sp84, sp80); + spC8 = (s16)(fabsf(this->actor.speed) * 20.0f) + 300; + spC8 = CLAMP_MIN(spC8, 100); + + sp7C = (s32)(BINANG_SUB(spE2, this->currentYaw) * -0.5f); + this->unk_B0C += (f32)(SQ(sp7C)) * 8e-9f; + Math_ScaledStepToS(&this->currentYaw, spE2, spC8); + sp6C = func_80835D2C(play, this, &D_8085D978, &sp70); + + var_fa1 = func_80835D2C(play, this, &D_8085D984, &sp70) - sp6C; + if (fabsf(var_fa1) > 100.0f) { + var_fa1 = 0.0f; + } + + var_a3 = Math_Atan2S_XY(60.0f, var_fa1); + if (ABS_ALT(var_a3) > 0x2AAA) { + var_a3 = 0; + } + + Math_ScaledStepToS(&this->actor.shape.rot.z, var_a3 + sp7C, spC8); + } + + spBC = this->linearVelocity; + this->actor.home.rot.y = this->currentYaw; + this->currentYaw = sp90; + Actor_GetSlopeDirection(this->actor.floorPoly, &slopeNormal, &downwardSlopeYaw); + + spB8 = sqrtf(SQ(spA4) + SQ(spA0)); + if (this->unk_B86[1] != 0) { + if ((ABS_ALT(sp8E) + ABS_ALT(this->unk_B6C)) > 15000) { + this->unk_B86[1] = 0; + this->unk_AE7 = 4; + this->unk_B8E = 0x14; + this->unk_AE8 = 0; + this->stateFlags3 &= ~PLAYER_STATE3_80000; + Magic_Reset(play); + } + } else { + f32 temp_ft4_2 = (0.6f * slopeNormal.x) + spA4; + f32 temp_ft5 = (0.6f * slopeNormal.z) + spA0; + f32 temp_fv0_3 = sqrtf(SQ(temp_ft4_2) + SQ(temp_ft5)); + + if ((temp_fv0_3 < spB8) || (temp_fv0_3 < 6.0f)) { + spA4 = temp_ft4_2; + spA0 = temp_ft5; + spB8 = temp_fv0_3; + } + } + + if (spB8 != 0.0f) { + f32 pad; + f32 sp54 = spB8 - 0.3f; + + sp54 = CLAMP_MIN(sp54, 0.0f); + + spB8 = sp54 / spB8; + + spA4 *= spB8; + spA0 *= spB8; + + if (sp54 != 0.0f) { + this->unk_B28 = Math_Atan2S_XY(spA0, spA4); + } + + if (this->unk_AE8 == 0) { + s32 temp_v0_10 = this->unk_B86[0]; + s32 temp_ft3_2 = sp54 * 800.0f; + + this->unk_B86[0] += (s16)temp_ft3_2; + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (temp_ft3_2 != 0) && + (((temp_v0_10 + temp_ft3_2) * temp_v0_10) <= 0)) { + spE0 = Player_GetFloorSfx(this, NA_SE_PL_GORON_ROLL); + func_8019F780(&this->actor.projectedPos, spE0, sp54); + } + } + } + + spAC = Math_SinS(this->actor.home.rot.y) * spBC; + spA8 = Math_CosS(this->actor.home.rot.y) * spBC; + + spB4 = spAC + spA4; + spB0 = spA8 + spA0; + + this->unk_B08 = sqrtf(SQ(spB4) + SQ(spB0)); + this->unk_B08 = CLAMP_MAX(this->unk_B08, 18.0f); + + this->currentYaw = Math_Atan2S_XY(spB0, spB4); + } + + func_808576BC(play, this); + + if (ABS_ALT(this->unk_AE8) > 0xFA0) { + this->stateFlags2 |= PLAYER_STATE2_8; + } + + if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { + this->linearVelocity = this->unk_B08 * Math_CosS(this->unk_B6C); + this->actor.velocity.y = this->unk_B08 * Math_SinS(this->unk_B6C); + } + + if ((this->unk_B86[1] != 0) || + SurfaceType_HasMaterialProperty(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId, + MATERIAL_PROPERTY_SOFT_IMPRINT)) { + func_800AE930(&play->colCtx, Effect_GetByIndex(this->meleeWeaponEffectIndex[2]), &this->actor.world.pos, + 15.0f, this->actor.shape.rot.y, this->actor.floorPoly, this->actor.floorBgId); + } else { + func_800AEF44(Effect_GetByIndex(this->meleeWeaponEffectIndex[2])); + } + } else { + Math_ScaledStepToS(&this->actor.shape.rot.z, 0, 0x190); + + this->unk_B86[0] = 0; + if (this->unk_B86[1] != 0) { + this->actor.gravity = -1.0f; + Math_ScaledStepToS(&this->actor.home.rot.y, spE2, 0x190); + + this->unk_B08 = sqrtf(SQ(this->linearVelocity) + SQ(this->actor.velocity.y)) * + ((this->linearVelocity >= 0.0f) ? 1.0f : -1.0f); + this->unk_B08 = CLAMP_MAX(this->unk_B08, 18.0f); + } else { + this->unk_B48 += this->actor.velocity.y * 0.005f; + if (this->unk_AE7 == 1) { + if (this->actor.velocity.y > 0.0f) { + if ((this->actor.velocity.y + this->actor.gravity) < 0.0f) { + this->actor.velocity.y = -this->actor.gravity; + } + } else { + this->unk_B8A = 0xA; + if (this->actor.velocity.y > -1.0f) { + this->actor.gravity = -0.2f; + } else { + this->unk_3D0.unk_00 = 1; + this->actor.gravity = -10.0f; + } + } + } + this->unk_B08 = this->linearVelocity; + } + + func_800AEF44(Effect_GetByIndex(this->meleeWeaponEffectIndex[2])); + } + + Math_ScaledStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 0x7D0); + + Math_AsymStepToS(&this->unk_AE8, spDC, (spDC >= 0) ? 0x7D0 : 0x3E8, 0x4B0); + + if (this->unk_AE8 != 0) { + spD8 = this->actor.shape.rot.x; + this->actor.shape.rot.x += this->unk_AE8; + + Math_ScaledStepToS(&this->unk_B86[0], 0, ABS_ALT(this->unk_AE8)); + if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (((this->unk_AE8 + spD8) * spD8) <= 0)) { + spE0 = + Player_GetFloorSfx(this, (this->unk_B86[1] != 0) ? NA_SE_PL_GORON_CHG_ROLL : NA_SE_PL_GORON_ROLL); + func_8019F780(&this->actor.projectedPos, spE0, this->unk_B08); + } + } + + if (this->unk_AE7 == 2) { + Player_SetCylinderForAttack(this, DMG_GORON_POUND, 4, 60); + Actor_SetPlayerImpact(play, PLAYER_IMPACT_GORON_GROUND_POUND, 2, 100.0f, &this->actor.world.pos); + } else if (this->unk_B86[1] != 0) { + Player_SetCylinderForAttack(this, DMG_GORON_SPIKES, 1, 25); + } else { + Player_SetCylinderForAttack(this, DMG_NORMAL_ROLL, 1, 25); + } + } +} + +void func_80858C84(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + func_8082E784(this); + func_8082E438(play, this, anim); + Player_StopHorizontalMovement(this); +} + +void func_80858CC8(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + func_8082E784(this); + PlayerAnimation_Change(play, &this->skelAnime, anim, 2.0f / 3.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_ONCE, + -8.0f); + Player_StopHorizontalMovement(this); +} + +void func_80858D48(PlayState* play, Player* this, PlayerAnimationHeader* anim) { + func_8082E784(this); + PlayerAnimation_Change(play, &this->skelAnime, anim, 2.0f / 3.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f); + Player_StopHorizontalMovement(this); +} + +void func_80858DB4(PlayState* play, Player* this, void* anim) { + Player_StopHorizontalMovement(this); +} + +void func_80858DDC(PlayState* play, Player* this, void* anim) { + func_80858C84(play, this, anim); +} + +void func_80858DFC(PlayState* play, Player* this, void* anim) { + func_8082E784(this); + func_8082E5A8(play, this, anim); + Player_StopHorizontalMovement(this); +} + +void func_80858E40(PlayState* play, Player* this, void* anim) { + func_80858CC8(play, this, anim); +} + +void func_80858E60(PlayState* play, Player* this, void* anim) { + func_80858D48(play, this, anim); +} + +void func_80858E80(PlayState* play, Player* this, void* anim) { + func_8082EA60(play, this, anim); +} + +void func_80858EA0(PlayState* play, Player* this, void* anim) { + func_8082EA10(play, this, anim, ANIM_FLAG_4 | ANIM_FLAG_8 | ANIM_FLAG_NOMOVE | ANIM_FLAG_80); +} + +void func_80858EC0(PlayState* play, Player* this, void* anim) { + Player_AnimationPlayOnceReverse(play, this, anim); + func_8082E920(play, this, ANIM_FLAG_4 | ANIM_FLAG_8 | ANIM_FLAG_NOMOVE | ANIM_FLAG_80); +} + +void func_80858EFC(PlayState* play, Player* this, void* anim) { + func_8082EB18(play, this, anim); +} + +void func_80858F1C(PlayState* play, Player* this, void* anim) { + func_8082EAC8(play, this, anim, ANIM_FLAG_4 | ANIM_FLAG_8 | ANIM_FLAG_NOMOVE | ANIM_FLAG_80); +} + +void func_80858F3C(PlayState* play, Player* this, void* anim) { + Player_AnimationPlayOnce(play, this, anim); +} + +void func_80858F5C(PlayState* play, Player* this, void* anim) { + Player_AnimationPlayLoop(play, this, anim); +} + +void func_80858F7C(PlayState* play, Player* this, void* anim) { + func_8082DB90(play, this, anim); +} + +void func_80858F9C(PlayState* play, Player* this, void* anim) { + func_8082DB60(play, this, anim); +} + +void func_80858FBC(PlayState* play, Player* this, void* anim) { + PlayerAnimation_Update(play, &this->skelAnime); +} + +void func_80858FE8(Player* this) { + if (this->skelAnime.animation == &gPlayerAnim_lost_horse_wait) { + Player_AnimSfx_PlayFloor(this, NA_SE_PL_SLIP_LEVEL - SFX_FLAG); + Player_PlaySfx(this, NA_SE_VO_LK_DRAGGED_DAMAGE - SFX_FLAG); + } +} + +void (*D_8085D990[])(PlayState*, Player*, void*) = { + /* 0 */ NULL, + /* 1 */ func_80858DB4, + /* 2 */ func_80858DDC, + /* 3 */ func_80858E40, + /* 4 */ func_80858E60, + /* 5 */ func_80858E80, + /* 6 */ func_80858EA0, + /* 7 */ func_80858EFC, + /* 8 */ func_80858F1C, + /* 9 */ func_80858F3C, + /* 10 */ func_80858F5C, + /* 11 */ func_80858FBC, + /* 12 */ func_80859028, + /* 13 */ func_808591BC, + /* 14 */ func_80858DFC, + /* 15 */ func_80858F7C, + /* 16 */ func_80858F9C, + /* 17 */ func_80859168, + /* 18 */ func_80859210, + /* 19 */ func_80858EC0, +}; + +AnimSfxEntry D_8085D9E0[] = { + ANIMSFX(ANIMSFX_TYPE_FLOOR_LAND, 34, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 45, NA_SE_PL_CALM_HIT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 51, NA_SE_PL_CALM_HIT, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 64, NA_SE_PL_CALM_HIT, STOP), +}; +AnimSfxEntry D_8085D9F0[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 7, NA_SE_VO_LI_DEMO_DAMAGE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR, 18, NA_SE_PL_BOUND, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_VOICE, 18, NA_SE_VO_LI_FREEZE, STOP), +}; +AnimSfxEntry D_8085D9FC[] = { + ANIMSFX(ANIMSFX_TYPE_FLOOR_BY_AGE, 14, NA_SE_PL_LAND_GROUND, STOP), +}; +AnimSfxEntry D_8085DA00[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 6, NA_SE_PL_GET_UP, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 18, NA_SE_VO_LK_WAKE_UP, STOP), +}; +AnimSfxEntry D_8085DA08[] = { + ANIMSFX(ANIMSFX_TYPE_FLOOR_BY_AGE, 26, NA_SE_PL_LAND_GROUND, STOP), +}; +AnimSfxEntry D_8085DA0C[] = { + ANIMSFX(ANIMSFX_TYPE_8, 16, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR_JUMP, 36, NA_SE_NONE, STOP), +}; +AnimSfxEntry D_8085DA14[] = { + ANIMSFX(ANIMSFX_TYPE_FLOOR_JUMP, 55, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_GENERAL, 55, NA_SE_VO_LK_CATCH_DEMO, STOP), +}; +AnimSfxEntry D_8085DA1C[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 4, NA_SE_VO_LK_USING_UP_ENERGY, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR, 16, NA_SE_PL_BOUND, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_VOICE, 16, NA_SE_VO_LI_DAMAGE_S, STOP), +}; +AnimSfxEntry D_8085DA28[] = { + ANIMSFX(ANIMSFX_TYPE_FLOOR_BY_AGE, 28, NA_SE_PL_LAND_GROUND, STOP), +}; +AnimSfxEntry D_8085DA2C[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 1, NA_SE_VO_LK_USING_UP_ENERGY, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR_JUMP, 42, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_VOICE, 44, NA_SE_VO_LI_FALL_L, STOP), +}; +AnimSfxEntry D_8085DA38[] = { + ANIMSFX(ANIMSFX_TYPE_FLOOR, 1, NA_SE_PL_BOUND, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_VOICE, 1, NA_SE_VO_LI_DAMAGE_S, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR_BY_AGE, 39, NA_SE_PL_LAND_GROUND, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR_LAND, 49, NA_SE_NONE, STOP), +}; + +// gPlayerAnim_cl_nigeru +AnimSfxEntry D_8085DA48[] = { + ANIMSFX(ANIMSFX_TYPE_6, 1, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_6, 5, NA_SE_NONE, STOP), +}; +AnimSfxEntry D_8085DA50[] = { + ANIMSFX(ANIMSFX_TYPE_6, 10, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_6, 13, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_6, 16, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_6, 19, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_6, 22, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR, 22, NA_SE_PL_SLIP, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_VOICE, 55, NA_SE_VO_LI_DAMAGE_S, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_FLOOR_LAND, 62, NA_SE_NONE, STOP), +}; + +AnimSfxEntry D_8085DA70[] = { + ANIMSFX(ANIMSFX_TYPE_6, 42, NA_SE_NONE, CONTINUE), + ANIMSFX(ANIMSFX_TYPE_6, 48, NA_SE_NONE, STOP), +}; +AnimSfxEntry D_8085DA78[] = { + ANIMSFX(ANIMSFX_TYPE_FLOOR, 2, NA_SE_PL_BOUND, STOP), +}; +AnimSfxEntry D_8085DA7C[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 5, NA_SE_VO_LI_FREEZE, STOP), +}; +AnimSfxEntry D_8085DA80[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 1, NA_SE_VO_LI_FALL_L, STOP), +}; +AnimSfxEntry D_8085DA84[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 13, NA_SE_VO_LI_HANG, STOP), +}; +AnimSfxEntry D_8085DA88[] = { + ANIMSFX(ANIMSFX_TYPE_FLOOR_LAND, 26, NA_SE_NONE, STOP), +}; +AnimSfxEntry D_8085DA8C[] = { + ANIMSFX(ANIMSFX_TYPE_VOICE, 4, NA_SE_VO_LI_SURPRISE, STOP), +}; +AnimSfxEntry D_8085DA90[] = { + ANIMSFX(ANIMSFX_TYPE_GENERAL, 18, NA_SE_PL_SIT_ON_HORSE, STOP), +}; + +void func_80859028(PlayState* play, Player* this, void* anim) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_80858D48(play, this, anim); + this->unk_AE8 = 1; + } + + if (this->skelAnime.animation == &gPlayerAnim_okiagaru_tatu) { + Player_PlayAnimSfx(this, D_8085DA08); + } else if (this->skelAnime.animation == &gPlayerAnim_lost_horse) { + Player_PlayAnimSfx(this, D_8085DA14); + } else if (this->skelAnime.animation == &gPlayerAnim_sirimochi) { + Player_PlayAnimSfx(this, D_8085DA38); + } else if (this->skelAnime.animation == &gPlayerAnim_alink_somukeru) { + Player_PlayAnimSfx(this, D_8085DA7C); + } else if (this->skelAnime.animation == &gPlayerAnim_al_fuwafuwa) { + Player_PlayAnimSfx(this, D_8085DA84); + } else if (this->skelAnime.animation == &gPlayerAnim_cl_umanoru) { + Player_PlayAnimSfx(this, D_8085DA90); + } else { + func_80858FE8(this); + } +} + +void func_80859168(PlayState* play, Player* this, void* anim) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_8082E794(this); + func_8082DB60(play, this, anim); + } +} + +void func_808591BC(PlayState* play, Player* this, void* anim) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_8082EB18(play, this, anim); + this->unk_AE8 = 1; + } +} + +void func_80859210(PlayState* play, Player* this, void* arg2) { + PlayerAnimation_Update(play, &this->skelAnime); + Player_PlayAnimSfx(this, arg2); +} + +void func_80859248(Player* this) { + if ((this->unk_398 == NULL) || (this->unk_398->update == NULL)) { + this->unk_398 = NULL; + } + this->targetedActor = this->unk_398; + if (this->unk_398 != NULL) { + this->actor.shape.rot.y = func_8083C62C(this, 0); + } +} + +void func_8085929C(PlayState* play, Player* this, UNK_TYPE arg2) { + this->stateFlags1 |= PLAYER_STATE1_8000000; + this->stateFlags2 |= PLAYER_STATE2_400; + this->stateFlags1 &= ~(PLAYER_STATE1_40000 | PLAYER_STATE1_80000); + Player_AnimationPlayLoop(play, this, &gPlayerAnim_link_swimer_swim); + this->linearVelocity = 0.0f; +} + +void func_80859300(PlayState* play, Player* this, UNK_TYPE arg2) { + this->actor.gravity = 0.0f; + + if (this->unk_AE7 == 0) { + if ((this->transformation == PLAYER_FORM_DEKU) || func_8083B3B4(play, this, NULL)) { + this->unk_AE7 = 1; + } else { + func_808477D0(play, this, NULL, fabsf(this->actor.velocity.y)); + Math_ScaledStepToS(&this->unk_AAA, -0x2710, 0x320); + func_8084748C(this, &this->actor.velocity.y, 4.0f, this->currentYaw); + } + } else { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + if (this->unk_AE7 == 1) { + func_8082E634(play, this, &gPlayerAnim_link_swimer_swim_wait); + } else { + Player_AnimationPlayLoop(play, this, &gPlayerAnim_link_swimer_swim_wait); + } + } + func_808475B4(this); + func_8084748C(this, &this->linearVelocity, 0.0f, this->actor.shape.rot.y); + } +} + +void func_80859414(PlayState* play, Player* this, UNK_TYPE arg2) { + func_80859248(this); + + if (func_801242B4(this)) { + func_80859300(play, this, 0); + } else { + PlayerAnimation_Update(play, &this->skelAnime); + if (func_801240DC(this) || (this->stateFlags1 & PLAYER_STATE1_800)) { + func_8083216C(this, play); + } else if ((this->interactRangeActor != NULL) && (this->interactRangeActor->textId == 0xFFFF)) { + func_8083D23C(this, play); + } + } +} + +void func_808594D0(PlayState* play, Player* this, UNK_TYPE arg2) { + if (this->stateFlags1 & PLAYER_STATE1_8000000) { + func_8085929C(play, this, 0); + } else { + PlayerAnimationHeader* anim = D_8085BE84[PLAYER_ANIMGROUP_43][this->modelAnimType]; + + if ((this->unk_396 == 6) || (this->unk_396 == 0x2E)) { + Player_AnimationPlayOnce(play, this, anim); + } else { + func_8082E784(this); + PlayerAnimation_Change(play, &this->skelAnime, anim, 2.0f / 3.0f, 0.0f, Animation_GetLastFrame(anim), + ANIMMODE_LOOP, -4.0f); + } + Player_StopHorizontalMovement(this); + } +} + +void func_808595B8(PlayState* play, Player* this, UNK_TYPE arg2) { + if (func_80847880(play, this)) { + return; + } + + if ((this->csMode == PLAYER_CSMODE_20) && (play->csCtx.state == CS_STATE_IDLE)) { + func_800B7298(play, NULL, PLAYER_CSMODE_END); + } else if (this->stateFlags1 & PLAYER_STATE1_8000000) { + func_80859300(play, this, 0); + this->actor.velocity.y = 0.0f; + } else { + PlayerAnimation_Update(play, &this->skelAnime); + if (func_801240DC(this) || (this->stateFlags1 & PLAYER_STATE1_800)) { + func_8083216C(this, play); + } + } +} + +void func_8085968C(PlayState* play, Player* this, UNK_TYPE arg2) { + if (this->actor.id == ACTOR_EN_TEST3) { + func_80838830(this, OBJECT_GI_MSSA); + this->stateFlags1 |= PLAYER_STATE1_400; + } + + func_8082DB90(play, this, + (this->transformation == PLAYER_FORM_DEKU) ? &gPlayerAnim_pn_getA : &gPlayerAnim_link_demo_get_itemA); +} + +void func_80859708(PlayState* play, Player* this, UNK_TYPE arg2) { + PlayerAnimation_Update(play, &this->skelAnime); + if ((this->actor.id == ACTOR_EN_TEST3) && Animation_OnFrame(&this->skelAnime, 20.0f)) { + this->getItemDrawIdPlusOne = GID_MASK_SUN + 1; + func_80151BB4(play, 0x1B); + Audio_PlayFanfare(NA_BGM_GET_NEW_MASK); + } +} + +void func_8085978C(PlayState* play, Player* this, UNK_TYPE arg2) { + f32 linearVelocity; + s16 yaw; + + this->stateFlags1 &= ~PLAYER_STATE1_2000000; + + yaw = Math_Vec3f_Yaw(&this->actor.world.pos, &this->unk_3A0); + linearVelocity = this->linearVelocity; + this->actor.world.rot.y = yaw; + this->actor.shape.rot.y = yaw; + this->currentYaw = yaw; + if (linearVelocity <= 0.0f) { + this->linearVelocity = 0.1f; + } else if (linearVelocity > 2.5f) { + this->linearVelocity = 2.5f; + } + + if ((this->transformation != PLAYER_FORM_HUMAN) && (play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_5)) { + R_PLAY_FILL_SCREEN_ON = 45; + R_PLAY_FILL_SCREEN_R = 255; + R_PLAY_FILL_SCREEN_G = 255; + R_PLAY_FILL_SCREEN_B = 255; + R_PLAY_FILL_SCREEN_ALPHA = 0; + play_sound(NA_SE_SY_WHITE_OUT_T); + } +} + +void func_80859890(PlayState* play, Player* this, UNK_TYPE arg2) { + f32 sp24; + + if (R_PLAY_FILL_SCREEN_ON > 0) { + R_PLAY_FILL_SCREEN_ALPHA += R_PLAY_FILL_SCREEN_ON; + if (R_PLAY_FILL_SCREEN_ALPHA > 255) { + R_PLAY_FILL_SCREEN_ON = -64; + R_PLAY_FILL_SCREEN_ALPHA = 255; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + this->actor.update = func_8012301C; + this->actor.draw = NULL; + this->unk_AE7 = 0; + } + } else if (R_PLAY_FILL_SCREEN_ON < 0) { + R_PLAY_FILL_SCREEN_ALPHA += R_PLAY_FILL_SCREEN_ON; + if (R_PLAY_FILL_SCREEN_ALPHA < 0) { + R_PLAY_FILL_SCREEN_ON = 0; + R_PLAY_FILL_SCREEN_ALPHA = 0; + } + } else { + sp24 = 2.5f; + func_808411D4(play, this, &sp24, 0xA); + this->unk_AE8++; + if (this->unk_AE8 >= 0x15) { + this->csMode = PLAYER_CSMODE_10; + } + } +} + +void func_80859990(PlayState* play, Player* this, UNK_TYPE arg2) { + this->linearVelocity = 2.5f; + func_80835BF8(&this->actor.world.pos, this->actor.shape.rot.y, 180.0f, &this->unk_3A0); +} + +void func_808599DC(PlayState* play, Player* this, UNK_TYPE arg2) { + f32 sp1C = 2.5f; + + func_808411D4(play, this, &sp1C, 0xA); +} + +void func_80859A10(PlayState* play, Player* this, UNK_TYPE arg2) { + func_8083B23C(this, play); +} + +void func_80859A44(PlayState* play, Player* this, UNK_TYPE arg2) { + func_80859248(this); + if (this->unk_AE8 != 0) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + Player_AnimationPlayLoop(play, this, func_8082EF54(this)); + this->unk_AE8 = 0; + } + func_8082FC60(this); + } else { + func_8083E958(play, this); + } +} + +void func_80859AD0(PlayState* play, Player* this, UNK_PTR arg2) { + func_80840F90(play, this, arg2, 0.0f, 0, 0); +} + +void func_80859AF8(PlayState* play, Player* this, UNK_PTR arg2) { + this->actor.shape.face = 0xF; + func_80840F90(play, this, arg2, 0.0f, 0, 0); +} + +void func_80859B28(PlayState* play, Player* this, UNK_PTR arg2) { + func_80840F90(play, this, arg2, 0.0f, 0, 1); +} + +void func_80859B54(PlayState* play, Player* this, UNK_TYPE arg2) { + func_80858CC8(play, this, &gPlayerAnim_link_normal_okarina_start); + this->itemAction = PLAYER_IA_OCARINA; + Player_SetModels(this, Player_ActionToModelGroup(this, this->itemAction)); +} + +void Player_Cutscene_Translate(PlayState* play, Player* this, CsCmdActorCue* playerAction) { + f32 startX = playerAction->startPos.x; + f32 startY = playerAction->startPos.y; + f32 startZ = playerAction->startPos.z; + f32 diffX = playerAction->endPos.x - startX; + f32 diffY = playerAction->endPos.y - startY; + f32 diffZ = playerAction->endPos.z - startZ; + f32 progress = (((f32)(play->csCtx.curFrame - playerAction->startFrame)) / + ((f32)(playerAction->endFrame - playerAction->startFrame))); + + this->actor.world.pos.x = (diffX * progress) + startX; + this->actor.world.pos.y = (diffY * progress) + startY; + this->actor.world.pos.z = (diffZ * progress) + startZ; +} + +void func_80859C60(PlayState* play, Player* this, void* arg2) { + if (arg2 != NULL) { + Player_Cutscene_Translate(play, this, arg2); + } + + PlayerAnimation_Update(play, &this->skelAnime); +} + +void func_80859CA0(PlayState* play, Player* this, s32 arg2) { + func_8082E514(play, this, D_8085BE84[PLAYER_ANIMGROUP_43][this->modelAnimType]); + Player_StopHorizontalMovement(this); +} + +void func_80859CE0(PlayState* play, Player* this, s32 arg2) { + this->actor.draw = Player_Draw; +} + +void func_80859CFC(PlayState* play, Player* this, UNK_TYPE arg2) { + func_80841358(play, this, false); + func_8082DB90(play, this, &gPlayerAnim_link_demo_return_to_past); +} + +void func_80859D44(PlayState* play, Player* this, UNK_TYPE arg2) { + PlayerAnimation_Update(play, &this->skelAnime); +} + +struct_8085DA94 D_8085DA94[PLAYER_CSMODE_MAX] = { + /* PLAYER_CSMODE_0 */ { 0, { NULL } }, + /* PLAYER_CSMODE_1 */ { -1, { func_808594D0 } }, + /* PLAYER_CSMODE_2 */ { 0, { NULL } }, + /* PLAYER_CSMODE_3 */ { 0, { NULL } }, + /* PLAYER_CSMODE_4 */ { 3, { &gPlayerAnim_link_demo_bikkuri } }, + /* PLAYER_CSMODE_5 */ { 0, { NULL } }, + /* PLAYER_CSMODE_END */ { 0, { NULL } }, + /* PLAYER_CSMODE_WAIT */ { -1, { func_808594D0 } }, + /* PLAYER_CSMODE_8 */ { 2, { &gPlayerAnim_link_demo_furimuki } }, + /* PLAYER_CSMODE_9 */ { -1, { func_8085978C } }, + /* PLAYER_CSMODE_10 */ { 3, { &gPlayerAnim_link_demo_warp } }, + /* PLAYER_CSMODE_11 */ { 5, { &gPlayerAnim_clink_demo_standup } }, + /* PLAYER_CSMODE_12 */ { 7, { &gPlayerAnim_clink_demo_standup_wait } }, + /* PLAYER_CSMODE_13 */ { 2, { &gPlayerAnim_link_demo_baru_op3 } }, + /* PLAYER_CSMODE_14 */ { 0, { NULL } }, + /* PLAYER_CSMODE_15 */ { 3, { &gPlayerAnim_link_demo_jibunmiru } }, + /* PLAYER_CSMODE_16 */ { -1, { func_80859B54 } }, + /* PLAYER_CSMODE_17 */ { 2, { &gPlayerAnim_link_normal_okarina_end } }, + /* PLAYER_CSMODE_18 */ { 16, { &gPlayerAnim_link_normal_hang_up_down } }, + /* PLAYER_CSMODE_19 */ { -1, { func_80859CA0 } }, + /* PLAYER_CSMODE_20 */ { -1, { func_808594D0 } }, + /* PLAYER_CSMODE_21 */ { 3, { &gPlayerAnim_clink_demo_mimawasi } }, + /* PLAYER_CSMODE_22 */ { 6, { &gPlayerAnim_om_get_mae } }, + /* PLAYER_CSMODE_23 */ { 3, { &gPlayerAnim_link_demo_look_hand } }, + /* PLAYER_CSMODE_24 */ { 3, { &gPlayerAnim_link_normal_wait_typeB_20f } }, + /* PLAYER_CSMODE_25 */ { -1, { func_80859CFC } }, + /* PLAYER_CSMODE_26 */ { -1, { func_8085A66C } }, + /* PLAYER_CSMODE_27 */ { 3, { &gPlayerAnim_link_demo_zeldamiru } }, + /* PLAYER_CSMODE_28 */ { 3, { &gPlayerAnim_link_demo_kenmiru1 } }, + /* PLAYER_CSMODE_29 */ { 3, { &gPlayerAnim_link_demo_kenmiru2 } }, + /* PLAYER_CSMODE_30 */ { 3, { &gPlayerAnim_link_demo_kenmiru2_modori } }, + /* PLAYER_CSMODE_31 */ { 6, { &gameplay_keep_Linkanim_00D310 } }, + /* PLAYER_CSMODE_32 */ { -1, { func_80859FCC } }, + /* PLAYER_CSMODE_33 */ { 3, { &gPlayerAnim_demo_rakka } }, + /* PLAYER_CSMODE_34 */ { 4, { &gPlayerAnim_demo_pikupiku } }, + /* PLAYER_CSMODE_35 */ { 3, { &gameplay_keep_Linkanim_00D2B8 } }, + /* PLAYER_CSMODE_36 */ { -1, { func_8085A120 } }, + /* PLAYER_CSMODE_37 */ { -1, { func_8085A19C } }, + /* PLAYER_CSMODE_38 */ { 6, { &gameplay_keep_Linkanim_00D278 } }, + /* PLAYER_CSMODE_39 */ { 6, { &gameplay_keep_Linkanim_00D288 } }, + /* PLAYER_CSMODE_40 */ { 5, { &gPlayerAnim_rakuba } }, + /* PLAYER_CSMODE_41 */ { 5, { &gPlayerAnim_bajyo_furikaeru } }, + /* PLAYER_CSMODE_42 */ { 5, { &gPlayerAnim_okiagaru } }, + /* PLAYER_CSMODE_43 */ { 5, { &gPlayerAnim_okiagaru_tatu } }, + /* PLAYER_CSMODE_44 */ { 7, { &gPlayerAnim_bajyo_walk } }, + /* PLAYER_CSMODE_45 */ { 5, { &gPlayerAnim_rakka } }, + /* PLAYER_CSMODE_46 */ { 5, { &gPlayerAnim_sirimochi } }, + /* PLAYER_CSMODE_47 */ { 5, { &gPlayerAnim_spotlight } }, + /* PLAYER_CSMODE_48 */ { 3, { &gPlayerAnim_al_hensin } }, + /* PLAYER_CSMODE_49 */ { 5, { &gPlayerAnim_dl_jibunmiru } }, + /* PLAYER_CSMODE_50 */ { 5, { &gPlayerAnim_vs_yousei } }, + /* PLAYER_CSMODE_51 */ { 5, { &gPlayerAnim_urusai } }, + /* PLAYER_CSMODE_52 */ { 5, { &gPlayerAnim_okarinatori } }, + /* PLAYER_CSMODE_53 */ { 5, { &gPlayerAnim_lost_horse } }, + /* PLAYER_CSMODE_54 */ { 4, { &gPlayerAnim_lost_horse_wait } }, + /* PLAYER_CSMODE_55 */ { 5, { &gPlayerAnim_lost_horse2 } }, + /* PLAYER_CSMODE_56 */ { 14, { &gPlayerAnim_okarinatori } }, + /* PLAYER_CSMODE_57 */ { 5, { &gPlayerAnim_cl_tobikakaru } }, + /* PLAYER_CSMODE_58 */ { -1, { func_8085978C } }, + /* PLAYER_CSMODE_59 */ { 5, { &gameplay_keep_Linkanim_00D0A0 } }, + /* PLAYER_CSMODE_60 */ { 2, { &gPlayerAnim_cl_furafura } }, + /* PLAYER_CSMODE_61 */ { 7, { &gPlayerAnim_cl_nigeru } }, + /* PLAYER_CSMODE_62 */ { 5, { &gPlayerAnim_cl_ononoki } }, + /* PLAYER_CSMODE_63 */ { 3, { &gPlayerAnim_al_gaku } }, + /* PLAYER_CSMODE_64 */ { 3, { &gPlayerAnim_al_fuwafuwa } }, + /* PLAYER_CSMODE_65 */ { 3, { &gPlayerAnim_al_fuwafuwa_modori } }, + /* PLAYER_CSMODE_66 */ { 3, { &gPlayerAnim_al_elf_tobidasi } }, + /* PLAYER_CSMODE_67 */ { -1, { func_8085968C } }, + /* PLAYER_CSMODE_68 */ { -1, { func_8085A24C } }, + /* PLAYER_CSMODE_69 */ { -1, { func_8085A330 } }, + /* PLAYER_CSMODE_70 */ { 7, { &gPlayerAnim_cl_tewofuru } }, + /* PLAYER_CSMODE_71 */ { 5, { &gPlayerAnim_cl_jibun_miru } }, + /* PLAYER_CSMODE_72 */ { 5, { &gPlayerAnim_cl_hoo } }, + /* PLAYER_CSMODE_73 */ { 3, { &gPlayerAnim_al_yareyare } }, + /* PLAYER_CSMODE_74 */ { 3, { &gPlayerAnim_al_yes } }, + /* PLAYER_CSMODE_75 */ { 3, { &gPlayerAnim_al_no } }, + /* PLAYER_CSMODE_76 */ { 3, { &gPlayerAnim_al_unun } }, + /* PLAYER_CSMODE_77 */ { 7, { &gPlayerAnim_dl_yusaburu } }, + /* PLAYER_CSMODE_78 */ { 5, { &gPlayerAnim_dl_kokeru } }, + /* PLAYER_CSMODE_79 */ { 3, { &gPlayerAnim_alink_powerup } }, + /* PLAYER_CSMODE_80 */ { 4, { &gPlayerAnim_alink_rakkatyu } }, + /* PLAYER_CSMODE_81 */ { 3, { &gPlayerAnim_alink_kyoro } }, + /* PLAYER_CSMODE_82 */ { 4, { &gPlayerAnim_alink_yurayura } }, + /* PLAYER_CSMODE_83 */ { 3, { &gPlayerAnim_alink_somukeru } }, + /* PLAYER_CSMODE_84 */ { 5, { &gPlayerAnim_alink_fukitobu } }, + /* PLAYER_CSMODE_85 */ { 3, { &gameplay_keep_Linkanim_00CFC8 } }, + /* PLAYER_CSMODE_86 */ { 4, { &gPlayerAnim_alink_tereru } }, + /* PLAYER_CSMODE_87 */ { 5, { &gameplay_keep_Linkanim_00D1D0 } }, + /* PLAYER_CSMODE_88 */ { 3, { &gPlayerAnim_alink_kaitenmiss } }, + /* PLAYER_CSMODE_89 */ { 4, { &gameplay_keep_Linkanim_00CFC0 } }, + /* PLAYER_CSMODE_90 */ { 4, { &gameplay_keep_Linkanim_00CFB8 } }, + /* PLAYER_CSMODE_91 */ { 4, { &gameplay_keep_Linkanim_00D050 } }, + /* PLAYER_CSMODE_92 */ { 4, { &gameplay_keep_Linkanim_00D048 } }, + /* PLAYER_CSMODE_93 */ { -1, { func_8085A8C4 } }, + /* PLAYER_CSMODE_94 */ { 3, { &gPlayerAnim_alink_ozigi } }, + /* PLAYER_CSMODE_95 */ { 3, { &gPlayerAnim_alink_ozigi_modori } }, + /* PLAYER_CSMODE_96 */ { 9, { &gPlayerAnim_link_normal_back_downA } }, + /* PLAYER_CSMODE_97 */ { -1, { func_8085A530 } }, + /* PLAYER_CSMODE_98 */ { 15, { &gPlayerAnim_cl_maskoff } }, + /* PLAYER_CSMODE_99 */ { 7, { &gPlayerAnim_cl_kubisime } }, + /* PLAYER_CSMODE_100 */ { 3, { &gPlayerAnim_alink_ee } }, + /* PLAYER_CSMODE_101 */ { 3, { &gameplay_keep_Linkanim_00CFF0 } }, + /* PLAYER_CSMODE_102 */ { -1, { func_8085A768 } }, + /* PLAYER_CSMODE_103 */ { -1, { func_8085AA60 } }, + /* PLAYER_CSMODE_104 */ { 5, { &gPlayerAnim_cl_dakisime } }, + /* PLAYER_CSMODE_105 */ { 5, { &gPlayerAnim_kf_omen } }, + /* PLAYER_CSMODE_106 */ { 5, { &gPlayerAnim_kf_dakiau } }, + /* PLAYER_CSMODE_107 */ { 5, { &gPlayerAnim_kf_hanare } }, + /* PLAYER_CSMODE_108 */ { 5, { &gPlayerAnim_kf_miseau } }, + /* PLAYER_CSMODE_109 */ { 5, { &gPlayerAnim_kf_awase } }, + /* PLAYER_CSMODE_110 */ { 7, { &gPlayerAnim_kf_tetunagu_loop } }, + /* PLAYER_CSMODE_111 */ { 3, { &gPlayerAnim_link_keirei } }, + /* PLAYER_CSMODE_112 */ { 5, { &gPlayerAnim_cl_umanoru } }, + /* PLAYER_CSMODE_113 */ { 5, { &gPlayerAnim_cl_wakare } }, + /* PLAYER_CSMODE_114 */ { 4, { &gPlayerAnim_alink_dance_loop } }, + /* PLAYER_CSMODE_115 */ { 2, { &gPlayerAnim_link_demo_goma_furimuki } }, + /* PLAYER_CSMODE_116 */ { 7, { &gPlayerAnim_link_uma_anim_fastrun } }, + /* PLAYER_CSMODE_117 */ { 5, { &gPlayerAnim_cl_umamiage } }, + /* PLAYER_CSMODE_118 */ { 7, { &gPlayerAnim_demo_suwari1 } }, + /* PLAYER_CSMODE_119 */ { 7, { &gPlayerAnim_demo_suwari2 } }, + /* PLAYER_CSMODE_120 */ { 7, { &gPlayerAnim_demo_suwari3 } }, + /* PLAYER_CSMODE_121 */ { -1, { func_80859990 } }, + /* PLAYER_CSMODE_122 */ { 0, { NULL } }, + /* PLAYER_CSMODE_123 */ { -1, { func_80859A10 } }, + /* PLAYER_CSMODE_124 */ { 7, { &gPlayerAnim_clink_demo_get1 } }, + /* PLAYER_CSMODE_125 */ { 5, { &gPlayerAnim_clink_demo_get2 } }, + /* PLAYER_CSMODE_126 */ { 5, { &gPlayerAnim_clink_demo_get3 } }, + /* PLAYER_CSMODE_127 */ { 3, { &gPlayerAnim_link_demo_gurad } }, + /* PLAYER_CSMODE_128 */ { 4, { &gPlayerAnim_link_demo_sita_wait } }, + /* PLAYER_CSMODE_129 */ { 3, { &gPlayerAnim_L_1kyoro } }, + /* PLAYER_CSMODE_130 */ { 3, { &gPlayerAnim_L_2kyoro } }, + /* PLAYER_CSMODE_131 */ { 3, { &gPlayerAnim_L_sagaru } }, + /* PLAYER_CSMODE_132 */ { 3, { &gPlayerAnim_L_bouzen } }, + /* PLAYER_CSMODE_133 */ { 3, { &gPlayerAnim_L_kamaeru } }, + /* PLAYER_CSMODE_134 */ { 3, { &gPlayerAnim_L_hajikareru } }, + /* PLAYER_CSMODE_135 */ { 3, { &gPlayerAnim_L_ken_miru } }, + /* PLAYER_CSMODE_136 */ { 3, { &gPlayerAnim_L_mukinaoru } }, + /* PLAYER_CSMODE_137 */ { 3, { &gPlayerAnim_link_demo_return_to_past } }, + /* PLAYER_CSMODE_138 */ { 3, { &gPlayerAnim_link_last_hit_motion1 } }, + /* PLAYER_CSMODE_139 */ { 3, { &gPlayerAnim_link_last_hit_motion2 } }, +}; + +struct_8085DA94 D_8085DEF4[PLAYER_CSMODE_MAX] = { + /* PLAYER_CSMODE_0 */ { 0, { NULL } }, + /* PLAYER_CSMODE_1 */ { -1, { func_80859414 } }, + /* PLAYER_CSMODE_2 */ { -1, { func_80859AD0 } }, + /* PLAYER_CSMODE_3 */ { -1, { func_80859B28 } }, + /* PLAYER_CSMODE_4 */ { 11, { NULL } }, + /* PLAYER_CSMODE_5 */ { -1, { func_8085ADA0 } }, + /* PLAYER_CSMODE_END */ { -1, { func_8085AACC } }, + /* PLAYER_CSMODE_WAIT */ { -1, { func_808595B8 } }, + /* PLAYER_CSMODE_8 */ { 18, { D_8085DA70 } }, + /* PLAYER_CSMODE_9 */ { -1, { func_80859890 } }, + /* PLAYER_CSMODE_10 */ { -1, { func_80859C60 } }, + /* PLAYER_CSMODE_11 */ { 18, { D_8085D9E0 } }, + /* PLAYER_CSMODE_12 */ { 11, { NULL } }, + /* PLAYER_CSMODE_13 */ { 11, { NULL } }, + /* PLAYER_CSMODE_14 */ { 0, { NULL } }, + /* PLAYER_CSMODE_15 */ { 11, { NULL } }, + /* PLAYER_CSMODE_16 */ { 17, { &gPlayerAnim_link_normal_okarina_swing } }, + /* PLAYER_CSMODE_17 */ { 11, { NULL } }, + /* PLAYER_CSMODE_18 */ { 11, { NULL } }, + /* PLAYER_CSMODE_19 */ { -1, { func_8085A710 } }, + /* PLAYER_CSMODE_20 */ { -1, { func_808595B8 } }, + /* PLAYER_CSMODE_21 */ { 12, { &gPlayerAnim_clink_demo_mimawasi_wait } }, + /* PLAYER_CSMODE_22 */ { -1, { func_80859D70 } }, + /* PLAYER_CSMODE_23 */ { 12, { &gPlayerAnim_link_demo_look_hand_wait } }, + /* PLAYER_CSMODE_24 */ { 11, { NULL } }, + /* PLAYER_CSMODE_25 */ { 11, { NULL } }, + /* PLAYER_CSMODE_26 */ { -1, { func_8085A6C0 } }, + /* PLAYER_CSMODE_27 */ { 12, { &gPlayerAnim_link_demo_zeldamiru_wait } }, + /* PLAYER_CSMODE_28 */ { 12, { &gPlayerAnim_link_demo_kenmiru1_wait } }, + /* PLAYER_CSMODE_29 */ { 12, { &gPlayerAnim_link_demo_kenmiru2_wait } }, + /* PLAYER_CSMODE_30 */ { 12, { &gPlayerAnim_demo_link_nwait } }, + /* PLAYER_CSMODE_31 */ { 12, { &gameplay_keep_Linkanim_00D318 } }, + /* PLAYER_CSMODE_32 */ { -1, { func_80859FF4 } }, + /* PLAYER_CSMODE_33 */ { -1, { Player_Cutscene_TranslateReverse } }, + /* PLAYER_CSMODE_34 */ { 11, { NULL } }, + /* PLAYER_CSMODE_35 */ { 12, { &gameplay_keep_Linkanim_00D2C0 } }, + /* PLAYER_CSMODE_36 */ { -1, { func_8085A144 } }, + /* PLAYER_CSMODE_37 */ { -1, { func_8085A1D4 } }, + /* PLAYER_CSMODE_38 */ { 12, { &gameplay_keep_Linkanim_00D280 } }, + /* PLAYER_CSMODE_39 */ { 12, { &gameplay_keep_Linkanim_00D290 } }, + /* PLAYER_CSMODE_40 */ { 18, { D_8085D9F0 } }, + /* PLAYER_CSMODE_41 */ { 11, { NULL } }, + /* PLAYER_CSMODE_42 */ { 18, { D_8085DA00 } }, + /* PLAYER_CSMODE_43 */ { 13, { &gPlayerAnim_okiagaru_wait } }, + /* PLAYER_CSMODE_44 */ { -1, { func_8085A364 } }, + /* PLAYER_CSMODE_45 */ { 18, { D_8085DA2C } }, + /* PLAYER_CSMODE_46 */ { 12, { &gPlayerAnim_sirimochi_wait } }, + /* PLAYER_CSMODE_47 */ { 12, { &gPlayerAnim_spotlight_wait } }, + /* PLAYER_CSMODE_48 */ { 12, { &gPlayerAnim_al_hensin_loop } }, + /* PLAYER_CSMODE_49 */ { 12, { &gPlayerAnim_dl_jibunmiru_wait } }, + /* PLAYER_CSMODE_50 */ { 18, { D_8085DA50 } }, + /* PLAYER_CSMODE_51 */ { 11, { NULL } }, + /* PLAYER_CSMODE_52 */ { 18, { D_8085D9FC } }, + /* PLAYER_CSMODE_53 */ { 12, { &gPlayerAnim_lost_horse_wait } }, + /* PLAYER_CSMODE_54 */ { -1, { func_8085A364 } }, + /* PLAYER_CSMODE_55 */ { 18, { D_8085DA1C } }, + /* PLAYER_CSMODE_56 */ { 11, { NULL } }, + /* PLAYER_CSMODE_57 */ { 18, { D_8085DA0C } }, + /* PLAYER_CSMODE_58 */ { -1, { func_808599DC } }, + /* PLAYER_CSMODE_59 */ { 11, { NULL } }, + /* PLAYER_CSMODE_60 */ { 18, { D_8085DA28 } }, + /* PLAYER_CSMODE_61 */ { -1, { func_8085A364 } }, + /* PLAYER_CSMODE_62 */ { 11, { NULL } }, + /* PLAYER_CSMODE_63 */ { 11, { NULL } }, + /* PLAYER_CSMODE_64 */ { 12, { &gPlayerAnim_al_fuwafuwa_loop } }, + /* PLAYER_CSMODE_65 */ { -1, { func_8085A40C } }, + /* PLAYER_CSMODE_66 */ { 11, { NULL } }, + /* PLAYER_CSMODE_67 */ { -1, { func_80859708 } }, + /* PLAYER_CSMODE_68 */ { -1, { func_8085A2AC } }, + /* PLAYER_CSMODE_69 */ { 11, { NULL } }, + /* PLAYER_CSMODE_70 */ { 11, { NULL } }, + /* PLAYER_CSMODE_71 */ { -1, { func_8085A40C } }, + /* PLAYER_CSMODE_72 */ { 11, { NULL } }, + /* PLAYER_CSMODE_73 */ { 11, { NULL } }, + /* PLAYER_CSMODE_74 */ { 11, { NULL } }, + /* PLAYER_CSMODE_75 */ { 11, { NULL } }, + /* PLAYER_CSMODE_76 */ { 11, { NULL } }, + /* PLAYER_CSMODE_77 */ { 11, { NULL } }, + /* PLAYER_CSMODE_78 */ { 18, { D_8085DA78 } }, + /* PLAYER_CSMODE_79 */ { 12, { &gPlayerAnim_alink_powerup_loop } }, + /* PLAYER_CSMODE_80 */ { -1, { func_8085A364 } }, + /* PLAYER_CSMODE_81 */ { 12, { &gPlayerAnim_alink_kyoro_loop } }, + /* PLAYER_CSMODE_82 */ { 11, { NULL } }, + /* PLAYER_CSMODE_83 */ { 12, { &gPlayerAnim_alink_somukeru_loop } }, + /* PLAYER_CSMODE_84 */ { 18, { D_8085DA80 } }, + /* PLAYER_CSMODE_85 */ { 12, { &gameplay_keep_Linkanim_00CFD0 } }, + /* PLAYER_CSMODE_86 */ { 11, { NULL } }, + /* PLAYER_CSMODE_87 */ { 11, { NULL } }, + /* PLAYER_CSMODE_88 */ { 11, { NULL } }, + /* PLAYER_CSMODE_89 */ { 11, { NULL } }, + /* PLAYER_CSMODE_90 */ { 11, { NULL } }, + /* PLAYER_CSMODE_91 */ { 11, { NULL } }, + /* PLAYER_CSMODE_92 */ { 11, { NULL } }, + /* PLAYER_CSMODE_93 */ { -1, { func_8085A940 } }, + /* PLAYER_CSMODE_94 */ { 12, { &gPlayerAnim_alink_ozigi_loop } }, + /* PLAYER_CSMODE_95 */ { 11, { NULL } }, + /* PLAYER_CSMODE_96 */ { -1, { func_8085A4A4 } }, + /* PLAYER_CSMODE_97 */ { -1, { func_8085A5DC } }, + /* PLAYER_CSMODE_98 */ { -1, { func_8085AA84 } }, + /* PLAYER_CSMODE_99 */ { 11, { NULL } }, + /* PLAYER_CSMODE_100 */ { 12, { &gPlayerAnim_alink_ee_loop } }, + /* PLAYER_CSMODE_101 */ { 12, { &gameplay_keep_Linkanim_00CFF8 } }, + /* PLAYER_CSMODE_102 */ { -1, { func_8085A7C0 } }, + /* PLAYER_CSMODE_103 */ { 11, { NULL } }, + /* PLAYER_CSMODE_104 */ { 13, { &gPlayerAnim_cl_dakisime_loop } }, + /* PLAYER_CSMODE_105 */ { 13, { &gPlayerAnim_kf_omen_loop } }, + /* PLAYER_CSMODE_106 */ { 13, { &gPlayerAnim_kf_dakiau_loop } }, + /* PLAYER_CSMODE_107 */ { 13, { &gPlayerAnim_kf_hanare_loop } }, + /* PLAYER_CSMODE_108 */ { 11, { NULL } }, + /* PLAYER_CSMODE_109 */ { 11, { NULL } }, + /* PLAYER_CSMODE_110 */ { 11, { NULL } }, + /* PLAYER_CSMODE_111 */ { 12, { &gPlayerAnim_link_kei_wait } }, + /* PLAYER_CSMODE_112 */ { 13, { &gPlayerAnim_cl_umanoru_loop } }, + /* PLAYER_CSMODE_113 */ { 13, { &gPlayerAnim_cl_wakare_loop } }, + /* PLAYER_CSMODE_114 */ { 11, { NULL } }, + /* PLAYER_CSMODE_115 */ { -1, { func_8085AA10 } }, + /* PLAYER_CSMODE_116 */ { 11, { NULL } }, + /* PLAYER_CSMODE_117 */ { -1, { func_8085A364 } }, + /* PLAYER_CSMODE_118 */ { 11, { NULL } }, + /* PLAYER_CSMODE_119 */ { 11, { NULL } }, + /* PLAYER_CSMODE_120 */ { 11, { NULL } }, + /* PLAYER_CSMODE_121 */ { -1, { func_808599DC } }, + /* PLAYER_CSMODE_122 */ { -1, { func_80859AF8 } }, + /* PLAYER_CSMODE_123 */ { -1, { func_80859A44 } }, + /* PLAYER_CSMODE_124 */ { 11, { NULL } }, + /* PLAYER_CSMODE_125 */ { 11, { NULL } }, + /* PLAYER_CSMODE_126 */ { 11, { NULL } }, + /* PLAYER_CSMODE_127 */ { 12, { &gPlayerAnim_link_demo_gurad_wait } }, + /* PLAYER_CSMODE_128 */ { 11, { NULL } }, + /* PLAYER_CSMODE_129 */ { 12, { &gPlayerAnim_L_kw } }, + /* PLAYER_CSMODE_130 */ { 11, { NULL } }, + /* PLAYER_CSMODE_131 */ { 11, { NULL } }, + /* PLAYER_CSMODE_132 */ { 11, { NULL } }, + /* PLAYER_CSMODE_133 */ { 11, { NULL } }, + /* PLAYER_CSMODE_134 */ { -1, { func_80859D44 } }, + /* PLAYER_CSMODE_135 */ { 11, { NULL } }, + /* PLAYER_CSMODE_136 */ { 12, { &gPlayerAnim_L_kennasi_w } }, + /* PLAYER_CSMODE_137 */ { -1, { func_80859EBC } }, + /* PLAYER_CSMODE_138 */ { -1, { func_80859F4C } }, + /* PLAYER_CSMODE_139 */ { -1, { func_80859F4C } }, +}; + +PlayerAnimationHeader* D_8085E354[PLAYER_FORM_MAX] = { + &gPlayerAnim_L_okarina_get, // PLAYER_FORM_FIERCE_DEITY + &gPlayerAnim_L_okarina_get, // PLAYER_FORM_GORON + &gPlayerAnim_L_okarina_get, // PLAYER_FORM_ZORA + &gPlayerAnim_L_okarina_get, // PLAYER_FORM_DEKU + &gPlayerAnim_om_get, // PLAYER_FORM_HUMAN +}; + +struct_8085E368 D_8085E368[PLAYER_FORM_MAX] = { + { { -200, 700, 100 }, { 800, 600, 800 } }, // PLAYER_FORM_FIERCE_DEITY + { { -200, 700, 100 }, { 800, 600, 800 } }, // PLAYER_FORM_GORON + { { -200, 700, 100 }, { 800, 600, 800 } }, // PLAYER_FORM_ZORA + { { -200, 700, 100 }, { 800, 600, 800 } }, // PLAYER_FORM_DEKU + { { -200, 500, 0 }, { 600, 400, 600 } }, // PLAYER_FORM_HUMAN +}; + +Color_RGBA8 D_8085E3A4 = { 255, 255, 255, 0 }; +Color_RGBA8 D_8085E3A8 = { 0, 128, 128, 0 }; + +void func_80859D70(PlayState* play, Player* this, UNK_TYPE arg2) { + struct_8085E368* posInfo; + Vec3f effectPos; + Vec3f randPos; + + func_808591BC(play, this, D_8085E354[this->transformation]); + + if (this->rightHandType != 0xFF) { + this->rightHandType = 0xFF; + } else { + posInfo = &D_8085E368[this->transformation]; + randPos.x = randPlusMinusPoint5Scaled(posInfo->range.x) + posInfo->base.x; + randPos.y = randPlusMinusPoint5Scaled(posInfo->range.y) + posInfo->base.y; + randPos.z = randPlusMinusPoint5Scaled(posInfo->range.z) + posInfo->base.z; + SkinMatrix_Vec3fMtxFMultXYZ(&this->shieldMf, &randPos, &effectPos); + EffectSsKirakira_SpawnDispersed(play, &effectPos, &gZeroVec3f, &gZeroVec3f, &D_8085E3A4, &D_8085E3A8, 600, -10); + } +} + +void func_80859EBC(PlayState* play, Player* this, s32 arg2) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_8085AACC(play, this, arg2); + } else if (this->unk_AE8 == 0) { + Item_Give(play, ITEM_SWORD_RAZOR); + func_80841358(play, this, false); + } else { + func_808484CC(this); + } +} + +void func_80859F4C(PlayState* play, Player* this, UNK_TYPE arg2) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_8083FCF0(play, this, 0.0f, 99.0f, this->skelAnime.endFrame - 8.0f); + } + if (this->heldItemAction != PLAYER_IA_SWORD_GILDED) { + func_80841358(play, this, true); + } +} + +void func_80859FCC(PlayState* play, Player* this, UNK_TYPE arg2) { + if (this->transformation != PLAYER_FORM_DEKU) { + gSaveContext.save.playerForm = PLAYER_FORM_DEKU; + } +} + +void func_80859FF4(PlayState* play, Player* this, UNK_TYPE arg2) { + PlayerAnimation_Update(play, &this->skelAnime); + if (gSaveContext.save.playerForm != this->transformation) { + this->actor.update = func_8012301C; + this->actor.draw = NULL; + } +} + +void Player_Cutscene_TranslateReverse(PlayState* play, Player* this, void* arg) { + CsCmdActorCue* playerAction = arg; + f32 xEnd = playerAction->endPos.x; + f32 yEnd = playerAction->endPos.y; + f32 zEnd = playerAction->endPos.z; + f32 xDiff; + f32 yDiff; + f32 zDiff; + f32 progress; + + xDiff = playerAction->startPos.x - xEnd; + yDiff = playerAction->startPos.y - yEnd; + zDiff = playerAction->startPos.z - zEnd; + + progress = ((f32)(playerAction->endFrame - play->csCtx.curFrame)) / + ((f32)(playerAction->endFrame - playerAction->startFrame)); + + this->actor.world.pos.x = (xDiff * progress) + xEnd; + this->actor.world.pos.y = (yDiff * progress) + yEnd; + this->actor.world.pos.z = (zDiff * progress) + zEnd; + PlayerAnimation_Update(play, &this->skelAnime); +} + +void func_8085A120(PlayState* play, Player* this, UNK_TYPE arg2) { + if (this->transformation != PLAYER_FORM_FIERCE_DEITY) { + gSaveContext.save.playerForm = PLAYER_FORM_FIERCE_DEITY; + } +} + +void func_8085A144(PlayState* play, Player* this, UNK_TYPE arg2) { + PlayerAnimation_Update(play, &this->skelAnime); + if (gSaveContext.save.playerForm != this->transformation) { + this->actor.update = func_8012301C; + this->actor.draw = NULL; + } +} + +void func_8085A19C(PlayState* play, Player* this, UNK_TYPE arg2) { + Player_AnimationPlayOnce(play, this, &gPlayerAnim_demo_rakka); + this->unk_AAA = -0x8000; +} + +void func_8085A1D4(PlayState* play, Player* this, UNK_TYPE arg2) { + PlayerAnimation_Update(play, &this->skelAnime); + this->actor.gravity = 0.0f; + Math_StepToF(&this->actor.velocity.y, -this->actor.terminalVelocity, -((f32)REG(68) / 100.0f)); +} + +void func_8085A24C(PlayState* play, Player* this, UNK_TYPE arg2) { + func_8082DB90(play, this, D_8085D17C[this->transformation]); + this->itemAction = PLAYER_IA_OCARINA; + Player_SetModels(this, Player_ActionToModelGroup(this, this->itemAction)); +} + +void func_8085A2AC(PlayState* play, Player* this, UNK_TYPE arg2) { + if ((PlayerAnimation_Update(play, &this->skelAnime)) && + (this->skelAnime.animation == D_8085D17C[this->transformation])) { + func_808525C4(play, this); + return; + } + if (this->unk_AE8 != 0) { + func_8085255C(play, this); + } +} + +void func_8085A330(PlayState* play, Player* this, UNK_TYPE arg2) { + Player_AnimationPlayOnceReverse(play, this, D_8085D17C[this->transformation]); +} + +void func_8085A364(PlayState* play, Player* this, void* arg2) { + Player_Cutscene_Translate(play, this, arg2); + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_8082EB18(play, this, &gPlayerAnim_cl_umamiage_loop); + } + + if (this->skelAnime.animation == &gPlayerAnim_cl_nigeru) { + Player_PlayAnimSfx(this, D_8085DA48); + } else if (this->skelAnime.animation == &gPlayerAnim_alink_rakkatyu) { + func_800B8F98(&this->actor, NA_SE_PL_FLYING_AIR - SFX_FLAG); + } else { + func_80858FE8(this); + } +} + +void func_8085A40C(PlayState* play, Player* this, void* arg2) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + func_80859CA0(play, this, arg2); + } else if (this->skelAnime.animation == &gPlayerAnim_al_fuwafuwa_modori) { + Player_PlayAnimSfx(this, D_8085DA88); + } else if (this->skelAnime.animation == &gPlayerAnim_cl_jibun_miru) { + Player_PlayAnimSfx(this, D_8085DA8C); + } +} + +void func_8085A4A4(PlayState* play, Player* this, void* arg2) { + if (PlayerAnimation_Update(play, &this->skelAnime) && (this->unk_AE8 == 0) && + (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { + Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_normal_back_downB); + this->unk_AE8 = 1; + } + if (this->unk_AE8 != 0) { + func_80832F24(this); + } +} + +void func_8085A530(PlayState* play, Player* this, void* arg2) { + PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_link_normal_give_other, 1.0f, + (play->sceneId == SCENE_ALLEY) ? IREG(56) : 0.0f, + Animation_GetLastFrame(&gPlayerAnim_link_normal_give_other), ANIMMODE_ONCE, -8.0f); +} + +void func_8085A5DC(PlayState* play, Player* this, void* arg2) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + if (this->unk_AE8++ >= 0x15) { + PlayerAnimation_Change(play, &this->skelAnime, &gPlayerAnim_pz_wait, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, + -16.0f); + } + } +} + +void func_8085A66C(PlayState* play, Player* this, void* arg2) { + if (func_801242B4(this)) { + func_8085929C(play, this, 0); + } else { + func_80858E40(play, this, &gPlayerAnim_link_demo_kousan); + } +} + +void func_8085A6C0(PlayState* play, Player* this, void* anim) { + if (func_801242B4(this)) { + func_80859300(play, this, 0); + } else { + func_80858FBC(play, this, anim); + } +} + +void func_8085A710(PlayState* play, Player* this, void* anim) { + func_80858FBC(play, this, anim); + if (func_8083D23C(this, play)) { + play->csCtx.state = CS_STATE_STOP; + CutsceneManager_Stop(CutsceneManager_GetCurrentCsId()); + } +} + +void func_8085A768(PlayState* play, Player* this, void* arg2) { + func_80838830(this, OBJECT_GI_RESERVE_C_01); + func_80858E40(play, this, &gPlayerAnim_link_normal_give_other); + this->stateFlags2 &= ~PLAYER_STATE2_1000000; +} + +void func_8085A7C0(PlayState* play, Player* this, UNK_TYPE arg2) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + if (this->unk_AE8 == 0) { + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) || + (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE)) { + this->getItemDrawIdPlusOne = GID_NONE + 1; + this->unk_AE8 = -1; + } else { + this->getItemDrawIdPlusOne = GID_PENDANT_OF_MEMORIES + 1; + } + } else if (this->unk_AE8 < 0) { + if (Actor_HasParent(&this->actor, play)) { + this->actor.parent = NULL; + this->unk_AE8 = 1; + } else { + Actor_OfferGetItem(&this->actor, play, GI_PENDANT_OF_MEMORIES, 9999.9f, 9999.9f); + } + } + } else if (PlayerAnimation_OnFrame(&this->skelAnime, 4.0f)) { + SET_WEEKEVENTREG(WEEKEVENTREG_50_80); + } +} + +void func_8085A8C4(PlayState* play, Player* this, UNK_TYPE arg2) { + if ((this->transformation != PLAYER_FORM_HUMAN) && (play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_5)) { + R_PLAY_FILL_SCREEN_ON = 45; + R_PLAY_FILL_SCREEN_R = 255; + R_PLAY_FILL_SCREEN_G = 255; + R_PLAY_FILL_SCREEN_B = 255; + R_PLAY_FILL_SCREEN_ALPHA = 0; + play_sound(NA_SE_SY_WHITE_OUT_T); + } +} + +void func_8085A940(PlayState* play, Player* this, UNK_TYPE arg2) { + if (R_PLAY_FILL_SCREEN_ON > 0) { + R_PLAY_FILL_SCREEN_ALPHA += R_PLAY_FILL_SCREEN_ON; + if (R_PLAY_FILL_SCREEN_ALPHA > 255) { + R_PLAY_FILL_SCREEN_ON = -64; + R_PLAY_FILL_SCREEN_ALPHA = 255; + gSaveContext.save.playerForm = PLAYER_FORM_HUMAN; + this->actor.update = func_8012301C; + this->actor.draw = NULL; + this->unk_AE7 = 0; + } + } else if (R_PLAY_FILL_SCREEN_ON < 0) { + R_PLAY_FILL_SCREEN_ALPHA += R_PLAY_FILL_SCREEN_ON; + if (R_PLAY_FILL_SCREEN_ALPHA < 0) { + R_PLAY_FILL_SCREEN_ON = 0; + R_PLAY_FILL_SCREEN_ALPHA = 0; + } + } else { + PlayerAnimation_Update(play, &this->skelAnime); + } +} + +void func_8085AA10(PlayState* play, Player* this, UNK_TYPE arg2) { + if (PlayerAnimation_Update(play, &this->skelAnime) && (CutsceneManager_GetCurrentCsId() == CS_ID_GLOBAL_DOOR)) { + CutsceneManager_Stop(CS_ID_GLOBAL_DOOR); + } +} + +void func_8085AA60(PlayState* play, Player* this, UNK_TYPE arg2) { + func_80848640(play, this); +} + +void func_8085AA84(PlayState* play, Player* this, UNK_TYPE arg2) { + if (PlayerAnimation_Update(play, &this->skelAnime)) { + this->stateFlags2 |= PLAYER_STATE2_1000000; + } +} + +void func_8085AACC(PlayState* play, Player* this, UNK_TYPE arg2) { + if (func_801242B4(this)) { + func_808353DC(play, this); + func_8082DC64(play, this); + } else { + func_80839ED0(this, play); + if (!func_808391D8(this, play)) { + func_8083D23C(this, play); + } + } + + this->csMode = PLAYER_CSMODE_0; + this->unk_AA5 = PLAYER_UNKAA5_0; +} + +void Player_Cutscene_SetPosAndYawToStart(Player* this, CsCmdActorCue* playerAction) { + this->actor.world.pos.x = playerAction->startPos.x; + this->actor.world.pos.y = playerAction->startPos.y; + this->actor.world.pos.z = playerAction->startPos.z; + + this->currentYaw = this->actor.shape.rot.y = playerAction->rot.y; +} + +void Player_Cutscene_8085ABA8(Player* this, CsCmdActorCue* playerAction) { + f32 xDiff = playerAction->startPos.x - (s32)this->actor.world.pos.x; + f32 yDiff = playerAction->startPos.y - (s32)this->actor.world.pos.y; + f32 zDiff = playerAction->startPos.z - (s32)this->actor.world.pos.z; + f32 dist; + s16 temp_v0; + + temp_v0 = (s16)playerAction->rot.y - this->actor.shape.rot.y; + dist = sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff)); + if (this->linearVelocity == 0.0f) { + if ((dist > 50.0f) || (ABS_ALT(temp_v0) > 0x4000)) { + Player_Cutscene_SetPosAndYawToStart(this, playerAction); + } + } + + this->skelAnime.moveFlags = 0; + func_8082E784(this); +} + +void func_8085AC9C(PlayState* play, Player* this, CsCmdActorCue* cue, struct_8085DA94* arg3) { + if (arg3->type > 0) { + D_8085D990[arg3->type](play, this, arg3->anim); + } else if (arg3->type < 0) { + arg3->func(play, this, cue); + } + + if ((D_80862B6C & 4) && !(this->skelAnime.moveFlags & ANIM_FLAG_4)) { + this->skelAnime.morphTable[PLAYER_LIMB_ROOT - 1].y /= this->ageProperties->unk_08; + D_80862B6C = 0; + } +} + +void func_8085AD5C(PlayState* play, Player* this, PlayerCsMode csMode) { + if ((csMode != PLAYER_CSMODE_1) && (csMode != PLAYER_CSMODE_WAIT) && (csMode != PLAYER_CSMODE_20) && + (csMode != PLAYER_CSMODE_END)) { + func_8082DCA0(play, this); + } +} + +void func_8085ADA0(PlayState* play, Player* this, s32 arg2) { + CsCmdActorCue* cue = (this->actor.id == ACTOR_EN_TEST3) + ? play->csCtx.actorCues[Cutscene_GetCueChannel(play, CS_CMD_ACTOR_CUE_506)] + : play->csCtx.playerCue; + s32 var_a0 = false; + s32 pad; + s32 csMode; + + if ((play->csCtx.state == CS_STATE_IDLE) || (play->csCtx.state == CS_STATE_STOP) || + (play->csCtx.state == CS_STATE_RUN_UNSTOPPABLE)) { + if ((D_8085D384[this->unk_396] == PLAYER_CSMODE_68) && (play->sceneId == SCENE_OKUJOU)) { + this->unk_AA5 = PLAYER_UNKAA5_5; + + if (func_80838A90(this, play)) { + this->csMode = PLAYER_CSMODE_0; + } + return; + } else { + var_a0 = true; + + if (D_8085D384[this->unk_396] != PLAYER_CSMODE_16) { + this->csMode = PLAYER_CSMODE_END; + func_800B7298(play, NULL, PLAYER_CSMODE_END); + this->unk_396 = 0; + Player_StopHorizontalMovement(this); + return; + } + } + } + + if (!var_a0 && (cue == NULL)) { + this->actor.flags &= ~ACTOR_FLAG_40; + return; + } + + if (!var_a0 && (this->unk_396 != cue->id)) { + csMode = D_8085D384[cue->id]; + + if ((csMode >= PLAYER_CSMODE_0) && (gDisablePlayerCsModeStartPos == 0)) { + if ((csMode == PLAYER_CSMODE_2) || (csMode == PLAYER_CSMODE_3)) { + Player_Cutscene_8085ABA8(this, cue); + } else { + Player_Cutscene_SetPosAndYawToStart(this, cue); + } + } + + if (csMode == PLAYER_CSMODE_108) { + this->stateFlags3 |= PLAYER_STATE3_20000000; + } else if (csMode == PLAYER_CSMODE_110) { + this->stateFlags3 &= ~PLAYER_STATE3_20000000; + } + + D_80862B6C = this->skelAnime.moveFlags; + + func_8082E794(this); + func_8085AD5C(play, this, ABS_ALT(csMode)); + func_8085AC9C(play, this, cue, &D_8085DA94[ABS_ALT(csMode)]); + + this->unk_AE8 = 0; + this->unk_AE7 = 0; + this->unk_396 = cue->id; + } + + csMode = D_8085D384[this->unk_396]; + func_8085AC9C(play, this, cue, &D_8085DEF4[ABS_ALT(csMode)]); + + if ((u16)cue->rot.x != 0) { + Math_SmoothStepToS(&this->actor.focus.rot.x, (u16)cue->rot.x, 4, 0x2710, 0); + func_80832754(this, false); + } +} + +void func_8085B08C(Player* this, PlayState* play) { + if (this->csMode != this->prevCsMode) { + D_80862B6C = this->skelAnime.moveFlags; + func_8082E794(this); + + this->prevCsMode = this->csMode; + func_8085AD5C(play, this, this->csMode); + func_8085AC9C(play, this, NULL, &D_8085DA94[this->csMode]); + } + + func_8085AC9C(play, this, NULL, &D_8085DEF4[this->csMode]); +} + +s32 Player_StartFishing(PlayState* play) { + Player* player = GET_PLAYER(play); + + func_8082DE50(play, player); + func_80831990(play, player, ITEM_FISHING_ROD); + return 1; +} + +// Player_GrabPlayerImpl? Player_GrabPlayerNoChecks? +void func_8085B170(PlayState* play, Player* this) { + func_8082DE50(play, this); + Player_SetAction(play, this, func_80853CC0, 0); + Player_AnimationPlayOnce(play, this, &gPlayerAnim_link_normal_re_dead_attack); + this->stateFlags2 |= PLAYER_STATE2_80; + func_8082DAD4(this); + Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_HELD); +} + +s32 Player_GrabPlayer(PlayState* play, Player* player) { + if (!Player_InBlockingCsMode(play, player) && (player->invincibilityTimer >= 0) && !func_801240DC(player)) { + if (!(player->stateFlags1 & (PLAYER_STATE1_80 | PLAYER_STATE1_2000 | PLAYER_STATE1_4000 | PLAYER_STATE1_100000 | + PLAYER_STATE1_200000 | PLAYER_STATE1_800000))) { + if (!(player->stateFlags2 & PLAYER_STATE2_80) && !(player->stateFlags3 & PLAYER_STATE3_80)) { + func_8085B170(play, player); + return true; + } + } + } + + return false; +} + +s32 func_8085B28C(PlayState* play, Player* this, PlayerCsMode csMode) { + Player* player = GET_PLAYER(play); + + if (this != NULL) { + if (csMode == PLAYER_CSMODE_0) { + return func_8084E034 == this->actionFunc; + } + + if ((this->actor.id == ACTOR_EN_TEST3) && (csMode < 0)) { + func_8083B0E4(play, this, this->actor.home.rot.y); + return false; + } + + if (this->actor.id == ACTOR_EN_TEST3) { + player = this; + } + } + + if ((player->actor.id == ACTOR_EN_TEST3) || !Player_InBlockingCsMode(play, player)) { + func_8082DE50(play, player); + Player_SetAction(play, player, func_8085B08C, 0); + player->csMode = csMode; + player->unk_398 = &this->actor; + func_8082DAD4(player); + + return true; + } + + return false; +} + +void func_8085B384(Player* this, PlayState* play) { + Player_SetAction(play, this, func_80849FE0, 1); + func_8082E438(play, this, func_8082ED20(this)); + this->currentYaw = this->actor.shape.rot.y; +} + +/** + * Returns true if Player's health reaches zero + */ +s32 Player_InflictDamage(PlayState* play, s32 damage) { + Player* player = GET_PLAYER(play); + + if ((player->stateFlags2 & PLAYER_STATE2_80) || !Player_InBlockingCsMode(play, player)) { + if (func_808339D4(play, player, damage) == 0) { + player->stateFlags2 &= ~PLAYER_STATE2_80; + return true; + } + } + + return false; +} + +// Start talking with the given actor +void Player_TalkWithPlayer(PlayState* play, Actor* actor) { + s32 pad; + Player* player = GET_PLAYER(play); + + func_808323C0(player, CS_ID_GLOBAL_TALK); + if ((player->talkActor != NULL) || (actor == player->tatlActor) || + CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_1 | ACTOR_FLAG_40000)) { + actor->flags |= ACTOR_FLAG_TALK_REQUESTED; + } + + player->talkActor = actor; + player->exchangeItemId = PLAYER_IA_NONE; + player->targetedActor = actor; + + if (actor->textId == 0xFFFF) { + func_800B7298(play, actor, PLAYER_CSMODE_1); + actor->flags |= ACTOR_FLAG_TALK_REQUESTED; + func_8082DE14(play, player); + } else { + if (player->actor.flags & ACTOR_FLAG_TALK_REQUESTED) { + player->actor.textId = 0; + } else { + player->actor.flags |= ACTOR_FLAG_TALK_REQUESTED; + player->actor.textId = actor->textId; + } + + if (player->stateFlags1 & PLAYER_STATE1_800000) { + s32 sp24 = player->unk_AE8; + + func_8082DE14(play, player); + func_80837B60(play, player); + player->unk_AE8 = sp24; + } else { + if (func_801242B4(player)) { + func_80832558(play, player, func_80837B60); + func_8082E634(play, player, &gPlayerAnim_link_swimer_swim_wait); + } else if ((actor->category != ACTORCAT_NPC) || (player->heldItemAction == PLAYER_IA_FISHING_ROD)) { + func_80837B60(play, player); + + if (!func_80123420(player)) { + if ((actor != player->tatlActor) && (actor->xzDistToPlayer < (actor->colChkInfo.cylRadius + 40))) { + func_8082DB90(play, player, &gPlayerAnim_link_normal_backspace); + } else { + Player_AnimationPlayLoop(play, player, func_8082ED20(player)); + } + } + } else { + func_80832558(play, player, func_80837B60); + func_8082DB90(play, player, + (actor->xzDistToPlayer < (actor->colChkInfo.cylRadius + 40)) + ? &gPlayerAnim_link_normal_backspace + : &gPlayerAnim_link_normal_talk_free); + } + + if (player->skelAnime.animation == &gPlayerAnim_link_normal_backspace) { + func_8082E920(play, player, ANIM_FLAG_1 | ANIM_FLAG_8 | ANIM_FLAG_NOMOVE); + } + func_8082DAD4(player); + } + + player->stateFlags1 |= PLAYER_STATE1_40 | PLAYER_STATE1_20000000; + } + + if ((player->tatlActor == player->talkActor) && ((player->talkActor->textId & 0xFF00) != 0x200)) { + player->tatlActor->flags |= ACTOR_FLAG_TALK_REQUESTED; + } +} + +void func_8085B74C(PlayState* play) { + Player* player = GET_PLAYER(play); + f32 temp_fv1; + f32 linearVelocity = player->linearVelocity; + + if (linearVelocity < 0.0f) { + linearVelocity = -linearVelocity; + player->actor.world.rot.y += 0x8000; + } + + temp_fv1 = R_RUN_SPEED_LIMIT / 100.0f; + + if (temp_fv1 < linearVelocity) { + gSaveContext.entranceSpeed = temp_fv1; + } else { + gSaveContext.entranceSpeed = linearVelocity; + } + + func_80835324(play, player, 400.0f, + (sPlayerConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) ? D_80862B16 : player->actor.world.rot.y); + player->stateFlags1 |= (PLAYER_STATE1_1 | PLAYER_STATE1_20000000); +} + +void func_8085B820(PlayState* play, s16 arg1) { + Player* player = GET_PLAYER(play); + + player->actor.focus.rot.y = arg1; + func_80836D8C(player); +} + +PlayerItemAction func_8085B854(PlayState* play, Player* player, ItemId itemId) { + PlayerItemAction itemAction = Player_ItemToItemAction(player, itemId); + + if ((itemAction >= PLAYER_IA_MASK_MIN) && (itemAction <= PLAYER_IA_MASK_MAX) && + (itemAction == GET_IA_FROM_MASK(player->currentMask))) { + itemAction = PLAYER_IA_NONE; + } + + if ((itemAction <= PLAYER_IA_NONE) || (itemAction >= PLAYER_IA_MAX)) { + return PLAYER_IA_MINUS1; + } + + player->itemAction = PLAYER_IA_NONE; + player->actionFunc = NULL; + func_80831760(play, player, func_80853A5C, 0); + player->csId = CS_ID_GLOBAL_TALK; + player->itemAction = itemAction; + Player_AnimationPlayOnce(play, player, &gPlayerAnim_link_normal_give_other); + player->stateFlags1 |= (PLAYER_STATE1_40 | PLAYER_STATE1_20000000); + player->getItemDrawIdPlusOne = GID_NONE + 1; + player->exchangeItemId = itemAction; + + return itemAction; +} + +s32 func_8085B930(PlayState* play, PlayerAnimationHeader* talkAnim, AnimationMode animMode) { + Player* player = GET_PLAYER(play); + + if (!(player->actor.flags & ACTOR_FLAG_TALK_REQUESTED)) { + return false; + } + + PlayerAnimation_Change(play, &player->skelAnime, (talkAnim == NULL) ? func_8082ED20(player) : talkAnim, 2.0f / 3.0f, + 0.0f, Animation_GetLastFrame(talkAnim), animMode, -6.0f); + return true; +} diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c index 8d7647bfea..46397dc199 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c +++ b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.c @@ -58,7 +58,7 @@ u32 EffectSsGSplash_Init(PlayState* play, u32 index, EffectSs* this, void* initP this->rType = initParams->type; } else { switch (initParams->type) { - case 0: + case EFFSSGSPLASH_TYPE_0: this->rgPrimColorR = 255; this->rgPrimColorG = 255; this->rgPrimColorB = 255; @@ -67,9 +67,9 @@ u32 EffectSsGSplash_Init(PlayState* play, u32 index, EffectSs* this, void* initP this->rgEnvColorG = 255; this->rgEnvColorB = 255; this->rgEnvColorA = 200; - this->rType = 0; + this->rType = EFFSSGSPLASH_TYPE_0; break; - case 1: + case EFFSSGSPLASH_TYPE_1: this->rgPrimColorR = 255; this->rgPrimColorG = 255; this->rgPrimColorB = 255; @@ -78,9 +78,9 @@ u32 EffectSsGSplash_Init(PlayState* play, u32 index, EffectSs* this, void* initP this->rgEnvColorG = 255; this->rgEnvColorB = 255; this->rgEnvColorA = 255; - this->rType = 1; + this->rType = EFFSSGSPLASH_TYPE_1; break; - case 2: + case EFFSSGSPLASH_TYPE_2: this->rgPrimColorR = 255; this->rgPrimColorG = 255; this->rgPrimColorB = 255; @@ -89,7 +89,7 @@ u32 EffectSsGSplash_Init(PlayState* play, u32 index, EffectSs* this, void* initP this->rgEnvColorG = 255; this->rgEnvColorB = 255; this->rgEnvColorA = 200; - this->rType = 2; + this->rType = EFFSSGSPLASH_TYPE_2; break; } } @@ -100,7 +100,7 @@ void EffectSsGSplash_Draw(PlayState* play, u32 index, EffectSs* this) { s16 texIndex; switch (this->rType) { - case 0: + case EFFSSGSPLASH_TYPE_0: texIndex = this->rgTexIndex / 100; if (texIndex > 7) { texIndex = 7; @@ -108,7 +108,7 @@ void EffectSsGSplash_Draw(PlayState* play, u32 index, EffectSs* this) { EffectSs_DrawGEffect(play, this, waterSplashTextures[texIndex]); break; - case 1: + case EFFSSGSPLASH_TYPE_1: texIndex = this->rgTexIndex / 100; if (texIndex > 7) { texIndex = 7; @@ -116,7 +116,7 @@ void EffectSsGSplash_Draw(PlayState* play, u32 index, EffectSs* this) { EffectSs_DrawGEffect(play, this, waterSplashTextures[texIndex]); break; - case 2: + case EFFSSGSPLASH_TYPE_2: texIndex = this->rgTexIndex / 100; if (texIndex > 7) { texIndex = 7; @@ -129,7 +129,7 @@ void EffectSsGSplash_Draw(PlayState* play, u32 index, EffectSs* this) { void EffectSsGSplash_Update(PlayState* play, u32 index, EffectSs* this) { Vec3f newSplashPos; - if ((this->rType == 1) && (this->life == 5)) { + if ((this->rType == EFFSSGSPLASH_TYPE_1) && (this->life == 5)) { newSplashPos = this->pos; newSplashPos.y += ((this->rgScale * 20) * 0.002f); EffectSsGSplash_Spawn(play, &newSplashPos, 0, 0, 2, this->rgScale / 2); diff --git a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.h b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.h index 9d3fbcd133..363db3e5a8 100644 --- a/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.h +++ b/src/overlays/effects/ovl_Effect_Ss_G_Splash/z_eff_ss_g_splash.h @@ -3,6 +3,12 @@ #include "global.h" +typedef enum EffSsGSplashType { + /* 0 */ EFFSSGSPLASH_TYPE_0, + /* 1 */ EFFSSGSPLASH_TYPE_1, + /* 2 */ EFFSSGSPLASH_TYPE_2 +} EffSsGSplashType; + typedef struct { /* 0x00 */ Vec3f pos; /* 0x0C */ u8 type; diff --git a/tools/disasm/disasm.py b/tools/disasm/disasm.py index e7b0f4d815..37ba8b45ea 100755 --- a/tools/disasm/disasm.py +++ b/tools/disasm/disasm.py @@ -186,9 +186,9 @@ def proper_name(symbol, in_data=False, is_symbol=True): # bg_ikana_mirror symbol with large addend folded into %lo elif symbol == 0x80B80248: return variables_ast[0x80B801A8][0] + f" + 0x{0x80B80248 - 0x80B801A8:X}" - # player symbol with very large addend folded into %lo, since we don't know the real symbol just use the first data symbol for now + # player symbol with very large addend folded into %lo elif symbol == 0x8084D2FC: - return variables_ast[0x8085B9F0][0] + f" - 0x{0x8085B9F0 - 0x8084D2FC:X}" + return variables_ast[0x8085D0FA][0] + f" - 0x{0x8085D0FA - 0x8084D2FC:X}" # OS_K0_TO_PHYSICAL on rspS2DEX text and data symbols elif symbol == 0x001ABAB0 or symbol == 0x001E3BB0: return variables_ast[symbol + 0x80000000][0] + " - 0x80000000" diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 6d9916fd76..0559d0a827 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -4245,14 +4245,14 @@ 0x80828788:("KaleidoScope_UpdateOpening",), 0x8082895C:("KaleidoScope_Update",), 0x8082DA90:("func_8082DA90",), - 0x8082DABC:("func_8082DABC",), + 0x8082DABC:("Player_StopHorizontalMovement",), 0x8082DAD4:("func_8082DAD4",), 0x8082DAFC:("func_8082DAFC",), - 0x8082DB18:("func_8082DB18",), - 0x8082DB3C:("func_8082DB3C",), + 0x8082DB18:("Player_AnimationPlayOnce",), + 0x8082DB3C:("Player_AnimationPlayLoop",), 0x8082DB60:("func_8082DB60",), 0x8082DB90:("func_8082DB90",), - 0x8082DBC0:("func_8082DBC0",), + 0x8082DBC0:("Player_AnimationPlayOnceReverse",), 0x8082DC28:("func_8082DC28",), 0x8082DC38:("func_8082DC38",), 0x8082DC64:("func_8082DC64",), @@ -4262,18 +4262,18 @@ 0x8082DE50:("func_8082DE50",), 0x8082DE88:("func_8082DE88",), 0x8082DF2C:("func_8082DF2C",), - 0x8082DF48:("func_8082DF48",), - 0x8082DF8C:("func_8082DF8C",), + 0x8082DF48:("Player_RequestRumble",), + 0x8082DF8C:("Player_AnimSfx_PlayVoice",), 0x8082E00C:("func_8082E00C",), - 0x8082E078:("func_8082E078",), - 0x8082E094:("func_8082E094",), - 0x8082E0CC:("func_8082E0CC",), - 0x8082E0F4:("func_8082E0F4",), - 0x8082E12C:("func_8082E12C",), - 0x8082E188:("func_8082E188",), - 0x8082E1BC:("func_8082E1BC",), + 0x8082E078:("Player_GetFloorSfx",), + 0x8082E094:("Player_AnimSfx_PlayFloor",), + 0x8082E0CC:("Player_GetFloorSfxByAge",), + 0x8082E0F4:("Player_AnimSfx_PlayFloorByAge",), + 0x8082E12C:("Player_AnimSfx_PlayFloorWalk",), + 0x8082E188:("Player_AnimSfx_PlayFloorJump",), + 0x8082E1BC:("Player_AnimSfx_PlayFloorLand",), 0x8082E1F0:("func_8082E1F0",), - 0x8082E224:("func_8082E224",), + 0x8082E224:("Player_PlayAnimSfx",), 0x8082E438:("func_8082E438",), 0x8082E4A4:("func_8082E4A4",), 0x8082E514:("func_8082E514",), @@ -4309,22 +4309,22 @@ 0x8082EF9C:("func_8082EF9C",), 0x8082EFE4:("func_8082EFE4",), 0x8082F02C:("func_8082F02C",), - 0x8082F09C:("func_8082F09C",), - 0x8082F0E4:("func_8082F0E4",), + 0x8082F09C:("Player_ResetCylinder",), + 0x8082F0E4:("Player_SetCylinderForAttack",), 0x8082F164:("func_8082F164",), 0x8082F1AC:("func_8082F1AC",), 0x8082F43C:("func_8082F43C",), 0x8082F470:("func_8082F470",), - 0x8082F524:("func_8082F524",), + 0x8082F524:("Player_ItemToItemAction",), 0x8082F594:("func_8082F594",), 0x8082F5A4:("func_8082F5A4",), 0x8082F5C0:("func_8082F5C0",), 0x8082F5FC:("func_8082F5FC",), - 0x8082F62C:("func_8082F62C",), + 0x8082F62C:("Player_SpawnExplosive",), 0x8082F7F4:("func_8082F7F4",), 0x8082F8A0:("func_8082F8A0",), 0x8082F8BC:("func_8082F8BC",), - 0x8082F938:("func_8082F938",), + 0x8082F938:("Player_OverrideBlureColors",), 0x8082FA5C:("func_8082FA5C",), 0x8082FB68:("func_8082FB68",), 0x8082FBE8:("func_8082FBE8",), @@ -4359,7 +4359,7 @@ 0x808313A8:("func_808313A8",), 0x808313F0:("func_808313F0",), 0x80831454:("func_80831454",), - 0x80831494:("func_80831494",), + 0x80831494:("Player_SetAction",), 0x8083172C:("func_8083172C",), 0x80831760:("func_80831760",), 0x808317C4:("func_808317C4",), @@ -4420,16 +4420,16 @@ 0x808354A4:("func_808354A4",), 0x808355D8:("func_808355D8",), 0x8083562C:("func_8083562C",), - 0x80835BC8:("func_80835BC8",), + 0x80835BC8:("Player_TranslateAndRotateY",), 0x80835BF8:("func_80835BF8",), - 0x80835C64:("func_80835C64",), + 0x80835C64:("Player_SpawnFairy",), 0x80835CD8:("func_80835CD8",), 0x80835D2C:("func_80835D2C",), 0x80835D58:("func_80835D58",), 0x80835DF8:("func_80835DF8",), - 0x80835EAC:("func_80835EAC",), - 0x8083604C:("func_8083604C",), - 0x80836258:("func_80836258",), + 0x80835EAC:("Player_Door_Staircase",), + 0x8083604C:("Player_Door_Sliding",), + 0x80836258:("Player_Door_Knob",), 0x808365DC:("func_808365DC",), 0x80836888:("func_80836888",), 0x8083692C:("func_8083692C",), @@ -4442,7 +4442,7 @@ 0x80836C70:("func_80836C70",), 0x80836D8C:("func_80836D8C",), 0x80836DC0:("func_80836DC0",), - 0x80836EA0:("func_80836EA0",), + 0x80836EA0:("Player_RequestQuake",), 0x80836F10:("func_80836F10",), 0x808370D4:("func_808370D4",), 0x80837134:("func_80837134",), @@ -4464,7 +4464,7 @@ 0x808381F8:("func_808381F8",), 0x8083827C:("func_8083827C",), 0x8083868C:("func_8083868C",), - 0x80838760:("func_80838760",), + 0x80838760:("Player_StopCutscene",), 0x808387A0:("func_808387A0",), 0x80838830:("func_80838830",), 0x808388B8:("func_808388B8",), @@ -4500,11 +4500,11 @@ 0x8083A844:("func_8083A844",), 0x8083A878:("func_8083A878",), 0x8083A98C:("func_8083A98C",), - 0x8083AD04:("func_8083AD04",), - 0x8083AD8C:("func_8083AD8C",), - 0x8083ADB8:("func_8083ADB8",), + 0x8083AD04:("Player_InitMode_Telescope",), + 0x8083AD8C:("Player_InitMode_B",), + 0x8083ADB8:("Player_InitMode_D",), 0x8083ADF0:("func_8083ADF0",), - 0x8083AE38:("func_8083AE38",), + 0x8083AE38:("Player_InitMode_F",), 0x8083AECC:("func_8083AECC",), 0x8083AF30:("func_8083AF30",), 0x8083AF8C:("func_8083AF8C",), @@ -4557,7 +4557,7 @@ 0x8083E958:("func_8083E958",), 0x8083E9C4:("func_8083E9C4",), 0x8083EA44:("func_8083EA44",), - 0x8083EBD0:("func_8083EBD0",), + 0x8083EBD0:("Player_ChooseIdleAnim",), 0x8083EE60:("func_8083EE60",), 0x8083F144:("func_8083F144",), 0x8083F190:("func_8083F190",), @@ -4571,7 +4571,7 @@ 0x8083FCF0:("func_8083FCF0",), 0x8083FD80:("func_8083FD80",), 0x8083FE38:("func_8083FE38",), - 0x8083FE90:("func_8083FE90",), + 0x8083FE90:("Player_RequestQuakeAndRumble",), 0x8083FEF4:("func_8083FEF4",), 0x8083FF30:("func_8083FF30",), 0x8083FFEC:("func_8083FFEC",), @@ -4590,33 +4590,33 @@ 0x80840F34:("func_80840F34",), 0x80840F90:("func_80840F90",), 0x808411D4:("func_808411D4",), - 0x808412A0:("func_808412A0",), - 0x808412BC:("func_808412BC",), + 0x808412A0:("Player_InitMode_0",), + 0x808412BC:("Player_InitMode_2",), 0x80841358:("func_80841358",), - 0x80841408:("func_80841408",), - 0x808414E0:("func_808414E0",), - 0x80841528:("func_80841528",), - 0x808415A0:("func_808415A0",), - 0x808415E4:("func_808415E4",), - 0x80841624:("func_80841624",), + 0x80841408:("Player_InitMode_1",), + 0x808414E0:("Player_InitMode_3",), + 0x80841528:("Player_InitMode_4",), + 0x808415A0:("Player_InitMode_7",), + 0x808415E4:("Player_InitMode_5",), + 0x80841624:("Player_InitMode_6",), 0x80841744:("func_80841744",), - 0x8084182C:("func_8084182C",), + 0x8084182C:("Player_InitCommon",), 0x80841A50:("func_80841A50",), 0x80841AC4:("Player_Init",), 0x80842510:("func_80842510",), 0x808425B4:("func_808425B4",), - 0x808426F0:("func_808426F0",), + 0x808426F0:("Player_SetDoAction",), 0x808430E0:("func_808430E0",), 0x80843178:("func_80843178",), - 0x80843EC0:("func_80843EC0",), + 0x80843EC0:("Player_UpdateCamAndSeqModes",), 0x808442D8:("func_808442D8",), 0x808445C4:("func_808445C4",), - 0x808446F4:("func_808446F4",), + 0x808446F4:("Player_DetectSecrets",), 0x80844784:("func_80844784",), 0x80844D80:("func_80844D80",), - 0x80844EF8:("func_80844EF8",), + 0x80844EF8:("Player_UpdateCommon",), 0x808460B8:("Player_Update",), - 0x808463C0:("func_808463C0",), + 0x808463C0:("Player_DrawGameplay",), 0x80846460:("func_80846460",), 0x80846528:("Player_Draw",), 0x808470D4:("Player_Destroy",), @@ -4834,7 +4834,7 @@ 0x80859AF8:("func_80859AF8",), 0x80859B28:("func_80859B28",), 0x80859B54:("func_80859B54",), - 0x80859BA8:("func_80859BA8",), + 0x80859BA8:("Player_Cutscene_Translate",), 0x80859C60:("func_80859C60",), 0x80859CA0:("func_80859CA0",), 0x80859CE0:("func_80859CE0",), @@ -4845,7 +4845,7 @@ 0x80859F4C:("func_80859F4C",), 0x80859FCC:("func_80859FCC",), 0x80859FF4:("func_80859FF4",), - 0x8085A04C:("func_8085A04C",), + 0x8085A04C:("Player_Cutscene_TranslateReverse",), 0x8085A120:("func_8085A120",), 0x8085A144:("func_8085A144",), 0x8085A19C:("func_8085A19C",), @@ -4869,19 +4869,19 @@ 0x8085AA60:("func_8085AA60",), 0x8085AA84:("func_8085AA84",), 0x8085AACC:("func_8085AACC",), - 0x8085AB58:("func_8085AB58",), - 0x8085ABA8:("func_8085ABA8",), + 0x8085AB58:("Player_Cutscene_SetPosAndYawToStart",), + 0x8085ABA8:("Player_Cutscene_8085ABA8",), 0x8085AC9C:("func_8085AC9C",), 0x8085AD5C:("func_8085AD5C",), 0x8085ADA0:("func_8085ADA0",), 0x8085B08C:("func_8085B08C",), - 0x8085B134:("func_8085B134",), + 0x8085B134:("Player_StartFishing",), 0x8085B170:("func_8085B170",), - 0x8085B1F0:("func_8085B1F0",), + 0x8085B1F0:("Player_GrabPlayer",), 0x8085B28C:("func_8085B28C",), 0x8085B384:("func_8085B384",), - 0x8085B3E0:("func_8085B3E0",), - 0x8085B460:("func_8085B460",), + 0x8085B3E0:("Player_InflictDamage",), + 0x8085B460:("Player_TalkWithPlayer",), 0x8085B74C:("func_8085B74C",), 0x8085B820:("func_8085B820",), 0x8085B854:("func_8085B854",), @@ -8591,24 +8591,24 @@ 0x8099BE48:("EnCrow_OverrideLimbDraw",), 0x8099BF20:("EnCrow_PostLimbDraw",), 0x8099BFA4:("EnCrow_Draw",), - 0x8099C290:("func_8099C290",), - 0x8099C328:("func_8099C328",), - 0x8099C41C:("func_8099C41C",), + 0x8099C290:("EnCow_RotatePoint",), + 0x8099C328:("EnCow_SetColliderPos",), + 0x8099C41C:("EnCow_SetTailPos",), 0x8099C498:("EnCow_Init",), 0x8099C834:("EnCow_Destroy",), - 0x8099C880:("func_8099C880",), - 0x8099CAA8:("func_8099CAA8",), - 0x8099CB20:("func_8099CB20",), - 0x8099CB68:("func_8099CB68",), - 0x8099CBCC:("func_8099CBCC",), - 0x8099CC68:("func_8099CC68",), - 0x8099CCF8:("func_8099CCF8",), - 0x8099CDA0:("func_8099CDA0",), - 0x8099CFAC:("func_8099CFAC",), + 0x8099C880:("EnCow_UpdateAnimation",), + 0x8099CAA8:("EnCow_TalkEnd",), + 0x8099CB20:("EnCow_GiveMilkEnd",), + 0x8099CB68:("EnCow_GiveMilkWait",), + 0x8099CBCC:("EnCow_GiveMilk",), + 0x8099CC68:("EnCow_CheckForEmptyBottle",), + 0x8099CCF8:("EnCow_Talk",), + 0x8099CDA0:("EnCow_Idle",), + 0x8099CFAC:("EnCow_DoTail",), 0x8099D144:("EnCow_Update",), - 0x8099D3C0:("func_8099D3C0",), - 0x8099D4AC:("func_8099D4AC",), - 0x8099D4FC:("func_8099D4FC",), + 0x8099D3C0:("EnCow_UpdateTail",), + 0x8099D4AC:("EnCow_OverrideLimbDraw",), + 0x8099D4FC:("EnCow_PostLimbDraw",), 0x8099D53C:("EnCow_Draw",), 0x8099D59C:("func_8099D59C",), 0x8099D780:("OceffWipe4_Init",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index f40abb468f..be8c6e08f6 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -4941,52 +4941,9 @@ 0x8085B9F0:("D_8085B9F0","UNK_TYPE1","",0x1), 0x8085BA08:("D_8085BA08","UNK_TYPE1","",0x1), 0x8085BA20:("D_8085BA20","UNK_TYPE1","",0x1), - 0x8085BA38:("D_8085BA38","UNK_TYPE1","",0x1), - 0x8085BE84:("D_8085BE84","UNK_TYPE1","",0x1), - 0x8085BE9C:("D_8085BE9C","UNK_TYPE1","",0x1), - 0x8085BEB4:("D_8085BEB4","UNK_TYPE1","",0x1), - 0x8085BECC:("D_8085BECC","UNK_TYPE1","",0x1), - 0x8085BEE4:("D_8085BEE4","UNK_TYPE1","",0x1), - 0x8085BEFC:("D_8085BEFC","UNK_TYPE1","",0x1), - 0x8085BF14:("D_8085BF14","UNK_TYPE1","",0x1), - 0x8085BF44:("D_8085BF44","UNK_TYPE1","",0x1), - 0x8085BF5C:("D_8085BF5C","UNK_TYPE1","",0x1), - 0x8085BF74:("D_8085BF74","UNK_TYPE1","",0x1), - 0x8085BF8C:("D_8085BF8C","UNK_TYPE1","",0x1), - 0x8085BFA4:("D_8085BFA4","UNK_TYPE1","",0x1), - 0x8085BFBC:("D_8085BFBC","UNK_TYPE1","",0x1), - 0x8085BFD4:("D_8085BFD4","UNK_TYPE1","",0x1), - 0x8085BFEC:("D_8085BFEC","UNK_TYPE1","",0x1), - 0x8085C004:("D_8085C004","UNK_TYPE1","",0x1), - 0x8085C01C:("D_8085C01C","UNK_TYPE1","",0x1), - 0x8085C034:("D_8085C034","UNK_TYPE1","",0x1), - 0x8085C04C:("D_8085C04C","UNK_TYPE1","",0x1), - 0x8085C064:("D_8085C064","UNK_TYPE1","",0x1), - 0x8085C07C:("D_8085C07C","UNK_TYPE1","",0x1), - 0x8085C094:("D_8085C094","UNK_TYPE1","",0x1), - 0x8085C0C4:("D_8085C0C4","UNK_TYPE1","",0x1), - 0x8085C0DC:("D_8085C0DC","UNK_TYPE1","",0x1), - 0x8085C0F4:("D_8085C0F4","UNK_TYPE1","",0x1), - 0x8085C10C:("D_8085C10C","UNK_TYPE1","",0x1), - 0x8085C124:("D_8085C124","UNK_TYPE1","",0x1), - 0x8085C13C:("D_8085C13C","UNK_TYPE1","",0x1), - 0x8085C154:("D_8085C154","UNK_TYPE1","",0x1), - 0x8085C16C:("D_8085C16C","UNK_TYPE1","",0x1), - 0x8085C184:("D_8085C184","UNK_TYPE1","",0x1), - 0x8085C19C:("D_8085C19C","UNK_TYPE1","",0x1), - 0x8085C1B4:("D_8085C1B4","UNK_TYPE1","",0x1), - 0x8085C1CC:("D_8085C1CC","UNK_TYPE1","",0x1), - 0x8085C1E4:("D_8085C1E4","UNK_TYPE1","",0x1), - 0x8085C1FC:("D_8085C1FC","UNK_TYPE1","",0x1), - 0x8085C214:("D_8085C214","UNK_TYPE1","",0x1), - 0x8085C22C:("D_8085C22C","UNK_TYPE1","",0x1), - 0x8085C244:("D_8085C244","UNK_TYPE1","",0x1), - 0x8085C25C:("D_8085C25C","UNK_TYPE1","",0x1), - 0x8085C274:("D_8085C274","UNK_TYPE1","",0x1), - 0x8085C28C:("D_8085C28C","UNK_TYPE1","",0x1), - 0x8085C2A4:("D_8085C2A4","UNK_TYPE4","",0x4), - 0x8085C2A8:("D_8085C2A8","UNK_TYPE4","",0x4), - 0x8085C2AC:("D_8085C2AC","UNK_TYPE4","",0x4), + 0x8085BA38:("sPlayerAgeProperties","UNK_TYPE1","",0x1), + 0x8085BE84:("D_8085BE84","LinkAnimationHeader*","[264]",0x420), + 0x8085C2A4:("D_8085C2A4","struct_8085C2A4","[6]",0x48), 0x8085C2EC:("D_8085C2EC","UNK_TYPE1","",0x1), 0x8085C318:("D_8085C318","UNK_TYPE1","",0x1), 0x8085C344:("D_8085C344","UNK_TYPE1","",0x1), @@ -4994,9 +4951,8 @@ 0x8085C3E4:("D_8085C3E4","f32","",0x4), 0x8085C3E8:("D_8085C3E8","f32","",0x4), 0x8085C3EC:("D_8085C3EC","UNK_TYPE2","",0x2), - 0x8085C3F4:("D_8085C3F4","UNK_TYPE1","",0x1), - 0x8085C84C:("D_8085C84C","UNK_TYPE4","",0x4), - 0x8085C850:("D_8085C850","UNK_TYPE4","",0x4), + 0x8085C3F4:("sGetItemTable","GetItemEntry","[0xB9]",0x456), + 0x8085C84C:("sPlayerIdleAnimations","UNK_TYPE4","",0x78), 0x8085C8C4:("D_8085C8C4","UNK_TYPE1","",0x1), 0x8085C8C8:("D_8085C8C8","UNK_TYPE1","",0x1), 0x8085C8CC:("D_8085C8CC","UNK_TYPE1","",0x1), @@ -5007,19 +4963,17 @@ 0x8085C90C:("D_8085C90C","UNK_TYPE1","",0x1), 0x8085C91C:("D_8085C91C","UNK_TYPE1","",0x1), 0x8085C924:("D_8085C924","UNK_TYPE1","",0x1), - 0x8085C928:("D_8085C928","UNK_TYPE1","",0x1), - 0x8085C938:("D_8085C938","UNK_TYPE1","",0x1), + 0x8085C928:("D_8085C928","UNK_TYPE1","",0x14), + 0x8085C93C:("D_8085C93C","UNK_TYPE1","",0x1), 0x8085C96C:("D_8085C96C","UNK_TYPE1","",0x1), 0x8085C98C:("D_8085C98C","UNK_TYPE1","",0x1), - 0x8085C99C:("D_8085C99C","UNK_TYPE1","",0x1), + 0x8085C99C:("sItemActionParams","UNK_TYPE1","",0x1), 0x8085C9F0:("D_8085C9F0","UNK_PTR","",0x4), 0x8085CB3C:("D_8085CB3C","UNK_PTR","",0x4), 0x8085CC88:("D_8085CC88","UNK_TYPE1","",0x1), - 0x8085CD00:("D_8085CD00","UNK_TYPE1","",0x1), - 0x8085CD24:("D_8085CD24","UNK_TYPE1","",0x1), - 0x8085CD30:("D_8085CD30","UNK_TYPE1","",0x1), - 0x8085CE30:("D_8085CE30","UNK_TYPE1","",0x1), - 0x8085CE60:("D_8085CE60","UNK_TYPE1","",0x1), + 0x8085CD00:("D_8085CD00","s8","[36]",0x24), + 0x8085CD24:("sPlayerExplosiveInfo","UNK_TYPE1","",0x1), + 0x8085CD30:("sMeleeAttackAnimInfo","UNK_TYPE1","",0x220), 0x8085CF50:("D_8085CF50","UNK_TYPE1","",0x1), 0x8085CF58:("D_8085CF58","UNK_TYPE1","",0x1), 0x8085CF60:("D_8085CF60","UNK_TYPE1","",0x1), @@ -5028,10 +4982,10 @@ 0x8085CF78:("D_8085CF78","UNK_TYPE1","",0x1), 0x8085CF80:("D_8085CF80","UNK_TYPE1","",0x1), 0x8085CF84:("D_8085CF84","UNK_TYPE1","",0x1), - 0x8085CF88:("D_8085CF88","UNK_TYPE1","",0x1), - 0x8085CFA8:("D_8085CFA8","UNK_TYPE2","",0x2), - 0x8085CFAE:("D_8085CFAE","UNK_TYPE1","",0x1), - 0x8085CFB8:("D_8085CFB8","UNK_TYPE1","",0x1), + 0x8085CF88:("D_8085CF88","BlureColors","[2]",0x20), + 0x8085CFA8:("D_8085CFA8","u16","[4]",0x8), + 0x8085CFB0:("D_8085CFB0","UNK_TYPE1","",0x1), + 0x8085CFB8:("sMagicArrowCosts","u8","[4]",0x4), 0x8085CFBC:("D_8085CFBC","UNK_TYPE1","",0x1), 0x8085CFC4:("D_8085CFC4","UNK_TYPE1","",0x1), 0x8085CFCC:("D_8085CFCC","UNK_TYPE1","",0x1), @@ -5051,47 +5005,42 @@ 0x8085D050:("D_8085D050","UNK_TYPE1","",0x1), 0x8085D054:("D_8085D054","UNK_PTR","",0x4), 0x8085D090:("D_8085D090","UNK_TYPE1","",0x1), - 0x8085D094:("D_8085D094","UNK_TYPE1","",0x1), - 0x8085D097:("D_8085D097","UNK_TYPE1","",0x1), + 0x8085D094:("D_8085D094","UNK_TYPE1","",0x6), 0x8085D09C:("D_8085D09C","UNK_TYPE4","",0x4), 0x8085D0D4:("D_8085D0D4","UNK_TYPE1","",0x1), 0x8085D0E4:("D_8085D0E4","UNK_TYPE1","",0x1), 0x8085D0F4:("D_8085D0F4","UNK_TYPE4","",0x4), - 0x8085D0F8:("D_8085D0F8","UNK_TYPE1","",0x1), + 0x8085D0F8:("sReturnEntranceGroupData","s16","[1]",0x2), + 0x8085D0FA:("sReturnEntranceGroupIndices","u8","[1]",0x1), 0x8085D100:("D_8085D100","UNK_TYPE1","",0x1), - 0x8085D10C:("D_8085D10C","f32","",0x4), - 0x8085D114:("D_8085D114","f32","",0x4), + 0x8085D10C:("D_8085D10C","Vec3f","",0xC), 0x8085D118:("D_8085D118","UNK_TYPE1","",0x1), 0x8085D124:("D_8085D124","UNK_TYPE1","",0x1), - 0x8085D130:("D_8085D130","UNK_TYPE1","",0x1), - 0x8085D134:("D_8085D134","f32","",0x4), - 0x8085D13C:("D_8085D13C","UNK_TYPE1","",0x1), + 0x8085D130:("D_8085D130","Vec3f","",0xC), + 0x8085D13C:("sFallImpactInfos","UNK_TYPE1","",0x1), 0x8085D148:("D_8085D148","UNK_TYPE1","",0x1), 0x8085D154:("D_8085D154","UNK_TYPE1","",0x1), 0x8085D160:("D_8085D160","UNK_TYPE1","",0x1), - 0x8085D174:("D_8085D174","UNK_TYPE1","",0x1), + 0x8085D174:("sPlayerMass","u8","[5]",0x5), 0x8085D17C:("D_8085D17C","UNK_TYPE1","",0x1), 0x8085D190:("D_8085D190","UNK_TYPE1","",0x1), 0x8085D1A4:("D_8085D1A4","UNK_TYPE1","",0x1), 0x8085D1F8:("D_8085D1F8","UNK_TYPE1","",0x1), 0x8085D200:("D_8085D200","UNK_TYPE4","",0x4), 0x8085D218:("D_8085D218","UNK_TYPE1","",0x1), - 0x8085D224:("D_8085D224","UNK_TYPE1","",0x1), - 0x8085D23C:("D_8085D23C","UNK_TYPE1","",0x1), - 0x8085D252:("D_8085D252","UNK_TYPE1","",0x1), + 0x8085D224:("D_8085D224","UNK_TYPE1","",0x30), + 0x8085D254:("D_8085D254","u16","[4]",0x8), 0x8085D25C:("D_8085D25C","UNK_TYPE1","",0x1), 0x8085D264:("D_8085D264","UNK_TYPE1","",0x1), 0x8085D26C:("D_8085D26C","UNK_TYPE1","",0x1), 0x8085D270:("D_8085D270","UNK_TYPE1","",0x1), - 0x8085D27C:("D_8085D27C","f32","",0x4), - 0x8085D284:("D_8085D284","f32","",0x4), - 0x8085D288:("D_8085D288","UNK_TYPE1","",0x1), - 0x8085D28C:("D_8085D28C","f32","",0x4), + 0x8085D27C:("D_8085D27C","Vec3f","",0xC), + 0x8085D288:("D_8085D288","Vec3f","",0xC), 0x8085D294:("D_8085D294","UNK_TYPE1","",0x1), 0x8085D2A4:("D_8085D2A4","UNK_TYPE1","",0x1), 0x8085D2B0:("D_8085D2B0","UNK_TYPE1","",0x1), 0x8085D2B4:("D_8085D2B4","UNK_TYPE1","",0x1), - 0x8085D2C0:("D_8085D2C0","ActorInitVar","",0x4), + 0x8085D2C0:("sInitChain","ActorInitVar","",0x4), 0x8085D2C4:("D_8085D2C4","UNK_TYPE4","",0x4), 0x8085D2CC:("D_8085D2CC","UNK_PTR","",0x4), 0x8085D30C:("D_8085D30C","EffectBlureInit2","",0x24), @@ -5101,9 +5050,7 @@ 0x8085D340:("D_8085D340","UNK_TYPE1","",0x1), 0x8085D34C:("D_8085D34C","UNK_TYPE1","",0x1), 0x8085D354:("D_8085D354","UNK_TYPE1","",0x1), - 0x8085D358:("D_8085D358","UNK_TYPE1","",0x1), - 0x8085D35C:("D_8085D35C","f32","",0x4), - 0x8085D360:("D_8085D360","f32","",0x4), + 0x8085D358:("D_8085D358","Vec3f","",0xC), 0x8085D364:("D_8085D364","UNK_TYPE1","",0x1), 0x8085D370:("D_8085D370","UNK_TYPE1","",0x1), 0x8085D37C:("D_8085D37C","UNK_TYPE1","",0x1), @@ -5113,8 +5060,8 @@ 0x8085D3F4:("D_8085D3F4","UNK_TYPE1","",0x1), 0x8085D3F8:("D_8085D3F8","UNK_TYPE1","",0x1), 0x8085D3FC:("D_8085D3FC","UNK_TYPE4","",0x4), - 0x8085D404:("D_8085D404","UNK_TYPE1","",0x1), - 0x8085D410:("D_8085D410","UNK_TYPE1","",0x1), + 0x8085D404:("sWaterConveyorSpeeds","UNK_TYPE1","",0x1), + 0x8085D410:("sFloorConveyorSpeeds","UNK_TYPE1","",0x1), 0x8085D41C:("D_8085D41C","UNK_TYPE1","",0x1), 0x8085D428:("D_8085D428","UNK_TYPE1","",0x1), 0x8085D450:("D_8085D450","UNK_TYPE1","",0x1), @@ -5132,32 +5079,28 @@ 0x8085D574:("D_8085D574","UNK_TYPE4","",0x4), 0x8085D580:("D_8085D580","UNK_TYPE1","",0x1), 0x8085D584:("D_8085D584","UNK_TYPE1","",0x1), - 0x8085D588:("D_8085D588","UNK_TYPE1","",0x1), - 0x8085D5A0:("D_8085D5A0","UNK_TYPE1","",0x1), - 0x8085D5B8:("D_8085D5B8","UNK_TYPE1","",0x1), + 0x8085D588:("D_8085D588","Vec3f","[2]",0x18), + 0x8085D5A0:("D_8085D5A0","Vec3f","[2]",0x18), + 0x8085D5B8:("D_8085D5B8","Vec3f","[2]",0x18), 0x8085D5D0:("D_8085D5D0","UNK_TYPE1","",0x1), 0x8085D5DC:("D_8085D5DC","UNK_TYPE1","",0x1), 0x8085D5E0:("D_8085D5E0","UNK_TYPE1","",0x1), 0x8085D5E4:("D_8085D5E4","UNK_TYPE1","",0x1), - 0x8085D5F0:("D_8085D5F0","UNK_TYPE1","",0x1), - 0x8085D5FA:("D_8085D5FA","UNK_TYPE1","",0x1), - 0x8085D604:("D_8085D604","UNK_TYPE1","",0x1), - 0x8085D60C:("D_8085D60C","UNK_TYPE1","",0x1), - 0x8085D61C:("D_8085D61C","UNK_TYPE1","",0x1), - 0x8085D62C:("D_8085D62C","f32","",0x4), - 0x8085D630:("D_8085D630","f32","",0x4), - 0x8085D634:("D_8085D634","f32","",0x4), - 0x8085D638:("D_8085D638","f32","",0x4), - 0x8085D640:("D_8085D640","f32","",0x4), - 0x8085D644:("D_8085D644","UNK_TYPE1","",0x1), - 0x8085D64C:("D_8085D64C","f32","",0x4), + 0x8085D5F0:("D_8085D5F0","UNK_TYPE1","",0xC), + 0x8085D5FC:("D_8085D5FC","UNK_TYPE1","",0x1), + 0x8085D604:("D_8085D604","UNK_TYPE1","",0x8), + 0x8085D60C:("D_8085D60C","UNK_TYPE1","",0x10), + 0x8085D61C:("D_8085D61C","UNK_TYPE1","",0x10), + 0x8085D62C:("D_8085D62C","Vec3f","",0xC), + 0x8085D638:("D_8085D638","Vec3f","",0xC), + 0x8085D644:("D_8085D644","Vec3f","",0xC), 0x8085D650:("D_8085D650","UNK_TYPE1","",0x1), 0x8085D658:("D_8085D658","UNK_TYPE1","",0x1), 0x8085D660:("D_8085D660","UNK_TYPE1","",0x1), 0x8085D66C:("D_8085D66C","UNK_TYPE4","",0x4), 0x8085D674:("D_8085D674","UNK_TYPE4","",0x4), - 0x8085D67C:("D_8085D67C","UNK_TYPE1","",0x1), - 0x8085D680:("D_8085D680","UNK_TYPE1","",0x1), + 0x8085D67C:("D_8085D67C","UNK_TYPE1","",0xC), + 0x8085D688:("D_8085D688","UNK_TYPE1","",0x1), 0x8085D6A4:("D_8085D6A4","UNK_TYPE1","",0x1), 0x8085D6D0:("D_8085D6D0","UNK_PTR","",0x4), 0x8085D6DC:("D_8085D6DC","UNK_TYPE1","",0x1), @@ -5168,18 +5111,16 @@ 0x8085D73C:("D_8085D73C","UNK_TYPE1","",0x1), 0x8085D74C:("D_8085D74C","UNK_TYPE1","",0x1), 0x8085D75C:("D_8085D75C","UNK_TYPE1","",0x1), - 0x8085D764:("D_8085D764","UNK_TYPE1","",0x1), - 0x8085D76D:("D_8085D76D","UNK_TYPE1","",0x1), + 0x8085D764:("D_8085D764","Vec3f","",0xC), 0x8085D770:("D_8085D770","UNK_TYPE1","",0x1), 0x8085D77C:("D_8085D77C","UNK_TYPE1","",0x1), 0x8085D788:("D_8085D788","UNK_TYPE1","",0x1), - 0x8085D78C:("D_8085D78C","UNK_TYPE1","",0x1), - 0x8085D797:("D_8085D797","UNK_TYPE1","",0x1), + 0x8085D78C:("D_8085D78C","Color_RGBA8","",0x4), + 0x8085D790:("D_8085D790","u8","[6]",0x6), 0x8085D798:("D_8085D798","UNK_TYPE2","",0x2), - 0x8085D7EC:("D_8085D7EC","UNK_TYPE1","",0x1), - 0x8085D7F8:("D_8085D7F8","UNK_TYPE1","",0x1), - 0x8085D800:("D_8085D800","f32","",0x4), - 0x8085D804:("D_8085D804","UNK_TYPE1","",0x1), + 0x8085D7EC:("D_8085D7EC","Vec3f","",0xC), + 0x8085D7F8:("D_8085D7F8","Vec3f","",0xC), + 0x8085D804:("D_8085D804","s8","[5]",0x5), 0x8085D80C:("D_8085D80C","UNK_TYPE1","",0x1), 0x8085D838:("D_8085D838","UNK_TYPE1","",0x1), 0x8085D840:("D_8085D840","UNK_TYPE1","",0x1), @@ -5189,18 +5130,14 @@ 0x8085D904:("D_8085D904","UNK_TYPE1","",0x1), 0x8085D908:("D_8085D908","UNK_TYPE1","",0x1), 0x8085D910:("D_8085D910","UNK_TYPE1","",0x1), - 0x8085D918:("D_8085D918","UNK_TYPE1","",0x1), - 0x8085D91C:("D_8085D91C","f32","",0x4), - 0x8085D924:("D_8085D924","UNK_TYPE1","",0x1), - 0x8085D928:("D_8085D928","f32","",0x4), + 0x8085D918:("D_8085D918","Vec3f","",0xC), + 0x8085D924:("D_8085D924","Vec3f","",0xC), 0x8085D930:("D_8085D930","UNK_TYPE1","",0x1), 0x8085D934:("D_8085D934","UNK_TYPE1","",0x1), 0x8085D938:("D_8085D938","UNK_TYPE4","",0x4), 0x8085D93C:("D_8085D93C","UNK_TYPE4","",0x4), - 0x8085D940:("D_8085D940","f32","",0x4), - 0x8085D948:("D_8085D948","f32","",0x4), - 0x8085D94C:("D_8085D94C","f32","",0x4), - 0x8085D954:("D_8085D954","f32","",0x4), + 0x8085D940:("D_8085D940","Vec3f","",0xC), + 0x8085D94C:("D_8085D94C","Vec3f","",0xC), 0x8085D958:("D_8085D958","UNK_TYPE1","",0x1), 0x8085D960:("D_8085D960","UNK_TYPE1","",0x1), 0x8085D96C:("D_8085D96C","UNK_TYPE1","",0x1), @@ -5444,20 +5381,18 @@ 0x8085E6EC:("D_8085E6EC","f32","",0x4), 0x8085E6F0:("D_8085E6F0","f32","",0x4), 0x8085E6F4:("D_8085E6F4","f32","",0x4), - 0x80862AF0:("D_80862AF0","UNK_TYPE1","",0x1), - 0x80862AF4:("D_80862AF4","f32","",0x4), - 0x80862AF8:("D_80862AF8","f32","",0x4), + 0x80862AF0:("sDogSpawnPos","Vec3f","",0xC), 0x80862AFC:("D_80862AFC","f32","",0x4), 0x80862B00:("D_80862B00","UNK_TYPE1","",0x1), 0x80862B02:("D_80862B02","UNK_TYPE1","",0x1), 0x80862B04:("D_80862B04","UNK_TYPE1","",0x1), - 0x80862B08:("D_80862B08","UNK_TYPE1","",0x1), - 0x80862B0C:("D_80862B0C","UNK_TYPE1","",0x1), - 0x80862B10:("D_80862B10","UNK_TYPE1","",0x1), - 0x80862B14:("D_80862B14","UNK_TYPE1","",0x1), + 0x80862B08:("sPlayerCurrentFloorType","UNK_TYPE1","",0x1), + 0x80862B0C:("sPlayerCurrentWallFlags","UNK_TYPE1","",0x1), + 0x80862B10:("sPlayerConveyorSpeedIndex","UNK_TYPE1","",0x1), + 0x80862B14:("sPlayerIsOnFloorConveyor","UNK_TYPE1","",0x1), 0x80862B16:("D_80862B16","UNK_TYPE1","",0x1), 0x80862B18:("D_80862B18","f32","",0x4), - 0x80862B1C:("D_80862B1C","UNK_TYPE1","",0x1), + 0x80862B1C:("sPlayerPrevFloorProperty","UNK_TYPE1","",0x1), 0x80862B20:("D_80862B20","UNK_TYPE1","",0x1), 0x80862B24:("D_80862B24","UNK_TYPE1","",0x1), 0x80862B28:("D_80862B28","UNK_TYPE1","",0x1), @@ -5465,7 +5400,7 @@ 0x80862B30:("D_80862B30","UNK_TYPE1","",0x1), 0x80862B3C:("D_80862B3C","f32","",0x4), 0x80862B40:("D_80862B40","UNK_TYPE1","",0x1), - 0x80862B44:("D_80862B44","UNK_TYPE1","",0x1), + 0x80862B44:("sPlayerControlInput","UNK_TYPE1","",0x1), 0x80862B48:("D_80862B48","UNK_TYPE1","",0x1), 0x80862B4C:("D_80862B4C","UNK_TYPE1","",0x1), 0x80862B50:("D_80862B50","UNK_TYPE1","",0x1), diff --git a/tools/gitable.py b/tools/gitable.py new file mode 100755 index 0000000000..dad39638ff --- /dev/null +++ b/tools/gitable.py @@ -0,0 +1,1171 @@ +#!/usr/bin/env python3 +import argparse +from cgitb import text +import dataclasses +import os +import struct +import sys +import typing + +GETITEMENTRY_FORMAT = ">BBbBH" +GETITEMENTRY_LENGTH = struct.calcsize(GETITEMENTRY_FORMAT) + +# MM US: 0x2E964 + +itemId_names = { + 0x00: "ITEM_OCARINA", + 0x01: "ITEM_BOW", + 0x02: "ITEM_ARROW_FIRE", + 0x03: "ITEM_ARROW_ICE", + 0x04: "ITEM_ARROW_LIGHT", + 0x05: "ITEM_OCARINA_FAIRY", + 0x06: "ITEM_BOMB", + 0x07: "ITEM_BOMBCHU", + 0x08: "ITEM_STICK", + 0x09: "ITEM_NUT", + 0x0A: "ITEM_MAGIC_BEANS", + 0x0B: "ITEM_SLINGSHOT", + 0x0C: "ITEM_POWDER_KEG", + 0x0D: "ITEM_PICTO_BOX", + 0x0E: "ITEM_LENS", + 0x0F: "ITEM_HOOKSHOT", + 0x10: "ITEM_SWORD_GREAT_FAIRY", + 0x11: "ITEM_LONGSHOT", + 0x12: "ITEM_BOTTLE", + 0x13: "ITEM_POTION_RED", + 0x14: "ITEM_POTION_GREEN", + 0x15: "ITEM_POTION_BLUE", + 0x16: "ITEM_FAIRY", + 0x17: "ITEM_DEKU_PRINCESS", + 0x18: "ITEM_MILK_BOTTLE", + 0x19: "ITEM_MILK_HALF", + 0x1A: "ITEM_FISH", + 0x1B: "ITEM_BUG", + 0x1C: "ITEM_BLUE_FIRE", + 0x1D: "ITEM_POE", + 0x1E: "ITEM_BIG_POE", + 0x1F: "ITEM_SPRING_WATER", + 0x20: "ITEM_HOT_SPRING_WATER", + 0x21: "ITEM_ZORA_EGG", + 0x22: "ITEM_GOLD_DUST", + 0x23: "ITEM_MUSHROOM", + 0x24: "ITEM_SEAHORSE", + 0x25: "ITEM_CHATEAU", + 0x26: "ITEM_HYLIAN_LOACH", + 0x27: "ITEM_OBABA_DRINK", + 0x28: "ITEM_MOON_TEAR", + 0x29: "ITEM_DEED_LAND", + 0x2A: "ITEM_DEED_SWAMP", + 0x2B: "ITEM_DEED_MOUNTAIN", + 0x2C: "ITEM_DEED_OCEAN", + 0x2D: "ITEM_ROOM_KEY", + 0x2E: "ITEM_LETTER_MAMA", + 0x2F: "ITEM_LETTER_TO_KAFEI", + 0x30: "ITEM_PENDANT_OF_MEMORIES", + 0x31: "ITEM_TINGLE_MAP", + 0x32: "ITEM_MASK_DEKU", + 0x33: "ITEM_MASK_GORON", + 0x34: "ITEM_MASK_ZORA", + 0x35: "ITEM_MASK_FIERCE_DEITY", + 0x36: "ITEM_MASK_TRUTH", + 0x37: "ITEM_MASK_KAFEIS_MASK", + 0x38: "ITEM_MASK_ALL_NIGHT", + 0x39: "ITEM_MASK_BUNNY", + 0x3A: "ITEM_MASK_KEATON", + 0x3B: "ITEM_MASK_GARO", + 0x3C: "ITEM_MASK_ROMANI", + 0x3D: "ITEM_MASK_CIRCUS_LEADER", + 0x3E: "ITEM_MASK_POSTMAN", + 0x3F: "ITEM_MASK_COUPLE", + 0x40: "ITEM_MASK_GREAT_FAIRY", + 0x41: "ITEM_MASK_GIBDO", + 0x42: "ITEM_MASK_DON_GERO", + 0x43: "ITEM_MASK_KAMARO", + 0x44: "ITEM_MASK_CAPTAIN", + 0x45: "ITEM_MASK_STONE", + 0x46: "ITEM_MASK_BREMEN", + 0x47: "ITEM_MASK_BLAST", + 0x48: "ITEM_MASK_SCENTS", + 0x49: "ITEM_MASK_GIANT", + 0x4A: "ITEM_BOW_ARROW_FIRE", + 0x4B: "ITEM_BOW_ARROW_ICE", + 0x4C: "ITEM_BOW_ARROW_LIGHT", + 0x4D: "ITEM_SWORD_KOKIRI", + 0x4E: "ITEM_SWORD_RAZOR", + 0x4F: "ITEM_SWORD_GILDED", + 0x50: "ITEM_SWORD_DEITY", + 0x51: "ITEM_SHIELD_HERO", + 0x52: "ITEM_SHIELD_MIRROR", + 0x53: "ITEM_QUIVER_30", + 0x54: "ITEM_QUIVER_40", + 0x55: "ITEM_QUIVER_50", + 0x56: "ITEM_BOMB_BAG_20", + 0x57: "ITEM_BOMB_BAG_30", + 0x58: "ITEM_BOMB_BAG_40", + 0x59: "ITEM_WALLET_DEFAULT", + 0x5A: "ITEM_WALLET_ADULT", + 0x5B: "ITEM_WALLET_GIANT", + 0x5C: "ITEM_FISHING_POLE", + 0x5D: "ITEM_REMAINS_ODOLWA", + 0x5E: "ITEM_REMAINS_GOHT", + 0x5F: "ITEM_REMAINS_GYORG", + 0x60: "ITEM_REMAINS_TWINMOLD", + 0x61: "ITEM_SONG_SONATA", + 0x62: "ITEM_SONG_LULLABY", + 0x63: "ITEM_SONG_NOVA", + 0x64: "ITEM_SONG_ELEGY", + 0x65: "ITEM_SONG_OATH", + 0x66: "ITEM_SONG_SARIA", + 0x67: "ITEM_SONG_TIME", + 0x68: "ITEM_SONG_HEALING", + 0x69: "ITEM_SONG_EPONA", + 0x6A: "ITEM_SONG_SOARING", + 0x6B: "ITEM_SONG_STORMS", + 0x6C: "ITEM_SONG_SUN", + 0x6D: "ITEM_BOMBERS_NOTEBOOK", + 0x6E: "ITEM_SKULL_TOKEN", + 0x6F: "ITEM_HEART_CONTAINER", + 0x70: "ITEM_HEART_PIECE", + 0x73: "ITEM_SONG_LULLABY_INTRO" , + 0x74: "ITEM_KEY_BOSS", + 0x75: "ITEM_COMPASS", + 0x76: "ITEM_DUNGEON_MAP", + 0x77: "ITEM_STRAY_FAIRIES", + 0x78: "ITEM_KEY_SMALL", + 0x79: "ITEM_MAGIC_SMALL", + 0x7A: "ITEM_MAGIC_LARGE", + 0x7B: "ITEM_HEART_PIECE_2", + 0x7C: "ITEM_INVALID_1", + 0x7D: "ITEM_INVALID_2", + 0x7E: "ITEM_INVALID_3", + 0x7F: "ITEM_INVALID_4", + 0x80: "ITEM_INVALID_5", + 0x81: "ITEM_INVALID_6", + 0x82: "ITEM_INVALID_7", + 0x83: "ITEM_RECOVERY_HEART", + 0x84: "ITEM_RUPEE_GREEN", + 0x85: "ITEM_RUPEE_BLUE", + 0x86: "ITEM_RUPEE_10", + 0x87: "ITEM_RUPEE_RED", + 0x88: "ITEM_RUPEE_PURPLE", + 0x89: "ITEM_RUPEE_SILVER", + 0x8A: "ITEM_RUPEE_HUGE", + 0x8B: "ITEM_STICKS_5", + 0x8C: "ITEM_STICKS_10", + 0x8D: "ITEM_NUTS_5", + 0x8E: "ITEM_NUTS_10", + 0x8F: "ITEM_BOMBS_5", + 0x90: "ITEM_BOMBS_10", + 0x91: "ITEM_BOMBS_20", + 0x92: "ITEM_BOMBS_30", + 0x93: "ITEM_ARROWS_10", + 0x94: "ITEM_ARROWS_30", + 0x95: "ITEM_ARROWS_40", + 0x96: "ITEM_ARROWS_50", + 0x97: "ITEM_BOMBCHUS_20", + 0x98: "ITEM_BOMBCHUS_10", + 0x99: "ITEM_BOMBCHUS_1", + 0x9A: "ITEM_BOMBCHUS_5", + 0x9B: "ITEM_STICK_UPGRADE_20", + 0x9C: "ITEM_STICK_UPGRADE_30", + 0x9D: "ITEM_NUT_UPGRADE_30", + 0x9E: "ITEM_NUT_UPGRADE_40", + 0x9F: "ITEM_CHATEAU_2", + 0xA0: "ITEM_MILK", + 0xA1: "ITEM_GOLD_DUST_2", + 0xA2: "ITEM_HYLIAN_LOACH_2", + 0xA3: "ITEM_SEAHORSE_CAUGHT", + 0xF0: "ITEM_F0" , + 0xF1: "ITEM_F1", + 0xF2: "ITEM_F2", + 0xFC: "ITEM_FC" , + 0xFD: "ITEM_FD", + 0xFE: "ITEM_FE", + 0xFF: "ITEM_NONE", +} + +getItemId_names = { + 0x00: "GI_NONE", + 0x01: "GI_RUPEE_GREEN", + 0x02: "GI_RUPEE_BLUE", + 0x03: "GI_RUPEE_10", + 0x04: "GI_RUPEE_RED", + 0x05: "GI_RUPEE_PURPLE", + 0x06: "GI_RUPEE_SILVER", + 0x07: "GI_RUPEE_HUGE", + 0x08: "GI_WALLET_ADULT", + 0x09: "GI_WALLET_GIANT", + 0x0A: "GI_RECOVERY_HEART", + 0x0C: "GI_HEART_PIECE", + 0x0D: "GI_HEART_CONTAINER", + 0x0E: "GI_MAGIC_SMALL", + 0x0F: "GI_MAGIC_LARGE", + 0x11: "GI_STRAY_FAIRY", + 0x14: "GI_BOMBS_1", + 0x15: "GI_BOMBS_5", + 0x16: "GI_BOMBS_10", + 0x17: "GI_BOMBS_20", + 0x18: "GI_BOMBS_30", + 0x19: "GI_STICKS_1", + 0x1A: "GI_BOMBCHUS_10", + 0x1B: "GI_BOMB_BAG_20", + 0x1C: "GI_BOMB_BAG_30", + 0x1D: "GI_BOMB_BAG_40", + 0x1E: "GI_ARROWS_10", + 0x1F: "GI_ARROWS_30", + 0x20: "GI_ARROWS_40", + 0x21: "GI_ARROWS_50", + 0x22: "GI_QUIVER_30", + 0x23: "GI_QUIVER_40", + 0x24: "GI_QUIVER_50", + 0x25: "GI_ARROW_FIRE", + 0x26: "GI_ARROW_ICE", + 0x27: "GI_ARROW_LIGHT", + 0x28: "GI_NUTS_1", + 0x29: "GI_NUTS_5", + 0x2A: "GI_NUTS_10", + 0x2E: "GI_BOMBCHUS_20", + 0x32: "GI_SHIELD_HERO", + 0x33: "GI_SHIELD_MIRROR", + 0x34: "GI_POWDER_KEG", + 0x35: "GI_MAGIC_BEANS", + 0x36: "GI_BOMBCHUS_1", + 0x37: "GI_SWORD_KOKIRI", + 0x38: "GI_SWORD_RAZOR", + 0x39: "GI_SWORD_GILDED", + 0x3A: "GI_BOMBCHUS_5", + 0x3B: "GI_SWORD_GREAT_FAIRY", + 0x3C: "GI_KEY_SMALL", + 0x3D: "GI_KEY_BOSS", + 0x3E: "GI_MAP", + 0x3F: "GI_COMPASS", + 0x40: "GI_40", + 0x41: "GI_HOOKSHOT", + 0x42: "GI_LENS", + 0x43: "GI_PICTO_BOX", + 0x4C: "GI_OCARINA", + 0x50: "GI_BOMBERS_NOTEBOOK", + 0x52: "GI_SKULL_TOKEN", + 0x55: "GI_REMAINS_ODOLWA", + 0x56: "GI_REMAINS_GOHT", + 0x57: "GI_REMAINS_GYORG", + 0x58: "GI_REMAINS_TWINMOLD", + 0x59: "GI_POTION_RED_BOTTLE", + 0x5A: "GI_BOTTLE", + 0x5B: "GI_POTION_RED", + 0x5C: "GI_POTION_GREEN", + 0x5D: "GI_POTION_BLUE", + 0x5E: "GI_FAIRY", + 0x5F: "GI_DEKU_PRINCESS", + 0x60: "GI_MILK_BOTTLE", + 0x61: "GI_MILK_HALF", + 0x62: "GI_FISH", + 0x63: "GI_BUG", + 0x64: "GI_BLUE_FIRE", + 0x65: "GI_POE", + 0x66: "GI_BIG_POE", + 0x67: "GI_SPRING_WATER", + 0x68: "GI_HOT_SPRING_WATER", + 0x69: "GI_ZORA_EGG", + 0x6A: "GI_GOLD_DUST", + 0x6B: "GI_MUSHROOM", + 0x6C: "GI_6C", + 0x6D: "GI_6D", + 0x6E: "GI_SEAHORSE", + 0x6F: "GI_CHATEAU_BOTTLE", + 0x70: "GI_70", + 0x75: "GI_75", + 0x76: "GI_ICE_TRAP", + 0x78: "GI_MASK_DEKU", + 0x79: "GI_MASK_GORON", + 0x7A: "GI_MASK_ZORA", + 0x7B: "GI_MASK_FIERCE_DEITY", + 0x7C: "GI_MASK_CAPTAIN", + 0x7D: "GI_MASK_GIANT", + 0x7E: "GI_MASK_ALL_NIGHT", + 0x7F: "GI_MASK_BUNNY", + 0x80: "GI_MASK_KEATON", + 0x81: "GI_MASK_GARO", + 0x82: "GI_MASK_ROMANI", + 0x83: "GI_MASK_CIRCUS_LEADER", + 0x84: "GI_MASK_POSTMAN", + 0x85: "GI_MASK_COUPLE", + 0x86: "GI_MASK_GREAT_FAIRY", + 0x87: "GI_MASK_GIBDO", + 0x88: "GI_MASK_DON_GERO", + 0x89: "GI_MASK_KAMARO", + 0x8A: "GI_MASK_TRUTH", + 0x8B: "GI_MASK_STONE", + 0x8C: "GI_MASK_BREMEN", + 0x8D: "GI_MASK_BLAST", + 0x8E: "GI_MASK_SCENTS", + 0x8F: "GI_MASK_KAFEIS_MASK", + 0x91: "GI_CHATEAU", + 0x92: "GI_MILK", + 0x93: "GI_GOLD_DUST_2", + 0x94: "GI_HYLIAN_LOACH", + 0x95: "GI_SEAHORSE_CAUGHT", + 0x96: "GI_MOON_TEAR", + 0x97: "GI_DEED_LAND", + 0x98: "GI_DEED_SWAMP", + 0x99: "GI_DEED_MOUNTAIN", + 0x9A: "GI_DEED_OCEAN", + 0x9B: "GI_SWORD_GREAT_FAIRY_STOLEN", + 0x9C: "GI_SWORD_KOKIRI_STOLEN", + 0x9D: "GI_SWORD_RAZOR_STOLEN", + 0x9E: "GI_SWORD_GILDED_STOLEN", + 0x9F: "GI_SHIELD_HERO_STOLEN", + 0xA0: "GI_ROOM_KEY", + 0xA1: "GI_LETTER_TO_MAMA", + 0xA2: "GI_A2", + 0xA3: "GI_A3", + 0xA4: "GI_A4", + 0xA5: "GI_A5", + 0xA6: "GI_A6", + 0xA7: "GI_A7", + 0xA8: "GI_A8", + 0xA9: "GI_BOTTLE_STOLEN", + 0xAA: "GI_LETTER_TO_KAFEI", + 0xAB: "GI_PENDANT_OF_MEMORIES", + 0xB4: "GI_TINGLE_MAP_CLOCK_TOWN", + 0xB5: "GI_TINGLE_MAP_WOODFALL", + 0xB6: "GI_TINGLE_MAP_SNOWHEAD", + 0xB7: "GI_TINGLE_MAP_ROMANI_RANCH", + 0xB8: "GI_TINGLE_MAP_GREAT_BAY", + 0xB9: "GI_TINGLE_MAP_STONE_TOWER", + 0xBA: "GI_MAX" # I pity the fool +} + +getItemDrawId_names = { + 0x00: "GID_BOTTLE", + 0x01: "GID_KEY_SMALL", + 0x02: "GID_MASK_KAMARO", + 0x03: "GID_MASK_COUPLE", + 0x04: "GID_04", + 0x05: "GID_05", + 0x06: "GID_06", + 0x07: "GID_07", + 0x08: "GID_RECOVERY_HEART", + 0x09: "GID_KEY_BOSS", + 0x0A: "GID_COMPASS", + 0x0B: "GID_BOMBERS_NOTEBOOK", + 0x0C: "GID_MASK_STONE", + 0x0D: "GID_MASK_KAFEIS_MASK", + 0x0E: "GID_MASK_CIRCUS_LEADER", + 0x0F: "GID_MASK_BREMEN", + 0x10: "GID_MASK_ALL_NIGHT", + 0x11: "GID_NUTS", + 0x12: "GID_HEART_CONTAINER", + 0x13: "GID_HEART_PIECE", + 0x14: "GID_QUIVER_30", + 0x15: "GID_QUIVER_40", + 0x16: "GID_QUIVER_50", + 0x17: "GID_BOMB_BAG_20", + 0x18: "GID_BOMB_BAG_30", + 0x19: "GID_BOMB_BAG_40", + 0x1A: "GID_STICK", + 0x1B: "GID_DUNGEON_MAP", + 0x1C: "GID_MAGIC_SMALL", + 0x1D: "GID_MAGIC_LARGE", + 0x1E: "GID_BOMB", + 0x1F: "GID_STONE_OF_AGONY", + 0x20: "GID_WALLET_ADULT", + 0x21: "GID_WALLET_GIANT", + 0x22: "GID_MASK_DON_GERO", + 0x23: "GID_ARROWS_SMALL", + 0x24: "GID_ARROWS_MEDIUM", + 0x25: "GID_ARROWS_LARGE", + 0x26: "GID_BOMBCHU", + 0x27: "GID_SHIELD_HERO", + 0x28: "GID_HOOKSHOT", + 0x29: "GID_29", + 0x2A: "GID_OCARINA", + 0x2B: "GID_MILK", + 0x2C: "GID_MASK_KEATON", + 0x2D: "GID_TINGLE_MAP", + 0x2E: "GID_BOW", + 0x2F: "GID_LENS", + 0x30: "GID_POTION_GREEN", + 0x31: "GID_POTION_RED", + 0x32: "GID_POTION_BLUE", + 0x33: "GID_SHIELD_MIRROR", + 0x34: "GID_MAGIC_BEANS", + 0x35: "GID_FISH", + 0x36: "GID_LETTER_MAMA", + 0x37: "GID_37", + 0x38: "GID_SWORD_BGS", + 0x39: "GID_MASK_SUN", + 0x3A: "GID_MASK_BLAST", + 0x3B: "GID_FAIRY", + 0x3C: "GID_MASK_SCENTS", + 0x3D: "GID_MASK_CAPTAIN", + 0x3E: "GID_MASK_BUNNY", + 0x3F: "GID_MASK_TRUTH", + 0x40: "GID_DEED_SWAMP", + 0x41: "GID_DEED_MOUNTAIN", + 0x42: "GID_RUPEE_HUGE", + 0x43: "GID_DEED_OCEAN", + 0x44: "GID_MASK_GORON", + 0x45: "GID_MASK_ZORA", + 0x46: "GID_46", + 0x47: "GID_ARROW_FIRE", + 0x48: "GID_ARROW_ICE", + 0x49: "GID_ARROW_LIGHT", + 0x4A: "GID_SKULL_TOKEN", + 0x4B: "GID_BUG", + 0x4C: "GID_4C", + 0x4D: "GID_POE", + 0x4E: "GID_FAIRY_2", + 0x4F: "GID_RUPEE_GREEN", + 0x50: "GID_RUPEE_BLUE", + 0x51: "GID_RUPEE_RED", + 0x52: "GID_BIG_POE", + 0x53: "GID_RUPEE_PURPLE", + 0x54: "GID_RUPEE_SILVER", + 0x55: "GID_SWORD_KOKIRI", + 0x56: "GID_SKULL_TOKEN_2", + 0x57: "GID_57", + 0x58: "GID_ZORA_EGG", + 0x59: "GID_MOON_TEAR", + 0x5A: "GID_DEED_LAND", + 0x5B: "GID_MASK_DEKU", + 0x5C: "GID_REMAINS_ODOLWA", + 0x5D: "GID_POWDER_KEG", + 0x5E: "GID_GOLD_DUST", + 0x5F: "GID_SEAHORSE", + 0x60: "GID_60", + 0x61: "GID_HYLIAN_LOACH", + 0x62: "GID_SEAHORSE_CAUGHT", + 0x63: "GID_REMAINS_GOHT", + 0x64: "GID_REMAINS_GYORG", + 0x65: "GID_REMAINS_TWINMOLD", + 0x66: "GID_SWORD_RAZOR", + 0x67: "GID_SWORD_GILDED", + 0x68: "GID_SWORD_GREAT_FAIRY", + 0x69: "GID_MASK_GARO", + 0x6A: "GID_MASK_GREAT_FAIRY", + 0x6B: "GID_MASK_GIBDO", + 0x6C: "GID_ROOM_KEY", + 0x6D: "GID_LETTER_TO_KAFEI", + 0x6E: "GID_PENDANT_OF_MEMORIES", + 0x6F: "GID_MUSHROOM", + 0x70: "GID_MASK_ROMANI", + 0x71: "GID_MASK_POSTMAN", + 0x72: "GID_MASK_GIANT", + 0x73: "GID_CHATEAU", + 0x74: "GID_PICTO_BOX", + 0x75: "GID_MASK_FIERCE_DEITY", + 0x76: "GID_MAX", + -1: "GID_NONE", +} + +objectId_names = { + 0x000: "OBJECT_UNSET_0", + 0x001: "GAMEPLAY_KEEP", + 0x002: "GAMEPLAY_FIELD_KEEP", + 0x003: "GAMEPLAY_DANGEON_KEEP", + 0x004: "OBJECT_NB", + 0x005: "OBJECT_OKUTA", + 0x006: "OBJECT_CROW", + 0x007: "OBJECT_AH", + 0x008: "OBJECT_DY_OBJ", + 0x009: "OBJECT_WALLMASTER", + 0x00A: "OBJECT_DODONGO", + 0x00B: "OBJECT_FIREFLY", + 0x00C: "OBJECT_BOX", + 0x00D: "OBJECT_AL", + 0x00E: "OBJECT_BUBBLE", + 0x00F: "OBJECT_NIW", + 0x010: "OBJECT_LINK_BOY", + 0x011: "OBJECT_LINK_CHILD", + 0x012: "OBJECT_TITE", + 0x013: "OBJECT_TAB", + 0x014: "OBJECT_PH", + 0x015: "OBJECT_AND", + 0x016: "OBJECT_MSMO", + 0x017: "OBJECT_DINOFOS", + 0x018: "OBJECT_DRS", + 0x019: "OBJECT_ZL1", + 0x01A: "OBJECT_AN4", + 0x01B: "OBJECT_UNSET_1B", + 0x01C: "OBJECT_TEST3", + 0x01D: "OBJECT_FAMOS", + 0x01E: "OBJECT_UNSET_1E", + 0x01F: "OBJECT_UNSET_1F", + 0x020: "OBJECT_ST", + 0x021: "OBJECT_UNSET_21", + 0x022: "OBJECT_THIEFBIRD", + 0x023: "OBJECT_UNSET_23", + 0x024: "OBJECT_UNSET_24", + 0x025: "OBJECT_UNSET_25", + 0x026: "OBJECT_UNSET_26", + 0x027: "OBJECT_UNSET_27", + 0x028: "OBJECT_UNSET_28", + 0x029: "OBJECT_UNSET_29", + 0x02A: "OBJECT_BOMBF", + 0x02B: "OBJECT_UNSET_2B", + 0x02C: "OBJECT_UNSET_2C", + 0x02D: "OBJECT_UNSET_2D", + 0x02E: "OBJECT_UNSET_2E", + 0x02F: "OBJECT_UNSET_2F", + 0x030: "OBJECT_AM", + 0x031: "OBJECT_DEKUBABA", + 0x032: "OBJECT_UNSET_32", + 0x033: "OBJECT_UNSET_33", + 0x034: "OBJECT_UNSET_34", + 0x035: "OBJECT_UNSET_35", + 0x036: "OBJECT_UNSET_36", + 0x037: "OBJECT_UNSET_37", + 0x038: "OBJECT_UNSET_38", + 0x039: "OBJECT_UNSET_39", + 0x03A: "OBJECT_UNSET_3A", + 0x03B: "OBJECT_UNSET_3B", + 0x03C: "OBJECT_UNSET_3C", + 0x03D: "OBJECT_UNSET_3D", + 0x03E: "OBJECT_WARP1", + 0x03F: "OBJECT_B_HEART", + 0x040: "OBJECT_DEKUNUTS", + 0x041: "OBJECT_UNSET_41", + 0x042: "OBJECT_UNSET_42", + 0x043: "OBJECT_UNSET_43", + 0x044: "OBJECT_UNSET_44", + 0x045: "OBJECT_UNSET_45", + 0x046: "OBJECT_UNSET_46", + 0x047: "OBJECT_UNSET_47", + 0x048: "OBJECT_UNSET_48", + 0x049: "OBJECT_UNSET_49", + 0x04A: "OBJECT_UNSET_4A", + 0x04B: "OBJECT_UNSET_4B", + 0x04C: "OBJECT_UNSET_4C", + 0x04D: "OBJECT_UNSET_4D", + 0x04E: "OBJECT_UNSET_4E", + 0x04F: "OBJECT_UNSET_4F", + 0x050: "OBJECT_UNSET_50", + 0x051: "OBJECT_BB", + 0x052: "OBJECT_DEATH", + 0x053: "OBJECT_UNSET_53", + 0x054: "OBJECT_UNSET_54", + 0x055: "OBJECT_UNSET_55", + 0x056: "OBJECT_UNSET_56", + 0x057: "OBJECT_UNSET_57", + 0x058: "OBJECT_UNSET_58", + 0x059: "OBJECT_UNSET_59", + 0x05A: "OBJECT_UNSET_5A", + 0x05B: "OBJECT_UNSET_5B", + 0x05C: "OBJECT_F40_OBJ", + 0x05D: "OBJECT_PO_COMPOSER", + 0x05E: "OBJECT_UNSET_5E", + 0x05F: "OBJECT_HATA", + 0x060: "OBJECT_UNSET_60", + 0x061: "OBJECT_WOOD02", + 0x062: "OBJECT_UNSET_62", + 0x063: "OBJECT_UNSET_63", + 0x064: "OBJECT_TRAP", + 0x065: "OBJECT_UNSET_65", + 0x066: "OBJECT_UNSET_66", + 0x067: "OBJECT_UNSET_67", + 0x068: "OBJECT_UNSET_68", + 0x069: "OBJECT_UNSET_69", + 0x06A: "OBJECT_VM", + 0x06B: "OBJECT_UNSET_6B", + 0x06C: "OBJECT_UNSET_6C", + 0x06D: "OBJECT_UNSET_6D", + 0x06E: "OBJECT_UNSET_6E", + 0x06F: "OBJECT_UNSET_6F", + 0x070: "OBJECT_EFC_STAR_FIELD", + 0x071: "OBJECT_UNSET_71", + 0x072: "OBJECT_UNSET_72", + 0x073: "OBJECT_UNSET_73", + 0x074: "OBJECT_UNSET_74", + 0x075: "OBJECT_RD", + 0x076: "OBJECT_YUKIMURA_OBJ", + 0x077: "OBJECT_HEAVY_OBJECT", + 0x078: "OBJECT_UNSET_78", + 0x079: "OBJECT_UNSET_79", + 0x07A: "OBJECT_UNSET_7A", + 0x07B: "OBJECT_UNSET_7B", + 0x07C: "OBJECT_UNSET_7C", + 0x07D: "OBJECT_HORSE_LINK_CHILD", + 0x07E: "OBJECT_UNSET_7E", + 0x07F: "OBJECT_UNSET_7F", + 0x080: "OBJECT_SYOKUDAI", + 0x081: "OBJECT_UNSET_81", + 0x082: "OBJECT_UNSET_82", + 0x083: "OBJECT_UNSET_83", + 0x084: "OBJECT_EFC_TW", + 0x085: "OBJECT_UNSET_85", + 0x086: "OBJECT_GI_KEY", + 0x087: "OBJECT_MIR_RAY", + 0x088: "OBJECT_CTOWER_ROT", + 0x089: "OBJECT_UNSET_89", + 0x08A: "OBJECT_BDOOR", + 0x08B: "OBJECT_UNSET_8B", + 0x08C: "OBJECT_UNSET_8C", + 0x08D: "OBJECT_UNSET_8D", + 0x08E: "OBJECT_SB", + 0x08F: "OBJECT_GI_MELODY", + 0x090: "OBJECT_GI_HEART", + 0x091: "OBJECT_GI_COMPASS", + 0x092: "OBJECT_GI_BOSSKEY", + 0x093: "OBJECT_UNSET_93", + 0x094: "OBJECT_GI_NUTS", + 0x095: "OBJECT_UNSET_95", + 0x096: "OBJECT_GI_HEARTS", + 0x097: "OBJECT_GI_ARROWCASE", + 0x098: "OBJECT_GI_BOMBPOUCH", + 0x099: "OBJECT_IN", + 0x09A: "OBJECT_UNSET_9A", + 0x09B: "OBJECT_UNSET_9B", + 0x09C: "OBJECT_UNSET_9C", + 0x09D: "OBJECT_OS_ANIME", + 0x09E: "OBJECT_GI_BOTTLE", + 0x09F: "OBJECT_GI_STICK", + 0x0A0: "OBJECT_GI_MAP", + 0x0A1: "OBJECT_OF1D_MAP", + 0x0A2: "OBJECT_RU2", + 0x0A3: "OBJECT_UNSET_A3", + 0x0A4: "OBJECT_GI_MAGICPOT", + 0x0A5: "OBJECT_GI_BOMB_1", + 0x0A6: "OBJECT_UNSET_A6", + 0x0A7: "OBJECT_MA2", + 0x0A8: "OBJECT_GI_PURSE", + 0x0A9: "OBJECT_UNSET_A9", + 0x0AA: "OBJECT_UNSET_AA", + 0x0AB: "OBJECT_RR", + 0x0AC: "OBJECT_UNSET_AC", + 0x0AD: "OBJECT_UNSET_AD", + 0x0AE: "OBJECT_UNSET_AE", + 0x0AF: "OBJECT_GI_ARROW", + 0x0B0: "OBJECT_GI_BOMB_2", + 0x0B1: "OBJECT_UNSET_B1", + 0x0B2: "OBJECT_UNSET_B2", + 0x0B3: "OBJECT_GI_SHIELD_2", + 0x0B4: "OBJECT_GI_HOOKSHOT", + 0x0B5: "OBJECT_GI_OCARINA", + 0x0B6: "OBJECT_GI_MILK", + 0x0B7: "OBJECT_MA1", + 0x0B8: "OBJECT_UNSET_B8", + 0x0B9: "OBJECT_UNSET_B9", + 0x0BA: "OBJECT_UNSET_BA", + 0x0BB: "OBJECT_NY", + 0x0BC: "OBJECT_FR", + 0x0BD: "OBJECT_UNSET_BD", + 0x0BE: "OBJECT_UNSET_BE", + 0x0BF: "OBJECT_GI_BOW", + 0x0C0: "OBJECT_GI_GLASSES", + 0x0C1: "OBJECT_GI_LIQUID", + 0x0C2: "OBJECT_ANI", + 0x0C3: "OBJECT_GI_SHIELD_3", + 0x0C4: "OBJECT_UNSET_C4", + 0x0C5: "OBJECT_UNSET_C5", + 0x0C6: "OBJECT_GI_BEAN", + 0x0C7: "OBJECT_GI_FISH", + 0x0C8: "OBJECT_UNSET_C8", + 0x0C9: "OBJECT_UNSET_C9", + 0x0CA: "OBJECT_UNSET_CA", + 0x0CB: "OBJECT_GI_LONGSWORD", + 0x0CC: "OBJECT_UNSET_CC", + 0x0CD: "OBJECT_UNSET_CD", + 0x0CE: "OBJECT_UNSET_CE", + 0x0CF: "OBJECT_UNSET_CF", + 0x0D0: "OBJECT_ZO", + 0x0D1: "OBJECT_UNSET_D1", + 0x0D2: "OBJECT_UMAJUMP", + 0x0D3: "OBJECT_UNSET_D3", + 0x0D4: "OBJECT_UNSET_D4", + 0x0D5: "OBJECT_MASTERGOLON", + 0x0D6: "OBJECT_MASTERZOORA", + 0x0D7: "OBJECT_AOB", + 0x0D8: "OBJECT_IK", + 0x0D9: "OBJECT_AHG", + 0x0DA: "OBJECT_CNE", + 0x0DB: "OBJECT_UNSET_DB", + 0x0DC: "OBJECT_UNSET_DC", + 0x0DD: "OBJECT_AN3", + 0x0DE: "OBJECT_BJI", + 0x0DF: "OBJECT_BBA", + 0x0E0: "OBJECT_AN2", + 0x0E1: "OBJECT_UNSET_E1", + 0x0E2: "OBJECT_AN1", + 0x0E3: "OBJECT_BOJ", + 0x0E4: "OBJECT_FZ", + 0x0E5: "OBJECT_BOB", + 0x0E6: "OBJECT_GE1", + 0x0E7: "OBJECT_YABUSAME_POINT", + 0x0E8: "OBJECT_UNSET_E8", + 0x0E9: "OBJECT_UNSET_E9", + 0x0EA: "OBJECT_UNSET_EA", + 0x0EB: "OBJECT_UNSET_EB", + 0x0EC: "OBJECT_D_HSBLOCK", + 0x0ED: "OBJECT_D_LIFT", + 0x0EE: "OBJECT_MAMENOKI", + 0x0EF: "OBJECT_GOROIWA", + 0x0F0: "OBJECT_TORYO", + 0x0F1: "OBJECT_DAIKU", + 0x0F2: "OBJECT_NWC", + 0x0F3: "OBJECT_GM", + 0x0F4: "OBJECT_MS", + 0x0F5: "OBJECT_HS", + 0x0F6: "OBJECT_UNSET_F6", + 0x0F7: "OBJECT_LIGHTSWITCH", + 0x0F8: "OBJECT_KUSA", + 0x0F9: "OBJECT_TSUBO", + 0x0FA: "OBJECT_UNSET_FA", + 0x0FB: "OBJECT_UNSET_FB", + 0x0FC: "OBJECT_KANBAN", + 0x0FD: "OBJECT_OWL", + 0x0FE: "OBJECT_MK", + 0x0FF: "OBJECT_FU", + 0x100: "OBJECT_GI_KI_TAN_MASK", + 0x101: "OBJECT_UNSET_101", + 0x102: "OBJECT_GI_MASK18", + 0x103: "OBJECT_GI_RABIT_MASK", + 0x104: "OBJECT_GI_TRUTH_MASK", + 0x105: "OBJECT_UNSET_105", + 0x106: "OBJECT_STREAM", + 0x107: "OBJECT_MM", + 0x108: "OBJECT_UNSET_108", + 0x109: "OBJECT_UNSET_109", + 0x10A: "OBJECT_UNSET_10A", + 0x10B: "OBJECT_UNSET_10B", + 0x10C: "OBJECT_UNSET_10C", + 0x10D: "OBJECT_UNSET_10D", + 0x10E: "OBJECT_UNSET_10E", + 0x10F: "OBJECT_JS", + 0x110: "OBJECT_CS", + 0x111: "OBJECT_UNSET_111", + 0x112: "OBJECT_UNSET_112", + 0x113: "OBJECT_GI_SOLDOUT", + 0x114: "OBJECT_UNSET_114", + 0x115: "OBJECT_MAG", + 0x116: "OBJECT_UNSET_116", + 0x117: "OBJECT_UNSET_117", + 0x118: "OBJECT_UNSET_118", + 0x119: "OBJECT_GI_GOLONMASK", + 0x11A: "OBJECT_GI_ZORAMASK", + 0x11B: "OBJECT_UNSET_11B", + 0x11C: "OBJECT_UNSET_11C", + 0x11D: "OBJECT_KA", + 0x11E: "OBJECT_UNSET_11E", + 0x11F: "OBJECT_ZG", + 0x120: "OBJECT_UNSET_120", + 0x121: "OBJECT_GI_M_ARROW", + 0x122: "OBJECT_DS2", + 0x123: "OBJECT_UNSET_123", + 0x124: "OBJECT_FISH", + 0x125: "OBJECT_GI_SUTARU", + 0x126: "OBJECT_UNSET_126", + 0x127: "OBJECT_SSH", + 0x128: "OBJECT_BIGSLIME", + 0x129: "OBJECT_BG", + 0x12A: "OBJECT_BOMBIWA", + 0x12B: "OBJECT_HINTNUTS", + 0x12C: "OBJECT_RS", + 0x12D: "OBJECT_UNSET_12D", + 0x12E: "OBJECT_GLA", + 0x12F: "OBJECT_UNSET_12F", + 0x130: "OBJECT_GELDB", + 0x131: "OBJECT_UNSET_131", + 0x132: "OBJECT_DOG", + 0x133: "OBJECT_KIBAKO2", + 0x134: "OBJECT_DNS", + 0x135: "OBJECT_DNK", + 0x136: "OBJECT_UNSET_136", + 0x137: "OBJECT_GI_INSECT", + 0x138: "OBJECT_UNSET_138", + 0x139: "OBJECT_GI_GHOST", + 0x13A: "OBJECT_GI_SOUL", + 0x13B: "OBJECT_UNSET_13B", + 0x13C: "OBJECT_UNSET_13C", + 0x13D: "OBJECT_UNSET_13D", + 0x13E: "OBJECT_UNSET_13E", + 0x13F: "OBJECT_GI_RUPY", + 0x140: "OBJECT_MU", + 0x141: "OBJECT_WF", + 0x142: "OBJECT_SKB", + 0x143: "OBJECT_GS", + 0x144: "OBJECT_PS", + 0x145: "OBJECT_OMOYA_OBJ", + 0x146: "OBJECT_COW", + 0x147: "OBJECT_UNSET_147", + 0x148: "OBJECT_GI_SWORD_1", + 0x149: "OBJECT_UNSET_149", + 0x14A: "OBJECT_UNSET_14A", + 0x14B: "OBJECT_ZL4", + 0x14C: "OBJECT_LINK_GORON", + 0x14D: "OBJECT_LINK_ZORA", + 0x14E: "OBJECT_GRASSHOPPER", + 0x14F: "OBJECT_BOYO", + 0x150: "OBJECT_UNSET_150", + 0x151: "OBJECT_UNSET_151", + 0x152: "OBJECT_UNSET_152", + 0x153: "OBJECT_FWALL", + 0x154: "OBJECT_LINK_NUTS", + 0x155: "OBJECT_JSO", + 0x156: "OBJECT_KNIGHT", + 0x157: "OBJECT_ICICLE", + 0x158: "OBJECT_SPDWEB", + 0x159: "OBJECT_UNSET_159", + 0x15A: "OBJECT_BOSS01", + 0x15B: "OBJECT_BOSS02", + 0x15C: "OBJECT_BOSS03", + 0x15D: "OBJECT_BOSS04", + 0x15E: "OBJECT_BOSS05", + 0x15F: "OBJECT_BOSS06", + 0x160: "OBJECT_BOSS07", + 0x161: "OBJECT_RAF", + 0x162: "OBJECT_FUNEN", + 0x163: "OBJECT_RAILLIFT", + 0x164: "OBJECT_NUMA_OBJ", + 0x165: "OBJECT_FLOWERPOT", + 0x166: "OBJECT_SPINYROLL", + 0x167: "OBJECT_ICE_BLOCK", + 0x168: "OBJECT_UNSET_168", + 0x169: "OBJECT_KEIKOKU_DEMO", + 0x16A: "OBJECT_SLIME", + 0x16B: "OBJECT_PR", + 0x16C: "OBJECT_F52_OBJ", + 0x16D: "OBJECT_F53_OBJ", + 0x16E: "OBJECT_UNSET_16E", + 0x16F: "OBJECT_KIBAKO", + 0x170: "OBJECT_SEK", + 0x171: "OBJECT_GMO", + 0x172: "OBJECT_BAT", + 0x173: "OBJECT_SEKIHIL", + 0x174: "OBJECT_SEKIHIG", + 0x175: "OBJECT_SEKIHIN", + 0x176: "OBJECT_SEKIHIZ", + 0x177: "OBJECT_UNSET_177", + 0x178: "OBJECT_WIZ", + 0x179: "OBJECT_LADDER", + 0x17A: "OBJECT_MKK", + 0x17B: "OBJECT_UNSET_17B", + 0x17C: "OBJECT_UNSET_17C", + 0x17D: "OBJECT_UNSET_17D", + 0x17E: "OBJECT_KEIKOKU_OBJ", + 0x17F: "OBJECT_SICHITAI_OBJ", + 0x180: "OBJECT_DEKUCITY_ANA_OBJ", + 0x181: "OBJECT_RAT", + 0x182: "OBJECT_WATER_EFFECT", + 0x183: "OBJECT_UNSET_183", + 0x184: "OBJECT_DBLUE_OBJECT", + 0x185: "OBJECT_BAL", + 0x186: "OBJECT_WARP_UZU", + 0x187: "OBJECT_DRIFTICE", + 0x188: "OBJECT_FALL", + 0x189: "OBJECT_HANAREYAMA_OBJ", + 0x18A: "OBJECT_CRACE_OBJECT", + 0x18B: "OBJECT_DNQ", + 0x18C: "OBJECT_OBJ_TOKEIDAI", + 0x18D: "OBJECT_EG", + 0x18E: "OBJECT_TRU", + 0x18F: "OBJECT_TRT", + 0x190: "OBJECT_HAKUGIN_OBJ", + 0x191: "OBJECT_HORSE_GAME_CHECK", + 0x192: "OBJECT_STK", + 0x193: "OBJECT_UNSET_193", + 0x194: "OBJECT_UNSET_194", + 0x195: "OBJECT_MNK", + 0x196: "OBJECT_GI_BOTTLE_RED", + 0x197: "OBJECT_TOKEI_TOBIRA", + 0x198: "OBJECT_AZ", + 0x199: "OBJECT_TWIG", + 0x19A: "OBJECT_DEKUCITY_OBJ", + 0x19B: "OBJECT_PO_FUSEN", + 0x19C: "OBJECT_RACETSUBO", + 0x19D: "OBJECT_HA", + 0x19E: "OBJECT_BIGOKUTA", + 0x19F: "OBJECT_OPEN_OBJ", + 0x1A0: "OBJECT_FU_KAITEN", + 0x1A1: "OBJECT_FU_MATO", + 0x1A2: "OBJECT_MTORIDE", + 0x1A3: "OBJECT_OSN", + 0x1A4: "OBJECT_TOKEI_STEP", + 0x1A5: "OBJECT_LOTUS", + 0x1A6: "OBJECT_TL", + 0x1A7: "OBJECT_DKJAIL_OBJ", + 0x1A8: "OBJECT_VISIBLOCK", + 0x1A9: "OBJECT_TSN", + 0x1AA: "OBJECT_DS2N", + 0x1AB: "OBJECT_FSN", + 0x1AC: "OBJECT_SHN", + 0x1AD: "OBJECT_BIGICICLE", + 0x1AE: "OBJECT_GI_BOTTLE_15", + 0x1AF: "OBJECT_TK", + 0x1B0: "OBJECT_MARKET_OBJ", + 0x1B1: "OBJECT_GI_RESERVE00", + 0x1B2: "OBJECT_GI_RESERVE01", + 0x1B3: "OBJECT_LIGHTBLOCK", + 0x1B4: "OBJECT_TAKARAYA_OBJECTS", + 0x1B5: "OBJECT_WDHAND", + 0x1B6: "OBJECT_SDN", + 0x1B7: "OBJECT_SNOWWD", + 0x1B8: "OBJECT_GIANT", + 0x1B9: "OBJECT_COMB", + 0x1BA: "OBJECT_HANA", + 0x1BB: "OBJECT_BOSS_HAKUGIN", + 0x1BC: "OBJECT_MEGANEANA_OBJ", + 0x1BD: "OBJECT_GI_NUTSMASK", + 0x1BE: "OBJECT_STK2", + 0x1BF: "OBJECT_SPOT11_OBJ", + 0x1C0: "OBJECT_DANPEI_OBJECT", + 0x1C1: "OBJECT_DHOUSE", + 0x1C2: "OBJECT_HAKAISI", + 0x1C3: "OBJECT_PO", + 0x1C4: "OBJECT_SNOWMAN", + 0x1C5: "OBJECT_PO_SISTERS", + 0x1C6: "OBJECT_PP", + 0x1C7: "OBJECT_GORONSWITCH", + 0x1C8: "OBJECT_DELF", + 0x1C9: "OBJECT_BOTIHASIRA", + 0x1CA: "OBJECT_GI_BIGBOMB", + 0x1CB: "OBJECT_PST", + 0x1CC: "OBJECT_BSMASK", + 0x1CD: "OBJECT_SPIDERTENT", + 0x1CE: "OBJECT_ZORAEGG", + 0x1CF: "OBJECT_KBT", + 0x1D0: "OBJECT_GG", + 0x1D1: "OBJECT_MARUTA", + 0x1D2: "OBJECT_GHAKA", + 0x1D3: "OBJECT_OYU", + 0x1D4: "OBJECT_DNP", + 0x1D5: "OBJECT_DAI", + 0x1D6: "OBJECT_KGY", + 0x1D7: "OBJECT_FB", + 0x1D8: "OBJECT_TAISOU", + 0x1D9: "OBJECT_MASK_BU_SAN", + 0x1DA: "OBJECT_MASK_KI_TAN", + 0x1DB: "OBJECT_MASK_RABIT", + 0x1DC: "OBJECT_MASK_SKJ", + 0x1DD: "OBJECT_MASK_BAKURETU", + 0x1DE: "OBJECT_MASK_TRUTH", + 0x1DF: "OBJECT_GK", + 0x1E0: "OBJECT_HAKA_OBJ", + 0x1E1: "OBJECT_MASK_GORON", + 0x1E2: "OBJECT_MASK_ZORA", + 0x1E3: "OBJECT_MASK_NUTS", + 0x1E4: "OBJECT_MASK_BOY", + 0x1E5: "OBJECT_DNT", + 0x1E6: "OBJECT_YUKIYAMA", + 0x1E7: "OBJECT_ICEFLOE", + 0x1E8: "OBJECT_GI_GOLD_DUST", + 0x1E9: "OBJECT_GI_BOTTLE_16", + 0x1EA: "OBJECT_GI_BOTTLE_22", + 0x1EB: "OBJECT_BEE", + 0x1EC: "OBJECT_OT", + 0x1ED: "OBJECT_UTUBO", + 0x1EE: "OBJECT_DORA", + 0x1EF: "OBJECT_GI_LOACH", + 0x1F0: "OBJECT_GI_SEAHORSE", + 0x1F1: "OBJECT_BIGPO", + 0x1F2: "OBJECT_HARIKO", + 0x1F3: "OBJECT_DNO", + 0x1F4: "OBJECT_SINKAI_KABE", + 0x1F5: "OBJECT_KIN2_OBJ", + 0x1F6: "OBJECT_ISHI", + 0x1F7: "OBJECT_HAKUGIN_DEMO", + 0x1F8: "OBJECT_JG", + 0x1F9: "OBJECT_GI_SWORD_2", + 0x1FA: "OBJECT_GI_SWORD_3", + 0x1FB: "OBJECT_GI_SWORD_4", + 0x1FC: "OBJECT_UM", + 0x1FD: "OBJECT_MASK_GIBUDO", + 0x1FE: "OBJECT_MASK_JSON", + 0x1FF: "OBJECT_MASK_KERFAY", + 0x200: "OBJECT_MASK_BIGELF", + 0x201: "OBJECT_RB", + 0x202: "OBJECT_MBAR_OBJ", + 0x203: "OBJECT_IKANA_OBJ", + 0x204: "OBJECT_KZ", + 0x205: "OBJECT_TOKEI_TURRET", + 0x206: "OBJECT_ZOG", + 0x207: "OBJECT_ROTLIFT", + 0x208: "OBJECT_POSTHOUSE_OBJ", + 0x209: "OBJECT_GI_MASK09", + 0x20A: "OBJECT_GI_MASK14", + 0x20B: "OBJECT_GI_MASK15", + 0x20C: "OBJECT_INIBS_OBJECT", + 0x20D: "OBJECT_TREE", + 0x20E: "OBJECT_KAIZOKU_OBJ", + 0x20F: "OBJECT_GI_RESERVE_B_00", + 0x210: "OBJECT_GI_RESERVE_C_00", + 0x211: "OBJECT_ZOB", + 0x212: "OBJECT_MILKBAR", + 0x213: "OBJECT_DMASK", + 0x214: "OBJECT_MASK_KYOJIN", + 0x215: "OBJECT_GI_RESERVE_C_01", + 0x216: "OBJECT_ZOD", + 0x217: "OBJECT_KUMO30", + 0x218: "OBJECT_OBJ_YASI", + 0x219: "OBJECT_MASK_ROMERNY", + 0x21A: "OBJECT_TANRON1", + 0x21B: "OBJECT_TANRON2", + 0x21C: "OBJECT_TANRON3", + 0x21D: "OBJECT_GI_MAGICMUSHROOM", + 0x21E: "OBJECT_OBJ_CHAN", + 0x21F: "OBJECT_GI_MASK10", + 0x220: "OBJECT_ZOS", + 0x221: "OBJECT_MASK_POSTHAT", + 0x222: "OBJECT_F40_SWITCH", + 0x223: "OBJECT_LODMOON", + 0x224: "OBJECT_TRO", + 0x225: "OBJECT_GI_MASK12", + 0x226: "OBJECT_GI_MASK23", + 0x227: "OBJECT_GI_BOTTLE_21", + 0x228: "OBJECT_GI_CAMERA", + 0x229: "OBJECT_KAMEJIMA", + 0x22A: "OBJECT_HARFGIBUD", + 0x22B: "OBJECT_ZOV", + 0x22C: "OBJECT_HGDOOR", + 0x22D: "OBJECT_UNSET_22D", + 0x22E: "OBJECT_UNSET_22E", + 0x22F: "OBJECT_UNSET_22F", + 0x230: "OBJECT_DOR01", + 0x231: "OBJECT_DOR02", + 0x232: "OBJECT_DOR03", + 0x233: "OBJECT_DOR04", + 0x234: "OBJECT_LAST_OBJ", + 0x235: "OBJECT_REDEAD_OBJ", + 0x236: "OBJECT_IKNINSIDE_OBJ", + 0x237: "OBJECT_IKNV_OBJ", + 0x238: "OBJECT_PAMERA", + 0x239: "OBJECT_HSSTUMP", + 0x23A: "OBJECT_ZM", + 0x23B: "OBJECT_BIG_FWALL", + 0x23C: "OBJECT_SECOM_OBJ", + 0x23D: "OBJECT_HUNSUI", + 0x23E: "OBJECT_UCH", + 0x23F: "OBJECT_TANRON4", + 0x240: "OBJECT_TANRON5", + 0x241: "OBJECT_DT", + 0x242: "OBJECT_GI_MASK03", + 0x243: "OBJECT_CHA", + 0x244: "OBJECT_OBJ_DINNER", + 0x245: "OBJECT_GI_RESERVE_B_01", + 0x246: "OBJECT_LASTDAY", + 0x247: "OBJECT_BAI", + 0x248: "OBJECT_IN2", + 0x249: "OBJECT_IKN_DEMO", + 0x24A: "OBJECT_YB", + 0x24B: "OBJECT_RZ", + 0x24C: "OBJECT_MASK_ZACHO", + 0x24D: "OBJECT_GI_FIELDMAP", + 0x24E: "OBJECT_MASK_STONE", + 0x24F: "OBJECT_BJT", + 0x250: "OBJECT_TARU", + 0x251: "OBJECT_MOONSTON", + 0x252: "OBJECT_MASK_BREE", + 0x253: "OBJECT_GI_SCHEDULE", + 0x254: "OBJECT_GI_STONEMASK", + 0x255: "OBJECT_ZORABAND", + 0x256: "OBJECT_KEPN_KOYA", + 0x257: "OBJECT_OBJ_USIYANE", + 0x258: "OBJECT_GI_MASK05", + 0x259: "OBJECT_GI_MASK11", + 0x25A: "OBJECT_GI_MASK20", + 0x25B: "OBJECT_NNH", + 0x25C: "OBJECT_MASK_GERO", + 0x25D: "OBJECT_MASK_YOFUKASI", + 0x25E: "OBJECT_MASK_MEOTO", + 0x25F: "OBJECT_MASK_DANCER", + 0x260: "OBJECT_KZSAKU", + 0x261: "OBJECT_OBJ_MILK_BIN", + 0x262: "OBJECT_RANDOM_OBJ", + 0x263: "OBJECT_KUJIYA", + 0x264: "OBJECT_KITAN", + 0x265: "OBJECT_GI_MASK06", + 0x266: "OBJECT_GI_MASK16", + 0x267: "OBJECT_ASTR_OBJ", + 0x268: "OBJECT_BSB", + 0x269: "OBJECT_FALL2", + 0x26A: "OBJECT_STH", + 0x26B: "OBJECT_GI_MSSA", + 0x26C: "OBJECT_SMTOWER", + 0x26D: "OBJECT_GI_MASK21", + 0x26E: "OBJECT_YADO_OBJ", + 0x26F: "OBJECT_SYOTEN", + 0x270: "OBJECT_MOONEND", + 0x271: "OBJECT_OB", + 0x272: "OBJECT_GI_BOTTLE_04", + 0x273: "OBJECT_OBJ_DANPEILIFT", + 0x274: "OBJECT_WDOR01", + 0x275: "OBJECT_WDOR02", + 0x276: "OBJECT_WDOR03", + 0x277: "OBJECT_STK3", + 0x278: "OBJECT_KINSTA1_OBJ", + 0x279: "OBJECT_KINSTA2_OBJ", + 0x27A: "OBJECT_BH", + 0x27B: "OBJECT_WDOR04", + 0x27C: "OBJECT_WDOR05", + 0x27D: "OBJECT_GI_MASK17", + 0x27E: "OBJECT_GI_MASK22", + 0x27F: "OBJECT_LBFSHOT", + 0x280: "OBJECT_FUSEN", + 0x281: "OBJECT_ENDING_OBJ", + 0x282: "OBJECT_GI_MASK13", + 0x283: "OBJECT_ID_MAX", +} + +@dataclasses.dataclass +class GetItemEntry: + getItemId: int + itemId: int + field: int + gi: int + textId: int + objectId: int + + def __str__(self) -> str: + itemId_name = itemId_names.get(self.itemId, f"NOT FOUND: 0x{self.itemId:X}") + gid = abs(self.gi) - 1 + getitemDrawId_name = getItemDrawId_names.get(gid, f"NOT FOUND: 0x{abs(self.gi) - 1:X}") + + if self.gi == 0: + chest_anim = 0 + else: + chest_anim = "CHEST_ANIM_SHORT" if self.gi < 0 else "CHEST_ANIM_LONG" + + objectId_name = objectId_names.get(self.objectId, f"NOT FOUND: 0x{abs(self.objectId):X}") + + ret = f"/* 0x{self.getItemId:02X} */ GET_ITEM({itemId_name}, {objectId_name}, {getitemDrawId_name}, 0x{self.textId:X}, 0x{self.field:X}, {chest_anim})" + + return ret + +def main() -> None: + description = "Extract and print the GetItem table" + epilog = "" + + parser = argparse.ArgumentParser(description=description, epilog=epilog, formatter_class=argparse.RawTextHelpFormatter) + parser.add_argument("file", help="binary file to read") + parser.add_argument("offset", help="offset at which to start reading") + parser.add_argument("count", help="number of entries to extract") + parser.add_argument("-g", help="look further back for glitched items from Get Item Manipulation", action="store_true") + + args = parser.parse_args() + + start = int(args.offset, 0) + count = int(args.count, 0) + glitched = args.g + pos_start = 0 + + with open(args.file, "rb") as f: + if glitched: + start -= GETITEMENTRY_LENGTH * count + pos_start -= count + count *= 2 + + f.seek(start, os.SEEK_SET) + data = f.read(GETITEMENTRY_LENGTH * count) + unpacked_data = struct.iter_unpack(GETITEMENTRY_FORMAT, data) + get_item_entries: typing.List[GetItemEntry] = [] + + for i,entry in enumerate(unpacked_data): + get_item_entries.append(GetItemEntry(pos_start + i+1, *entry)) + + for entry in get_item_entries: + print(f"{entry},") + + + +if __name__ == "__main__": + main() diff --git a/tools/namefixer.py b/tools/namefixer.py index a03cc06cf0..54edb56440 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -222,6 +222,7 @@ wordReplace = { "SkelAnime_InitLink": "SkelAnime_InitPlayer", "LinkAnimation_SetUpdateFunction": "PlayerAnimation_SetUpdateFunction", "LinkAnimation_Update": "PlayerAnimation_Update", + "LinkAnimation_AnimateFrame": "PlayerAnimation_AnimateFrame", "SkelAnime_SetTransition": "Animation_SetMorph", "LinkAnimation_Change": "PlayerAnimation_Change", "LinkAnimation_PlayOnce": "PlayerAnimation_PlayOnce", @@ -903,6 +904,7 @@ wordReplace = { "player->swordInfo": "player->meleeWeaponInfo", "player->itemActionParam": "player->heldItemAction", "player->heldItemActionParam": "player->itemAction", + "player->unk_A86": "player->currentActorCsIndex", "player->unk_A9C": "player->secretRumbleCharge", "player->unk_AA0": "player->closestSecretDistSq", "player->unk_AAC": "player->headLimbRot", @@ -911,6 +913,8 @@ wordReplace = { "player->getItemDrawId": "player->getItemDrawIdPlusOne", "player->unk_B68": "player->fallStartHeight", "player->unk_B6A": "player->fallDistance", + "player->unk_B80": "player->pushedSpeed", + "player->unk_B84": "player->pushedYaw", "player->targetActor": "player->talkActor", "player->targetActorDistance": "player->talkActorDistance", "player->unk_730": "player->targetedActor", @@ -991,6 +995,7 @@ wordReplace = { "play->sceneLoadFlag": "play->transitionTrigger", "play->unk_18B4A": "play->transitionMode", "play->unk_1887F": "play->transitionType", + "play->roomCtx.currRoom": "play->roomCtx.curRoom", "gSaveContext.nextTransition": "gSaveContext.nextTransitionType", "gSaveContext.unk_3F48": "gSaveContext.cutsceneTransitionControl", "gSaveContext.fadeDuration": "gSaveContext.transFadeDuration", diff --git a/undefined_syms.txt b/undefined_syms.txt index 2187673fcd..7ef51ef241 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1103,18 +1103,6 @@ D_06002188 = 0x06002188; D_06000B70 = 0x06000B70; D_06000D60 = 0x06000D60; -// ovl_player_actor - -D_06008860 = 0x06008860; -D_0600BDD8 = 0x0600BDD8; -D_0600C540 = 0x0600C540; -D_060127B0 = 0x060127B0; -D_06013138 = 0x06013138; -D_060134D0 = 0x060134D0; -D_06014684 = 0x06014684; -D_060177B8 = 0x060177B8; -D_060178D0 = 0x060178D0; - // segment 0x07