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"
|
|
|
|
|
|
|
|
namespace loot
|
|
|
|
{
|
|
|
|
namespace
|
|
|
|
{
|
2023-02-02 17:28:48 -05:00
|
|
|
game::dvar_t* dvar_cg_unlockall_loot;
|
|
|
|
|
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;
|
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-02-02 17:28:48 -05:00
|
|
|
if (!dvar_cg_unlockall_loot->current.enabled)
|
|
|
|
{
|
|
|
|
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-02-02 17:28:48 -05:00
|
|
|
if (dvar_cg_unlockall_loot->current.enabled && (item_id == 99003 || item_id >= 99018 && item_id <= 99021 || item_id == 99025||
|
|
|
|
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-02-02 17:28:48 -05:00
|
|
|
if (dvar_cg_unlockall_loot->current.enabled)
|
|
|
|
{
|
|
|
|
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-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-02-11 14:40:26 -05:00
|
|
|
dvar_cg_unlockall_loot = game::Dvar_RegisterBool(game::Dvar_GenerateHash("cg_unlockall_loot"), "cg_unlockall_loot", false, (game::dvarFlags_e)0x0, "Unlocks blackmarket loot");
|
2023-02-02 17:28:48 -05:00
|
|
|
dvar_cg_unlockall_loot->debugName = "cg_unlockall_loot";
|
|
|
|
|
2022-11-28 16:15:58 -05:00
|
|
|
loot_getitemquantity_hook.create(0x141E82C90_g, loot_getitemquantity_stub);
|
2022-11-28 18:09:44 -05:00
|
|
|
liveinventory_getitemquantity_hook.create(0x141E090C0_g, liveinventory_getitemquantity_stub);
|
|
|
|
liveinventory_areextraslotspurchased_hook.create(0x141E089E0_g, liveinventory_areextraslotspurchased_stub);
|
2023-02-11 14:40:26 -05:00
|
|
|
|
|
|
|
scheduler::once([]() {
|
|
|
|
if (dvar_cg_unlockall_loot->current.enabled)
|
|
|
|
{
|
|
|
|
game::Dvar_SetFromStringByName("ui_enableAllHeroes", "1", true);
|
|
|
|
}
|
|
|
|
}, scheduler::pipeline::dvars_loaded);
|
2022-11-27 18:30:29 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-11-29 02:07:29 -05:00
|
|
|
REGISTER_COMPONENT(loot::component)
|