2022-03-09 19:30:03 -05:00
|
|
|
#include <std_include.hpp>
|
|
|
|
#include "loader/component_loader.hpp"
|
|
|
|
|
|
|
|
#include "scheduler.hpp"
|
|
|
|
#include "dvars.hpp"
|
|
|
|
|
|
|
|
#include "game/game.hpp"
|
|
|
|
#include "game/dvars.hpp"
|
|
|
|
|
|
|
|
#include <utils/nt.hpp>
|
|
|
|
#include <utils/hook.hpp>
|
|
|
|
#include <utils/flags.hpp>
|
|
|
|
|
|
|
|
namespace stats
|
|
|
|
{
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
game::dvar_t* cg_unlock_all_items;
|
2022-05-24 20:00:59 -04:00
|
|
|
game::dvar_t* cg_unlock_all_loot;
|
2022-03-09 19:30:03 -05:00
|
|
|
|
|
|
|
utils::hook::detour is_item_unlocked_hook;
|
2022-05-24 20:00:59 -04:00
|
|
|
utils::hook::detour is_item_unlocked_hook2;
|
2022-03-09 19:30:03 -05:00
|
|
|
|
2022-05-20 16:02:42 -04:00
|
|
|
int is_item_unlocked_stub(int a1, void* a2, void* a3, void* a4, int a5, void* a6)
|
2022-03-09 19:30:03 -05:00
|
|
|
{
|
|
|
|
if (cg_unlock_all_items->current.enabled)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-05-20 16:02:42 -04:00
|
|
|
return is_item_unlocked_hook.invoke<int>(a1, a2, a3, a4, a5, a6);
|
2022-03-09 19:30:03 -05:00
|
|
|
}
|
|
|
|
|
2022-03-17 19:27:13 -04:00
|
|
|
int is_item_unlocked()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2022-05-24 20:00:59 -04:00
|
|
|
|
|
|
|
int is_item_unlocked_stub2(void* a1, void* a2)
|
|
|
|
{
|
|
|
|
const auto state = is_item_unlocked_hook2.invoke<int>(a1, a2);
|
|
|
|
if (state == 15 /*Not In Inventory*/ && cg_unlock_all_loot->current.enabled)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
2022-03-09 19:30:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
class component final : public component_interface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void post_unpack() override
|
|
|
|
{
|
2022-03-17 19:27:13 -04:00
|
|
|
if (game::environment::is_sp())
|
2022-03-09 19:30:03 -05:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-20 16:02:42 -04:00
|
|
|
utils::hook::jump(0x19E6E0_b, is_item_unlocked, true);
|
|
|
|
|
2022-03-17 19:27:13 -04:00
|
|
|
if (game::environment::is_dedi())
|
|
|
|
{
|
2022-05-18 20:27:46 -04:00
|
|
|
utils::hook::jump(0x19E070_b, is_item_unlocked, true);
|
|
|
|
utils::hook::jump(0x19D390_b, is_item_unlocked, true);
|
2022-05-24 20:00:59 -04:00
|
|
|
utils::hook::jump(0x19D140_b, is_item_unlocked, true);
|
2022-03-17 19:27:13 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-20 16:02:42 -04:00
|
|
|
is_item_unlocked_hook.create(0x19E070_b, is_item_unlocked_stub);
|
2022-05-24 20:00:59 -04:00
|
|
|
is_item_unlocked_hook2.create(0x19D140_b, is_item_unlocked_stub2);
|
2022-05-20 15:11:58 -04:00
|
|
|
|
2022-03-17 19:27:13 -04:00
|
|
|
cg_unlock_all_items = dvars::register_bool("cg_unlockall_items", false, game::DVAR_FLAG_SAVED,
|
|
|
|
"Whether items should be locked based on the player's stats or always unlocked.");
|
|
|
|
dvars::register_bool("cg_unlockall_classes", false, game::DVAR_FLAG_SAVED,
|
|
|
|
"Whether classes should be locked based on the player's stats or always unlocked.");
|
2022-05-24 20:00:59 -04:00
|
|
|
cg_unlock_all_loot = dvars::register_bool("cg_unlockall_loot", false, game::DVAR_FLAG_SAVED,
|
2022-05-20 15:11:58 -04:00
|
|
|
"Whether loot should be locked based on the player's stats or always unlocked.");
|
2022-03-17 19:27:13 -04:00
|
|
|
}
|
2022-03-09 19:30:03 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-05-19 18:06:09 -04:00
|
|
|
REGISTER_COMPONENT(stats::component)
|