Added config file for saved dvars and added menu for unlocking loot
This commit is contained in:
parent
43364491ab
commit
d25d6a7c10
4
data/ui_scripts/luafixes/__init__.lua
Normal file
4
data/ui_scripts/luafixes/__init__.lua
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
-- Fix LUI_NULL_FUNCTION messages
|
||||||
|
function Engine.PIXBeginEvent() end
|
||||||
|
function Engine.PIXEndEvent() end
|
286
data/ui_scripts/stats/__init__.lua
Normal file
286
data/ui_scripts/stats/__init__.lua
Normal file
@ -0,0 +1,286 @@
|
|||||||
|
DataSources.MPStatsSettings = DataSourceHelpers.ListSetup( "MPStatsSettings", function ( controller )
|
||||||
|
local optionsTable = {}
|
||||||
|
|
||||||
|
table.insert( optionsTable, CoD.OptionsUtility.CreateDvarSettings( controller, "Unlock all loot", "Whether loot should be locked based on the player's stats or always unlocked.", "MPStatsSettings_unlock_loot", "cg_unlockall_loot", {
|
||||||
|
{
|
||||||
|
option = "MENU_DISABLED",
|
||||||
|
value = 0,
|
||||||
|
default = true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
option = "MENU_ENABLED",
|
||||||
|
value = 1
|
||||||
|
},
|
||||||
|
}, nil, function(f1_arg0, f1_arg1, f1_arg2, dvarName, f1_arg4)
|
||||||
|
local oldValue = Engine.DvarInt( nil, dvarName )
|
||||||
|
local newValue = f1_arg1.value
|
||||||
|
UpdateInfoModels( f1_arg1 )
|
||||||
|
if oldValue == newValue then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
Engine.SetDvar( dvarName, f1_arg1.value )
|
||||||
|
Engine.SetDvar( "ui_enableAllHeroes", f1_arg1.value )
|
||||||
|
end) )
|
||||||
|
|
||||||
|
return optionsTable
|
||||||
|
end)
|
||||||
|
|
||||||
|
LUI.createMenu.MPStatsMenu = function ( controller )
|
||||||
|
local self = CoD.Menu.NewForUIEditor( "MPStatsMenu" )
|
||||||
|
if PreLoadFunc then
|
||||||
|
PreLoadFunc( self, controller )
|
||||||
|
end
|
||||||
|
self.soundSet = "ChooseDecal"
|
||||||
|
self:setOwner( controller )
|
||||||
|
self:setLeftRight( true, true, 0, 0 )
|
||||||
|
self:setTopBottom( true, true, 0, 0 )
|
||||||
|
self:playSound( "menu_open", controller )
|
||||||
|
self.buttonModel = Engine.CreateModel( Engine.GetModelForController( controller ), "MPStatsMenu.buttonPrompts" )
|
||||||
|
self.anyChildUsesUpdateState = true
|
||||||
|
|
||||||
|
local GameSettingsBackground = CoD.GameSettings_Background.new( self, controller )
|
||||||
|
GameSettingsBackground:setLeftRight( true, true, 0, 0 )
|
||||||
|
GameSettingsBackground:setTopBottom( true, true, 0, 0 )
|
||||||
|
GameSettingsBackground.MenuFrame.titleLabel:setText( Engine.Localize( "STATS SETTINGS" ) )
|
||||||
|
GameSettingsBackground.MenuFrame.cac3dTitleIntermediary0.FE3dTitleContainer0.MenuTitle.TextBox1.Label0:setText( Engine.Localize( "STATS SETTINGS" ) )
|
||||||
|
GameSettingsBackground.GameSettingsSelectedItemInfo.GameModeInfo:setAlpha( 0 )
|
||||||
|
GameSettingsBackground.GameSettingsSelectedItemInfo.GameModeName:setAlpha( 0 )
|
||||||
|
self:addElement( GameSettingsBackground )
|
||||||
|
self.GameSettingsBackground = GameSettingsBackground
|
||||||
|
|
||||||
|
local Options = CoD.Competitive_SettingsList.new( self, controller )
|
||||||
|
Options:setLeftRight( true, false, 26, 741 )
|
||||||
|
Options:setTopBottom( true, false, 135, 720 )
|
||||||
|
Options.Title.DescTitle:setText( Engine.Localize( "Stats" ) )
|
||||||
|
Options.ButtonList:setVerticalCount( 15 )
|
||||||
|
Options.ButtonList:setDataSource( "MPStatsSettings" )
|
||||||
|
self:addElement( Options )
|
||||||
|
self.Options = Options
|
||||||
|
|
||||||
|
self:AddButtonCallbackFunction( self, controller, Enum.LUIButton.LUI_KEY_XBB_PSCIRCLE, nil, function ( element, menu, controller, model )
|
||||||
|
GoBack( self, controller )
|
||||||
|
SetPerControllerTableProperty( controller, "disableGameSettingsOptions", nil )
|
||||||
|
return true
|
||||||
|
end, function ( element, menu, controller )
|
||||||
|
CoD.Menu.SetButtonLabel( menu, Enum.LUIButton.LUI_KEY_XBB_PSCIRCLE, "MENU_BACK" )
|
||||||
|
return true
|
||||||
|
end, false )
|
||||||
|
|
||||||
|
GameSettingsBackground.MenuFrame:setModel( self.buttonModel, controller )
|
||||||
|
Options.id = "Options"
|
||||||
|
|
||||||
|
self:processEvent( {
|
||||||
|
name = "menu_loaded",
|
||||||
|
controller = controller
|
||||||
|
} )
|
||||||
|
self:processEvent( {
|
||||||
|
name = "update_state",
|
||||||
|
menu = self
|
||||||
|
} )
|
||||||
|
if not self:restoreState() then
|
||||||
|
self.Options:processEvent( {
|
||||||
|
name = "gain_focus",
|
||||||
|
controller = controller
|
||||||
|
} )
|
||||||
|
end
|
||||||
|
|
||||||
|
LUI.OverrideFunction_CallOriginalSecond( self, "close", function ( element )
|
||||||
|
element.GameSettingsBackground:close()
|
||||||
|
element.Options:close()
|
||||||
|
Engine.UnsubscribeAndFreeModel( Engine.GetModel( Engine.GetModelForController( controller ), "MPStatsMenu.buttonPrompts" ) )
|
||||||
|
end )
|
||||||
|
|
||||||
|
if PostLoadFunc then
|
||||||
|
PostLoadFunc( self, controller )
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
CoD.LobbyButtons.MP_STATS = {
|
||||||
|
stringRef = "STATS",
|
||||||
|
action = function ( self, element, controller, param, menu )
|
||||||
|
SetPerControllerTableProperty( controller, "disableGameSettingsOptions", true )
|
||||||
|
OpenPopup( menu, "MPStatsMenu", controller )
|
||||||
|
end,
|
||||||
|
customId = "btnMPStats"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
local IsGamescomDemo = function ()
|
||||||
|
return Dvar.ui_execdemo_gamescom:get()
|
||||||
|
end
|
||||||
|
|
||||||
|
local IsBetaDemo = function ()
|
||||||
|
return Dvar.ui_execdemo_beta:get()
|
||||||
|
end
|
||||||
|
|
||||||
|
local SetButtonState = function ( button, state )
|
||||||
|
if state == nil then
|
||||||
|
return
|
||||||
|
elseif state == CoD.LobbyButtons.DISABLED then
|
||||||
|
button.disabled = true
|
||||||
|
elseif state == CoD.LobbyButtons.HIDDEN then
|
||||||
|
button.hidden = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local AddButton = function ( controller, options, button, isLargeButton )
|
||||||
|
button.disabled = false
|
||||||
|
button.hidden = false
|
||||||
|
button.selected = false
|
||||||
|
button.warning = false
|
||||||
|
if button.defaultState ~= nil then
|
||||||
|
if button.defaultState == CoD.LobbyButtons.DISABLED then
|
||||||
|
button.disabled = true
|
||||||
|
elseif button.defaultState == CoD.LobbyButtons.HIDDEN then
|
||||||
|
button.hidden = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if button.disabledFunc ~= nil then
|
||||||
|
button.disabled = button.disabledFunc( controller )
|
||||||
|
end
|
||||||
|
if button.visibleFunc ~= nil then
|
||||||
|
button.hidden = not button.visibleFunc( controller )
|
||||||
|
end
|
||||||
|
if IsBetaDemo() then
|
||||||
|
SetButtonState( button, button.demo_beta )
|
||||||
|
elseif IsGamescomDemo() then
|
||||||
|
SetButtonState( button, button.demo_gamescom )
|
||||||
|
end
|
||||||
|
if button.hidden then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local lobbyNav = LobbyData.GetLobbyNav()
|
||||||
|
if button.selectedFunc ~= nil then
|
||||||
|
button.selected = button.selectedFunc( button.selectedParam )
|
||||||
|
elseif CoD.LobbyMenus.History[lobbyNav] ~= nil then
|
||||||
|
button.selected = CoD.LobbyMenus.History[lobbyNav] == button.customId
|
||||||
|
end
|
||||||
|
if button.newBreadcrumbFunc then
|
||||||
|
local f8_local1 = button.newBreadcrumbFunc
|
||||||
|
if type( f8_local1 ) == "string" then
|
||||||
|
f8_local1 = LUI.getTableFromPath( f8_local1 )
|
||||||
|
end
|
||||||
|
if f8_local1 then
|
||||||
|
button.isBreadcrumbNew = f8_local1( controller )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if button.warningFunc ~= nil then
|
||||||
|
button.warning = button.warningFunc( controller )
|
||||||
|
end
|
||||||
|
if button.starterPack == CoD.LobbyButtons.STARTERPACK_UPGRADE then
|
||||||
|
button.starterPackUpgrade = true
|
||||||
|
if IsStarterPack() then
|
||||||
|
button.disabled = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.insert( options, {
|
||||||
|
optionDisplay = button.stringRef,
|
||||||
|
action = button.action,
|
||||||
|
param = button.param,
|
||||||
|
customId = button.customId,
|
||||||
|
isLargeButton = isLargeButton,
|
||||||
|
isLastButtonInGroup = false,
|
||||||
|
disabled = button.disabled,
|
||||||
|
selected = button.selected,
|
||||||
|
isBreadcrumbNew = button.isBreadcrumbNew,
|
||||||
|
warning = button.warning,
|
||||||
|
requiredChunk = button.selectedParam,
|
||||||
|
starterPackUpgrade = button.starterPackUpgrade,
|
||||||
|
unloadMod = button.unloadMod
|
||||||
|
} )
|
||||||
|
end
|
||||||
|
|
||||||
|
local AddLargeButton = function ( controller, options, button )
|
||||||
|
AddButton( controller, options, button, true )
|
||||||
|
end
|
||||||
|
|
||||||
|
local AddSmallButton = function ( controller, options, button )
|
||||||
|
AddButton( controller, options, button, false )
|
||||||
|
end
|
||||||
|
|
||||||
|
local AddSpacer = function ( options )
|
||||||
|
if 0 < #options then
|
||||||
|
options[#options].isLastButtonInGroup = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
CoD.LobbyMenus.MPButtonsOnline = function ( f26_arg0, f26_arg1, f26_arg2 )
|
||||||
|
if f26_arg2 == 1 then
|
||||||
|
AddLargeButton( f26_arg0, f26_arg1, CoD.LobbyButtons.MP_FIND_MATCH )
|
||||||
|
AddSpacer( f26_arg1 )
|
||||||
|
end
|
||||||
|
AddLargeButton( f26_arg0, f26_arg1, CoD.LobbyButtons.MP_CAC_NO_WARNING )
|
||||||
|
AddLargeButton( f26_arg0, f26_arg1, CoD.LobbyButtons.MP_SPECIALISTS_NO_WARNING )
|
||||||
|
AddLargeButton( f26_arg0, f26_arg1, CoD.LobbyButtons.MP_SCORESTREAKS )
|
||||||
|
if (Dvar.ui_execdemo_beta:get() or IsStarterPack()) and IsStoreAvailable() then
|
||||||
|
if CoD.isPC then
|
||||||
|
AddLargeButton( f26_arg0, f26_arg1, CoD.LobbyButtons.STEAM_STORE )
|
||||||
|
else
|
||||||
|
AddLargeButton( f26_arg0, f26_arg1, CoD.LobbyButtons.STORE )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if Engine.DvarBool( nil, "inventory_test_button_visible" ) then
|
||||||
|
AddLargeButton( f26_arg0, f26_arg1, CoD.LobbyButtons.MP_INVENTORY_TEST )
|
||||||
|
end
|
||||||
|
AddSpacer( f26_arg1 )
|
||||||
|
if not DisableBlackMarket() then
|
||||||
|
AddSmallButton( f26_arg0, f26_arg1, CoD.LobbyButtons.BLACK_MARKET )
|
||||||
|
end
|
||||||
|
AddSpacer( f26_arg1 )
|
||||||
|
AddSmallButton( f26_arg0, f26_arg1, CoD.LobbyButtons.MP_STATS )
|
||||||
|
end
|
||||||
|
|
||||||
|
local targetButtons = {
|
||||||
|
[LobbyData.UITargets.UI_MAIN.id] = CoD.LobbyMenus.ModeSelect,
|
||||||
|
[LobbyData.UITargets.UI_MODESELECT.id] = CoD.LobbyMenus.ModeSelect,
|
||||||
|
[LobbyData.UITargets.UI_CPLOBBYLANGAME.id] = CoD.LobbyMenus.CPButtonsLAN,
|
||||||
|
[LobbyData.UITargets.UI_CPLOBBYLANCUSTOMGAME.id] = CoD.LobbyMenus.CPButtonsLANCUSTOM,
|
||||||
|
[LobbyData.UITargets.UI_CPLOBBYONLINE.id] = CoD.LobbyMenus.CPButtonsOnline,
|
||||||
|
[LobbyData.UITargets.UI_CPLOBBYONLINEPUBLICGAME.id] = CoD.LobbyMenus.CPButtonsPublicGame,
|
||||||
|
[LobbyData.UITargets.UI_CPLOBBYONLINECUSTOMGAME.id] = CoD.LobbyMenus.CPButtonsCustomGame,
|
||||||
|
[LobbyData.UITargets.UI_CP2LOBBYLANGAME.id] = CoD.LobbyMenus.CPZMButtonsLAN,
|
||||||
|
[LobbyData.UITargets.UI_CP2LOBBYLANCUSTOMGAME.id] = CoD.LobbyMenus.CPButtonsLANCUSTOM,
|
||||||
|
[LobbyData.UITargets.UI_CP2LOBBYONLINE.id] = CoD.LobbyMenus.CPZMButtonsOnline,
|
||||||
|
[LobbyData.UITargets.UI_CP2LOBBYONLINEPUBLICGAME.id] = CoD.LobbyMenus.CPZMButtonsPublicGame,
|
||||||
|
[LobbyData.UITargets.UI_CP2LOBBYONLINECUSTOMGAME.id] = CoD.LobbyMenus.CPButtonsCustomGame,
|
||||||
|
[LobbyData.UITargets.UI_DOALOBBYLANGAME.id] = CoD.LobbyMenus.DOAButtonsLAN,
|
||||||
|
[LobbyData.UITargets.UI_DOALOBBYONLINE.id] = CoD.LobbyMenus.DOAButtonsOnline,
|
||||||
|
[LobbyData.UITargets.UI_DOALOBBYONLINEPUBLICGAME.id] = CoD.LobbyMenus.DOAButtonsPublicGame,
|
||||||
|
[LobbyData.UITargets.UI_MPLOBBYLANGAME.id] = CoD.LobbyMenus.MPButtonsLAN,
|
||||||
|
[LobbyData.UITargets.UI_MPLOBBYMAIN.id] = CoD.LobbyMenus.MPButtonsMain,
|
||||||
|
[LobbyData.UITargets.UI_MPLOBBYONLINE.id] = CoD.LobbyMenus.MPButtonsOnline,
|
||||||
|
[LobbyData.UITargets.UI_MPLOBBYONLINEPUBLICGAME.id] = CoD.LobbyMenus.MPButtonsOnlinePublic,
|
||||||
|
[LobbyData.UITargets.UI_MPLOBBYONLINEMODGAME.id] = CoD.LobbyMenus.MPButtonsModGame,
|
||||||
|
[LobbyData.UITargets.UI_MPLOBBYONLINECUSTOMGAME.id] = CoD.LobbyMenus.MPButtonsCustomGame,
|
||||||
|
[LobbyData.UITargets.UI_MPLOBBYONLINEARENA.id] = CoD.LobbyMenus.MPButtonsArena,
|
||||||
|
[LobbyData.UITargets.UI_MPLOBBYONLINEARENAGAME.id] = CoD.LobbyMenus.MPButtonsArenaGame,
|
||||||
|
[LobbyData.UITargets.UI_FRLOBBYONLINEGAME.id] = CoD.LobbyMenus.FRButtonsOnlineGame,
|
||||||
|
[LobbyData.UITargets.UI_FRLOBBYLANGAME.id] = CoD.LobbyMenus.FRButtonsLANGame,
|
||||||
|
[LobbyData.UITargets.UI_ZMLOBBYLANGAME.id] = CoD.LobbyMenus.ZMButtonsLAN,
|
||||||
|
[LobbyData.UITargets.UI_ZMLOBBYONLINE.id] = CoD.LobbyMenus.ZMButtonsOnline,
|
||||||
|
[LobbyData.UITargets.UI_ZMLOBBYONLINEPUBLICGAME.id] = CoD.LobbyMenus.ZMButtonsPublicGame,
|
||||||
|
[LobbyData.UITargets.UI_ZMLOBBYONLINECUSTOMGAME.id] = CoD.LobbyMenus.ZMButtonsCustomGame,
|
||||||
|
[LobbyData.UITargets.UI_MPLOBBYONLINETHEATER.id] = CoD.LobbyMenus.ButtonsTheaterGame,
|
||||||
|
[LobbyData.UITargets.UI_ZMLOBBYONLINETHEATER.id] = CoD.LobbyMenus.ButtonsTheaterGame
|
||||||
|
}
|
||||||
|
CoD.LobbyMenus.AddButtonsForTarget = function ( controller, id )
|
||||||
|
local buttonFunc = targetButtons[id]
|
||||||
|
local model = nil
|
||||||
|
if Engine.IsLobbyActive( Enum.LobbyType.LOBBY_TYPE_GAME ) then
|
||||||
|
model = Engine.GetModel( DataSources.LobbyRoot.getModel( controller ), "gameClient.isHost" )
|
||||||
|
else
|
||||||
|
model = Engine.GetModel( DataSources.LobbyRoot.getModel( controller ), "privateClient.isHost" )
|
||||||
|
end
|
||||||
|
local isLeader = nil
|
||||||
|
if model ~= nil then
|
||||||
|
isLeader = Engine.GetModelValue( model )
|
||||||
|
else
|
||||||
|
isLeader = 1
|
||||||
|
end
|
||||||
|
local result = {}
|
||||||
|
buttonFunc( controller, result, isLeader )
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
101
src/client/component/dvars.cpp
Normal file
101
src/client/component/dvars.cpp
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
#include <std_include.hpp>
|
||||||
|
#include "loader/component_loader.hpp"
|
||||||
|
|
||||||
|
#include "game/game.hpp"
|
||||||
|
|
||||||
|
#include <utils/hook.hpp>
|
||||||
|
#include <utils/io.hpp>
|
||||||
|
#include <utils/string.hpp>
|
||||||
|
|
||||||
|
#include "scheduler.hpp"
|
||||||
|
|
||||||
|
namespace dvars
|
||||||
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
bool initial_config_read = false;
|
||||||
|
utils::hook::detour dvar_register_new_hook;
|
||||||
|
utils::hook::detour dvar_set_variant_hook;
|
||||||
|
|
||||||
|
utils::hook::detour set_config_dvar_hook;
|
||||||
|
utils::hook::detour for_each_name_match_hook;
|
||||||
|
utils::hook::detour get_debug_name_hook;
|
||||||
|
|
||||||
|
|
||||||
|
const std::string get_config_file_path()
|
||||||
|
{
|
||||||
|
return "players/user/config.cfg";
|
||||||
|
}
|
||||||
|
|
||||||
|
void write_archive_dvars()
|
||||||
|
{
|
||||||
|
std::string config_buffer;
|
||||||
|
|
||||||
|
for (int i = 0; i < *game::g_dvarCount; ++i)
|
||||||
|
{
|
||||||
|
const auto* dvar = reinterpret_cast<const game::dvar_t*>(&game::s_dvarPool[160 * i]);
|
||||||
|
|
||||||
|
if (!dvar->debugName || (game::dvarFlags_e::DVAR_SAVED & dvar->flags) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto name = dvar->debugName;
|
||||||
|
auto value = game::Dvar_DisplayableValue(dvar);
|
||||||
|
|
||||||
|
config_buffer.append(utils::string::va("set %s %s\n", name, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config_buffer.length() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
utils::io::write_file(get_config_file_path(), config_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dvar_set_variant_stub(game::dvar_t* dvar, game::DvarValue* value, unsigned int source)
|
||||||
|
{
|
||||||
|
dvar_set_variant_hook.invoke(dvar, value, source);
|
||||||
|
|
||||||
|
if (initial_config_read && (game::dvarFlags_e::DVAR_SAVED & dvar->flags) != 0 && dvar->debugName)
|
||||||
|
{
|
||||||
|
write_archive_dvars();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void read_archive_dvars()
|
||||||
|
{
|
||||||
|
const std::string path = get_config_file_path();
|
||||||
|
|
||||||
|
if (!utils::io::file_exists(path))
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::string filedata;
|
||||||
|
utils::io::read_file(path, &filedata);
|
||||||
|
|
||||||
|
game::Cbuf_ExecuteBuffer(0, game::ControllerIndex_t::CONTROLLER_INDEX_0, filedata.c_str());
|
||||||
|
initial_config_read = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
game::dvar_t* dvar_register_new_stub(game::dvarStrHash_t hash, const char* dvar_name, game::dvarType_t type, unsigned int flags,
|
||||||
|
game::DvarValue value, game::DvarLimits domain, const char* description)
|
||||||
|
{
|
||||||
|
auto dvar = dvar_register_new_hook.invoke<game::dvar_t*>(hash, dvar_name, type, flags, value, domain, description);
|
||||||
|
|
||||||
|
dvar->debugName = dvar_name; // TODO: gives access violation error
|
||||||
|
|
||||||
|
return dvar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class component final : public client_component
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void post_unpack() override
|
||||||
|
{
|
||||||
|
scheduler::once(read_archive_dvars, scheduler::pipeline::main);
|
||||||
|
|
||||||
|
//dvar_register_new_hook.create(0x1422C5330_g, dvar_register_new_stub);
|
||||||
|
dvar_set_variant_hook.create(0x1422C9A90_g, dvar_set_variant_stub);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_COMPONENT(dvars::component)
|
@ -10,13 +10,20 @@ namespace loot
|
|||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
game::dvar_t* dvar_cg_unlockall_loot;
|
||||||
|
|
||||||
utils::hook::detour loot_getitemquantity_hook;
|
utils::hook::detour loot_getitemquantity_hook;
|
||||||
utils::hook::detour liveinventory_getitemquantity_hook;
|
utils::hook::detour liveinventory_getitemquantity_hook;
|
||||||
utils::hook::detour liveinventory_areextraslotspurchased_hook;
|
utils::hook::detour liveinventory_areextraslotspurchased_hook;
|
||||||
|
|
||||||
int loot_getitemquantity_stub(const game::ControllerIndex_t /*controller_index*/, const game::eModes mode,
|
int loot_getitemquantity_stub(const game::ControllerIndex_t controller_index, const game::eModes mode,
|
||||||
const int /*item_id*/)
|
const int item_id)
|
||||||
{
|
{
|
||||||
|
if (!dvar_cg_unlockall_loot->current.enabled)
|
||||||
|
{
|
||||||
|
return loot_getitemquantity_hook.invoke<int>(controller_index, mode, item_id);
|
||||||
|
}
|
||||||
|
|
||||||
if (mode == game::eModes::MODE_ZOMBIES)
|
if (mode == game::eModes::MODE_ZOMBIES)
|
||||||
{
|
{
|
||||||
return 999;
|
return 999;
|
||||||
@ -28,8 +35,8 @@ namespace loot
|
|||||||
int liveinventory_getitemquantity_stub(const game::ControllerIndex_t controller_index, const int item_id)
|
int liveinventory_getitemquantity_stub(const game::ControllerIndex_t controller_index, const int item_id)
|
||||||
{
|
{
|
||||||
// Item id's for extra CaC slots, CWL camo's and paid specialist outfits
|
// Item id's for extra CaC slots, CWL camo's and paid specialist outfits
|
||||||
if (item_id == 99003 || item_id >= 99018 && item_id <= 99021 || item_id == 99025 || item_id >= 90047 &&
|
if (dvar_cg_unlockall_loot->current.enabled && (item_id == 99003 || item_id >= 99018 && item_id <= 99021 || item_id == 99025||
|
||||||
item_id <= 90064)
|
item_id >= 90047 && item_id <= 90064))
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -37,15 +44,14 @@ namespace loot
|
|||||||
return liveinventory_getitemquantity_hook.invoke<int>(controller_index, item_id);
|
return liveinventory_getitemquantity_hook.invoke<int>(controller_index, item_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool liveinventory_areextraslotspurchased_stub(const game::ControllerIndex_t /*controller_index*/)
|
bool liveinventory_areextraslotspurchased_stub(const game::ControllerIndex_t controller_index)
|
||||||
{
|
{
|
||||||
return true;
|
if (dvar_cg_unlockall_loot->current.enabled)
|
||||||
}
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void set_dvars_on_startup()
|
return liveinventory_areextraslotspurchased_hook.invoke<bool>(controller_index);
|
||||||
{
|
|
||||||
game::Dvar_SetFromStringByName("ui_enableAllHeroes", "1", true);
|
|
||||||
game::Dvar_SetFromStringByName("ui_allLootUnlocked", "1", true);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -53,7 +59,9 @@ namespace loot
|
|||||||
{
|
{
|
||||||
void post_unpack() override
|
void post_unpack() override
|
||||||
{
|
{
|
||||||
scheduler::once(set_dvars_on_startup, scheduler::pipeline::main);
|
dvar_cg_unlockall_loot = game::Dvar_RegisterBool(game::Dvar_GenerateHash("cg_unlockall_loot"), "cg_unlockall_loot", false, (game::dvarFlags_e)0x40, "Unlocks blackmarket loot");
|
||||||
|
dvar_cg_unlockall_loot->debugName = "cg_unlockall_loot";
|
||||||
|
|
||||||
loot_getitemquantity_hook.create(0x141E82C90_g, loot_getitemquantity_stub);
|
loot_getitemquantity_hook.create(0x141E82C90_g, loot_getitemquantity_stub);
|
||||||
liveinventory_getitemquantity_hook.create(0x141E090C0_g, liveinventory_getitemquantity_stub);
|
liveinventory_getitemquantity_hook.create(0x141E090C0_g, liveinventory_getitemquantity_stub);
|
||||||
liveinventory_areextraslotspurchased_hook.create(0x141E089E0_g, liveinventory_areextraslotspurchased_stub);
|
liveinventory_areextraslotspurchased_hook.create(0x141E089E0_g, liveinventory_areextraslotspurchased_stub);
|
||||||
|
@ -222,7 +222,14 @@ namespace ui_scripting
|
|||||||
ui_cod_init_hook.invoke(frontend);
|
ui_cod_init_hook.invoke(frontend);
|
||||||
|
|
||||||
if (game::Com_IsRunningUILevel())
|
if (game::Com_IsRunningUILevel())
|
||||||
|
{
|
||||||
|
// Fetch the names of the local files so file overrides are already handled
|
||||||
|
globals = {};
|
||||||
|
load_local_script_files(game::get_host_library().get_folder().append("/data/ui_scripts/").string());
|
||||||
|
load_local_script_files("boiii/ui_scripts/");
|
||||||
|
load_local_script_files("data/ui_scripts/");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
const auto _0 = utils::finally(&try_start);
|
const auto _0 = utils::finally(&try_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +666,6 @@ namespace game
|
|||||||
vec4_t vector;
|
vec4_t vector;
|
||||||
const char* string;
|
const char* string;
|
||||||
byte color[4];
|
byte color[4];
|
||||||
const dvar_t* indirect[3];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct $7034703ED3857507327AE195CCA24A71
|
struct $7034703ED3857507327AE195CCA24A71
|
||||||
|
@ -43,6 +43,7 @@ namespace game
|
|||||||
0x1420EDC20
|
0x1420EDC20
|
||||||
};
|
};
|
||||||
WEAK symbol<void(char* text, int maxSize)> Con_GetTextCopy{0x14133A7D0, 0x140182C40};
|
WEAK symbol<void(char* text, int maxSize)> Con_GetTextCopy{0x14133A7D0, 0x140182C40};
|
||||||
|
WEAK symbol<void(uint32_t localClientNum, ControllerIndex_t controllerIndex, const char* buffer)> Cbuf_ExecuteBuffer{0x14133BE10};
|
||||||
|
|
||||||
// DB
|
// DB
|
||||||
WEAK symbol<void(XZoneInfo* zoneInfo, uint32_t zoneCount, bool sync, bool suppressSync)> DB_LoadXAssets{
|
WEAK symbol<void(XZoneInfo* zoneInfo, uint32_t zoneCount, bool sync, bool suppressSync)> DB_LoadXAssets{
|
||||||
@ -80,9 +81,17 @@ namespace game
|
|||||||
WEAK symbol<dvar_t*(unsigned int hash)> Dvar_FindMalleableVar{0x1422BD6A0};
|
WEAK symbol<dvar_t*(unsigned int hash)> Dvar_FindMalleableVar{0x1422BD6A0};
|
||||||
WEAK symbol<const char*(const dvar_t* dvar)> Dvar_GetDebugName{0x1422BDCB0};
|
WEAK symbol<const char*(const dvar_t* dvar)> Dvar_GetDebugName{0x1422BDCB0};
|
||||||
WEAK symbol<const char*(const dvar_t* dvar)> Dvar_GetString{0x1422BFFF0, 0x140575E30};
|
WEAK symbol<const char*(const dvar_t* dvar)> Dvar_GetString{0x1422BFFF0, 0x140575E30};
|
||||||
|
WEAK symbol<const char*(const dvar_t* dvar)> Dvar_DisplayableValue{0x1422BCAE0};
|
||||||
|
WEAK symbol<bool(const dvar_t* dvar)> Dvar_GetBool{ 0x1422BD930 };
|
||||||
|
WEAK symbol<dvar_t*(dvarStrHash_t hash, const char* dvarName, bool value, dvarFlags_e flags, const char* description)> Dvar_RegisterBool{
|
||||||
|
0x1422D1360
|
||||||
|
};
|
||||||
|
WEAK symbol<void (void (*callback)(const dvar_t*, void*), void* userData)> Dvar_ForEach{ 0x1422BD760 };
|
||||||
WEAK symbol<void(const char* dvarName, const char* string, bool createIfMissing)> Dvar_SetFromStringByName{
|
WEAK symbol<void(const char* dvarName, const char* string, bool createIfMissing)> Dvar_SetFromStringByName{
|
||||||
0x1422C7F60
|
0x1422C7F60
|
||||||
};
|
};
|
||||||
|
WEAK symbol<char> s_dvarPool{ 0x157AC8220 };
|
||||||
|
WEAK symbol<int> g_dvarCount{ 0x157AC81CC };
|
||||||
|
|
||||||
// Scr
|
// Scr
|
||||||
WEAK symbol<void(scriptInstance_t inst, int value)> Scr_AddInt{0x0, 0x14016F160};
|
WEAK symbol<void(scriptInstance_t inst, int value)> Scr_AddInt{0x0, 0x14016F160};
|
||||||
|
Loading…
Reference in New Issue
Block a user