From 4528a6b60aff70508ca34d3015315745067cdeba Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 23 Jul 2017 13:45:04 -1000 Subject: [PATCH] Additional CPlayer work --- .idea/misc.xml | 2 +- DataSpec/AssetMap32Download.cmake | 3 + DataSpec/AssetMap64Download.cmake | 3 + DataSpec/CMakeLists.txt | 15 +- DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp | 17 +- DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp | 15 +- DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp | 222 ++++++------ DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp | 43 ++- Runtime/Camera/CFirstPersonCamera.cpp | 2 +- Runtime/Collision/CCollisionActor.cpp | 10 +- Runtime/Collision/CGameCollision.cpp | 20 +- Runtime/Collision/CGameCollision.hpp | 3 + Runtime/Collision/CMaterialList.hpp | 2 +- Runtime/RetroTypes.hpp | 7 + Runtime/Weapon/CGrappleArm.hpp | 7 +- Runtime/Weapon/CGunWeapon.hpp | 18 + Runtime/Weapon/CPlayerGun.cpp | 7 + Runtime/Weapon/CPlayerGun.hpp | 6 +- Runtime/World/CGrappleParameters.hpp | 8 +- Runtime/World/CPlayer.cpp | 399 +++++++++++++++++++-- Runtime/World/CPlayer.hpp | 18 +- Runtime/World/CScriptGrapplePoint.hpp | 1 + Runtime/World/CScriptPlatform.cpp | 2 +- Runtime/rstl.hpp | 103 ++++++ hecl | 2 +- 25 files changed, 733 insertions(+), 202 deletions(-) create mode 100644 DataSpec/AssetMap32Download.cmake create mode 100644 DataSpec/AssetMap64Download.cmake diff --git a/.idea/misc.xml b/.idea/misc.xml index 79b3c9483..674375dd3 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/DataSpec/AssetMap32Download.cmake b/DataSpec/AssetMap32Download.cmake new file mode 100644 index 000000000..9d7612a1d --- /dev/null +++ b/DataSpec/AssetMap32Download.cmake @@ -0,0 +1,3 @@ +message(STATUS "32-bit asset name map not found; downloading to '${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap32.bin'") +file(DOWNLOAD "https://www.dropbox.com/s/8rzkxstfap6hgi3/AssetNameMap32.dat" + ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap32.bin SHOW_PROGRESS) \ No newline at end of file diff --git a/DataSpec/AssetMap64Download.cmake b/DataSpec/AssetMap64Download.cmake new file mode 100644 index 000000000..86244a3cc --- /dev/null +++ b/DataSpec/AssetMap64Download.cmake @@ -0,0 +1,3 @@ +message(STATUS "64-bit asset name map not found; downloading to '${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap64.bin'") +file(DOWNLOAD "https://www.dropbox.com/s/o1pp3ctu5dyhfwx/AssetNameMap64.dat" + ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap64.bin SHOW_PROGRESS) \ No newline at end of file diff --git a/DataSpec/CMakeLists.txt b/DataSpec/CMakeLists.txt index f3bfc9128..3a3ef2971 100644 --- a/DataSpec/CMakeLists.txt +++ b/DataSpec/CMakeLists.txt @@ -41,18 +41,13 @@ include(DNAMP3/CMakeLists.txt) # Embed master shader script bintoc(RetroMasterShader.c Blender/RetroMasterShader.py RETRO_MASTER_SHADER) -if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap32.bin") - message(STATUS "Downloading 32bit ID map to '${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap32.bin'") - file(DOWNLOAD "https://www.dropbox.com/s/8rzkxstfap6hgi3/AssetNameMap32.dat" - ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap32.bin SHOW_PROGRESS) -endif() +# Download asset name databases +add_custom_command(OUTPUT AssetNameMap32.bin COMMAND ${CMAKE_COMMAND} ARGS -P + ${CMAKE_CURRENT_SOURCE_DIR}/AssetMap32Download.cmake) bintoc(AssetNameMap32.c ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap32.bin ASSET_NAME_MP32) -if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap64.bin") - message(STATUS "Downloading 64bit ID map to '${CMAKE_CURRENT_BINARY_DIR}/DNAMP3/AssetNameMap64.bin'") - file(DOWNLOAD "https://www.dropbox.com/s/o1pp3ctu5dyhfwx/AssetNameMap64.dat" - ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap64.bin SHOW_PROGRESS) -endif() +add_custom_command(OUTPUT AssetNameMap64.bin COMMAND ${CMAKE_COMMAND} ARGS -P + ${CMAKE_CURRENT_SOURCE_DIR}/AssetMap64Download.cmake) bintoc(AssetNameMap64.c ${CMAKE_CURRENT_BINARY_DIR}/AssetNameMap64.bin ASSET_NAME_MP64) # Each game's DataSpec implementation diff --git a/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp b/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp index 3fe91543f..6f8b0c4f5 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp @@ -14,8 +14,8 @@ struct ITweakGunRes : ITweak { Power, Ice, - Plasma, Wave, + Plasma, Phazon }; @@ -49,25 +49,32 @@ struct ITweakGunRes : ITweak ResId GetBeamModel(EBeamId beam) const { - int b = int(beam); + auto b = int(beam); if (b < 0 || b > 4) b = 0; switch (EBeamId(b)) { case EBeamId::Power: - default: return x10_powerBeam; case EBeamId::Ice: return x14_iceBeam; - case EBeamId::Plasma: - return x1c_plasmaBeam; case EBeamId::Wave: return x18_waveBeam; + case EBeamId::Plasma: + return x1c_plasmaBeam; case EBeamId::Phazon: return x20_phazonBeam; } } + const ResId* GetWeaponPair(EBeamId beam) const + { + auto b = int(beam); + if (b < 0 || b > 4) + return x34_weapons[0]; + return x34_weapons[b]; + } + void ResolveResources(const urde::IFactory& factory) { x4_gunMotion = factory.GetResourceIdByName(GetGunMotion().c_str())->id; diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp index 267d69927..d213d3ba8 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp @@ -13,7 +13,8 @@ struct ITweakPlayer : ITweak virtual float GetX54() const=0; virtual float GetX58() const=0; virtual float GetX5C() const=0; - virtual float GetHardLandingVelocityThreshold() const=0; + virtual float GetNormalGravAccel() const=0; + virtual float GetFluidGravAccel() const=0; virtual float GetHudLagAmount() const=0; virtual float GetOrbitNormalDistance() const=0; virtual uint32_t GetOrbitScreenBoxHalfExtentX(int zone) const=0; @@ -28,6 +29,10 @@ struct ITweakPlayer : ITweak virtual float GetScanningRange() const=0; // x218 virtual bool GetScanFreezesGame() const=0; // x21c_25 virtual bool GetFiringCancelsCameraPitch() const=0; + virtual bool GetAssistedAimingIgnoreHorizontal() const=0; + virtual bool GetAssistedAimingIgnoreVertical() const=0; + virtual float GetAimAssistHorizontalAngle() const=0; + virtual float GetAimAssistVerticalAngle() const=0; virtual float GetScanningFrameSenseRange() const=0; virtual bool GetGunButtonTogglesHolster() const=0; virtual bool GetGunNotFiringHolstersGun() const=0; @@ -37,10 +42,18 @@ struct ITweakPlayer : ITweak virtual float GetX274() const=0; // x274 virtual float GetX278() const=0; // x278 virtual float GetPlayerBallHalfExtent() const=0; // x27c + virtual float GetGrappleSwingLength() const=0; virtual float GetGrappleSwingPeriod() const=0; + virtual float GetGrapplePullSpeedMin() const=0; + virtual float GetMaxGrappleLockedTurnAlignDistance() const=0; + virtual float GetGrapplePullSpeedProportion() const=0; + virtual float GetGrapplePullSpeedMax() const=0; + virtual float GetGrappleLookCenterSpeed() const=0; + virtual float GetMaxGrappleTurnSpeed() const=0; virtual float GetGrappleJumpForce() const=0; virtual float GetGrappleReleaseTime() const=0; virtual uint32_t GetGrappleJumpMode() const=0; + virtual bool InvertGrappleTurn() const=0; virtual float GetX124() const=0; // x134 virtual float GetX184() const=0; // x184 virtual float GetX1fc() const=0; diff --git a/DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp b/DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp index 18b5f7f95..8c0ab989b 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakPlayer.cpp @@ -103,10 +103,10 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader) xa4_[6] = __dna_reader.readFloatBig(); /* xa4_[7] */ xa4_[7] = __dna_reader.readFloatBig(); - /* xc4_hardLandingVelocityThreshold */ - xc4_hardLandingVelocityThreshold = __dna_reader.readFloatBig(); - /* xc8_ */ - xc8_ = __dna_reader.readFloatBig(); + /* xc4_normalGravAccel */ + xc4_normalGravAccel = __dna_reader.readFloatBig(); + /* xc8_fluidGravAccel */ + xc8_fluidGravAccel = __dna_reader.readFloatBig(); /* xcc_ */ xcc_ = __dna_reader.readFloatBig(); /* xd0_ */ @@ -215,10 +215,10 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader) x22a_25_ = __dna_reader.readBool(); /* x22a_26_ */ x22a_26_firingCancelsCameraPitch = __dna_reader.readBool(); - /* x22a_27_ */ - x22a_27_ = __dna_reader.readBool(); - /* x22a_28_ */ - x22a_28_ = __dna_reader.readBool(); + /* x22a_27_assistedAimingIgnoreHorizontal */ + x22a_27_assistedAimingIgnoreHorizontal = __dna_reader.readBool(); + /* x22a_28_assistedAimingIgnoreVertical */ + x22a_28_assistedAimingIgnoreVertical = __dna_reader.readBool(); /* x22c_ */ x22c_ = __dna_reader.readFloatBig(); /* x230_ */ @@ -247,10 +247,10 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader) x25c_ = __dna_reader.readFloatBig(); /* x260_ */ x260_ = __dna_reader.readFloatBig(); - /* x264_ */ - x264_ = __dna_reader.readFloatBig(); - /* x268_ */ - x268_ = __dna_reader.readFloatBig(); + /* x264_aimAssistHorizontalAngle */ + x264_aimAssistHorizontalAngle = __dna_reader.readFloatBig(); + /* x268_aimAssistVerticalAngle */ + x268_aimAssistVerticalAngle = __dna_reader.readFloatBig(); /* x158_[0] */ x158_[0] = __dna_reader.readFloatBig(); /* x164_[0] */ @@ -363,24 +363,24 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader) x224_scanningFrameSenseRange = __dna_reader.readFloatBig(); /* x2a0_ */ x2a0_ = __dna_reader.readFloatBig(); - /* x2a4_ */ - x2a4_ = __dna_reader.readFloatBig(); + /* x2a4_grappleSwingLength */ + x2a4_grappleSwingLength = __dna_reader.readFloatBig(); /* x2a8_grappleSwingPeriod */ x2a8_grappleSwingPeriod = __dna_reader.readFloatBig(); - /* x2ac_ */ - x2ac_ = __dna_reader.readFloatBig(); + /* x2ac_grapplePullSpeedMin */ + x2ac_grapplePullSpeedMin = __dna_reader.readFloatBig(); /* x2b0_ */ x2b0_ = __dna_reader.readFloatBig(); - /* x2b4_ */ - x2b4_ = __dna_reader.readFloatBig(); - /* x2b8_ */ - x2b8_ = __dna_reader.readFloatBig(); - /* x2bc_ */ - x2bc_ = __dna_reader.readFloatBig(); - /* x2c0_ */ - x2c0_ = __dna_reader.readFloatBig(); - /* x2c4_ */ - x2c4_ = __dna_reader.readFloatBig(); + /* x2b4_maxGrappleLockedTurnAlignDistance */ + x2b4_maxGrappleLockedTurnAlignDistance = __dna_reader.readFloatBig(); + /* x2b8_grapplePullSpeedProportion */ + x2b8_grapplePullSpeedProportion = __dna_reader.readFloatBig(); + /* x2bc_grapplePullSpeedMax */ + x2bc_grapplePullSpeedMax = __dna_reader.readFloatBig(); + /* x2c0_grappleLookCenterSpeed */ + x2c0_grappleLookCenterSpeed = __dna_reader.readFloatBig(); + /* x2c4_maxGrappleTurnSpeed */ + x2c4_maxGrappleTurnSpeed = __dna_reader.readFloatBig(); /* x2c8_grappleJumpForce */ x2c8_grappleJumpForce = __dna_reader.readFloatBig(); /* x2cc_grappleReleaseTime */ @@ -390,7 +390,7 @@ void CTweakPlayer::read(athena::io::IStreamReader& __dna_reader) /* x2d4_ */ x2d4_ = __dna_reader.readBool(); /* x2d5_ */ - x2d5_ = __dna_reader.readBool(); + x2d5_invertGrappleTurn = __dna_reader.readBool(); /* x2d8_ */ x2d8_ = __dna_reader.readFloatBig(); /* x2dc_ */ @@ -543,10 +543,10 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const __dna_writer.writeFloatBig(xa4_[6]); /* xa4_[7] */ __dna_writer.writeFloatBig(xa4_[7]); - /* xc4_hardLandingVelocityThreshold */ - __dna_writer.writeFloatBig(xc4_hardLandingVelocityThreshold); - /* xc8_ */ - __dna_writer.writeFloatBig(xc8_); + /* xc4_normalGravAccel */ + __dna_writer.writeFloatBig(xc4_normalGravAccel); + /* xc8_fluidGravAccel */ + __dna_writer.writeFloatBig(xc8_fluidGravAccel); /* xcc_ */ __dna_writer.writeFloatBig(xcc_); /* xd0_ */ @@ -655,10 +655,10 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const __dna_writer.writeBool(x22a_25_); /* x22a_26_ */ __dna_writer.writeBool(x22a_26_firingCancelsCameraPitch); - /* x22a_27_ */ - __dna_writer.writeBool(x22a_27_); - /* x22a_28_ */ - __dna_writer.writeBool(x22a_28_); + /* x22a_27_assistedAimingIgnoreHorizontal */ + __dna_writer.writeBool(x22a_27_assistedAimingIgnoreHorizontal); + /* x22a_28_assistedAimingIgnoreVertical */ + __dna_writer.writeBool(x22a_28_assistedAimingIgnoreVertical); /* x22c_ */ __dna_writer.writeFloatBig(x22c_); /* x230_ */ @@ -687,10 +687,10 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const __dna_writer.writeFloatBig(x25c_); /* x260_ */ __dna_writer.writeFloatBig(x260_); - /* x264_ */ - __dna_writer.writeFloatBig(x264_); - /* x268_ */ - __dna_writer.writeFloatBig(x268_); + /* x264_aimAssistHorizontalAngle */ + __dna_writer.writeFloatBig(x264_aimAssistHorizontalAngle); + /* x268_aimAssistVerticalAngle */ + __dna_writer.writeFloatBig(x268_aimAssistVerticalAngle); /* x158_[0] */ __dna_writer.writeFloatBig(x158_[0]); /* x164_[0] */ @@ -803,24 +803,24 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const __dna_writer.writeFloatBig(x224_scanningFrameSenseRange); /* x2a0_ */ __dna_writer.writeFloatBig(x2a0_); - /* x2a4_ */ - __dna_writer.writeFloatBig(x2a4_); + /* x2a4_grappleSwingLength */ + __dna_writer.writeFloatBig(x2a4_grappleSwingLength); /* x2a8_grappleSwingPeriod */ __dna_writer.writeFloatBig(x2a8_grappleSwingPeriod); - /* x2ac_ */ - __dna_writer.writeFloatBig(x2ac_); + /* x2ac_grapplePullSpeedMin */ + __dna_writer.writeFloatBig(x2ac_grapplePullSpeedMin); /* x2b0_ */ __dna_writer.writeFloatBig(x2b0_); - /* x2b4_ */ - __dna_writer.writeFloatBig(x2b4_); - /* x2b8_ */ - __dna_writer.writeFloatBig(x2b8_); - /* x2bc_ */ - __dna_writer.writeFloatBig(x2bc_); - /* x2c0_ */ - __dna_writer.writeFloatBig(x2c0_); - /* x2c4_ */ - __dna_writer.writeFloatBig(x2c4_); + /* x2b4_maxGrappleLockedTurnAlignDistance */ + __dna_writer.writeFloatBig(x2b4_maxGrappleLockedTurnAlignDistance); + /* x2b8_grapplePullSpeedProportion */ + __dna_writer.writeFloatBig(x2b8_grapplePullSpeedProportion); + /* x2bc_grapplePullSpeedMax */ + __dna_writer.writeFloatBig(x2bc_grapplePullSpeedMax); + /* x2c0_grappleLookCenterSpeed */ + __dna_writer.writeFloatBig(x2c0_grappleLookCenterSpeed); + /* x2c4_maxGrappleTurnSpeed */ + __dna_writer.writeFloatBig(x2c4_maxGrappleTurnSpeed); /* x2c8_grappleJumpForce */ __dna_writer.writeFloatBig(x2c8_grappleJumpForce); /* x2cc_grappleReleaseTime */ @@ -830,7 +830,7 @@ void CTweakPlayer::write(athena::io::IStreamWriter& __dna_writer) const /* x2d4_ */ __dna_writer.writeBool(x2d4_); /* x2d5_ */ - __dna_writer.writeBool(x2d5_); + __dna_writer.writeBool(x2d5_invertGrappleTurn); /* x2d8_ */ __dna_writer.writeFloatBig(x2d8_); /* x2dc_ */ @@ -1013,10 +1013,10 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin) /* xa4_[7] */ xa4_[7] = __dna_docin.readFloat("xa4_"); } - /* xc4_hardLandingVelocityThreshold */ - xc4_hardLandingVelocityThreshold = __dna_docin.readFloat("xc4_hardLandingVelocityThreshold"); - /* xc8_ */ - xc8_ = __dna_docin.readFloat("xc8_"); + /* xc4_normalGravAccel */ + xc4_normalGravAccel = __dna_docin.readFloat("xc4_normalGravAccel"); + /* xc8_fluidGravAccel */ + xc8_fluidGravAccel = __dna_docin.readFloat("xc8_fluidGravAccel"); /* xcc_ */ xcc_ = __dna_docin.readFloat("xcc_"); /* xd0_ */ @@ -1125,10 +1125,10 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin) x22a_25_ = __dna_docin.readBool("x22a_25_"); /* x22a_26_firingCancelsCameraPitch */ x22a_26_firingCancelsCameraPitch = __dna_docin.readBool("x22a_26_firingCancelsCameraPitch"); - /* x22a_27_ */ - x22a_27_ = __dna_docin.readBool("x22a_27_"); - /* x22a_28_ */ - x22a_28_ = __dna_docin.readBool("x22a_28_"); + /* x22a_27_assistedAimingIgnoreHorizontal */ + x22a_27_assistedAimingIgnoreHorizontal = __dna_docin.readBool("x22a_27_assistedAimingIgnoreHorizontal"); + /* x22a_28_assistedAimingIgnoreVertical */ + x22a_28_assistedAimingIgnoreVertical = __dna_docin.readBool("x22a_28_assistedAimingIgnoreVertical"); /* x22c_ */ x22c_ = __dna_docin.readFloat("x22c_"); /* x230_ */ @@ -1157,10 +1157,10 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin) x25c_ = __dna_docin.readFloat("x25c_"); /* x260_ */ x260_ = __dna_docin.readFloat("x260_"); - /* x264_ */ - x264_ = __dna_docin.readFloat("x264_"); - /* x268_ */ - x268_ = __dna_docin.readFloat("x268_"); + /* x264_aimAssistHorizontalAngle */ + x264_aimAssistHorizontalAngle = __dna_docin.readFloat("x264_aimAssistHorizontalAngle"); + /* x268_aimAssistVerticalAngle */ + x268_aimAssistVerticalAngle = __dna_docin.readFloat("x268_aimAssistVerticalAngle"); /* x158_ */ size_t __x158_Count; if (auto v = __dna_docin.enterSubVector("x158_", __x158_Count)) @@ -1318,24 +1318,24 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin) x224_scanningFrameSenseRange = __dna_docin.readFloat("x224_scanningFrameSenseRange"); /* x2a0_ */ x2a0_ = __dna_docin.readFloat("x2a0_"); - /* x2a4_ */ - x2a4_ = __dna_docin.readFloat("x2a4_"); + /* x2a4_grappleSwingLength */ + x2a4_grappleSwingLength = __dna_docin.readFloat("x2a4_grappleSwingLength"); /* x2a8_grappleSwingPeriod */ x2a8_grappleSwingPeriod = __dna_docin.readFloat("x2a8_grappleSwingPeriod"); - /* x2ac_ */ - x2ac_ = __dna_docin.readFloat("x2ac_"); + /* x2ac_grapplePullSpeedMin */ + x2ac_grapplePullSpeedMin = __dna_docin.readFloat("x2ac_grapplePullSpeedMin"); /* x2b0_ */ x2b0_ = __dna_docin.readFloat("x2b0_"); - /* x2b4_ */ - x2b4_ = __dna_docin.readFloat("x2b4_"); - /* x2b8_ */ - x2b8_ = __dna_docin.readFloat("x2b8_"); - /* x2bc_ */ - x2bc_ = __dna_docin.readFloat("x2bc_"); - /* x2c0_ */ - x2c0_ = __dna_docin.readFloat("x2c0_"); - /* x2c4_ */ - x2c4_ = __dna_docin.readFloat("x2c4_"); + /* x2b4_maxGrappleLockedTurnAlignDistance */ + x2b4_maxGrappleLockedTurnAlignDistance = __dna_docin.readFloat("x2b4_maxGrappleLockedTurnAlignDistance"); + /* x2b8_grapplePullSpeedProportion */ + x2b8_grapplePullSpeedProportion = __dna_docin.readFloat("x2b8_grapplePullSpeedProportion"); + /* x2bc_grapplePullSpeedMax */ + x2bc_grapplePullSpeedMax = __dna_docin.readFloat("x2bc_grapplePullSpeedMax"); + /* x2c0_grappleLookCenterSpeed */ + x2c0_grappleLookCenterSpeed = __dna_docin.readFloat("x2c0_grappleLookCenterSpeed"); + /* x2c4_maxGrappleTurnSpeed */ + x2c4_maxGrappleTurnSpeed = __dna_docin.readFloat("x2c4_maxGrappleTurnSpeed"); /* x2c8_grappleJumpForce */ x2c8_grappleJumpForce = __dna_docin.readFloat("x2c8_grappleJumpForce"); /* x2cc_grappleReleaseTime */ @@ -1345,7 +1345,7 @@ void CTweakPlayer::read(athena::io::YAMLDocReader& __dna_docin) /* x2d4_ */ x2d4_ = __dna_docin.readBool("x2d4_"); /* x2d5_ */ - x2d5_ = __dna_docin.readBool("x2d5_"); + x2d5_invertGrappleTurn = __dna_docin.readBool("x2d5_"); /* x2d8_ */ x2d8_ = __dna_docin.readFloat("x2d8_"); /* x2dc_ */ @@ -1522,10 +1522,10 @@ void CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) const /* xa4_[7] */ __dna_docout.writeFloat("xa4_", xa4_[7]); } - /* xc4_hardLandingVelocityThreshold */ - __dna_docout.writeFloat("xc4_hardLandingVelocityThreshold", xc4_hardLandingVelocityThreshold); - /* xc8_ */ - __dna_docout.writeFloat("xc8_", xc8_); + /* xc4_normalGravAccel */ + __dna_docout.writeFloat("xc4_normalGravAccel", xc4_normalGravAccel); + /* xc8_fluidGravAccel */ + __dna_docout.writeFloat("xc8_fluidGravAccel", xc8_fluidGravAccel); /* xcc_ */ __dna_docout.writeFloat("xcc_", xcc_); /* xd0_ */ @@ -1634,10 +1634,10 @@ void CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) const __dna_docout.writeBool("x22a_25_", x22a_25_); /* x22a_26_firingCancelsCameraPitch */ __dna_docout.writeBool("x22a_26_firingCancelsCameraPitch", x22a_26_firingCancelsCameraPitch); - /* x22a_27_ */ - __dna_docout.writeBool("x22a_27_", x22a_27_); - /* x22a_28_ */ - __dna_docout.writeBool("x22a_28_", x22a_28_); + /* x22a_27_assistedAimingIgnoreHorizontal */ + __dna_docout.writeBool("x22a_27_assistedAimingIgnoreHorizontal", x22a_27_assistedAimingIgnoreHorizontal); + /* x22a_28_assistedAimingIgnoreVertical */ + __dna_docout.writeBool("x22a_28_assistedAimingIgnoreVertical", x22a_28_assistedAimingIgnoreVertical); /* x22c_ */ __dna_docout.writeFloat("x22c_", x22c_); /* x230_ */ @@ -1666,10 +1666,10 @@ void CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) const __dna_docout.writeFloat("x25c_", x25c_); /* x260_ */ __dna_docout.writeFloat("x260_", x260_); - /* x264_ */ - __dna_docout.writeFloat("x264_", x264_); - /* x268_ */ - __dna_docout.writeFloat("x268_", x268_); + /* x264_aimAssistHorizontalAngle */ + __dna_docout.writeFloat("x264_aimAssistHorizontalAngle", x264_aimAssistHorizontalAngle); + /* x268_aimAssistVerticalAngle */ + __dna_docout.writeFloat("x268_aimAssistVerticalAngle", x268_aimAssistVerticalAngle); /* x158_ */ if (auto v = __dna_docout.enterSubVector("x158_")) { @@ -1818,24 +1818,24 @@ void CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) const __dna_docout.writeFloat("x224_scanningFrameSenseRange", x224_scanningFrameSenseRange); /* x2a0_ */ __dna_docout.writeFloat("x2a0_", x2a0_); - /* x2a4_ */ - __dna_docout.writeFloat("x2a4_", x2a4_); + /* x2a4_grappleSwingLength */ + __dna_docout.writeFloat("x2a4_grappleSwingLength", x2a4_grappleSwingLength); /* x2a8_grappleSwingPeriod */ __dna_docout.writeFloat("x2a8_grappleSwingPeriod", x2a8_grappleSwingPeriod); - /* x2ac_ */ - __dna_docout.writeFloat("x2ac_", x2ac_); + /* x2ac_grapplePullSpeedMin */ + __dna_docout.writeFloat("x2ac_grapplePullSpeedMin", x2ac_grapplePullSpeedMin); /* x2b0_ */ __dna_docout.writeFloat("x2b0_", x2b0_); - /* x2b4_ */ - __dna_docout.writeFloat("x2b4_", x2b4_); - /* x2b8_ */ - __dna_docout.writeFloat("x2b8_", x2b8_); - /* x2bc_ */ - __dna_docout.writeFloat("x2bc_", x2bc_); - /* x2c0_ */ - __dna_docout.writeFloat("x2c0_", x2c0_); - /* x2c4_ */ - __dna_docout.writeFloat("x2c4_", x2c4_); + /* x2b4_maxGrappleLockedTurnAlignDistance */ + __dna_docout.writeFloat("x2b4_maxGrappleLockedTurnAlignDistance", x2b4_maxGrappleLockedTurnAlignDistance); + /* x2b8_grapplePullSpeedProportion */ + __dna_docout.writeFloat("x2b8_grapplePullSpeedProportion", x2b8_grapplePullSpeedProportion); + /* x2bc_grapplePullSpeedMax */ + __dna_docout.writeFloat("x2bc_grapplePullSpeedMax", x2bc_grapplePullSpeedMax); + /* x2c0_grappleLookCenterSpeed */ + __dna_docout.writeFloat("x2c0_grappleLookCenterSpeed", x2c0_grappleLookCenterSpeed); + /* x2c4_maxGrappleTurnSpeed */ + __dna_docout.writeFloat("x2c4_maxGrappleTurnSpeed", x2c4_maxGrappleTurnSpeed); /* x2c8_grappleJumpForce */ __dna_docout.writeFloat("x2c8_grappleJumpForce", x2c8_grappleJumpForce); /* x2cc_grappleReleaseTime */ @@ -1845,7 +1845,7 @@ void CTweakPlayer::write(athena::io::YAMLDocWriter& __dna_docout) const /* x2d4_ */ __dna_docout.writeBool("x2d4_", x2d4_); /* x2d4_ */ - __dna_docout.writeBool("x2d5_", x2d5_); + __dna_docout.writeBool("x2d5_", x2d5_invertGrappleTurn); /* x2d8_ */ __dna_docout.writeFloat("x2d8_", x2d8_); /* x2dc_ */ @@ -1913,8 +1913,8 @@ void CTweakPlayer::FixupValues() x244_ = zeus::degToRad(x244_); x248_ = zeus::degToRad(x248_); x250_ = zeus::degToRad(x250_); - x264_ = zeus::degToRad(x264_); - x268_ = zeus::degToRad(x268_); + x264_aimAssistHorizontalAngle = zeus::degToRad(x264_aimAssistHorizontalAngle); + x268_aimAssistVerticalAngle = zeus::degToRad(x268_aimAssistVerticalAngle); x17c_ = zeus::degToRad(x17c_); x184_ = zeus::degToRad(x184_); x188_ = zeus::degToRad(x188_); @@ -1925,7 +1925,7 @@ void CTweakPlayer::FixupValues() x1f0_ = zeus::degToRad(x1f0_); x1f4_ = zeus::degToRad(x1f4_); x2b0_ = zeus::degToRad(x2b0_); - x2c0_ = zeus::degToRad(x2c0_); + x2c0_grappleLookCenterSpeed = zeus::degToRad(x2c0_grappleLookCenterSpeed); x280_ = zeus::degToRad(x280_); x284_ = zeus::degToRad(x284_); x290_ = zeus::degToRad(x290_); diff --git a/DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp b/DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp index 374a38194..ea582e0f9 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp @@ -17,8 +17,8 @@ struct CTweakPlayer : ITweakPlayer Value x64_[8]; Value x84_[8]; Value xa4_[8]; - Value xc4_hardLandingVelocityThreshold; - Value xc8_; + Value xc4_normalGravAccel; + Value xc8_fluidGravAccel; Value xcc_; Value xd0_; Value xd4_; @@ -116,8 +116,8 @@ struct CTweakPlayer : ITweakPlayer Value x22a_24_ : 1; Value x22a_25_ : 1; Value x22a_26_firingCancelsCameraPitch : 1; - Value x22a_27_ : 1; - Value x22a_28_ : 1; + Value x22a_27_assistedAimingIgnoreHorizontal : 1; + Value x22a_28_assistedAimingIgnoreVertical : 1; Value x22c_; Value x230_; Value x234_; @@ -132,8 +132,8 @@ struct CTweakPlayer : ITweakPlayer Value x258_; Value x25c_; Value x260_; - Value x264_; - Value x268_; + Value x264_aimAssistHorizontalAngle; + Value x268_aimAssistVerticalAngle; Value x26c_playerHeight; Value x270_playerXYHalfExtent; Value x274_; @@ -148,20 +148,20 @@ struct CTweakPlayer : ITweakPlayer Value x298_; Value x29c_; Value x2a0_; - Value x2a4_; + Value x2a4_grappleSwingLength; Value x2a8_grappleSwingPeriod; - Value x2ac_; + Value x2ac_grapplePullSpeedMin; Value x2b0_; - Value x2b4_; - Value x2b8_; - Value x2bc_; - Value x2c0_; - Value x2c4_; + Value x2b4_maxGrappleLockedTurnAlignDistance; + Value x2b8_grapplePullSpeedProportion; + Value x2bc_grapplePullSpeedMax; + Value x2c0_grappleLookCenterSpeed; + Value x2c4_maxGrappleTurnSpeed; Value x2c8_grappleJumpForce; Value x2cc_grappleReleaseTime; Value x2d0_grappleJumpMode; Value x2d4_; - Value x2d5_; + Value x2d5_invertGrappleTurn; Value x2d8_; Value x2dc_; Value x2e0_; @@ -179,7 +179,8 @@ struct CTweakPlayer : ITweakPlayer float GetX54() const { return x44_[4]; } float GetX58() const { return x44_[5]; } float GetX5C() const { return x44_[6]; } - float GetHardLandingVelocityThreshold() const { return xc4_hardLandingVelocityThreshold; } + float GetNormalGravAccel() const { return xc4_normalGravAccel; } + float GetFluidGravAccel() const { return xc8_fluidGravAccel; } float GetHudLagAmount() const { return x138_hudLagAmount; } float GetOrbitNormalDistance() const { return x180_orbitNormalDistance; } uint32_t GetOrbitScreenBoxHalfExtentX(int zone) const { return x1a8_orbitScreenBoxHalfExtentX[zone]; } @@ -197,15 +198,27 @@ struct CTweakPlayer : ITweakPlayer bool GetGunButtonTogglesHolster() const { return x229_30_gunButtonTogglesHolster; } bool GetGunNotFiringHolstersGun() const { return x229_31_gunNotFiringHolstersGun; } bool GetFiringCancelsCameraPitch() const { return x22a_26_firingCancelsCameraPitch; } + bool GetAssistedAimingIgnoreHorizontal() const { return x22a_27_assistedAimingIgnoreHorizontal; } + bool GetAssistedAimingIgnoreVertical() const { return x22a_28_assistedAimingIgnoreVertical; } + float GetAimAssistHorizontalAngle() const { return x264_aimAssistHorizontalAngle; } + float GetAimAssistVerticalAngle() const { return x268_aimAssistVerticalAngle; } 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 GetGrappleSwingLength() const { return x2a4_grappleSwingLength; } float GetGrappleSwingPeriod() const { return x2a8_grappleSwingPeriod; } + float GetGrapplePullSpeedMin() const { return x2ac_grapplePullSpeedMin; } + float GetMaxGrappleLockedTurnAlignDistance() const { return x2b4_maxGrappleLockedTurnAlignDistance; } + float GetGrapplePullSpeedProportion() const { return x2b8_grapplePullSpeedProportion; } + float GetGrapplePullSpeedMax() const { return x2bc_grapplePullSpeedMax; } + float GetGrappleLookCenterSpeed() const { return x2c0_grappleLookCenterSpeed; } + float GetMaxGrappleTurnSpeed() const { return x2c4_maxGrappleTurnSpeed; } float GetGrappleJumpForce() const { return x2c8_grappleJumpForce; } float GetGrappleReleaseTime() const { return x2cc_grappleReleaseTime; } uint32_t GetGrappleJumpMode() const { return x2d0_grappleJumpMode; } + bool InvertGrappleTurn() const { return x2d5_invertGrappleTurn; } float GetX124() const { return x134_; } float GetX184() const { return x184_; } float GetX1fc() const { return x1fc_; } diff --git a/Runtime/Camera/CFirstPersonCamera.cpp b/Runtime/Camera/CFirstPersonCamera.cpp index 778cd878f..30117a40e 100644 --- a/Runtime/Camera/CFirstPersonCamera.cpp +++ b/Runtime/Camera/CFirstPersonCamera.cpp @@ -248,7 +248,7 @@ void CFirstPersonCamera::UpdateTransform(CStateManager& mgr, float dt) if (player->GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed || player->GetOrbitState() == CPlayer::EPlayerOrbitState::Five || - player->GetGrappleState() == CPlayer::EGrappleState::Zero || + player->GetGrappleState() == CPlayer::EGrappleState::None || mgr.GetGameState() == CStateManager::EGameState::SoftPaused || mgr.GetCameraManager()->IsInCinematicCamera()) { diff --git a/Runtime/Collision/CCollisionActor.cpp b/Runtime/Collision/CCollisionActor.cpp index 0c65db21c..76af3239c 100644 --- a/Runtime/Collision/CCollisionActor.cpp +++ b/Runtime/Collision/CCollisionActor.cpp @@ -27,7 +27,7 @@ CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, co SetCoefficientOfRestitutionModifier(0.5f); SetCallTouch(false); SetMaterialFilter(CMaterialFilter::MakeIncludeExclude( - {EMaterialTypes::Solid}, {EMaterialTypes::CollisionActor, EMaterialTypes::StaticCollision})); + {EMaterialTypes::Solid}, {EMaterialTypes::CollisionActor, EMaterialTypes::NoStaticCollision})); } CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, const zeus::CVector3f& boxSize, @@ -39,12 +39,12 @@ CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, co , x25c_owner(uid2) , x260_boxSize(boxSize) , x280_aaboxPrimitive(new CCollidableAABox(zeus::CAABox(-0.5f * boxSize, 0.5f * boxSize), - CMaterialList(EMaterialTypes::Solid, EMaterialTypes::StaticCollision))) + CMaterialList(EMaterialTypes::Solid, EMaterialTypes::NoStaticCollision))) { SetCoefficientOfRestitutionModifier(0.5f); SetCallTouch(false); SetMaterialFilter(CMaterialFilter::MakeIncludeExclude( - {EMaterialTypes::Solid}, {EMaterialTypes::CollisionActor, EMaterialTypes::StaticCollision})); + {EMaterialTypes::Solid}, {EMaterialTypes::CollisionActor, EMaterialTypes::NoStaticCollision})); } CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, bool active, float radius, float mass) @@ -54,13 +54,13 @@ CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, bo , x258_primitiveType(EPrimitiveType::Sphere) , x25c_owner(uid2) , x284_spherePrimitive(new CCollidableSphere(zeus::CSphere(zeus::CVector3f::skZero, radius), - CMaterialList(EMaterialTypes::StaticCollision, EMaterialTypes::Solid))) + CMaterialList(EMaterialTypes::NoStaticCollision, EMaterialTypes::Solid))) , x288_sphereRadius(radius) { SetCoefficientOfRestitutionModifier(0.5f); SetCallTouch(false); SetMaterialFilter(CMaterialFilter::MakeIncludeExclude( - {EMaterialTypes::Solid}, {EMaterialTypes::CollisionActor, EMaterialTypes::StaticCollision})); + {EMaterialTypes::Solid}, {EMaterialTypes::CollisionActor, EMaterialTypes::NoStaticCollision})); } void CCollisionActor::Accept(IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/Collision/CGameCollision.cpp b/Runtime/Collision/CGameCollision.cpp index 0b1f64463..c6dbb3e13 100644 --- a/Runtime/Collision/CGameCollision.cpp +++ b/Runtime/Collision/CGameCollision.cpp @@ -102,7 +102,7 @@ void CGameCollision::MoveAndCollide(CStateManager& mgr, CPhysicsActor& actor, fl mgr.BuildColliderList(useColliderList, actor, zeus::CAABox(motionVol.min - 1.f, motionVol.max + 1.f)); CAreaCollisionCache cache(motionVol); if (actor.GetCollisionPrimitive()->GetPrimType() != FOURCC('OBTG') && - !actor.GetMaterialFilter().GetExcludeList().HasMaterial(EMaterialTypes::StaticCollision)) + !actor.GetMaterialFilter().GetExcludeList().HasMaterial(EMaterialTypes::NoStaticCollision)) { BuildAreaCollisionCache(mgr, cache); zeus::CVector3f pos = actor.GetCollisionPrimitive()->CalculateAABox(actor.GetPrimitiveTransform()).center(); @@ -434,12 +434,24 @@ float CGameCollision::GetMinExtentForCollisionPrimitive(const CCollisionPrimitiv return 1.f; } +bool CGameCollision::DetectCollisionBoolean(CStateManager& mgr, const CCollisionPrimitive& prim, + const zeus::CTransform& xf, const CMaterialFilter& filter, + const rstl::reserved_vector& nearList) +{ + if (!filter.GetExcludeList().HasMaterial(EMaterialTypes::NoStaticCollision) && + DetectStaticCollisionBoolean(mgr, prim, xf, filter)) + return true; + if (DetectDynamicCollisionBoolean(prim, xf, nearList, mgr)) + return true; + return false; +} + bool CGameCollision::DetectCollisionBoolean_Cached(CStateManager& mgr, CAreaCollisionCache& cache, const CCollisionPrimitive& prim, const zeus::CTransform& xf, const CMaterialFilter& filter, const rstl::reserved_vector& nearList) { - if (!filter.GetExcludeList().HasMaterial(EMaterialTypes::StaticCollision) && + if (!filter.GetExcludeList().HasMaterial(EMaterialTypes::NoStaticCollision) && DetectStaticCollisionBoolean_Cached(mgr, cache, prim, xf, filter)) return true; if (DetectDynamicCollisionBoolean(prim, xf, nearList, mgr)) @@ -552,7 +564,7 @@ bool CGameCollision::DetectCollision_Cached(CStateManager& mgr, CAreaCollisionCa { idOut = kInvalidUniqueId; bool ret = false; - if (!filter.GetExcludeList().HasMaterial(EMaterialTypes::StaticCollision)) + if (!filter.GetExcludeList().HasMaterial(EMaterialTypes::NoStaticCollision)) if (DetectStaticCollision_Cached(mgr, cache, prim, xf, filter, infoList)) ret = true; @@ -574,7 +586,7 @@ bool CGameCollision::DetectCollision_Cached_Moving(CStateManager& mgr, CAreaColl TUniqueId& idOut, CCollisionInfo& infoOut, double& d) { idOut = kInvalidUniqueId; - if (!filter.GetExcludeList().HasMaterial(EMaterialTypes::StaticCollision)) + if (!filter.GetExcludeList().HasMaterial(EMaterialTypes::NoStaticCollision)) { if (CGameCollision::DetectStaticCollision_Cached_Moving(mgr, cache, prim, xf, filter, dir, infoOut, d)) return true; diff --git a/Runtime/Collision/CGameCollision.hpp b/Runtime/Collision/CGameCollision.hpp index 18755b6fb..ea0cf5585 100644 --- a/Runtime/Collision/CGameCollision.hpp +++ b/Runtime/Collision/CGameCollision.hpp @@ -63,6 +63,9 @@ public: const zeus::CVector3f& dir, float mag, const CMaterialFilter& filter); static void BuildAreaCollisionCache(CStateManager& mgr, CAreaCollisionCache& cache); static float GetMinExtentForCollisionPrimitive(const CCollisionPrimitive& prim); + static bool DetectCollisionBoolean(CStateManager& mgr, const CCollisionPrimitive& prim, + const zeus::CTransform& xf, const CMaterialFilter& filter, + const rstl::reserved_vector& nearList); static bool DetectCollisionBoolean_Cached(CStateManager& mgr, CAreaCollisionCache& cache, const CCollisionPrimitive& prim, const zeus::CTransform& xf, const CMaterialFilter& filter, diff --git a/Runtime/Collision/CMaterialList.hpp b/Runtime/Collision/CMaterialList.hpp index 24ade427f..bb9b89d95 100644 --- a/Runtime/Collision/CMaterialList.hpp +++ b/Runtime/Collision/CMaterialList.hpp @@ -45,7 +45,7 @@ enum class EMaterialTypes Projectile = 35, Bomb = 36, GroundCollider = 37, - StaticCollision = 38, + NoStaticCollision = 38, Scannable = 39, Target = 40, Orbit = 41, diff --git a/Runtime/RetroTypes.hpp b/Runtime/RetroTypes.hpp index a88d1c0e9..a8a490689 100644 --- a/Runtime/RetroTypes.hpp +++ b/Runtime/RetroTypes.hpp @@ -101,7 +101,14 @@ public: void AddValue(const T& t) { if (this->size() < N) + { this->push_back(t); + } + else + { + this->pop_back(); + this->insert(this->begin(), t); + } } rstl::optional_object GetAverage() const diff --git a/Runtime/Weapon/CGrappleArm.hpp b/Runtime/Weapon/CGrappleArm.hpp index 85569a8c9..88a0e6163 100644 --- a/Runtime/Weapon/CGrappleArm.hpp +++ b/Runtime/Weapon/CGrappleArm.hpp @@ -25,7 +25,7 @@ public: }; private: CModelData x0_modelData; - zeus::CTransform x220_; + zeus::CTransform x220_xf; EArmState x334_animState; union { @@ -38,9 +38,10 @@ private: }; public: - CGrappleArm(const zeus::CVector3f& vec); + explicit CGrappleArm(const zeus::CVector3f& vec); void AsyncLoadSuit(CStateManager& mgr); - void SetX220(const zeus::CTransform& xf) { x220_ = xf; } + void SetTransform(const zeus::CTransform& xf) { x220_xf = xf; } + const zeus::CTransform& GetTransform() const { return x220_xf; } void SetAnimState(EArmState state); EArmState GetAnimState() const { return x334_animState; } bool BeamActive() const { return x3b2_25_beamActive; } diff --git a/Runtime/Weapon/CGunWeapon.hpp b/Runtime/Weapon/CGunWeapon.hpp index 8cd317974..203e99cce 100644 --- a/Runtime/Weapon/CGunWeapon.hpp +++ b/Runtime/Weapon/CGunWeapon.hpp @@ -23,6 +23,18 @@ class CActorLights; class CGunController; struct CModelFlags; class CStateManager; +class CWeaponDescription; + +class CVelocityInfo +{ + friend class CGunWeapon; + rstl::reserved_vector x0_vel; + rstl::reserved_vector x1c_; + rstl::reserved_vector x24_; +public: + const zeus::CVector3f& GetVelocity(int i) const { return x0_vel[i]; } +}; + class CGunWeapon { public: @@ -37,9 +49,14 @@ protected: zeus::CVector3f x4_; TToken x104_gunCharacter; TToken x13c_armCharacter; + rstl::reserved_vector, 2> x144_weapons; + TToken x160_xferEffect; + rstl::reserved_vector, 2> x16c_muzzleEffects; + rstl::reserved_vector, 2> x188_secondaryEffects; EWeaponType x1c0_weaponType; TUniqueId x1c4_uid; EMaterialTypes x1c8_matType; + CVelocityInfo x1d0_velInfo; CPlayerState::EBeamId x200_beamId; public: CGunWeapon(ResId ancsId, EWeaponType type, TUniqueId uid, EMaterialTypes, const zeus::CVector3f& vec); @@ -61,6 +78,7 @@ public: virtual void Load(bool) {} virtual void Unload(CStateManager&) {} virtual bool IsLoaded() const {return false;} + const CVelocityInfo& GetVelocityInfo() const { return x1d0_velInfo; } }; } diff --git a/Runtime/Weapon/CPlayerGun.cpp b/Runtime/Weapon/CPlayerGun.cpp index f84a6fc10..8e998a834 100644 --- a/Runtime/Weapon/CPlayerGun.cpp +++ b/Runtime/Weapon/CPlayerGun.cpp @@ -61,4 +61,11 @@ void CPlayerGun::CancelFiring(CStateManager& mgr) } +float CPlayerGun::GetBeamVelocity() const +{ + if (x72c_currentBeam->IsLoaded()) + return x72c_currentBeam->GetVelocityInfo().GetVelocity(x330_chargeWeaponIdx).y; + return 10.f; +} + } diff --git a/Runtime/Weapon/CPlayerGun.hpp b/Runtime/Weapon/CPlayerGun.hpp index 40f64b2a9..57ca48bf9 100644 --- a/Runtime/Weapon/CPlayerGun.hpp +++ b/Runtime/Weapon/CPlayerGun.hpp @@ -80,7 +80,7 @@ private: u32 x324_ = 4; u32 x328_ = 0x2000; u32 x32c_ = 0; - u32 x330_ = 0; + u32 x330_chargeWeaponIdx = 0; u32 x334_ = 0; u32 x338_ = 0; u32 x33c_ = 0; @@ -114,7 +114,7 @@ private: zeus::CTransform x3e8_xf; zeus::CTransform x418_; zeus::CTransform x448_; - zeus::CTransform x478_; + zeus::CTransform x478_assistAimXf; zeus::CTransform x4a8_; zeus::CTransform x4d8_; zeus::CTransform x508_; @@ -222,11 +222,13 @@ public: u32 GetPendingSelectedBeam() const { return x314_pendingSelectedBeam; } const CGunMorph& GetGunMorph() const { return x678_morph; } void SetTransform(const zeus::CTransform& xf) { x3e8_xf = xf; } + void SetAssistAimTransform(const zeus::CTransform& xf) { x478_assistAimXf = xf; } 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); + float GetBeamVelocity() const; }; } diff --git a/Runtime/World/CGrappleParameters.hpp b/Runtime/World/CGrappleParameters.hpp index aa8aef4d6..1d844c1fc 100644 --- a/Runtime/World/CGrappleParameters.hpp +++ b/Runtime/World/CGrappleParameters.hpp @@ -17,14 +17,16 @@ class CGrappleParameters float x20_i; float x24_j; float x28_k; - bool x2c_l; + bool x2c_lockSwingTurn; public: CGrappleParameters(float a, float b, float c, float d, float e, float f, float g, float h, - float i, float j, float k, bool l) + float i, float j, float k, bool lockSwingTurn) : x0_a(a), x4_b(b), x8_c(c), xc_d(d), x10_e(e), x14_f(f), x18_g(g), x1c_h(h), - x20_i(i), x24_j(j), x28_k(k), x2c_l(l) {} + x20_i(i), x24_j(j), x28_k(k), x2c_lockSwingTurn(lockSwingTurn) {} + + bool GetLockSwingTurn() const { return x2c_lockSwingTurn; } }; } diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index 45e18b6b9..a6f6da3ac 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -68,7 +68,7 @@ CPlayer::CPlayer(TUniqueId uid, const zeus::CTransform& xf, const zeus::CAABox& SetInertiaTensorScalar(xe8_mass); x1f4_lastNonCollidingState = GetMotionState(); x490_gun->SetTransform(x34_transform); - x490_gun->GetGrappleArm().SetX220(x34_transform); + x490_gun->GetGrappleArm().SetTransform(x34_transform); InitializeBallTransition(); zeus::CAABox ballTransAABB = x64_modelData->GetBounds(); @@ -379,7 +379,7 @@ void CPlayer::TakeDamage(bool significant, const zeus::CVector3f& location, } } - if (x3b8_grappleState != EGrappleState::Zero) + if (x3b8_grappleState != EGrappleState::None) BreakGrapple(EPlayerOrbitRequest::Eleven, mgr); } @@ -878,7 +878,7 @@ void CPlayer::Freeze(CStateManager& stateMgr, ResId steamTxtr, u16 sfx, ResId ic CPhysicsActor::Stop(); ClearForcesAndTorques(); - if (x3b8_grappleState != EGrappleState::Zero) + if (x3b8_grappleState != EGrappleState::None) BreakGrapple(EPlayerOrbitRequest::Ten, stateMgr); else SetOrbitRequest(EPlayerOrbitRequest::Ten, stateMgr); @@ -979,7 +979,7 @@ void CPlayer::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CState { if (x258_movementState != EPlayerMovementState::Falling) { - float hardThres = 30.f * 2.f * -g_tweakPlayer->GetHardLandingVelocityThreshold(); + float hardThres = 30.f * 2.f * -g_tweakPlayer->GetNormalGravAccel(); hardThres = (hardThres != 0.f) ? hardThres * std::sqrt(hardThres) : 0.f; float landVol = zeus::clamp(95.f, 1.6f * -x794_.z + 95.f, 127.f) / 127.f; u16 landSfx; @@ -1409,12 +1409,12 @@ void CPlayer::UpdateGunState(const CFinalInput& input, CStateManager& mgr) bool needsDraw = false; if (ControlMapper::GetDigitalInput(ControlMapper::ECommands::FireOrBomb, input) || ControlMapper::GetDigitalInput(ControlMapper::ECommands::MissileOrPowerBomb, input) || - x3b8_grappleState == EGrappleState::Zero || + x3b8_grappleState == EGrappleState::None || (g_tweakPlayer->GetGunButtonTogglesHolster() && ControlMapper::GetPressInput(ControlMapper::ECommands::ToggleHolster, input))) needsDraw = true; - if (x3b8_grappleState == EGrappleState::Zero && + if (x3b8_grappleState == EGrappleState::None && (mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan || mgr.GetPlayerState()->GetTransitioningVisor() == CPlayerState::EPlayerVisor::Scan )) needsDraw = false; @@ -1581,12 +1581,96 @@ void CPlayer::UpdateGunTransform(const zeus::CVector3f& gunPos, CStateManager& m void CPlayer::UpdateAssistedAiming(const zeus::CTransform& xf, const CStateManager& mgr) { + zeus::CTransform assistXf = xf; + if (TCastToConstPtr target = mgr.GetObjectById(x3f4_aimTarget)) + { + zeus::CVector3f gunToTarget = x480_assistedTargetAim - xf.origin; + zeus::CVector3f gunToTargetFlat = gunToTarget; + gunToTargetFlat.z = 0.f; + float gunToTargetFlatMag = gunToTargetFlat.magnitude(); + zeus::CVector3f gunDirFlat = xf.basis[1]; + gunDirFlat.z = 0.f; + float gunDirFlatMag = gunDirFlat.magnitude(); + if (gunToTargetFlat.canBeNormalized() && gunDirFlat.canBeNormalized()) + { + gunToTargetFlat = gunToTargetFlat / gunToTargetFlatMag; + gunDirFlat = gunDirFlat / gunDirFlatMag; + float vAngleDelta = std::atan2(gunToTarget.z, gunToTargetFlatMag) - + std::atan2(xf.basis[1].z, gunDirFlatMag); + bool hasVAngleDelta = true; + if (!x9c6_27_aimingAtProjectile && std::fabs(vAngleDelta) > g_tweakPlayer->GetAimAssistVerticalAngle()) + { + if (g_tweakPlayer->GetAssistedAimingIgnoreVertical()) + { + vAngleDelta = 0.f; + hasVAngleDelta = false; + } + else if (vAngleDelta > 0.f) + { + vAngleDelta = g_tweakPlayer->GetAimAssistVerticalAngle(); + } + else + { + vAngleDelta = -g_tweakPlayer->GetAimAssistVerticalAngle(); + } + } + bool targetToLeft = gunDirFlat.cross(gunToTargetFlat).z > 0.f; + float hAngleDelta = std::acos(zeus::clamp(-1.f, gunDirFlat.dot(gunToTargetFlat), 1.f)); + bool hasHAngleDelta = true; + if (!x9c6_27_aimingAtProjectile && std::fabs(hAngleDelta) > g_tweakPlayer->GetAimAssistHorizontalAngle()) + { + hAngleDelta = g_tweakPlayer->GetAimAssistHorizontalAngle(); + if (g_tweakPlayer->GetAssistedAimingIgnoreHorizontal()) + { + hAngleDelta = 0.f; + hasHAngleDelta = false; + } + } + + if (targetToLeft) + hAngleDelta = -hAngleDelta; + + if (!hasVAngleDelta || !hasHAngleDelta) + { + vAngleDelta = 0.f; + hAngleDelta = 0.f; + } + + gunToTarget.x = std::sin(hAngleDelta) * std::cos(vAngleDelta); + gunToTarget.y = std::cos(hAngleDelta) * std::cos(vAngleDelta); + gunToTarget.z = std::sin(vAngleDelta); + gunToTarget = xf.rotate(gunToTarget); + assistXf = zeus::lookAt(zeus::CVector3f::skZero, gunToTarget, zeus::CVector3f::skUp); + } + } + + x490_gun->SetAssistAimTransform(assistXf); } void CPlayer::UpdateAimTargetPrediction(const zeus::CTransform& xf, const CStateManager& mgr) { - + if (x3f4_aimTarget != kInvalidUniqueId) + { + if (TCastToConstPtr target = mgr.GetObjectById(x3f4_aimTarget)) + { + x9c6_27_aimingAtProjectile = TCastToConstPtr(target); + zeus::CVector3f instantTarget = target->GetAimPosition(mgr, 0.f); + zeus::CVector3f gunToTarget = instantTarget - xf.origin; + float timeToTarget = gunToTarget.magnitude() / x490_gun->GetBeamVelocity(); + zeus::CVector3f predictTarget = target->GetAimPosition(mgr, timeToTarget); + zeus::CVector3f predictOffset = predictTarget - instantTarget; + x3f8_targetAimPosition = instantTarget; + if (predictOffset.magnitude() < 0.1f) + x404_aimTargetAverage.AddValue(zeus::CVector3f::skZero); + else + x404_aimTargetAverage.AddValue(predictOffset); + if (auto avg = x404_aimTargetAverage.GetAverage()) + x480_assistedTargetAim = instantTarget + *avg; + else + x480_assistedTargetAim = predictTarget; + } + } } void CPlayer::ResetAimTargetPrediction(TUniqueId target) @@ -1621,11 +1705,268 @@ void CPlayer::HolsterGun(CStateManager& mgr) ResetAimTargetPrediction(kInvalidUniqueId); } -void CPlayer::UpdateGrappleArmTransform(const zeus::CVector3f&, CStateManager& mgr, float) {} +void CPlayer::UpdateGrappleArmTransform(const zeus::CVector3f& offset, CStateManager& mgr, float dt) +{ + zeus::CTransform armXf = x34_transform; + zeus::CVector3f armPosition = x34_transform.rotate(offset) + x34_transform.origin; + armXf.origin = armPosition; + if (x2f8_morphTransState != EPlayerMorphBallState::Unmorphed) + { + x490_gun->GetGrappleArm().SetTransform(armXf); + } + else if (!x490_gun->GetGrappleArm().IsArmMoving()) + { + zeus::CVector3f lookDir = x34_transform.basis[1]; + zeus::CVector3f armToTarget = x490_gun->GetGrappleArm().GetTransform().basis[1]; + if (lookDir.canBeNormalized()) + { + lookDir.normalize(); + if (x3b8_grappleState != EGrappleState::None) + { + if (TCastToPtr target = mgr.ObjectById(x310_orbitTargetId)) + { + armToTarget = target->GetTranslation() - armPosition; + zeus::CVector3f armToTargetFlat = armToTarget; + armToTargetFlat.z = 0.f; + if (armToTarget.canBeNormalized()) + armToTarget.normalize(); + if (armToTargetFlat.canBeNormalized() && x3b8_grappleState != EGrappleState::Firing) + { + zeus::CQuaternion adjRot = + zeus::CQuaternion::lookAt(armToTargetFlat.normalized(), lookDir, 2.f * M_PIF); + armToTarget = adjRot.transform(armToTarget); + if (x3bc_grappleSwingTimer >= 0.25f * g_tweakPlayer->GetGrappleSwingPeriod() && + x3bc_grappleSwingTimer < 0.75f * g_tweakPlayer->GetGrappleSwingPeriod()) + armToTarget = x490_gun->GetGrappleArm().GetTransform().basis[1]; + } + } + } + armXf = zeus::lookAt(zeus::CVector3f::skZero, armToTarget, zeus::CVector3f::skUp); + armXf.origin = armPosition; + x490_gun->GetGrappleArm().SetTransform(armXf); + } + } +} -void CPlayer::ApplyGrappleForces(const CFinalInput& input, CStateManager& mgr, float) {} +float CPlayer::GetGravity() const +{ + if (!g_GameState->GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GravitySuit) && + CheckSubmerged()) + return g_tweakPlayer->GetFluidGravAccel(); + if (x37c_sidewaysDashing) + return -100.f; + return g_tweakPlayer->GetNormalGravAccel(); +} -bool CPlayer::ValidateFPPosition(const zeus::CVector3f& pos, CStateManager& mgr) { return false; } +void CPlayer::ApplyGrappleForces(const CFinalInput& input, CStateManager& mgr, float dt) +{ + if (TCastToPtr point = mgr.ObjectById(x310_orbitTargetId)) + { + switch (x3b8_grappleState) + { + case EGrappleState::Pull: + { + zeus::CVector3f playerToPoint = point->GetTranslation() - GetTranslation(); + if (playerToPoint.canBeNormalized()) + { + zeus::CVector3f playerToSwingLow = point->GetTranslation() + + zeus::CVector3f(0.f, 0.f, -g_tweakPlayer->GetGrappleSwingLength()) - GetTranslation(); + if (playerToSwingLow.canBeNormalized()) + { + float distToSwingLow = playerToSwingLow.magnitude(); + playerToSwingLow.normalize(); + float timeToLow = + zeus::clamp(-1.f, distToSwingLow / g_tweakPlayer->GetGrapplePullSpeedProportion(), 1.f); + float pullSpeed = timeToLow * (g_tweakPlayer->GetGrapplePullSpeedMax() - + g_tweakPlayer->GetGrapplePullSpeedMin()) + g_tweakPlayer->GetGrapplePullSpeedMin(); + SetVelocityWR(playerToSwingLow * pullSpeed); + + if (distToSwingLow < g_tweakPlayer->GetMaxGrappleLockedTurnAlignDistance()) + { + x3b8_grappleState = EGrappleState::Swinging; + x3bc_grappleSwingTimer = 0.25f * g_tweakPlayer->GetGrappleSwingPeriod(); + x3d8_grappleJumpTimeout = 0.f; + x9c6_28_aligningGrappleSwingTurn = point->GetGrappleParameters().GetLockSwingTurn(); + } + else + { + CMotionState mState = PredictMotion(dt); + zeus::CVector3f lookDirFlat = x34_transform.basis[1]; + lookDirFlat.z = 0.f; + zeus::CVector3f newPlayerToPointFlat = + point->GetTranslation() - (GetTranslation() + mState.x0_translation); + newPlayerToPointFlat.z = 0.f; + if (lookDirFlat.canBeNormalized()) + lookDirFlat.normalize(); + if (newPlayerToPointFlat.canBeNormalized()) + newPlayerToPointFlat.normalize(); + float lookToPointAngle = + std::acos(zeus::clamp(-1.f, lookDirFlat.dot(newPlayerToPointFlat), 1.f)); + if (lookToPointAngle > 0.001f) + { + float deltaAngle = dt * g_tweakPlayer->GetGrappleLookCenterSpeed(); + if (lookToPointAngle >= deltaAngle) + { + zeus::CVector3f leftDirFlat(lookDirFlat.y, -lookDirFlat.x, 0.f); + if (leftDirFlat.canBeNormalized()) + leftDirFlat.normalize(); + if (newPlayerToPointFlat.dot(leftDirFlat) >= 0.f) + deltaAngle = -deltaAngle; + RotateToOR(zeus::CQuaternion::fromAxisAngle(zeus::CVector3f::skUp, deltaAngle), dt); + } + else if (std::fabs(lookToPointAngle - M_PIF) > 0.001f) + { + RotateToOR(zeus::CQuaternion::shortestRotationArc(lookDirFlat, + newPlayerToPointFlat), dt); + } + } + else + { + SetAngularVelocityWR(zeus::CAxisAngle::sIdentity); + x174_torque = zeus::CAxisAngle::sIdentity; + } + } + } + else + { + x3b8_grappleState = EGrappleState::Swinging; + x3bc_grappleSwingTimer = 0.25f * g_tweakPlayer->GetGrappleSwingPeriod(); + x3d8_grappleJumpTimeout = 0.f; + } + } + break; + } + case EGrappleState::Swinging: + { + float turnAngleSpeed = zeus::degToRad(g_tweakPlayer->GetMaxGrappleTurnSpeed()); + if (g_tweakPlayer->InvertGrappleTurn()) + turnAngleSpeed *= -1.f; + zeus::CVector3f pointToPlayer = GetTranslation() - point->GetTranslation(); + float pointToPlayerZProj = + zeus::clamp(-1.f, std::fabs(pointToPlayer.z / pointToPlayer.magnitude()), 1.f); + + bool enableTurn = false; + if (!point->GetGrappleParameters().GetLockSwingTurn()) + { + if (ControlMapper::GetAnalogInput(ControlMapper::ECommands::TurnLeft, input) > 0.05f) + { + enableTurn = true; + turnAngleSpeed *= -ControlMapper::GetAnalogInput(ControlMapper::ECommands::TurnLeft, input); + } + if (ControlMapper::GetAnalogInput(ControlMapper::ECommands::TurnRight, input) > 0.05f) + { + enableTurn = true; + turnAngleSpeed *= ControlMapper::GetAnalogInput(ControlMapper::ECommands::TurnRight, input); + } + } + else if (x9c6_28_aligningGrappleSwingTurn) + { + enableTurn = true; + } + + x3bc_grappleSwingTimer += dt; + if (x3bc_grappleSwingTimer > g_tweakPlayer->GetGrappleSwingPeriod()) + x3bc_grappleSwingTimer -= g_tweakPlayer->GetGrappleSwingPeriod(); + + zeus::CVector3f swingAxis = x3c0_grappleSwingAxis; + if (x3bc_grappleSwingTimer < 0.5f * g_tweakPlayer->GetGrappleSwingPeriod()) + swingAxis *= zeus::CVector3f::skNegOne; + + float pullSpeed = std::fabs(zeus::clamp(-1.f, + std::cos(2.f * M_PIF * (x3bc_grappleSwingTimer / g_tweakPlayer->GetGrappleSwingPeriod()) + + (M_PIF / 2.f)), 1.f)) * g_tweakPlayer->GetGrapplePullSpeedMin(); + zeus::CVector3f pullVec = pointToPlayer.normalized().cross(swingAxis) * pullSpeed; + pullVec += pointToPlayer * zeus::clamp(-1.f, (pointToPlayer.magnitude() - + g_tweakPlayer->GetGrappleSwingLength()) / + g_tweakPlayer->GetGrappleSwingLength(), 1.f) * -32.f * pointToPlayerZProj; + zeus::CVector3f backupVel = x138_velocity; + SetVelocityWR(pullVec); + + zeus::CTransform backupXf = x34_transform; + CMotionState predMotion = PredictMotion(dt); + zeus::CVector3f newPos = x34_transform.origin + predMotion.x0_translation; + if (ValidateFPPosition(newPos, mgr)) + { + if (enableTurn) + { + zeus::CQuaternion turnRot; + turnRot.rotateZ(turnAngleSpeed * dt); + if (point->GetGrappleParameters().GetLockSwingTurn() && x9c6_28_aligningGrappleSwingTurn) + { + zeus::CVector3f pointDir = point->GetTransform().basis[1].normalized(); + zeus::CVector3f playerDir = x34_transform.basis[1].normalized(); + float playerPointProj = zeus::clamp(-1.f, playerDir.dot(pointDir), 1.f); + if (std::fabs(playerPointProj) == 1.f) + x9c6_28_aligningGrappleSwingTurn = false; + if (playerPointProj < 0.f) + { + playerPointProj = -playerPointProj; + pointDir = -pointDir; + } + float turnAngleAdj = std::acos(playerPointProj) * dt; + turnRot = zeus::CQuaternion::lookAt(playerDir, pointDir, turnAngleAdj); + } + if (pointToPlayer.magSquared() > 0.04f) + { + zeus::CVector3f pointToPlayerFlat = pointToPlayer; + pointToPlayerFlat.z = 0.f; + zeus::CVector3f playerToGrapplePlane = + point->GetTranslation() + turnRot.transform(pointToPlayerFlat) - GetTranslation(); + if (playerToGrapplePlane.canBeNormalized()) + pullVec += playerToGrapplePlane / dt; + } + zeus::CVector3f swingAxisBackup = x3c0_grappleSwingAxis; + x3c0_grappleSwingAxis = turnRot.transform(x3c0_grappleSwingAxis); + x3c0_grappleSwingAxis.normalize(); + zeus::CVector3f swingForward(-x3c0_grappleSwingAxis.y, x3c0_grappleSwingAxis.x, 0.f); + x34_transform = + zeus::CTransform(x3c0_grappleSwingAxis, swingForward, zeus::CVector3f::skUp, GetTranslation()); + xe4_27_ = true; + xe4_28_ = true; + xe4_29_ = true; + SetVelocityWR(pullVec); + + if (!ValidateFPPosition(GetTranslation(), mgr)) + { + x3c0_grappleSwingAxis = swingAxisBackup; + x34_transform = backupXf; + xe4_27_ = true; + xe4_28_ = true; + xe4_29_ = true; + SetVelocityWR(backupVel); + } + } + } + else + { + BreakGrapple(EPlayerOrbitRequest::Six, mgr); + } + break; + } + case EGrappleState::JumpOff: + { + zeus::CVector3f gravForce = {0.f, 0.f, GetGravity() * xe8_mass}; + ApplyForceOR(gravForce, zeus::CAxisAngle::sIdentity); + break; + } + default: + break; + } + } + + zeus::CVector3f newAngVel = {0.f, 0.f, 0.9f * GetAngularVelocityOR().getVector().z}; + SetAngularVelocityOR(newAngVel); +} + +bool CPlayer::ValidateFPPosition(const zeus::CVector3f& pos, CStateManager& mgr) +{ + CMaterialFilter solidFilter = CMaterialFilter::MakeInclude({EMaterialTypes::Solid}); + zeus::CAABox aabb(x2d8_.min - 1.f + pos, x2d8_.max + 1.f + pos); + rstl::reserved_vector nearList; + mgr.BuildColliderList(nearList, *this, aabb); + CCollidableAABox colAABB({GetBaseBoundingBox().min + pos, GetBaseBoundingBox().max + pos}, {}); + return !CGameCollision::DetectCollisionBoolean(mgr, colAABB, zeus::CTransform::Identity(), solidFilter, nearList); +} void CPlayer::UpdateGrappleState(const CFinalInput& input, CStateManager& mgr) { @@ -1637,7 +1978,7 @@ void CPlayer::UpdateGrappleState(const CFinalInput& input, CStateManager& mgr) if (x310_orbitTargetId == kInvalidUniqueId) { - x3b8_grappleState = EGrappleState::Zero; + x3b8_grappleState = EGrappleState::None; AddMaterial(EMaterialTypes::GroundCollider, mgr); return; } @@ -1673,7 +2014,7 @@ void CPlayer::UpdateGrappleState(const CFinalInput& input, CStateManager& mgr) x3c0_grappleSwingAxis.normalize(); x3bc_grappleSwingTimer = 0.f; SetOrbitTargetId(x33c_, mgr); - x3b8_grappleState = EGrappleState::Two; + x3b8_grappleState = EGrappleState::Pull; x33c_ = kInvalidUniqueId; x490_gun->GetGrappleArm().GrappleBeamConnected(); } @@ -1702,8 +2043,8 @@ void CPlayer::UpdateGrappleState(const CFinalInput& input, CStateManager& mgr) HolsterGun(mgr); switch (x3b8_grappleState) { - case EGrappleState::One: - case EGrappleState::Three: + case EGrappleState::Firing: + case EGrappleState::Swinging: switch (g_tweakPlayer->GetGrappleJumpMode()) { case 0: @@ -1742,8 +2083,8 @@ void CPlayer::UpdateGrappleState(const CFinalInput& input, CStateManager& mgr) } break; } - case EGrappleState::Zero: - x3b8_grappleState = EGrappleState::One; + case EGrappleState::None: + x3b8_grappleState = EGrappleState::Firing; x490_gun->GetGrappleArm().Activate(true); break; default: @@ -1776,7 +2117,7 @@ void CPlayer::UpdateGrappleState(const CFinalInput& input, CStateManager& mgr) switch (g_tweakPlayer->GetGrappleJumpMode()) { case 0: - if (x3b8_grappleState == EGrappleState::Four) + if (x3b8_grappleState == EGrappleState::JumpOff) { x3d8_grappleJumpTimeout -= input.DeltaTime(); if (x3d8_grappleJumpTimeout <= 0.f) @@ -1791,16 +2132,16 @@ void CPlayer::UpdateGrappleState(const CFinalInput& input, CStateManager& mgr) case 1: switch (x3b8_grappleState) { - case EGrappleState::Three: + case EGrappleState::Swinging: if (!ControlMapper::GetDigitalInput(ControlMapper::ECommands::FireOrBomb, input) && x3d8_grappleJumpTimeout <= 0.f) { x3d8_grappleJumpTimeout = g_tweakPlayer->GetGrappleReleaseTime(); - x3b8_grappleState = EGrappleState::Four; + x3b8_grappleState = EGrappleState::JumpOff; ApplyGrappleJump(mgr); } break; - case EGrappleState::Four: + case EGrappleState::JumpOff: x3d8_grappleJumpTimeout -= input.DeltaTime(); if (x3d8_grappleJumpTimeout <= 0.f) { @@ -1810,8 +2151,8 @@ void CPlayer::UpdateGrappleState(const CFinalInput& input, CStateManager& mgr) PreventFallingCameraPitch(); } break; - case EGrappleState::One: - case EGrappleState::Two: + case EGrappleState::Firing: + case EGrappleState::Pull: if (!ControlMapper::GetDigitalInput(ControlMapper::ECommands::FireOrBomb, input)) BreakGrapple(EPlayerOrbitRequest::Zero, mgr); break; @@ -1870,7 +2211,7 @@ void CPlayer::BeginGrapple(zeus::CVector3f& vec, CStateManager& mgr) x3c0_grappleSwingAxis.normalize(); x3bc_grappleSwingTimer = 0.f; SetOrbitState(EPlayerOrbitState::Five, mgr); - x3b8_grappleState = EGrappleState::Two; + x3b8_grappleState = EGrappleState::Pull; RemoveMaterial(EMaterialTypes::GroundCollider, mgr); } } @@ -1879,17 +2220,17 @@ void CPlayer::BreakGrapple(EPlayerOrbitRequest req, CStateManager& mgr) { x294_jumpCameraPitchTimer = 0.f; x29c_spaceJumpCameraPitchTimer = 0.f; - if (g_tweakPlayer->GetGrappleJumpMode() == 2 && x3b8_grappleState == EGrappleState::Three) + if (g_tweakPlayer->GetGrappleJumpMode() == 2 && x3b8_grappleState == EGrappleState::Swinging) { ApplyGrappleJump(mgr); PreventFallingCameraPitch(); } SetOrbitRequest(req, mgr); - x3b8_grappleState = EGrappleState::Zero; + x3b8_grappleState = EGrappleState::None; AddMaterial(EMaterialTypes::GroundCollider, mgr); x490_gun->GetGrappleArm().SetAnimState(CGrappleArm::EArmState::Eight); - if (!InGrappleJumpCooldown() && x3b8_grappleState != EGrappleState::Four) + if (!InGrappleJumpCooldown() && x3b8_grappleState != EGrappleState::JumpOff) DrawGun(mgr); } @@ -2517,7 +2858,7 @@ bool CPlayer::CFailsafeTest::Passes() const if (posMag >= 1.f / 30.f && posMag >= minVelMag / 30.f) test1 = false; - if (!notEqualStates && x0_stateSamples[0] == EInputState::StartingJump) + if (notEqualStates == 0 && x0_stateSamples[0] == EInputState::StartingJump) { float inputMag = (inputAABB.max - inputAABB.min).magnitude(); zeus::CAABox inputFrom0AABB(inputAABB); @@ -2552,7 +2893,7 @@ void CPlayer::IncrementPhazon() bool CPlayer::CheckSubmerged() const { - if (!xe6_24_fluidCounter) + if (xe6_24_fluidCounter == 0) return false; return x828_waterLevelOnPlayer >= (x2f8_morphTransState == EPlayerMorphBallState::Morphed ? @@ -2563,7 +2904,7 @@ void CPlayer::UpdateSubmerged(CStateManager& mgr) { x82c_inLava = false; x828_waterLevelOnPlayer = 0.f; - if (xe6_24_fluidCounter) + if (xe6_24_fluidCounter != 0) { if (TCastToPtr water = mgr.ObjectById(xc4_fluidId)) { diff --git a/Runtime/World/CPlayer.hpp b/Runtime/World/CPlayer.hpp index b7addd7bf..ed57891c9 100644 --- a/Runtime/World/CPlayer.hpp +++ b/Runtime/World/CPlayer.hpp @@ -143,12 +143,11 @@ public: enum class EGrappleState { - Zero, - One, - Two, - Three, - Four, - Five + None, + Firing, + Pull, + Swinging, + JumpOff }; enum class EGunHolsterState @@ -246,7 +245,7 @@ private: std::vector x364_offScreenOrbitObjects; bool x374_ = false; float x378_ = 0.f; - bool x37c_ = false; + bool x37c_sidewaysDashing = false; float x380_ = 0.f; float x384_ = 0.f; float x388_ = 0.f; @@ -261,7 +260,7 @@ private: float x3ac_scanningTime = 0.f; float x3b0_ = 0.f; TUniqueId x3b4_scanningObject = kInvalidUniqueId; - EGrappleState x3b8_grappleState = EGrappleState::Zero; + EGrappleState x3b8_grappleState = EGrappleState::None; float x3bc_grappleSwingTimer = 0.f; zeus::CVector3f x3c0_grappleSwingAxis = zeus::CVector3f::skRight; float x3cc_ = 0.f; @@ -372,7 +371,7 @@ private: bool x9c6_25_ : 1; bool x9c6_26_ : 1; bool x9c6_27_aimingAtProjectile : 1; - bool x9c6_28_ : 1; + bool x9c6_28_aligningGrappleSwingTurn : 1; bool x9c6_29_disableInput : 1; bool x9c6_30_newScanScanning : 1; bool x9c6_31_overrideRadarRadius : 1; @@ -496,6 +495,7 @@ public: EPlayerCameraState GetCameraState() const { return x2f4_cameraState; } EPlayerMorphBallState GetMorphballTransitionState() const { return x2f8_morphTransState; } void UpdateGrappleArmTransform(const zeus::CVector3f&, CStateManager& mgr, float); + float GetGravity() const; void ApplyGrappleForces(const CFinalInput& input, CStateManager& mgr, float); bool ValidateFPPosition(const zeus::CVector3f& pos, CStateManager& mgr); void UpdateGrappleState(const CFinalInput& input, CStateManager& mgr); diff --git a/Runtime/World/CScriptGrapplePoint.hpp b/Runtime/World/CScriptGrapplePoint.hpp index 67fb63be9..43347d590 100644 --- a/Runtime/World/CScriptGrapplePoint.hpp +++ b/Runtime/World/CScriptGrapplePoint.hpp @@ -15,6 +15,7 @@ public: bool active, const CGrappleParameters& params); void Accept(IVisitor& visitor); + const CGrappleParameters& GetGrappleParameters() const { return x100_parameters; } }; } diff --git a/Runtime/World/CScriptPlatform.cpp b/Runtime/World/CScriptPlatform.cpp index a32a71603..7bc157c8e 100644 --- a/Runtime/World/CScriptPlatform.cpp +++ b/Runtime/World/CScriptPlatform.cpp @@ -31,7 +31,7 @@ CScriptPlatform::CScriptPlatform(TUniqueId uid, const std::string& name, const C { CActor::SetMaterialFilter(CMaterialFilter::MakeIncludeExclude( CMaterialList(EMaterialTypes::Solid), - CMaterialList(EMaterialTypes::StaticCollision, EMaterialTypes::Twenty, EMaterialTypes::Platform))); + CMaterialList(EMaterialTypes::NoStaticCollision, EMaterialTypes::Twenty, EMaterialTypes::Platform))); if (x304_treeGroupContainer) x314_treeGroup = std::make_unique(x304_treeGroupContainer->GetObj(), x68_material); } diff --git a/Runtime/rstl.hpp b/Runtime/rstl.hpp index 331e452d8..07d703c00 100644 --- a/Runtime/rstl.hpp +++ b/Runtime/rstl.hpp @@ -60,6 +60,109 @@ ForwardIt binary_find(ForwardIt first, ForwardIt last, const T& value, GetKey ge first = std::lower_bound(first, last, value, comp); return (!(first == last) && !(value < getkey(*first))) ? first : last; } + +#if 0 +template +class basic_string +{ + struct COWData + { + uint32_t x0_capacity; + uint32_t x4_refCount; + _CharTp x8_data[]; + }; + + const _CharTp* x0_ptr; + COWData* x4_cow; + uint32_t x8_size; + + void internal_allocate(int size) + { + x4_cow = reinterpret_cast(new uint8_t[size * sizeof(_CharTp) + 8]); + x0_ptr = x4_cow->x8_data; + x4_cow->x0_capacity = uint32_t(size); + x4_cow->x4_refCount = 1; + } + + static const _CharTp _EmptyString; + +public: + struct literal_t {}; + + basic_string(literal_t, const _CharTp* data) + { + x0_ptr = data; + x4_cow = nullptr; + + const _CharTp* it = data; + while (*it) + ++it; + + x8_size = uint32_t((it - data) / sizeof(_CharTp)); + } + + basic_string(const basic_string& str) + { + x0_ptr = str.x0_ptr; + x4_cow = str.x4_cow; + x8_size = str.x8_size; + if (x4_cow) + ++x4_cow->x4_refCount; + } + + basic_string(const _CharTp* data, int size) + { + if (size <= 0 && !data) + { + x0_ptr = &_EmptyString; + x4_cow = nullptr; + x8_size = 0; + return; + } + + const _CharTp* it = data; + uint32_t len = 0; + while (*it) + { + if (size != -1 && len >= size) + break; + ++it; + ++len; + } + + internal_allocate(len + 1); + x8_size = len; + for (int i = 0; i < len; ++i) + x4_cow->x8_data[i] = data[i]; + x4_cow->x8_data[len] = 0; + } + + ~basic_string() + { + if (x4_cow && --x4_cow->x4_refCount == 0) + delete[] x4_cow; + } +}; + +template <> +const char basic_string::_EmptyString = 0; +template <> +const wchar_t basic_string::_EmptyString = 0; + +typedef basic_string wstring; +typedef basic_string string; + +wstring wstring_l(const wchar_t* data) +{ + return wstring(wstring::literal_t(), data); +} + +string string_l(const char* data) +{ + return string(string::literal_t(), data); +} +#endif + } #endif // __RSTL_HPP__ diff --git a/hecl b/hecl index 204ddd5ad..d56b3d0d8 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 204ddd5adf94822abafb25eb0771ddf2a2fa2f65 +Subproject commit d56b3d0d8b598f522ee25b8fb461ef5426044eea