From 17caafece328b1b2ea1ef2d5d2dacbb2813a7e00 Mon Sep 17 00:00:00 2001 From: Skull Merlin <86374920+skkuull@users.noreply.github.com> Date: Fri, 18 Mar 2022 22:16:34 +0200 Subject: [PATCH 1/2] fix stats --- src/client/component/stats.cpp | 37 ++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/client/component/stats.cpp b/src/client/component/stats.cpp index eac4c3c..e06679a 100644 --- a/src/client/component/stats.cpp +++ b/src/client/component/stats.cpp @@ -18,7 +18,7 @@ namespace stats utils::hook::detour is_item_unlocked_hook2; utils::hook::detour is_item_unlocked_hook3; - int is_item_unlocked_stub(void* a1, void* a2, void* a3) + int is_item_unlocked_stub(int a1, void* a2, int a3) { if (cg_unlock_all_items->current.enabled) { @@ -28,7 +28,7 @@ namespace stats return is_item_unlocked_hook.invoke(a1, a2, a3); } - int is_item_unlocked_stub2(void* a1, void* a2, void* a3, void* a4, void* a5) + int is_item_unlocked_stub2(int a1, void* a2, void* a3, void* a4, int a5) { if (cg_unlock_all_items->current.enabled) { @@ -38,7 +38,7 @@ namespace stats return is_item_unlocked_hook2.invoke(a1, a2, a3, a4, a5); } - int is_item_unlocked_stub3(void* a1) + int is_item_unlocked_stub3(int a1) { if (cg_unlock_all_items->current.enabled) { @@ -47,6 +47,11 @@ namespace stats return is_item_unlocked_hook3.invoke(a1); } + + int is_item_unlocked() + { + return 0; // 0 == yes + } } class component final : public component_interface @@ -54,18 +59,28 @@ namespace stats public: void post_unpack() override { - if (!game::environment::is_mp()) + if (game::environment::is_sp()) { return; } - // unlock all items - cg_unlock_all_items = game::Dvar_RegisterBool("cg_unlockall_items", false, game::DVAR_FLAG_SAVED, "Whether items should be locked based on the player's stats or always unlocked."); - game::Dvar_RegisterBool("cg_unlockall_classes", false, game::DVAR_FLAG_SAVED, "Whether classes should be locked based on the player's stats or always unlocked."); - - is_item_unlocked_hook.create(0x1403BD790, is_item_unlocked_stub); // LiveStorage_IsItemUnlockedFromTable_LocalClient - is_item_unlocked_hook2.create(0x1403BD290, is_item_unlocked_stub2); // LiveStorage_IsItemUnlockedFromTable - is_item_unlocked_hook3.create(0x1403BAF60, is_item_unlocked_stub3); // idk (unlocks loot etc) + if (game::environment::is_dedi()) + { + // unlock all items + utils::hook::jump(0x1403BD790, is_item_unlocked); // LiveStorage_IsItemUnlockedFromTable_LocalClient + utils::hook::jump(0x1403BD290, is_item_unlocked); // LiveStorage_IsItemUnlockedFromTable + utils::hook::jump(0x1403BAF60, is_item_unlocked); // idk ( unlocks loot etc ) + } + else + { + // unlock all items + cg_unlock_all_items = game::Dvar_RegisterBool("cg_unlockall_items", false, game::DVAR_FLAG_SAVED, "Whether items should be locked based on the player's stats or always unlocked."); + game::Dvar_RegisterBool("cg_unlockall_classes", false, game::DVAR_FLAG_SAVED, "Whether classes should be locked based on the player's stats or always unlocked."); + + is_item_unlocked_hook.create(0x1403BD790, is_item_unlocked_stub); // LiveStorage_IsItemUnlockedFromTable_LocalClient + is_item_unlocked_hook2.create(0x1403BD290, is_item_unlocked_stub2); // LiveStorage_IsItemUnlockedFromTable + is_item_unlocked_hook3.create(0x1403BAF60, is_item_unlocked_stub3); // idk (unlocks loot etc) + } command::add("setPlayerDataInt", [](const command::params& params) { From 69853cc0c32eadd929a1dc8a6c87c648ed39decd Mon Sep 17 00:00:00 2001 From: Skull Merlin <86374920+skkuull@users.noreply.github.com> Date: Tue, 22 Mar 2022 17:43:15 +0300 Subject: [PATCH 2/2] Update stats.cpp --- src/client/component/stats.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/component/stats.cpp b/src/client/component/stats.cpp index e06679a..bccac67 100644 --- a/src/client/component/stats.cpp +++ b/src/client/component/stats.cpp @@ -18,7 +18,7 @@ namespace stats utils::hook::detour is_item_unlocked_hook2; utils::hook::detour is_item_unlocked_hook3; - int is_item_unlocked_stub(int a1, void* a2, int a3) + int is_item_unlocked_stub(void* a1, void* a2, void* a3) { if (cg_unlock_all_items->current.enabled) { @@ -28,7 +28,7 @@ namespace stats return is_item_unlocked_hook.invoke(a1, a2, a3); } - int is_item_unlocked_stub2(int a1, void* a2, void* a3, void* a4, int a5) + int is_item_unlocked_stub2(void* a1, void* a2, void* a3, void* a4, void* a5) { if (cg_unlock_all_items->current.enabled) { @@ -38,7 +38,7 @@ namespace stats return is_item_unlocked_hook2.invoke(a1, a2, a3, a4, a5); } - int is_item_unlocked_stub3(int a1) + int is_item_unlocked_stub3(void* a1) { if (cg_unlock_all_items->current.enabled) {