diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index a998da18..ce87e4bd 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -289,7 +289,7 @@ __ct__11CObjectListF15EGameObjectList = .text:0x80010038; // type:function size: __ct__Q211CObjectList16SObjectListEntryFv = .text:0x8001012C; // type:function size:0x18 scope:weak __dt__7CPlayerFv = .text:0x80010144; // type:function size:0x730 scope:global fn_80010874 = .text:0x80010874; // type:function size:0x58 -__dt__10CMorphBallFv = .text:0x800108CC; // type:function size:0x1CC scope:global +__dt__Q27CPlayer12CInputFilterFv = .text:0x800108CC; // type:function size:0x1CC scope:global IsTransparent__7CPlayerCFv = .text:0x80010A98; // type:function size:0x18 scope:global IsEnergyLow__7CPlayerCFRC13CStateManager = .text:0x80010AB0; // type:function size:0x7C scope:global FinishNewScan__7CPlayerFR13CStateManager = .text:0x80010B2C; // type:function size:0x12C scope:global @@ -399,15 +399,15 @@ GetFirstPersonCameraTransform__7CPlayerCFR13CStateManager = .text:0x800190CC; // UpdateGunTransform__7CPlayerFRC9CVector3fR13CStateManager = .text:0x800190F4; // type:function size:0x464 scope:global UpdateAssistedAiming__7CPlayerFRC12CTransform4fR13CStateManager = .text:0x80019558; // type:function size:0x3E8 scope:global UpdateAimTargetPrediction__7CPlayerFRC12CTransform4fR13CStateManager = .text:0x80019940; // type:function size:0x294 scope:global -GetAverage__31TReservedAverage<9CVector3f,20>CFv = .text:0x80019BD4; // type:function size:0x74 scope:global -fn_80019C48 = .text:0x80019C48; // type:function size:0x15C -ResetAimTargetPrediction__7CPlayerF9TUniqueId = .text:0x80019DA4; // type:function size:0x7C scope:global +GetAverage__31TReservedAverage<9CVector3f,10>CFv = .text:0x80019BD4; // type:function size:0x74 scope:global +AddValue__31TReservedAverage<9CVector3f,10>FRC9CVector3f = .text:0x80019C48; // type:function size:0x15C +SetAimTargetId__7CPlayerF9TUniqueId = .text:0x80019DA4; // type:function size:0x7C scope:global UpdateGunState__7CPlayerFRC11CFinalInputR13CStateManager = .text:0x80019E20; // type:function size:0x28C scope:global DrawGun__7CPlayerFR13CStateManager = .text:0x8001A0AC; // type:function size:0x6C scope:global ResetGun__7CPlayerFR13CStateManager = .text:0x8001A118; // type:function size:0x54 scope:global HolsterGun__7CPlayerFR13CStateManager = .text:0x8001A16C; // type:function size:0xA8 scope:global IsMorphBallTransitioning__7CPlayerCFv = .text:0x8001A214; // type:function size:0x28 scope:global -__ct__7CPlayerF9TUniqueIdRC12CTransform4fRC6CAABoxUi9CVector3fffffRC13CMaterialList = .text:0x8001A23C; // type:function size:0xBFC scope:global +__ct__7CPlayerF9TUniqueIdRC12CTransform4fRC6CAABoxUiRC9CVector3fffffRC13CMaterialList = .text:0x8001A23C; // type:function size:0xBFC scope:global None__16CActorParametersFv = .text:0x8001AE38; // type:function size:0x20 scope:global MakePlayerAnimres__FUiRC9CVector3f = .text:0x8001AE58; // type:function size:0x38 scope:global SetMaterial__19CCollisionPrimitiveFRC13CMaterialList = .text:0x8001AE90; // type:function size:0x14 scope:global @@ -6265,7 +6265,7 @@ ComputeBallMovement__10CMorphBallFRC11CFinalInputR13CStateManagerf = .text:0x800 ForwardInput__10CMorphBallCFRC11CFinalInput = .text:0x800F8D8C; // type:function size:0x6C scope:global GetBallTouchRadius__10CMorphBallCFv = .text:0x800F8DF8; // type:function size:0xC scope:global GetBallRadius__10CMorphBallCFv = .text:0x800F8E04; // type:function size:0xC scope:global -fn_800F8E10 = .text:0x800F8E10; // type:function size:0x764 +__dt__10CMorphBallFv = .text:0x800F8E10; // type:function size:0x764 __ct__10CMorphBallFR7CPlayerf = .text:0x800F9574; // type:function size:0xE98 scope:global fn_800FA40C = .text:0x800FA40C; // type:function size:0x2C fn_800FA438 = .text:0x800FA438; // type:function size:0x7C @@ -6650,7 +6650,7 @@ __ct__12CBloodFlowerF9TUniqueIdRCQ24rstl66basic_string __ct__9TEditorIdFR12CInputStream = .text:0x8011A460; // type:function size:0x38 scope:global __sinit_TGameTypes_cpp = .text:0x8011A498; // type:function size:0x20 scope:local GetMaximumCollisionVelocity__13CPhysicsActorCFv = .text:0x8011A4B8; // type:function size:0x8 scope:global -SetMaximumCollisionVelocity__13CPhysicsActorFf = .text:0x8011A4C0; // type:function size:0x8 scope:global +SetMaxVelocityAfterCollision__13CPhysicsActorFf = .text:0x8011A4C0; // type:function size:0x8 scope:global GetCollisionAccuracyModifier__13CPhysicsActorCFv = .text:0x8011A4C8; // type:function size:0x8 scope:global SetCollisionAccuracyModifier__13CPhysicsActorFf = .text:0x8011A4D0; // type:function size:0x8 scope:global GetCoefficientOfRestitutionModifier__13CPhysicsActorCFv = .text:0x8011A4D8; // type:function size:0x8 scope:global @@ -7979,7 +7979,7 @@ BeginGrapple__7CPlayerFR9CVector3fR13CStateManager = .text:0x8017B020; // type:f BreakGrapple__7CPlayerF19EPlayerOrbitRequestR13CStateManager = .text:0x8017B0C4; // type:function size:0xD8 scope:global SetOrbitRequest__7CPlayerF19EPlayerOrbitRequestR13CStateManager = .text:0x8017B19C; // type:function size:0xB8 scope:global SetOrbitRequestForTarget__7CPlayerF9TUniqueId19EPlayerOrbitRequestR13CStateManager = .text:0x8017B254; // type:function size:0x54 scope:global -InGrappleJumpCooldown__7CPlayerCFv = .text:0x8017B2A8; // type:function size:0x38 scope:global +CheckPostGrapple__7CPlayerCFv = .text:0x8017B2A8; // type:function size:0x38 scope:global PreventFallingCameraPitch__7CPlayerFv = .text:0x8017B2E0; // type:function size:0x1C scope:global OrbitCarcass__7CPlayerFR13CStateManager = .text:0x8017B2FC; // type:function size:0x3C scope:global OrbitPoint__7CPlayerFQ27CPlayer16EPlayerOrbitTypeR13CStateManager = .text:0x8017B338; // type:function size:0x60 scope:global @@ -16710,11 +16710,11 @@ lbl_803CBEA2 = .rodata:0x803CBEA2; // type:object size:0x186 lbl_803CC028 = .rodata:0x803CC028; // type:object size:0x8 @stringBase0 = .rodata:0x803CC030; // type:object size:0x3EA scope:local data:string_table lbl_803CC420 = .rodata:0x803CC420; // type:object size:0x18 -skPlayerLandSfxSoft__7CPlayer = .rodata:0x803CC438; // type:object size:0x30 scope:global -skPlayerLandSfxHard__7CPlayer = .rodata:0x803CC468; // type:object size:0x30 scope:global -skLeftStepSounds_7CPlayer = .rodata:0x803CC498; // type:object size:0x30 scope:global -skRightStepSounds_7CPlayer = .rodata:0x803CC4C8; // type:object size:0x30 scope:global -lbl_803CC4F8 = .rodata:0x803CC4F8; // type:object size:0x48 +skPlayerLandSfxSoft = .rodata:0x803CC438; // type:object size:0x30 scope:local data:short +skPlayerLandSfxHard = .rodata:0x803CC468; // type:object size:0x30 scope:local data:short +skLeftStepSounds = .rodata:0x803CC498; // type:object size:0x30 scope:local data:short +skRightStepSounds = .rodata:0x803CC4C8; // type:object size:0x30 scope:local data:short +@stringBase0 = .rodata:0x803CC4F8; // type:object size:0x47 scope:local data:string_table lbl_803CC540 = .rodata:0x803CC540; // type:object size:0x48 data:4byte MetroidBuildInfo = .rodata:0x803CC588; // type:object size:0x3C scope:global data:string lbl_803CC5C4 = .rodata:0x803CC5C4; // type:object size:0xC data:2byte @@ -17042,7 +17042,7 @@ lbl_803CEC89 = .rodata:0x803CEC89; // type:object size:0x19 data:string lbl_803CECA2 = .rodata:0x803CECA2; // type:object size:0x19 data:string lbl_803CECBB = .rodata:0x803CECBB; // type:object size:0x13D lbl_803CEDF8 = .rodata:0x803CEDF8; // type:object size:0x8 -lbl_803CEE00 = .rodata:0x803CEE00; // type:object size:0x20 +lbl_803CEE00 = .rodata:0x803CEE00; // type:object size:0x1C lbl_803CEE20 = .rodata:0x803CEE20; // type:object size:0x18 lbl_803CEE38 = .rodata:0x803CEE38; // type:object size:0x8 lbl_803CEE40 = .rodata:0x803CEE40; // type:object size:0x10 data:4byte @@ -17745,13 +17745,13 @@ lbl_803D68D0 = .rodata:0x803D68D0; // type:object size:0x8 lbl_803D68D8 = .rodata:0x803D68D8; // type:object size:0x8 lbl_803D68E0 = .rodata:0x803D68E0; // type:object size:0x18 lbl_803D68F8 = .rodata:0x803D68F8; // type:object size:0x50 -lbl_803D6948 = .rodata:0x803D6948; // type:object size:0x68 +lbl_803D6948 = .rodata:0x803D6948; // type:object size:0x63 lbl_803D69B0 = .rodata:0x803D69B0; // type:object size:0x18 lbl_803D69C8 = .rodata:0x803D69C8; // type:object size:0x18 data:4byte lbl_803D69E0 = .rodata:0x803D69E0; // type:object size:0x8 lbl_803D69E8 = .rodata:0x803D69E8; // type:object size:0x18 @stringBase0 = .rodata:0x803D6A00; // type:object size:0x1C scope:local data:string_table -lbl_803D6A20 = .rodata:0x803D6A20; // type:object size:0x28 +lbl_803D6A20 = .rodata:0x803D6A20; // type:object size:0x23 @stringBase0 = .rodata:0x803D6A48; // type:object size:0x7 scope:local data:string_table lbl_803D6A50 = .rodata:0x803D6A50; // type:object size:0xC data:4byte lbl_803D6A5C = .rodata:0x803D6A5C; // type:object size:0xC data:4byte @@ -17813,11 +17813,11 @@ vtxDescList$288 = .rodata:0x803D73B8; // type:object size:0x10 scope:local lbl_803D73C8 = .rodata:0x803D73C8; // type:object size:0x20 @stringBase0 = .rodata:0x803D73E8; // type:object size:0x7 scope:local data:string_table lbl_803D73F0 = .rodata:0x803D73F0; // type:object size:0x10 data:4byte -@stringBase0 = .rodata:0x803D7400; // type:object size:0x8 scope:local data:string_table +@stringBase0 = .rodata:0x803D7400; // type:object size:0x7 scope:local data:string_table gkCRC32Table = .rodata:0x803D7408; // type:object size:0x400 scope:local @stringBase0 = .rodata:0x803D7808; // type:object size:0x18 scope:local data:string_table lbl_803D7820 = .rodata:0x803D7820; // type:object size:0x20 -lbl_803D7840 = .rodata:0x803D7840; // type:object size:0x8 +lbl_803D7840 = .rodata:0x803D7840; // type:object size:0x7 data:string lbl_803D7848 = .rodata:0x803D7848; // type:object size:0x20 lbl_803D7868 = .rodata:0x803D7868; // type:object size:0x20 lbl_803D7888 = .rodata:0x803D7888; // type:object size:0x18 data:4byte @@ -17878,7 +17878,7 @@ skInvalidString = .rodata:0x803D8310; // type:object size:0x10 scope:local data: lbl_803D8328 = .rodata:0x803D8328; // type:object size:0x8 lbl_803D8330 = .rodata:0x803D8330; // type:object size:0x8 @stringBase0 = .rodata:0x803D8338; // type:object size:0x7 scope:local data:string_table -lbl_803D8340 = .rodata:0x803D8340; // type:object size:0x8 +lbl_803D8340 = .rodata:0x803D8340; // type:object size:0x7 data:string @stringBase0 = .rodata:0x803D8348; // type:object size:0x7 scope:local data:string_table lbl_803D8350 = .rodata:0x803D8350; // type:object size:0x18 lbl_803D8368 = .rodata:0x803D8368; // type:object size:0x18 @@ -18230,7 +18230,7 @@ lbl_803DFD78 = .data:0x803DFD78; // type:object size:0x88 __vt__19CScriptCameraShaker = .data:0x803DFE00; // type:object size:0x20 scope:global __vt__20CScriptActorKeyframe = .data:0x803DFE20; // type:object size:0x20 scope:global __vt__14CBCScriptedCmd = .data:0x803DFE40; // type:object size:0xC scope:weak -lbl_803DFE50 = .data:0x803DFE50; // type:object size:0x20 +lbl_803DFE50 = .data:0x803DFE50; // type:object size:0x1C lbl_803DFE70 = .data:0x803DFE70; // type:object size:0x80 __vt__7CWeapon = .data:0x803DFEF0; // type:object size:0x6C scope:global jumptable_803DFF5C = .data:0x803DFF5C; // type:object size:0x24 scope:local @@ -18860,7 +18860,7 @@ __vt__14CVEAngleSphere = .data:0x803EF748; // type:object size:0x10 scope:global __vt__15CEmitterElement = .data:0x803EF758; // type:object size:0x10 scope:global __vt__9CVESphere = .data:0x803EF768; // type:object size:0x10 scope:global __vt__16CEESimpleEmitter = .data:0x803EF778; // type:object size:0x10 scope:global -__vt__52TObjOwnerDerivedFromIObj = .data:0x803EF788; // type:object size:0x10 scope:global +__vt__52TObjOwnerDerivedFromIObj = .data:0x803EF788; // type:object size:0xC scope:global __vt__17CImageInstruction = .data:0x803EF798; // type:object size:0x20 scope:global __vt__17CParticleElectric = .data:0x803EF7B8; // type:object size:0x78 scope:global __vt__44TObjOwnerDerivedFromIObj<16CDependencyGroup> = .data:0x803EF830; // type:object size:0xC scope:weak @@ -19045,8 +19045,8 @@ __lconv = .data:0x803F2D20; // type:object size:0x38 scope:global data:4byte @1428 = .data:0x803F2E60; // type:object size:0xE0 scope:local @1427 = .data:0x803F2F40; // type:object size:0x44 scope:local @1693 = .data:0x803F2F88; // type:object size:0x50 scope:local -kf$395 = .data:0x803F2FD8; // type:object size:0x1C scope:local -midi2TimeTab = .data:0x803F2FF4; // type:object size:0x204 scope:local +kf$395 = .data:0x803F2FD8; // type:object size:0x1A scope:local +midi2TimeTab = .data:0x803F2FF4; // type:object size:0x200 scope:local mask$603 = .data:0x803F31F8; // type:object size:0x20 scope:local dirty$604 = .data:0x803F3218; // type:object size:0x10 scope:local mask$608 = .data:0x803F3228; // type:object size:0x20 scope:local @@ -19119,13 +19119,18 @@ sMainSpace = .bss:0x80457560; // type:object size:0x168 scope:local lbl_804576C8 = .bss:0x804576C8; // type:object size:0xD0 lbl_80457798 = .bss:0x80457798; // type:object size:0x160 @27 = .bss:0x804578F8; // type:object size:0xC scope:local -lbl_80457908 = .bss:0x80457908; // type:object size:0xC0 data:float -lbl_804579C8 = .bss:0x804579C8; // type:object size:0x20 data:4byte +...bss.0 = .bss:0x80457908; // type:label scope:local +testRayStart = .bss:0x80457908; // type:object size:0xC data:float +testRayNormal = .bss:0x80457914; // type:object size:0xC data:float +testRayResult = .bss:0x80457920; // type:object size:0x30 +testBoxResult = .bss:0x80457950; // type:object size:0x60 +testBox = .bss:0x804579B0; // type:object size:0x18 data:float +skVisorToItemMapping = .bss:0x804579C8; // type:object size:0x20 data:4byte lbl_804579E8 = .bss:0x804579E8; // type:object size:0x10 data:float lbl_804579F8 = .bss:0x804579F8; // type:object size:0x18 data:4byte -lbl_80457A10 = .bss:0x80457A10; // type:object size:0x838 -lbl_80458248 = .bss:0x80458248; // type:object size:0x108 -lbl_80458350 = .bss:0x80458350; // type:object size:0x1E58 +sAllocSpace$2944 = .bss:0x80457A10; // type:object size:0x838 +sAllocSpace$2964 = .bss:0x80458248; // type:object size:0x108 +sAllocSpace$2980 = .bss:0x80458350; // type:object size:0x1E58 lbl_8045A1A8 = .bss:0x8045A1A8; // type:object size:0xF98 lbl_8045B140 = .bss:0x8045B140; // type:object size:0x40 lbl_8045B180 = .bss:0x8045B180; // type:object size:0x5C @@ -19252,7 +19257,7 @@ lbl_804BFFAC = .bss:0x804BFFAC; // type:object size:0x14 sStaticSkinningData__8Skinning = .bss:0x804BFFC0; // type:object size:0x8000C scope:local align:32 sSkinningBuffer__8Skinning = .bss:0x8053FFCC; // type:object size:0x28 scope:local data:byte sAllocations__8Skinning = .bss:0x8053FFF4; // type:object size:0x1C scope:local -lbl_80540010 = .bss:0x80540010; // type:object size:0x10 +lbl_80540010 = .bss:0x80540010; // type:object size:0xC lbl_80540020 = .bss:0x80540020; // type:object size:0x500 align:32 lbl_80540520 = .bss:0x80540520; // type:object size:0x30 lbl_80540550 = .bss:0x80540550; // type:object size:0x30 @@ -22456,7 +22461,7 @@ lbl_805A9E08 = .sdata2:0x805A9E08; // type:object size:0x1 data:byte lbl_805A9E09 = .sdata2:0x805A9E09; // type:object size:0x1 data:byte lbl_805A9E0C = .sdata2:0x805A9E0C; // type:object size:0x4 data:float lbl_805A9E10 = .sdata2:0x805A9E10; // type:object size:0x4 data:float -lbl_805A9E14 = .sdata2:0x805A9E14; // type:object size:0x4 data:4byte +kGunLocator = .sdata2:0x805A9E14; // type:object size:0x4 data:4byte skDefaultHudFadeOutSpeed__7CPlayer = .sdata2:0x805A9E18; // type:object size:0x4 scope:global data:float skDefaultHudFadeInSpeed__7CPlayer = .sdata2:0x805A9E1C; // type:object size:0x4 scope:global data:float lbl_805A9E20 = .sdata2:0x805A9E20; // type:object size:0x4 data:float @@ -23718,7 +23723,7 @@ lbl_805AB448 = .sdata2:0x805AB448; // type:object size:0x4 data:float lbl_805AB44C = .sdata2:0x805AB44C; // type:object size:0x4 data:float lbl_805AB450 = .sdata2:0x805AB450; // type:object size:0x4 data:float lbl_805AB454 = .sdata2:0x805AB454; // type:object size:0x4 data:float -lbl_805AB458 = .sdata2:0x805AB458; // type:object size:0x8 data:float +lbl_805AB458 = .sdata2:0x805AB458; // type:object size:0x4 data:float lbl_805AB460 = .sdata2:0x805AB460; // type:object size:0x8 data:float lbl_805AB468 = .sdata2:0x805AB468; // type:object size:0x4 data:4byte lbl_805AB46C = .sdata2:0x805AB46C; // type:object size:0x4 data:4byte @@ -26657,7 +26662,7 @@ lbl_805AE92C = .sdata2:0x805AE92C; // type:object size:0x4 data:float lbl_805AE930 = .sdata2:0x805AE930; // type:object size:0x8 align:8 data:double @23 = .sdata2:0x805AE938; // type:object size:0x4 scope:local data:float @24 = .sdata2:0x805AE93C; // type:object size:0x4 scope:local data:float -lbl_805AE940 = .sdata2:0x805AE940; // type:object size:0x8 data:float +lbl_805AE940 = .sdata2:0x805AE940; // type:object size:0x4 data:float kInput_AnalogOnThreshhold__11CFinalInput = .sdata2:0x805AE948; // type:object size:0x4 scope:global data:float kInput_AnalogTriggerOnThreshhold__11CFinalInput = .sdata2:0x805AE94C; // type:object size:0x4 scope:global data:float @358 = .sdata2:0x805AE950; // type:object size:0x4 scope:local data:float @@ -27060,7 +27065,7 @@ lbl_805AF360 = .sdata2:0x805AF360; // type:object size:0x4 data:float lbl_805AF364 = .sdata2:0x805AF364; // type:object size:0x4 data:float lbl_805AF368 = .sdata2:0x805AF368; // type:object size:0x4 data:float lbl_805AF36C = .sdata2:0x805AF36C; // type:object size:0x4 data:float -lbl_805AF370 = .sdata2:0x805AF370; // type:object size:0x8 data:float +lbl_805AF370 = .sdata2:0x805AF370; // type:object size:0x4 data:float @113 = .sdata2:0x805AF378; // type:object size:0x4 scope:local data:float @114 = .sdata2:0x805AF380; // type:object size:0x8 scope:local align:8 data:double @115 = .sdata2:0x805AF388; // type:object size:0x8 scope:local align:8 data:double diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index e3fef8d1..bd13514d 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -289,7 +289,7 @@ __ct__11CObjectListF15EGameObjectList = .text:0x800100B4; // type:function size: __ct__Q211CObjectList16SObjectListEntryFv = .text:0x800101A8; // type:function size:0x18 scope:weak __dt__7CPlayerFv = .text:0x800101C0; // type:function size:0x730 scope:global fn_80010874 = .text:0x800108F0; // type:function size:0x58 scope:global -__dt__10CMorphBallFv = .text:0x80010948; // type:function size:0x1CC scope:global +__dt__Q27CPlayer12CInputFilterFv = .text:0x80010948; // type:function size:0x1CC scope:global IsTransparent__7CPlayerCFv = .text:0x80010B14; // type:function size:0x18 scope:global IsEnergyLow__7CPlayerCFRC13CStateManager = .text:0x80010B2C; // type:function size:0x7C scope:global FinishNewScan__7CPlayerFR13CStateManager = .text:0x80010BA8; // type:function size:0x12C scope:global @@ -399,15 +399,15 @@ GetFirstPersonCameraTransform__7CPlayerCFR13CStateManager = .text:0x80019148; // UpdateGunTransform__7CPlayerFRC9CVector3fR13CStateManager = .text:0x80019170; // type:function size:0x464 scope:global UpdateAssistedAiming__7CPlayerFRC12CTransform4fR13CStateManager = .text:0x800195D4; // type:function size:0x3E8 scope:global UpdateAimTargetPrediction__7CPlayerFRC12CTransform4fR13CStateManager = .text:0x800199BC; // type:function size:0x294 scope:global -GetAverage__31TReservedAverage<9CVector3f,20>CFv = .text:0x80019C50; // type:function size:0x74 scope:global -fn_80019C48 = .text:0x80019CC4; // type:function size:0x15C scope:global -ResetAimTargetPrediction__7CPlayerF9TUniqueId = .text:0x80019E20; // type:function size:0x7C scope:global +GetAverage__31TReservedAverage<9CVector3f,10>CFv = .text:0x80019C50; // type:function size:0x74 scope:global +AddValue__31TReservedAverage<9CVector3f,10>FRC9CVector3f = .text:0x80019CC4; // type:function size:0x15C scope:global +SetAimTargetId__7CPlayerF9TUniqueId = .text:0x80019E20; // type:function size:0x7C scope:global UpdateGunState__7CPlayerFRC11CFinalInputR13CStateManager = .text:0x80019E9C; // type:function size:0x28C scope:global DrawGun__7CPlayerFR13CStateManager = .text:0x8001A128; // type:function size:0x6C scope:global ResetGun__7CPlayerFR13CStateManager = .text:0x8001A194; // type:function size:0x54 scope:global HolsterGun__7CPlayerFR13CStateManager = .text:0x8001A1E8; // type:function size:0xA8 scope:global IsMorphBallTransitioning__7CPlayerCFv = .text:0x8001A290; // type:function size:0x28 scope:global -__ct__7CPlayerF9TUniqueIdRC12CTransform4fRC6CAABoxUi9CVector3fffffRC13CMaterialList = .text:0x8001A2B8; // type:function size:0xBFC scope:global +__ct__7CPlayerF9TUniqueIdRC12CTransform4fRC6CAABoxUiRC9CVector3fffffRC13CMaterialList = .text:0x8001A2B8; // type:function size:0xBFC scope:global None__16CActorParametersFv = .text:0x8001AEB4; // type:function size:0x20 scope:global MakePlayerAnimres__FUiRC9CVector3f = .text:0x8001AED4; // type:function size:0x38 scope:global SetMaterial__19CCollisionPrimitiveFRC13CMaterialList = .text:0x8001AF0C; // type:function size:0x14 scope:global @@ -6267,7 +6267,7 @@ ComputeBallMovement__10CMorphBallFRC11CFinalInputR13CStateManagerf = .text:0x800 ForwardInput__10CMorphBallCFRC11CFinalInput = .text:0x800F8E08; // type:function size:0x6C scope:global GetBallTouchRadius__10CMorphBallCFv = .text:0x800F8E74; // type:function size:0xC scope:global GetBallRadius__10CMorphBallCFv = .text:0x800F8E80; // type:function size:0xC scope:global -fn_800F8E10 = .text:0x800F8E8C; // type:function size:0x764 scope:global +__dt__10CMorphBallFv = .text:0x800F8E8C; // type:function size:0x764 scope:global __ct__10CMorphBallFR7CPlayerf = .text:0x800F95F0; // type:function size:0xE98 scope:global fn_800FA40C = .text:0x800FA488; // type:function size:0x2C scope:global fn_800FA438 = .text:0x800FA4B4; // type:function size:0x7C scope:global @@ -6652,7 +6652,7 @@ __ct__12CBloodFlowerF9TUniqueIdRCQ24rstl66basic_string __ct__9TEditorIdFR12CInputStream = .text:0x8011A4DC; // type:function size:0x38 scope:global __sinit_TGameTypes_cpp = .text:0x8011A514; // type:function size:0x20 scope:local GetMaximumCollisionVelocity__13CPhysicsActorCFv = .text:0x8011A534; // type:function size:0x8 scope:global -SetMaximumCollisionVelocity__13CPhysicsActorFf = .text:0x8011A53C; // type:function size:0x8 scope:global +SetMaxVelocityAfterCollision__13CPhysicsActorFf = .text:0x8011A53C; // type:function size:0x8 scope:global GetCollisionAccuracyModifier__13CPhysicsActorCFv = .text:0x8011A544; // type:function size:0x8 scope:global SetCollisionAccuracyModifier__13CPhysicsActorFf = .text:0x8011A54C; // type:function size:0x8 scope:global GetCoefficientOfRestitutionModifier__13CPhysicsActorCFv = .text:0x8011A554; // type:function size:0x8 scope:global @@ -7983,7 +7983,7 @@ BeginGrapple__7CPlayerFR9CVector3fR13CStateManager = .text:0x8017B09C; // type:f BreakGrapple__7CPlayerF19EPlayerOrbitRequestR13CStateManager = .text:0x8017B140; // type:function size:0xD8 scope:global SetOrbitRequest__7CPlayerF19EPlayerOrbitRequestR13CStateManager = .text:0x8017B218; // type:function size:0xB8 scope:global SetOrbitRequestForTarget__7CPlayerF9TUniqueId19EPlayerOrbitRequestR13CStateManager = .text:0x8017B2D0; // type:function size:0x54 scope:global -InGrappleJumpCooldown__7CPlayerCFv = .text:0x8017B324; // type:function size:0x38 scope:global +CheckPostGrapple__7CPlayerCFv = .text:0x8017B324; // type:function size:0x38 scope:global PreventFallingCameraPitch__7CPlayerFv = .text:0x8017B35C; // type:function size:0x1C scope:global OrbitCarcass__7CPlayerFR13CStateManager = .text:0x8017B378; // type:function size:0x3C scope:global OrbitPoint__7CPlayerFQ27CPlayer16EPlayerOrbitTypeR13CStateManager = .text:0x8017B3B4; // type:function size:0x60 scope:global @@ -19152,9 +19152,9 @@ lbl_80457908 = .bss:0x80457AE8; // type:object size:0xC0 scope:local data:float lbl_804579C8 = .bss:0x80457BA8; // type:object size:0x20 scope:local data:4byte lbl_804579E8 = .bss:0x80457BC8; // type:object size:0x10 scope:local data:float lbl_804579F8 = .bss:0x80457BD8; // type:object size:0x18 scope:local data:4byte -lbl_80457A10 = .bss:0x80457BF0; // type:object size:0x838 scope:local -lbl_80458248 = .bss:0x80458428; // type:object size:0x108 scope:local -lbl_80458350 = .bss:0x80458530; // type:object size:0x1E58 scope:local +sAllocSpace$2944 = .bss:0x80457BF0; // type:object size:0x838 scope:local +sAllocSpace$2964 = .bss:0x80458428; // type:object size:0x108 scope:local +sAllocSpace$2980 = .bss:0x80458530; // type:object size:0x1E58 scope:local lbl_8045A1A8 = .bss:0x8045A388; // type:object size:0xF98 scope:local lbl_8045B140 = .bss:0x8045B320; // type:object size:0x40 scope:local lbl_8045B180 = .bss:0x8045B360; // type:object size:0x5C scope:local diff --git a/include/Collision/CCollisionPrimitive.hpp b/include/Collision/CCollisionPrimitive.hpp index 3085a019..1c14d871 100644 --- a/include/Collision/CCollisionPrimitive.hpp +++ b/include/Collision/CCollisionPrimitive.hpp @@ -38,14 +38,12 @@ public: const char* mInfo; }; - class Comparison { - - }; + class Comparison {}; CCollisionPrimitive(const CMaterialList& list); virtual uint GetTableIndex() const = 0; - virtual void SetMaterial(const CMaterialList&); + virtual void SetMaterial(const CMaterialList& other) { x8_material = other; } virtual const CMaterialList& GetMaterial() const; virtual CAABox CalculateAABox(const CTransform4f&) const = 0; virtual CAABox CalculateLocalAABox() const = 0; diff --git a/include/Collision/CRayCastResult.hpp b/include/Collision/CRayCastResult.hpp index 20112dd7..d37022aa 100644 --- a/include/Collision/CRayCastResult.hpp +++ b/include/Collision/CRayCastResult.hpp @@ -16,7 +16,7 @@ public: }; CRayCastResult(float time, const CVector3f& point, const CPlane& plane, const CMaterialList& list) : x0_time(time), x4_point(point), x10_plane(plane), x20_valid(kI_Valid), x28_material(list) {} - CRayCastResult(EInvalid invalid) + CRayCastResult(EInvalid invalid = kI_Invalid) : x0_time(0) , x4_point(CVector3f(0.f, 0.f, 0.f)) , x10_plane(CPlane(0.f, CUnitVector3f(1.f, 0.f, 0.f, CUnitVector3f::kN_Yes))) diff --git a/include/Kyoto/Audio/CSfxManager.hpp b/include/Kyoto/Audio/CSfxManager.hpp index faf02d2c..ff4310ab 100644 --- a/include/Kyoto/Audio/CSfxManager.hpp +++ b/include/Kyoto/Audio/CSfxManager.hpp @@ -210,8 +210,8 @@ public: static void SetDuration(CSfxHandle handle, float duration); static ushort GetReverbAmount(); - static CSfxHandle SfxStart(const ushort id, const short vol, const short pan, - const bool useAcoustics = false, const short prio = kMaxPriority, + static CSfxHandle SfxStart(const ushort id, const short vol = 127, const short pan = 64, + const bool useAcoustics = false, const short prio = kMedPriority, const bool looped = false, const int areaId = kAllAreas); static void SfxStop(CSfxHandle handle); static void SfxVolume(CSfxHandle handle, uchar volume); diff --git a/include/Kyoto/Math/CVector3f.hpp b/include/Kyoto/Math/CVector3f.hpp index 6181716f..97e2868d 100644 --- a/include/Kyoto/Math/CVector3f.hpp +++ b/include/Kyoto/Math/CVector3f.hpp @@ -55,9 +55,15 @@ public: } inline float MagSquared() const { return GetX() * GetX() + GetY() * GetY() + GetZ() * GetZ(); } static CVector3f Cross(const CVector3f& lhs, const CVector3f& rhs) { - const float x = (lhs.GetY() * rhs.GetZ()) - (rhs.GetY() * lhs.GetZ()); - const float y = (lhs.GetZ() * rhs.GetX()) - (rhs.GetZ() * lhs.GetX()); - const float z = (lhs.GetX() * rhs.GetY()) - (rhs.GetX() * lhs.GetY()); + const float lX = lhs.mX; + const float lY = lhs.mY; + const float lZ = lhs.mZ; + const float rX = rhs.mX; + const float rY = rhs.mY; + const float rZ = rhs.mZ; + float z = lX * rY - rX * lY; + float y = lZ * rX - rZ * lX; + float x = lY * rZ - rY * lZ; return CVector3f(x, y, z); } @@ -92,16 +98,9 @@ public: mZ *= v; return *this; } - CVector3f& operator/=(const float v) { - mX /= v; - mY /= v; - mZ /= v; - return *this; - } + CVector3f& operator/=(const float v) { return *this *= (1.f / v); } - CVector2f ToVec2f() const { - return CVector2f(mX, mY); - } + CVector2f ToVec2f() const { return CVector2f(mX, mY); } static float Dot(const CVector3f& a, const CVector3f& b) { return (a.GetX() * b.GetX()) + (a.GetY() * b.GetY()) + (a.GetZ() * b.GetZ()); @@ -176,11 +175,13 @@ inline CVector3f operator*(const float f, const CVector3f& vec) { } inline CVector3f operator/(const CVector3f& vec, const float f) { - float x = vec.GetX() / f; - float y = vec.GetY() / f; - float z = vec.GetZ() / f; + float n = (1.f / f); + float x = vec.GetX() * n; + float y = vec.GetY() * n; + float z = vec.GetZ() * n; return CVector3f(x, y, z); } + inline CVector3f operator-(const CVector3f& vec) { return CVector3f(-vec.GetX(), -vec.GetY(), -vec.GetZ()); } diff --git a/include/Kyoto/TAverage.hpp b/include/Kyoto/TAverage.hpp index a1969673..1613909d 100644 --- a/include/Kyoto/TAverage.hpp +++ b/include/Kyoto/TAverage.hpp @@ -7,7 +7,14 @@ #include "rstl/vector.hpp" template < typename T > -T GetAverageValue(const T* ptr, int count); // TODO +T GetAverageValue(const T* ptr, int count) { + const T* end = ptr + count; + T ret = *ptr++; + for (; ptr < end; ++ptr) { + ret = ret + *ptr; + } + return ret / count; +} template < typename T > class TAverage : rstl::vector< T > { diff --git a/include/Kyoto/TReservedAverage.hpp b/include/Kyoto/TReservedAverage.hpp index cfb2d1c7..647fffaa 100644 --- a/include/Kyoto/TReservedAverage.hpp +++ b/include/Kyoto/TReservedAverage.hpp @@ -15,14 +15,28 @@ public: TReservedAverage(const T& value) { // resize(value, N); TODO } - void AddValue(const T& value) { - this->push_back(value); - for (int i = this->size() - 1; i > 0; --i) { - this->operator[](i) = this->operator[](i - 1); - } - this->operator[](0) = value; - } + void AddValue(const T& value); rstl::optional_object< T > GetAverage() const; }; +template < typename T, int N > +/* inline */ void TReservedAverage< T, N >::AddValue(const T& value) { + if (this->size() < this->capacity()) { + this->push_back(value); + } + for (int i = this->size() - 1; i > 0; --i) { + this->operator[](i) = this->operator[](i - 1); + } + this->operator[](0) = value; +} + +template < typename T, int N > +rstl::optional_object< T > TReservedAverage< T, N >::GetAverage() const { + if (this->empty()) { + return rstl::optional_object_null(); + } else { + return GetAverageValue(this->data(), this->size()); + } +} + #endif // _TRESERVEDAVERAGE diff --git a/include/MetroidPrime/CActorParameters.hpp b/include/MetroidPrime/CActorParameters.hpp index b41fe547..8fe0c9e8 100644 --- a/include/MetroidPrime/CActorParameters.hpp +++ b/include/MetroidPrime/CActorParameters.hpp @@ -133,7 +133,7 @@ public: float GetFadeInTime() const { return x5c_fadeInTime; } float GetFadeOutTime() const { return x60_fadeOutTime; } - static CActorParameters None(); + static CActorParameters None() { return CActorParameters(); } private: CLightParameters x0_lighting; diff --git a/include/MetroidPrime/CAnimRes.hpp b/include/MetroidPrime/CAnimRes.hpp index f14725a6..f802d0bf 100644 --- a/include/MetroidPrime/CAnimRes.hpp +++ b/include/MetroidPrime/CAnimRes.hpp @@ -27,7 +27,13 @@ public: , x14_canLoop(loop) , x18_defaultAnim(defaultAnim) {} - // name? + CAssetId GetId() const { return x0_ancsId; } + // or GetBodyType__8CAnimResCFv ? + int GetCharacterNodeId() const { return x4_charIdx; } + const CVector3f& GetScale() const { return x8_scale; } + int GetDefaultAnim() const { return x18_defaultAnim; } + bool CanLoop() const { return x14_canLoop; } + static const int kDefaultCharIdx; }; CHECK_SIZEOF(CAnimRes, 0x1c) diff --git a/include/MetroidPrime/CModelData.hpp b/include/MetroidPrime/CModelData.hpp index a8211dae..3562c7a9 100644 --- a/include/MetroidPrime/CModelData.hpp +++ b/include/MetroidPrime/CModelData.hpp @@ -66,7 +66,15 @@ public: CModelData(); CModelData(const CAnimRes&); CModelData(const CStaticRes&); - CModelData(const CModelData& other); + CModelData(const CModelData& other) + : x0_scale(other.x0_scale) + , xc_animData(other.xc_animData) + , x14_24_renderSorted(other.x14_24_renderSorted) + , x14_25_sortThermal(other.x14_25_sortThermal) + , x18_ambientColor(other.x18_ambientColor) + , x1c_normalModel(other.x1c_normalModel) + , x2c_xrayModel(other.x2c_xrayModel) + , x3c_infraModel(other.x3c_infraModel) {} ~CModelData(); CAdvancementDeltas AdvanceAnimation(float dt, CStateManager& mgr, TAreaId aid, bool advTree); diff --git a/include/MetroidPrime/CPhysicsActor.hpp b/include/MetroidPrime/CPhysicsActor.hpp index 9f24fe2e..bb306c10 100644 --- a/include/MetroidPrime/CPhysicsActor.hpp +++ b/include/MetroidPrime/CPhysicsActor.hpp @@ -129,13 +129,14 @@ public: void SetAngularImpulseWR(const CAxisAngle& angularImpulse) { x180_angularImpulse = angularImpulse; } + void SetLastNonCollidingState(const CMotionState& state) { x1f4_lastNonCollidingState = state; } float GetCoefficientOfRestitutionModifier() const; void SetCoefficientOfRestitutionModifier(float modifier); float GetCollisionAccuracyModifier() const; void SetCollisionAccuracyModifier(float modifier); float GetMaximumCollisionVelocity() const; - void SetMaximumCollisionVelocity(float velocity); + void SetMaxVelocityAfterCollision(float velocity); CPhysicsState GetPhysicsState() const; void SetPhysicsState(const CPhysicsState& state); @@ -155,7 +156,7 @@ public: CVector3f GetMoveToORImpulseWR(const CVector3f& impulse, float d) const; CVector3f GetRotateToORAngularMomentumWR(const CQuaternion& q, float d) const; void RotateToWR(const CQuaternion&, float); - + void MoveInOneFrameOR(const CVector3f& trans, float d); void RotateInOneFrameOR(const CQuaternion&, float); diff --git a/include/MetroidPrime/Cameras/CFirstPersonCamera.hpp b/include/MetroidPrime/Cameras/CFirstPersonCamera.hpp index ae93c953..ecd6dba3 100644 --- a/include/MetroidPrime/Cameras/CFirstPersonCamera.hpp +++ b/include/MetroidPrime/Cameras/CFirstPersonCamera.hpp @@ -24,7 +24,7 @@ public: void SetScriptPitchId(TUniqueId uid) { x1c4_pitchId = uid; } // UpdateElevation__18CFirstPersonCameraFR13CStateManager // UpdateTransform__18CFirstPersonCameraFR13CStateManagerf - // GetGunFollowTransform__18CFirstPersonCameraCFv + const CTransform4f& GetGunFollowTransform() const; // SetLockCamera__18CFirstPersonCameraFb void CancelCinematicOffset(); diff --git a/include/MetroidPrime/Player/CGrappleArm.hpp b/include/MetroidPrime/Player/CGrappleArm.hpp index 37145684..57a2aef2 100644 --- a/include/MetroidPrime/Player/CGrappleArm.hpp +++ b/include/MetroidPrime/Player/CGrappleArm.hpp @@ -2,8 +2,11 @@ #define _CGRAPPLEARM #include "types.h" -#include "rstl/single_ptr.hpp" + #include "Kyoto/Audio/CSfxHandle.hpp" +#include "Kyoto/Math/CTransform4f.hpp" + +#include "rstl/single_ptr.hpp" class CVector3f; class CStateManager; @@ -34,6 +37,8 @@ public: void EnterStruck(CStateManager&, float, bool, bool); void DisconnectGrappleBeam(); + void SetTransform(const CTransform4f& xf) { *(CTransform4f*)(&x0_pad[0x220]) = xf; } + // EArmState GetAnimState() const { return x334_animState; } bool GetActive() const { return x3b2_24_active; } bool BeamActive() const { return x3b2_25_beamActive; } @@ -42,8 +47,8 @@ public: bool IsSuitLoading() const { return x3b2_29_suitLoading; } private: - uchar x0_pad[0x328]; - rstl::single_ptr x328_gunController; + uchar x0_pad[0x328]; // TODO + rstl::single_ptr< CGunController > x328_gunController; CSfxHandle x32c_grappleLoopSfx; CSfxHandle x330_swooshSfx; EArmState x334_animState; diff --git a/include/MetroidPrime/Player/CMorphBall.hpp b/include/MetroidPrime/Player/CMorphBall.hpp index b1675ddc..cf46876d 100644 --- a/include/MetroidPrime/Player/CMorphBall.hpp +++ b/include/MetroidPrime/Player/CMorphBall.hpp @@ -1,16 +1,33 @@ #ifndef _CMORPHBALL #define _CMORPHBALL -class CMorphBall { +#include "Kyoto/TOneStatic.hpp" +#include "Kyoto/TReservedAverage.hpp" + +#include "Collision/CCollidableSphere.hpp" +#include "Collision/CCollisionInfoList.hpp" + +class CElementGen; +class CGenDescription; +class CModelData; +class CMorphBallShadow; +class CParticleSwoosh; +class CPlayer; +class CRainSplashGenerator; +class CStateManager; +class CSwooshDescription; +class CToken; +class CWorldShadow; + +class CMorphBall : public TOneStatic< CMorphBall > { public: enum EBallBoostState { kBBS_BoostAvailable, kBBS_BoostDisabled }; - enum ESpiderBallState { kSBS_Inactive, kSBS_Active }; - enum EBombJumpState { kBJS_BombJumpAvailable, kBJS_BombJumpDisabled }; - // - + CMorphBall(CPlayer&, float); + ~CMorphBall(); + float GetBallRadius() const; EBallBoostState GetBallBoostState() const; // { return x1e3c_boostState; } @@ -18,7 +35,142 @@ public: EBombJumpState GetBombJumpState() const; // { return x1e40_bombJumpState; } void SetBombJumpState(EBombJumpState state); void LoadMorphBallModel(CStateManager& mgr); + void Update(float dt, CStateManager& mgr); + void StopSounds(); + void UpdateEffects(float dt, CStateManager& mgr); +private: + struct CSpiderBallElectricityManager { + uint x0_effectIdx; + uint x4_lifetime; + uint x8_curFrame; + CSpiderBallElectricityManager(uint effectIdx, uint lifetime) + : x0_effectIdx(effectIdx), x4_lifetime(lifetime) {} + }; + + CPlayer& x0_player; + int x4_loadedModelId; + uint x8_ballGlowColorIdx; + float xc_radius; + CVector3f x10_boostControlForce; + CVector3f x1c_controlForce; + bool x28_tireMode; + float x2c_tireLeanAngle; + float x30_ballTiltAngle; + CCollidableSphere x38_collisionSphere; + rstl::single_ptr< CModelData > x58_ballModel; + uint x5c_ballModelShader; + rstl::single_ptr< CModelData > x60_spiderBallGlassModel; + uint x64_spiderBallGlassModelShader; + rstl::single_ptr< CModelData > x68_lowPolyBallModel; + uint x6c_lowPolyBallModelShader; + rstl::single_ptr< CModelData > x70_frozenBallModel; + CCollisionInfoList x74_collisionInfos; + char xc78_[0x187c - 0xc78]; + ESpiderBallState x187c_spiderBallState; + CVector3f x1880_playerToSpiderNormal; + float x188c_spiderPullMovement; + CVector3f x1890_spiderTrackPoint; + CVector3f x189c_spiderInterpBetweenPoints; + CVector3f x18a8_spiderBetweenPoints; + float x18b4_linVelDamp; + float x18b8_angVelDamp; + bool x18bc_spiderNearby; + bool x18bd_touchingSpider; + bool x18be_spiderBallSwinging; + bool x18bf_spiderSwingInAir; + bool x18c0_isSpiderSurface; + CTransform4f x18c4_spiderSurfaceTransform; + float x18f4_spiderSurfacePivotAngle; + float x18f8_spiderSurfacePivotTargetAngle; + float x18fc_refPullVel; + float x1900_playerToSpiderTrackDist; + float x1904_swingControlDir; + float x1908_swingControlTime; + CVector2f x190c_normSpiderSurfaceForces; + float x1914_spiderTrackForceMag; + float x1918_spiderViewControlMag; + float x191c_damageTimer; + bool x1920_spiderForcesReset; + CTransform4f x1924_surfaceToWorld; + bool x1954_isProjectile; + rstl::vector< CToken > x1958_animationTokens; + TToken< CSwooshDescription > x1968_slowBlueTailSwoosh; + TToken< CSwooshDescription > x1970_slowBlueTailSwoosh2; + TToken< CSwooshDescription > x1978_jaggyTrail; + TToken< CGenDescription > x1980_wallSpark; + TToken< CGenDescription > x1988_ballInnerGlow; + TToken< CGenDescription > x1990_spiderBallMagnetEffect; + TToken< CGenDescription > x1998_boostBallGlow; + TToken< CSwooshDescription > x19a0_spiderElectric; + TToken< CGenDescription > x19a8_morphBallTransitionFlash; + TToken< CGenDescription > x19b0_effect_morphBallIceBreak; + rstl::single_ptr< CParticleSwoosh > x19b8_slowBlueTailSwooshGen; + rstl::single_ptr< CParticleSwoosh > x19bc_slowBlueTailSwooshGen2; + rstl::single_ptr< CParticleSwoosh > x19c0_slowBlueTailSwoosh2Gen; + rstl::single_ptr< CParticleSwoosh > x19c4_slowBlueTailSwoosh2Gen2; + rstl::single_ptr< CParticleSwoosh > x19c8_jaggyTrailGen; + rstl::single_ptr< CElementGen > x19cc_wallSparkGen; + rstl::single_ptr< CElementGen > x19d0_ballInnerGlowGen; + rstl::single_ptr< CElementGen > x19d4_spiderBallMagnetEffectGen; + rstl::single_ptr< CElementGen > x19d8_boostBallGlowGen; + rstl::single_ptr< CElementGen > x19dc_morphBallTransitionFlashGen; + rstl::single_ptr< CElementGen > x19e0_effect_morphBallIceBreakGen; + rstl::reserved_vector< rstl::pair< rstl::single_ptr< CParticleSwoosh >, bool >, 48 > + x19e4_spiderElectricGens; + rstl::list< CSpiderBallElectricityManager > x1b68_activeSpiderElectricList; + CRandom16 x1b80_rand; + rstl::reserved_vector< TToken< CGenDescription >, 8 > x1b84_wakeEffects; + rstl::reserved_vector< rstl::auto_ptr< CElementGen >, 8 > x1bc8_wakeEffectGens; + int x1c0c_wakeEffectIdx; + TUniqueId x1c10_ballInnerGlowLight; + rstl::single_ptr< CWorldShadow > x1c14_worldShadow; + rstl::single_ptr< CActorLights > x1c18_actorLights; + rstl::single_ptr< CRainSplashGenerator > x1c1c_rainSplashGen; + float x1c20_tireFactor; + float x1c24_maxTireFactor; + float x1c28_tireInterpSpeed; + bool x1c2c_tireInterpolating; + float x1c30_boostOverLightFactor; + float x1c34_boostLightFactor; + float x1c38_spiderLightFactor; + TReservedAverage< CQuaternion, 5 > x1c3c_ballOrientAvg; + TReservedAverage< CVector3f, 5 > x1c90_ballPosAvg; + TReservedAverage< float, 15 > x1cd0_liftSpeedAvg; + TReservedAverage< CVector3f, 15 > x1d10_liftControlForceAvg; + uint x1dc8_failsafeCounter; + CVector3f x1dcc_; + CVector3f x1dd8_; + bool x1de4_24_inBoost : 1; + bool x1de4_25_boostEnabled : 1; + float x1de8_boostChargeTime; + float x1dec_timeNotInBoost; + float x1df0_; + float x1df4_boostDrainTime; + bool x1df8_24_inHalfPipeMode : 1; + bool x1df8_25_inHalfPipeModeInAir : 1; + bool x1df8_26_touchedHalfPipeRecently : 1; + bool x1df8_27_ballCloseToCollision : 1; + float x1dfc_touchHalfPipeCooldown; + float x1e00_disableControlCooldown; + float x1e04_touchHalfPipeRecentCooldown; + CVector3f x1e08_prevHalfPipeNormal; + CVector3f x1e14_halfPipeNormal; + uint x1e20_ballAnimIdx; + CSfxHandle x1e24_boostSfxHandle; + CSfxHandle x1e28_wallHitSfxHandle; + CSfxHandle x1e2c_rollSfxHandle; + CSfxHandle x1e30_spiderSfxHandle; + ushort x1e34_rollSfx; + ushort x1e36_landSfx; + uint x1e38_wallSparkFrameCountdown; + EBallBoostState x1e3c_boostState; + EBombJumpState x1e40_bombJumpState; + float x1e44_damageEffect; + float x1e48_damageEffectDecaySpeed; + float x1e4c_damageTime; + rstl::single_ptr< CMorphBallShadow > x1e50_shadow; }; +CHECK_SIZEOF(CMorphBall, 0x1e58); #endif // _CMORPHBALL diff --git a/include/MetroidPrime/Player/CPlayer.hpp b/include/MetroidPrime/Player/CPlayer.hpp index 3215510a..e01df554 100644 --- a/include/MetroidPrime/Player/CPlayer.hpp +++ b/include/MetroidPrime/Player/CPlayer.hpp @@ -15,7 +15,6 @@ #include "rstl/vector.hpp" class CPlayerGun; -class CFailsafeTest; class CMorphBall; class CPlayerCameraBob; @@ -45,7 +44,7 @@ enum EPlayerOrbitRequest { kOR_LostGrappleLineOfSight, }; -class CPlayer : public CPhysicsActor { +class CPlayer : public CPhysicsActor, public TOneStatic< CPlayer > { struct CVisorSteam { float x0_curTargetAlpha; float x4_curAlphaInDur; @@ -60,11 +59,11 @@ class CPlayer : public CPhysicsActor { bool x28_affectsThermal; public: - CVisorSteam(float targetAlpha, float alphaInDur, float alphaOutDur, CAssetId tex) - : x0_curTargetAlpha(targetAlpha) - , x4_curAlphaInDur(alphaInDur) - , x8_curAlphaOutDur(alphaOutDur) - , xc_tex(tex) {} + CVisorSteam(float targetAlpha, float alphaInDur, float alphaOutDur, CAssetId tex); + // : x0_curTargetAlpha(targetAlpha) + // , x4_curAlphaInDur(alphaInDur) + // , x8_curAlphaOutDur(alphaOutDur) + // , xc_tex(tex) {} CAssetId GetTextureId() const { return xc_tex; } void SetSteam(float targetAlpha, float alphaInDur, float alphaOutDur, CAssetId txtr, bool affectsThermal); @@ -79,11 +78,12 @@ class CPlayer : public CPhysicsActor { void AddSample(int, const CVector3f&, const CVector3f&, const CVector2f&); bool Passes(); void Reset(); + private: - rstl::reserved_vector x0_; - rstl::reserved_vector x54_; - rstl::reserved_vector x148_; - rstl::reserved_vector x23c_; + rstl::reserved_vector< int, 20 > x0_; + rstl::reserved_vector< CVector3f, 20 > x54_; + rstl::reserved_vector< CVector3f, 20 > x148_; + rstl::reserved_vector< CVector2f, 20 > x23c_; }; public: @@ -156,6 +156,10 @@ public: kGH_Holstering, }; + CPlayer(TUniqueId uid, const CTransform4f& xf, const CAABox& aabb, CAssetId resId, + const CVector3f& playerScale, float mass, float stepUp, float stepDown, float ballRadius, + const CMaterialList& ml); + // CEntity ~CPlayer() override; void Accept(IVisitor& visitor) override; @@ -211,11 +215,39 @@ public: void SetOrbitRequestForTarget(TUniqueId id, EPlayerOrbitRequest req, CStateManager& mgr); void AddOrbitDisableSource(CStateManager& mgr, TUniqueId addId); void RemoveOrbitDisableSource(TUniqueId uid); - void ResetAimTargetPrediction(TUniqueId target); + void SetAimTargetId(TUniqueId target); void DoSfxEffects(CSfxHandle sfx); void UnFreeze(CStateManager& mgr); void UpdateCinematicState(CStateManager& mgr); bool IsMorphBallTransitioning() const; + void InitialiseAnimation(); + void LoadAnimationTokens(); + void HolsterGun(CStateManager& mgr); + void ResetGun(CStateManager& mgr); + void DrawGun(CStateManager& mgr); + bool CheckPostGrapple() const; + void UpdateGunState(const CFinalInput& input, CStateManager& mgr); + void UpdateAimTargetPrediction(const CTransform4f& xf, CStateManager& mgr); + void UpdateAssistedAiming(const CTransform4f& xf, CStateManager& mgr); + void UpdateGunTransform(const CVector3f& gunPos, CStateManager& mgr); + const CTransform4f& GetFirstPersonCameraTransform(CStateManager& mgr) const; + void UpdateDebugCamera(CStateManager& mgr); + void UpdateArmAndGunTransforms(float dt, CStateManager& mgr); + void UpdateGrappleArmTransform(const CVector3f& offset, CStateManager& mgr, float dt); + void ForceGunOrientation(const CTransform4f& xf, CStateManager& mgr); + void Update(float dt, CStateManager& mgr); + void UpdateMorphBallTransition(float dt, CStateManager& mgr); + void ApplySubmergedPitchBend(CSfxHandle sfx); + void UpdateAimTarget(CStateManager& mgr); + void UpdateAimTargetTimer(float dt); + void UpdateOrbitModeTimer(float dt); + void UpdateOrbitPreventionTimer(float dt); + void UpdateGunAlpha(); + void UpdateVisorTransition(float dt, CStateManager& mgr); + void UpdatePlayerSounds(float dt); + bool ShouldSampleFailsafe(CStateManager& mgr); + bool IsEnergyLow(CStateManager& mgr); + bool StartSamusVoiceSfx(ushort sfx, short vol, int prio); CPlayerGun* PlayerGun() { return x490_gun.get(); } const CPlayerGun* GetPlayerGun() const { return x490_gun.get(); } @@ -237,10 +269,12 @@ public: EGrappleState GetGrappleState() const { return x3b8_grappleState; } bool IsInFreeLook() const { return x3dc_inFreeLook; } bool GetFreeLookStickState() const { return x3de_lookAnalogHeld; } + TUniqueId GetAimTargetId() const { return x3f4_aimTarget; } EPlayerCameraState GetCameraState() const { return x2f4_cameraState; } void SetCameraState(EPlayerCameraState state, CStateManager& mgr); EGunHolsterState GetGunHolsterState() const { return x498_gunHolsterState; } NPlayer::EPlayerMovementState GetPlayerMovementState() const { return x258_movementState; } + const CVector3f& GetAssistedTargetAim() const { return x480_assistedTargetAim; } void Teleport(const CTransform4f& xf, CStateManager& mgr, bool resetBallCam); void SetSpawnedMorphBallState(EPlayerMorphBallState state, CStateManager& mgr); @@ -342,7 +376,7 @@ private: float x494_gunAlpha; EGunHolsterState x498_gunHolsterState; float x49c_gunHolsterRemTime; - rstl::single_ptr< CFailsafeTest > x4a0_failsafeTest; + rstl::single_ptr< CInputFilter > x4a0_inputFilter; TReservedAverage< float, 20 > x4a4_moveSpeedAvg; float x4f8_moveSpeed; float x4fc_flatMoveSpeed; @@ -395,10 +429,7 @@ private: CVector3f x794_lastVelocity; CVisorSteam x7a0_visorSteam; CPlayerState::EPlayerSuit x7cc_transitionSuit; - rstl::auto_ptr< CAnimRes > x7d0_animRes; - CVector3f x7d8_beamScale; - bool x7e4_; - uint x7e8_; + CAnimRes x7d0_animRes; CPlayerState::EBeamId x7ec_beam; rstl::single_ptr< CModelData > x7f0_ballTransitionBeamModel; CTransform4f x7f4_gunWorldXf; diff --git a/include/MetroidPrime/Player/CPlayerCameraBob.hpp b/include/MetroidPrime/Player/CPlayerCameraBob.hpp index afe552c7..5a633aa5 100644 --- a/include/MetroidPrime/Player/CPlayerCameraBob.hpp +++ b/include/MetroidPrime/Player/CPlayerCameraBob.hpp @@ -6,12 +6,13 @@ #include "Kyoto/Math/CTransform4f.hpp" #include "Kyoto/Math/CVector2f.hpp" #include "Kyoto/Math/CVector3f.hpp" +#include "Kyoto/TOneStatic.hpp" #include "rstl/reserved_vector.hpp" class CStateManager; -class CPlayerCameraBob { +class CPlayerCameraBob : public TOneStatic< CPlayerCameraBob > { public: enum ECameraBobType { kCBT_Zero, @@ -29,7 +30,37 @@ public: kCBS_Unspecified, }; - CPlayerCameraBob(ECameraBobType type, const CVector2f& vec, float bobPeriod); + static float kCameraBobExtentX; + static float kCameraBobExtentY; + static float kCameraBobPeriod; + static float kOrbitBobScale; + static float kMaxOrbitBobScale; + static float kSlowSpeedPeriodScale; + static float kTargetMagnitudeTrackingRate; + static float kLandingBobSpringConstant; + static float lbl_805A7398; + static float lbl_805A739C; + static float kLandingBobSpringConstant2; + static float lbl_805A73A4; + static float kViewWanderRadius; + static float kViewWanderSpeedMin; + static float kViewWanderSpeedMax; + static float kViewWanderRollVariation; + static float kGunBobMagnitude; + static float kHelmetBobMagnitude; + static float kLandingBobDamping; + static float kLandingBobDamping2; + static float kCameraDamping; + static float lbl_805A73C0; + static float lbl_805A73C4; + static float lbl_805A73C8; + static float lbl_805A73CC; + static float lbl_805A73D0; + static float lbl_805A73D4; + + CPlayerCameraBob(ECameraBobType type, + const CVector2f& vec = CVector2f(kCameraBobExtentX, kCameraBobExtentY), + float bobPeriod = kCameraBobPeriod); CTransform4f GetViewWanderTransform() const; CVector3f GetHelmetBobTranslation() const; @@ -85,35 +116,6 @@ private: CTransform4f xd0_viewWanderXf; float x100_wanderMagnitude; float x104_targetWanderMagnitude; - -public: - static float kCameraBobExtentX; - static float kCameraBobExtentY; - static float kCameraBobPeriod; - static float kOrbitBobScale; - static float kMaxOrbitBobScale; - static float kSlowSpeedPeriodScale; - static float kTargetMagnitudeTrackingRate; - static float kLandingBobSpringConstant; - static float lbl_805A7398; - static float lbl_805A739C; - static float kLandingBobSpringConstant2; - static float lbl_805A73A4; - static float kViewWanderRadius; - static float kViewWanderSpeedMin; - static float kViewWanderSpeedMax; - static float kViewWanderRollVariation; - static float kGunBobMagnitude; - static float kHelmetBobMagnitude; - static float kLandingBobDamping; - static float kLandingBobDamping2; - static float kCameraDamping; - static float lbl_805A73C0; - static float lbl_805A73C4; - static float lbl_805A73C8; - static float lbl_805A73CC; - static float lbl_805A73D0; - static float lbl_805A73D4; }; CHECK_SIZEOF(CPlayerCameraBob, 0x108) diff --git a/include/MetroidPrime/Player/CPlayerEnergyDrain.hpp b/include/MetroidPrime/Player/CPlayerEnergyDrain.hpp index 87f22916..6d738fdc 100644 --- a/include/MetroidPrime/Player/CPlayerEnergyDrain.hpp +++ b/include/MetroidPrime/Player/CPlayerEnergyDrain.hpp @@ -20,6 +20,15 @@ private: }; class CPlayerEnergyDrain { +public: + CPlayerEnergyDrain(uint numSources); + + void AddEnergyDrainSource(TUniqueId id, float intensity); + void RemoveEnergyDrainSource(TUniqueId id); + float GetEnergyDrainIntensity() const; + float GetEnergyDrainTime() const { return x10_energyDrainTime; } + void ProcessEnergyDrain(const CStateManager& mgr, float dt); + private: rstl::vector< CEnergyDrainSource > x0_sources; float x10_energyDrainTime; diff --git a/include/MetroidPrime/Player/CPlayerGun.hpp b/include/MetroidPrime/Player/CPlayerGun.hpp index 26a3e851..b10dd5ce 100644 --- a/include/MetroidPrime/Player/CPlayerGun.hpp +++ b/include/MetroidPrime/Player/CPlayerGun.hpp @@ -171,8 +171,9 @@ public: void SetFidgetAnimBits(int, bool); void AsyncLoadSuit(CStateManager&); void ReturnToRestPose(); - void DropPowerBomb(CStateManager&) const; + TUniqueId DropPowerBomb(CStateManager&) const; void SetPhazonBeamFeedback(bool); + void SetAssistAimTransform(const CTransform4f& xf) { x478_assistAimXf = xf; } float GetChargeBeamFactor() const { return x834_24_charging ? x340_chargeBeamFactor : 0.f; } @@ -181,6 +182,9 @@ public: int GetStateFlags() const { return x2f8_stateFlags; } void SetStateFlags(int flags) { x2f8_stateFlags = flags; } bool IsCharging() const { return x834_24_charging; } + void SetTransform(CTransform4f xf) { x3e8_xf = xf; } + CGrappleArm& GetGrappleArm() const { return *x740_grappleArm.get(); } + bool IsFidgeting() const { return x833_24_notFidgeting; } private: class CGunMorph { diff --git a/include/MetroidPrime/Player/CPlayerState.hpp b/include/MetroidPrime/Player/CPlayerState.hpp index 757dcd1a..ed4a6291 100644 --- a/include/MetroidPrime/Player/CPlayerState.hpp +++ b/include/MetroidPrime/Player/CPlayerState.hpp @@ -123,7 +123,7 @@ public: void UpdateVisorTransition(float dt); void StartTransitionToVisor(EPlayerVisor visor); void ResetVisor(); - bool IsPlayerAlive() const { return x0_24_alive; } + bool IsAlive() const { return x0_24_alive; } bool ItemEnabled(EItemType type) const; void DisableItem(EItemType type); diff --git a/include/MetroidPrime/TGameTypes.hpp b/include/MetroidPrime/TGameTypes.hpp index 44b2e4e3..aec51c1a 100644 --- a/include/MetroidPrime/TGameTypes.hpp +++ b/include/MetroidPrime/TGameTypes.hpp @@ -54,6 +54,7 @@ struct TUniqueId { bool operator==(const TUniqueId& other) const { return value == other.value; } bool operator!=(const TUniqueId& other) const { return value != other.value; } bool operator<(const TUniqueId& other) const { return value < other.value; } + operator bool() const { return *this != kInvalidUniqueId; } private: }; diff --git a/include/MetroidPrime/Tweaks/CTweakPlayer.hpp b/include/MetroidPrime/Tweaks/CTweakPlayer.hpp index c845d7ad..a709e949 100644 --- a/include/MetroidPrime/Tweaks/CTweakPlayer.hpp +++ b/include/MetroidPrime/Tweaks/CTweakPlayer.hpp @@ -155,7 +155,7 @@ public: float GetGravityDamageReduction() const { return x304_gravityDamageReduction; } float GetPhazonDamageReduction() const { return x308_phazonDamageReduction; } -private: +// private: float x4_maxTranslationalAcceleration[8]; float x24_maxRotationalAcceleration[8]; float x44_translationFriction[8]; diff --git a/include/MetroidPrime/Tweaks/CTweakPlayerGun.hpp b/include/MetroidPrime/Tweaks/CTweakPlayerGun.hpp index 15bd26f3..01848dfe 100644 --- a/include/MetroidPrime/Tweaks/CTweakPlayerGun.hpp +++ b/include/MetroidPrime/Tweaks/CTweakPlayerGun.hpp @@ -91,7 +91,7 @@ public: const SWeaponInfo& GetBeamInfo(int beam) const; -private: +// private: float x4_upLookAngle; float x8_downLookAngle; float xc_verticalSpread; diff --git a/include/MetroidPrime/Tweaks/CTweakPlayerRes.hpp b/include/MetroidPrime/Tweaks/CTweakPlayerRes.hpp index 03b7f267..a6dc001c 100644 --- a/include/MetroidPrime/Tweaks/CTweakPlayerRes.hpp +++ b/include/MetroidPrime/Tweaks/CTweakPlayerRes.hpp @@ -1,21 +1,24 @@ #ifndef _CTWEAKPLAYERRES #define _CTWEAKPLAYERRES -#include +#include "MetroidPrime/Player/CPlayerState.hpp" +#include "MetroidPrime/Tweaks/ITweakObject.hpp" #include "Kyoto/SObjectTag.hpp" -struct CTweakPlayerRes : public ITweakObject, public TOneStatic { +struct CTweakPlayerRes : public ITweakObject, public TOneStatic< CTweakPlayerRes > { public: -/* - CAssetId x4_saveStationIcon; - CAssetId x8_missileStationIcon; - CAssetId xc_elevatorIcon; - CAssetId x10_minesBreakFirstTopIcon; - CAssetId x14_minesBreakFirstBottomIcon; -*/ + /* + CAssetId x4_saveStationIcon; + CAssetId x8_missileStationIcon; + CAssetId xc_elevatorIcon; + CAssetId x10_minesBreakFirstTopIcon; + CAssetId x14_minesBreakFirstBottomIcon; + */ char cls[0xf0]; CTweakPlayerRes(CInputStream& in); + + CAssetId GetBallTransitionBeamResId(CPlayerState::EBeamId id) const; }; extern CTweakPlayerRes* gpTweakPlayerRes; diff --git a/libc/math.h b/libc/math.h index 683a3513..a732edab 100644 --- a/libc/math.h +++ b/libc/math.h @@ -80,7 +80,7 @@ _MATH_INLINE float fmodf(float x, float m) { return (float)fmod((double)x, (doub float tanf(float x); double asin(double x); double acos(double x); -float acosf(float x); +_MATH_INLINE float acosf(float x) { return (float)acos((double)x); } double log(double x); double exp(double x); diff --git a/src/Kyoto/Graphics/CLight.cpp b/src/Kyoto/Graphics/CLight.cpp index adea10ee..0294c478 100644 --- a/src/Kyoto/Graphics/CLight.cpp +++ b/src/Kyoto/Graphics/CLight.cpp @@ -159,5 +159,5 @@ CVector3f CLight::GetNormalIndependentLightingAtPoint(const CVector3f& point) co return floatCol; float dist = rstl::max_val((x0_pos - point).Magnitude(), gkEpsilon32); - return floatCol * (1.f / (dist * (x2c_distQ * dist) + (x28_distL * dist + x24_distC))); + return floatCol / (dist * (x2c_distQ * dist) + (x28_distL * dist + x24_distC)); } diff --git a/src/Kyoto/Particles/CModVectorElement.cpp b/src/Kyoto/Particles/CModVectorElement.cpp index 333aa946..c0acc3ee 100644 --- a/src/Kyoto/Particles/CModVectorElement.cpp +++ b/src/Kyoto/Particles/CModVectorElement.cpp @@ -172,7 +172,7 @@ bool CMVEImplosion::GetValue(int frame, CVector3f& pVel, CVector3f& pPos) const return false; } - CVector3f dvs = (1.f / dvm) * dv; + CVector3f dvs = dv / dvm; float b; x8_magScale->GetValue(frame, b); pVel += b * dvs; @@ -213,7 +213,7 @@ bool CMVELinearImplosion::GetValue(int frame, CVector3f& pVel, CVector3f& pPos) return false; } - CVector3f dvs = (1.f / dvm) * dv; + CVector3f dvs = dv / dvm; float b; x8_magScale->GetValue(frame, b); pVel = b * dvs; @@ -254,7 +254,7 @@ bool CMVEExponentialImplosion::GetValue(int frame, CVector3f& pVel, CVector3f& p return false; } - CVector3f dvs = (1.f / dvm) * dv; + CVector3f dvs = dv / dvm; float b; x8_magScale->GetValue(frame, b); pVel += dvm * (b * dvs); @@ -285,10 +285,10 @@ bool CMVESwirl::GetValue(int frame, CVector3f& pVel, CVector3f& pPos) const { xc_filterGain->GetValue(frame, c); x10_tangentialVelocity->GetValue(frame, d); - CVector3f cross = CVector3f::Cross(b, posToHelix); + // CVector3f cross = ; pVel = c * ( b * CVector3f::Dot(b, pVel) + - d * cross + d * CVector3f::Cross(b, posToHelix) ) + (1.f - c) * pVel; return false; } diff --git a/src/MetroidPrime/BodyState/CBodyController.cpp b/src/MetroidPrime/BodyState/CBodyController.cpp index 7f4bc527..4ed1a5fe 100644 --- a/src/MetroidPrime/BodyState/CBodyController.cpp +++ b/src/MetroidPrime/BodyState/CBodyController.cpp @@ -192,7 +192,7 @@ void CBodyController::UnFreeze() { x0_actor->SetVolume(127); CPhysicsActor* act = TCastToPtr< CPhysicsActor >(GetOwner()); act->SetConstantForceWR(x314_backedUpForce); - act->SetVelocityWR(x314_backedUpForce * (1.f / act->GetMass())); + act->SetVelocityWR(x314_backedUpForce / act->GetMass()); } float CBodyController::GetPercentageFrozen() const { diff --git a/src/MetroidPrime/CPhysicsActor.cpp b/src/MetroidPrime/CPhysicsActor.cpp index b8ea648c..463a4b71 100644 --- a/src/MetroidPrime/CPhysicsActor.cpp +++ b/src/MetroidPrime/CPhysicsActor.cpp @@ -234,17 +234,17 @@ void CPhysicsActor::UseCollisionImpulses() { } void CPhysicsActor::MoveToWR(const CVector3f& trans, float d) { - xfc_constantForce = (trans - GetTransform().GetTranslation()) * GetMass() * (1.f / d); + xfc_constantForce = (trans - GetTransform().GetTranslation()) * GetMass() / d; ComputeDerivedQuantities(); } void CPhysicsActor::MoveToInOneFrameWR(const CVector3f& trans, float d) { - x18c_moveImpulse += (trans - GetTranslation()) * GetMass() * (1.f / d); + x18c_moveImpulse += (trans - GetTranslation()) * GetMass() / d; } CVector3f CPhysicsActor::GetMoveToORImpulseWR(const CVector3f& trans, float d) const { CVector3f impulse = GetTransform().Rotate(trans); - return (GetMass() * impulse) * (1.f / d); + return (GetMass() * impulse) / d; } CVector3f CPhysicsActor::GetRotateToORAngularMomentumWR(const CQuaternion& q, float d) const { @@ -396,6 +396,6 @@ void CPhysicsActor::SetCollisionAccuracyModifier(float modifier) { float CPhysicsActor::GetMaximumCollisionVelocity() const { return x238_maximumCollisionVelocity; } -void CPhysicsActor::SetMaximumCollisionVelocity(float velocity) { +void CPhysicsActor::SetMaxVelocityAfterCollision(float velocity) { x238_maximumCollisionVelocity = velocity; } diff --git a/src/MetroidPrime/CVisorFlare.cpp b/src/MetroidPrime/CVisorFlare.cpp index 9c9374fe..bf8d5db9 100644 --- a/src/MetroidPrime/CVisorFlare.cpp +++ b/src/MetroidPrime/CVisorFlare.cpp @@ -65,7 +65,7 @@ void CVisorFlare::Update(float dt, const CVector3f& pos, const CActor* act, CSta CVector3f camPos = mgr.GetCameraManager()->GetCurrentCamera(mgr).GetTranslation(); CVector3f camDiff = pos - camPos; float mag = camDiff.Magnitude(); - camDiff *= (1.f / mag); + camDiff /= mag; CMaterialFilter nearMaterialList = CMaterialFilter::MakeInclude(CMaterialList(kMT_Occluder)); TEntityList nearVec; diff --git a/src/MetroidPrime/Cameras/CBallCamera.cpp b/src/MetroidPrime/Cameras/CBallCamera.cpp index c3c3bea2..be95d8f4 100644 --- a/src/MetroidPrime/Cameras/CBallCamera.cpp +++ b/src/MetroidPrime/Cameras/CBallCamera.cpp @@ -342,7 +342,7 @@ void CBallCamera::UpdateColliders(const CTransform4f& xf, } colliderList[idx].SetRealPosition(worldPos); colliderList[idx].SetPosition(localPos); - CVector3f scaledWorldColliderPos = centerToCollider * mag * (1.f / tolerance); + CVector3f scaledWorldColliderPos = centerToCollider * mag / tolerance; scaledWorldColliderPos *= x308_speedFactor; scaledWorldColliderPos += x31c_predictedLookPos; colliderList[idx].SetLookAtPosition(scaledWorldColliderPos); diff --git a/src/MetroidPrime/Player/CPlayer.cpp b/src/MetroidPrime/Player/CPlayer.cpp new file mode 100644 index 00000000..2571e5f9 --- /dev/null +++ b/src/MetroidPrime/Player/CPlayer.cpp @@ -0,0 +1,805 @@ +#include "MetroidPrime/Player/CPlayer.hpp" + +#include "MetroidPrime/CActorParameters.hpp" +#include "MetroidPrime/CControlMapper.hpp" +#include "MetroidPrime/CWorld.hpp" +#include "MetroidPrime/Cameras/CCameraManager.hpp" +#include "MetroidPrime/Cameras/CFirstPersonCamera.hpp" +#include "MetroidPrime/Player/CGrappleArm.hpp" +#include "MetroidPrime/Player/CMorphBall.hpp" +#include "MetroidPrime/Player/CPlayerCameraBob.hpp" +#include "MetroidPrime/Player/CPlayerGun.hpp" +#include "MetroidPrime/SFX/LavaWorld.h" +#include "MetroidPrime/SFX/MiscSamus.h" +#include "MetroidPrime/Tweaks/CTweakPlayer.hpp" +#include "MetroidPrime/Tweaks/CTweakPlayerGun.hpp" +#include "MetroidPrime/Tweaks/CTweakPlayerRes.hpp" + +#include "Kyoto/Audio/CSfxManager.hpp" +#include "Kyoto/Audio/CStreamAudioManager.hpp" +#include "Kyoto/Math/CRelAngle.hpp" + +#include "Collision/CCollisionInfo.hpp" +#include "Collision/CRayCastResult.hpp" + +#include "rstl/math.hpp" + +static CVector3f testRayStart(0.f, 0.f, 0.f); +static CVector3f testRayNormal(0.f, 0.f, 1.f); +static CRayCastResult testRayResult; +static CCollisionInfo testBoxResult; +static CAABox testBox(CAABox::Identity()); +typedef rstl::pair< CPlayerState::EItemType, ControlMapper::ECommands > TVisorToItemMapping; +static TVisorToItemMapping skVisorToItemMapping[4] = { + TVisorToItemMapping(CPlayerState::kIT_CombatVisor, ControlMapper::kC_NoVisor), + TVisorToItemMapping(CPlayerState::kIT_XRayVisor, ControlMapper::kC_XrayVisor), + TVisorToItemMapping(CPlayerState::kIT_ThermalVisor, ControlMapper::kC_EnviroVisor), + TVisorToItemMapping(CPlayerState::kIT_ScanVisor, ControlMapper::kC_ThermoVisor), +}; + +static const ushort skPlayerLandSfxSoft[24] = { + 0xFFFF, + SFXsam_landstone_00, + SFXsam_landmetl_00, + SFXsam_landgrass_00, + SFXsam_landice_00, + 0xFFFF, + SFXsam_landgrate_00, + SFXsam_landphazon_00, + SFXsam_landdirt_00, + SFXlav_landlava_00, + SFXsam_landlavastone_00, + SFXsam_landsnow_00, + SFXsam_landmud_00, + 0xFFFF, + SFXsam_landgrass_00, + SFXsam_landmetl_00, + SFXsam_landmetl_00, + SFXsam_landdirt_00, + 0xFFFF, + 0xFFFF, + 0xFFFF, + 0xFFFF, + SFXsam_landwood_00, + SFXsam_b_landorg_00, +}; + +static const ushort skPlayerLandSfxHard[24] = { + 0xFFFF, + SFXsam_landstone_02, + SFXsam_b_landmetl_02, + SFXsam_landgrass_02, + SFXsam_landice_02, + 0xFFFF, + SFXsam_landgrate_02, + SFXsam_landphazon_02, + SFXsam_landdirt_02, + SFXlav_landlava_02, + SFXsam_landlavastone_02, + SFXsam_landsnow_02, + SFXsam_landmud_02, + 0xFFFF, + SFXsam_landgrass_02, + SFXsam_b_landmetl_02, + SFXsam_b_landmetl_02, + SFXsam_landdirt_02, + 0xFFFF, + 0xFFFF, + 0xFFFF, + 0xFFFF, + SFXsam_landwood_02, + SFXsam_landorg_02, +}; + +static const ushort skLeftStepSounds[24] = { + 0xFFFF, + SFXsam_wlkstone_00, + SFXsam_wlkmetal_00, + SFXsam_b_wlkgrass_00, + SFXsam_wlkice_00, + 0xFFFF, + SFXsam_wlkgrate_00, + SFXsam_wlkphazon_00, + SFXsam_wlkdirt_00, + SFXlav_wlklava_00, + SFXsam_wlklavastone_00, + SFXsam_wlksnow_00, + SFXsam_wlkmud_00, + 0xFFFF, + SFXsam_b_wlkorg_00, + SFXsam_wlkmetal_00, + SFXsam_wlkmetal_00, + SFXsam_wlkdirt_00, + 0xFFFF, + 0xFFFF, + 0xFFFF, + 0xFFFF, + SFXsam_wlkwood_00, + SFXsam_b_wlkorg_00, +}; + +static const ushort skRightStepSounds[24] = { + 0xFFFF, + SFXsam_wlkstone_01, + SFXsam_wlkmetal_01, + SFXsam_b_wlkgrass_01, + SFXsam_wlkice_01, + 0xFFFF, + SFXsam_wlkgrate_01, + SFXsam_wlkphazon_01, + SFXsam_wlkdirt_01, + SFXlav_wlklava_01, + SFXsam_wlklavastone_01, + SFXsam_wlksnow_01, + SFXsam_wlkmud_01, + 0xFFFF, + SFXsam_b_wlkorg_01, + SFXsam_wlkmetal_01, + SFXsam_wlkmetal_01, + SFXsam_wlkdirt_01, + 0xFFFF, + 0xFFFF, + 0xFFFF, + 0xFFFF, + SFXsam_wlkwood_01, + SFXsam_b_wlkorg_01, +}; + +static const char* const kGunLocator = "GUN_LCTR"; + +CAnimRes MakePlayerAnimres(CAssetId resId, const CVector3f& scale) { + return CAnimRes(resId, CAnimRes::kDefaultCharIdx, scale, 0, true); +} + +CPlayer::CPlayer(TUniqueId uid, const CTransform4f& xf, const CAABox& aabb, CAssetId resId, + const CVector3f& playerScale, float mass, float stepUp, float stepDown, + float ballRadius, const CMaterialList& ml) +: CPhysicsActor(uid, true, rstl::string_l("CPlayer"), + CEntityInfo(kInvalidAreaId, CEntity::NullConnectionList), xf, + MakePlayerAnimres(resId, playerScale), ml, aabb, SMoverData(mass), + CActorParameters::None(), stepUp, stepDown) +, x258_movementState(NPlayer::kMS_OnGround) +, x25c_ballTransitionsRes() +, x26c_attachedActor(kInvalidUniqueId) +, x270_attachedActorTime(0.f) +, x274_energyDrain(4) +, x288_startingJumpTimeout(0.f) +, x28c_sjTimer(0.f) +, x290_minJumpTimeout(0.f) +, x294_jumpCameraTimer(0.f) +, x298_jumpPresses(0) +, x29c_fallCameraTimer(0.f) +, x2a0_(0.f) +, x2a4_cancelCameraPitch(false) +, x2a8_timeSinceJump(1000.f) +, x2ac_surfaceRestraint(kSR_Normal) +, x2b0_outOfWaterTicks(2) +, x2b4_accelerationTable() +, x2d0_curAcceleration(1) +, x2d4_accelerationChangeTimer(0.f) +, x2d8_fpBounds(aabb) +, x2f0_ballTransHeight(1.f) +, x2f4_cameraState(kCS_FirstPerson) +, x2f8_morphBallState(kMS_Unmorphed) +, x2fc_spawnedMorphBallState(kMS_Unmorphed) +, x300_fallingTime(0.f) +, x304_orbitState(kOS_NoOrbit) +, x308_orbitType(kOT_Close) +, x30c_orbitRequest(kOR_Default) +, x310_orbitTargetId(kInvalidUniqueId) +, x314_orbitPoint(0.f, 0.f, 0.f) +, x320_orbitVector(0.f, 0.f, 0.f) +, x32c_orbitModeTimer(0.f) +, x330_orbitZoneMode(kZI_Targeting) +, x334_orbitType(kZT_Ellipse) +, x338_(1) +, x33c_orbitNextTargetId(kInvalidUniqueId) +, x340_(0.f) +, x344_nearbyOrbitObjects() +, x354_onScreenOrbitObjects() +, x364_offScreenOrbitObjects() +, x374_orbitLockEstablished(false) +, x378_orbitPreventionTimer(0.f) +, x37c_sidewaysDashing(false) +, x380_strafeInputAtDash(0.f) +, x384_dashTimer(0.f) +, x388_dashButtonHoldTime(0.f) +, x38c_doneSidewaysDashing(false) +, x390_orbitSource(2) +, x394_orbitingEnemy(false) +, x398_dashSpeedMultiplier(1.5f) +, x39c_noStrafeDashBlend(false) +, x3a0_dashDuration(0.5f) +, x3a4_strafeDashBlendDuration(0.449f) +, x3a8_scanState(kSS_NotScanning) +, x3ac_scanningTime(0.f) +, x3b0_curScanTime(0.f) +, x3b4_scanningObject(kInvalidUniqueId) +, x3b8_grappleState(kGS_None) +, x3bc_grappleSwingTimer(0.f) +, x3c0_grappleSwingAxis(0.f, 1.f, 0.f) +, x3cc_(0.f) +, x3d0_(0.f) +, x3d4_(0.f) +, x3d8_grappleJumpTimeout(0.f) +, x3dc_inFreeLook(false) +, x3dd_lookButtonHeld(false) +, x3de_lookAnalogHeld(false) +, x3e0_curFreeLookCenteredTime(0.f) +, x3e4_freeLookYawAngle(0.f) +, x3e8_horizFreeLookAngleVel(0.f) +, x3ec_freeLookPitchAngle(0.f) +, x3f0_vertFreeLookAngleVel(0.f) +, x3f4_aimTarget(kInvalidUniqueId) +, x3f8_targetAimPosition(CVector3f::Zero()) +, x404_aimTargetAverage() +, x480_assistedTargetAim(CVector3f::Zero()) +, x48c_aimTargetTimer(0.f) +, x490_gun(rs_new CPlayerGun(uid)) +, x494_gunAlpha(1.f) +, x498_gunHolsterState(kGH_Drawn) +, x49c_gunHolsterRemTime(gpTweakPlayerGun->x40_gunNotFiringTime) +, x4a0_inputFilter(rs_new CInputFilter()) +, x4a4_moveSpeedAvg() +, x4f8_moveSpeed(0.f) +, x4fc_flatMoveSpeed(0.f) +, x500_lookDir(GetTransform().GetColumn(kDY)) +, x50c_moveDir(GetTransform().GetColumn(kDY)) +, x518_leaveMorphDir(GetTransform().GetColumn(kDY)) +, x524_lastPosForDirCalc(GetTransform().GetTranslation()) +, x530_gunDir(GetTransform().GetColumn(kDY)) +, x53c_timeMoving(0.f) +, x540_controlDir(GetTransform().GetColumn(kDY)) +, x54c_controlDirFlat(GetTransform().GetColumn(kDY)) +, x558_wasDamaged(false) +, x55c_damageAmt(0.f) +, x560_prevDamageAmt(0.f) +, x564_damageLocation(CVector3f::Zero()) +, x570_immuneTimer(0.f) +, x574_morphTime(0.f) +, x578_morphDuration(0.f) +, x57c_(0) +, x580_(0) +, x584_ballTransitionAnim(-1) +, x588_alpha(1.f) +, x58c_transitionVel(0.f) +, x590_leaveMorphballAllowed(true) +, x594_transisionBeamXfs() +, x658_transitionModelXfs() +, x71c_transitionModelAlphas() +, x730_transitionModels() +, x740_staticTimer(0.f) +, x744_staticOutSpeed(0.f) +, x748_staticInSpeed(0.f) +, x74c_visorStaticAlpha(1.f) +, x750_frozenTimeout(0.f) +, x754_iceBreakJumps(0) +, x758_frozenTimeoutBias(0.f) +, x75c_additionalIceBreakJumps(0) +, x760_controlsFrozen(false) +, x764_controlsFrozenTimeout(0.f) +, x768_morphball() +, x76c_cameraBob(rs_new CPlayerCameraBob(CPlayerCameraBob::kCBT_One)) +, x770_damageLoopSfx() +, x774_samusVoiceTimeout(0.f) +, x778_dashSfx() +, x77c_samusVoiceSfx() +, x780_samusVoicePriority(0) +, x784_damageSfxTimer(0.f) +, x788_damageLoopSfxId(0) +, x78c_footstepSfxTimer(0.f) +, x790_footstepSfxSel(kFS_None) +, x794_lastVelocity(CVector3f::Zero()) +, x7a0_visorSteam(0.f, 0.f, 0.f, kInvalidAssetId) +, x7cc_transitionSuit(CPlayerState::kPS_Invalid) +, x7d0_animRes(resId, CAnimRes::kDefaultCharIdx, playerScale, 0, true) +, x7ec_beam(CPlayerState::kBI_Power) +, x7f0_ballTransitionBeamModel() +, x7f4_gunWorldXf(CTransform4f::Identity()) +, x824_transitionFilterTimer(0.f) +, x828_distanceUnderWater(0.f) +, x82c_inLava(false) +, x82e_ridingPlatform(kInvalidUniqueId) +, x830_playerHint(kInvalidUniqueId) +, x834_playerHintPriority(1000) +, x838_playerHints() +, x93c_playerHintsToRemove() +, x980_playerHintsToAdd() +, x9c4_24_visorChangeRequested(false) +, x9c4_25_showCrosshairs(false) +, x9c4_26_(true) +, x9c4_27_canEnterMorphBall(true) +, x9c4_28_canLeaveMorphBall(true) +, x9c4_29_spiderBallControlXY(false) +, x9c4_30_controlDirOverride(false) +, x9c4_31_inWaterMovement(false) +, x9c5_24_(false) +, x9c5_25_splashUpdated(false) +, x9c5_26_(false) +, x9c5_27_camSubmerged(false) +, x9c5_28_slidingOnWall(false) +, x9c5_29_hitWall(false) +#if NONMATCHING +, x9c5_30_selectFluidBallSound(false) +#endif +, x9c5_31_stepCameraZBiasDirty(true) +, x9c6_24_extendTargetDistance(false) +, x9c6_25_interpolatingControlDir(false) +, x9c6_26_outOfBallLookAtHint(false) +, x9c6_27_aimingAtProjectile(false) +, x9c6_28_aligningGrappleSwingTurn(false) +, x9c6_29_disableInput(false) +#if NONMATCHING +, x9c6_30_newScanScanning(false) +#endif +, x9c6_31_overrideRadarRadius(false) +, x9c7_25_outOfBallLookAtHintActor(false) +#if NONMATCHING +, x9c7_24_noDamageLoopSfx(false) +#endif +, x9c8_eyeZBias(0.f) +, x9cc_stepCameraZBias(0.f) +, x9d0_bombJumpCount(0) +, x9d4_bombJumpCheckDelayFrames(0) +, x9d8_controlDirOverrideDir(0.f, 1.f, 0.f) +, x9e4_orbitDisableList() +, x9f4_deathTime(0.f) +, x9f8_controlDirInterpTime(0.f) +, x9fc_controlDirInterpDur(0.f) +, xa00_deathPowerBomb(kInvalidUniqueId) +, xa04_preThinkDt(0.f) +, xa08_steamTextureId(kInvalidAssetId) +#if NONMATCHING +, xa0c_iceTextureId(kInvalidAssetId) +#endif +, xa10_envDmgCounter(0) +, xa14_envDmgCameraShakeTimer(0.f) +, xa18_phazonDamageLag(0.f) +, xa1c_threatOverride(0.f) +, xa20_radarXYRadiusOverride(1.f) +, xa24_radarZRadiusOverride(1.f) +, xa28_attachedActorStruggle(0.f) +, xa2c_damageLoopSfxDelayTicks(2) +, xa30_samusExhaustedVoiceTimer(4.f) { + CModelData ballTransitionBeamModelData( + CStaticRes(gpTweakPlayerRes->GetBallTransitionBeamResId(x7ec_beam), playerScale)); + CModelData* ptr; + if (ballTransitionBeamModelData.IsNull()) { + ptr = nullptr; + } else { + ptr = rs_new CModelData(ballTransitionBeamModelData); + } + x7f0_ballTransitionBeamModel = ptr; + x730_transitionModels.reserve(3); + x768_morphball = rs_new CMorphBall(*this, ballRadius); + SetInertiaTensorScalar(GetMass()); + SetLastNonCollidingState(GetMotionState()); + x490_gun->SetTransform(GetTransform()); + x490_gun->GetGrappleArm().SetTransform(GetTransform()); + InitialiseAnimation(); + CAABox bounds = GetModelData()->GetBounds(CTransform4f::Identity()); + x2f0_ballTransHeight = bounds.GetMaxPoint().GetZ() - bounds.GetMinPoint().GetZ(); + SetCalculateLighting(true); + ActorLights()->SetCastShadows(true); + x50c_moveDir.SetZ(0.f); + if (x50c_moveDir.CanBeNormalized()) { + x50c_moveDir.Normalize(); + } + x2b4_accelerationTable.push_back(20.f); + x2b4_accelerationTable.push_back(80.f); + x2b4_accelerationTable.push_back(80.f); + x2b4_accelerationTable.push_back(270.f); + SetMaxVelocityAfterCollision(25.f); + x354_onScreenOrbitObjects.reserve(64); + x344_nearbyOrbitObjects.reserve(64); + x364_offScreenOrbitObjects.reserve(64); + ModelData()->SetScale(playerScale); + x7f0_ballTransitionBeamModel->SetScale(playerScale); + LoadAnimationTokens(); +} + +bool CPlayer::IsMorphBallTransitioning() const { + switch (x2f8_morphBallState) { + case kMS_Morphing: + case kMS_Unmorphing: + return true; + default: + return false; + } +} + +void CPlayer::HolsterGun(CStateManager& mgr) { + if (x498_gunHolsterState == kGH_Holstered || x498_gunHolsterState == kGH_Holstering) { + return; + } + + float time = gpTweakPlayerGun->x3c_gunHolsterTime; + if (x2f8_morphBallState == kMS_Morphing) { + time = 0.1f; + } + if (x498_gunHolsterState == kGH_Drawing) { + x49c_gunHolsterRemTime = time * (1.f - x49c_gunHolsterRemTime / 0.45f); + } else { + x49c_gunHolsterRemTime = time; + } + + x498_gunHolsterState = kGH_Holstering; + x490_gun->CancelFiring(mgr); + SetAimTargetId(kInvalidUniqueId); +} + +void CPlayer::ResetGun(CStateManager& mgr) { + x498_gunHolsterState = kGH_Holstered; + x49c_gunHolsterRemTime = 0.f; + x490_gun->CancelFiring(mgr); + SetAimTargetId(kInvalidUniqueId); +} + +void CPlayer::DrawGun(CStateManager& mgr) { + if (x498_gunHolsterState != kGH_Holstered || CheckPostGrapple()) { + return; + } + + x498_gunHolsterState = kGH_Drawing; + x49c_gunHolsterRemTime = 0.45f; + x490_gun->ResetIdle(mgr); +} + +void CPlayer::UpdateGunState(const CFinalInput& input, CStateManager& mgr) { + float dt = input.Time(); + switch (x498_gunHolsterState) { + case kGH_Drawn: { + bool needsHolster = false; + if (gpTweakPlayer->GetGunButtonTogglesHolster()) { + if (ControlMapper::GetPressInput(ControlMapper::kC_ToggleHolster, input)) { + needsHolster = true; + } + if (!ControlMapper::GetDigitalInput(ControlMapper::kC_FireOrBomb, input) && + !ControlMapper::GetDigitalInput(ControlMapper::kC_MissileOrPowerBomb, input) && + gpTweakPlayer->x229_31_gunNotFiringHolstersGun) { + x49c_gunHolsterRemTime -= dt; + if (x49c_gunHolsterRemTime <= 0.f) { + needsHolster = true; + } + } + } else { + if (!ControlMapper::GetDigitalInput(ControlMapper::kC_FireOrBomb, input) && + !ControlMapper::GetDigitalInput(ControlMapper::kC_MissileOrPowerBomb, input) && + x490_gun->IsFidgeting()) { + if (gpTweakPlayer->x229_31_gunNotFiringHolstersGun) { + x49c_gunHolsterRemTime -= dt; + } + } else { + x49c_gunHolsterRemTime = gpTweakPlayerGun->x40_gunNotFiringTime; + } + } + + if (needsHolster) { + HolsterGun(mgr); + } + break; + } + case kGH_Drawing: { + if (x49c_gunHolsterRemTime > 0.f) { + x49c_gunHolsterRemTime -= dt; + } else { + x498_gunHolsterState = kGH_Drawn; + x49c_gunHolsterRemTime = gpTweakPlayerGun->x40_gunNotFiringTime; + } + break; + } + case kGH_Holstered: { + bool needsDraw = false; + if (ControlMapper::GetDigitalInput(ControlMapper::kC_FireOrBomb, input) || + ControlMapper::GetDigitalInput(ControlMapper::kC_MissileOrPowerBomb, input) || + x3b8_grappleState == kGS_None) { + needsDraw = true; + } else if (gpTweakPlayer->x229_30_gunButtonTogglesHolster && + ControlMapper::GetPressInput(ControlMapper::kC_ToggleHolster, input)) { + needsDraw = true; + } + + if (x3b8_grappleState != kGS_None || + mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::kPV_Scan || + mgr.GetPlayerState()->GetTransitioningVisor() == CPlayerState::kPV_Scan) { + needsDraw = false; + } + + if (needsDraw) { + DrawGun(mgr); + } + break; + } + case kGH_Holstering: + if (x49c_gunHolsterRemTime > 0.f) { + x49c_gunHolsterRemTime -= dt; + } else { + x498_gunHolsterState = kGH_Holstered; + } + break; + default: + break; + } +} + +void CPlayer::SetAimTargetId(TUniqueId target) { + if (target == kInvalidUniqueId || x3f4_aimTarget != target) { + x404_aimTargetAverage.clear(); + } + x3f4_aimTarget = target; +} + +void CPlayer::UpdateAimTargetPrediction(const CTransform4f& xf, CStateManager& mgr) { + if (GetAimTargetId() == kInvalidUniqueId) { + return; + } + + const CActor* target = TCastToConstPtr< CActor >(mgr.GetObjectById(GetAimTargetId())); + if (!target) { + return; + } + + x9c6_27_aimingAtProjectile = TCastToConstPtr< CGameProjectile >(target) != nullptr; + CVector3f instantTarget = target->GetAimPosition(mgr, 0.f); + CVector3f gunToTarget = instantTarget - xf.GetTranslation(); + float timeToTarget = gunToTarget.Magnitude() / x490_gun->GetBeamVelocity(); + CVector3f predictTarget = target->GetAimPosition(mgr, timeToTarget); + CVector3f predictOffset = predictTarget - instantTarget; + x3f8_targetAimPosition = instantTarget; + + if (predictOffset.Magnitude() < 0.1f) { + x404_aimTargetAverage.AddValue(CVector3f::Zero()); + } else { + x404_aimTargetAverage.AddValue(predictTarget - instantTarget); + } + + if (x404_aimTargetAverage.GetAverage() && !x9c6_27_aimingAtProjectile) { + x480_assistedTargetAim = instantTarget + *x404_aimTargetAverage.GetAverage(); + } else { + x480_assistedTargetAim = predictTarget; + } +} + +void CPlayer::UpdateAssistedAiming(const CTransform4f& xf, CStateManager& mgr) { + CTransform4f assistXf = xf; + if (const CActor* target = TCastToConstPtr< CActor >(mgr.GetObjectById(GetAimTargetId()))) { + CVector3f gunToTarget = x480_assistedTargetAim - xf.GetTranslation(); + CVector3f gunToTargetFlat = gunToTarget.DropZ(); + float gunToTargetFlatMag = gunToTargetFlat.Magnitude(); + CVector3f gunDirFlat = xf.GetColumn(kDY); + gunDirFlat.SetZ(0.f); + float gunDirFlatMag = gunDirFlat.Magnitude(); + if (gunToTargetFlat.CanBeNormalized() && gunDirFlat.CanBeNormalized()) { + gunToTargetFlat /= gunToTargetFlatMag; + gunDirFlat /= gunDirFlatMag; + float az1 = atan2f(gunToTarget.GetZ(), gunToTargetFlatMag); + float az2 = atan2f(xf.GetColumn(kDY).GetZ(), gunDirFlatMag); + float vAngleDelta = az1 - az2; + bool hasVAngleDelta = true; + if (!x9c6_27_aimingAtProjectile && + fabsf(vAngleDelta) > gpTweakPlayer->x268_aimAssistVerticalAngle) { + if (gpTweakPlayer->x22a_28_assistedAimingIgnoreVertical) { + vAngleDelta = 0.f; + hasVAngleDelta = false; + } else if (vAngleDelta > 0.f) { + vAngleDelta = gpTweakPlayer->x268_aimAssistVerticalAngle; + } else { + vAngleDelta = -gpTweakPlayer->x268_aimAssistVerticalAngle; + } + } + + bool targetToLeft = CVector3f::Cross(gunDirFlat, gunToTargetFlat).GetZ() > 0.f; + float hAngleDelta = acosf(CMath::Limit(CVector3f::Dot(gunToTargetFlat, gunDirFlat), 1.f)); + bool hasHAngleDelta = true; + if (!x9c6_27_aimingAtProjectile && + fabsf(hAngleDelta) > gpTweakPlayer->x264_aimAssistHorizontalAngle) { + hAngleDelta = gpTweakPlayer->x264_aimAssistHorizontalAngle; + if (gpTweakPlayer->x22a_27_assistedAimingIgnoreHorizontal) { + hAngleDelta = 0.f; + hasHAngleDelta = false; + } + } + + if (targetToLeft) { + hAngleDelta = -hAngleDelta; + } + if (!hasVAngleDelta || !hasHAngleDelta) { + vAngleDelta = 0.f; + hAngleDelta = 0.f; + } + + gunToTarget = CVector3f(sinf(hAngleDelta) * cosf(vAngleDelta), + cosf(hAngleDelta) * cosf(vAngleDelta), sinf(vAngleDelta)); + gunToTarget = xf.Rotate(gunToTarget); + assistXf = CTransform4f::LookAt(CVector3f::Zero(), gunToTarget); + } + } + + x490_gun->SetAssistAimTransform(assistXf); +} + +void CPlayer::UpdateGunTransform(const CVector3f& gunPos, CStateManager& mgr) { +#if !NONMATCHING + CTransform4f xf = GetTransform(); +#endif + float eyeHeight = GetEyeHeight(); + CTransform4f camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr); + CTransform4f gunXf = camXf; + + CVector3f viewGunPos; + if (x2f8_morphBallState == kMS_Morphing) { + viewGunPos = camXf * CVector3f(gunPos - CVector3f(0.f, 0.f, eyeHeight)); + } else { + viewGunPos = GetEyePosition() + camXf.Rotate(gunPos - CVector3f(0.f, 0.f, eyeHeight)); + } + gunXf.SetTranslation(viewGunPos); + + CUnitVector3f rightDir(camXf.GetColumn(kDX)); + switch (x498_gunHolsterState) { + case kGH_Drawing: { + float liftAngle = CMath::Limit(x49c_gunHolsterRemTime / 0.45f, 1.f); + if (liftAngle > 0.01f) { + CQuaternion quat = CQuaternion::AxisAngle( + rightDir, CRelAngle::FromRadians(-liftAngle * gpTweakPlayerGun->x44_fixedVerticalAim)); + gunXf = quat.BuildTransform4f() * camXf.GetRotation(); + gunXf.SetTranslation(viewGunPos); + } + break; + } + case kGH_Holstered: { + CQuaternion quat = CQuaternion::AxisAngle( + rightDir, CRelAngle::FromRadians(-gpTweakPlayerGun->x44_fixedVerticalAim)); + gunXf = quat.BuildTransform4f() * camXf.GetRotation(); + gunXf.SetTranslation(viewGunPos); + break; + } + case kGH_Holstering: { + float liftAngle = + 1.f - CMath::Limit(x49c_gunHolsterRemTime / gpTweakPlayerGun->x3c_gunHolsterTime, 1.f); + if (x2f8_morphBallState == kMS_Morphing) { + liftAngle = 1.f - CMath::Limit(x49c_gunHolsterRemTime / 0.1f, 1.f); + } + if (liftAngle > 0.01f) { + CQuaternion quat = CQuaternion::AxisAngle( + rightDir, CRelAngle::FromRadians(-liftAngle * gpTweakPlayerGun->x44_fixedVerticalAim)); + gunXf = quat.BuildTransform4f() * camXf.GetRotation(); + gunXf.SetTranslation(viewGunPos); + } + break; + } + default: + break; + } + + x490_gun->SetTransform(gunXf); + CTransform4f out = gunXf; + UpdateAimTargetPrediction(out, mgr); + UpdateAssistedAiming(out, mgr); +} + +const CTransform4f& CPlayer::GetFirstPersonCameraTransform(CStateManager& mgr) const { + return mgr.GetCameraManager()->GetFirstPersonCamera()->GetGunFollowTransform(); +} + +void CPlayer::UpdateDebugCamera(CStateManager& mgr) {} + +void CPlayer::UpdateArmAndGunTransforms(float dt, CStateManager& mgr) { + CVector3f grappleOffset = CVector3f::Zero(); + CVector3f gunOffset; + if (x2f8_morphBallState == kMS_Morphed) { + gunOffset = CVector3f(0.f, 0.f, 0.6f); + } else { + gunOffset = gpTweakPlayerGun->x4c_gunPosition; + grappleOffset = x490_gun->GetGrappleArm().IsArmMoving() + ? CVector3f::Zero() + : gpTweakPlayerGun->x64_grapplingArmPosition; + gunOffset[kDZ] += GetEyeHeight(); + grappleOffset[kDZ] += GetEyeHeight(); + } + + UpdateGunTransform(gunOffset + x76c_cameraBob->GetGunBobTransformation().GetTranslation(), mgr); + UpdateGrappleArmTransform(grappleOffset, mgr, dt); +} + +void CPlayer::ForceGunOrientation(const CTransform4f& xf, CStateManager& mgr) { + ResetGun(mgr); + x530_gunDir = xf.GetColumn(kDY); + x490_gun->SetTransform(xf); + UpdateArmAndGunTransforms(0.01f, mgr); +} + +void CPlayer::Update(float dt, CStateManager& mgr) { + SetCoefficientOfRestitutionModifier(0.f); + UpdateMorphBallTransition(dt, mgr); + + CPlayerState::EBeamId newBeam = mgr.GetPlayerState()->GetCurrentBeam(); + if (x7ec_beam != newBeam) { + x7ec_beam = newBeam; + CModelData modelData(CStaticRes(gpTweakPlayerRes->GetBallTransitionBeamResId(x7ec_beam), + x7d0_animRes.GetScale())); + CModelData* ptr; + if (modelData.IsNull()) { + ptr = nullptr; + } else { + ptr = rs_new CModelData(modelData); + } + x7f0_ballTransitionBeamModel = ptr; + } + + if (!mgr.GetPlayerState()->IsAlive()) { + if (!x9f4_deathTime) { + CSfxManager::KillAll(CSfxManager::kSC_Game); + CStreamAudioManager::StopAll(); + if (x2f8_morphBallState == kMS_Unmorphed) { + ApplySubmergedPitchBend(CSfxManager::SfxStart(SFXsam_death)); + } + } + + float prevDeathTime = x9f4_deathTime; + x9f4_deathTime += dt; + if (x2f8_morphBallState != kMS_Unmorphed) { + if (x9f4_deathTime >= 1.f && prevDeathTime < 1.f) { + xa00_deathPowerBomb = x490_gun->DropPowerBomb(mgr); + } + if (x9f4_deathTime >= 4.f && prevDeathTime < 4.f) { + ApplySubmergedPitchBend(CSfxManager::SfxStart(SFXsam_death)); + } + } + } + + switch (x2f8_morphBallState) { + case kMS_Unmorphed: + case kMS_Morphing: + case kMS_Unmorphing: + CTransform4f gunXf = GetModelData()->GetScaledLocatorTransform(rstl::string_l(kGunLocator)); + x7f4_gunWorldXf = GetTransform() * gunXf; + break; + case kMS_Morphed: + break; + } + + if (x2f8_morphBallState == kMS_Unmorphed) { + UpdateAimTargetTimer(dt); + UpdateAimTarget(mgr); + UpdateOrbitModeTimer(dt); + } + UpdateOrbitPreventionTimer(dt); + if (x2f8_morphBallState == kMS_Morphed) { + x768_morphball->Update(dt, mgr); + } else { + x768_morphball->StopSounds(); + } + if (x2f8_morphBallState == kMS_Morphing || x2f8_morphBallState == kMS_Unmorphing) { + x768_morphball->UpdateEffects(dt, mgr); + } + UpdateGunAlpha(); + UpdateDebugCamera(mgr); + UpdateVisorTransition(dt, mgr); + mgr.SetActorAreaId(*this, mgr.GetWorld()->GetCurrentAreaId()); + UpdatePlayerSounds(dt); + if (x26c_attachedActor != kInvalidUniqueId) { + x270_attachedActorTime += dt; + } + + x740_staticTimer = rstl::max_val(0.f, x740_staticTimer - dt); + if (x740_staticTimer > 0.f) { + x74c_visorStaticAlpha = rstl::max_val(0.f, x74c_visorStaticAlpha - x744_staticOutSpeed * dt); + } else { + x74c_visorStaticAlpha = rstl::min_val(1.f, x74c_visorStaticAlpha + x748_staticInSpeed * dt); + } + + x274_energyDrain.ProcessEnergyDrain(mgr, dt); + x4a4_moveSpeedAvg.AddValue(x4f8_moveSpeed); + + mgr.PlayerState()->UpdateStaticInterference(mgr, dt); + if (!ShouldSampleFailsafe(mgr)) { + CPhysicsActor::Stop(); + } + + xa30_samusExhaustedVoiceTimer = IsEnergyLow(mgr) ? xa30_samusExhaustedVoiceTimer - dt : 4.f; + + if (!mgr.GetCameraManager()->IsInCinematicCamera() && xa30_samusExhaustedVoiceTimer <= 0.f) { + StartSamusVoiceSfx(SFXsam_vox_exhausted, 127, 7); + xa30_samusExhaustedVoiceTimer = 4.f; + } +} diff --git a/src/MetroidPrime/Player/CPlayerGun.cpp b/src/MetroidPrime/Player/CPlayerGun.cpp index 30381b96..03a34f8d 100644 --- a/src/MetroidPrime/Player/CPlayerGun.cpp +++ b/src/MetroidPrime/Player/CPlayerGun.cpp @@ -1097,6 +1097,6 @@ void CPlayerGun::AsyncLoadSuit(CStateManager&) {} void CPlayerGun::ReturnToRestPose() {} -void CPlayerGun::DropPowerBomb(CStateManager&) const {} +TUniqueId CPlayerGun::DropPowerBomb(CStateManager&) const {} void CPlayerGun::SetPhazonBeamFeedback(bool) {} diff --git a/src/MetroidPrime/ScriptObjects/CScriptCoverPoint.cpp b/src/MetroidPrime/ScriptObjects/CScriptCoverPoint.cpp index f524d0cf..d3eab642 100644 --- a/src/MetroidPrime/ScriptObjects/CScriptCoverPoint.cpp +++ b/src/MetroidPrime/ScriptObjects/CScriptCoverPoint.cpp @@ -68,7 +68,7 @@ const bool CScriptCoverPoint::Blown(const CVector3f& point) const { } else { CVector3f posDif = point - GetTransform().GetTranslation(); float magnitude = posDif.Magnitude(); - posDif *= 1.f / magnitude; + posDif /= magnitude; if (magnitude > 8.0f) { CUnitVector3f normDif(posDif.GetX(), posDif.GetY(), 0.f, CUnitVector3f::kN_Yes); CUnitVector3f frontVec(GetTransform().GetColumn(kDY).GetX(), diff --git a/src/MetroidPrime/Weapons/CPowerBomb.cpp b/src/MetroidPrime/Weapons/CPowerBomb.cpp index cb9bc534..b3325330 100644 --- a/src/MetroidPrime/Weapons/CPowerBomb.cpp +++ b/src/MetroidPrime/Weapons/CPowerBomb.cpp @@ -100,11 +100,12 @@ void CPowerBomb::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CState case kSM_Registered: mgr.AddWeaponId(GetOwnerId(), GetWeaponType()); OrigDamageInfo().SetRadius(0.f); - if (mgr.GetPlayerState()->IsPlayerAlive()) { + if (mgr.GetPlayerState()->IsAlive()) { CSfxManager::AddEmitter(SFXsfx0710, GetTranslation(), CVector3f::Zero(), true, false); mgr.InformListeners(GetTranslation(), kLNT_BombExplode); } else { - mgr.Player()->DoSfxEffects(CSfxManager::SfxStart(SFXsfx073F, 0x7f, 0x40, false)); + mgr.Player()->DoSfxEffects( + CSfxManager::SfxStart(SFXsfx073F, 127, 64, false, CSfxManager::kMaxPriority)); } break; diff --git a/src/MetroidPrime/Weapons/CTargetableProjectile.cpp b/src/MetroidPrime/Weapons/CTargetableProjectile.cpp index 3cb1adb7..8527de5b 100644 --- a/src/MetroidPrime/Weapons/CTargetableProjectile.cpp +++ b/src/MetroidPrime/Weapons/CTargetableProjectile.cpp @@ -43,7 +43,7 @@ bool CTargetableProjectile::Explode(const CVector3f& pos, const CVector3f& norma CSfxManager::kInternalInvalidSfxId, false); mgr.AddObject(projectile); projectile->AddMaterial(kMT_Orbit, mgr); - mgr.Player()->ResetAimTargetPrediction(uid); + mgr.Player()->SetAimTargetId(uid); mgr.Player()->SetOrbitTargetId(uid, mgr); SetHitProjectileOwner(kInvalidUniqueId); } diff --git a/tools/metaforce_renames.py b/tools/metaforce_renames.py index 01cc8aab..1113af4f 100644 --- a/tools/metaforce_renames.py +++ b/tools/metaforce_renames.py @@ -22,6 +22,7 @@ _LITERAL_REPLACEMENTS = [ ("zeus::", ""), ("u32 ", "uint "), ("s32 ", "int "), + ("u16 ", "ushort "), ("std::min(", "rstl::min_val("), ("std::max(", "rstl::max_val("),