From 82901862fa453c3b014b0f67d7b101185c0edb50 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Mon, 23 Dec 2024 23:18:15 -0800 Subject: [PATCH] Match and link CFire, minor fixes --- config/GM8E01_00/splits.txt | 2 +- config/GM8E01_00/symbols.txt | 25 ++-- config/GM8E01_01/splits.txt | 2 +- config/GM8E01_01/symbols.txt | 20 ++-- configure.py | 4 +- include/Kyoto/Input/CFinalInput.hpp | 4 +- include/Kyoto/Math/CAABox.hpp | 3 +- include/Kyoto/Particles/CElementGen.hpp | 5 +- include/MetroidPrime/Decode.hpp | 2 +- include/MetroidPrime/Player/CGameOptions.hpp | 36 +++--- include/MetroidPrime/Player/CPlayer.hpp | 3 +- include/MetroidPrime/ScriptObjects/CFire.hpp | 2 +- include/MetroidPrime/TGameTypes.hpp | 1 - .../MetroidPrime/Weapons/CGameProjectile.hpp | 31 +++-- .../Weapons/CProjectileWeapon.hpp | 4 +- include/MetroidPrime/Weapons/CWeapon.hpp | 4 +- src/MetroidPrime/Decode.cpp | 2 +- .../Player/CFaceplateDecoration.cpp | 2 +- src/MetroidPrime/Player/CGameOptions.cpp | 16 +-- src/MetroidPrime/ScriptObjects/CFire.cpp | 112 +++++++++++++++++- 20 files changed, 198 insertions(+), 82 deletions(-) diff --git a/config/GM8E01_00/splits.txt b/config/GM8E01_00/splits.txt index a48a241f..87be1687 100644 --- a/config/GM8E01_00/splits.txt +++ b/config/GM8E01_00/splits.txt @@ -158,7 +158,7 @@ MetroidPrime/Tweaks/CTweakGame.cpp: .text start:0x800371E4 end:0x80037400 .data start:0x803D9CD0 end:0x803D9CE0 -MetroidPrime/CGameProjectile.cpp: +MetroidPrime/Weapons/CGameProjectile.cpp: .text start:0x80037400 end:0x8003A7A4 .rodata start:0x803CCE20 end:0x803CCE38 .data start:0x803D9CE0 end:0x803D9D50 diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index 69f5ed27..15e9108e 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -10777,7 +10777,7 @@ __ct__7CPufferF9TUniqueIdRCQ24rstl66basic_string,Q24rs AcceptScriptMsg__5CFireF20EScriptObjectMessage9TUniqueIdR13CStateManager = .text:0x8025CC24; // type:function size:0x80 scope:global Think__5CFireFfR13CStateManager = .text:0x8025CCA4; // type:function size:0x24C scope:global Accept__5CFireFR8IVisitor = .text:0x8025CEF0; // type:function size:0x38 scope:global -Render__5CFireCFRC13CStateManager = .text:0x8025CF28; // type:function size:0xEC scope:global +AddToRenderer__5CFireCFRC14CFrustumPlanesRC13CStateManager = .text:0x8025CF28; // type:function size:0xEC scope:global GetTouchBounds__5CFireCFv = .text:0x8025D014; // type:function size:0x68 scope:global Touch__5CFireFR6CActorR13CStateManager = .text:0x8025D07C; // type:function size:0xC4 scope:global __dt__5CFireFv = .text:0x8025D140; // type:function size:0x9C scope:global @@ -17543,7 +17543,7 @@ lbl_803D51F6 = .rodata:0x803D51F6; // type:object size:0xC data:string lbl_803D5202 = .rodata:0x803D5202; // type:object size:0xC data:string lbl_803D520E = .rodata:0x803D520E; // type:object size:0xC data:string lbl_803D521A = .rodata:0x803D521A; // type:object size:0x16 -lbl_803D5230 = .rodata:0x803D5230; // type:object size:0x10 +@stringBase0 = .rodata:0x803D5230; // type:object size:0xC scope:local data:string_table @stringBase0 = .rodata:0x803D5240; // type:object size:0x15 scope:local data:string_table lbl_803D5258 = .rodata:0x803D5258; // type:object size:0x11 data:string lbl_803D5269 = .rodata:0x803D5269; // type:object size:0xF @@ -18051,7 +18051,7 @@ lbl_803D9CA8 = .data:0x803D9CA8; // type:object size:0x10 __vt__12CTweakPlayer = .data:0x803D9CB8; // type:object size:0xC scope:weak __vt__12ITweakObject = .data:0x803D9CC4; // type:object size:0xC scope:weak __vt__10CTweakGame = .data:0x803D9CD0; // type:object size:0xC scope:global -lbl_803D9CE0 = .data:0x803D9CE0; // type:object size:0x70 +__vt__15CGameProjectile = .data:0x803D9CE0; // type:object size:0x70 kVerticalAngleTable = .data:0x803D9D50; // type:object size:0xC scope:global data:float kHorizontalAngleTable = .data:0x803D9D5C; // type:object size:0xC scope:global kVerticalVarianceTable = .data:0x803D9D68; // type:object size:0xC scope:global @@ -18543,7 +18543,7 @@ jumptable_803E95A4 = .data:0x803E95A4; // type:object size:0xAC scope:local skGasJetLocators = .data:0x803E9650; // type:object size:0x38 scope:global data:4byte skGasLocators = .data:0x803E9688; // type:object size:0x38 scope:global data:4byte __vt__7CPuffer = .data:0x803E96C0; // type:object size:0x2D0 scope:global -lbl_803E9990 = .data:0x803E9990; // type:object size:0x70 +__vt__5CFire = .data:0x803E9990; // type:object size:0x6C __vt__16CPauseScreenBlur = .data:0x803E9A00; // type:object size:0xC scope:global lbl_803E9A10 = .data:0x803E9A10; // type:object size:0xC data:4byte lbl_803E9A1C = .data:0x803E9A1C; // type:object size:0xC data:4byte @@ -20987,8 +20987,8 @@ lbl_805A8378 = .sdata:0x805A8378; // type:object size:0x8 lbl_805A8380 = .sdata:0x805A8380; // type:object size:0x4 data:4byte lbl_805A8384 = .sdata:0x805A8384; // type:object size:0x4 data:4byte lbl_805A8388 = .sdata:0x805A8388; // type:object size:0x8 data:4byte -lbl_805A8390 = .sdata:0x805A8390; // type:object size:0x4 data:4byte -lbl_805A8394 = .sdata:0x805A8394; // type:object size:0x4 data:4byte +kSolidMat = .sdata:0x805A8390; // type:object size:0x4 scope:local data:4byte +kProjectileMat = .sdata:0x805A8394; // type:object size:0x4 scope:local data:4byte @281 = .sdata:0x805A8398; // type:object size:0x4 scope:local data:float @286 = .sdata:0x805A839C; // type:object size:0x4 scope:local data:float lbl_805A83A0 = .sdata:0x805A83A0; // type:object size:0x4 data:4byte @@ -25715,11 +25715,11 @@ lbl_805AD708 = .sdata2:0x805AD708; // type:object size:0x4 data:float lbl_805AD70C = .sdata2:0x805AD70C; // type:object size:0x4 data:float lbl_805AD710 = .sdata2:0x805AD710; // type:object size:0x4 data:float lbl_805AD714 = .sdata2:0x805AD714; // type:object size:0x4 data:float -lbl_805AD718 = .sdata2:0x805AD718; // type:object size:0x4 data:float -lbl_805AD71C = .sdata2:0x805AD71C; // type:object size:0x4 data:float -lbl_805AD720 = .sdata2:0x805AD720; // type:object size:0x4 data:float -lbl_805AD724 = .sdata2:0x805AD724; // type:object size:0x4 data:float -lbl_805AD728 = .sdata2:0x805AD728; // type:object size:0x8 align:8 data:double +@429 = .sdata2:0x805AD718; // type:object size:0x4 scope:local data:float +@430 = .sdata2:0x805AD71C; // type:object size:0x4 scope:local data:float +@431 = .sdata2:0x805AD720; // type:object size:0x4 scope:local data:float +@432 = .sdata2:0x805AD724; // type:object size:0x4 scope:local data:float +@434 = .sdata2:0x805AD728; // type:object size:0x8 scope:local align:8 data:double @395 = .sdata2:0x805AD730; // type:object size:0x4 scope:local data:float @396 = .sdata2:0x805AD734; // type:object size:0x4 scope:local data:float @454 = .sdata2:0x805AD738; // type:object size:0x4 scope:local data:float @@ -26838,8 +26838,7 @@ lbl_805AEC80 = .sdata2:0x805AEC80; // type:object size:0x8 align:8 data:double lbl_805AEC88 = .sdata2:0x805AEC88; // type:object size:0x8 align:8 data:double @38 = .sdata2:0x805AEC90; // type:object size:0x4 scope:local data:4byte lbl_805AEC98 = .sdata2:0x805AEC98; // type:object size:0x8 align:8 data:double -@150 = .sdata2:0x805AECA0; // type:object size:0x4 scope:local data:4byte -lbl_805AECA4 = .sdata2:0x805AECA4; // type:object size:0x1 data:byte +@150 = .sdata2:0x805AECA0; // type:object size:0x5 scope:local data:string lbl_805AECA8 = .sdata2:0x805AECA8; // type:object size:0x8 align:8 data:double lbl_805AECB0 = .sdata2:0x805AECB0; // type:object size:0x8 align:8 data:double @136 = .sdata2:0x805AECB8; // type:object size:0x8 scope:local align:8 data:double diff --git a/config/GM8E01_01/splits.txt b/config/GM8E01_01/splits.txt index 2dd2d695..8cb42406 100644 --- a/config/GM8E01_01/splits.txt +++ b/config/GM8E01_01/splits.txt @@ -154,7 +154,7 @@ MetroidPrime/Tweaks/CTweakGame.cpp: .text start:0x80037260 end:0x8003747C .data start:0x803D9EB0 end:0x803D9EC0 -MetroidPrime/CGameProjectile.cpp: +MetroidPrime/Weapons/CGameProjectile.cpp: .text start:0x8003747C end:0x8003A820 .rodata start:0x803CD000 end:0x803CD018 .data start:0x803D9EC0 end:0x803D9F30 diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index b124674d..de10ef9b 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -10777,7 +10777,7 @@ __ct__7CPufferF9TUniqueIdRCQ24rstl66basic_string,Q24rs AcceptScriptMsg__5CFireF20EScriptObjectMessage9TUniqueIdR13CStateManager = .text:0x8025CCA0; // type:function size:0x80 scope:global Think__5CFireFfR13CStateManager = .text:0x8025CD20; // type:function size:0x24C scope:global Accept__5CFireFR8IVisitor = .text:0x8025CF6C; // type:function size:0x38 scope:global -Render__5CFireCFRC13CStateManager = .text:0x8025CFA4; // type:function size:0xEC scope:global +AddToRenderer__5CFireCFRC14CFrustumPlanesRC13CStateManager = .text:0x8025CFA4; // type:function size:0xEC scope:global GetTouchBounds__5CFireCFv = .text:0x8025D090; // type:function size:0x68 scope:global Touch__5CFireFR6CActorR13CStateManager = .text:0x8025D0F8; // type:function size:0xC4 scope:global __dt__5CFireFv = .text:0x8025D1BC; // type:function size:0x9C scope:global @@ -17581,7 +17581,7 @@ lbl_803D53D6 = .rodata:0x803D53D6; // type:object size:0xC data:string lbl_803D53E2 = .rodata:0x803D53E2; // type:object size:0xC data:string lbl_803D53EE = .rodata:0x803D53EE; // type:object size:0xC data:string lbl_803D53FA = .rodata:0x803D53FA; // type:object size:0x16 -lbl_803D5410 = .rodata:0x803D5410; // type:object size:0x10 +@stringBase0 = .rodata:0x803D5410; // type:object size:0xC scope:local data:string_table lbl_803D5420 = .rodata:0x803D5420; // type:object size:0x18 lbl_803D5438 = .rodata:0x803D5438; // type:object size:0x11 data:string lbl_803D5449 = .rodata:0x803D5449; // type:object size:0xF @@ -18578,7 +18578,7 @@ jumptable_803E9784 = .data:0x803E9784; // type:object size:0xAC scope:local lbl_803E9830 = .data:0x803E9830; // type:object size:0x38 data:4byte lbl_803E9868 = .data:0x803E9868; // type:object size:0x38 data:4byte lbl_803E98A0 = .data:0x803E98A0; // type:object size:0x2D0 -lbl_803E9B70 = .data:0x803E9B70; // type:object size:0x70 +__vt__5CFire = .data:0x803E9B70; // type:object size:0x6C scope:local __vt__16CPauseScreenBlur = .data:0x803E9BE0; // type:object size:0x10 lbl_803E9BF0 = .data:0x803E9BF0; // type:object size:0xC data:4byte lbl_803E9BFC = .data:0x803E9BFC; // type:object size:0xC data:4byte @@ -20891,8 +20891,8 @@ lbl_805A8558 = .sdata:0x805A8558; // type:object size:0x8 lbl_805A8560 = .sdata:0x805A8560; // type:object size:0x4 data:4byte lbl_805A8564 = .sdata:0x805A8564; // type:object size:0x4 data:4byte lbl_805A8568 = .sdata:0x805A8568; // type:object size:0x8 data:4byte -lbl_805A8570 = .sdata:0x805A8570; // type:object size:0x4 data:4byte -lbl_805A8574 = .sdata:0x805A8574; // type:object size:0x4 data:4byte +kSolidMat = .sdata:0x805A8570; // type:object size:0x4 scope:local data:4byte +kProjectileMat = .sdata:0x805A8574; // type:object size:0x4 scope:local data:4byte lbl_805A8578 = .sdata:0x805A8578; // type:object size:0x4 data:float lbl_805A857C = .sdata:0x805A857C; // type:object size:0x4 data:float lbl_805A8580 = .sdata:0x805A8580; // type:object size:0x4 data:4byte @@ -25618,11 +25618,11 @@ lbl_805AD8E8 = .sdata2:0x805AD8E8; // type:object size:0x4 data:float lbl_805AD8EC = .sdata2:0x805AD8EC; // type:object size:0x4 data:float lbl_805AD8F0 = .sdata2:0x805AD8F0; // type:object size:0x4 data:float lbl_805AD8F4 = .sdata2:0x805AD8F4; // type:object size:0x4 data:float -lbl_805AD8F8 = .sdata2:0x805AD8F8; // type:object size:0x4 data:float -lbl_805AD8FC = .sdata2:0x805AD8FC; // type:object size:0x4 data:float -lbl_805AD900 = .sdata2:0x805AD900; // type:object size:0x4 data:float -lbl_805AD904 = .sdata2:0x805AD904; // type:object size:0x4 data:float -lbl_805AD908 = .sdata2:0x805AD908; // type:object size:0x8 data:double +@429 = .sdata2:0x805AD8F8; // type:object size:0x4 scope:local data:float +@430 = .sdata2:0x805AD8FC; // type:object size:0x4 scope:local data:float +@431 = .sdata2:0x805AD900; // type:object size:0x4 scope:local data:float +@432 = .sdata2:0x805AD904; // type:object size:0x4 scope:local data:float +@434 = .sdata2:0x805AD908; // type:object size:0x8 scope:local data:double lbl_805AD910 = .sdata2:0x805AD910; // type:object size:0x4 data:float lbl_805AD914 = .sdata2:0x805AD914; // type:object size:0x4 data:float lbl_805AD918 = .sdata2:0x805AD918; // type:object size:0x4 data:float diff --git a/configure.py b/configure.py index afe32385..099b9dab 100755 --- a/configure.py +++ b/configure.py @@ -411,7 +411,7 @@ config.libs = [ Object(MatchingFor("GM8E01_00", "GM8E01_01"), "MetroidPrime/Tweaks/CTweakPlayer.cpp"), Object(NonMatching, "MetroidPrime/Tweaks/CTweaks.cpp"), Object(MatchingFor("GM8E01_00", "GM8E01_01"), "MetroidPrime/Tweaks/CTweakGame.cpp"), - Object(NonMatching, "MetroidPrime/CGameProjectile.cpp"), + Object(NonMatching, "MetroidPrime/Weapons/CGameProjectile.cpp"), Object(NonMatching, "MetroidPrime/Player/CPlayerGun.cpp"), Object(NonMatching, "MetroidPrime/CStateManager.cpp"), Object(MatchingFor("GM8E01_00", "GM8E01_01"), "MetroidPrime/CEntity.cpp"), @@ -729,7 +729,7 @@ config.libs = [ Object(NonMatching, "MetroidPrime/Weapons/CElectricBeamProjectile.cpp"), Object(NonMatching, "MetroidPrime/Enemies/CRidley.cpp"), Object(NonMatching, "MetroidPrime/Enemies/CPuffer.cpp"), - Object(NonMatching, "MetroidPrime/ScriptObjects/CFire.cpp"), + Object(MatchingFor("GM8E01_00", "GM8E01_01"), "MetroidPrime/ScriptObjects/CFire.cpp"), Object(MatchingFor("GM8E01_00", "GM8E01_01"), "MetroidPrime/CPauseScreenBlur.cpp"), Object(NonMatching, "MetroidPrime/Enemies/CTryclops.cpp"), Object(NonMatching, "MetroidPrime/Weapons/CNewFlameThrower.cpp"), diff --git a/include/Kyoto/Input/CFinalInput.hpp b/include/Kyoto/Input/CFinalInput.hpp index 43a24b25..36e30fb5 100644 --- a/include/Kyoto/Input/CFinalInput.hpp +++ b/include/Kyoto/Input/CFinalInput.hpp @@ -16,8 +16,8 @@ class CFinalInput { public: CFinalInput(); - CFinalInput(int channel, float dt, const CControllerGamepadData& data, float leftDif, - float rightDiv); + CFinalInput(const int channel, const float dt, const CControllerGamepadData& data, const float leftDiv, + const float rightDiv); CFinalInput(int channel, float dt, const COsContext& context); CFinalInput(const CFinalInput& other) : x0_dt(other.x0_dt) diff --git a/include/Kyoto/Math/CAABox.hpp b/include/Kyoto/Math/CAABox.hpp index 19c3e710..0e25a6bd 100644 --- a/include/Kyoto/Math/CAABox.hpp +++ b/include/Kyoto/Math/CAABox.hpp @@ -35,7 +35,8 @@ public: }; CAABox(const CVector3f& min, const CVector3f& max); - CAABox(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) + CAABox(const float minX, const float minY, const float minZ, const float maxX, const float maxY, + const float maxZ) : min(minX, minY, minZ), max(maxX, maxY, maxZ) {} CAABox(CInputStream& in); // CAABox(const CAABox& other) diff --git a/include/Kyoto/Particles/CElementGen.hpp b/include/Kyoto/Particles/CElementGen.hpp index cdc11f2b..d2c3d779 100644 --- a/include/Kyoto/Particles/CElementGen.hpp +++ b/include/Kyoto/Particles/CElementGen.hpp @@ -74,12 +74,13 @@ public: virtual void DestroyParticles() override; virtual void AddModifier(CWarp*) override; virtual uint Get4CharId() const override; - + int GetMaxParticles() const { return x90_MAXP; } int GetEmitterTime() const; int GetSystemCount(); int GetCumulativeParticleCount() const { return x260_cumulativeParticles; } - bool IsIndirectTextured() const; // { return x28_loadedGenDesc->x54_x40_TEXR && x28_loadedGenDesc->x58_x44_TIND; } + bool IsIndirectTextured() + const; // { return x28_loadedGenDesc->x54_x40_TEXR && x28_loadedGenDesc->x58_x44_TIND; } float GetExternalVar(int index) const; static void Initialize(); diff --git a/include/MetroidPrime/Decode.hpp b/include/MetroidPrime/Decode.hpp index 683cbb06..5c30db0f 100644 --- a/include/MetroidPrime/Decode.hpp +++ b/include/MetroidPrime/Decode.hpp @@ -25,7 +25,7 @@ const CArchMsgParmUserInput& GetParmUserInput(const CArchitectureMessage& msg); const CArchMsgParmInt32& GetParmNewGameflowState(const CArchitectureMessage& msg); -CArchitectureMessage CreateControllerStatus(EArchMsgTarget target, const short& chan, +CArchitectureMessage CreateControllerStatus(const EArchMsgTarget target, const short& chan, const bool& connected); CArchitectureMessage CreateQuitGameplay(EArchMsgTarget target); diff --git a/include/MetroidPrime/Player/CGameOptions.hpp b/include/MetroidPrime/Player/CGameOptions.hpp index 89c93e5f..3d8ed1fa 100644 --- a/include/MetroidPrime/Player/CGameOptions.hpp +++ b/include/MetroidPrime/Player/CGameOptions.hpp @@ -26,28 +26,28 @@ public: void ResetToDefaults(); void EnsureOptions(); - void SetScreenBrightness(int, bool); - float TuneScreenBrightness(); - void SetScreenPositionX(int, bool); - void SetScreenPositionY(int, bool); - void SetScreenStretch(int, bool); - void SetSfxVolume(int, bool); - void SetMusicVolume(int, bool); + void SetScreenBrightness(const int, const bool); + const float TuneScreenBrightness(); + void SetScreenPositionX(const int, const bool); + void SetScreenPositionY(const int, const bool); + void SetScreenStretch(const int, const bool); + void SetSfxVolume(const int, const bool); + void SetMusicVolume(const int,const bool); void SetSurroundMode(CAudioSys::ESurroundModes, bool); - float GetHudAlpha() const; - float GetHelmetAlpha() const; - void SetHelmetAlpha(int); - void SetHUDLag(bool); + const float GetHudAlpha() const; + const float GetHelmetAlpha() const; + void SetHelmetAlpha(const int); + void SetHUDLag(const bool); void SetIsHintSystemEnabled(bool); - void ToggleControls(bool); - void ResetControllerAssets(int); - void SetControls(int); + void ToggleControls(const bool); + void ResetControllerAssets(const int); + void SetControls(const int); - void SetInvertYAxis(bool invert); - bool GetInvertYAxis() const { return x68_25_invertY; } - void SetIsRumbleEnabled(bool rumble); - bool GetIsRumbleEnabled() const { return x68_26_rumble; } + void SetInvertYAxis(const bool invert); + const bool GetInvertYAxis() const { return x68_25_invertY; } + void SetIsRumbleEnabled(const bool rumble); + const bool GetIsRumbleEnabled() const { return x68_26_rumble; } private: rstl::reserved_vector< uchar, 64 > x0_; diff --git a/include/MetroidPrime/Player/CPlayer.hpp b/include/MetroidPrime/Player/CPlayer.hpp index d4c651e7..08353d9d 100644 --- a/include/MetroidPrime/Player/CPlayer.hpp +++ b/include/MetroidPrime/Player/CPlayer.hpp @@ -53,7 +53,7 @@ class CPlayer : public CPhysicsActor, public TOneStatic< CPlayer > { void SetSteam(float targetAlpha, float alphaInDur, float alphaOutDur, CAssetId txtr, bool affectsThermal); void Update(float dt); - float GetAlpha() const { return x20_alpha; } + const float GetAlpha() const { return x20_alpha; } bool AffectsThermal() const { return x28_affectsThermal; } }; @@ -377,6 +377,7 @@ public: void Teleport(const CTransform4f& xf, CStateManager& mgr, bool resetBallCam); void SetSpawnedMorphBallState(EPlayerMorphBallState state, CStateManager& mgr); const CVisorSteam& GetVisorSteam() const { return x7a0_visorSteam; } + const float GetVisorSteamAlpha() const { return x7a0_visorSteam.GetAlpha(); } void SetVisorSteam(float targetAlpha, float alphaInDur, float alphaOutDir, CAssetId txtr, bool affectsThermal); diff --git a/include/MetroidPrime/ScriptObjects/CFire.hpp b/include/MetroidPrime/ScriptObjects/CFire.hpp index f33d511c..9865fbd0 100644 --- a/include/MetroidPrime/ScriptObjects/CFire.hpp +++ b/include/MetroidPrime/ScriptObjects/CFire.hpp @@ -24,7 +24,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; // CActor - void Render(const CStateManager&) const override; + void AddToRenderer(const CFrustumPlanes&, const CStateManager&) const override; rstl::optional_object< CAABox > GetTouchBounds() const override; void Touch(CActor&, CStateManager&) override; diff --git a/include/MetroidPrime/TGameTypes.hpp b/include/MetroidPrime/TGameTypes.hpp index aec51c1a..054e7ef5 100644 --- a/include/MetroidPrime/TGameTypes.hpp +++ b/include/MetroidPrime/TGameTypes.hpp @@ -45,7 +45,6 @@ CHECK_SIZEOF(TEditorId, 0x4) struct TUniqueId { ushort value; - TUniqueId(ushort version, ushort id) : value(((version & 0x3F) << 10) | (id & 0x3FF)) {} ushort Value() const { return value & 0x3FF; } diff --git a/include/MetroidPrime/Weapons/CGameProjectile.hpp b/include/MetroidPrime/Weapons/CGameProjectile.hpp index 180e1e42..fa875367 100644 --- a/include/MetroidPrime/Weapons/CGameProjectile.hpp +++ b/include/MetroidPrime/Weapons/CGameProjectile.hpp @@ -1,6 +1,7 @@ #ifndef _CGAMEPROJECTILE #define _CGAMEPROJECTILE +#include "Collision/CRayCastResult.hpp" #include "types.h" #include "MetroidPrime/CStateManager.hpp" @@ -13,20 +14,25 @@ #include "rstl/vector.hpp" class CGenDescription; -class CProjectileTouchResult; +class CProjectileTouchResult { +public: +private: + TUniqueId x0_id; + rstl::optional_object< CRayCastResult > x4_result; +}; class CGameProjectile : public CWeapon { public: - CGameProjectile(bool active, const TToken< CWeaponDescription >&, const rstl::string& name, - EWeaponType wType, const CTransform4f& xf, EMaterialTypes excludeMat, - const CDamageInfo& dInfo, TUniqueId uid, TAreaId aid, TUniqueId owner, - TUniqueId homingTarget, uint attribs, bool underwater, - const CVector3f& scale, + CGameProjectile(const bool active, const TToken< CWeaponDescription >&, const rstl::string& name, + const EWeaponType wType, const CTransform4f& xf, const EMaterialTypes excludeMat, + const CDamageInfo& dInfo, const TUniqueId uid, const TAreaId aid, + const TUniqueId owner, const TUniqueId homingTarget, const uint attribs, + const bool underwater, const CVector3f& scale, const rstl::optional_object< TLockedToken< CGenDescription > >& visorParticle, - ushort visorSfx, bool sendCollideMsg); + const ushort visorSfx, bool sendCollideMsg); // CEntity - ~CGameProjectile() override; + ~CGameProjectile() override {} void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; @@ -39,6 +45,7 @@ public: virtual void ResolveCollisionWithActor(const CRayCastResult& res, CActor& act, CStateManager& mgr); + CProjectileTouchResult CanCollideWithTrigger(CActor& act, CStateManager& mgr); const CProjectileWeapon& GetProjectile() const { return x170_projectile; } const CVector3f& GetPreviousPos() const { return x298_previousPos; } TUniqueId GetHomingTargetId() const { return x2c0_homingTargetId; } @@ -49,8 +56,12 @@ public: void DeleteProjectileLight(CStateManager&); void ApplyDamageToActors(CStateManager& mgr, const CDamageInfo& dInfo); - CRayCastResult RayCollisionCheckWithWorld(TUniqueId& idOut, const CVector3f& start, const CVector3f& end, - float mag, const TEntityList& nearList, CStateManager& mgr); + CRayCastResult RayCollisionCheckWithWorld(TUniqueId& idOut, const CVector3f& start, + const CVector3f& end, float mag, + const TEntityList& nearList, CStateManager& mgr); + static EProjectileAttrib GetBeamAttribType(EWeaponType wType); + + CAABox GetProjectileBounds() const; protected: rstl::optional_object< TLockedToken< CGenDescription > > x158_visorParticle; diff --git a/include/MetroidPrime/Weapons/CProjectileWeapon.hpp b/include/MetroidPrime/Weapons/CProjectileWeapon.hpp index 1c8f6568..dce25ee9 100644 --- a/include/MetroidPrime/Weapons/CProjectileWeapon.hpp +++ b/include/MetroidPrime/Weapons/CProjectileWeapon.hpp @@ -20,11 +20,11 @@ class CParticleSwoosh; class CProjectileWeapon { public: // TODO ctor - + CProjectileWeapon(const TToken& wDesc, const CVector3f& origin, const CTransform4f& orient, const CVector3f& scale, const int); virtual ~CProjectileWeapon(); virtual void Update(float dt); virtual void AddToRenderer(); - virtual void Render(); + virtual void Render() const; virtual CVector3f GetTranslation() const; virtual CTransform4f GetTransform() const; diff --git a/include/MetroidPrime/Weapons/CWeapon.hpp b/include/MetroidPrime/Weapons/CWeapon.hpp index c188d731..625982d0 100644 --- a/include/MetroidPrime/Weapons/CWeapon.hpp +++ b/include/MetroidPrime/Weapons/CWeapon.hpp @@ -31,9 +31,9 @@ public: kPA_KeepInCinematic = (1 << 17), }; - CWeapon(TUniqueId uid, TAreaId areaId, bool active, TUniqueId owner, EWeaponType type, + CWeapon(const TUniqueId uid, const TAreaId areaId, const bool active, const TUniqueId owner, const EWeaponType type, const rstl::string& name, const CTransform4f& xf, const CMaterialFilter& filter, - const CMaterialList& mList, const CDamageInfo& dInfo, int attribs, + const CMaterialList& mList, const CDamageInfo& dInfo, const int attribs, const CModelData& mData); // CEntity diff --git a/src/MetroidPrime/Decode.cpp b/src/MetroidPrime/Decode.cpp index e0d85969..2463b341 100644 --- a/src/MetroidPrime/Decode.cpp +++ b/src/MetroidPrime/Decode.cpp @@ -41,7 +41,7 @@ const CArchMsgParmInt32& MakeMsg::GetParmNewGameflowState(const CArchitectureMes return *static_cast< const CArchMsgParmInt32* >(msg.GetParm()); } -CArchitectureMessage MakeMsg::CreateControllerStatus(EArchMsgTarget target, const short& chan, +CArchitectureMessage MakeMsg::CreateControllerStatus(const EArchMsgTarget target, const short& chan, const bool& connected) { return CArchitectureMessage(target, kAM_ControllerStatus, rs_new CArchMsgParmControllerStatus(chan, connected)); diff --git a/src/MetroidPrime/Player/CFaceplateDecoration.cpp b/src/MetroidPrime/Player/CFaceplateDecoration.cpp index 8ccadf2d..659593f3 100644 --- a/src/MetroidPrime/Player/CFaceplateDecoration.cpp +++ b/src/MetroidPrime/Player/CFaceplateDecoration.cpp @@ -27,7 +27,7 @@ void CFaceplateDecoration::Update(float dt, const CStateManager& mgr) { void CFaceplateDecoration::Draw(const CStateManager& stateMgr) const { if (x4_tex.valid() && x4_tex->IsLoaded()) { CTexture* texture = TToken< CTexture >(*x4_tex).GetT(); - float alpha = stateMgr.GetPlayer()->GetVisorSteam().GetAlpha(); + float alpha = stateMgr.GetPlayer()->GetVisorSteamAlpha(); if (!close_enough(alpha, 0.f)) { CCameraFilterPass::DrawFilter(CCameraFilterPass::kFT_Blend, CCameraFilterPass::kFS_FullscreenQuarters, diff --git a/src/MetroidPrime/Player/CGameOptions.cpp b/src/MetroidPrime/Player/CGameOptions.cpp index e336d270..a20ed176 100644 --- a/src/MetroidPrime/Player/CGameOptions.cpp +++ b/src/MetroidPrime/Player/CGameOptions.cpp @@ -167,7 +167,7 @@ void CGameOptions::SetScreenBrightness(int value, bool apply) { } } -float CGameOptions::TuneScreenBrightness() { +const float CGameOptions::TuneScreenBrightness() { float f = x48_screenBrightness - 4; return f / 4.f * 0.375f + 1.f; } @@ -223,21 +223,21 @@ void CGameOptions::SetSurroundMode(CAudioSys::ESurroundModes mode, bool apply) { } } -float CGameOptions::GetHudAlpha() const { return x60_hudAlpha * 0.003921569f; } +const float CGameOptions::GetHudAlpha() const { return x60_hudAlpha * 0.003921569f; } -float CGameOptions::GetHelmetAlpha() const { return x64_helmetAlpha * 0.003921569f; } +const float CGameOptions::GetHelmetAlpha() const { return x64_helmetAlpha * 0.003921569f; } -void CGameOptions::SetHelmetAlpha(int alpha) { x64_helmetAlpha = alpha; } +void CGameOptions::SetHelmetAlpha(const int alpha) { x64_helmetAlpha = alpha; } -void CGameOptions::SetHUDLag(bool flag) { x68_24_hudLag = flag; } +void CGameOptions::SetHUDLag(const bool flag) { x68_24_hudLag = flag; } void CGameOptions::SetIsHintSystemEnabled(bool flag) { x68_28_hintSystem = flag; } -void CGameOptions::SetInvertYAxis(bool flag) { x68_25_invertY = flag; } +void CGameOptions::SetInvertYAxis(const bool flag) { x68_25_invertY = flag; } -void CGameOptions::SetIsRumbleEnabled(bool flag) { x68_26_rumble = flag; } +void CGameOptions::SetIsRumbleEnabled(const bool flag) { x68_26_rumble = flag; } -void CGameOptions::ToggleControls(bool flag) { +void CGameOptions::ToggleControls(const bool flag) { x68_27_swapBeamsControls = flag; if (flag) { SetControls(1); diff --git a/src/MetroidPrime/ScriptObjects/CFire.cpp b/src/MetroidPrime/ScriptObjects/CFire.cpp index a651e0c4..5b13cfe2 100644 --- a/src/MetroidPrime/ScriptObjects/CFire.cpp +++ b/src/MetroidPrime/ScriptObjects/CFire.cpp @@ -1,14 +1,30 @@ #include "MetroidPrime/ScriptObjects/CFire.hpp" -#include "MetroidPrime/CActorParameters.hpp" -static inline CMaterialList MakeMaterialList() { return CMaterialList(kMT_Projectile); } +#include "Kyoto/CToken.hpp" +#include "Kyoto/SObjectTag.hpp" +#include "MetroidPrime/CActorParameters.hpp" +#include "MetroidPrime/CStateManager.hpp" +#include "MetroidPrime/Player/CPlayer.hpp" +#include "MetroidPrime/Player/CPlayerState.hpp" + +#include "Collision/CMaterialFilter.hpp" +#include "Collision/CMaterialList.hpp" + +#include "Kyoto/Math/CFrustumPlanes.hpp" +#include "MetaRender/CCubeRenderer.hpp" + +#include "rstl/optional_object.hpp" +#include + +static EMaterialTypes kSolidMat = kMT_Solid; +static EMaterialTypes kProjectileMat = kMT_Projectile; CFire::CFire(const TToken< CGenDescription >& effect, TUniqueId uid, TAreaId area, bool active, TUniqueId owner, const CTransform4f& xf, const CDamageInfo& dInfo, const CAABox& aabox, const CVector3f& vec, bool b1, CAssetId visorEffect, bool b2, bool b3, bool b4, float f1, float f2, float f3, float f4) : CActor(uid, active, "Fire", CEntityInfo(area, NullConnectionList), xf, - CModelData::CModelDataNull(), MakeMaterialList(), CActorParameters::None(), + CModelData::CModelDataNull(), CMaterialList(kProjectileMat), CActorParameters::None(), kInvalidUniqueId) , xe8_(rs_new CElementGen(effect)) , xec_owner(owner) @@ -19,7 +35,7 @@ CFire::CFire(const TToken< CGenDescription >& effect, TUniqueId uid, TAreaId are , x148_24_(b2) , x148_25_(b3) , x148_26_(b4) -, x148_27_(b2 && b3 && b4) +, x148_27_(b4 && b3 && b2) , x148_28_(false) , x148_29_(b1) , x14c_(f2) @@ -32,3 +48,91 @@ CFire::CFire(const TToken< CGenDescription >& effect, TUniqueId uid, TAreaId are } CFire::~CFire() {} + +void CFire::Touch(CActor& act, CStateManager& mgr) { + if (act.GetUniqueId() == xec_owner) { + return; + } + + mgr.ApplyDamage(GetUniqueId(), act.GetUniqueId(), GetUniqueId(), x10c_damageInfo2, + CMaterialFilter::MakeIncludeExclude(CMaterialList(kSolidMat), CMaterialList()), + CVector3f::Zero()); +} + +rstl::optional_object< CAABox > CFire::GetTouchBounds() const { + if (GetActive()) { + return x128_; + } + + return rstl::optional_object_null(); +} + +void CFire::AddToRenderer(const CFrustumPlanes& frustum, const CStateManager& mgr) const { + bool drawParticles = true; + if (!x148_27_) { + switch (mgr.GetPlayerState()->GetActiveVisor(mgr)) { + case CPlayerState::kPV_Combat: + case CPlayerState::kPV_Scan: + drawParticles = x148_24_; + break; + case CPlayerState::kPV_XRay: + drawParticles = x148_26_; + break; + case CPlayerState::kPV_Thermal: + drawParticles = x148_25_; + break; + } + } + + if (drawParticles) + gpRender->AddParticleGen(*xe8_); + CActor::AddToRenderer(frustum, mgr); +} + +void CFire::Accept(IVisitor& visitor) { visitor.Visit(*this); } + +void CFire::Think(float dt, CStateManager& mgr) { + const float particleCount = static_cast< float >(xe8_->GetParticleCount()) / + static_cast< float >(xe8_->GetMaxParticles()); + if (GetActive()) { + xe8_->Update(dt * x144_); + x10c_damageInfo2 = + CDamageInfo(xf0_damageInfo1, (particleCount > 0.5f ? particleCount : 0.f) * dt); + } + + bool doFree = false; + if (xe8_->IsSystemDeletable()) { + doFree = true; + } + + if (x148_29_) { + if (mgr.GetPlayer()->GetTouchBounds()->DoBoundsOverlap(*GetTouchBounds()) && !doFree && + particleCount > 0.5f) { + mgr.Player()->SetVisorSteam(particleCount * x14c_, x154_, x158_, x150_, true); + } else { + mgr.Player()->SetVisorSteam(0.f, 1.f, 1.f, kInvalidAssetId, true); + } + } + + x15c_ += dt; + + if (x15c_ > 45.f) + doFree = true; + + if (doFree) { + mgr.DeleteObjectRequest(GetUniqueId()); + } +} + +void CFire::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { + CActor::AcceptScriptMsg(msg, uid, mgr); + + switch (msg) { + case kSM_Registered: + xe8_->SetParticleEmission(true); + SetActive(true); + break; + default: + break; + } +}