2022-11-27 18:30:29 -05:00
|
|
|
#include <std_include.hpp>
|
|
|
|
#include "loader/component_loader.hpp"
|
|
|
|
|
|
|
|
#include <utils/hook.hpp>
|
|
|
|
|
2022-11-29 02:07:29 -05:00
|
|
|
#include "scheduler.hpp"
|
2022-11-27 18:30:29 -05:00
|
|
|
#include "game/game.hpp"
|
2023-03-16 08:14:58 -04:00
|
|
|
#include "game/utils.hpp"
|
2022-11-27 18:30:29 -05:00
|
|
|
|
|
|
|
namespace loot
|
|
|
|
{
|
|
|
|
namespace
|
|
|
|
{
|
2023-02-02 17:28:48 -05:00
|
|
|
game::dvar_t* dvar_cg_unlockall_loot;
|
2023-03-10 17:58:57 -05:00
|
|
|
game::dvar_t* dvar_cg_unlockall_purchases;
|
|
|
|
game::dvar_t* dvar_cg_unlockall_attachments;
|
|
|
|
game::dvar_t* dvar_cg_cg_unlockall_camos;
|
2023-02-02 17:28:48 -05:00
|
|
|
|
2022-11-28 16:15:58 -05:00
|
|
|
utils::hook::detour loot_getitemquantity_hook;
|
2022-11-28 18:09:44 -05:00
|
|
|
utils::hook::detour liveinventory_getitemquantity_hook;
|
|
|
|
utils::hook::detour liveinventory_areextraslotspurchased_hook;
|
2023-03-10 17:58:57 -05:00
|
|
|
utils::hook::detour bg_unlockablesisitempurchased_hook;
|
|
|
|
utils::hook::detour bg_unlockablesisitemattachmentlocked_hook;
|
|
|
|
utils::hook::detour bg_unlockablesisattachmentslotlocked_hook;
|
2022-11-28 16:15:58 -05:00
|
|
|
|
2023-02-02 17:28:48 -05:00
|
|
|
int loot_getitemquantity_stub(const game::ControllerIndex_t controller_index, const game::eModes mode,
|
|
|
|
const int item_id)
|
2022-11-28 16:15:58 -05:00
|
|
|
{
|
2023-03-14 14:32:08 -04:00
|
|
|
if (!dvar_cg_unlockall_loot->current.value.enabled)
|
2023-02-02 17:28:48 -05:00
|
|
|
{
|
|
|
|
return loot_getitemquantity_hook.invoke<int>(controller_index, mode, item_id);
|
|
|
|
}
|
|
|
|
|
2022-11-29 02:07:29 -05:00
|
|
|
if (mode == game::eModes::MODE_ZOMBIES)
|
|
|
|
{
|
2022-11-28 18:09:44 -05:00
|
|
|
return 999;
|
|
|
|
}
|
2022-11-29 02:07:29 -05:00
|
|
|
|
2022-11-28 16:15:58 -05:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2022-11-29 02:07:29 -05:00
|
|
|
int liveinventory_getitemquantity_stub(const game::ControllerIndex_t controller_index, const int item_id)
|
2022-11-28 18:09:44 -05:00
|
|
|
{
|
|
|
|
// Item id's for extra CaC slots, CWL camo's and paid specialist outfits
|
2023-03-14 14:32:08 -04:00
|
|
|
if (dvar_cg_unlockall_loot->current.value.enabled && (item_id == 99003 || item_id >= 99018 && item_id <= 99021 || item_id == 99025||
|
2023-02-02 17:28:48 -05:00
|
|
|
item_id >= 90047 && item_id <= 90064))
|
2022-11-29 02:07:29 -05:00
|
|
|
{
|
2022-11-28 18:09:44 -05:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2022-11-29 02:07:29 -05:00
|
|
|
return liveinventory_getitemquantity_hook.invoke<int>(controller_index, item_id);
|
2022-11-28 18:09:44 -05:00
|
|
|
}
|
|
|
|
|
2023-02-02 17:28:48 -05:00
|
|
|
bool liveinventory_areextraslotspurchased_stub(const game::ControllerIndex_t controller_index)
|
2022-11-28 18:09:44 -05:00
|
|
|
{
|
2023-03-14 14:32:08 -04:00
|
|
|
if (dvar_cg_unlockall_loot->current.value.enabled)
|
2023-02-02 17:28:48 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2022-11-28 18:09:44 -05:00
|
|
|
|
2023-02-02 17:28:48 -05:00
|
|
|
return liveinventory_areextraslotspurchased_hook.invoke<bool>(controller_index);
|
2022-11-27 18:30:29 -05:00
|
|
|
}
|
2023-03-10 17:58:57 -05:00
|
|
|
|
|
|
|
bool bg_unlockablesisitempurchased_stub(game::eModes mode, const game::ControllerIndex_t controller_index, int item_index)
|
|
|
|
{
|
2023-03-14 14:32:08 -04:00
|
|
|
if (dvar_cg_unlockall_purchases->current.value.enabled)
|
2023-03-10 17:58:57 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bg_unlockablesisitempurchased_hook.invoke<bool>(mode, controller_index, item_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool bg_unlockablesisitemattachmentlocked_stub(game::eModes mode, const game::ControllerIndex_t controller_index, int item_index, int attachment_num)
|
|
|
|
{
|
2023-03-14 14:32:08 -04:00
|
|
|
if (dvar_cg_unlockall_attachments->current.value.enabled)
|
2023-03-10 17:58:57 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bg_unlockablesisitemattachmentlocked_hook.invoke<bool>(mode, controller_index, item_index, attachment_num);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool bg_unlockablesisattachmentslotlocked_stub(game::eModes mode, const game::ControllerIndex_t controller_index, int item_index, int attachment_slot_index)
|
|
|
|
{
|
2023-03-14 14:32:08 -04:00
|
|
|
if (dvar_cg_unlockall_attachments->current.value.enabled)
|
2023-03-10 17:58:57 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bg_unlockablesisattachmentslotlocked_hook.invoke<bool>(mode, controller_index, item_index, attachment_slot_index);
|
|
|
|
}
|
2022-11-27 18:30:29 -05:00
|
|
|
};
|
|
|
|
|
2023-01-01 15:51:04 -05:00
|
|
|
struct component final : client_component
|
2022-11-27 18:30:29 -05:00
|
|
|
{
|
|
|
|
void post_unpack() override
|
|
|
|
{
|
2023-03-16 08:14:58 -04:00
|
|
|
dvar_cg_unlockall_loot = game::register_dvar_bool("cg_unlockall_loot", false, game::DVAR_ARCHIVE, "Unlocks blackmarket loot");
|
|
|
|
dvar_cg_unlockall_purchases = game::register_dvar_bool("cg_unlockall_purchases", false, game::DVAR_ARCHIVE, "Unlock all purchases with tokens");
|
|
|
|
dvar_cg_unlockall_attachments = game::register_dvar_bool("cg_unlockall_attachments", false, game::DVAR_ARCHIVE, "Unlocks all attachments");
|
|
|
|
dvar_cg_cg_unlockall_camos = game::register_dvar_bool("cg_unlockall_camos", false, game::DVAR_ARCHIVE, "Unlocks all camos");
|
2023-02-02 17:28:48 -05:00
|
|
|
|
2023-03-04 11:05:55 -05:00
|
|
|
loot_getitemquantity_hook.create(0x141E82C00_g, loot_getitemquantity_stub);
|
|
|
|
liveinventory_getitemquantity_hook.create(0x141E09030_g, liveinventory_getitemquantity_stub);
|
|
|
|
liveinventory_areextraslotspurchased_hook.create(0x141E08950_g, liveinventory_areextraslotspurchased_stub);
|
2023-03-10 17:58:57 -05:00
|
|
|
bg_unlockablesisitempurchased_hook.create(0x1426A9620_g, bg_unlockablesisitempurchased_stub);
|
|
|
|
bg_unlockablesisitemattachmentlocked_hook.create(0x1426A88D0_g, bg_unlockablesisitemattachmentlocked_stub);
|
|
|
|
bg_unlockablesisattachmentslotlocked_hook.create(0x1426A86D0_g, bg_unlockablesisattachmentslotlocked_stub);
|
2023-02-11 14:40:26 -05:00
|
|
|
|
|
|
|
scheduler::once([]() {
|
2023-03-14 14:32:08 -04:00
|
|
|
if (dvar_cg_unlockall_loot->current.value.enabled)
|
2023-02-11 14:40:26 -05:00
|
|
|
{
|
|
|
|
game::Dvar_SetFromStringByName("ui_enableAllHeroes", "1", true);
|
|
|
|
}
|
|
|
|
}, scheduler::pipeline::dvars_loaded);
|
2022-11-27 18:30:29 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-03-05 04:47:12 -05:00
|
|
|
REGISTER_COMPONENT(loot::component)
|