From 1679ef60ccadae9b8a9e4afe3da8a305ac33ee2c Mon Sep 17 00:00:00 2001 From: Wanted Date: Mon, 12 Feb 2024 10:28:03 +0000 Subject: [PATCH] feat: add specific dvar to unlock loot (#1) Co-authored-by: WantedDV Reviewed-on: https://git.alterware.dev/AlterWare/s1-mod/pulls/1 Co-authored-by: Wanted Co-committed-by: Wanted --- .gitignore | 1 + src/client/component/stats.cpp | 52 ++++++++++++++++++---------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 130a33a..64c35ae 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,7 @@ build # Visual Studio 2015 cache/options directory .vs/ +.vscode # MSTest test Results [Tt]est[Rr]esult*/ diff --git a/src/client/component/stats.cpp b/src/client/component/stats.cpp index bccac67..2450b63 100644 --- a/src/client/component/stats.cpp +++ b/src/client/component/stats.cpp @@ -13,44 +13,45 @@ namespace stats namespace { game::dvar_t* cg_unlock_all_items; + game::dvar_t* cg_unlock_all_loot; - utils::hook::detour is_item_unlocked_hook; - utils::hook::detour is_item_unlocked_hook2; - utils::hook::detour is_item_unlocked_hook3; + utils::hook::detour is_item_locked_hook1; + utils::hook::detour is_item_locked_hook2; + utils::hook::detour is_item_locked_hook3; - int is_item_unlocked_stub(void* a1, void* a2, void* a3) + int is_item_locked_stub1(void* a1, void* a2, void* a3) { if (cg_unlock_all_items->current.enabled) { return 0; } - return is_item_unlocked_hook.invoke(a1, a2, a3); + return is_item_locked_hook1.invoke(a1, a2, a3); } - int is_item_unlocked_stub2(void* a1, void* a2, void* a3, void* a4, void* a5) + int is_item_locked_stub2(void* a1, void* a2, void* a3, void* a4, void* a5) { if (cg_unlock_all_items->current.enabled) { return 0; } - return is_item_unlocked_hook2.invoke(a1, a2, a3, a4, a5); + return is_item_locked_hook2.invoke(a1, a2, a3, a4, a5); } - int is_item_unlocked_stub3(void* a1) + int is_loot_locked_stub(void* a1) { - if (cg_unlock_all_items->current.enabled) + if (cg_unlock_all_loot->current.enabled) { return 0; } - return is_item_unlocked_hook3.invoke(a1); + return is_item_locked_hook3.invoke(a1); } - int is_item_unlocked() + int is_item_locked() { - return 0; // 0 == yes + return 0; } } @@ -66,23 +67,24 @@ namespace stats 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 ) + // unlock all + utils::hook::jump(0x1403BD790, is_item_locked); // LiveStorage_IsItemUnlockedFromTable_LocalClient + utils::hook::jump(0x1403BD290, is_item_locked); // LiveStorage_IsItemUnlockedFromTable + utils::hook::jump(0x1403BAF60, is_item_locked); // unlocks supply drop loot } 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) - } + // unlock all + cg_unlock_all_items = game::Dvar_RegisterBool("cg_unlockall_items", false, game::DVAR_FLAG_SAVED, "Unlock items that are level-locked by the player's stats."); + cg_unlock_all_loot = game::Dvar_RegisterBool("cg_unlockall_loot", false, game::DVAR_FLAG_SAVED, "Unlock supply drop loot."); + game::Dvar_RegisterBool("cg_unlockall_classes", false, game::DVAR_FLAG_SAVED, "Unlock extra class slots."); - command::add("setPlayerDataInt", [](const command::params& params) + is_item_locked_hook1.create(0x1403BD790, is_item_locked_stub1); // LiveStorage_IsItemUnlockedFromTable_LocalClient + is_item_locked_hook2.create(0x1403BD290, is_item_locked_stub2); // LiveStorage_IsItemUnlockedFromTable + is_item_locked_hook3.create(0x1403BAF60, is_loot_locked_stub); // unlocks supply drop loot + } + + command::add("setPlayerDataInt", [](const command::params& params) { if (params.size() < 2) {