feat: add specific dvar to unlock loot (#1)

Co-authored-by: WantedDV <wanteddeviation@gmail.com>
Reviewed-on: https://git.alterware.dev/AlterWare/s1-mod/pulls/1
Co-authored-by: Wanted <wanted@no-reply@alterware.dev>
Co-committed-by: Wanted <wanted@no-reply@alterware.dev>
This commit is contained in:
Wanted 2024-02-12 10:28:03 +00:00 committed by Jack Back
parent 2deb2c340e
commit 1679ef60cc
2 changed files with 28 additions and 25 deletions

1
.gitignore vendored
View File

@ -58,6 +58,7 @@ build
# Visual Studio 2015 cache/options directory # Visual Studio 2015 cache/options directory
.vs/ .vs/
.vscode
# MSTest test Results # MSTest test Results
[Tt]est[Rr]esult*/ [Tt]est[Rr]esult*/

View File

@ -13,44 +13,45 @@ namespace stats
namespace namespace
{ {
game::dvar_t* cg_unlock_all_items; 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_locked_hook1;
utils::hook::detour is_item_unlocked_hook2; utils::hook::detour is_item_locked_hook2;
utils::hook::detour is_item_unlocked_hook3; 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) if (cg_unlock_all_items->current.enabled)
{ {
return 0; return 0;
} }
return is_item_unlocked_hook.invoke<int>(a1, a2, a3); return is_item_locked_hook1.invoke<int>(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) if (cg_unlock_all_items->current.enabled)
{ {
return 0; return 0;
} }
return is_item_unlocked_hook2.invoke<int>(a1, a2, a3, a4, a5); return is_item_locked_hook2.invoke<int>(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 0;
} }
return is_item_unlocked_hook3.invoke<int>(a1); return is_item_locked_hook3.invoke<int>(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()) if (game::environment::is_dedi())
{ {
// unlock all items // unlock all
utils::hook::jump(0x1403BD790, is_item_unlocked); // LiveStorage_IsItemUnlockedFromTable_LocalClient utils::hook::jump(0x1403BD790, is_item_locked); // LiveStorage_IsItemUnlockedFromTable_LocalClient
utils::hook::jump(0x1403BD290, is_item_unlocked); // LiveStorage_IsItemUnlockedFromTable utils::hook::jump(0x1403BD290, is_item_locked); // LiveStorage_IsItemUnlockedFromTable
utils::hook::jump(0x1403BAF60, is_item_unlocked); // idk ( unlocks loot etc ) utils::hook::jump(0x1403BAF60, is_item_locked); // unlocks supply drop loot
} }
else else
{ {
// unlock all items // unlock all
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."); 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.");
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."); 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.");
is_item_unlocked_hook.create(0x1403BD790, is_item_unlocked_stub); // LiveStorage_IsItemUnlockedFromTable_LocalClient is_item_locked_hook1.create(0x1403BD790, is_item_locked_stub1); // LiveStorage_IsItemUnlockedFromTable_LocalClient
is_item_unlocked_hook2.create(0x1403BD290, is_item_unlocked_stub2); // LiveStorage_IsItemUnlockedFromTable is_item_locked_hook2.create(0x1403BD290, is_item_locked_stub2); // LiveStorage_IsItemUnlockedFromTable
is_item_unlocked_hook3.create(0x1403BAF60, is_item_unlocked_stub3); // idk (unlocks loot etc) is_item_locked_hook3.create(0x1403BAF60, is_loot_locked_stub); // unlocks supply drop loot
} }
command::add("setPlayerDataInt", [](const command::params& params) command::add("setPlayerDataInt", [](const command::params& params)
{ {
if (params.size() < 2) if (params.size() < 2)
{ {