2022-03-21 21:51:23 -04:00
# include "global.h"
# include "objects/gameplay_keep/gameplay_keep.h"
2022-12-20 23:32:01 -05:00
# include "objects/gameplay_field_keep/gameplay_field_keep.h"
2022-03-21 21:51:23 -04:00
# include "objects/object_link_boy/object_link_boy.h"
# include "objects/object_link_child/object_link_child.h"
# include "objects/object_triforce_spot/object_triforce_spot.h"
# include "overlays/actors/ovl_Demo_Effect/z_demo_effect.h"
2023-01-25 18:13:33 -05:00
# include "soh/Enhancements/game-interactor/GameInteractor.h"
2023-09-26 09:45:37 -04:00
# include "soh/Enhancements/randomizer/draw.h"
2022-09-27 22:41:17 -04:00
2023-06-27 19:53:35 -04:00
# include <stdlib.h>
2022-03-21 21:51:23 -04:00
typedef struct {
/* 0x00 */ u8 flag ;
/* 0x02 */ u16 textId ;
} TextTriggerEntry ; // size = 0x04
typedef struct {
/* 0x00 */ void * dList ;
/* 0x04 */ Vec3f pos ;
} BowStringData ; // size = 0x10
FlexSkeletonHeader * gPlayerSkelHeaders [ ] = { & gLinkAdultSkel , & gLinkChildSkel } ;
s16 sBootData [ PLAYER_BOOTS_MAX ] [ 17 ] = {
{ 200 , 1000 , 300 , 700 , 550 , 270 , 600 , 350 , 800 , 600 , - 100 , 600 , 590 , 750 , 125 , 200 , 130 } ,
{ 200 , 1000 , 300 , 700 , 550 , 270 , 1000 , 0 , 800 , 300 , - 160 , 600 , 590 , 750 , 125 , 200 , 130 } ,
{ 200 , 1000 , 300 , 700 , 550 , 270 , 600 , 600 , 800 , 550 , - 100 , 600 , 540 , 270 , 25 , 0 , 130 } ,
{ 200 , 1000 , 300 , 700 , 380 , 400 , 0 , 300 , 800 , 500 , - 100 , 600 , 590 , 750 , 125 , 200 , 130 } ,
{ 80 , 800 , 150 , 700 , 480 , 270 , 600 , 50 , 800 , 550 , - 40 , 400 , 540 , 270 , 25 , 0 , 80 } ,
{ 200 , 1000 , 300 , 800 , 500 , 400 , 800 , 400 , 800 , 550 , - 100 , 600 , 540 , 750 , 125 , 400 , 200 } ,
} ;
// Used to map action params to model groups
u8 sActionModelGroups [ ] = {
2023-10-26 20:38:43 -04:00
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_NONE
PLAYER_MODELGROUP_15 , // PLAYER_IA_LAST_USED
PLAYER_MODELGROUP_10 , // PLAYER_IA_FISHING_POLE
PLAYER_MODELGROUP_SWORD , // PLAYER_IA_SWORD_MASTER
PLAYER_MODELGROUP_SWORD , // PLAYER_IA_SWORD_KOKIRI
PLAYER_MODELGROUP_BGS , // PLAYER_IA_SWORD_BIGGORON
PLAYER_MODELGROUP_10 , // PLAYER_IA_DEKU_STICK
PLAYER_MODELGROUP_HAMMER , // PLAYER_IA_HAMMER
PLAYER_MODELGROUP_BOW_SLINGSHOT , // PLAYER_IA_BOW
PLAYER_MODELGROUP_BOW_SLINGSHOT , // PLAYER_IA_BOW_FIRE
PLAYER_MODELGROUP_BOW_SLINGSHOT , // PLAYER_IA_BOW_ICE
PLAYER_MODELGROUP_BOW_SLINGSHOT , // PLAYER_IA_BOW_LIGHT
PLAYER_MODELGROUP_BOW_SLINGSHOT , // PLAYER_IA_BOW_0C
PLAYER_MODELGROUP_BOW_SLINGSHOT , // PLAYER_IA_BOW_0D
PLAYER_MODELGROUP_BOW_SLINGSHOT , // PLAYER_IA_BOW_0E
PLAYER_MODELGROUP_BOW_SLINGSHOT , // PLAYER_IA_SLINGSHOT
PLAYER_MODELGROUP_HOOKSHOT , // PLAYER_IA_HOOKSHOT
PLAYER_MODELGROUP_HOOKSHOT , // PLAYER_IA_LONGSHOT
PLAYER_MODELGROUP_EXPLOSIVES , // PLAYER_IA_BOMB
PLAYER_MODELGROUP_EXPLOSIVES , // PLAYER_IA_BOMBCHU
PLAYER_MODELGROUP_BOOMERANG , // PLAYER_IA_BOOMERANG
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_MAGIC_SPELL_15
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_MAGIC_SPELL_16
PLAYER_MODELGROUP_BOW_SLINGSHOT , // PLAYER_IA_MAGIC_SPELL_17
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_FARORES_WIND
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_NAYRUS_LOVE
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_DINS_FIRE
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_DEKU_NUT
PLAYER_MODELGROUP_OCARINA , // PLAYER_IA_OCARINA_FAIRY
PLAYER_MODELGROUP_OOT , // PLAYER_IA_OCARINA_OF_TIME
PLAYER_MODELGROUP_BOTTLE , // PLAYER_IA_BOTTLE
PLAYER_MODELGROUP_BOTTLE , // PLAYER_IA_BOTTLE_FISH
PLAYER_MODELGROUP_BOTTLE , // PLAYER_IA_BOTTLE_FIRE
PLAYER_MODELGROUP_BOTTLE , // PLAYER_IA_BOTTLE_BUG
PLAYER_MODELGROUP_BOTTLE , // PLAYER_IA_BOTTLE_POE
PLAYER_MODELGROUP_BOTTLE , // PLAYER_IA_BOTTLE_BIG_POE
PLAYER_MODELGROUP_BOTTLE , // PLAYER_IA_BOTTLE_RUTOS_LETTER
PLAYER_MODELGROUP_BOTTLE , // PLAYER_IA_BOTTLE_POTION_RED
PLAYER_MODELGROUP_BOTTLE , // PLAYER_IA_BOTTLE_POTION_BLUE
PLAYER_MODELGROUP_BOTTLE , // PLAYER_IA_BOTTLE_POTION_GREEN
PLAYER_MODELGROUP_BOTTLE , // PLAYER_IA_BOTTLE_MILK_FULL
PLAYER_MODELGROUP_BOTTLE , // PLAYER_IA_BOTTLE_MILK_HALF
PLAYER_MODELGROUP_BOTTLE , // PLAYER_IA_BOTTLE_FAIRY
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_ZELDAS_LETTER
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_WEIRD_EGG
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_CHICKEN
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_MAGIC_BEAN
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_POCKET_EGG
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_POCKET_CUCCO
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_COJIRO
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_ODD_MUSHROOM
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_ODD_POTION
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_POACHERS_SAW
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_BROKEN_GORONS_SWORD
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_PRESCRIPTION
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_FROG
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_EYEDROPS
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_CLAIM_CHECK
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_MASK_KEATON
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_MASK_SKULL
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_MASK_SPOOKY
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_MASK_BUNNY_HOOD
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_MASK_GORON
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_MASK_ZORA
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_MASK_GERUDO
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_MASK_TRUTH
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_LENS_OF_TRUTH
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_SHIELD_DEKU
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_SHIELD_HYLIAN
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_SHIELD_MIRROR
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_TUNIC_KOKIRI
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_TUNIC_GORON
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_TUNIC_ZORA
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_BOOTS_KOKIRI
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_BOOTS_IRON
PLAYER_MODELGROUP_DEFAULT , // PLAYER_IA_BOOTS_HOVER
2022-03-21 21:51:23 -04:00
} ;
TextTriggerEntry sTextTriggers [ ] = {
{ 1 , 0x3040 } ,
{ 2 , 0x401D } ,
{ 0 , 0x0000 } ,
{ 2 , 0x401D } ,
} ;
// Used to map model groups to model types for [animation, left hand, right hand, sheath, waist]
2023-10-26 20:38:43 -04:00
u8 gPlayerModelTypes [ PLAYER_MODELGROUP_MAX ] [ PLAYER_MODELGROUPENTRY_MAX ] = {
/* PLAYER_MODELGROUP_0 */
{
PLAYER_ANIMTYPE_2 ,
PLAYER_MODELTYPE_LH_OPEN ,
PLAYER_MODELTYPE_RH_SHIELD ,
PLAYER_MODELTYPE_SHEATH_16 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_CHILD_HYLIAN_SHIELD */
{
PLAYER_ANIMTYPE_1 ,
PLAYER_MODELTYPE_LH_SWORD ,
PLAYER_MODELTYPE_RH_CLOSED ,
PLAYER_MODELTYPE_SHEATH_19 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_SWORD */
{
PLAYER_ANIMTYPE_1 ,
PLAYER_MODELTYPE_LH_SWORD ,
PLAYER_MODELTYPE_RH_SHIELD ,
PLAYER_MODELTYPE_SHEATH_17 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_DEFAULT */
{
PLAYER_ANIMTYPE_0 ,
PLAYER_MODELTYPE_LH_OPEN ,
PLAYER_MODELTYPE_RH_OPEN ,
PLAYER_MODELTYPE_SHEATH_18 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_4 */
{
PLAYER_ANIMTYPE_0 ,
PLAYER_MODELTYPE_LH_OPEN ,
PLAYER_MODELTYPE_RH_OPEN ,
PLAYER_MODELTYPE_SHEATH_18 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_BGS */
{
PLAYER_ANIMTYPE_3 ,
PLAYER_MODELTYPE_LH_BGS ,
PLAYER_MODELTYPE_RH_CLOSED ,
PLAYER_MODELTYPE_SHEATH_19 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_BOW_SLINGSHOT */
{
PLAYER_ANIMTYPE_4 ,
PLAYER_MODELTYPE_LH_CLOSED ,
PLAYER_MODELTYPE_RH_BOW_SLINGSHOT ,
PLAYER_MODELTYPE_SHEATH_18 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_EXPLOSIVES */
{
PLAYER_ANIMTYPE_5 ,
PLAYER_MODELTYPE_LH_OPEN ,
PLAYER_MODELTYPE_RH_OPEN ,
PLAYER_MODELTYPE_SHEATH_18 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_BOOMERANG */
{
PLAYER_ANIMTYPE_0 ,
PLAYER_MODELTYPE_LH_BOOMERANG ,
PLAYER_MODELTYPE_RH_OPEN ,
PLAYER_MODELTYPE_SHEATH_18 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_HOOKSHOT */
{
PLAYER_ANIMTYPE_4 ,
PLAYER_MODELTYPE_LH_OPEN ,
PLAYER_MODELTYPE_RH_HOOKSHOT ,
PLAYER_MODELTYPE_SHEATH_18 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_10 */
{
PLAYER_ANIMTYPE_3 ,
PLAYER_MODELTYPE_LH_CLOSED ,
PLAYER_MODELTYPE_RH_CLOSED ,
PLAYER_MODELTYPE_SHEATH_18 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_HAMMER */
{
PLAYER_ANIMTYPE_3 ,
PLAYER_MODELTYPE_LH_HAMMER ,
PLAYER_MODELTYPE_RH_CLOSED ,
PLAYER_MODELTYPE_SHEATH_18 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_OCARINA */
{
PLAYER_ANIMTYPE_0 ,
PLAYER_MODELTYPE_LH_OPEN ,
PLAYER_MODELTYPE_RH_OCARINA ,
PLAYER_MODELTYPE_SHEATH_18 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_OOT */
{
PLAYER_ANIMTYPE_0 ,
PLAYER_MODELTYPE_LH_OPEN ,
PLAYER_MODELTYPE_RH_OOT ,
PLAYER_MODELTYPE_SHEATH_18 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_BOTTLE */
{
PLAYER_ANIMTYPE_0 ,
PLAYER_MODELTYPE_LH_BOTTLE ,
PLAYER_MODELTYPE_RH_OPEN ,
PLAYER_MODELTYPE_SHEATH_18 ,
PLAYER_MODELTYPE_WAIST
} ,
/* PLAYER_MODELGROUP_15 */
{
PLAYER_ANIMTYPE_0 ,
PLAYER_MODELTYPE_LH_SWORD ,
PLAYER_MODELTYPE_RH_OPEN ,
PLAYER_MODELTYPE_SHEATH_19 ,
PLAYER_MODELTYPE_WAIST
} ,
2022-03-21 21:51:23 -04:00
} ;
2023-10-26 20:38:43 -04:00
Gfx * sPlayerRightHandShieldDLs [ PLAYER_SHIELD_MAX * 4 ] = {
// PLAYER_SHIELD_NONE
2022-03-21 21:51:23 -04:00
gLinkAdultRightHandClosedNearDL ,
gLinkChildRightHandClosedNearDL ,
gLinkAdultRightHandClosedFarDL ,
gLinkChildRightHandClosedFarDL ,
2023-10-26 20:38:43 -04:00
// PLAYER_SHIELD_DEKU
2022-03-21 21:51:23 -04:00
gLinkAdultRightHandClosedNearDL ,
gLinkChildRightFistAndDekuShieldNearDL ,
gLinkAdultRightHandClosedFarDL ,
gLinkChildRightFistAndDekuShieldFarDL ,
2023-10-26 20:38:43 -04:00
// PLAYER_SHIELD_HYLIAN
2022-03-21 21:51:23 -04:00
gLinkAdultRightHandHoldingHylianShieldNearDL ,
gLinkChildRightHandClosedNearDL ,
gLinkAdultRightHandHoldingHylianShieldFarDL ,
gLinkChildRightHandClosedFarDL ,
2023-10-26 20:38:43 -04:00
// PLAYER_SHIELD_MIRROR
2022-03-21 21:51:23 -04:00
gLinkAdultRightHandHoldingMirrorShieldNearDL ,
gLinkChildRightHandClosedNearDL ,
gLinkAdultRightHandHoldingMirrorShieldFarDL ,
gLinkChildRightHandClosedFarDL ,
} ;
2023-10-26 20:38:43 -04:00
Gfx * sSheathWithSwordDLs [ ( PLAYER_SHIELD_MAX + 2 ) * 4 ] = {
// PLAYER_SHIELD_NONE
2022-03-21 21:51:23 -04:00
gLinkAdultMasterSwordAndSheathNearDL , gLinkChildSwordAndSheathNearDL ,
gLinkAdultMasterSwordAndSheathFarDL , gLinkChildSwordAndSheathFarDL ,
2023-10-26 20:38:43 -04:00
// PLAYER_SHIELD_DEKU
2022-03-21 21:51:23 -04:00
gLinkAdultMasterSwordAndSheathNearDL , gLinkChildDekuShieldSwordAndSheathNearDL ,
gLinkAdultMasterSwordAndSheathFarDL , gLinkChildDekuShieldSwordAndSheathFarDL ,
2023-10-26 20:38:43 -04:00
// PLAYER_SHIELD_HYLIAN
2022-03-21 21:51:23 -04:00
gLinkAdultHylianShieldSwordAndSheathNearDL , gLinkChildHylianShieldSwordAndSheathNearDL ,
gLinkAdultHylianShieldSwordAndSheathFarDL , gLinkChildHylianShieldSwordAndSheathFarDL ,
2023-10-26 20:38:43 -04:00
// PLAYER_SHIELD_MIRROR
2022-03-21 21:51:23 -04:00
gLinkAdultMirrorShieldSwordAndSheathNearDL , gLinkChildSwordAndSheathNearDL ,
gLinkAdultMirrorShieldSwordAndSheathFarDL , gLinkChildSwordAndSheathFarDL ,
2023-10-26 20:38:43 -04:00
// PLAYER_SHIELD_NONE (child, no sword)
2022-03-21 21:51:23 -04:00
NULL , NULL ,
NULL , NULL ,
2023-10-26 20:38:43 -04:00
// PLAYER_SHIELD_DEKU (child, no sword)
2022-03-21 21:51:23 -04:00
NULL , gLinkChildDekuShieldWithMatrixDL ,
NULL , gLinkChildDekuShieldWithMatrixDL ,
} ;
2023-10-26 20:38:43 -04:00
Gfx * sSheathWithoutSwordDLs [ ( PLAYER_SHIELD_MAX + 2 ) * 4 ] = {
// PLAYER_SHIELD_NONE
2022-03-21 21:51:23 -04:00
gLinkAdultSheathNearDL ,
gLinkChildSheathNearDL ,
gLinkAdultSheathFarDL ,
gLinkChildSheathFarDL ,
2023-10-26 20:38:43 -04:00
// PLAYER_SHIELD_DEKU
2022-03-21 21:51:23 -04:00
gLinkAdultSheathNearDL ,
gLinkChildDekuShieldAndSheathNearDL ,
gLinkAdultSheathFarDL ,
gLinkChildDekuShieldAndSheathFarDL ,
2023-10-26 20:38:43 -04:00
// PLAYER_SHIELD_HYLIAN
2022-03-21 21:51:23 -04:00
gLinkAdultHylianShieldAndSheathNearDL ,
gLinkChildHylianShieldAndSheathNearDL ,
gLinkAdultHylianShieldAndSheathFarDL ,
gLinkChildHylianShieldAndSheathFarDL ,
2023-10-26 20:38:43 -04:00
// PLAYER_SHIELD_MIRROR
2022-03-21 21:51:23 -04:00
gLinkAdultMirrorShieldAndSheathNearDL ,
gLinkChildSheathNearDL ,
gLinkAdultMirrorShieldAndSheathFarDL ,
gLinkChildSheathFarDL ,
2023-10-26 20:38:43 -04:00
// PLAYER_SHIELD_NONE (child, no sword)
2022-03-21 21:51:23 -04:00
NULL ,
NULL ,
NULL ,
NULL ,
2023-10-26 20:38:43 -04:00
// PLAYER_SHIELD_DEKU (child, no sword)
2022-03-21 21:51:23 -04:00
gLinkAdultSheathNearDL ,
gLinkChildDekuShieldWithMatrixDL ,
gLinkAdultSheathNearDL ,
gLinkChildDekuShieldWithMatrixDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * gPlayerLeftHandBgsDLs [ ] = {
2023-10-26 20:38:43 -04:00
// Biggoron Sword
2022-03-21 21:51:23 -04:00
gLinkAdultLeftHandHoldingBgsNearDL , gLinkChildLeftHandHoldingMasterSwordDL ,
gLinkAdultLeftHandHoldingBgsFarDL , gLinkChildLeftHandHoldingMasterSwordDL ,
2023-10-26 20:38:43 -04:00
// Broken Giant's Knife
2022-03-21 21:51:23 -04:00
gLinkAdultHandHoldingBrokenGiantsKnifeDL , gLinkChildLeftHandHoldingMasterSwordDL ,
gLinkAdultHandHoldingBrokenGiantsKnifeFarDL , gLinkChildLeftHandHoldingMasterSwordDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * gPlayerLeftHandOpenDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultLeftHandNearDL ,
gLinkChildLeftHandNearDL ,
gLinkAdultLeftHandFarDL ,
gLinkChildLeftHandFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * gPlayerLeftHandClosedDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultLeftHandClosedNearDL ,
gLinkChildLeftFistNearDL ,
gLinkAdultLeftHandClosedFarDL ,
gLinkChildLeftFistFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sPlayerLeftHandSwordDLs2 [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultLeftHandHoldingMasterSwordNearDL ,
gLinkChildLeftFistAndKokiriSwordNearDL ,
gLinkAdultLeftHandHoldingMasterSwordFarDL ,
gLinkChildLeftFistAndKokiriSwordFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sPlayerLeftHandSwordDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultLeftHandHoldingMasterSwordNearDL ,
gLinkChildLeftFistAndKokiriSwordNearDL ,
gLinkAdultLeftHandHoldingMasterSwordFarDL ,
gLinkChildLeftFistAndKokiriSwordFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sPlayerRightHandOpenDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultRightHandNearDL ,
gLinkChildRightHandNearDL ,
gLinkAdultRightHandFarDL ,
gLinkChildRightHandFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sPlayerRightHandClosedDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultRightHandClosedNearDL ,
gLinkChildRightHandClosedNearDL ,
gLinkAdultRightHandClosedFarDL ,
gLinkChildRightHandClosedFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sPlayerRightHandBowSlingshotDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultRightHandHoldingBowNearDL ,
gLinkChildRightHandHoldingSlingshotNearDL ,
gLinkAdultRightHandHoldingBowFarDL ,
gLinkChildRightHandHoldingSlingshotFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sSwordAndSheathDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultMasterSwordAndSheathNearDL ,
gLinkChildSwordAndSheathNearDL ,
gLinkAdultMasterSwordAndSheathFarDL ,
gLinkChildSwordAndSheathFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sSheathDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultSheathNearDL ,
gLinkChildSheathNearDL ,
gLinkAdultSheathFarDL ,
gLinkChildSheathFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sPlayerWaistDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultWaistNearDL ,
gLinkChildWaistNearDL ,
gLinkAdultWaistFarDL ,
gLinkChildWaistFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sPlayerRightHandBowSlingshotDLs2 [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultRightHandHoldingBowNearDL ,
gLinkChildRightHandHoldingSlingshotNearDL ,
gLinkAdultRightHandHoldingBowFarDL ,
gLinkChildRightHandHoldingSlingshotFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sPlayerRightHandOcarinaDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultRightHandHoldingOotNearDL ,
gLinkChildRightHandHoldingFairyOcarinaNearDL ,
gLinkAdultRightHandHoldingOotFarDL ,
gLinkChildRightHandHoldingFairyOcarinaFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sPlayerRightHandOotDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultRightHandHoldingOotNearDL ,
gLinkChildRightHandAndOotNearDL ,
gLinkAdultRightHandHoldingOotFarDL ,
gLinkChildRightHandHoldingOOTFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sPlayerRightHandHookshotDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultRightHandHoldingHookshotNearDL ,
gLinkChildRightHandNearDL ,
gLinkAdultRightHandHoldingHookshotNearDL , // The 'far' display list exists but is not used
gLinkChildRightHandFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sPlayerLeftHandHammerDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultLeftHandHoldingHammerNearDL ,
gLinkChildLeftHandNearDL ,
gLinkAdultLeftHandHoldingHammerFarDL ,
gLinkChildLeftHandFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * gPlayerLeftHandBoomerangDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultLeftHandNearDL ,
gLinkChildLeftFistAndBoomerangNearDL ,
gLinkAdultLeftHandFarDL ,
gLinkChildLeftFistAndBoomerangFarDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sPlayerLeftHandBottleDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultLeftHandOutNearDL ,
gLinkChildLeftHandUpNearDL ,
gLinkAdultLeftHandOutNearDL ,
gLinkChildLeftHandUpNearDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sFirstPersonLeftForearmDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultRightArmOutNearDL ,
NULL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sFirstPersonLeftHandDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultRightHandOutNearDL ,
NULL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sFirstPersonRightShoulderDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultRightShoulderNearDL ,
gLinkChildRightShoulderNearDL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sFirstPersonForearmDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultLeftArmOutNearDL ,
NULL ,
} ;
2023-09-15 14:39:46 -04:00
Gfx * sFirstPersonRightHandHoldingWeaponDLs [ ] = {
2022-03-21 21:51:23 -04:00
gLinkAdultRightHandHoldingBowFirstPersonDL ,
gLinkChildRightArmStretchedSlingshotDL ,
} ;
// Indexed by model types (left hand, right hand, sheath or waist)
2023-10-26 20:38:43 -04:00
Gfx * * sPlayerDListGroups [ PLAYER_MODELTYPE_MAX ] = {
gPlayerLeftHandOpenDLs , // PLAYER_MODELTYPE_LH_OPEN
gPlayerLeftHandClosedDLs , // PLAYER_MODELTYPE_LH_CLOSED
sPlayerLeftHandSwordDLs , // PLAYER_MODELTYPE_LH_SWORD
sPlayerLeftHandSwordDLs2 , // PLAYER_MODELTYPE_LH_SWORD_2
gPlayerLeftHandBgsDLs , // PLAYER_MODELTYPE_LH_BGS
sPlayerLeftHandHammerDLs , // PLAYER_MODELTYPE_LH_HAMMER
gPlayerLeftHandBoomerangDLs , // PLAYER_MODELTYPE_LH_BOOMERANG
sPlayerLeftHandBottleDLs , // PLAYER_MODELTYPE_LH_BOTTLE
sPlayerRightHandOpenDLs , // PLAYER_MODELTYPE_RH_OPEN
sPlayerRightHandClosedDLs , // PLAYER_MODELTYPE_RH_CLOSED
sPlayerRightHandShieldDLs , // PLAYER_MODELTYPE_RH_SHIELD
sPlayerRightHandBowSlingshotDLs , // PLAYER_MODELTYPE_RH_BOW_SLINGSHOT
sPlayerRightHandBowSlingshotDLs2 , // PLAYER_MODELTYPE_RH_BOW_SLINGSHOT_2
sPlayerRightHandOcarinaDLs , // PLAYER_MODELTYPE_RH_OCARINA
sPlayerRightHandOotDLs , // PLAYER_MODELTYPE_RH_OOT
sPlayerRightHandHookshotDLs , // PLAYER_MODELTYPE_RH_HOOKSHOT
sSwordAndSheathDLs , // PLAYER_MODELTYPE_SHEATH_16
sSheathDLs , // PLAYER_MODELTYPE_SHEATH_17
sSheathWithSwordDLs , // PLAYER_MODELTYPE_SHEATH_18
sSheathWithoutSwordDLs , // PLAYER_MODELTYPE_SHEATH_19
sPlayerWaistDLs , // PLAYER_MODELTYPE_WAIST
2022-03-21 21:51:23 -04:00
} ;
Gfx gCullBackDList [ ] = {
gsSPSetGeometryMode ( G_CULL_BACK ) ,
gsSPEndDisplayList ( ) ,
} ;
Gfx gCullFrontDList [ ] = {
gsSPSetGeometryMode ( G_CULL_FRONT ) ,
gsSPEndDisplayList ( ) ,
} ;
Vec3f * D_80160000 ;
s32 sDListsLodOffset ;
Vec3f sGetItemRefPos ;
2023-09-15 14:39:46 -04:00
s32 sLeftHandType ;
s32 sRightHandType ;
2022-03-21 21:51:23 -04:00
2022-11-06 03:24:34 -05:00
void Player_SetBootData ( PlayState * play , Player * this ) {
2022-03-21 21:51:23 -04:00
s32 currentBoots ;
s16 * bootRegs ;
REG ( 27 ) = 2000 ;
REG ( 48 ) = 370 ;
currentBoots = this - > currentBoots ;
if ( currentBoots = = PLAYER_BOOTS_KOKIRI ) {
if ( ! LINK_IS_ADULT ) {
currentBoots = PLAYER_BOOTS_KOKIRI_CHILD ;
}
} else if ( currentBoots = = PLAYER_BOOTS_IRON ) {
if ( this - > stateFlags1 & 0x8000000 ) {
currentBoots = PLAYER_BOOTS_IRON_UNDERWATER ;
}
REG ( 27 ) = 500 ;
REG ( 48 ) = 100 ;
}
bootRegs = sBootData [ currentBoots ] ;
REG ( 19 ) = bootRegs [ 0 ] ;
REG ( 30 ) = bootRegs [ 1 ] ;
REG ( 32 ) = bootRegs [ 2 ] ;
REG ( 34 ) = bootRegs [ 3 ] ;
REG ( 35 ) = bootRegs [ 4 ] ;
REG ( 36 ) = bootRegs [ 5 ] ;
REG ( 37 ) = bootRegs [ 6 ] ;
REG ( 38 ) = bootRegs [ 7 ] ;
REG ( 43 ) = bootRegs [ 8 ] ;
REG ( 45 ) = bootRegs [ 9 ] ;
REG ( 68 ) = bootRegs [ 10 ] ;
REG ( 69 ) = bootRegs [ 11 ] ;
IREG ( 66 ) = bootRegs [ 12 ] ;
IREG ( 67 ) = bootRegs [ 13 ] ;
IREG ( 68 ) = bootRegs [ 14 ] ;
IREG ( 69 ) = bootRegs [ 15 ] ;
MREG ( 95 ) = bootRegs [ 16 ] ;
2022-11-06 03:24:34 -05:00
if ( play - > roomCtx . curRoom . behaviorType1 = = ROOM_BEHAVIOR_TYPE1_2 ) {
2022-03-21 21:51:23 -04:00
REG ( 45 ) = 500 ;
}
}
2023-04-27 19:20:41 -04:00
// Custom method used to determine if we're using a custom model for link
uint8_t Player_IsCustomLinkModel ( ) {
2023-06-03 15:27:45 -04:00
return ( LINK_IS_ADULT & & ResourceGetIsCustomByName ( gLinkAdultSkel ) ) | |
( LINK_IS_CHILD & & ResourceGetIsCustomByName ( gLinkChildSkel ) ) ;
2023-04-27 19:20:41 -04:00
}
2022-11-06 03:24:34 -05:00
s32 Player_InBlockingCsMode ( PlayState * play , Player * this ) {
return ( this - > stateFlags1 & 0x20000080 ) | | ( this - > csMode ! = 0 ) | | ( play - > sceneLoadFlag = = 0x14 ) | |
2022-03-21 21:51:23 -04:00
( this - > stateFlags1 & 1 ) | | ( this - > stateFlags3 & 0x80 ) | |
2023-10-19 19:13:33 -04:00
( ( gSaveContext . magicState ! = MAGIC_STATE_IDLE ) & & ( Player_ActionToMagicSpell ( this , this - > itemAction ) > = 0 ) ) ;
2022-03-21 21:51:23 -04:00
}
2022-11-06 03:24:34 -05:00
s32 Player_InCsMode ( PlayState * play ) {
Player * this = GET_PLAYER ( play ) ;
2022-03-21 21:51:23 -04:00
2022-11-06 03:24:34 -05:00
return Player_InBlockingCsMode ( play , this ) | | ( this - > unk_6AD = = 4 ) ;
2022-03-21 21:51:23 -04:00
}
s32 func_8008E9C4 ( Player * this ) {
return ( this - > stateFlags1 & 0x10 ) ;
}
s32 Player_IsChildWithHylianShield ( Player * this ) {
return gSaveContext . linkAge ! = 0 & & ( this - > currentShield = = PLAYER_SHIELD_HYLIAN ) ;
}
s32 Player_ActionToModelGroup ( Player * this , s32 actionParam ) {
s32 modelGroup = sActionModelGroups [ actionParam ] ;
2023-10-26 20:38:43 -04:00
if ( ( modelGroup = = PLAYER_MODELGROUP_SWORD ) & & Player_IsChildWithHylianShield ( this ) ) {
// child, using kokiri sword with hylian shield equipped
return PLAYER_MODELGROUP_CHILD_HYLIAN_SHIELD ;
2022-03-21 21:51:23 -04:00
} else {
return modelGroup ;
}
}
void Player_SetModelsForHoldingShield ( Player * this ) {
if ( ( this - > stateFlags1 & 0x400000 ) & &
2022-11-29 18:28:57 -05:00
( ( this - > itemAction < 0 ) | | ( this - > itemAction = = this - > heldItemAction ) ) ) {
2023-09-15 14:39:46 -04:00
if ( ( CVarGetInteger ( " gShieldTwoHanded " , 0 ) & & ( this - > heldItemAction ! = PLAYER_IA_DEKU_STICK ) | |
2022-06-16 21:08:32 -04:00
! Player_HoldsTwoHandedWeapon ( this ) ) & & ! Player_IsChildWithHylianShield ( this ) ) {
2023-10-26 20:38:43 -04:00
this - > rightHandType = PLAYER_MODELTYPE_RH_SHIELD ;
this - > rightHandDLists = & sPlayerDListGroups [ PLAYER_MODELTYPE_RH_SHIELD ] [ gSaveContext . linkAge ] ;
if ( this - > sheathType = = PLAYER_MODELTYPE_SHEATH_18 ) {
this - > sheathType = PLAYER_MODELTYPE_SHEATH_16 ;
} else if ( this - > sheathType = = PLAYER_MODELTYPE_SHEATH_19 ) {
this - > sheathType = PLAYER_MODELTYPE_SHEATH_17 ;
2022-03-21 21:51:23 -04:00
}
2022-05-30 22:48:19 -04:00
this - > sheathDLists = & sPlayerDListGroups [ this - > sheathType ] [ gSaveContext . linkAge ] ;
2023-10-26 20:38:43 -04:00
this - > modelAnimType = PLAYER_ANIMTYPE_2 ;
2022-11-29 18:28:57 -05:00
this - > itemAction = - 1 ;
2022-03-21 21:51:23 -04:00
}
}
}
void Player_SetModels ( Player * this , s32 modelGroup ) {
2023-02-14 21:14:42 -05:00
// Left hand
2023-10-26 20:38:43 -04:00
this - > leftHandType = gPlayerModelTypes [ modelGroup ] [ PLAYER_MODELGROUPENTRY_LEFT_HAND ] ;
2023-02-14 21:14:42 -05:00
this - > leftHandDLists = & sPlayerDListGroups [ this - > leftHandType ] [ gSaveContext . linkAge ] ;
// Right hand
2023-10-26 20:38:43 -04:00
this - > rightHandType = gPlayerModelTypes [ modelGroup ] [ PLAYER_MODELGROUPENTRY_RIGHT_HAND ] ;
2023-02-14 21:14:42 -05:00
this - > rightHandDLists = & sPlayerDListGroups [ this - > rightHandType ] [ gSaveContext . linkAge ] ;
if ( CVarGetInteger ( " gBowSlingShotAmmoFix " , 0 ) & & this - > rightHandType = = 11 ) { // If holding Bow/Slingshot
this - > rightHandDLists = & sPlayerDListGroups [ this - > rightHandType ] [ Player_HoldsSlingshot ( this ) ] ;
}
// Sheath
2023-10-26 20:38:43 -04:00
this - > sheathType = gPlayerModelTypes [ modelGroup ] [ PLAYER_MODELGROUPENTRY_SHEATH ] ;
2023-02-14 21:14:42 -05:00
this - > sheathDLists = & sPlayerDListGroups [ this - > sheathType ] [ gSaveContext . linkAge ] ;
2022-03-21 21:51:23 -04:00
2023-02-14 21:14:42 -05:00
// Waist
2022-05-30 22:48:19 -04:00
this - > waistDLists = & sPlayerDListGroups [ gPlayerModelTypes [ modelGroup ] [ 4 ] ] [ gSaveContext . linkAge ] ;
2022-03-21 21:51:23 -04:00
Player_SetModelsForHoldingShield ( this ) ;
}
void Player_SetModelGroup ( Player * this , s32 modelGroup ) {
this - > modelGroup = modelGroup ;
2023-10-26 20:38:43 -04:00
if ( modelGroup = = PLAYER_MODELGROUP_CHILD_HYLIAN_SHIELD ) {
this - > modelAnimType = PLAYER_ANIMTYPE_0 ;
2022-03-21 21:51:23 -04:00
} else {
2023-10-26 20:38:43 -04:00
this - > modelAnimType = gPlayerModelTypes [ modelGroup ] [ PLAYER_MODELGROUPENTRY_ANIM ] ;
2022-03-21 21:51:23 -04:00
}
2023-10-26 20:38:43 -04:00
if ( ( this - > modelAnimType < PLAYER_ANIMTYPE_3 ) & & ( this - > currentShield = = PLAYER_SHIELD_NONE ) ) {
this - > modelAnimType = PLAYER_ANIMTYPE_0 ;
2022-03-21 21:51:23 -04:00
}
Player_SetModels ( this , modelGroup ) ;
}
void func_8008EC70 ( Player * this ) {
2022-11-29 18:28:57 -05:00
this - > itemAction = this - > heldItemAction ;
Player_SetModelGroup ( this , Player_ActionToModelGroup ( this , this - > heldItemAction ) ) ;
2022-03-21 21:51:23 -04:00
this - > unk_6AD = 0 ;
}
2022-11-06 03:24:34 -05:00
void Player_SetEquipmentData ( PlayState * play , Player * this ) {
2022-03-21 21:51:23 -04:00
if ( this - > csMode ! = 0x56 ) {
2023-10-30 11:56:36 -04:00
this - > currentShield = SHIELD_EQUIP_TO_PLAYER ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SHIELD ) ) ;
this - > currentTunic = TUNIC_EQUIP_TO_PLAYER ( CUR_EQUIP_VALUE ( EQUIP_TYPE_TUNIC ) ) ;
this - > currentBoots = BOOTS_EQUIP_TO_PLAYER ( CUR_EQUIP_VALUE ( EQUIP_TYPE_BOOTS ) ) ;
2022-11-29 18:28:57 -05:00
this - > currentSwordItemId = B_BTN_ITEM ;
Player_SetModelGroup ( this , Player_ActionToModelGroup ( this , this - > heldItemAction ) ) ;
2022-11-06 03:24:34 -05:00
Player_SetBootData ( play , this ) ;
2022-03-21 21:51:23 -04:00
}
}
2022-11-06 03:24:34 -05:00
void Player_UpdateBottleHeld ( PlayState * play , Player * this , s32 item , s32 actionParam ) {
Inventory_UpdateBottleItem ( play , item , this - > heldItemButton ) ;
2022-03-21 21:51:23 -04:00
if ( item ! = ITEM_BOTTLE ) {
this - > heldItemId = item ;
2022-11-29 18:28:57 -05:00
this - > heldItemAction = actionParam ;
2022-03-21 21:51:23 -04:00
}
2022-11-29 18:28:57 -05:00
this - > itemAction = actionParam ;
2022-03-21 21:51:23 -04:00
}
void func_8008EDF0 ( Player * this ) {
this - > unk_664 = NULL ;
this - > stateFlags2 & = ~ 0x2000 ;
}
void func_8008EE08 ( Player * this ) {
if ( ( this - > actor . bgCheckFlags & 1 ) | | ( this - > stateFlags1 & 0x8A00000 ) | |
( ! ( this - > stateFlags1 & 0xC0000 ) & & ( ( this - > actor . world . pos . y - this - > actor . floorHeight ) < 100.0f ) ) ) {
this - > stateFlags1 & = ~ 0x400F8000 ;
} else if ( ! ( this - > stateFlags1 & 0x2C0000 ) ) {
this - > stateFlags1 | = 0x80000 ;
}
func_8008EDF0 ( this ) ;
}
2022-11-06 03:24:34 -05:00
void func_8008EEAC ( PlayState * play , Actor * actor ) {
Player * this = GET_PLAYER ( play ) ;
2022-03-21 21:51:23 -04:00
func_8008EE08 ( this ) ;
this - > unk_664 = actor ;
this - > unk_684 = actor ;
this - > stateFlags1 | = 0x10000 ;
2022-11-06 03:24:34 -05:00
Camera_SetParam ( Play_GetCamera ( play , 0 ) , 8 , actor ) ;
Camera_ChangeMode ( Play_GetCamera ( play , 0 ) , 2 ) ;
2022-03-21 21:51:23 -04:00
}
2022-11-06 03:24:34 -05:00
s32 func_8008EF30 ( PlayState * play ) {
Player * this = GET_PLAYER ( play ) ;
2022-03-21 21:51:23 -04:00
return ( this - > stateFlags1 & 0x800000 ) ;
}
2022-11-06 03:24:34 -05:00
s32 func_8008EF44 ( PlayState * play , s32 ammo ) {
play - > shootingGalleryStatus = ammo + 1 ;
2022-03-21 21:51:23 -04:00
return 1 ;
}
2022-11-06 03:24:34 -05:00
s32 Player_IsBurningStickInRange ( PlayState * play , Vec3f * pos , f32 xzRange , f32 yRange ) {
Player * this = GET_PLAYER ( play ) ;
2022-03-21 21:51:23 -04:00
Vec3f diff ;
s32 pad ;
2023-09-15 14:39:46 -04:00
if ( ( this - > heldItemAction = = PLAYER_IA_DEKU_STICK ) & & ( this - > unk_860 ! = 0 ) ) {
2022-11-29 18:28:57 -05:00
Math_Vec3f_Diff ( & this - > meleeWeaponInfo [ 0 ] . tip , pos , & diff ) ;
2022-03-21 21:51:23 -04:00
return ( ( SQ ( diff . x ) + SQ ( diff . z ) ) < = SQ ( xzRange ) ) & & ( 0.0f < = diff . y ) & & ( diff . y < = yRange ) ;
} else {
return false ;
}
}
s32 Player_GetStrength ( void ) {
s32 strengthUpgrade = CUR_UPG_VALUE ( UPG_STRENGTH ) ;
2023-01-17 00:17:49 -05:00
if ( CVarGetInteger ( " gTimelessEquipment " , 0 ) | | LINK_IS_ADULT ) {
2022-03-21 21:51:23 -04:00
return strengthUpgrade ;
} else if ( strengthUpgrade ! = 0 ) {
return PLAYER_STR_BRACELET ;
} else {
return PLAYER_STR_NONE ;
}
}
2022-11-06 03:24:34 -05:00
u8 Player_GetMask ( PlayState * play ) {
Player * this = GET_PLAYER ( play ) ;
2022-03-21 21:51:23 -04:00
return this - > currentMask ;
}
2022-11-06 03:24:34 -05:00
Player * Player_UnsetMask ( PlayState * play ) {
Player * this = GET_PLAYER ( play ) ;
2022-03-21 21:51:23 -04:00
this - > currentMask = PLAYER_MASK_NONE ;
return this ;
}
2022-11-06 03:24:34 -05:00
s32 Player_HasMirrorShieldEquipped ( PlayState * play ) {
Player * this = GET_PLAYER ( play ) ;
2022-03-21 21:51:23 -04:00
return ( this - > currentShield = = PLAYER_SHIELD_MIRROR ) ;
}
2022-11-06 03:24:34 -05:00
s32 Player_HasMirrorShieldSetToDraw ( PlayState * play ) {
Player * this = GET_PLAYER ( play ) ;
2022-03-21 21:51:23 -04:00
2023-10-26 20:38:43 -04:00
return ( this - > rightHandType = = PLAYER_MODELTYPE_RH_SHIELD ) & & ( this - > currentShield = = PLAYER_SHIELD_MIRROR ) ;
2022-03-21 21:51:23 -04:00
}
s32 Player_ActionToMagicSpell ( Player * this , s32 actionParam ) {
2022-11-29 18:28:57 -05:00
s32 magicSpell = actionParam - PLAYER_IA_MAGIC_SPELL_15 ;
2022-03-21 21:51:23 -04:00
if ( ( magicSpell > = 0 ) & & ( magicSpell < 6 ) ) {
return magicSpell ;
} else {
return - 1 ;
}
}
s32 Player_HoldsHookshot ( Player * this ) {
2022-11-29 18:28:57 -05:00
return ( this - > heldItemAction = = PLAYER_IA_HOOKSHOT ) | | ( this - > heldItemAction = = PLAYER_IA_LONGSHOT ) ;
2022-03-21 21:51:23 -04:00
}
2023-02-14 21:14:42 -05:00
s32 Player_HoldsBow ( Player * this ) {
switch ( this - > heldItemAction ) {
case PLAYER_IA_BOW :
case PLAYER_IA_BOW_FIRE :
case PLAYER_IA_BOW_ICE :
case PLAYER_IA_BOW_LIGHT :
return true ;
default :
return false ;
}
}
s32 Player_HoldsSlingshot ( Player * this ) {
return this - > heldItemAction = = PLAYER_IA_SLINGSHOT ;
}
2022-03-21 21:51:23 -04:00
s32 func_8008F128 ( Player * this ) {
return Player_HoldsHookshot ( this ) & & ( this - > heldActor = = NULL ) ;
}
2023-09-15 14:39:46 -04:00
s32 Player_ActionToMeleeWeapon ( s32 actionParam ) {
2022-11-29 18:28:57 -05:00
s32 sword = actionParam - PLAYER_IA_FISHING_POLE ;
2022-03-21 21:51:23 -04:00
if ( ( sword > 0 ) & & ( sword < 6 ) ) {
return sword ;
} else {
return 0 ;
}
}
2023-09-15 14:39:46 -04:00
s32 Player_GetMeleeWeaponHeld ( Player * this ) {
return Player_ActionToMeleeWeapon ( this - > heldItemAction ) ;
2022-03-21 21:51:23 -04:00
}
s32 Player_HoldsTwoHandedWeapon ( Player * this ) {
2023-09-15 14:39:46 -04:00
if ( ( this - > heldItemAction > = PLAYER_IA_SWORD_BIGGORON ) & & ( this - > heldItemAction < = PLAYER_IA_HAMMER ) ) {
2022-03-21 21:51:23 -04:00
return 1 ;
} else {
return 0 ;
}
}
s32 Player_HoldsBrokenKnife ( Player * this ) {
2023-09-15 14:39:46 -04:00
return ( this - > heldItemAction = = PLAYER_IA_SWORD_BIGGORON ) & & ( gSaveContext . swordHealth < = 0.0f ) ;
2022-03-21 21:51:23 -04:00
}
s32 Player_ActionToBottle ( Player * this , s32 actionParam ) {
2022-11-29 18:28:57 -05:00
s32 bottle = actionParam - PLAYER_IA_BOTTLE ;
2022-03-21 21:51:23 -04:00
if ( ( bottle > = 0 ) & & ( bottle < 13 ) ) {
return bottle ;
} else {
return - 1 ;
}
}
s32 Player_GetBottleHeld ( Player * this ) {
2022-11-29 18:28:57 -05:00
return Player_ActionToBottle ( this , this - > heldItemAction ) ;
2022-03-21 21:51:23 -04:00
}
s32 Player_ActionToExplosive ( Player * this , s32 actionParam ) {
2022-11-29 18:28:57 -05:00
s32 explosive = actionParam - PLAYER_IA_BOMB ;
2022-03-21 21:51:23 -04:00
if ( ( explosive > = 0 ) & & ( explosive < 2 ) ) {
return explosive ;
} else {
return - 1 ;
}
}
s32 Player_GetExplosiveHeld ( Player * this ) {
2022-11-29 18:28:57 -05:00
return Player_ActionToExplosive ( this , this - > heldItemAction ) ;
2022-03-21 21:51:23 -04:00
}
s32 func_8008F2BC ( Player * this , s32 actionParam ) {
s32 sword = 0 ;
2022-11-29 18:28:57 -05:00
if ( actionParam ! = PLAYER_IA_LAST_USED ) {
sword = actionParam - PLAYER_IA_SWORD_MASTER ;
2022-03-21 21:51:23 -04:00
if ( ( sword < 0 ) | | ( sword > = 3 ) ) {
goto return_neg ;
}
}
return sword ;
return_neg :
return - 1 ;
}
2023-09-15 14:39:46 -04:00
s32 Player_GetEnvironmentalHazard ( PlayState * play ) {
2022-11-06 03:24:34 -05:00
Player * this = GET_PLAYER ( play ) ;
2022-03-21 21:51:23 -04:00
TextTriggerEntry * triggerEntry ;
s32 var ;
2022-11-06 03:24:34 -05:00
if ( play - > roomCtx . curRoom . behaviorType2 = = ROOM_BEHAVIOR_TYPE2_3 ) { // Room is hot
2022-03-21 21:51:23 -04:00
var = 0 ;
} else if ( ( this - > unk_840 > 80 ) & &
( ( this - > currentBoots = = PLAYER_BOOTS_IRON ) | | ( this - > unk_840 > = 300 ) ) ) { // Deep underwater
var = ( ( this - > currentBoots = = PLAYER_BOOTS_IRON ) & & ( this - > actor . bgCheckFlags & 1 ) ) ? 1 : 3 ;
} else if ( this - > stateFlags1 & 0x8000000 ) { // Swimming
var = 2 ;
} else {
return 0 ;
}
// Trigger general textboxes under certain conditions, like "It's so hot in here!"
2022-11-06 03:24:34 -05:00
if ( ! Player_InCsMode ( play ) ) {
2022-03-21 21:51:23 -04:00
triggerEntry = & sTextTriggers [ var ] ;
if ( ( triggerEntry - > flag ! = 0 ) & & ! ( gSaveContext . textTriggerFlags & triggerEntry - > flag ) & &
2023-04-21 16:05:38 -04:00
( ( ( var = = 0 ) & & ( this - > currentTunic ! = PLAYER_TUNIC_GORON & & CVarGetInteger ( " gSuperTunic " , 0 ) = = 0 & & CVarGetInteger ( " gDisableTunicWarningText " , 0 ) = = 0 ) ) | |
2022-03-21 21:51:23 -04:00
( ( ( var = = 1 ) | | ( var = = 3 ) ) & & ( this - > currentBoots = = PLAYER_BOOTS_IRON ) & &
2023-04-21 16:05:38 -04:00
( this - > currentTunic ! = PLAYER_TUNIC_ZORA & & CVarGetInteger ( " gSuperTunic " , 0 ) = = 0 & & CVarGetInteger ( " gDisableTunicWarningText " , 0 ) = = 0 ) ) ) ) {
2022-11-06 03:24:34 -05:00
Message_StartTextbox ( play , triggerEntry - > textId , NULL ) ;
2022-03-21 21:51:23 -04:00
gSaveContext . textTriggerFlags | = triggerEntry - > flag ;
}
}
return var + 1 ;
}
u8 sEyeMouthIndexes [ ] [ 2 ] = {
{ 0 , 0 } , { 1 , 0 } , { 2 , 0 } , { 0 , 0 } , { 1 , 0 } , { 2 , 0 } , { 4 , 0 } , { 5 , 1 } ,
{ 7 , 2 } , { 0 , 2 } , { 3 , 0 } , { 4 , 0 } , { 2 , 2 } , { 1 , 1 } , { 0 , 2 } , { 0 , 0 } ,
} ;
/**
* Link ' s eye and mouth textures are placed at the exact same place in adult and child Link ' s respective object files .
* This allows the array to only contain the symbols for one file and have it apply to both . This is a problem for
* shiftability , and changes will need to be made in the code to account for this in a modding scenario . The symbols
* from adult Link ' s object are used here .
*/
2022-05-11 13:18:24 -04:00
# if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__)
2022-03-21 21:51:23 -04:00
//TODO: Formatting
void * sEyeTextures [ 2 ] [ 8 ] = {
{ gLinkAdultEyesOpenTex , gLinkAdultEyesHalfTex , gLinkAdultEyesClosedfTex , gLinkAdultEyesRollLeftTex ,
gLinkAdultEyesRollRightTex , gLinkAdultEyesShockTex , gLinkAdultEyesUnk1Tex , gLinkAdultEyesUnk2Tex } ,
{ gLinkChildEyesOpenTex , gLinkChildEyesHalfTex , gLinkChildEyesClosedfTex , gLinkChildEyesRollLeftTex ,
gLinkChildEyesRollRightTex , gLinkChildEyesShockTex , gLinkChildEyesUnk1Tex , gLinkChildEyesUnk2Tex } ,
} ;
# else
void * sEyeTextures [ ] = {
gLinkAdultEyesOpenTex , gLinkAdultEyesHalfTex , gLinkAdultEyesClosedfTex , gLinkAdultEyesRollLeftTex ,
gLinkAdultEyesRollRightTex , gLinkAdultEyesShockTex , gLinkAdultEyesUnk1Tex , gLinkAdultEyesUnk2Tex ,
} ;
# endif
2022-05-11 13:18:24 -04:00
# if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__)
2022-03-21 21:51:23 -04:00
void * sMouthTextures [ 2 ] [ 4 ] = {
{
gLinkAdultMouth1Tex ,
gLinkAdultMouth2Tex ,
gLinkAdultMouth3Tex ,
gLinkAdultMouth4Tex ,
} ,
{
gLinkChildMouth1Tex ,
gLinkChildMouth2Tex ,
gLinkChildMouth3Tex ,
gLinkChildMouth4Tex ,
} ,
} ;
# else
void * sMouthTextures [ ] = {
gLinkAdultMouth1Tex ,
gLinkAdultMouth2Tex ,
gLinkAdultMouth3Tex ,
gLinkAdultMouth4Tex ,
} ;
# endif
Color_RGB8 sTunicColors [ ] = {
{ 30 , 105 , 27 } ,
{ 100 , 20 , 0 } ,
{ 0 , 60 , 100 } ,
} ;
Color_RGB8 sGauntletColors [ ] = {
{ 255 , 255 , 255 } ,
{ 254 , 207 , 15 } ,
} ;
Gfx * sBootDListGroups [ ] [ 2 ] = {
2023-10-26 20:38:43 -04:00
{ gLinkAdultLeftIronBootDL , gLinkAdultRightIronBootDL } , // PLAYER_BOOTS_IRON
{ gLinkAdultLeftHoverBootDL , gLinkAdultRightHoverBootDL } , // PLAYER_BOOTS_HOVER
2022-03-21 21:51:23 -04:00
} ;
2023-09-15 14:39:46 -04:00
void Player_DrawImpl ( PlayState * play , void * * skeleton , Vec3s * jointTable , s32 dListCount , s32 lod , s32 tunic ,
2022-03-21 21:51:23 -04:00
s32 boots , s32 face , OverrideLimbDrawOpa overrideLimbDraw , PostLimbDrawOpa postLimbDraw ,
void * data ) {
Color_RGB8 * color ;
s32 eyeIndex = ( jointTable [ 22 ] . x & 0xF ) - 1 ;
s32 mouthIndex = ( jointTable [ 22 ] . x > > 4 ) - 1 ;
2022-11-06 03:24:34 -05:00
OPEN_DISPS ( play - > state . gfxCtx ) ;
2022-03-21 21:51:23 -04:00
if ( eyeIndex < 0 ) {
eyeIndex = sEyeMouthIndexes [ face ] [ 0 ] ;
}
if ( eyeIndex > 7 )
eyeIndex = 7 ;
2022-05-11 13:18:24 -04:00
# if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__)
2022-03-21 21:51:23 -04:00
gSPSegment ( POLY_OPA_DISP + + , 0x08 , SEGMENTED_TO_VIRTUAL ( sEyeTextures [ gSaveContext . linkAge ] [ eyeIndex ] ) ) ;
# else
gSPSegment ( POLY_OPA_DISP + + , 0x08 , SEGMENTED_TO_VIRTUAL ( sEyeTextures [ eyeIndex ] ) ) ;
# endif
if ( mouthIndex < 0 ) {
mouthIndex = sEyeMouthIndexes [ face ] [ 1 ] ;
}
if ( mouthIndex > 3 )
mouthIndex = 3 ;
2022-05-11 13:18:24 -04:00
# if defined(MODDING) || defined(_MSC_VER) || defined(__GNUC__)
2022-03-21 21:51:23 -04:00
gSPSegment ( POLY_OPA_DISP + + , 0x09 , SEGMENTED_TO_VIRTUAL ( sMouthTextures [ gSaveContext . linkAge ] [ mouthIndex ] ) ) ;
# else
gSPSegment ( POLY_OPA_DISP + + , 0x09 , SEGMENTED_TO_VIRTUAL ( sMouthTextures [ eyeIndex ] ) ) ;
# endif
2022-05-29 12:57:09 -04:00
2022-05-11 15:10:44 -04:00
Color_RGB8 sTemp ;
2022-12-08 23:24:39 -05:00
color = & sTunicColors [ tunic ] ;
2023-01-17 00:17:49 -05:00
if ( tunic = = PLAYER_TUNIC_KOKIRI & & CVarGetInteger ( " gCosmetics.Link_KokiriTunic.Changed " , 0 ) ) {
sTemp = CVarGetColor24 ( " gCosmetics.Link_KokiriTunic.Value " , sTunicColors [ PLAYER_TUNIC_KOKIRI ] ) ;
2022-12-08 23:24:39 -05:00
color = & sTemp ;
2023-01-17 00:17:49 -05:00
} else if ( tunic = = PLAYER_TUNIC_GORON & & CVarGetInteger ( " gCosmetics.Link_GoronTunic.Changed " , 0 ) ) {
sTemp = CVarGetColor24 ( " gCosmetics.Link_GoronTunic.Value " , sTunicColors [ PLAYER_TUNIC_GORON ] ) ;
2022-12-08 23:24:39 -05:00
color = & sTemp ;
2023-01-17 00:17:49 -05:00
} else if ( tunic = = PLAYER_TUNIC_ZORA & & CVarGetInteger ( " gCosmetics.Link_ZoraTunic.Changed " , 0 ) ) {
sTemp = CVarGetColor24 ( " gCosmetics.Link_ZoraTunic.Value " , sTunicColors [ PLAYER_TUNIC_ZORA ] ) ;
2022-12-08 23:24:39 -05:00
color = & sTemp ;
2022-04-26 18:33:18 -04:00
}
2022-05-29 12:57:09 -04:00
2022-03-21 21:51:23 -04:00
gDPSetEnvColor ( POLY_OPA_DISP + + , color - > r , color - > g , color - > b , 0 ) ;
2023-04-27 19:20:41 -04:00
// If we have a custom link model, always use the most detailed LOD
if ( Player_IsCustomLinkModel ( ) ) {
lod = 0 ;
}
2022-03-21 21:51:23 -04:00
sDListsLodOffset = lod * 2 ;
2022-11-06 03:24:34 -05:00
SkelAnime_DrawFlexLod ( play , skeleton , jointTable , dListCount , overrideLimbDraw , postLimbDraw , data , lod ) ;
2022-03-21 21:51:23 -04:00
2023-09-15 14:39:46 -04:00
if ( ( ( CVarGetInteger ( " gFPSGauntlets " , 0 ) & & LINK_IS_ADULT ) | | ( overrideLimbDraw ! = Player_OverrideLimbDrawGameplayFirstPerson ) ) & &
( overrideLimbDraw ! = Player_OverrideLimbDrawGameplayCrawling ) & &
2023-06-01 21:38:43 -04:00
( gSaveContext . gameMode ! = 3 ) ) {
2022-03-21 21:51:23 -04:00
if ( LINK_IS_ADULT ) {
s32 strengthUpgrade = CUR_UPG_VALUE ( UPG_STRENGTH ) ;
if ( strengthUpgrade > = 2 ) { // silver or gold gauntlets
gDPPipeSync ( POLY_OPA_DISP + + ) ;
2022-12-08 23:24:39 -05:00
color = & sGauntletColors [ strengthUpgrade - 2 ] ;
2023-01-17 00:17:49 -05:00
if ( strengthUpgrade = = PLAYER_STR_SILVER_G & & CVarGetInteger ( " gCosmetics.Gloves_SilverGauntlets.Changed " , 0 ) ) {
sTemp = CVarGetColor24 ( " gCosmetics.Gloves_SilverGauntlets.Value " , sGauntletColors [ PLAYER_STR_SILVER_G - 2 ] ) ;
2022-12-08 23:24:39 -05:00
color = & sTemp ;
2023-01-17 00:17:49 -05:00
} else if ( strengthUpgrade = = PLAYER_STR_GOLD_G & & CVarGetInteger ( " gCosmetics.Gloves_GoldenGauntlets.Changed " , 0 ) ) {
sTemp = CVarGetColor24 ( " gCosmetics.Gloves_GoldenGauntlets.Value " , sGauntletColors [ PLAYER_STR_GOLD_G - 2 ] ) ;
2022-12-08 23:24:39 -05:00
color = & sTemp ;
2022-10-03 05:15:19 -04:00
}
2022-03-21 21:51:23 -04:00
gDPSetEnvColor ( POLY_OPA_DISP + + , color - > r , color - > g , color - > b , 0 ) ;
gSPDisplayList ( POLY_OPA_DISP + + , gLinkAdultLeftGauntletPlate1DL ) ;
gSPDisplayList ( POLY_OPA_DISP + + , gLinkAdultRightGauntletPlate1DL ) ;
gSPDisplayList ( POLY_OPA_DISP + + ,
2023-10-26 20:38:43 -04:00
( sLeftHandType = = PLAYER_MODELTYPE_LH_OPEN ) ? gLinkAdultLeftGauntletPlate2DL : gLinkAdultLeftGauntletPlate3DL ) ;
2022-03-21 21:51:23 -04:00
gSPDisplayList ( POLY_OPA_DISP + + ,
2023-10-26 20:38:43 -04:00
( sRightHandType = = PLAYER_MODELTYPE_RH_OPEN ) ? gLinkAdultRightGauntletPlate2DL : gLinkAdultRightGauntletPlate3DL ) ;
2022-03-21 21:51:23 -04:00
}
if ( boots ! = 0 ) {
Gfx * * bootDLists = sBootDListGroups [ boots - 1 ] ;
gSPDisplayList ( POLY_OPA_DISP + + , bootDLists [ 0 ] ) ;
gSPDisplayList ( POLY_OPA_DISP + + , bootDLists [ 1 ] ) ;
}
} else {
if ( Player_GetStrength ( ) > PLAYER_STR_NONE ) {
gSPDisplayList ( POLY_OPA_DISP + + , gLinkChildGoronBraceletDL ) ;
}
}
}
2022-11-06 03:24:34 -05:00
CLOSE_DISPS ( play - > state . gfxCtx ) ;
2022-03-21 21:51:23 -04:00
}
2023-09-15 14:39:46 -04:00
Vec3f sZeroVec = { 0.0f , 0.0f , 0.0f } ;
2022-03-21 21:51:23 -04:00
Vec3f D_80126038 [ ] = {
{ 1304.0f , 0.0f , 0.0f } ,
{ 695.0f , 0.0f , 0.0f } ,
} ;
f32 D_80126050 [ ] = { 1265.0f , 826.0f } ;
f32 D_80126058 [ ] = { SQ ( 13.04f ) , SQ ( 6.95f ) } ;
f32 D_80126060 [ ] = { 10.019104f , - 19.925102f } ;
f32 D_80126068 [ ] = { 5.0f , 3.0f } ;
Vec3f D_80126070 = { 0.0f , - 300.0f , 0.0f } ;
2022-11-06 03:24:34 -05:00
void func_8008F87C ( PlayState * play , Player * this , SkelAnime * skelAnime , Vec3f * pos , Vec3s * rot ,
2022-03-21 21:51:23 -04:00
s32 thighLimbIndex , s32 shinLimbIndex , s32 footLimbIndex ) {
Vec3f spA4 ;
Vec3f sp98 ;
Vec3f footprintPos ;
CollisionPoly * sp88 ;
s32 sp84 ;
f32 sp80 ;
f32 sp7C ;
f32 sp78 ;
f32 sp74 ;
f32 sp70 ;
f32 sp6C ;
f32 sp68 ;
f32 sp64 ;
f32 sp60 ;
f32 sp5C ;
f32 sp58 ;
f32 sp54 ;
f32 sp50 ;
s16 temp1 ;
s16 temp2 ;
s32 temp3 ;
if ( ( this - > actor . scale . y > = 0.0f ) & & ! ( this - > stateFlags1 & 0x80 ) & &
2022-11-29 18:28:57 -05:00
( Player_ActionToMagicSpell ( this , this - > itemAction ) < 0 ) ) {
2022-03-21 21:51:23 -04:00
s32 pad ;
2022-05-30 22:48:19 -04:00
sp7C = D_80126058 [ gSaveContext . linkAge ] ;
sp78 = D_80126060 [ gSaveContext . linkAge ] ;
sp74 = D_80126068 [ gSaveContext . linkAge ] - this - > unk_6C4 ;
2022-03-21 21:51:23 -04:00
Matrix_Push ( ) ;
Matrix_TranslateRotateZYX ( pos , rot ) ;
2023-09-15 14:39:46 -04:00
Matrix_MultVec3f ( & sZeroVec , & spA4 ) ;
2022-05-30 22:48:19 -04:00
Matrix_TranslateRotateZYX ( & D_80126038 [ gSaveContext . linkAge ] , & skelAnime - > jointTable [ shinLimbIndex ] ) ;
Matrix_Translate ( D_80126050 [ gSaveContext . linkAge ] , 0.0f , 0.0f , MTXMODE_APPLY ) ;
2023-09-15 14:39:46 -04:00
Matrix_MultVec3f ( & sZeroVec , & sp98 ) ;
2022-03-21 21:51:23 -04:00
Matrix_MultVec3f ( & D_80126070 , & footprintPos ) ;
Matrix_Pop ( ) ;
footprintPos . y + = 15.0f ;
2022-11-06 03:24:34 -05:00
sp80 = BgCheck_EntityRaycastFloor4 ( & play - > colCtx , & sp88 , & sp84 , & this - > actor , & footprintPos ) + sp74 ;
2022-03-21 21:51:23 -04:00
if ( sp98 . y < sp80 ) {
sp70 = sp98 . x - spA4 . x ;
sp6C = sp98 . y - spA4 . y ;
sp68 = sp98 . z - spA4 . z ;
sp64 = sqrtf ( SQ ( sp70 ) + SQ ( sp6C ) + SQ ( sp68 ) ) ;
sp60 = ( SQ ( sp64 ) + sp78 ) / ( 2.0f * sp64 ) ;
sp58 = sp7C - SQ ( sp60 ) ;
sp58 = ( sp7C < SQ ( sp60 ) ) ? 0.0f : sqrtf ( sp58 ) ;
sp54 = Math_FAtan2F ( sp58 , sp60 ) ;
sp6C = sp80 - spA4 . y ;
sp64 = sqrtf ( SQ ( sp70 ) + SQ ( sp6C ) + SQ ( sp68 ) ) ;
sp60 = ( SQ ( sp64 ) + sp78 ) / ( 2.0f * sp64 ) ;
sp5C = sp64 - sp60 ;
sp58 = sp7C - SQ ( sp60 ) ;
sp58 = ( sp7C < SQ ( sp60 ) ) ? 0.0f : sqrtf ( sp58 ) ;
sp50 = Math_FAtan2F ( sp58 , sp60 ) ;
temp1 = ( M_PI - ( Math_FAtan2F ( sp5C , sp58 ) + ( ( M_PI / 2 ) - sp50 ) ) ) * ( 0x8000 / M_PI ) ;
temp1 = temp1 - skelAnime - > jointTable [ shinLimbIndex ] . z ;
if ( ( s16 ) ( ABS ( skelAnime - > jointTable [ shinLimbIndex ] . x ) + ABS ( skelAnime - > jointTable [ shinLimbIndex ] . y ) ) < 0 ) {
temp1 + = 0x8000 ;
}
temp2 = ( sp50 - sp54 ) * ( 0x8000 / M_PI ) ;
rot - > z - = temp2 ;
skelAnime - > jointTable [ thighLimbIndex ] . z = skelAnime - > jointTable [ thighLimbIndex ] . z - temp2 ;
skelAnime - > jointTable [ shinLimbIndex ] . z = skelAnime - > jointTable [ shinLimbIndex ] . z + temp1 ;
skelAnime - > jointTable [ footLimbIndex ] . z = skelAnime - > jointTable [ footLimbIndex ] . z + temp2 - temp1 ;
2022-11-06 03:24:34 -05:00
temp3 = func_80041D4C ( & play - > colCtx , sp88 , sp84 ) ;
2022-03-21 21:51:23 -04:00
2022-11-06 03:24:34 -05:00
if ( ( temp3 > = 2 ) & & ( temp3 < 4 ) & & ! SurfaceType_IsWallDamage ( & play - > colCtx , sp88 , sp84 ) ) {
2022-03-21 21:51:23 -04:00
footprintPos . y = sp80 ;
2022-11-06 03:24:34 -05:00
EffectSsGFire_Spawn ( play , & footprintPos ) ;
2022-03-21 21:51:23 -04:00
}
}
}
}
2023-09-15 14:39:46 -04:00
s32 Player_OverrideLimbDrawGameplayCommon ( PlayState * play , s32 limbIndex , Gfx * * dList , Vec3f * pos , Vec3s * rot , void * thisx ) {
2022-03-21 21:51:23 -04:00
Player * this = ( Player * ) thisx ;
if ( limbIndex = = PLAYER_LIMB_ROOT ) {
2023-09-15 14:39:46 -04:00
sLeftHandType = this - > leftHandType ;
sRightHandType = this - > rightHandType ;
2022-11-29 18:28:57 -05:00
D_80160000 = & this - > meleeWeaponInfo [ 2 ] . base ;
2022-03-21 21:51:23 -04:00
if ( ! LINK_IS_ADULT ) {
if ( ! ( this - > skelAnime . moveFlags & 4 ) | | ( this - > skelAnime . moveFlags & 1 ) ) {
pos - > x * = 0.64f ;
pos - > z * = 0.64f ;
}
if ( ! ( this - > skelAnime . moveFlags & 4 ) | | ( this - > skelAnime . moveFlags & 2 ) ) {
pos - > y * = 0.64f ;
}
}
pos - > y - = this - > unk_6C4 ;
if ( this - > unk_6C2 ! = 0 ) {
Matrix_Translate ( pos - > x , ( ( Math_CosS ( this - > unk_6C2 ) - 1.0f ) * 200.0f ) + pos - > y , pos - > z , MTXMODE_APPLY ) ;
Matrix_RotateX ( this - > unk_6C2 * ( M_PI / 0x8000 ) , MTXMODE_APPLY ) ;
Matrix_RotateZYX ( rot - > x , rot - > y , rot - > z , MTXMODE_APPLY ) ;
pos - > x = pos - > y = pos - > z = 0.0f ;
rot - > x = rot - > y = rot - > z = 0 ;
}
} else {
if ( * dList ! = NULL ) {
D_80160000 + + ;
}
if ( limbIndex = = PLAYER_LIMB_HEAD ) {
2023-01-17 00:17:49 -05:00
if ( CVarGetInteger ( " gCosmetics.Link_HeadScale.Changed " , 0 ) ) {
f32 scale = CVarGetFloat ( " gCosmetics.Link_HeadScale.Value " , 1.0f ) ;
2022-12-08 23:24:39 -05:00
Matrix_Scale ( scale , scale , scale , MTXMODE_APPLY ) ;
if ( scale > 1.2f ) {
Matrix_Translate ( - ( ( LINK_IS_ADULT ? 320.0f : 200.0f ) * scale ) , 0.0f , 0.0f , MTXMODE_APPLY ) ;
} else if ( scale < 1.0f ) {
Matrix_Translate ( ( LINK_IS_ADULT ? 3600.0f : 2900.0f ) * ABS ( scale - 1.0f ) , 0.0f , 0.0f , MTXMODE_APPLY ) ;
}
}
2022-03-21 21:51:23 -04:00
rot - > x + = this - > unk_6BA ;
rot - > y - = this - > unk_6B8 ;
rot - > z + = this - > unk_6B6 ;
2022-12-08 23:24:39 -05:00
} else if ( limbIndex = = PLAYER_LIMB_L_HAND ) {
2023-01-17 00:17:49 -05:00
if ( CVarGetInteger ( " gCosmetics.Link_SwordScale.Changed " , 0 ) ) {
f32 scale = CVarGetFloat ( " gCosmetics.Link_SwordScale.Value " , 1.0f ) ;
2022-12-08 23:24:39 -05:00
Matrix_Scale ( scale , scale , scale , MTXMODE_APPLY ) ;
Matrix_Translate ( - ( ( LINK_IS_ADULT ? 320.0f : 200.0f ) * scale ) , 0.0f , 0.0f , MTXMODE_APPLY ) ;
}
2022-03-21 21:51:23 -04:00
} else if ( limbIndex = = PLAYER_LIMB_UPPER ) {
if ( this - > unk_6B0 ! = 0 ) {
Matrix_RotateZ ( 0x44C * ( M_PI / 0x8000 ) , MTXMODE_APPLY ) ;
Matrix_RotateY ( this - > unk_6B0 * ( M_PI / 0x8000 ) , MTXMODE_APPLY ) ;
}
if ( this - > unk_6BE ! = 0 ) {
Matrix_RotateY ( this - > unk_6BE * ( M_PI / 0x8000 ) , MTXMODE_APPLY ) ;
}
if ( this - > unk_6BC ! = 0 ) {
Matrix_RotateX ( this - > unk_6BC * ( M_PI / 0x8000 ) , MTXMODE_APPLY ) ;
}
if ( this - > unk_6C0 ! = 0 ) {
Matrix_RotateZ ( this - > unk_6C0 * ( M_PI / 0x8000 ) , MTXMODE_APPLY ) ;
}
} else if ( limbIndex = = PLAYER_LIMB_L_THIGH ) {
2022-11-06 03:24:34 -05:00
func_8008F87C ( play , this , & this - > skelAnime , pos , rot , PLAYER_LIMB_L_THIGH , PLAYER_LIMB_L_SHIN ,
2022-03-21 21:51:23 -04:00
PLAYER_LIMB_L_FOOT ) ;
} else if ( limbIndex = = PLAYER_LIMB_R_THIGH ) {
2022-11-06 03:24:34 -05:00
func_8008F87C ( play , this , & this - > skelAnime , pos , rot , PLAYER_LIMB_R_THIGH , PLAYER_LIMB_R_SHIN ,
2022-03-21 21:51:23 -04:00
PLAYER_LIMB_R_FOOT ) ;
return false ;
} else {
return false ;
}
}
return false ;
}
2023-09-15 14:39:46 -04:00
s32 Player_OverrideLimbDrawGameplayDefault ( PlayState * play , s32 limbIndex , Gfx * * dList , Vec3f * pos , Vec3s * rot , void * thisx ) {
2022-03-21 21:51:23 -04:00
Player * this = ( Player * ) thisx ;
2023-09-15 14:39:46 -04:00
if ( ! Player_OverrideLimbDrawGameplayCommon ( play , limbIndex , dList , pos , rot , thisx ) )
2023-04-27 19:20:41 -04:00
{
2022-03-21 21:51:23 -04:00
if ( limbIndex = = PLAYER_LIMB_L_HAND ) {
Gfx * * dLists = this - > leftHandDLists ;
2023-10-26 20:38:43 -04:00
if ( ( sLeftHandType = = PLAYER_MODELTYPE_LH_BGS ) & & ( gSaveContext . swordHealth < = 0.0f ) ) {
2022-03-21 21:51:23 -04:00
dLists + = 4 ;
2023-10-26 20:38:43 -04:00
} else if ( ( sLeftHandType = = PLAYER_MODELTYPE_LH_BOOMERANG ) & & ( this - > stateFlags1 & 0x2000000 ) ) {
2023-09-15 14:39:46 -04:00
dLists = & gPlayerLeftHandOpenDLs [ gSaveContext . linkAge ] ;
sLeftHandType = 0 ;
2023-10-26 20:38:43 -04:00
} else if ( ( this - > leftHandType = = PLAYER_MODELTYPE_LH_OPEN ) & & ( this - > actor . speedXZ > 2.0f ) & & ! ( this - > stateFlags1 & 0x8000000 ) ) {
2023-09-15 14:39:46 -04:00
dLists = & gPlayerLeftHandClosedDLs [ gSaveContext . linkAge ] ;
2023-10-26 20:38:43 -04:00
sLeftHandType = PLAYER_MODELTYPE_LH_CLOSED ;
2022-03-21 21:51:23 -04:00
}
* dList = ResourceMgr_LoadGfxByName ( dLists [ sDListsLodOffset ] ) ;
} else if ( limbIndex = = PLAYER_LIMB_R_HAND ) {
Gfx * * dLists = this - > rightHandDLists ;
2023-10-26 20:38:43 -04:00
if ( sRightHandType = = PLAYER_MODELTYPE_RH_SHIELD ) {
2022-03-21 21:51:23 -04:00
dLists + = this - > currentShield * 4 ;
2023-10-26 20:38:43 -04:00
} else if ( ( this - > rightHandType = = PLAYER_MODELTYPE_RH_OPEN ) & & ( this - > actor . speedXZ > 2.0f ) & & ! ( this - > stateFlags1 & 0x8000000 ) ) {
2023-09-15 14:39:46 -04:00
dLists = & sPlayerRightHandClosedDLs [ gSaveContext . linkAge ] ;
2023-10-26 20:38:43 -04:00
sRightHandType = PLAYER_MODELTYPE_RH_CLOSED ;
2022-03-21 21:51:23 -04:00
}
* dList = ResourceMgr_LoadGfxByName ( dLists [ sDListsLodOffset ] ) ;
} else if ( limbIndex = = PLAYER_LIMB_SHEATH ) {
Gfx * * dLists = this - > sheathDLists ;
2023-10-26 20:38:43 -04:00
if ( ( this - > sheathType = = PLAYER_MODELTYPE_SHEATH_18 ) | | ( this - > sheathType = = PLAYER_MODELTYPE_SHEATH_19 ) ) {
2022-03-21 21:51:23 -04:00
dLists + = this - > currentShield * 4 ;
if ( ! LINK_IS_ADULT & & ( this - > currentShield < PLAYER_SHIELD_HYLIAN ) & &
( gSaveContext . equips . buttonItems [ 0 ] ! = ITEM_SWORD_KOKIRI ) ) {
2023-10-26 20:38:43 -04:00
dLists + = PLAYER_SHIELD_MAX * 4 ;
2022-03-21 21:51:23 -04:00
}
2023-10-26 20:38:43 -04:00
} else if ( ! LINK_IS_ADULT & & ( ( this - > sheathType = = PLAYER_MODELTYPE_SHEATH_16 ) | | ( this - > sheathType = = PLAYER_MODELTYPE_SHEATH_17 ) ) & &
2022-03-21 21:51:23 -04:00
( gSaveContext . equips . buttonItems [ 0 ] ! = ITEM_SWORD_KOKIRI ) ) {
2023-10-26 20:38:43 -04:00
dLists = & sSheathWithSwordDLs [ PLAYER_SHIELD_MAX * 4 ] ;
2022-03-21 21:51:23 -04:00
}
if ( dLists [ sDListsLodOffset ] ! = NULL ) {
* dList = ResourceMgr_LoadGfxByName ( dLists [ sDListsLodOffset ] ) ;
} else {
* dList = NULL ;
}
} else if ( limbIndex = = PLAYER_LIMB_WAIST ) {
2023-04-27 19:20:41 -04:00
if ( ! Player_IsCustomLinkModel ( ) ) {
* dList = ResourceMgr_LoadGfxByName (
this - > waistDLists [ sDListsLodOffset ] ) ; // NOTE: This needs to be disabled when using custom
// characters - they're not going to have LODs anyways...
}
2022-03-21 21:51:23 -04:00
}
}
2023-01-25 18:13:33 -05:00
if ( GameInteractor_InvisibleLinkActive ( ) ) {
2022-09-27 22:41:17 -04:00
this - > actor . shape . shadowDraw = NULL ;
* dList = NULL ;
}
2022-03-21 21:51:23 -04:00
return false ;
}
2023-09-15 14:39:46 -04:00
s32 Player_OverrideLimbDrawGameplayFirstPerson ( PlayState * play , s32 limbIndex , Gfx * * dList , Vec3f * pos , Vec3s * rot , void * thisx ) {
2022-03-21 21:51:23 -04:00
Player * this = ( Player * ) thisx ;
2023-09-15 14:39:46 -04:00
if ( ! Player_OverrideLimbDrawGameplayCommon ( play , limbIndex , dList , pos , rot , thisx ) ) {
2022-03-21 21:51:23 -04:00
if ( this - > unk_6AD ! = 2 ) {
* dList = NULL ;
} else if ( limbIndex = = PLAYER_LIMB_L_FOREARM ) {
2023-09-15 14:39:46 -04:00
* dList = sFirstPersonLeftForearmDLs [ gSaveContext . linkAge ] ;
2022-03-21 21:51:23 -04:00
} else if ( limbIndex = = PLAYER_LIMB_L_HAND ) {
2023-02-14 21:14:42 -05:00
s32 handOutDlIndex = gSaveContext . linkAge ;
if ( CVarGetInteger ( " gBowSlingShotAmmoFix " , 0 ) & & LINK_IS_ADULT & & Player_HoldsSlingshot ( this ) ) {
handOutDlIndex = 1 ;
}
2023-09-15 14:39:46 -04:00
* dList = sFirstPersonLeftHandDLs [ handOutDlIndex ] ;
2022-03-21 21:51:23 -04:00
} else if ( limbIndex = = PLAYER_LIMB_R_SHOULDER ) {
2023-09-15 14:39:46 -04:00
* dList = sFirstPersonRightShoulderDLs [ gSaveContext . linkAge ] ;
2022-03-21 21:51:23 -04:00
} else if ( limbIndex = = PLAYER_LIMB_R_FOREARM ) {
2023-09-15 14:39:46 -04:00
* dList = sFirstPersonForearmDLs [ gSaveContext . linkAge ] ;
2022-03-21 21:51:23 -04:00
} else if ( limbIndex = = PLAYER_LIMB_R_HAND ) {
2023-02-14 21:14:42 -05:00
s32 firstPersonWeaponIndex = gSaveContext . linkAge ;
if ( CVarGetInteger ( " gBowSlingShotAmmoFix " , 0 ) ) {
if ( Player_HoldsBow ( this ) ) {
firstPersonWeaponIndex = 0 ;
} else if ( Player_HoldsSlingshot ( this ) ) {
firstPersonWeaponIndex = 1 ;
}
}
2022-03-21 21:51:23 -04:00
* dList = Player_HoldsHookshot ( this ) ? gLinkAdultRightHandHoldingHookshotFarDL
2023-09-15 14:39:46 -04:00
: sFirstPersonRightHandHoldingWeaponDLs [ firstPersonWeaponIndex ] ;
2022-03-21 21:51:23 -04:00
} else {
* dList = NULL ;
}
}
return false ;
}
2023-09-15 14:39:46 -04:00
s32 Player_OverrideLimbDrawGameplayCrawling ( PlayState * play , s32 limbIndex , Gfx * * dList , Vec3f * pos , Vec3s * rot , void * thisx ) {
if ( ! Player_OverrideLimbDrawGameplayCommon ( play , limbIndex , dList , pos , rot , thisx ) ) {
2022-03-21 21:51:23 -04:00
* dList = NULL ;
}
return false ;
}
2022-11-06 03:24:34 -05:00
u8 func_80090480 ( PlayState * play , ColliderQuad * collider , WeaponInfo * weaponInfo , Vec3f * newTip ,
2022-03-21 21:51:23 -04:00
Vec3f * newBase ) {
if ( weaponInfo - > active = = 0 ) {
if ( collider ! = NULL ) {
2022-11-06 03:24:34 -05:00
Collider_ResetQuadAT ( play , & collider - > base ) ;
2022-03-21 21:51:23 -04:00
}
Math_Vec3f_Copy ( & weaponInfo - > tip , newTip ) ;
Math_Vec3f_Copy ( & weaponInfo - > base , newBase ) ;
weaponInfo - > active = 1 ;
return 1 ;
} else if ( ( weaponInfo - > tip . x = = newTip - > x ) & & ( weaponInfo - > tip . y = = newTip - > y ) & &
( weaponInfo - > tip . z = = newTip - > z ) & & ( weaponInfo - > base . x = = newBase - > x ) & &
( weaponInfo - > base . y = = newBase - > y ) & & ( weaponInfo - > base . z = = newBase - > z ) ) {
if ( collider ! = NULL ) {
2022-11-06 03:24:34 -05:00
Collider_ResetQuadAT ( play , & collider - > base ) ;
2022-03-21 21:51:23 -04:00
}
return 0 ;
} else {
if ( collider ! = NULL ) {
Collider_SetQuadVertices ( collider , newBase , newTip , & weaponInfo - > base , & weaponInfo - > tip ) ;
2022-11-06 03:24:34 -05:00
CollisionCheck_SetAT ( play , & play - > colChkCtx , & collider - > base ) ;
2022-03-21 21:51:23 -04:00
}
Math_Vec3f_Copy ( & weaponInfo - > base , newBase ) ;
Math_Vec3f_Copy ( & weaponInfo - > tip , newTip ) ;
weaponInfo - > active = 1 ;
return 1 ;
}
}
2023-09-15 14:39:46 -04:00
void Player_UpdateShieldCollider ( PlayState * play , Player * this , ColliderQuad * collider , Vec3f * quadSrc ) {
2022-03-21 21:51:23 -04:00
static u8 shieldColTypes [ PLAYER_SHIELD_MAX ] = {
COLTYPE_METAL ,
COLTYPE_WOOD ,
COLTYPE_METAL ,
COLTYPE_METAL ,
} ;
if ( this - > stateFlags1 & 0x400000 ) {
Vec3f quadDest [ 4 ] ;
this - > shieldQuad . base . colType = shieldColTypes [ this - > currentShield ] ;
Matrix_MultVec3f ( & quadSrc [ 0 ] , & quadDest [ 0 ] ) ;
Matrix_MultVec3f ( & quadSrc [ 1 ] , & quadDest [ 1 ] ) ;
Matrix_MultVec3f ( & quadSrc [ 2 ] , & quadDest [ 2 ] ) ;
Matrix_MultVec3f ( & quadSrc [ 3 ] , & quadDest [ 3 ] ) ;
Collider_SetQuadVertices ( collider , & quadDest [ 0 ] , & quadDest [ 1 ] , & quadDest [ 2 ] , & quadDest [ 3 ] ) ;
2022-11-06 03:24:34 -05:00
CollisionCheck_SetAC ( play , & play - > colChkCtx , & collider - > base ) ;
CollisionCheck_SetAT ( play , & play - > colChkCtx , & collider - > base ) ;
2022-03-21 21:51:23 -04:00
}
}
Vec3f D_80126080 = { 5000.0f , 400.0f , 0.0f } ;
Vec3f D_8012608C = { 5000.0f , - 400.0f , 1000.0f } ;
Vec3f D_80126098 = { 5000.0f , 1400.0f , - 1000.0f } ;
Vec3f D_801260A4 [ 3 ] = {
{ 0.0f , 400.0f , 0.0f } ,
{ 0.0f , 1400.0f , - 1000.0f } ,
{ 0.0f , - 400.0f , 1000.0f } ,
} ;
2022-11-06 03:24:34 -05:00
void func_800906D4 ( PlayState * play , Player * this , Vec3f * newTipPos ) {
2022-03-21 21:51:23 -04:00
Vec3f newBasePos [ 3 ] ;
Matrix_MultVec3f ( & D_801260A4 [ 0 ] , & newBasePos [ 0 ] ) ;
Matrix_MultVec3f ( & D_801260A4 [ 1 ] , & newBasePos [ 1 ] ) ;
Matrix_MultVec3f ( & D_801260A4 [ 2 ] , & newBasePos [ 2 ] ) ;
2022-11-29 18:28:57 -05:00
if ( func_80090480 ( play , NULL , & this - > meleeWeaponInfo [ 0 ] , & newTipPos [ 0 ] , & newBasePos [ 0 ] ) & &
2022-03-21 21:51:23 -04:00
! ( this - > stateFlags1 & 0x400000 ) ) {
2022-11-29 18:28:57 -05:00
EffectBlure_AddVertex ( Effect_GetByIndex ( this - > meleeWeaponEffectIndex ) , & this - > meleeWeaponInfo [ 0 ] . tip ,
& this - > meleeWeaponInfo [ 0 ] . base ) ;
2022-03-21 21:51:23 -04:00
}
2023-09-15 14:39:46 -04:00
if ( ( this - > meleeWeaponState > 0 ) & & ( ( this - > meleeWeaponAnimation < 0x18 ) | | ( this - > stateFlags2 & 0x20000 ) ) ) {
2022-11-29 18:28:57 -05:00
func_80090480 ( play , & this - > meleeWeaponQuads [ 0 ] , & this - > meleeWeaponInfo [ 1 ] , & newTipPos [ 1 ] , & newBasePos [ 1 ] ) ;
func_80090480 ( play , & this - > meleeWeaponQuads [ 1 ] , & this - > meleeWeaponInfo [ 2 ] , & newTipPos [ 2 ] , & newBasePos [ 2 ] ) ;
2022-03-21 21:51:23 -04:00
}
}
2022-12-20 23:32:01 -05:00
void Player_DrawGetItemIceTrap ( PlayState * play , Player * this , Vec3f * refPos , s32 drawIdPlusOne , f32 height ) {
OPEN_DISPS ( play - > state . gfxCtx ) ;
2023-01-17 00:17:49 -05:00
if ( CVarGetInteger ( " gLetItSnow " , 0 ) ) {
2022-12-20 23:32:01 -05:00
Gfx_SetupDL_25Opa ( play - > state . gfxCtx ) ;
Matrix_Scale ( 0.2f , 0.2f , 0.2f , MTXMODE_APPLY ) ;
gSPMatrix ( POLY_OPA_DISP + + , MATRIX_NEWMTX ( play - > state . gfxCtx ) , G_MTX_MODELVIEW | G_MTX_LOAD ) ;
gDPSetGrayscaleColor ( POLY_OPA_DISP + + , 75 , 75 , 75 , 255 ) ;
gSPGrayscale ( POLY_OPA_DISP + + , true ) ;
gSPDisplayList ( POLY_OPA_DISP + + , ( Gfx * ) gSilverRockDL ) ;
gSPGrayscale ( POLY_OPA_DISP + + , false ) ;
} else {
if ( iceTrapScale < 0.01 ) {
iceTrapScale + = 0.001f ;
} else if ( iceTrapScale < 0.8f ) {
iceTrapScale + = 0.2f ;
}
gSPSegment ( POLY_XLU_DISP + + , 0x08 ,
Gfx_TwoTexScroll ( play - > state . gfxCtx , 0 , 0 , ( 0 - play - > gameplayFrames ) % 128 , 32 , 32 , 1 , 0 ,
( play - > gameplayFrames * - 2 ) % 128 , 32 , 32 ) ) ;
Matrix_Translate ( 0.0f , - 40.0f , 0.0f , MTXMODE_APPLY ) ;
Matrix_Scale ( iceTrapScale , iceTrapScale , iceTrapScale , 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 ) ;
// Reset matrix for the fake item model because we're animating the size of the ice block around it before this.
Matrix_Translate ( refPos - > x + ( 3.3f * Math_SinS ( this - > actor . shape . rot . y ) ) , refPos - > y + height ,
refPos - > z + ( ( 3.3f + ( IREG ( 90 ) / 10.0f ) ) * Math_CosS ( this - > actor . shape . rot . y ) ) , MTXMODE_NEW ) ;
Matrix_RotateZYX ( 0 , play - > gameplayFrames * 1000 , 0 , MTXMODE_APPLY ) ;
Matrix_Scale ( 0.2f , 0.2f , 0.2f , MTXMODE_APPLY ) ;
// Draw fake item model.
GetItem_Draw ( play , drawIdPlusOne - 1 ) ;
}
CLOSE_DISPS ( play - > state . gfxCtx ) ;
}
2022-11-06 03:24:34 -05:00
void Player_DrawGetItemImpl ( PlayState * play , Player * this , Vec3f * refPos , s32 drawIdPlusOne ) {
2022-03-21 21:51:23 -04:00
f32 height = ( this - > exchangeItemId ! = EXCH_ITEM_NONE ) ? 6.0f : 14.0f ;
2022-11-06 03:24:34 -05:00
OPEN_DISPS ( play - > state . gfxCtx ) ;
2022-03-21 21:51:23 -04:00
gSegments [ 6 ] = VIRTUAL_TO_PHYSICAL ( this - > giObjectSegment ) ;
gSPSegment ( POLY_OPA_DISP + + , 0x06 , this - > giObjectSegment ) ;
gSPSegment ( POLY_XLU_DISP + + , 0x06 , this - > giObjectSegment ) ;
Matrix_Translate ( refPos - > x + ( 3.3f * Math_SinS ( this - > actor . shape . rot . y ) ) , refPos - > y + height ,
refPos - > z + ( ( 3.3f + ( IREG ( 90 ) / 10.0f ) ) * Math_CosS ( this - > actor . shape . rot . y ) ) , MTXMODE_NEW ) ;
2022-11-06 03:24:34 -05:00
Matrix_RotateZYX ( 0 , play - > gameplayFrames * 1000 , 0 , MTXMODE_APPLY ) ;
2022-03-21 21:51:23 -04:00
Matrix_Scale ( 0.2f , 0.2f , 0.2f , MTXMODE_APPLY ) ;
2022-12-20 23:32:01 -05:00
if ( this - > getItemEntry . modIndex = = MOD_RANDOMIZER & & this - > getItemEntry . getItemId = = RG_ICE_TRAP ) {
Player_DrawGetItemIceTrap ( play , this , refPos , drawIdPlusOne , height ) ;
2023-09-26 09:45:37 -04:00
} else if ( this - > getItemEntry . modIndex = = MOD_RANDOMIZER & & this - > getItemEntry . getItemId = = RG_TRIFORCE_PIECE ) {
Randomizer_DrawTriforcePieceGI ( play , this - > getItemEntry ) ;
2022-12-20 23:32:01 -05:00
} else if ( this - > getItemEntry . drawFunc ! = NULL ) {
2022-12-08 23:24:39 -05:00
this - > getItemEntry . drawFunc ( play , & this - > getItemEntry ) ;
} else {
GetItem_Draw ( play , drawIdPlusOne - 1 ) ;
Randomizer v2 (#1065)
* Revert changes to GetItemFromGet
* Fixes Ganon's Boss Key shuffled while regular boss Keys aren't.
* Enum + combo box
* Add obtainability checks correctly
* combobox title rename + no number tracking
* Fix repeatable purchases and bottles rendering incorrectly
* Move shopsanity option in GUI
* Struct instead of ImVec + basic comportment for all case
* Attempt to fix odd build issue
* Cast randoGet for ganons boss key
* Remove redundancy in KD room
* Update logic Cvar names
* Fix Ganons Trials coming from old save files. Fixes #1365
* Fixes crash when entering Ganon's Castle lobby on linux.
* Makes `Item_Give` safe to use with a NULL globalCtx.
This should allow it's use for giving items to Link's Pocket
during rando save initialization.
* Converts Song from Impa to use `Item_Give`
* Adds more options for Link's starting item.
* Removes unneeded `GiveLinkItem` functions.
* and make it build
* bring back new rando dropdown
* gSaveContext access in GameMenuBar.cpp
* Implement Skip Scarecrow's Song
* Reimplement progressive Bombchus
* Rando-next: Deku Nut and Seed ammo gives a blue rupee
Fixes #1390
* Fixes Link starting with BGS
* Persist item tracker notes
* Adjust Hooks include
* Use SohImGui::RequestCvarSaveOnNextTick
* Fix issues from LUS refactor
* Fix for overriding deku scrub messages
* Fix mistake from merge
oops
* Restore checkboxes to enhancements menu
These got lost in the merge
* Update location access logic
Including MQ locations in Spirit and GC now
* Implement rando bombchu drops
* Missing break
* Simplify mudwall collision check
There was no need to have a second collider specifically for Ice Arrow hits
* Update settings.cpp
* Simplify mudwall collision check
* Restore checkboxes in menu
Accidentally lost these during merge
* Clean up bool
* Update logic Cvar name
* Fixed capacity on ammmo tracking
* Fix for beans obtainability
* Hook into file delete and clear notes
* Incorporate magic arrows in rando settings
* Update tooltip
To inform the player that they might have to reload the room if they're enabling this for the first time.
* Update tooltip
* Add line break in tooltip
* Tooltip wording + line break
* tweak on main logic
* All color logic for all types
* Fix: changes to please new LUS
* Ensure itemTrackerNotes vector is not fully empty
* Implement's Tycoon Wallet.
* Refactor DrawItemCount and Use EnhancementCombobox for tracker capacity options
* small tweaks and rename
* always display XX/YY when in ammo/capacity mode
* Move all merchant messages to be generated on file load
* added hovertext for the number display
* Swap german and french translations for shop messages
* Set key colors to be on by default
* Add another flag to skip mask shop
* Fix Sold Out bug
* Fix gerudo keys, add disabled checkbox
* tooltip line break
* Add trials required and merchant prices to save file instead of loading from active spoiler log
* Remove trialsRequired persisting in save manager
* Adds slotIndex to girla (shop item actor) and uses that for IdentifyShopItem.
* Fix issue when merchantPrices is empty
* Fix for a single zeroed merchantPrice entry
* Fix #1417
* Implements items selling out and fixes issues with purchasing some items.
* Fixes order of operations so Rupees will be spent.
* Fixes sold out items not getting overwritten by the randomized info.
* Clarify var names and comments
Also preserve chain platform cutscene in spirit based on Link's position
* Remove !=0 from cvar check
* Clarify var names and comments
* Rename randomizerMerchantPrices to merchantPrices
* Handle shop items in SaveManager
* Fix merge mistake
* Base whats in the bazaar shop on entranceIndex instead of age
* Tidy up chain platform cutscene check
* Fix merge error
Didn't mean to have Zhora changes in here yet
* Use 3drando item table for parsing spoiler names
* Use another nested method instead of one at the top level to fetch the table
* Add missing newline
* Remove log
* Respect custom draw functions
* Fix issues with rendering songs
* Fix localized item names for shopsanity
* Implements a larger array of Sprites for the Icon Hash.
* Uses the hash instead of seed for spoilerfile name and icons.
* Removes some unused functions and variables in `spoiler_log.cpp`
* Prevents leading 0s added to hash from being in file name
* Changes filename format to icon indexes separated by dashes
* Hopefully makes Jenkins happy
* Hopefully makes Jenkins happy
* [Rando] Child Gerudo Fortress 37th Heartpiece randomized
Fixes #1071
* Add descriptions to save editor flags editor, and added randomizer flags (#1386)
* Add descriptions to save editor flags editor, and added randomizer flags
* Hide randomizer flags when not on a randomizer save
* Move flag descriptions to header file
* Update soh/soh/Enhancements/debugger/debugSaveEditor.h
* Update soh/soh/Enhancements/debugger/debugSaveEditor.h
* Fix merge error
* crash on pause menu on linux (only in appimage)
Fixes #1437
* Applies fix to Song from Impa as well.
* Allow buying tunics as child when shopsanity is on
* Fix for custom draw methods overriding sold out sign
* Simplify logic around shopsanity and fix some issues
* Fix dungeon reward stone rotation and add particles
* Fix some issues with ice traps
* Fix adult wallet having its own max capacity
* Fix amount of keys given for BotW
* format
* Use EnGirlAShopItem enum instead of raw hex values
* [#1434] Renders non-warp songs more consistently with warp songs
* A few changes around merchant messages
* Various changes from PR feedback
* Rando: Junk Hint missing french translation
* Typo
* Fix free scrub being at 0 instead of TEXT_SCRUB_RANDOM
* Replace magic numbers in message handler
* Update soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c
Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
* Update soh/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c
Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
* Fix BGS softlock for shopsanity
* Support tycoon wallet on tracker
* Revert "Fix BGS softlock for shopsanity"
This reverts commit 5fdb961ea460fb9a035cf0bb6ae77bfeedc1de0f.
* [#1053] Resolves an issue with shop items and bombchu bowling where BGS would display two message boxes
* Implements some necessary plumbing and resolves several Ice Trap Softlocks.
Adds a way for an item entry to tell what type of check it came from (NPC vs Chest vs Freestanding, etc.)
Sets this value from chests and item00 actors.
Relocates pendingIceTraps to save context so it can persist through cutscenes and get stored on save init for Link's Pocket and Song from Impa.
Restructures pendingIceTraps into a counter rather than a true or false, so that we can be frozen multiple times in a row if applicable (atm that should only be at the start of a run if Link's Pocket and Song from Impa were both Ice Traps).
Adds a textbox for Ice Traps and a special case of holding up nothing in the get item process. This fixes all the cases where Ice Traps would softlock due to the actor giving the item expecting a closing textbox. After holding the item above his head Link increments the pendingIceTraps counter by one and sets whatever flag he has pending.
None of the above plumbing applies to Ice Traps from chests, those work exactly the same as before, as do freestanding item00 ice traps (thanks to the additional check for ITEM_FROM_FREESTANDING.
OoT and Ruto's Letter count as NPC's, so they get the FOWL text box and set a pending ice trap rather than immediately freezing, since Link weill be in the water. Link will get frozen the next time he touches land, which in the case of OoT is after the fade to white and right before the Song of Time check.
Fixes all the other softlocks I'm aware of, including Fishing, Bombchu Bowling, Skull Kid, and losing the second Gerudo Archery check.
* fix bgs check in player
* move bgs logic for tokensanity into MOD_NONE check
* set bgs flag before `Item_Give`ing
* move bgs flag into `MOD_NONE` check in girla
* use existing check in `z_player`
* Adds comment explaining the decision to default ITEM_FROM_NPC.
* Rename pendingIceTraps to pendingIceTrapCount
* Adds some RANDOTODO comments about cleaning up a couple things.
* Merge branch 'develop-zhora' into ztornn
* manually restore changes to `z_player.c`
* Fix after some ice trap prepwork from earlier
* Actual fix
* Woops
* More rupee names
* Actually fix it
* Add back comment
* Fix Skip Scarecrow Song
* Fix ruto's letter and LH sun stick rendering
* Also fixes it for treasure chest game
* Tweak: Rando French Wallet
* ADD: French Tycoon
* Hide dungeon items/notes by default
* [#1301] Fix issue with UI not restoring after getting an item from biggoron
* Update soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c
* Update soh/src/overlays/actors/ovl_En_Go2/z_en_go2.c
* Fix random crash that only affected one person for some reason
Co-authored-by: Garrett Cox <garrettjcox@gmail.com>
Co-authored-by: Christopher Leggett <chris@leggett.dev>
Co-authored-by: PurpleHato <linkvssangoku.jr@gmail.com>
Co-authored-by: Sarge-117 <adam_branston@outlook.com>
Co-authored-by: briaguya <briaguya@alice>
Co-authored-by: aMannus <mannusmenting@gmail.com>
Co-authored-by: lil David <1337lilDavid@gmail.com>
Co-authored-by: Sarge-117 <108380086+Sarge-117@users.noreply.github.com>
Co-authored-by: louist103 <35883445+louist103@users.noreply.github.com>
2022-09-21 00:50:22 -04:00
}
2022-03-21 21:51:23 -04:00
2022-11-06 03:24:34 -05:00
CLOSE_DISPS ( play - > state . gfxCtx ) ;
2022-03-21 21:51:23 -04:00
}
2022-11-06 03:24:34 -05:00
void Player_DrawGetItem ( PlayState * play , Player * this ) {
2022-03-21 21:51:23 -04:00
//if (!this->giObjectLoading || !osRecvMesg(&this->giObjectLoadQueue, NULL, OS_MESG_NOBLOCK)) // OTRTODO: Do something about osRecvMesg here...
{
this - > giObjectLoading = false ;
2022-11-06 03:24:34 -05:00
Player_DrawGetItemImpl ( play , this , & sGetItemRefPos , ABS ( this - > unk_862 ) ) ;
2022-03-21 21:51:23 -04:00
}
}
void func_80090A28 ( Player * this , Vec3f * vecs ) {
D_8012608C . x = D_80126080 . x ;
if ( this - > unk_845 > = 3 ) {
this - > unk_845 + = 1 ;
D_8012608C . x * = 1.0f + ( ( 9 - this - > unk_845 ) * 0.1f ) ;
}
D_8012608C . x + = 1200.0f ;
D_80126098 . x = D_8012608C . x ;
Matrix_MultVec3f ( & D_80126080 , & vecs [ 0 ] ) ;
Matrix_MultVec3f ( & D_8012608C , & vecs [ 1 ] ) ;
Matrix_MultVec3f ( & D_80126098 , & vecs [ 2 ] ) ;
}
2023-08-20 14:00:28 -04:00
void Player_DrawHookshotReticle ( PlayState * play , Player * this , f32 hookshotRange ) {
2022-03-21 21:51:23 -04:00
static Vec3f D_801260C8 = { - 500.0f , - 100.0f , 0.0f } ;
2023-08-20 14:00:28 -04:00
CollisionPoly * colPoly ;
2022-03-21 21:51:23 -04:00
s32 bgId ;
2023-08-20 14:00:28 -04:00
Vec3f hookshotStart ;
Vec3f hookshotEnd ;
Vec3f firstHit ;
2022-03-21 21:51:23 -04:00
Vec3f sp68 ;
f32 sp64 ;
D_801260C8 . z = 0.0f ;
2023-08-20 14:00:28 -04:00
Matrix_MultVec3f ( & D_801260C8 , & hookshotStart ) ;
D_801260C8 . z = hookshotRange ;
Matrix_MultVec3f ( & D_801260C8 , & hookshotEnd ) ;
2022-03-21 21:51:23 -04:00
2023-08-20 14:00:28 -04:00
if ( BgCheck_AnyLineTest3 ( & play - > colCtx , & hookshotStart , & hookshotEnd , & firstHit , & colPoly , 1 , 1 , 1 , 1 , & bgId ) ) {
2022-11-06 03:24:34 -05:00
OPEN_DISPS ( play - > state . gfxCtx ) ;
2022-03-21 21:51:23 -04:00
2022-11-29 18:29:36 -05:00
WORLD_OVERLAY_DISP = Gfx_SetupDL ( WORLD_OVERLAY_DISP , 0x07 ) ;
2022-03-21 21:51:23 -04:00
2023-08-20 14:00:28 -04:00
SkinMatrix_Vec3fMtxFMultXYZW ( & play - > viewProjectionMtxF , & firstHit , & sp68 , & sp64 ) ;
2022-03-21 21:51:23 -04:00
2023-08-20 14:00:28 -04:00
const f32 sp60 = ( sp64 < 200.0f ) ? 0.08f : ( sp64 / 200.0f ) * 0.08f ;
2022-03-21 21:51:23 -04:00
2023-08-20 14:00:28 -04:00
Matrix_Translate ( firstHit . x , firstHit . y , firstHit . z , MTXMODE_NEW ) ;
2022-03-21 21:51:23 -04:00
Matrix_Scale ( sp60 , sp60 , sp60 , MTXMODE_APPLY ) ;
2023-08-20 14:00:28 -04:00
gSPMatrix ( WORLD_OVERLAY_DISP + + , MATRIX_NEWMTX ( play - > state . gfxCtx ) , G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW ) ;
gSPMatrix ( WORLD_OVERLAY_DISP + + , SEG_ADDR ( 1 , 0 ) , G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW ) ;
gSPTexture ( WORLD_OVERLAY_DISP + + , 0xFFFF , 0xFFFF , 0 , G_TX_RENDERTILE , G_ON ) ;
2023-09-10 13:21:38 -04:00
gDPLoadTextureBlock ( WORLD_OVERLAY_DISP + + , gLinkAdultHookshotReticleTex , G_IM_FMT_I , G_IM_SIZ_8b , 64 , 64 , 0 ,
G_TX_NOMIRROR | G_TX_CLAMP , G_TX_NOMIRROR | G_TX_CLAMP , 6 , 6 , G_TX_NOLOD , G_TX_NOLOD ) ;
2023-08-20 14:00:28 -04:00
if ( SurfaceType_IsHookshotSurface ( & play - > colCtx , colPoly , bgId ) & & CVarGetInteger ( " gHookshotableReticle " , false ) ) {
const Color_RGBA8 defaultColor = { . r = 0 , . g = 255 , . b = 0 , . a = 255 } ;
const Color_RGBA8 color = CVarGetColor ( " gCosmetics.HookshotReticle_Target.Value " , defaultColor ) ;
gDPSetPrimColor ( WORLD_OVERLAY_DISP + + , 0 , 0 , color . r , color . g , color . b , color . a ) ;
} else {
const Color_RGBA8 defaultColor = { . r = 255 , . g = 0 , . b = 0 , . a = 255 } ;
const Color_RGBA8 color = CVarGetColor ( " gCosmetics.HookshotReticle_NonTarget.Value " , defaultColor ) ;
gDPSetPrimColor ( WORLD_OVERLAY_DISP + + , 0 , 0 , color . r , color . g , color . b , color . a ) ;
}
2023-10-13 19:14:18 -04:00
gSPVertex ( WORLD_OVERLAY_DISP + + , ( uintptr_t ) gLinkAdultHookshotReticleVtx , 3 , 0 ) ;
2023-08-20 14:00:28 -04:00
gSP1Triangle ( WORLD_OVERLAY_DISP + + , 0 , 1 , 2 , 0 ) ;
2022-03-21 21:51:23 -04:00
2022-11-06 03:24:34 -05:00
CLOSE_DISPS ( play - > state . gfxCtx ) ;
2022-03-21 21:51:23 -04:00
}
}
Vec3f D_801260D4 = { 1100.0f , - 700.0f , 0.0f } ;
2023-09-15 14:39:46 -04:00
f32 sMeleeWeaponLengths [ ] = {
2022-03-21 21:51:23 -04:00
0.0f , 4000.0f , 3000.0f , 5500.0f , 0.0f , 2500.0f ,
} ;
2022-09-20 22:49:31 -04:00
f32 sSwordTypes [ ] = {
0 , 5 , 4 , 6 , 0 , 8 ,
} ;
2022-03-21 21:51:23 -04:00
Gfx * sBottleDLists [ ] = { gLinkAdultBottleDL , gLinkChildBottleDL } ;
Color_RGB8 sBottleColors [ ] = {
{ 255 , 255 , 255 } , { 80 , 80 , 255 } , { 255 , 100 , 255 } , { 0 , 0 , 255 } , { 255 , 0 , 255 } ,
{ 255 , 0 , 255 } , { 200 , 200 , 100 } , { 255 , 0 , 0 } , { 0 , 0 , 255 } , { 0 , 255 , 0 } ,
{ 255 , 255 , 255 } , { 255 , 255 , 255 } , { 80 , 80 , 255 } ,
} ;
2023-09-15 14:39:46 -04:00
Vec3f sLeftHandArrowVec3 = { 398.0f , 1419.0f , 244.0f } ;
2022-03-21 21:51:23 -04:00
BowStringData sBowStringData [ ] = {
{ gLinkAdultBowStringDL , { 0.0f , - 360.4f , 0.0f } } , // bow
{ gLinkChildSlinghotStringDL , { 606.0f , 236.0f , 0.0f } } , // slingshot
} ;
2023-09-15 14:39:46 -04:00
Vec3f sRightHandLimbModelShieldQuadVertices [ ] = {
2022-03-21 21:51:23 -04:00
{ - 4500.0f , - 3000.0f , - 600.0f } ,
{ 1500.0f , - 3000.0f , - 600.0f } ,
{ - 4500.0f , 3000.0f , - 600.0f } ,
{ 1500.0f , 3000.0f , - 600.0f } ,
} ;
Vec3f D_80126184 = { 100.0f , 1500.0f , 0.0f } ;
Vec3f D_80126190 = { 100.0f , 1640.0f , 0.0f } ;
2023-09-15 14:39:46 -04:00
Vec3f sSheathLimbModelShieldQuadVertices [ ] = {
2022-03-21 21:51:23 -04:00
{ - 3000.0f , - 3000.0f , - 900.0f } ,
{ 3000.0f , - 3000.0f , - 900.0f } ,
{ - 3000.0f , 3000.0f , - 900.0f } ,
{ 3000.0f , 3000.0f , - 900.0f } ,
} ;
2023-09-15 14:39:46 -04:00
Vec3f sSheathLimbModelShieldOnBackPos = { 630.0f , 100.0f , - 30.0f } ;
Vec3s sSheathLimbModelShieldOnBackZyxRot = { 0 , 0 , 0x7FFF } ;
2022-03-21 21:51:23 -04:00
2023-09-15 14:39:46 -04:00
Vec3f sLeftRightFootLimbModelFootPos [ ] = {
2022-03-21 21:51:23 -04:00
{ 200.0f , 300.0f , 0.0f } ,
{ 200.0f , 200.0f , 0.0f } ,
} ;
2023-04-22 21:59:34 -04:00
// OTRTODO: Figure out why this value works/what this value should be
// This was originally obtained by working down from FLT_MAX until the math
// started working out properly
# define RETICLE_MAX 3.402823466e+12f
2023-09-15 14:39:46 -04:00
void Player_PostLimbDrawGameplay ( PlayState * play , s32 limbIndex , Gfx * * dList , Vec3s * rot , void * thisx ) {
2022-03-21 21:51:23 -04:00
Player * this = ( Player * ) thisx ;
if ( * dList ! = NULL ) {
2023-09-15 14:39:46 -04:00
Matrix_MultVec3f ( & sZeroVec , D_80160000 ) ;
2022-03-21 21:51:23 -04:00
}
if ( limbIndex = = PLAYER_LIMB_L_HAND ) {
MtxF sp14C ;
Actor * hookedActor ;
Math_Vec3f_Copy ( & this - > leftHandPos , D_80160000 ) ;
2023-09-15 14:39:46 -04:00
if ( this - > itemAction = = PLAYER_IA_DEKU_STICK ) {
2022-03-21 21:51:23 -04:00
Vec3f sp124 [ 3 ] ;
2022-11-06 03:24:34 -05:00
OPEN_DISPS ( play - > state . gfxCtx ) ;
2022-03-21 21:51:23 -04:00
if ( this - > actor . scale . y > = 0.0f ) {
D_80126080 . x = this - > unk_85C * 5000.0f ;
func_80090A28 ( this , sp124 ) ;
2023-09-15 14:39:46 -04:00
if ( this - > meleeWeaponState ! = 0 ) {
2022-12-08 23:24:39 -05:00
EffectBlure_ChangeType ( Effect_GetByIndex ( this - > meleeWeaponEffectIndex ) , 7 ) ; // stick sword type
2022-11-06 03:24:34 -05:00
func_800906D4 ( play , this , sp124 ) ;
2022-03-21 21:51:23 -04:00
} else {
2022-11-29 18:28:57 -05:00
Math_Vec3f_Copy ( & this - > meleeWeaponInfo [ 0 ] . tip , & sp124 [ 0 ] ) ;
2022-03-21 21:51:23 -04:00
}
}
Matrix_Translate ( - 428.26f , 267.2f , - 33.82f , MTXMODE_APPLY ) ;
Matrix_RotateZYX ( - 0x8000 , 0 , 0x4000 , MTXMODE_APPLY ) ;
Matrix_Scale ( 1.0f , this - > unk_85C , 1.0f , MTXMODE_APPLY ) ;
2022-11-06 03:24:34 -05:00
gSPMatrix ( POLY_OPA_DISP + + , MATRIX_NEWMTX ( play - > state . gfxCtx ) ,
2022-03-21 21:51:23 -04:00
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW ) ;
gSPDisplayList ( POLY_OPA_DISP + + , gLinkChildLinkDekuStickDL ) ;
2022-11-06 03:24:34 -05:00
CLOSE_DISPS ( play - > state . gfxCtx ) ;
2023-09-15 14:39:46 -04:00
} else if ( ( this - > actor . scale . y > = 0.0f ) & & ( this - > meleeWeaponState ! = 0 ) ) {
2022-03-21 21:51:23 -04:00
Vec3f spE4 [ 3 ] ;
if ( Player_HoldsBrokenKnife ( this ) ) {
D_80126080 . x = 1500.0f ;
} else {
2023-09-15 14:39:46 -04:00
D_80126080 . x = sMeleeWeaponLengths [ Player_GetMeleeWeaponHeld ( this ) ] ;
EffectBlure_ChangeType ( Effect_GetByIndex ( this - > meleeWeaponEffectIndex ) , sSwordTypes [ Player_GetMeleeWeaponHeld ( this ) ] ) ;
2022-03-21 21:51:23 -04:00
}
func_80090A28 ( this , spE4 ) ;
2022-11-06 03:24:34 -05:00
func_800906D4 ( play , this , spE4 ) ;
2023-10-26 20:38:43 -04:00
} else if ( ( * dList ! = NULL ) & & ( this - > leftHandType = = PLAYER_MODELTYPE_LH_BOTTLE ) ) {
2022-11-29 18:28:57 -05:00
Color_RGB8 * bottleColor = & sBottleColors [ Player_ActionToBottle ( this , this - > itemAction ) ] ;
2022-03-21 21:51:23 -04:00
2022-11-06 03:24:34 -05:00
OPEN_DISPS ( play - > state . gfxCtx ) ;
2022-03-21 21:51:23 -04:00
2022-11-06 03:24:34 -05:00
gSPMatrix ( POLY_XLU_DISP + + , MATRIX_NEWMTX ( play - > state . gfxCtx ) ,
2022-03-21 21:51:23 -04:00
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW ) ;
gDPSetEnvColor ( POLY_XLU_DISP + + , bottleColor - > r , bottleColor - > g , bottleColor - > b , 0 ) ;
2022-05-30 22:48:19 -04:00
gSPDisplayList ( POLY_XLU_DISP + + , sBottleDLists [ ( gSaveContext . linkAge ) ] ) ;
2022-03-21 21:51:23 -04:00
2022-11-06 03:24:34 -05:00
CLOSE_DISPS ( play - > state . gfxCtx ) ;
2022-03-21 21:51:23 -04:00
}
if ( this - > actor . scale . y > = 0.0f ) {
if ( ! Player_HoldsHookshot ( this ) & & ( ( hookedActor = this - > heldActor ) ! = NULL ) ) {
if ( this - > stateFlags1 & 0x200 ) {
2023-09-15 14:39:46 -04:00
Matrix_MultVec3f ( & sLeftHandArrowVec3 , & hookedActor - > world . pos ) ;
2022-03-21 21:51:23 -04:00
Matrix_RotateZYX ( 0x69E8 , - 0x5708 , 0x458E , MTXMODE_APPLY ) ;
Matrix_Get ( & sp14C ) ;
Matrix_MtxFToYXZRotS ( & sp14C , & hookedActor - > world . rot , 0 ) ;
hookedActor - > shape . rot = hookedActor - > world . rot ;
} else if ( this - > stateFlags1 & 0x800 ) {
Vec3s spB8 ;
Matrix_Get ( & sp14C ) ;
Matrix_MtxFToYXZRotS ( & sp14C , & spB8 , 0 ) ;
2023-05-30 15:05:04 -04:00
if ( hookedActor - > flags & ACTOR_FLAG_PILLAR_PICKUP ) {
2022-03-21 21:51:23 -04:00
hookedActor - > world . rot . x = hookedActor - > shape . rot . x = spB8 . x - this - > unk_3BC . x ;
} else {
hookedActor - > world . rot . y = hookedActor - > shape . rot . y = this - > actor . shape . rot . y + this - > unk_3BC . y ;
}
}
} else {
Matrix_Get ( & this - > mf_9E0 ) ;
Matrix_MtxFToYXZRotS ( & this - > mf_9E0 , & this - > unk_3BC , 0 ) ;
}
}
} else if ( limbIndex = = PLAYER_LIMB_R_HAND ) {
Actor * heldActor = this - > heldActor ;
2023-10-26 20:38:43 -04:00
if ( this - > rightHandType = = PLAYER_MODELTYPE_RH_FF ) {
2022-03-21 21:51:23 -04:00
Matrix_Get ( & this - > shieldMf ) ;
2023-10-26 20:38:43 -04:00
} else if ( ( this - > rightHandType = = PLAYER_MODELTYPE_RH_BOW_SLINGSHOT ) | | ( this - > rightHandType = = PLAYER_MODELTYPE_RH_BOW_SLINGSHOT_2 ) ) {
2023-02-14 21:14:42 -05:00
s32 stringModelToUse = gSaveContext . linkAge ;
if ( CVarGetInteger ( " gBowSlingShotAmmoFix " , 0 ) ) {
stringModelToUse = Player_HoldsSlingshot ( this ) ;
}
BowStringData * stringData = & sBowStringData [ stringModelToUse ] ;
2022-03-21 21:51:23 -04:00
2022-11-06 03:24:34 -05:00
OPEN_DISPS ( play - > state . gfxCtx ) ;
2022-03-21 21:51:23 -04:00
Matrix_Push ( ) ;
Matrix_Translate ( stringData - > pos . x , stringData - > pos . y , stringData - > pos . z , MTXMODE_APPLY ) ;
if ( ( this - > stateFlags1 & 0x200 ) & & ( this - > unk_860 > = 0 ) & & ( this - > unk_834 < = 10 ) ) {
Vec3f sp90 ;
f32 distXYZ ;
2023-09-15 14:39:46 -04:00
Matrix_MultVec3f ( & sZeroVec , & sp90 ) ;
2022-03-21 21:51:23 -04:00
distXYZ = Math_Vec3f_DistXYZ ( D_80160000 , & sp90 ) ;
this - > unk_858 = distXYZ - 3.0f ;
if ( distXYZ < 3.0f ) {
this - > unk_858 = 0.0f ;
} else {
this - > unk_858 * = 1.6f ;
if ( this - > unk_858 > 1.0f ) {
this - > unk_858 = 1.0f ;
}
}
this - > unk_85C = - 0.5f ;
}
Matrix_Scale ( 1.0f , this - > unk_858 , 1.0f , MTXMODE_APPLY ) ;
if ( ! LINK_IS_ADULT ) {
Matrix_RotateZ ( this - > unk_858 * - 0.2f , MTXMODE_APPLY ) ;
}
2022-11-06 03:24:34 -05:00
gSPMatrix ( POLY_XLU_DISP + + , MATRIX_NEWMTX ( play - > state . gfxCtx ) ,
2022-03-21 21:51:23 -04:00
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW ) ;
gSPDisplayList ( POLY_XLU_DISP + + , stringData - > dList ) ;
Matrix_Pop ( ) ;
2022-11-06 03:24:34 -05:00
CLOSE_DISPS ( play - > state . gfxCtx ) ;
2023-10-26 20:38:43 -04:00
} else if ( ( this - > actor . scale . y > = 0.0f ) & & ( this - > rightHandType = = PLAYER_MODELTYPE_RH_SHIELD ) ) {
2022-03-21 21:51:23 -04:00
Matrix_Get ( & this - > shieldMf ) ;
2023-09-15 14:39:46 -04:00
Player_UpdateShieldCollider ( play , this , & this - > shieldQuad , sRightHandLimbModelShieldQuadVertices ) ;
2022-03-21 21:51:23 -04:00
}
if ( this - > actor . scale . y > = 0.0f ) {
2022-11-29 18:28:57 -05:00
if ( ( this - > heldItemAction = = PLAYER_IA_HOOKSHOT ) | |
( this - > heldItemAction = = PLAYER_IA_LONGSHOT ) ) {
2022-03-21 21:51:23 -04:00
Matrix_MultVec3f ( & D_80126184 , & this - > unk_3C8 ) ;
if ( heldActor ! = NULL ) {
MtxF sp44 ;
s32 pad ;
Matrix_MultVec3f ( & D_80126190 , & heldActor - > world . pos ) ;
Matrix_RotateZYX ( 0 , - 0x4000 , - 0x4000 , MTXMODE_APPLY ) ;
Matrix_Get ( & sp44 ) ;
Matrix_MtxFToYXZRotS ( & sp44 , & heldActor - > world . rot , 0 ) ;
heldActor - > shape . rot = heldActor - > world . rot ;
if ( func_8002DD78 ( this ) ! = 0 ) {
Matrix_Translate ( 500.0f , 300.0f , 0.0f , MTXMODE_APPLY ) ;
Player_DrawHookshotReticle (
2023-01-23 17:28:50 -05:00
play , this , ( ( this - > heldItemAction = = PLAYER_IA_HOOKSHOT ) ? 38600.0f : 77600.0f ) * CVarGetFloat ( " gCheatHookshotReachMultiplier " , 1.0f ) ) ;
2022-03-21 21:51:23 -04:00
}
}
2023-04-22 21:59:34 -04:00
} else if ( CVarGetInteger ( " gBowReticle " , 0 ) & & (
( this - > heldItemAction = = PLAYER_IA_BOW_FIRE ) | |
( this - > heldItemAction = = PLAYER_IA_BOW_ICE ) | |
( this - > heldItemAction = = PLAYER_IA_BOW_LIGHT ) | |
( this - > heldItemAction = = PLAYER_IA_BOW ) | |
( this - > heldItemAction = = PLAYER_IA_SLINGSHOT ) ) ) {
if ( heldActor ! = NULL ) {
MtxF sp44 ;
s32 pad ;
Matrix_RotateZYX ( 0 , - 15216 , - 17496 , MTXMODE_APPLY ) ;
Matrix_Get ( & sp44 ) ;
if ( func_8002DD78 ( this ) ! = 0 ) {
Matrix_Translate ( 500.0f , 300.0f , 0.0f , MTXMODE_APPLY ) ;
Player_DrawHookshotReticle ( play , this , RETICLE_MAX ) ;
}
}
2022-03-21 21:51:23 -04:00
}
if ( ( this - > unk_862 ! = 0 ) | | ( ( func_8002DD6C ( this ) = = 0 ) & & ( heldActor ! = NULL ) ) ) {
if ( ! ( this - > stateFlags1 & 0x400 ) & & ( this - > unk_862 ! = 0 ) & & ( this - > exchangeItemId ! = EXCH_ITEM_NONE ) ) {
Math_Vec3f_Copy ( & sGetItemRefPos , & this - > leftHandPos ) ;
} else {
sGetItemRefPos . x = ( this - > bodyPartsPos [ 15 ] . x + this - > leftHandPos . x ) * 0.5f ;
sGetItemRefPos . y = ( this - > bodyPartsPos [ 15 ] . y + this - > leftHandPos . y ) * 0.5f ;
sGetItemRefPos . z = ( this - > bodyPartsPos [ 15 ] . z + this - > leftHandPos . z ) * 0.5f ;
}
if ( this - > unk_862 = = 0 ) {
Math_Vec3f_Copy ( & heldActor - > world . pos , & sGetItemRefPos ) ;
}
}
}
} else if ( this - > actor . scale . y > = 0.0f ) {
if ( limbIndex = = PLAYER_LIMB_SHEATH ) {
2023-10-26 20:38:43 -04:00
if ( ( this - > rightHandType ! = PLAYER_MODELTYPE_RH_SHIELD ) & & ( this - > rightHandType ! = PLAYER_MODELTYPE_RH_FF ) ) {
2022-03-21 21:51:23 -04:00
if ( Player_IsChildWithHylianShield ( this ) ) {
2023-09-15 14:39:46 -04:00
Player_UpdateShieldCollider ( play , this , & this - > shieldQuad , sSheathLimbModelShieldQuadVertices ) ;
2022-03-21 21:51:23 -04:00
}
2023-09-15 14:39:46 -04:00
Matrix_TranslateRotateZYX ( & sSheathLimbModelShieldOnBackPos , & sSheathLimbModelShieldOnBackZyxRot ) ;
2022-03-21 21:51:23 -04:00
Matrix_Get ( & this - > shieldMf ) ;
}
} else if ( limbIndex = = PLAYER_LIMB_HEAD ) {
Matrix_MultVec3f ( & D_801260D4 , & this - > actor . focus . pos ) ;
} else {
2023-09-15 14:39:46 -04:00
Vec3f * vec = & sLeftRightFootLimbModelFootPos [ ( gSaveContext . linkAge ) ] ;
2022-03-21 21:51:23 -04:00
Actor_SetFeetPos ( & this - > actor , limbIndex , PLAYER_LIMB_L_FOOT , vec , PLAYER_LIMB_R_FOOT , vec ) ;
}
}
}
2022-11-06 03:24:34 -05:00
u32 func_80091738 ( PlayState * play , u8 * segment , SkelAnime * skelAnime ) {
2022-05-30 22:48:19 -04:00
s16 linkObjectId = gLinkObjectIds [ gSaveContext . linkAge ] ;
2022-03-21 21:51:23 -04:00
size_t size ;
void * ptr ;
size = gObjectTable [ OBJECT_GAMEPLAY_KEEP ] . vromEnd - gObjectTable [ OBJECT_GAMEPLAY_KEEP ] . vromStart ;
ptr = segment + 0x3800 ;
2022-07-05 19:29:34 -04:00
DmaMgr_SendRequest1 ( ptr , gObjectTable [ OBJECT_GAMEPLAY_KEEP ] . vromStart , size , __FILE__ , __LINE__ ) ;
2022-03-21 21:51:23 -04:00
size = gObjectTable [ linkObjectId ] . vromEnd - gObjectTable [ linkObjectId ] . vromStart ;
ptr = segment + 0x8800 ;
2022-07-05 19:29:34 -04:00
DmaMgr_SendRequest1 ( ptr , gObjectTable [ linkObjectId ] . vromStart , size , __FILE__ , __LINE__ ) ;
2022-03-21 21:51:23 -04:00
ptr = ( void * ) ALIGN16 ( ( intptr_t ) ptr + size ) ;
gSegments [ 4 ] = VIRTUAL_TO_PHYSICAL ( segment + 0x3800 ) ;
gSegments [ 6 ] = VIRTUAL_TO_PHYSICAL ( segment + 0x8800 ) ;
2022-11-06 03:24:34 -05:00
SkelAnime_InitLink ( play , skelAnime , gPlayerSkelHeaders [ gSaveContext . linkAge ] , & gPlayerAnim_link_normal_wait , 9 ,
2022-03-21 21:51:23 -04:00
ptr , ptr , PLAYER_LIMB_MAX ) ;
return size + 0x8800 + 0x90 ;
}
2023-10-26 20:38:43 -04:00
u8 sPauseModelGroupBySword [ ] = {
PLAYER_MODELGROUP_SWORD , // PLAYER_SWORD_KOKIRI
PLAYER_MODELGROUP_SWORD , // PLAYER_SWORD_MASTER
PLAYER_MODELGROUP_BGS , // PLAYER_SWORD_BIGGORON
} ;
2022-03-21 21:51:23 -04:00
2023-09-15 14:39:46 -04:00
s32 Player_OverrideLimbDrawPause ( PlayState * play , s32 limbIndex , Gfx * * dList , Vec3f * pos , Vec3s * rot , void * arg ) {
2023-10-26 20:38:43 -04:00
u8 * playerSwordAndShield = arg ;
// SOH: Ensure positive value from playerSwordAndShield[] to avoid OOB array access.
// This can occur in the case where playerSwordAndShield[0] is PLAYER_SWORD_NONE
u8 modelGroup = sPauseModelGroupBySword [ playerSwordAndShield [ 0 ] > 0 ? playerSwordAndShield [ 0 ] - PLAYER_SWORD_KOKIRI : 0 ] ;
2022-03-21 21:51:23 -04:00
s32 type ;
s32 dListOffset = 0 ;
Gfx * * dLists ;
2022-05-30 22:48:19 -04:00
size_t ptrSize = sizeof ( uint32_t ) ;
2022-03-21 21:51:23 -04:00
2023-10-26 20:38:43 -04:00
if ( ( modelGroup = = PLAYER_MODELGROUP_SWORD ) & & ! LINK_IS_ADULT & & ( playerSwordAndShield [ 1 ] = = PLAYER_SHIELD_HYLIAN ) ) {
modelGroup = PLAYER_MODELGROUP_CHILD_HYLIAN_SHIELD ;
2022-03-21 21:51:23 -04:00
}
if ( limbIndex = = PLAYER_LIMB_L_HAND ) {
2023-10-26 20:38:43 -04:00
type = gPlayerModelTypes [ modelGroup ] [ PLAYER_MODELGROUPENTRY_LEFT_HAND ] ;
2023-09-15 14:39:46 -04:00
sLeftHandType = type ;
2022-03-21 21:51:23 -04:00
2023-10-26 20:38:43 -04:00
// SOH: Handle unexpected swordless case. Previously OOB array access is avoided, but we want the
// hand model-type to be set to open (otherwise it is set to holding sword model-type)
if ( playerSwordAndShield [ 0 ] = = PLAYER_SWORD_NONE ) {
type = PLAYER_MODELTYPE_LH_OPEN ;
}
2022-03-21 21:51:23 -04:00
2023-10-26 20:38:43 -04:00
if ( ( type = = PLAYER_MODELTYPE_LH_BGS ) & & ( gSaveContext . swordHealth < = 0.0f ) ) {
2022-03-21 21:51:23 -04:00
dListOffset = 4 ;
}
} else if ( limbIndex = = PLAYER_LIMB_R_HAND ) {
2023-10-26 20:38:43 -04:00
type = gPlayerModelTypes [ modelGroup ] [ PLAYER_MODELGROUPENTRY_RIGHT_HAND ] ;
2023-09-15 14:39:46 -04:00
sRightHandType = type ;
2023-10-26 20:38:43 -04:00
if ( type = = PLAYER_MODELTYPE_RH_SHIELD ) {
dListOffset = playerSwordAndShield [ 1 ] * ptrSize ;
2022-03-21 21:51:23 -04:00
}
} else if ( limbIndex = = PLAYER_LIMB_SHEATH ) {
2023-10-26 20:38:43 -04:00
type = gPlayerModelTypes [ modelGroup ] [ PLAYER_MODELGROUPENTRY_SHEATH ] ;
if ( ( type = = PLAYER_MODELTYPE_SHEATH_18 ) | | ( type = = PLAYER_MODELTYPE_SHEATH_19 ) ) {
dListOffset = playerSwordAndShield [ 1 ] * ptrSize ;
} else if ( type = = PLAYER_MODELTYPE_SHEATH_16 & & CVarGetInteger ( " gPauseLiveLink " , 0 ) ) {
//if (playerSwordAndShield[0] == 1)
2022-03-21 21:51:23 -04:00
//dListOffset = 4;
}
} else if ( limbIndex = = PLAYER_LIMB_WAIST ) {
2023-10-26 20:38:43 -04:00
type = gPlayerModelTypes [ modelGroup ] [ PLAYER_MODELGROUPENTRY_WAIST ] ;
2023-04-27 19:20:41 -04:00
if ( Player_IsCustomLinkModel ( ) ) {
return 0 ;
}
2022-03-21 21:51:23 -04:00
} else {
return 0 ;
}
2022-05-30 22:48:19 -04:00
dLists = & sPlayerDListGroups [ type ] [ gSaveContext . linkAge ] ;
2022-03-21 21:51:23 -04:00
* dList = dLists [ dListOffset ] ;
return 0 ;
}
# include <overlays/actors/ovl_Demo_Effect/z_demo_effect.h>
2023-06-27 19:53:35 -04:00
void DemoEffect_DrawTriforceSpot ( Actor * thisx , PlayState * play ) ;
2022-03-21 21:51:23 -04:00
2022-11-06 03:24:34 -05:00
void Pause_DrawTriforceSpot ( PlayState * play , s32 showLightColumn ) {
2022-03-21 21:51:23 -04:00
static DemoEffect triforce ;
static s16 rotation = 0 ;
triforce . triforceSpot . crystalLightOpacity = 244 ;
triforce . triforceSpot . triforceSpotOpacity = 249 ;
triforce . triforceSpot . lightColumnOpacity = showLightColumn ? 244 : 0 ;
triforce . triforceSpot . rotation = rotation ;
2022-11-06 03:24:34 -05:00
DemoEffect_DrawTriforceSpot ( & triforce , play ) ;
2022-03-21 21:51:23 -04:00
rotation + = 0x03E8 ;
}
2023-09-15 14:39:46 -04:00
void Player_DrawPauseImpl ( PlayState * play , void * seg04 , void * seg06 , SkelAnime * skelAnime , Vec3f * pos , Vec3s * rot ,
2022-03-21 21:51:23 -04:00
f32 scale , s32 sword , s32 tunic , s32 shield , s32 boots , s32 width , s32 height , Vec3f * eye , Vec3f * at ,
f32 fovy , void * img1 , void * img2 ) {
static Vp viewport = { 128 , 224 , 511 , 0 , 128 , 224 , 511 , 0 } ;
static Lights1 lights1 = gdSPDefLights1 ( 80 , 80 , 80 , 255 , 255 , 255 , 84 , 84 , 172 ) ;
static Vec3f lightDir = { 89.8f , 0.0f , 89.8f } ;
2023-10-26 20:38:43 -04:00
u8 playerSwordAndShield [ 2 ] ;
2022-03-21 21:51:23 -04:00
Gfx * opaRef ;
Gfx * xluRef ;
Gfx * kalRef ;
u16 perspNorm ;
2022-11-06 03:24:34 -05:00
Mtx * perspMtx = Graph_Alloc ( play - > state . gfxCtx , sizeof ( Mtx ) ) ;
Mtx * lookAtMtx = Graph_Alloc ( play - > state . gfxCtx , sizeof ( Mtx ) ) ;
2022-03-21 21:51:23 -04:00
2022-11-06 03:24:34 -05:00
OPEN_DISPS ( play - > state . gfxCtx ) ;
2022-03-21 21:51:23 -04:00
gSPSegment ( POLY_OPA_DISP + + , 0x00 , NULL ) ;
gDPPipeSync ( POLY_OPA_DISP + + ) ;
gSPLoadGeometryMode ( POLY_OPA_DISP + + , 0 ) ;
gSPTexture ( POLY_OPA_DISP + + , 0xFFFF , 0xFFFF , 0 , G_TX_RENDERTILE , G_OFF ) ;
gDPSetCombineMode ( POLY_OPA_DISP + + , G_CC_SHADE , G_CC_SHADE ) ;
gDPSetOtherMode ( POLY_OPA_DISP + + ,
G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE |
G_TD_CLAMP | G_TP_PERSP | G_CYC_FILL | G_PM_NPRIMITIVE ,
G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2 ) ;
gSPLoadGeometryMode ( POLY_OPA_DISP + + , G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH ) ;
gDPSetScissor ( POLY_OPA_DISP + + , G_SC_NON_INTERLACE , 0 , 0 , width , height ) ;
gSPClipRatio ( POLY_OPA_DISP + + , FRUSTRATIO_1 ) ;
viewport . vp . vscale [ 0 ] = viewport . vp . vtrans [ 0 ] = width * 2 ;
viewport . vp . vscale [ 1 ] = viewport . vp . vtrans [ 1 ] = height * 2 ;
gSPViewport ( POLY_OPA_DISP + + , & viewport ) ;
2022-05-30 22:48:19 -04:00
2022-03-21 21:51:23 -04:00
guPerspective ( perspMtx , & perspNorm , fovy , ( f32 ) width / ( f32 ) height , 10.0f , 4000.0f , 1.0f ) ;
gSPPerspNormalize ( POLY_OPA_DISP + + , perspNorm ) ;
gSPMatrix ( POLY_OPA_DISP + + , perspMtx , G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION ) ;
guLookAt ( lookAtMtx , eye - > x , eye - > y , eye - > z , at - > x , at - > y , at - > z , 0.0f , 1.0f , 0.0f ) ;
gSPMatrix ( POLY_OPA_DISP + + , lookAtMtx , G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION ) ;
2023-10-26 20:38:43 -04:00
playerSwordAndShield [ 0 ] = sword ;
playerSwordAndShield [ 1 ] = shield ;
2022-03-21 21:51:23 -04:00
2023-01-17 00:17:49 -05:00
Matrix_SetTranslateRotateYXZ ( pos - > x - ( ( CVarGetInteger ( " gPauseLiveLink " , 0 ) & & LINK_AGE_IN_YEARS = = YEARS_ADULT ) ? 25 : 0 ) ,
pos - > y - ( CVarGetInteger ( " gPauseTriforce " , 0 ) ? 16 : 0 ) , pos - > z , rot ) ;
2023-06-13 08:46:15 -04:00
Matrix_Scale ( scale * ( CVarGetInteger ( " gMirroredWorld " , 0 ) ? - 1 : 1 ) , scale , scale , MTXMODE_APPLY ) ;
2022-03-21 21:51:23 -04:00
gSPSegment ( POLY_OPA_DISP + + , 0x04 , seg04 ) ;
gSPSegment ( POLY_OPA_DISP + + , 0x06 , seg06 ) ;
gSPSetLights1 ( POLY_OPA_DISP + + , lights1 ) ;
2022-11-06 03:24:34 -05:00
func_80093C80 ( play ) ;
2022-03-21 21:51:23 -04:00
POLY_OPA_DISP = Gfx_SetFog2 ( POLY_OPA_DISP + + , 0 , 0 , 0 , 0 , 997 , 1000 ) ;
2022-11-06 03:24:34 -05:00
func_8002EABC ( pos , & play - > view . eye , & lightDir , play - > state . gfxCtx ) ;
2022-03-21 21:51:23 -04:00
gSPSegment ( POLY_OPA_DISP + + , 0x0C , gCullBackDList ) ;
2023-09-15 14:39:46 -04:00
Player_DrawImpl ( play , skelAnime - > skeleton , skelAnime - > jointTable , skelAnime - > dListCount , 0 , tunic , boots , 0 ,
2023-10-26 20:38:43 -04:00
Player_OverrideLimbDrawPause , NULL , & playerSwordAndShield ) ;
2022-03-21 21:51:23 -04:00
2023-01-17 00:17:49 -05:00
if ( CVarGetInteger ( " gPauseTriforce " , 0 ) ) {
2022-03-21 21:51:23 -04:00
Matrix_SetTranslateRotateYXZ ( pos - > x - ( LINK_AGE_IN_YEARS = = YEARS_ADULT ? 25 : 0 ) ,
pos - > y + 280 + ( LINK_AGE_IN_YEARS = = YEARS_ADULT ? 48 : 0 ) , pos - > z , rot ) ;
2023-06-13 08:46:15 -04:00
Matrix_Scale ( scale * ( CVarGetInteger ( " gMirroredWorld " , 0 ) ? - 1 : 1 ) , scale * 1 , scale * 1 , MTXMODE_APPLY ) ;
2022-03-21 21:51:23 -04:00
Gfx * ohNo = POLY_XLU_DISP ;
POLY_XLU_DISP = POLY_OPA_DISP ;
2022-11-06 03:24:34 -05:00
Pause_DrawTriforceSpot ( play , 1 ) ;
2022-03-21 21:51:23 -04:00
POLY_OPA_DISP = POLY_XLU_DISP ;
POLY_XLU_DISP = ohNo ;
}
2022-11-06 03:24:34 -05:00
POLY_OPA_DISP = Play_SetFog ( play , POLY_OPA_DISP + + ) ;
2022-03-31 19:42:44 -04:00
2022-11-06 03:24:34 -05:00
CLOSE_DISPS ( play - > state . gfxCtx ) ;
2022-03-21 21:51:23 -04:00
}
2022-05-29 16:40:50 -04:00
uintptr_t SelectedAnim = 0 ; // Current Animaiton on the menu
s16 EquipedStance ; // Link's current mode (Two handed, One handed...)
s16 FrameCountSinceLastAnim = 0 ; // Time since last animation
s16 MinFrameCount ; // Frame to wait before checking if we need to change the animation
2023-09-15 14:39:46 -04:00
void Player_DrawPause ( PlayState * play , u8 * segment , SkelAnime * skelAnime , Vec3f * pos , Vec3s * rot , f32 scale ,
2022-03-21 21:51:23 -04:00
s32 sword , s32 tunic , s32 shield , s32 boots ) {
2022-11-06 03:24:34 -05:00
Input * p1Input = & play - > state . input [ 0 ] ;
2022-03-21 21:51:23 -04:00
Vec3f eye = { 0.0f , 0.0f , - 400.0f } ;
Vec3f at = { 0.0f , 0.0f , 0.0f } ;
Vec3s * destTable ;
Vec3s * srcTable ;
s32 i ;
2022-05-29 16:40:50 -04:00
bool canswitchrnd = false ;
2023-01-17 00:17:49 -05:00
s16 SelectedMode = CVarGetInteger ( " gPauseLiveLink " , 0 ) ;
MinFrameCount = CVarGetInteger ( " gMinFrameCount " , 200 ) ;
2022-03-21 21:51:23 -04:00
gSegments [ 4 ] = VIRTUAL_TO_PHYSICAL ( segment + 0x3800 ) ;
gSegments [ 6 ] = VIRTUAL_TO_PHYSICAL ( segment + 0x8800 ) ;
2022-05-29 16:40:50 -04:00
uintptr_t * PauseMenuAnimSet [ 15 ] [ 4 ] = {
{ 0 , 0 , 0 , 0 } , // 0 = none
// IDLE // Two Handed // No shield // Kid Hylian Shield
2022-09-18 23:29:24 -04:00
{ gPlayerAnim_link_normal_wait , gPlayerAnim_link_fighter_wait_long , gPlayerAnim_link_normal_wait_free , gPlayerAnim_link_normal_wait_free } , // Idle
{ gPlayerAnim_link_normal_waitF_typeA_20f , gPlayerAnim_link_normal_waitF_typeA_20f , gPlayerAnim_link_normal_waitF_typeA_20f , gPlayerAnim_link_normal_waitF_typeA_20f } , // Idle look around
{ gPlayerAnim_link_waitF_itemA_20f , gPlayerAnim_link_waitF_itemA_20f , gPlayerAnim_link_waitF_itemA_20f , gPlayerAnim_link_waitF_itemA_20f } , // Idle Belt
{ gPlayerAnim_link_wait_itemC_20f , gPlayerAnim_link_wait_itemC_20f , gPlayerAnim_link_wait_itemC_20f , gPlayerAnim_link_wait_itemC_20f } , // Idle shield adjust
{ gPlayerAnim_link_wait_itemD1_20f , gPlayerAnim_link_wait_itemD2_20f , gPlayerAnim_link_wait_itemD1_20f , gPlayerAnim_link_wait_itemD1_20f } , // Idle test sword
{ gPlayerAnim_link_waitF_typeD_20f , gPlayerAnim_link_waitF_typeD_20f , gPlayerAnim_link_waitF_typeD_20f , gPlayerAnim_link_waitF_typeD_20f } , // Idle yawn
{ gPlayerAnim_link_anchor_waitR , gPlayerAnim_link_fighter_waitR_long , gPlayerAnim_link_anchor_waitR , gPlayerAnim_link_anchor_waitR } , // Battle Stance
{ gPlayerAnim_link_normal_walk_free , gPlayerAnim_link_fighter_walk_long , gPlayerAnim_link_normal_walk_free , gPlayerAnim_link_normal_walk_free } , // Walking (No shield)
{ gPlayerAnim_link_normal_walk , gPlayerAnim_link_fighter_walk_long , gPlayerAnim_link_normal_walk , gPlayerAnim_link_normal_walk } , // Walking (Holding shield)
{ gPlayerAnim_link_normal_run , gPlayerAnim_link_fighter_run_long , gPlayerAnim_link_normal_run , gPlayerAnim_link_normal_run } , // Running (No shield)
{ gPlayerAnim_link_normal_run_free , gPlayerAnim_link_fighter_run_long , gPlayerAnim_link_normal_run_free , gPlayerAnim_link_normal_run_free } , // Running (Holding shield)
{ gPlayerAnim_link_normal_talk_free_wait , gPlayerAnim_link_normal_talk_free_wait , gPlayerAnim_link_normal_talk_free_wait , gPlayerAnim_link_normal_talk_free_wait } , // Hand on hip
{ gPlayerAnim_link_fighter_power_kiru_wait , gPlayerAnim_link_fighter_Lpower_kiru_wait , gPlayerAnim_link_fighter_power_kiru_wait , gPlayerAnim_link_fighter_power_kiru_wait } , // Spin Charge
{ gPlayerAnim_link_demo_look_hand_wait , gPlayerAnim_link_demo_look_hand_wait , gPlayerAnim_link_demo_look_hand_wait , gPlayerAnim_link_demo_look_hand_wait } , // Look at hand
2022-05-29 16:40:50 -04:00
} ;
s16 AnimArraySize = ARRAY_COUNT ( PauseMenuAnimSet ) ;
2023-01-17 00:17:49 -05:00
if ( CVarGetInteger ( " gPauseLiveLink " , 0 ) | | CVarGetInteger ( " gPauseTriforce " , 0 ) ) {
2022-05-29 16:40:50 -04:00
uintptr_t anim = 0 ; // Initialise anim
2023-10-30 11:56:36 -04:00
if ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SWORD ) > = EQUIP_VALUE_SWORD_BIGGORON ) {
2022-05-29 16:40:50 -04:00
EquipedStance = 1 ;
2023-10-30 11:56:36 -04:00
} else if ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SHIELD ) = = EQUIP_VALUE_SWORD_NONE ) {
2022-05-29 16:40:50 -04:00
EquipedStance = 2 ;
2023-10-30 11:56:36 -04:00
} else if ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SHIELD ) = = EQUIP_VALUE_SWORD_MASTER & & LINK_AGE_IN_YEARS = = YEARS_CHILD ) {
2022-05-29 16:40:50 -04:00
EquipedStance = 3 ;
} else {
// Link is idle so revert to 0
EquipedStance = 0 ;
}
if ( SelectedMode = = 16 ) {
// Apply Random function
s16 SwitchAtFrame = 0 ;
s16 CurAnimDuration = 0 ;
if ( FrameCountSinceLastAnim = = 0 ) {
// When opening Kaleido this will be passed one time
SelectedAnim = rand ( ) % ( AnimArraySize - 0 ) ;
if ( SelectedAnim = = 0 ) {
// prevent loading 0 that would result to a crash.
SelectedAnim = 1 ;
}
} else if ( FrameCountSinceLastAnim > = 1 ) {
SwitchAtFrame = Animation_GetLastFrame ( PauseMenuAnimSet [ SelectedAnim ] [ EquipedStance ] ) ;
CurAnimDuration = Animation_GetLastFrame ( PauseMenuAnimSet [ SelectedAnim ] [ EquipedStance ] ) ;
if ( SwitchAtFrame < MinFrameCount ) {
// Animation frame count is lower than minimal wait time then we wait for another round.
// This will be looped to always add current animation time if that still lower than minimum time
while ( SwitchAtFrame < MinFrameCount ) {
SwitchAtFrame = SwitchAtFrame + CurAnimDuration ;
}
} else if ( CurAnimDuration > = MinFrameCount ) {
// Since we have more (or same) animation time than min duration we set the wait time to animation
// time.
SwitchAtFrame = CurAnimDuration ;
}
if ( FrameCountSinceLastAnim > = SwitchAtFrame ) {
SelectedAnim = rand ( ) % ( AnimArraySize - 0 ) ;
if ( SelectedAnim = = 0 ) {
// prevent loading 0 that would result to a crash.
SelectedAnim = 1 ;
}
FrameCountSinceLastAnim = 1 ;
}
anim = PauseMenuAnimSet [ SelectedAnim ] [ EquipedStance ] ;
}
FrameCountSinceLastAnim + + ;
2022-07-25 06:36:06 -04:00
} else if ( SelectedMode = = 17 ) {
// Apply Random function
s16 SwitchAtFrame = 0 ;
s16 CurAnimDuration = 0 ;
s16 LastAnim ;
if ( FrameCountSinceLastAnim = = 0 ) {
// When opening Kaleido this will be passed one time
SelectedAnim = ( rand ( ) % ( 6 - 1 + 1 ) ) + 1 ;
if ( SelectedAnim = = 0 ) {
// prevent loading 0 that would result to a crash.
SelectedAnim = 1 ;
}
} else if ( FrameCountSinceLastAnim > = 1 ) {
SwitchAtFrame = Animation_GetLastFrame ( PauseMenuAnimSet [ SelectedAnim ] [ EquipedStance ] ) ;
CurAnimDuration = Animation_GetLastFrame ( PauseMenuAnimSet [ SelectedAnim ] [ EquipedStance ] ) ;
if ( SwitchAtFrame < MinFrameCount ) {
// Animation frame count is lower than minimal wait time then we wait for another round.
// This will be looped to always add current animation time if that still lower than minimum time
while ( SwitchAtFrame < MinFrameCount ) {
SwitchAtFrame = SwitchAtFrame + CurAnimDuration ;
}
} else if ( CurAnimDuration > = MinFrameCount ) {
// Since we have more (or same) animation time than min duration we set the wait time to animation
// time.
SwitchAtFrame = CurAnimDuration ;
}
if ( FrameCountSinceLastAnim > = SwitchAtFrame ) {
LastAnim = SelectedAnim ;
if ( LastAnim = = 1 ) {
2023-10-30 11:56:36 -04:00
if ( ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SWORD ) ! = EQUIP_VALUE_SWORD_NONE ) & & ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SHIELD ) ! = EQUIP_VALUE_SHIELD_NONE ) ) { // if the player has a sword and shield equipped
if ( ( LINK_AGE_IN_YEARS = = YEARS_ADULT ) | | ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SHIELD ) = = EQUIP_VALUE_SHIELD_DEKU ) ) { // if he's an adult or a kid with the deku shield
2022-07-25 06:36:06 -04:00
SelectedAnim = ( rand ( ) % ( 6 - 2 + 1 ) ) + 2 ; // select any 5 animations that aren't the default standing anim
} else { //else if he's a child with a shield that isn't the deku shield
s16 randval = ( rand ( ) % ( 5 - 2 + 1 ) ) + 2 ; // 4 animations
if ( randval = = 4 ) { //if its the shield anim
SelectedAnim = = 6 ; // set to yawn anim
} else {
SelectedAnim = randval ;
}
}
2023-10-30 11:56:36 -04:00
} else if ( ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SWORD ) ! = EQUIP_VALUE_SWORD_NONE ) & & ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SHIELD ) = = EQUIP_VALUE_SHIELD_NONE ) ) { // if the player has a sword equipped but no shield
2022-07-25 06:36:06 -04:00
s16 randval = ( rand ( ) % ( 5 - 2 + 1 ) ) + 2 ; // 4 animations
if ( randval = = 4 ) { //if its the shield anim
SelectedAnim = = 6 ; // set to yawn anim
} else {
SelectedAnim = randval ;
}
2023-10-30 11:56:36 -04:00
} else if ( ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SWORD ) = = EQUIP_VALUE_SWORD_NONE ) & & ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SHIELD ) ! = EQUIP_VALUE_SHIELD_NONE ) ) { //if the player has a shield equipped but no sword
if ( ( LINK_AGE_IN_YEARS = = YEARS_ADULT ) | | ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SHIELD ) = = EQUIP_VALUE_SHIELD_DEKU ) ) { // if he's an adult or a kid with the deku shield
2022-07-25 06:36:06 -04:00
s16 randval = ( rand ( ) % ( 5 - 2 + 1 ) ) + 2 ; // 4 animations
if ( randval = = 5 ) { //if its the sword anim
SelectedAnim = = 6 ; // set to yawn anim
} else {
SelectedAnim = randval ;
}
} else {
s16 randval = ( rand ( ) % ( 4 - 2 + 1 ) ) + 2 ; // 3 animations
if ( randval = = 4 ) { //if its the shield anim
SelectedAnim = = 6 ; // set to yawn anim
} else {
SelectedAnim = randval ;
}
}
2023-10-30 11:56:36 -04:00
} else if ( ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SWORD ) = = EQUIP_VALUE_SWORD_NONE ) & & ( CUR_EQUIP_VALUE ( EQUIP_TYPE_SHIELD ) = = EQUIP_VALUE_SHIELD_NONE ) ) { // if the player has no sword or shield equipped
2022-07-25 06:36:06 -04:00
s16 randval = ( rand ( ) % ( 4 - 2 + 1 ) ) + 2 ; // 3 animations
if ( randval = = 4 ) { //if its the shield anim
SelectedAnim = = 6 ; // set to yawn anim
} else {
SelectedAnim = randval ;
}
}
} else {
SelectedAnim = 1 ;
}
if ( SelectedAnim = = 0 ) {
// prevent loading 0 that would result to a crash. Also makes sure default idle is every other anim
SelectedAnim = 1 ;
}
FrameCountSinceLastAnim = 1 ;
}
anim = PauseMenuAnimSet [ SelectedAnim ] [ EquipedStance ] ;
}
FrameCountSinceLastAnim + + ;
2022-05-29 16:40:50 -04:00
} else if ( SelectedMode = = 15 ) {
// When opening Kaleido this will be passed one time
if ( FrameCountSinceLastAnim < 1 ) {
SelectedAnim = rand ( ) % ( AnimArraySize - 0 ) ;
FrameCountSinceLastAnim + + ;
if ( SelectedAnim = = 0 ) {
// prevent loading 0 that would result to a crash.
SelectedAnim = 1 ;
}
FrameCountSinceLastAnim = 1 ;
}
if ( CHECK_BTN_ALL ( p1Input - > press . button , BTN_B ) | | CHECK_BTN_ALL ( p1Input - > press . button , BTN_START ) ) {
FrameCountSinceLastAnim = 0 ;
}
anim = PauseMenuAnimSet [ SelectedAnim ] [ EquipedStance ] ;
} else if ( SelectedMode < 16 ) {
// Not random so we place our CVar as SelectedAnim
SelectedAnim = SelectedMode ;
anim = PauseMenuAnimSet [ SelectedAnim ] [ EquipedStance ] ;
}
2022-03-21 21:51:23 -04:00
2022-05-29 16:40:50 -04:00
anim = PauseMenuAnimSet [ SelectedAnim ] [ EquipedStance ] ;
2022-03-21 21:51:23 -04:00
2022-09-18 23:29:24 -04:00
//anim = gPlayerAnim_link_wait_itemD2_20f; // Use for biggoron sword?
2022-03-21 21:51:23 -04:00
2023-01-17 00:17:49 -05:00
if ( CVarGetInteger ( " gPauseTriforce " , 0 ) ) {
2022-09-18 23:29:24 -04:00
anim = gPlayerAnim_link_magic_kaze2 ;
2022-03-21 21:51:23 -04:00
sword = 0 ;
shield = 0 ;
}
if ( skelAnime - > animation ! = anim ) {
2022-11-06 03:24:34 -05:00
LinkAnimation_Change ( play , skelAnime , anim , 1.0f , 0.0f , Animation_GetLastFrame ( anim ) , ANIMMODE_LOOP ,
2022-03-21 21:51:23 -04:00
- 6.0f ) ;
}
2022-11-06 03:24:34 -05:00
LinkAnimation_Update ( play , skelAnime ) ;
2022-03-21 21:51:23 -04:00
if ( ! LINK_IS_ADULT ) {
// Link is placed too far up by default when animating
at . y + = 60 ;
}
} else {
if ( ! LINK_IS_ADULT ) {
if ( shield = = PLAYER_SHIELD_DEKU ) {
2022-09-18 23:29:24 -04:00
srcTable = gLinkPauseChildDekuShieldJointTable ;
2022-03-21 21:51:23 -04:00
} else {
2022-09-18 23:29:24 -04:00
srcTable = gLinkPauseChildJointTable ;
2022-03-21 21:51:23 -04:00
}
} else {
2023-10-30 11:56:36 -04:00
if ( sword = = PLAYER_SWORD_BIGGORON ) {
2022-09-18 23:29:24 -04:00
srcTable = gLinkPauseAdultBgsJointTable ;
2022-03-21 21:51:23 -04:00
} else if ( shield ! = PLAYER_SHIELD_NONE ) {
2022-09-18 23:29:24 -04:00
srcTable = gLinkPauseAdultShieldJointTable ;
2022-03-21 21:51:23 -04:00
} else {
2022-09-18 23:29:24 -04:00
srcTable = gLinkPauseAdultJointTable ;
2022-03-21 21:51:23 -04:00
}
}
srcTable = ResourceMgr_LoadArrayByNameAsVec3s ( srcTable ) ;
2024-05-09 21:39:13 -04:00
Vec3s * ogSrcTable = srcTable ;
2022-03-21 21:51:23 -04:00
destTable = skelAnime - > jointTable ;
for ( i = 0 ; i < skelAnime - > limbCount ; i + + ) {
* destTable + + = * srcTable + + ;
}
2024-05-09 21:39:13 -04:00
free ( ogSrcTable ) ;
2022-03-21 21:51:23 -04:00
}
2023-09-15 14:39:46 -04:00
Player_DrawPauseImpl ( play , segment + 0x3800 , segment + 0x8800 , skelAnime , pos , rot , scale , sword , tunic , shield ,
2022-11-06 03:24:34 -05:00
boots , 64 , 112 , & eye , & at , 60.0f , play - > state . gfxCtx - > curFrameBuffer ,
play - > state . gfxCtx - > curFrameBuffer + 0x1C00 ) ;
2022-03-21 21:51:23 -04:00
}