From a71e48cf43ecc5a9d097aa6853d3d1f3f5f56f0d Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 16 Jul 2017 17:04:14 -1000 Subject: [PATCH] More work on CPlayer --- DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp | 8 +- DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp | 1 + DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp | 106 ++--- DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp | 22 +- DataSpec/DNAMP1/Tweaks/CTweakPlayerGun.hpp | 3 +- Editor/ViewManager.cpp | 2 +- Editor/ViewManager.hpp | 2 +- Runtime/CGameOptions.cpp | 8 +- Runtime/CGameOptions.hpp | 12 +- Runtime/CStateManager.cpp | 2 +- Runtime/Camera/CFirstPersonCamera.cpp | 19 +- Runtime/Camera/CFirstPersonCamera.hpp | 7 +- Runtime/Weapon/CGrappleArm.cpp | 5 + Runtime/Weapon/CGrappleArm.hpp | 15 + Runtime/Weapon/CPlayerGun.cpp | 10 + Runtime/Weapon/CPlayerGun.hpp | 2 + Runtime/World/CPlayer.cpp | 380 ++++++++++++++++-- Runtime/World/CPlayer.hpp | 106 +++-- amuse | 2 +- hecl | 2 +- 20 files changed, 558 insertions(+), 156 deletions(-) diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp index 674e2b0cf..b76298b1b 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp @@ -15,6 +15,7 @@ struct ITweakPlayer : ITweak virtual float GetX5C() const=0; virtual float GetHardLandingVelocityThreshold() const=0; virtual float GetHudLagAmount() const=0; + virtual float GetOrbitNormalDistance() const=0; virtual uint32_t GetOrbitScreenBoxHalfExtentX(int zone) const=0; virtual uint32_t GetOrbitScreenBoxHalfExtentY(int zone) const=0; virtual uint32_t GetOrbitScreenBoxCenterX(int zone) const=0; @@ -26,6 +27,7 @@ struct ITweakPlayer : ITweak virtual float GetOrbitZRange() const=0; virtual float GetScanningRange() const=0; // x218 virtual bool GetScanFreezesGame() const=0; // x21c_25 + virtual bool GetFiringCancelsCameraPitch() const=0; virtual float GetScanningFrameSenseRange() const=0; virtual float GetPlayerHeight() const=0; // x26c virtual float GetPlayerXYHalfExtent() const=0; // x270 @@ -33,6 +35,9 @@ struct ITweakPlayer : ITweak virtual float GetX274() const=0; // x274 virtual float GetX278() const=0; // x278 virtual float GetPlayerBallHalfExtent() const=0; // x27c + virtual float GetGrappleSwingPeriod() const=0; + virtual float GetGrappleJumpForce() const=0; + virtual uint32_t GetGrappleJumpMode() const=0; virtual float GetX124() const=0; // x134 virtual float GetX184() const=0; // x184 virtual float GetX1fc() const=0; @@ -49,7 +54,8 @@ struct ITweakPlayer : ITweak virtual float GetLeftLogicalThreshold() const=0; virtual float GetRightLogicalThreshold() const=0; virtual float GetX164(int type) const=0; - virtual uint32_t GetIceBreakPressCount() const=0; + virtual float GetFrozenTimeout() const=0; + virtual uint32_t GetIceBreakJumpCount() const=0; virtual float GetVariaDamageReduction() const=0; virtual float GetGravityDamageReduction() const=0; virtual float GetPhazonDamageReduction() const=0; diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp index 8c29c33f6..f569bb716 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp @@ -40,6 +40,7 @@ struct ITweakPlayerGun : ITweak virtual float GetX30() const = 0; // x30 virtual float GetX34() const = 0; // x34 virtual float GetX38() const = 0; // x38 + virtual float GetGunHolsterTime() const=0; virtual float GetGunNotFiringTime() const=0; virtual float GetRichochetDamage(atUint32) const = 0; }; diff --git a/DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp b/DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp index bb3bb50d7..92fb809b9 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp @@ -214,7 +214,7 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader) /* x22a_25_ */ x22a_25_ = __dna_reader.readBool(); /* x22a_26_ */ - x22a_26_ = __dna_reader.readBool(); + x22a_26_firingCancelsCameraPitch = __dna_reader.readBool(); /* x22a_27_ */ x22a_27_ = __dna_reader.readBool(); /* x22a_28_ */ @@ -272,7 +272,7 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader) /* x17c_ */ x17c_ = __dna_reader.readFloatBig(); /* x180_ */ - x180_ = __dna_reader.readFloatBig(); + x180_orbitNormalDistance = __dna_reader.readFloatBig(); /* x184_ */ x184_ = __dna_reader.readFloatBig(); /* x188_ */ @@ -365,8 +365,8 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader) x2a0_ = __dna_reader.readFloatBig(); /* x2a4_ */ x2a4_ = __dna_reader.readFloatBig(); - /* x2a8_ */ - x2a8_ = __dna_reader.readFloatBig(); + /* x2a8_grappleSwingPeriod */ + x2a8_grappleSwingPeriod = __dna_reader.readFloatBig(); /* x2ac_ */ x2ac_ = __dna_reader.readFloatBig(); /* x2b0_ */ @@ -381,12 +381,12 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader) x2c0_ = __dna_reader.readFloatBig(); /* x2c4_ */ x2c4_ = __dna_reader.readFloatBig(); - /* x2c8_ */ - x2c8_ = __dna_reader.readFloatBig(); + /* x2c8_grappleJumpForce */ + x2c8_grappleJumpForce = __dna_reader.readFloatBig(); /* x2cc_ */ x2cc_ = __dna_reader.readFloatBig(); - /* x2d0_ */ - x2d0_ = __dna_reader.readUint32Big(); + /* x2d0_grappleJumpMode */ + x2d0_grappleJumpMode = __dna_reader.readUint32Big(); /* x2d4_ */ x2d4_ = __dna_reader.readBool(); /* x2d5_ */ @@ -433,10 +433,10 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader) x2f0_ = __dna_reader.readFloatBig(); /* x2f4_ */ x2f4_ = __dna_reader.readBool(); - /* x2f8_ */ - x2f8_ = __dna_reader.readFloatBig(); - /* x2fc_ */ - x2fc_iceBreakPressCount = __dna_reader.readUint32Big(); + /* x2f8_frozenTimeout */ + x2f8_frozenTimeout = __dna_reader.readFloatBig(); + /* x2fc_iceBreakJumpCount */ + x2fc_iceBreakJumpCount = __dna_reader.readUint32Big(); /* x300_variaDamageReduction */ x300_variaDamageReduction = __dna_reader.readFloatBig(); /* x304_gravityDamageReduction */ @@ -654,7 +654,7 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const /* x22a_25_ */ __dna_writer.writeBool(x22a_25_); /* x22a_26_ */ - __dna_writer.writeBool(x22a_26_); + __dna_writer.writeBool(x22a_26_firingCancelsCameraPitch); /* x22a_27_ */ __dna_writer.writeBool(x22a_27_); /* x22a_28_ */ @@ -712,7 +712,7 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const /* x17c_ */ __dna_writer.writeFloatBig(x17c_); /* x180_ */ - __dna_writer.writeFloatBig(x180_); + __dna_writer.writeFloatBig(x180_orbitNormalDistance); /* x184_ */ __dna_writer.writeFloatBig(x184_); /* x188_ */ @@ -805,8 +805,8 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const __dna_writer.writeFloatBig(x2a0_); /* x2a4_ */ __dna_writer.writeFloatBig(x2a4_); - /* x2a8_ */ - __dna_writer.writeFloatBig(x2a8_); + /* x2a8_grappleSwingPeriod */ + __dna_writer.writeFloatBig(x2a8_grappleSwingPeriod); /* x2ac_ */ __dna_writer.writeFloatBig(x2ac_); /* x2b0_ */ @@ -821,12 +821,12 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const __dna_writer.writeFloatBig(x2c0_); /* x2c4_ */ __dna_writer.writeFloatBig(x2c4_); - /* x2c8_ */ - __dna_writer.writeFloatBig(x2c8_); + /* x2c8_grappleJumpForce */ + __dna_writer.writeFloatBig(x2c8_grappleJumpForce); /* x2cc_ */ __dna_writer.writeFloatBig(x2cc_); - /* x2d0_ */ - __dna_writer.writeUint32Big(x2d0_); + /* x2d0_grappleJumpMode */ + __dna_writer.writeUint32Big(x2d0_grappleJumpMode); /* x2d4_ */ __dna_writer.writeBool(x2d4_); /* x2d5_ */ @@ -873,10 +873,10 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const __dna_writer.writeFloatBig(x2f0_); /* x2f4_ */ __dna_writer.writeBool(x2f4_); - /* x2f8_ */ - __dna_writer.writeFloatBig(x2f8_); - /* x2fc_ */ - __dna_writer.writeUint32Big(x2fc_iceBreakPressCount); + /* x2f8_frozenTimeout */ + __dna_writer.writeFloatBig(x2f8_frozenTimeout); + /* x2fc_iceBreakJumpCount */ + __dna_writer.writeUint32Big(x2fc_iceBreakJumpCount); /* x300_variaDamageReduction */ __dna_writer.writeFloatBig(x300_variaDamageReduction); /* x304_gravityDamageReduction */ @@ -1123,8 +1123,8 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin) x22a_24_ = __dna_docin.readBool("x22a_24_"); /* x22a_25_ */ x22a_25_ = __dna_docin.readBool("x22a_25_"); - /* x22a_26_ */ - x22a_26_ = __dna_docin.readBool("x22a_26_"); + /* x22a_26_firingCancelsCameraPitch */ + x22a_26_firingCancelsCameraPitch = __dna_docin.readBool("x22a_26_firingCancelsCameraPitch"); /* x22a_27_ */ x22a_27_ = __dna_docin.readBool("x22a_27_"); /* x22a_28_ */ @@ -1196,8 +1196,8 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin) } /* x17c_ */ x17c_ = __dna_docin.readFloat("x17c_"); - /* x180_ */ - x180_ = __dna_docin.readFloat("x180_"); + /* x180_orbitNormalDistance */ + x180_orbitNormalDistance = __dna_docin.readFloat("x180_orbitNormalDistance"); /* x184_ */ x184_ = __dna_docin.readFloat("x184_"); /* x188_ */ @@ -1320,8 +1320,8 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin) x2a0_ = __dna_docin.readFloat("x2a0_"); /* x2a4_ */ x2a4_ = __dna_docin.readFloat("x2a4_"); - /* x2a8_ */ - x2a8_ = __dna_docin.readFloat("x2a8_"); + /* x2a8_grappleSwingPeriod */ + x2a8_grappleSwingPeriod = __dna_docin.readFloat("x2a8_grappleSwingPeriod"); /* x2ac_ */ x2ac_ = __dna_docin.readFloat("x2ac_"); /* x2b0_ */ @@ -1336,12 +1336,12 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin) x2c0_ = __dna_docin.readFloat("x2c0_"); /* x2c4_ */ x2c4_ = __dna_docin.readFloat("x2c4_"); - /* x2c8_ */ - x2c8_ = __dna_docin.readFloat("x2c8_"); + /* x2c8_grappleJumpForce */ + x2c8_grappleJumpForce = __dna_docin.readFloat("x2c8_grappleJumpForce"); /* x2cc_ */ x2cc_ = __dna_docin.readFloat("x2cc_"); - /* x2d0_ */ - x2d0_ = __dna_docin.readUint32("x2d0_"); + /* x2d0_grappleJumpMode */ + x2d0_grappleJumpMode = __dna_docin.readUint32("x2d0_grappleJumpMode"); /* x2d4_ */ x2d4_ = __dna_docin.readBool("x2d4_"); /* x2d5_ */ @@ -1388,10 +1388,10 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin) x2f0_ = __dna_docin.readFloat("x2f0_"); /* x2f4_ */ x2f4_ = __dna_docin.readBool("x2f4_"); - /* x2f8_ */ - x2f8_ = __dna_docin.readFloat("x2f8_"); - /* x2fc_iceBreakPressCount */ - x2fc_iceBreakPressCount = __dna_docin.readUint32("x2fc_iceBreakPressCount"); + /* x2f8_frozenTimeout */ + x2f8_frozenTimeout = __dna_docin.readFloat("x2f8_frozenTimeout"); + /* x2fc_iceBreakJumpCount */ + x2fc_iceBreakJumpCount = __dna_docin.readUint32("x2fc_iceBreakJumpCount"); /* x300_variaDamageReduction */ x300_variaDamageReduction = __dna_docin.readFloat("x300_variaDamageReduction"); /* x304_gravityDamageReduction */ @@ -1400,7 +1400,7 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin) x308_phazonDamageReduction = __dna_docin.readFloat("x308_phazonDamageReduction"); } -void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) const +void CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) const { /* x4_ */ if (auto v = __dna_docout.enterSubVector("x4_")) @@ -1632,8 +1632,8 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) __dna_docout.writeBool("x22a_24_", x22a_24_); /* x22a_25_ */ __dna_docout.writeBool("x22a_25_", x22a_25_); - /* x22a_26_ */ - __dna_docout.writeBool("x22a_26_", x22a_26_); + /* x22a_26_firingCancelsCameraPitch */ + __dna_docout.writeBool("x22a_26_firingCancelsCameraPitch", x22a_26_firingCancelsCameraPitch); /* x22a_27_ */ __dna_docout.writeBool("x22a_27_", x22a_27_); /* x22a_28_ */ @@ -1702,8 +1702,8 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) } /* x17c_ */ __dna_docout.writeFloat("x17c_", x17c_); - /* x180_ */ - __dna_docout.writeFloat("x180_", x180_); + /* x180_orbitNormalDistance */ + __dna_docout.writeFloat("x180_orbitNormalDistance", x180_orbitNormalDistance); /* x184_ */ __dna_docout.writeFloat("x184_", x184_); /* x188_ */ @@ -1820,8 +1820,8 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) __dna_docout.writeFloat("x2a0_", x2a0_); /* x2a4_ */ __dna_docout.writeFloat("x2a4_", x2a4_); - /* x2a8_ */ - __dna_docout.writeFloat("x2a8_", x2a8_); + /* x2a8_grappleSwingPeriod */ + __dna_docout.writeFloat("x2a8_grappleSwingPeriod", x2a8_grappleSwingPeriod); /* x2ac_ */ __dna_docout.writeFloat("x2ac_", x2ac_); /* x2b0_ */ @@ -1836,12 +1836,12 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) __dna_docout.writeFloat("x2c0_", x2c0_); /* x2c4_ */ __dna_docout.writeFloat("x2c4_", x2c4_); - /* x2c8_ */ - __dna_docout.writeFloat("x2c8_", x2c8_); + /* x2c8_grappleJumpForce */ + __dna_docout.writeFloat("x2c8_grappleJumpForce", x2c8_grappleJumpForce); /* x2cc_ */ __dna_docout.writeFloat("x2cc_", x2cc_); - /* x2d0_ */ - __dna_docout.writeUint32("x2d0_", x2d0_); + /* x2d0_grappleJumpMode */ + __dna_docout.writeUint32("x2d0_grappleJumpMode", x2d0_grappleJumpMode); /* x2d4_ */ __dna_docout.writeBool("x2d4_", x2d4_); /* x2d4_ */ @@ -1888,10 +1888,10 @@ void CTweakPlayer::CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) __dna_docout.writeFloat("x2f0_", x2f0_); /* x2f4_ */ __dna_docout.writeBool("x2f4_", x2f4_); - /* x2f8_ */ - __dna_docout.writeFloat("x2f8_", x2f8_); - /* x2fc_iceBreakPressCount */ - __dna_docout.writeUint32("x2fc_iceBreakPressCount", x2fc_iceBreakPressCount); + /* x2f8_frozenTimeout */ + __dna_docout.writeFloat("x2f8_frozenTimeout", x2f8_frozenTimeout); + /* x2fc_iceBreakJumpCount */ + __dna_docout.writeUint32("x2fc_iceBreakJumpCount", x2fc_iceBreakJumpCount); /* x300_variaDamageReduction */ __dna_docout.writeFloat("x300_variaDamageReduction", x300_variaDamageReduction); /* x304_gravityDamageReduction */ diff --git a/DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp b/DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp index 4b8eb05cf..6c1d7b08f 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp @@ -58,7 +58,7 @@ struct CTweakPlayer : ITweakPlayer Value x164_[3]; Value x170_[3]; Value x17c_; - Value x180_; + Value x180_orbitNormalDistance; Value x184_; Value x188_; Value x18c_; @@ -115,7 +115,7 @@ struct CTweakPlayer : ITweakPlayer Value x229_31_ : 1; Value x22a_24_ : 1; Value x22a_25_ : 1; - Value x22a_26_ : 1; + Value x22a_26_firingCancelsCameraPitch : 1; Value x22a_27_ : 1; Value x22a_28_ : 1; Value x22c_; @@ -149,7 +149,7 @@ struct CTweakPlayer : ITweakPlayer Value x29c_; Value x2a0_; Value x2a4_; - Value x2a8_; + Value x2a8_grappleSwingPeriod; Value x2ac_; Value x2b0_; Value x2b4_; @@ -157,9 +157,9 @@ struct CTweakPlayer : ITweakPlayer Value x2bc_; Value x2c0_; Value x2c4_; - Value x2c8_; + Value x2c8_grappleJumpForce; Value x2cc_; - Value x2d0_; + Value x2d0_grappleJumpMode; Value x2d4_; Value x2d5_; Value x2d8_; @@ -170,8 +170,8 @@ struct CTweakPlayer : ITweakPlayer Value x2ec_; Value x2f0_; Value x2f4_; - Value x2f8_; - Value x2fc_iceBreakPressCount; + Value x2f8_frozenTimeout; + Value x2fc_iceBreakJumpCount; Value x300_variaDamageReduction; Value x304_gravityDamageReduction; Value x308_phazonDamageReduction; @@ -181,6 +181,7 @@ struct CTweakPlayer : ITweakPlayer float GetX5C() const { return x44_[6]; } float GetHardLandingVelocityThreshold() const { return xc4_hardLandingVelocityThreshold; } float GetHudLagAmount() const { return x138_hudLagAmount; } + float GetOrbitNormalDistance() const { return x180_orbitNormalDistance; } uint32_t GetOrbitScreenBoxHalfExtentX(int zone) const { return x1a8_orbitScreenBoxHalfExtentX[zone]; } uint32_t GetOrbitScreenBoxHalfExtentY(int zone) const { return x1b0_orbitScreenBoxHalfExtentY[zone]; } uint32_t GetOrbitScreenBoxCenterX(int zone) const { return x1b8_orbitScreenBoxCenterX[zone]; } @@ -193,11 +194,15 @@ struct CTweakPlayer : ITweakPlayer float GetScanningRange() const { return x218_scanningRange; } bool GetScanFreezesGame() const { return x21c_25_scanFreezesGame; } float GetScanningFrameSenseRange() const { return x224_scanningFrameSenseRange; } + bool GetFiringCancelsCameraPitch() const { return x22a_26_firingCancelsCameraPitch; } float GetPlayerHeight() const { return x26c_playerHeight; } float GetPlayerXYHalfExtent() const { return x270_playerXYHalfExtent; } float GetX274() const { return x274_; } float GetX278() const { return x278_; } float GetPlayerBallHalfExtent() const { return x27c_playerBallHalfExtent; } + float GetGrappleSwingPeriod() const { return x2a8_grappleSwingPeriod; } + float GetGrappleJumpForce() const { return x2c8_grappleJumpForce; } + uint32_t GetGrappleJumpMode() const { return x2d0_grappleJumpMode; } float GetX124() const { return x134_; } float GetX184() const { return x184_; } float GetX1fc() const { return x1fc_; } @@ -215,7 +220,8 @@ struct CTweakPlayer : ITweakPlayer float GetLeftLogicalThreshold() const { return x150_leftDiv; } float GetRightLogicalThreshold() const { return x154_rightDiv; } float GetX164(int type) const { return x164_[type]; } - uint32_t GetIceBreakPressCount() const { return x2fc_iceBreakPressCount; } + float GetFrozenTimeout() const { return x2f8_frozenTimeout; } + uint32_t GetIceBreakJumpCount() const { return x2fc_iceBreakJumpCount; } float GetVariaDamageReduction() const { return x300_variaDamageReduction; } float GetGravityDamageReduction() const { return x304_gravityDamageReduction; } float GetPhazonDamageReduction() const { return x308_phazonDamageReduction; } diff --git a/DataSpec/DNAMP1/Tweaks/CTweakPlayerGun.hpp b/DataSpec/DNAMP1/Tweaks/CTweakPlayerGun.hpp index d44920c42..220df9389 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakPlayerGun.hpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakPlayerGun.hpp @@ -25,7 +25,7 @@ struct CTweakPlayerGun : ITweakPlayerGun Value x30_; Value x34_; Value x38_; - Value x3c_; + Value x3c_gunHolsterTime; Value x40_gunNotFiringTime; Value x44_; Value x48_; @@ -59,6 +59,7 @@ struct CTweakPlayerGun : ITweakPlayerGun float GetX30() const { return x30_; } float GetX34() const { return x34_; } float GetX38() const { return x38_; } + float GetGunHolsterTime() const { return x3c_gunHolsterTime; } float GetGunNotFiringTime() const { return x40_gunNotFiringTime; } float GetRichochetDamage(atUint32 type) const { diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index 8e0fab78a..49c88fba8 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -327,7 +327,7 @@ void ViewManager::pushRecentFile(const hecl::SystemString& path) void ViewManager::init(boo::IApplication* app) { - m_mainWindow = std::unique_ptr(app->newWindow(_S("URDE"), 1)); + m_mainWindow = app->newWindow(_S("URDE"), 1); m_mainWindow->showWindow(); m_mainWindow->setWaitCursor(true); diff --git a/Editor/ViewManager.hpp b/Editor/ViewManager.hpp index 744aa2676..a2bb0e272 100644 --- a/Editor/ViewManager.hpp +++ b/Editor/ViewManager.hpp @@ -30,7 +30,7 @@ class ViewManager : public specter::IViewManager friend class RootSpace; friend class SplitSpace; - std::unique_ptr m_mainWindow; + std::shared_ptr m_mainWindow; hecl::Runtime::FileStoreManager& m_fileStoreManager; hecl::CVarManager& m_cvarManager; ProjectManager m_projManager; diff --git a/Runtime/CGameOptions.cpp b/Runtime/CGameOptions.cpp index 5229447f8..0e8a7661e 100644 --- a/Runtime/CGameOptions.cpp +++ b/Runtime/CGameOptions.cpp @@ -65,8 +65,8 @@ CPersistentOptions::CPersistentOptions(CBitStreamReader& stream) for (int b=0 ; b<64 ; ++b) x68_[b] = stream.ReadEncoded(1); - xc0_freezeBreakCount = stream.ReadEncoded(2); - xc4_frozenCount = stream.ReadEncoded(2); + xc0_frozenFpsCount = stream.ReadEncoded(2); + xc4_frozenBallCount = stream.ReadEncoded(2); xc8_ = stream.ReadEncoded(1); xcc_logScanCount = stream.ReadEncoded(7); xd0_24_fusionLinked = stream.ReadEncoded(1); @@ -111,8 +111,8 @@ void CPersistentOptions::PutTo(CBitStreamWriter& w) const for (int b=0 ; b<64 ; ++b) w.WriteEncoded(x68_[b], 1); - w.WriteEncoded(xc0_freezeBreakCount, 2); - w.WriteEncoded(xc4_frozenCount, 2); + w.WriteEncoded(xc0_frozenFpsCount, 2); + w.WriteEncoded(xc4_frozenBallCount, 2); w.WriteEncoded(xc8_, 1); w.WriteEncoded(xcc_logScanCount, 7); w.WriteEncoded(xd0_24_fusionLinked, 1); diff --git a/Runtime/CGameOptions.hpp b/Runtime/CGameOptions.hpp index cc4eb41ae..28836386e 100644 --- a/Runtime/CGameOptions.hpp +++ b/Runtime/CGameOptions.hpp @@ -59,8 +59,8 @@ class CPersistentOptions bool x68_[64] = {}; std::vector> xac_cinematicStates; /* (MLVL, Cinematic) */ u32 xbc_autoMapperKeyState = 0; - u32 xc0_freezeBreakCount = 0; - u32 xc4_frozenCount = 0; + u32 xc0_frozenFpsCount = 0; + u32 xc4_frozenBallCount = 0; u32 xc8_ = 0; u32 xcc_logScanCount = 0; @@ -100,10 +100,10 @@ public: void SetAllItemsCollected(bool v) { xd0_29_allItemsCollected = v; } u32 GetLogScanCount() const { return xcc_logScanCount; } void SetLogScanCount(u32 v) { xcc_logScanCount = v; } - void IncrFreezeBreakCount() { xc0_freezeBreakCount = std::min(int(xc0_freezeBreakCount + 1), 3); } - bool GetShowBreakMessage() const { return xc0_freezeBreakCount != 3; } - void IncrFrozenCount() { xc4_frozenCount = std::min(int(xc4_frozenCount + 1), 3); } - bool GetShowFrozenMessage() const { return xc4_frozenCount != 3; } + void IncrementFrozenFpsCount() { xc0_frozenFpsCount = std::min(int(xc0_frozenFpsCount + 1), 3); } + bool GetShowFrozenFpsMessage() const { return xc0_frozenFpsCount != 3; } + void IncrementFrozenBallCount() { xc4_frozenBallCount = std::min(int(xc4_frozenBallCount + 1), 3); } + bool GetShowFrozenBallMessage() const { return xc4_frozenBallCount != 3; } void PutTo(CBitStreamWriter& w) const; u8* GetNESState() { return x0_; } diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index e0b457fbc..8d38f19bf 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -1362,7 +1362,7 @@ void CStateManager::ApplyDamageToWorld(TUniqueId damager, const CActor& actor, c { if (player->GetFrozenState()) { - g_GameState->SystemOptions().IncrFrozenCount(); + g_GameState->SystemOptions().IncrementFrozenBallCount(); CHUDMemoParms info = {0.f, true, true, true}; MP1::CSamusHud::DisplayHudMemo(u"", info); player->Stop(*this); diff --git a/Runtime/Camera/CFirstPersonCamera.cpp b/Runtime/Camera/CFirstPersonCamera.cpp index 455b2dbe5..778cd878f 100644 --- a/Runtime/Camera/CFirstPersonCamera.cpp +++ b/Runtime/Camera/CFirstPersonCamera.cpp @@ -86,9 +86,9 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt) playerXf.rotate({0.f, std::min(std::fabs(std::cos(x1c0_)), 1.0f), std::min(std::fabs(std::sin(x1c0_)), 1.0f)}); if (player->x3dc_inFreeLook) { - float angle = player->x3ec_; - if (std::fabs(player->x3ec_) > (g_tweakPlayer->GetX124() - std::fabs(x1c0_))) - angle = (player->x3ec_ > -0.f ? -1.f : 1.f); + float angle = player->x3ec_freeLookPitchAngle; + if (std::fabs(player->x3ec_freeLookPitchAngle) > (g_tweakPlayer->GetX124() - std::fabs(x1c0_))) + angle = (player->x3ec_freeLookPitchAngle > -0.f ? -1.f : 1.f); zeus::CVector3f vec; vec.z = std::sin(angle); vec.y = std::cos(-player->x3e4_) * std::cos(angle); @@ -124,9 +124,9 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt) player->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed && player->x3dc_inFreeLook && x1c4_pitchId == kInvalidUniqueId) { - if (player->x294_ > 0.f) + if (player->x294_jumpCameraPitchTimer > 0.f) { - float angle = zeus::clamp(0.f, (player->x294_ - g_tweakPlayer->GetX288()) / g_tweakPlayer->GetX28c(), 1.f) * + float angle = zeus::clamp(0.f, (player->x294_jumpCameraPitchTimer - g_tweakPlayer->GetX288()) / g_tweakPlayer->GetX28c(), 1.f) * g_tweakPlayer->GetX290(); angle += x1c0_; rVec.x = 0.f; @@ -135,9 +135,9 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt) rVec = playerXf.rotate(rVec); } - else if (player->x29c_ > 0.f) + else if (player->x29c_spaceJumpCameraPitchTimer > 0.f) { - float angle = zeus::clamp(0.f, (player->x29c_ - g_tweakPlayer->GetX294()) / g_tweakPlayer->GetX298(), 1.f) * + float angle = zeus::clamp(0.f, (player->x29c_spaceJumpCameraPitchTimer - g_tweakPlayer->GetX294()) / g_tweakPlayer->GetX298(), 1.f) * g_tweakPlayer->GetX29C(); rVec.x = 0.f; rVec.y = std::cos(angle); @@ -175,7 +175,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt) const CScriptGrapplePoint* gPoint = TCastToConstPtr(mgr.GetObjectById(player->x310_orbitTargetId)); - if (gPoint && player->x29c_ > 0.f) + if (gPoint && player->x29c_spaceJumpCameraPitchTimer > 0.f) { gunFrontVec = x190_gunFollowXf.frontVector(); if (gunFrontVec.canBeNormalized()) @@ -248,7 +248,8 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt) if (player->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed || player->GetOrbitState() == CPlayer::EPlayerOrbitState::Five || - player->x3b8_ == 0 || mgr.GetGameState() == CStateManager::EGameState::SoftPaused || + player->GetGrappleState() == CPlayer::EGrappleState::Zero || + mgr.GetGameState() == CStateManager::EGameState::SoftPaused || mgr.GetCameraManager()->IsInCinematicCamera()) { bobXf = zeus::CTransform::Identity(); diff --git a/Runtime/Camera/CFirstPersonCamera.hpp b/Runtime/Camera/CFirstPersonCamera.hpp index b15899f43..379c5e906 100644 --- a/Runtime/Camera/CFirstPersonCamera.hpp +++ b/Runtime/Camera/CFirstPersonCamera.hpp @@ -9,10 +9,10 @@ namespace urde class CFirstPersonCamera : public CGameCamera { float x188_; - u8 x18c_; + bool x18c_ = false; zeus::CTransform x190_gunFollowXf; - float x1c0_; - TUniqueId x1c4_pitchId; + float x1c0_ = 0.f; + TUniqueId x1c4_pitchId = kInvalidUniqueId; union { struct { @@ -40,6 +40,7 @@ public: void UpdateElevation(CStateManager&); void CalculateGunFollowOrientationAndTransform(zeus::CTransform&, zeus::CQuaternion&, float, zeus::CVector3f&); void SetScriptPitchId(TUniqueId uid) { x1c4_pitchId = uid; } + void SetX18C(bool v) { x18c_ = v; } }; } diff --git a/Runtime/Weapon/CGrappleArm.cpp b/Runtime/Weapon/CGrappleArm.cpp index 5b6bb9fea..920093556 100644 --- a/Runtime/Weapon/CGrappleArm.cpp +++ b/Runtime/Weapon/CGrappleArm.cpp @@ -11,4 +11,9 @@ void CGrappleArm::AsyncLoadSuit(CStateManager& mgr) { } +void CGrappleArm::SetAnimState(EArmState state) +{ + +} + } diff --git a/Runtime/Weapon/CGrappleArm.hpp b/Runtime/Weapon/CGrappleArm.hpp index f1b60bacc..bf69058a6 100644 --- a/Runtime/Weapon/CGrappleArm.hpp +++ b/Runtime/Weapon/CGrappleArm.hpp @@ -10,12 +10,27 @@ namespace urde class CGrappleArm { +public: + enum class EArmState + { + Zero, + One, + Two, + Three, + Four, + Five, + Six, + Seven, + Eight, + }; +private: CModelData x0_modelData; zeus::CTransform x220_; public: CGrappleArm(const zeus::CVector3f& vec); void AsyncLoadSuit(CStateManager& mgr); void SetX220(const zeus::CTransform& xf) { x220_ = xf; } + void SetAnimState(EArmState state); }; } diff --git a/Runtime/Weapon/CPlayerGun.cpp b/Runtime/Weapon/CPlayerGun.cpp index 252f0cd29..bed43dfc7 100644 --- a/Runtime/Weapon/CPlayerGun.cpp +++ b/Runtime/Weapon/CPlayerGun.cpp @@ -51,4 +51,14 @@ void CPlayerGun::ProcessInput(const CFinalInput& input, CStateManager& mgr) } +void CPlayerGun::ResetIdle(CStateManager& mgr) +{ + +} + +void CPlayerGun::CancelFiring(CStateManager& mgr) +{ + +} + } diff --git a/Runtime/Weapon/CPlayerGun.hpp b/Runtime/Weapon/CPlayerGun.hpp index 342d21799..b641f5ec2 100644 --- a/Runtime/Weapon/CPlayerGun.hpp +++ b/Runtime/Weapon/CPlayerGun.hpp @@ -224,6 +224,8 @@ public: CGrappleArm& GetGrappleArm() { return *x740_grappleArm; } void DamageRumble(const zeus::CVector3f& location, float damage, const CStateManager& mgr); void ProcessInput(const CFinalInput& input, CStateManager& mgr); + void ResetIdle(CStateManager& mgr); + void CancelFiring(CStateManager& mgr); }; } diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index 80f72e0e6..28256529f 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -370,7 +370,7 @@ void CPlayer::TakeDamage(bool significant, const zeus::CVector3f& location, } } - if (x3b8_) + if (x3b8_grappleState != EGrappleState::Zero) BreakGrapple(EPlayerOrbitRequest::Eleven, mgr); } @@ -582,7 +582,8 @@ void CPlayer::ProcessInput(const CFinalInput& input, CStateManager& mgr) UpdateVisorState(input, input.DeltaTime(), mgr); if (x2f8_morphTransState == EPlayerMorphBallState::Morphed || - (x2f8_morphTransState == EPlayerMorphBallState::Unmorphed && x498_ == 2)) + (x2f8_morphTransState == EPlayerMorphBallState::Unmorphed && + x498_gunHolsterState == EGunHolsterState::Drawn)) { x490_gun->ProcessInput(input, mgr); if (x2f8_morphTransState == EPlayerMorphBallState::Morphed && x2fc_ != kInvalidUniqueId) @@ -609,7 +610,7 @@ void CPlayer::ProcessInput(const CFinalInput& input, CStateManager& mgr) UpdateCameraState(mgr); UpdateMorphBallState(input, mgr); - UpdateCameraTimers(input); + UpdateCameraTimers(input.DeltaTime(), input); UpdateFootstepSounds(input, mgr, input.DeltaTime()); x2a8_ += input.DeltaTime(); @@ -812,14 +813,14 @@ void CPlayer::Stop(CStateManager& stateMgr) if (GetFrozenState()) { x750_frozenTimeout = 0.f; - x754_iceBreakPresses = 0; + x754_iceBreakJumps = 0; CPhysicsActor::Stop(); ClearForcesAndTorques(); RemoveMaterial(EMaterialTypes::Immovable, stateMgr); - if (!stateMgr.GetCameraManager()->IsInCinematicCamera() && xa0c_ != -1) + if (!stateMgr.GetCameraManager()->IsInCinematicCamera() && xa0c_iceTextureId != kInvalidResId) { std::experimental::optional> gpsm; - gpsm.emplace(g_SimplePool->GetObj(SObjectTag(FOURCC('PART'), xa0c_))); + gpsm.emplace(g_SimplePool->GetObj(SObjectTag(FOURCC('PART'), xa0c_iceTextureId))); CHUDBillboardEffect* effect = new CHUDBillboardEffect(gpsm, {}, stateMgr.AllocateUniqueId(), true, "FrostExplosion", CHUDBillboardEffect::GetNearClipDistance(stateMgr), CHUDBillboardEffect::GetScaleForPOV(stateMgr), zeus::CColor::skWhite, @@ -833,6 +834,43 @@ void CPlayer::Stop(CStateManager& stateMgr) } } +void CPlayer::Freeze(CStateManager& stateMgr, ResId steamTxtr, u16 sfx, ResId iceTxtr) +{ + if (stateMgr.GetCameraManager()->IsInCinematicCamera() || GetFrozenState()) + return; + + bool showMsg; + if (x2f8_morphTransState == EPlayerMorphBallState::Unmorphed) + showMsg = g_GameState->SystemOptions().GetShowFrozenFpsMessage(); + else + showMsg = g_GameState->SystemOptions().GetShowFrozenBallMessage(); + + if (showMsg) + { + const char16_t* msg = + g_MainStringTable->GetString(int(x2f8_morphTransState >= EPlayerMorphBallState::Morphed) + 19); + CHUDMemoParms parms(5.f, true, false, false); + MP1::CSamusHud::DisplayHudMemo(msg, parms); + } + + x750_frozenTimeout = x758_frozenTimeoutBias + g_tweakPlayer->GetFrozenTimeout(); + x754_iceBreakJumps = -x75c_additionalIceBreakJumps; + + CPhysicsActor::Stop(); + ClearForcesAndTorques(); + if (x3b8_grappleState != EGrappleState::Zero) + BreakGrapple(EPlayerOrbitRequest::Ten, stateMgr); + else + SetOrbitRequest(EPlayerOrbitRequest::Ten, stateMgr); + + AddMaterial(EMaterialTypes::Immovable, stateMgr); + xa08_steamTextureId = steamTxtr; + xa0c_iceTextureId = iceTxtr; + CSfxHandle hnd = CSfxManager::SfxStart(sfx, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); + ApplySubmergedPitchBend(hnd); + EndLandingControlFreeze(); +} + bool CPlayer::GetFrozenState() const { return x750_frozenTimeout > 0.f; } void CPlayer::UpdateFrozenState(const CFinalInput& input, CStateManager& mgr) @@ -860,7 +898,7 @@ void CPlayer::UpdateFrozenState(const CFinalInput& input, CStateManager& mgr) case EPlayerMorphBallState::Unmorphing: if (ControlMapper::GetAnalogInput(ControlMapper::ECommands::JumpOrBoost, input)) { - if (x754_iceBreakPresses) + if (x754_iceBreakJumps) { /* Subsequent Breaks */ CSfxHandle hnd = CSfxManager::SfxStart(3127, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); @@ -872,10 +910,10 @@ void CPlayer::UpdateFrozenState(const CFinalInput& input, CStateManager& mgr) CSfxHandle hnd = CSfxManager::SfxStart(3128, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); ApplySubmergedPitchBend(hnd); } - x754_iceBreakPresses += 1; - if (x754_iceBreakPresses > g_tweakPlayer->GetIceBreakPressCount()) + x754_iceBreakJumps += 1; + if (x754_iceBreakJumps > g_tweakPlayer->GetIceBreakJumpCount()) { - g_GameState->SystemOptions().IncrFreezeBreakCount(); + g_GameState->SystemOptions().IncrementFrozenFpsCount(); CHUDMemoParms info(0.f, true, true, true); MP1::CSamusHud::DisplayHudMemo(u"", info); Stop(mgr); @@ -1091,7 +1129,122 @@ void CPlayer::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CState void CPlayer::SetVisorSteam(float, float, float, ResId, bool) {} -void CPlayer::UpdateFootstepSounds(const CFinalInput& input, CStateManager&, float) {} +static const u16 skLeftStepSounds[] = +{ + 0xFFFF, 0x05B9, 0x05D7, 0x0622, 0x0653, + 0xFFFF, 0x05D5, 0x0611, 0x05D9, 0x0887, + 0x0699, 0x063A, 0x0631, 0xFFFF, 0x0629, + 0x05D7, 0x05D7, 0x05D9, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0x05F9, 0x0629 +}; + +static const u16 skRightStepSounds[] = +{ + 0xFFFF, 0x05BA, 0x05D8, 0x0623, 0x0654, + 0xFFFF, 0x05D6, 0x0612, 0x05DB, 0x0888, + 0x069A, 0x063B, 0x0632, 0xFFFF, 0x062A, + 0x05D8, 0x05D8, 0x05DB, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0x05FA, 0x062A +}; + +void CPlayer::UpdateFootstepSounds(const CFinalInput& input, CStateManager& mgr, float dt) +{ + if (x2f8_morphTransState != EPlayerMorphBallState::Unmorphed || + x258_movementState != EPlayerMovementState::OnGround || + x3dc_inFreeLook || x3dd_freeLookPitchAngleCalculated) + return; + + float sfxVol = 1.f; + x78c_footstepSfxTimer += dt; + float turn = std::fabs(TurnInput(input)); + float forward = std::fabs(ForwardInput(input, dt)); + float sfxDelay = 0.f; + if (forward > 0.05f || x304_orbitState != EPlayerOrbitState::Zero) + { + float vel = std::min(1.f, x138_velocity.magnitude() / GetActualFirstPersonMaxVelocity()); + if (vel > 0.05f) + { + sfxDelay = -0.475f * vel + 0.85f; + if (x790_footstepSfxSel == EFootstepSfx::None) + x790_footstepSfxSel = EFootstepSfx::Left; + } + else + { + x78c_footstepSfxTimer = 0.f; + x790_footstepSfxSel = EFootstepSfx::None; + } + + sfxVol = 0.3f * vel + 0.7f; + } + else if (turn > 0.05f) + { + if (x790_footstepSfxSel == EFootstepSfx::Left) + sfxDelay = -0.813f * turn + 1.f; + else + sfxDelay = -2.438f * turn + 3.f; + if (x790_footstepSfxSel == EFootstepSfx::None) + { + x790_footstepSfxSel = EFootstepSfx::Left; + sfxDelay = x78c_footstepSfxTimer; + } + sfxVol = 0.75f; + } + else + { + x78c_footstepSfxTimer = 0.f; + x790_footstepSfxSel = EFootstepSfx::None; + } + + if (x790_footstepSfxSel != EFootstepSfx::None && x78c_footstepSfxTimer > sfxDelay) + { + static float EarHeight = GetEyeHeight() - 0.1f; + if (xe6_24_fluidCounter && x828_waterLevelOnPlayer > 0.f && x828_waterLevelOnPlayer < EarHeight) + { + if (x82c_inLava) + { + if (x790_footstepSfxSel == EFootstepSfx::Left) + { + CSfxHandle hnd = CSfxManager::SfxStart(2183, sfxVol, 0.f, true, 0x7f, false, kInvalidAreaId); + ApplySubmergedPitchBend(hnd); + } + else + { + CSfxHandle hnd = CSfxManager::SfxStart(2184, sfxVol, 0.f, true, 0x7f, false, kInvalidAreaId); + ApplySubmergedPitchBend(hnd); + } + } + else + { + if (x790_footstepSfxSel == EFootstepSfx::Left) + { + CSfxHandle hnd = CSfxManager::SfxStart(1484, sfxVol, 0.f, true, 0x7f, false, kInvalidAreaId); + ApplySubmergedPitchBend(hnd); + } + else + { + CSfxHandle hnd = CSfxManager::SfxStart(1485, sfxVol, 0.f, true, 0x7f, false, kInvalidAreaId); + ApplySubmergedPitchBend(hnd); + } + } + } + else + { + u16 sfx; + if (x790_footstepSfxSel == EFootstepSfx::Left) + sfx = GetMaterialSoundUnderPlayer(mgr, skLeftStepSounds, 24, -1); + else + sfx = GetMaterialSoundUnderPlayer(mgr, skRightStepSounds, 24, -1); + CSfxHandle hnd = CSfxManager::SfxStart(sfx, sfxVol, 0.f, true, 0x7f, false, kInvalidAreaId); + ApplySubmergedPitchBend(hnd); + } + + x78c_footstepSfxTimer = 0.f; + if (x790_footstepSfxSel == EFootstepSfx::Left) + x790_footstepSfxSel = EFootstepSfx::Right; + else + x790_footstepSfxSel = EFootstepSfx::Left; + } +} u16 CPlayer::GetMaterialSoundUnderPlayer(CStateManager& mgr, const u16* table, u32 length, u16 defId) { @@ -1136,7 +1289,38 @@ void CPlayer::UpdateCameraState(CStateManager& mgr) {} void CPlayer::UpdateDebugCamera(CStateManager& mgr) {} -void CPlayer::UpdateCameraTimers(const CFinalInput& input) {} +void CPlayer::UpdateCameraTimers(float dt, const CFinalInput& input) +{ + if (x3dc_inFreeLook || x3dd_freeLookPitchAngleCalculated) + { + x294_jumpCameraPitchTimer = 0.f; + x29c_spaceJumpCameraPitchTimer = 0.f; + return; + } + + if (g_tweakPlayer->GetFiringCancelsCameraPitch()) + { + if (ControlMapper::GetDigitalInput(ControlMapper::ECommands::FireOrBomb, input) || + ControlMapper::GetDigitalInput(ControlMapper::ECommands::MissileOrPowerBomb, input)) + { + if (x288_startingJumpTimeout > 0.f) + { + x2a4_cancelCameraPitch = true; + return; + } + } + } + + if (ControlMapper::GetPressInput(ControlMapper::ECommands::JumpOrBoost, input)) + ++x298_jumpPresses; + + if (ControlMapper::GetDigitalInput(ControlMapper::ECommands::JumpOrBoost, input) && + x294_jumpCameraPitchTimer > 0.f && !x2a4_cancelCameraPitch && x298_jumpPresses <= 2) + x294_jumpCameraPitchTimer += dt; + + if (x29c_spaceJumpCameraPitchTimer > 0.f && !x2a4_cancelCameraPitch) + x29c_spaceJumpCameraPitchTimer += dt; +} void CPlayer::UpdateMorphBallState(const CFinalInput&, CStateManager& mgr) {} @@ -1164,9 +1348,30 @@ void CPlayer::ResetAimTargetPrediction(TUniqueId target) x3f4_aimTarget = target; } -void CPlayer::DrawGun(CStateManager& mgr) {} +void CPlayer::DrawGun(CStateManager& mgr) +{ + if (x498_gunHolsterState != EGunHolsterState::Holstered || InGrappleJumpCooldown()) + return; + x498_gunHolsterState = EGunHolsterState::Drawing; + x49c_gunNotFiringTimeout = 0.45f; + x490_gun->ResetIdle(mgr); +} -void CPlayer::HolsterGun(CStateManager& mgr) {} +void CPlayer::HolsterGun(CStateManager& mgr) +{ + if (x498_gunHolsterState == EGunHolsterState::Holstered || + x498_gunHolsterState == EGunHolsterState::Holstering) + return; + float time = x2f8_morphTransState == EPlayerMorphBallState::Morphing ? 0.1f : + g_tweakPlayerGun->GetGunHolsterTime(); + if (x498_gunHolsterState == EGunHolsterState::Drawing) + x49c_gunNotFiringTimeout = time * (1.f - x49c_gunNotFiringTimeout / 0.45f); + else + x49c_gunNotFiringTimeout = time; + x498_gunHolsterState = EGunHolsterState::Holstering; + x490_gun->CancelFiring(mgr); + ResetAimTargetPrediction(kInvalidUniqueId); +} void CPlayer::UpdateGrappleArmTransform(const zeus::CVector3f&, CStateManager& mgr, float) {} @@ -1176,11 +1381,55 @@ bool CPlayer::ValidateFPPosition(const zeus::CVector3f& pos, CStateManager& mgr) void CPlayer::UpdateGrappleState(const CFinalInput& input, CStateManager& mgr) {} -void CPlayer::ApplyGrappleJump(CStateManager& mgr) {} +void CPlayer::ApplyGrappleJump(CStateManager& mgr) +{ + if (TCastToPtr point = mgr.ObjectById(x310_orbitTargetId)) + { + zeus::CVector3f tmp = x3c0_grappleSwingAxis; + if (x3bc_grappleSwingTimer < 0.5f * g_tweakPlayer->GetGrappleSwingPeriod()) + tmp *= zeus::CVector3f::skNegOne; + zeus::CVector3f pointToPlayer = GetTranslation() - point->GetTranslation(); + zeus::CVector3f cross = pointToPlayer.normalized().cross(tmp); + zeus::CVector3f pointToPlayerFlat(pointToPlayer.x, pointToPlayer.y, 0.f); + float dot = 1.f; + if (pointToPlayerFlat.canBeNormalized() && cross.canBeNormalized()) + dot = zeus::clamp(-1.f, std::fabs(cross.normalized().dot(pointToPlayerFlat.normalized())), 1.f); + ApplyForceWR(g_tweakPlayer->GetGrappleJumpForce() * cross * 10000.f * dot, zeus::CAxisAngle::sIdentity); + } +} -void CPlayer::BeginGrapple(zeus::CVector3f&, CStateManager& mgr) {} +void CPlayer::BeginGrapple(zeus::CVector3f& vec, CStateManager& mgr) +{ + vec.z = 0.f; + if (vec.canBeNormalized()) + { + x3c0_grappleSwingAxis.x = vec.y; + x3c0_grappleSwingAxis.y = -vec.x; + x3c0_grappleSwingAxis.normalize(); + x3bc_grappleSwingTimer = 0.f; + SetOrbitState(EPlayerOrbitState::Five, mgr); + x3b8_grappleState = EGrappleState::Two; + RemoveMaterial(EMaterialTypes::GroundCollider, mgr); + } +} -void CPlayer::BreakGrapple(EPlayerOrbitRequest, CStateManager& mgr) {} +void CPlayer::BreakGrapple(EPlayerOrbitRequest req, CStateManager& mgr) +{ + x294_jumpCameraPitchTimer = 0.f; + x29c_spaceJumpCameraPitchTimer = 0.f; + if (g_tweakPlayer->GetGrappleJumpMode() == 2 && x3b8_grappleState == EGrappleState::Three) + { + ApplyGrappleJump(mgr); + PreventFallingCameraPitch(); + } + + SetOrbitRequest(req, mgr); + x3b8_grappleState = EGrappleState::Zero; + AddMaterial(EMaterialTypes::GroundCollider, mgr); + x490_gun->GetGrappleArm().SetAnimState(CGrappleArm::EArmState::Eight); + if (!InGrappleJumpCooldown() && x3b8_grappleState != EGrappleState::Four) + DrawGun(mgr); +} void CPlayer::SetOrbitRequest(EPlayerOrbitRequest req, CStateManager& mgr) { @@ -1200,24 +1449,85 @@ void CPlayer::SetOrbitRequest(EPlayerOrbitRequest req, CStateManager& mgr) } } -void CPlayer::PreventFallingCameraPitch() {} +bool CPlayer::InGrappleJumpCooldown() const +{ + if (x258_movementState == EPlayerMovementState::OnGround) + return false; + return x3d8_grappleJumpTimeout > 0.f || x294_jumpCameraPitchTimer == 0.f; +} -void CPlayer::OrbitCarcass(CStateManager&) {} +void CPlayer::PreventFallingCameraPitch() +{ + x294_jumpCameraPitchTimer = 0.f; + x29c_spaceJumpCameraPitchTimer = 0.01f; + x2a4_cancelCameraPitch = true; +} -void CPlayer::OrbitPoint(EPlayerOrbitType, CStateManager& mgr) {} +void CPlayer::OrbitCarcass(CStateManager& mgr) +{ + if (x304_orbitState == EPlayerOrbitState::One) + { + x308_orbitType = EPlayerOrbitType::Two; + SetOrbitState(EPlayerOrbitState::Three, mgr); + } +} -zeus::CVector3f CPlayer::GetHUDOrbitTargetPosition() const { return {}; } +void CPlayer::OrbitPoint(EPlayerOrbitType type, CStateManager& mgr) +{ + x308_orbitType = type; + SetOrbitState(EPlayerOrbitState::Two, mgr); + SetOrbitPosition(g_tweakPlayer->GetX164(int(x308_orbitType)), mgr); +} -void CPlayer::SetOrbitState(EPlayerOrbitState, CStateManager& mgr) {} +zeus::CVector3f CPlayer::GetHUDOrbitTargetPosition() const +{ + return x314_orbitPoint + x76c_cameraBob->GetCameraBobTransformation().origin; +} + +void CPlayer::SetOrbitState(EPlayerOrbitState state, CStateManager& mgr) +{ + x304_orbitState = state; + CFirstPersonCamera* cam = mgr.GetCameraManager()->GetFirstPersonCamera(); + switch (x304_orbitState) + { + case EPlayerOrbitState::One: + cam->SetX18C(false); + break; + case EPlayerOrbitState::Three: + { + cam->SetX18C(true); + zeus::CVector3f playerToPoint = x314_orbitPoint - GetTranslation(); + if (playerToPoint.canBeNormalized()) + x340_ = playerToPoint.magnitude(); + else + x340_ = 0.f; + SetOrbitTargetId(kInvalidUniqueId, mgr); + x33c_ = kInvalidUniqueId; + break; + } + case EPlayerOrbitState::Zero: + x32c_orbitDistance = g_tweakPlayer->GetOrbitNormalDistance(); + x32c_orbitDistance = 0.28f; + SetOrbitTargetId(kInvalidUniqueId, mgr); + x33c_ = kInvalidUniqueId; + break; + case EPlayerOrbitState::Two: + SetOrbitTargetId(kInvalidUniqueId, mgr); + x33c_ = kInvalidUniqueId; + break; + default: + break; + } +} void CPlayer::SetOrbitTargetId(TUniqueId id, CStateManager& mgr) { if (id != kInvalidUniqueId) { - x394_ = (TCastToPtr(mgr.ObjectById(id)) || - TCastToPtr(mgr.ObjectById(id)) || - CPatterned::CastTo(mgr.ObjectById(id)) || - TCastToPtr(mgr.ObjectById(id))); + x394_orbitingEnemy = (TCastToPtr(mgr.ObjectById(id)) || + TCastToPtr(mgr.ObjectById(id)) || + CPatterned::CastTo(mgr.ObjectById(id)) || + TCastToPtr(mgr.ObjectById(id))); } x310_orbitTargetId = id; @@ -1350,7 +1660,7 @@ void CPlayer::FindOrbitableObjects(const rstl::reserved_vector& { if (GetUniqueId() == act->GetUniqueId()) continue; - if (ValidateOrbitTargetId(act->GetUniqueId(), mgr)) + if (ValidateOrbitTargetId(act->GetUniqueId(), mgr) != EOrbitObjectType::Zero) continue; zeus::CVector3f orbitPos = act->GetOrbitPosition(mgr); zeus::CVector3f screenPos = fpCam->ConvertToScreenSpace(orbitPos); @@ -1471,7 +1781,7 @@ void CPlayer::ActivateOrbitSource(CStateManager& mgr) SetOrbitRequest(EPlayerOrbitRequest::Six, mgr); break; case 2: - if (x394_) + if (x394_orbitingEnemy) OrbitPoint(EPlayerOrbitType::One, mgr); else OrbitCarcass(mgr); @@ -1489,9 +1799,15 @@ float CPlayer::GetOrbitMaxLockDistance(CStateManager& mgr) const { return 0.f; } float CPlayer::GetOrbitMaxTargetDistance(CStateManager& mgr) const { return 0.f; } -bool CPlayer::ValidateOrbitTargetId(TUniqueId, CStateManager& mgr) const { return false; } +CPlayer::EOrbitObjectType CPlayer::ValidateOrbitTargetId(TUniqueId, CStateManager& mgr) const +{ + return EOrbitObjectType::Zero; +} -bool CPlayer::ValidateCurrentOrbitTargetId(CStateManager& mgr) { return false; } +CPlayer::EOrbitObjectType CPlayer::ValidateCurrentOrbitTargetId(CStateManager& mgr) +{ + return EOrbitObjectType::Zero; +} bool CPlayer::ValidateOrbitTargetIdAndPointer(TUniqueId, CStateManager& mgr) const { return false; } @@ -1779,7 +2095,7 @@ bool CPlayer::CheckSubmerged() const void CPlayer::UpdateSubmerged(CStateManager& mgr) { - x82c_ = false; + x82c_inLava = false; x828_waterLevelOnPlayer = 0.f; if (xe6_24_fluidCounter) { @@ -1788,7 +2104,7 @@ void CPlayer::UpdateSubmerged(CStateManager& mgr) x828_waterLevelOnPlayer = -(zeus::CVector3f::skUp.dot(x34_transform.origin) - water->GetTriggerBoundsWR().max.z); CFluidPlane::EFluidType fluidType = water->GetFluidPlane().GetFluidType(); - x82c_ = (fluidType == CFluidPlane::EFluidType::Two || fluidType == CFluidPlane::EFluidType::Five); + x82c_inLava = (fluidType == CFluidPlane::EFluidType::Two || fluidType == CFluidPlane::EFluidType::Five); CheckSubmerged(); } } diff --git a/Runtime/World/CPlayer.hpp b/Runtime/World/CPlayer.hpp index 98a82a1df..8aead76ef 100644 --- a/Runtime/World/CPlayer.hpp +++ b/Runtime/World/CPlayer.hpp @@ -41,7 +41,8 @@ public: enum class EPlayerOrbitType { Zero, - One + One, + Two }; enum class EPlayerOrbitState @@ -70,6 +71,17 @@ public: Eleven }; + enum class EOrbitObjectType + { + Zero, + One, + Two, + Three, + Four, + Five, + Six + }; + enum class EPlayerZoneInfo { Zero, @@ -121,6 +133,31 @@ public: SnakeWeed }; + enum class EFootstepSfx + { + None, + Left, + Right + }; + + enum class EGrappleState + { + Zero, + One, + Two, + Three, + Four, + Five + }; + + enum class EGunHolsterState + { + Holstered, + Drawing, + Drawn, + Holstering + }; + private: struct CVisorSteam { @@ -170,14 +207,14 @@ private: TUniqueId x26c_ = kInvalidUniqueId; float x270_ = 0.f; CPlayerEnergyDrain x274_energyDrain = CPlayerEnergyDrain(4); - float x288_ = 0.f; + float x288_startingJumpTimeout = 0.f; float x28c_sjTimer = 0.f; float x290_ = 0.f; - float x294_ = 0.f; - u32 x298_ = 0; - float x29c_ = 0.f; + float x294_jumpCameraPitchTimer = 0.f; + u32 x298_jumpPresses = 0; + float x29c_spaceJumpCameraPitchTimer = 0.f; float x2a0_ = 0.f; - u8 x2a4_ = 0; + bool x2a4_cancelCameraPitch = false; float x2a8_ = 1000.f; EPlayerMovementSurface x2ac_movementSurface = EPlayerMovementSurface::Normal; u32 x2b0_ = 2; @@ -196,7 +233,7 @@ private: TUniqueId x310_orbitTargetId = kInvalidUniqueId; zeus::CVector3f x314_orbitPoint; zeus::CVector3f x320_orbitVector; - float x32c_ = 0.f; + float x32c_orbitDistance = 0.f; EPlayerZoneInfo x330_orbitZone = EPlayerZoneInfo::Zero; EPlayerZoneType x334_orbitType = EPlayerZoneType::Ellipse; u32 x338_ = 1; @@ -207,36 +244,34 @@ private: std::vector x364_offScreenOrbitObjects; bool x374_ = false; float x378_ = 0.f; - u8 x37c_ = 0; + bool x37c_ = false; float x380_ = 0.f; float x384_ = 0.f; float x388_ = 0.f; bool x38c_ = false; u32 x390_orbitSource = 2; - u8 x394_ = 0; + bool x394_orbitingEnemy = false; float x398_ = 1.5f; - u8 x39c_ = 0; + bool x39c_ = false; float x3a0_ = 0.5f; float x3a4_ = 0.449f; EPlayerScanState x3a8_scanState = EPlayerScanState::NotScanning; float x3ac_scanningTime = 0.f; float x3b0_ = 0.f; TUniqueId x3b4_scanningObject = kInvalidUniqueId; - u32 x3b8_ = 0; - float x3bc_ = 0.f; - float x3c0_ = 1.0f; - float x3c4_ = 0.f; - float x3c8_ = 0.f; + EGrappleState x3b8_grappleState = EGrappleState::Zero; + float x3bc_grappleSwingTimer = 0.f; + zeus::CVector3f x3c0_grappleSwingAxis = zeus::CVector3f::skRight; float x3cc_ = 0.f; float x3d0_ = 0.f; float x3d4_ = 0.f; - float x3d8_ = 0.f; - bool x3dc_inFreeLook = 0; - bool x3dd_ = 0; - bool x3de_lookControlHeld = 0; + float x3d8_grappleJumpTimeout = 0.f; + bool x3dc_inFreeLook = false; + bool x3dd_freeLookPitchAngleCalculated = false; + bool x3de_lookControlHeld = false; float x3e4_ = 0.f; float x3e8_ = 0.f; - float x3ec_ = 0.f; + float x3ec_freeLookPitchAngle = 0.f; float x3f0_ = 0.f; TUniqueId x3f4_aimTarget = kInvalidUniqueId; zeus::CVector3f x3f8_targetAimPosition = zeus::CVector3f::skZero; @@ -245,7 +280,7 @@ private: float x48c_ = 0.f; std::unique_ptr x490_gun; float x494_mapAlpha = 1.f; - u32 x498_ = 2; + EGunHolsterState x498_gunHolsterState = EGunHolsterState::Drawn; float x49c_gunNotFiringTimeout; std::unique_ptr x4a0_failsafeTest; u32 x4a4_ = 0; @@ -278,9 +313,9 @@ private: float x748_ = 0.f; float x74c_visorStaticAlpha = 1.f; float x750_frozenTimeout = 0.f; - u32 x754_iceBreakPresses = 0; - float x758_ = 0.f; - u32 x75c_ = 0; + s32 x754_iceBreakJumps = 0; + float x758_frozenTimeoutBias = 0.f; + s32 x75c_additionalIceBreakJumps = 0; bool x760_controlsFrozen = false; float x764_controlsFrozenTimeout = 0.f; std::unique_ptr x768_morphball; @@ -292,18 +327,18 @@ private: int x780_samusVoicePriority = 0; float x784_ = 0.f; u16 x788_damageLoopSfxId = 0; - float x78c_ = 0.f; - u32 x790_ = 0; + float x78c_footstepSfxTimer = 0.f; + EFootstepSfx x790_footstepSfxSel = EFootstepSfx::None; zeus::CVector3f x794_; - CVisorSteam x7a0_visorSteam = CVisorSteam(0.f, 0.f, 0.f, -1); - ResId x7cc_ = -1; + CVisorSteam x7a0_visorSteam = CVisorSteam(0.f, 0.f, 0.f, kInvalidResId); + ResId x7cc_ = kInvalidResId; CAnimRes x7d0_animRes; CPlayerState::EBeamId x7ec_beam = CPlayerState::EBeamId::Power; std::unique_ptr x7f0_ballTransitionBeamModel; zeus::CTransform x7f4_; float x824_ = 0.f; float x828_waterLevelOnPlayer = 0.f; - bool x82c_ = false; + bool x82c_inLava = false; TUniqueId x82e_ridingPlatform = kInvalidUniqueId; TUniqueId x830_ = kInvalidUniqueId; u32 x834_ = 1000; @@ -357,8 +392,8 @@ private: float x9fc_ = 0.f; TUniqueId xa00_ = kInvalidUniqueId; float xa04_ = 0.f; - ResId xa08_steamTextureId = -1; - ResId xa0c_; + ResId xa08_steamTextureId = kInvalidResId; + ResId xa0c_iceTextureId; u32 xa10_phazonCounter = 0; float xa14_ = 0.f; float xa18_ = 0.f; @@ -428,6 +463,7 @@ public: void CalculatePlayerControlDirection(CStateManager& mgr); void CalculatePlayerMovementDirection(float dt); void Stop(CStateManager& stateMgr); + void Freeze(CStateManager& stateMgr, ResId steamTxtr, u16 sfx, ResId iceTxtr); bool GetFrozenState() const; void UpdateFrozenState(const CFinalInput& input, CStateManager& mgr); void Think(float, CStateManager&); @@ -444,7 +480,7 @@ public: void ForceGunOrientation(const zeus::CTransform&, CStateManager& mgr); void UpdateCameraState(CStateManager& mgr); void UpdateDebugCamera(CStateManager& mgr); - void UpdateCameraTimers(const CFinalInput& input); + void UpdateCameraTimers(float dt, const CFinalInput& input); void UpdateMorphBallState(const CFinalInput&, CStateManager& mgr); CFirstPersonCamera& GetFirstPersonCamera(CStateManager& mgr); void UpdateGunTransform(const zeus::CVector3f&, float, CStateManager& mgr, bool); @@ -463,6 +499,7 @@ public: void BeginGrapple(zeus::CVector3f&, CStateManager& mgr); void BreakGrapple(EPlayerOrbitRequest, CStateManager& mgr); void SetOrbitRequest(EPlayerOrbitRequest req, CStateManager& mgr); + bool InGrappleJumpCooldown() const; void PreventFallingCameraPitch(); void OrbitCarcass(CStateManager&); void OrbitPoint(EPlayerOrbitType, CStateManager& mgr); @@ -501,8 +538,8 @@ public: void UpdateOrbitTarget(CStateManager& mgr); float GetOrbitMaxLockDistance(CStateManager& mgr) const; float GetOrbitMaxTargetDistance(CStateManager& mgr) const; - bool ValidateOrbitTargetId(TUniqueId, CStateManager& mgr) const; - bool ValidateCurrentOrbitTargetId(CStateManager& mgr); + EOrbitObjectType ValidateOrbitTargetId(TUniqueId uid, CStateManager& mgr) const; + EOrbitObjectType ValidateCurrentOrbitTargetId(CStateManager& mgr); bool ValidateOrbitTargetIdAndPointer(TUniqueId, CStateManager& mgr) const; zeus::CVector3f GetBallPosition() const; zeus::CVector3f GetEyePosition() const; @@ -536,6 +573,7 @@ public: float GetScanningTime() const { return x3ac_scanningTime; } TUniqueId GetOrbitTargetId() const { return x310_orbitTargetId; } TUniqueId GetScanningObjectId() const { return x3b4_scanningObject; } + EGrappleState GetGrappleState() const { return x3b8_grappleState; } bool IsNewScanScanning() const { return x9c6_30_newScanScanning; } float GetThreatOverride() const { return xa1c_threatOverride; } bool IsOverrideRadarRadius() const { return x9c6_31_overrideRadarRadius; } diff --git a/amuse b/amuse index 0bace131e..aef2b2a70 160000 --- a/amuse +++ b/amuse @@ -1 +1 @@ -Subproject commit 0bace131e877b24f29924b7d6887100e81461b48 +Subproject commit aef2b2a7074e0947771d92ac52069841dad69b20 diff --git a/hecl b/hecl index 8a6ffc988..d4f08d45d 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 8a6ffc988577d52774e1a377a793c069517cf9a7 +Subproject commit d4f08d45d929733e7c10fa3993bf915aa54c074f