-
Notifications
You must be signed in to change notification settings - Fork 39
Add new cheat options to Player mod #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pavledev
wants to merge
19
commits into
master
Choose a base branch
from
feat/player-mod-options
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9ede0c1
Update signature of ZSecuritySystemCameraManager::OnFrameUpdate and Z…
pavledev 66fb7e2
Fix indentation in IKControllerOwner declaration
pavledev 098a354
Add IsCustomFlagEnabled virtual function to IIKControllerOwner and ad…
pavledev 2dc0fbb
Add missing virtual function to IIKControllerOwner
pavledev 1d50cd0
Add offset comment for padding in ZHM5Health
pavledev 706f855
Add and ZHM5WeaponRecoilController and ZHM5BaseController
pavledev 7036c24
Add virtual functions to IFirearm and add new fields to ZHM5ItemWeapon
pavledev 7e0abab
Fix padding in ZCharacterSubcontrollerInventory
pavledev 23cd937
Add new cheat options to Player mod
pavledev 5d1ef5f
Extend ZGameTime with constructors, operators, and conversions
pavledev f25a7fd
Replace padding with boolean field in ZGameTimeManager
pavledev ebebd2a
Use default ZGameTime initialization instead of raw zero
pavledev c8f10ee
Apply cheats only to player weapons
pavledev 078bb7a
Add m_pOwner to ZHM5Item, add missing offset comments and update offs…
pavledev 5c9ae6c
Add eLIMITED_AMMO item to ECustomFlags
pavledev ab5054c
Make IKControllerOwner::IsCustomFlagEnabled const
pavledev 627699d
Add IsInfiniteAmmoEnabled method to ZHitman5
pavledev 591e7e1
Refactor hook returns to use brace initialization
pavledev b05a9cd
Merge branch 'master' into feat/player-mod-options
pavledev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,16 @@ void Player::Init() { | |
| &Player::ZSecuritySystemCameraManager_OnFrameUpdate | ||
| ); | ||
| Hooks::ZSecuritySystemCamera_FrameUpdate->AddDetour(this, &Player::ZSecuritySystemCamera_FrameUpdate); | ||
|
|
||
| Hooks::ZHM5ItemWeapon_SetBulletsInMagazine->AddDetour(this, &Player::ZHM5ItemWeapon_SetBulletsInMagazine); | ||
| Hooks::ZHitmanMorphemePostProcessor_UpdateWeaponRecoil->AddDetour( | ||
| this, | ||
| &Player::ZHitmanMorphemePostProcessor_UpdateWeaponRecoil | ||
| ); | ||
| Hooks::ZHM5WeaponRecoilController_RecoilWeapon->AddDetour(this, &Player::ZHM5WeaponRecoilController_RecoilWeapon); | ||
| Hooks::ZHM5ItemWeapon_FireProjectiles->AddDetour(this, &Player::ZHM5ItemWeapon_FireProjectiles); | ||
| Hooks::ZHM5ItemWeapon_IsFiring->AddDetour(this, &Player::ZHM5ItemWeapon_IsFiring); | ||
| Hooks::ZActor_YouGotHit->AddDetour(this, &Player::ZActor_YouGotHit); | ||
| } | ||
|
|
||
| void Player::OnDrawMenu() { | ||
|
|
@@ -59,6 +69,16 @@ void Player::OnDrawUI(const bool p_HasFocus) { | |
| ToggleInfiniteAmmo(); | ||
| } | ||
|
|
||
| ImGui::Checkbox("No Reload", &m_IsNoReloadEnabled); | ||
|
|
||
| ImGui::Checkbox("No Recoil", &m_IsNoRecoilEnabled); | ||
|
|
||
| ImGui::Checkbox("Super Accuracy", &m_IsSuperAccuracyEnabled); | ||
|
|
||
| ImGui::Checkbox("RapidFire", &m_IsRapidFireEnabled); | ||
|
|
||
| ImGui::Checkbox("One Hit Kill", &m_IsOneHitKillEnabled); | ||
|
|
||
| static char s_OutfitName[2048] { "" }; | ||
| static uint8_t s_CurrentCharacterSetIndex = 0; | ||
| static std::string s_CurrentCharSetCharacterType = "HeroA"; | ||
|
|
@@ -606,35 +626,177 @@ DEFINE_PLUGIN_DETOUR(Player, void, OnClearScene, ZEntitySceneContext* th, bool p | |
| m_IsInfiniteAmmoEnabled = false; | ||
| m_GlobalOutfitKit = {}; | ||
|
|
||
| return HookResult<void>(HookAction::Continue()); | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| DEFINE_PLUGIN_DETOUR( | ||
| Player, | ||
| void, | ||
| ZSecuritySystemCameraManager_OnFrameUpdate, | ||
| ZSecuritySystemCameraManager* th, | ||
| const SGameUpdateEvent* const updateEvent | ||
| const SGameUpdateEvent& updateEvent | ||
| ) { | ||
| if (m_IsInvisible) { | ||
| return HookResult<void>(HookAction::Return()); | ||
| return { HookAction::Return() }; | ||
| } | ||
|
|
||
| return HookResult<void>(HookAction::Continue()); | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| DEFINE_PLUGIN_DETOUR( | ||
| Player, | ||
| void, | ||
| ZSecuritySystemCamera_FrameUpdate, | ||
| ZSecuritySystemCamera* th, | ||
| const SGameUpdateEvent* const updateEvent | ||
| const SGameUpdateEvent& updateEvent | ||
| ) { | ||
| if (m_IsInvisible) { | ||
| return HookResult<void>(HookAction::Return()); | ||
| return { HookAction::Return() }; | ||
| } | ||
|
|
||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| DEFINE_PLUGIN_DETOUR(Player, void, ZHM5ItemWeapon_SetBulletsInMagazine, IFirearm* th, int32_t nBullets) { | ||
| if (!m_IsNoReloadEnabled) { | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| const auto s_LocalHitman = SDK()->GetLocalPlayer(); | ||
|
|
||
| if (!s_LocalHitman) { | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| ZHM5ItemWeapon* s_HM5ItemWeapon = static_cast<ZHM5ItemWeapon*>(th); | ||
|
|
||
| if (s_HM5ItemWeapon->m_pOwner != s_LocalHitman.m_entityRef) { | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| if (s_HM5ItemWeapon->m_nBulletsFired == s_HM5ItemWeapon->m_nBulletsToFire) { | ||
| s_HM5ItemWeapon->m_nBulletsFired = 0; | ||
| } | ||
|
|
||
| if (nBullets != 0) { | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| if (!s_LocalHitman.m_pInterfaceRef->IsInfiniteAmmoEnabled()) { | ||
| auto s_Character = s_LocalHitman.m_pInterfaceRef->m_pCharacter.m_pInterfaceRef; | ||
| auto s_Controllers = &s_Character->m_rSubcontrollerContainer.m_pInterfaceRef->m_aReferencedControllers; | ||
| auto s_Inventory = static_cast<ZCharacterSubcontrollerInventory*>((*s_Controllers)[6].m_pInterfaceRef); | ||
|
|
||
| const eAmmoType s_AmmoType = th->GetAmmoType(); | ||
|
|
||
| uint32 s_AmmoInPocket = Functions::ZCharacterSubcontrollerInventory_GetAmmoInPocketForType->Call( | ||
| s_Inventory, | ||
| s_AmmoType | ||
| ); | ||
|
|
||
| if (s_AmmoInPocket > 0) { | ||
| s_AmmoInPocket -= s_HM5ItemWeapon->GetMagazineCapacity(); | ||
|
|
||
| s_Inventory->m_nAmmoInPocket[static_cast<size_t>(s_AmmoType)] = s_AmmoInPocket; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we guaranteed to have an element in at this index?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
|
|
||
| nBullets = s_HM5ItemWeapon->GetMagazineCapacity(); | ||
| } | ||
| } | ||
| else { | ||
| nBullets = s_HM5ItemWeapon->GetMagazineCapacity(); | ||
| } | ||
|
|
||
| p_Hook->CallOriginal(th, nBullets); | ||
|
|
||
| return { HookAction::Return() }; | ||
| } | ||
|
|
||
| DEFINE_PLUGIN_DETOUR( | ||
| Player, | ||
| void, | ||
| ZHitmanMorphemePostProcessor_UpdateWeaponRecoil, | ||
| ZHitmanMorphemePostProcessor* th, | ||
| float fDeltaTime, | ||
| const THashMap<int32_t, int32_t, TDefaultHashMapPolicy<int32_t>>& charboneMap, | ||
| TArrayRef<int32_t> hierarchy | ||
| ) { | ||
| if (m_IsNoRecoilEnabled) { | ||
| return { HookAction::Return() }; | ||
| } | ||
|
|
||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| DEFINE_PLUGIN_DETOUR( | ||
| Player, | ||
| void, | ||
| ZHM5WeaponRecoilController_RecoilWeapon, | ||
| ZHM5WeaponRecoilController* th, | ||
| const TEntityRef<ZHM5ItemWeapon>& rWeapon | ||
| ) { | ||
| if (!m_IsNoRecoilEnabled) { | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| p_Hook->CallOriginal(th, rWeapon); | ||
|
|
||
| th->m_vRecoil = SVector2(0.f, 0.f); | ||
|
|
||
| return { HookAction::Return() }; | ||
| } | ||
|
|
||
| DEFINE_PLUGIN_DETOUR(Player, bool, ZHM5ItemWeapon_FireProjectiles, ZHM5ItemWeapon* th, bool bMayStartSound) { | ||
| if (!m_IsSuperAccuracyEnabled) { | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| const auto s_LocalHitman = SDK()->GetLocalPlayer(); | ||
|
|
||
| if (!s_LocalHitman) { | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| if (th->m_pOwner != s_LocalHitman.m_entityRef) { | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| bool s_Result = p_Hook->CallOriginal(th, bMayStartSound); | ||
|
|
||
| th->m_fPrecisionFactor = 0.f; | ||
|
|
||
| return { HookAction::Return(), s_Result }; | ||
| } | ||
|
|
||
| DEFINE_PLUGIN_DETOUR(Player, bool, ZHM5ItemWeapon_IsFiring, IFirearm* th) { | ||
| if (!m_IsRapidFireEnabled) { | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| const auto s_LocalHitman = SDK()->GetLocalPlayer(); | ||
|
|
||
| if (!s_LocalHitman) { | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| ZHM5ItemWeapon* s_HM5ItemWeapon = static_cast<ZHM5ItemWeapon*>(th); | ||
|
|
||
| if (s_HM5ItemWeapon->m_pOwner != s_LocalHitman.m_entityRef) { | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| s_HM5ItemWeapon->m_tLastShootTime = ZGameTime {}; | ||
|
|
||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| DEFINE_PLUGIN_DETOUR(Player, bool, ZActor_YouGotHit, IBaseCharacter* th, const SHitInfo& hitInfo) { | ||
| if (m_IsOneHitKillEnabled) { | ||
| ZActor* s_Actor = static_cast<ZActor*>(th); | ||
|
|
||
| s_Actor->m_fCurrentHitPoints = 0.f; | ||
| } | ||
|
|
||
| return HookResult<void>(HookAction::Continue()); | ||
| return { HookAction::Continue() }; | ||
| } | ||
|
|
||
| DEFINE_ZHM_PLUGIN(Player); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.