iw6-lui/lui/gamex.dec.lua
2024-09-12 17:25:45 +02:00

289 lines
8.0 KiB
Lua

if not GameX then
GameX = {}
end
GameX.GetPlayerOpposingTeam = function ( f1_arg0 )
local f1_local0 = f1_arg0
if not f1_local0 then
f1_local0 = Game.GetPlayerTeam()
if GameX.IsSpectatingNotOnTeam( f1_local0 ) then
f1_local0 = spectatorFakeTeam
end
end
local f1_local1 = otherTeamLookup[f1_local0]
if not f1_local1 then
f1_local1 = 0
end
return f1_local1
end
GameX.gameModeIsFFA = function ( f2_arg0 )
local f2_local0 = f2_arg0 or Engine.GetDvarString( "ui_gametype" )
if f2_local0 == "dm" or f2_local0 == "sotf_ffa" or f2_local0 == "gun" or f2_local0 == "mugger" or f2_local0 == "adrn" or f2_local0 == "assn" or f2_local0 == "fo" or f2_local0 == "sna" then
return true
elseif f2_local0 == "cranked" then
return Engine.GetDvarInt( "scr_cranked_teambased" ) == 0
else
return false
end
end
GameX.GetTeamName = function ( f3_arg0 )
local f3_local0 = {
"free",
"axis",
"allies"
}
return f3_local0[f3_arg0 + 1]
end
GameX.GetFactionName = function ( f4_arg0 )
local f4_local0 = {
"free",
"federation",
"ghosts"
}
return f4_local0[f4_arg0 + 1]
end
GameX.IsSpectatingNotOnTeam = function ( f5_arg0 )
local f5_local0
if not (Game.IsSpectating() or Game.GetOmnvar( "ui_session_state" ) == "spectator") or (f5_arg0 or Game.GetPlayerTeam()) ~= Teams.spectator then
f5_local0 = false
else
f5_local0 = true
end
return f5_local0
end
GameX.IsHardcoreMode = function ()
return Engine.GetDvarBool( "g_hardcore" )
end
GameX.IsRankedMatch = function ()
return Engine.GetDvarBool( "onlinegame" ) and not Engine.GetDvarBool( "xblive_privatematch" )
end
GameX.IsOnlineMatch = function ()
local f8_local0 = Engine.GetDvarBool( "onlinegame" )
if not f8_local0 then
f8_local0 = Engine.GetDvarBool( "xblive_privatematch" )
end
return f8_local0
end
GameX.GetGameMode = function ()
return Engine.GetDvarString( "ui_gametype" )
end
GameX.GetNumPlayerSlotsForFinalScoreboard = function ( f10_arg0, f10_arg1 )
local f10_local0 = GameX.IsRankedMatch() and Engine.GetDvarInt( "party_maxplayers" ) or 0
local f10_local1 = Game.GetNumPlayersOnTeam( f10_arg0 )
if GameX.gameModeIsFFA( f10_arg1 ) then
assert( f10_arg0 == Teams.free )
return math.max( 1, math.max( f10_local1, f10_local0 ) )
elseif f10_arg1 == "infect" then
if f10_arg0 == Teams.allies then
return math.max( 0, f10_local1 )
else
local f10_local2 = Game.GetNumPlayersOnTeam( GameX.GetPlayerOpposingTeam( f10_arg0 ) )
local f10_local3 = f10_local0 - f10_local2
if f10_local1 + f10_local2 == 0 then
return 1
else
return math.max( 0, math.max( f10_local1, f10_local3 ) )
end
end
elseif f10_arg1 == "horde" then
if f10_arg0 == Teams.allies then
return math.max( 4, math.max( f10_local1, f10_local0 ) )
else
return math.max( 0, f10_local1 )
end
end
local f10_local2 = assert
local f10_local3
if f10_arg0 ~= Teams.axis and f10_arg0 ~= Teams.allies then
f10_local3 = false
else
f10_local3 = true
end
f10_local2( f10_local3 )
return math.max( 1, math.max( f10_local1, f10_local0 / 2 ) )
end
GameX.GetPlayerScoreInfoAtRankForGameMode = function ( f11_arg0, f11_arg1, f11_arg2, f11_arg3 )
local f11_local0 = Game.GetPlayerScoreInfoAtRank( f11_arg0, f11_arg1 )
if not f11_local0 then
return nil
end
local f11_local1 = 99
local f11_local2 = 99
if f11_arg2 == "horde" then
f11_local1 = 999
f11_local2 = 999
end
f11_local0.score = math.min( 9999, f11_local0.score )
f11_local0.kills = math.min( f11_local1, f11_local0.kills )
f11_local0.deaths = math.min( 99, f11_local0.deaths )
f11_local0.assists = math.min( f11_local2, f11_local0.assists )
f11_local0.prestige = f11_local0.prestige or 0
if not (f11_arg2 ~= "dm" and (f11_arg2 ~= "cranked" or not GameX.gameModeIsFFA( f11_arg2 ))) or f11_arg2 == "sotf_ffa" then
local f11_local3 = Game.GetOmnvar( "ui_game_type_kill_value" )
if not f11_local3 then
f11_local0.extrascore0 = 0
else
f11_local0.extrascore0 = math.min( 9999, f11_local0.score * f11_local3 )
end
elseif f11_arg2 == "horde" then
f11_local0.extrascore0 = math.min( 999, f11_local0.extrascore0 )
elseif f11_arg2 == "infect" then
f11_local0.time = CoD.FormatInfectedTime( f11_local0.extrascore0, f11_arg3 )
else
f11_local0.extrascore0 = math.min( 99, f11_local0.extrascore0 )
end
return f11_local0
end
GameX.GetScreenDims = function ()
local f12_local0 = {}
local f12_local1 = Engine.GetLuiRoot()
f12_local0 = f12_local1:getCurrentGlobalRect()
return f12_local0[3], f12_local0[4]
end
GameX.GetScreenWidth = function ()
local f13_local0 = {}
local f13_local1 = Engine.GetLuiRoot()
f13_local0 = f13_local1:getCurrentGlobalRect()
return f13_local0[3]
end
GameX.GetScreenHeight = function ()
local f14_local0 = {}
local f14_local1 = Engine.GetLuiRoot()
f14_local0 = f14_local1:getCurrentGlobalRect()
return f14_local0[4]
end
GameX.GetSafeZoneSize = function ( f15_arg0, f15_arg1 )
local f15_local0 = f15_arg0 or SliderBounds.HorzMargin.Min
local f15_local1 = f15_arg1 or SliderBounds.VertMargin.Min
local f15_local2, f15_local3 = GameX.GetScreenDims()
local f15_local4 = f15_local2 * (1 - f15_local0) / 2
local f15_local5 = f15_local3 * (1 - f15_local1) / 2
local f15_local6 = Engine.SplitscreenPlayerCount()
assert( f15_local6 <= MaxLocalClients )
local f15_local7 = assert
local f15_local8
if f15_local6 ~= 1 and f15_local6 ~= 2 then
f15_local8 = false
else
f15_local8 = true
end
f15_local7( f15_local8 )
if f15_local6 == 2 then
f15_local5 = f15_local5 * 2
f15_local7 = Engine.GetCurrentLocalClient()
assert( f15_local7 and f15_local7 < MaxLocalClients )
if f15_local7 == 0 then
return f15_local4, f15_local5, -f15_local4, 0
else
return f15_local4, 0, -f15_local4, -f15_local5
end
else
return f15_local4, f15_local5, -f15_local4, -f15_local5
end
end
GameX.GetAdjustedSafeZoneSize = function ()
return GameX.GetSafeZoneSize( Engine.GetDvarFloat( "safeArea_adjusted_horizontal" ), Engine.GetDvarFloat( "safeArea_adjusted_vertical" ) )
end
GameX.IsSplitscreen = function ()
local f17_local0 = Engine.SplitscreenPlayerCount()
local f17_local1 = assert
local f17_local2
if f17_local0 and f17_local0 > MaxLocalClients then
f17_local2 = false
else
f17_local2 = true
end
f17_local1( f17_local2 )
return f17_local0 > 1
end
OptionState = {
Locked = false
}
GameX.IsOptionStateLocked = function ()
return OptionState.Locked
end
GameX.SetOptionState = function ( f19_arg0 )
OptionState.Locked = f19_arg0
end
GameX.GetTeamNameOverride = function ( f20_arg0 )
if not MLG.IsMLGSpectator() then
return nil
elseif MatchRules.IsUsingMatchRulesData() then
local f20_local0 = nil
if f20_arg0 == Teams.allies then
f20_local0 = "ghostsTeamName"
elseif f20_arg0 == Teams.axis then
f20_local0 = "fedTeamName"
end
local f20_local1 = MatchRules.GetData( "commonOption", f20_local0 )
if f20_local1 and f20_local1 ~= "" then
return f20_local1
end
end
return nil
end
GameX.GetLocalizedTeamName = function ( f21_arg0 )
if f21_arg0 ~= Teams.allies and f21_arg0 ~= Teams.axis then
return nil
else
local f21_local0 = GameX.GetTeamNameOverride( f21_arg0 )
if f21_local0 and f21_local0 ~= "" then
return f21_local0
elseif f21_arg0 == Teams.allies then
return Engine.Localize( "LUA_MENU_ALLIES_CAPS" )
elseif f21_arg0 == Teams.axis then
return Engine.Localize( "LUA_MENU_AXIS_CAPS" )
else
end
end
end
GameX.GetLocalizedTeamNameMixedCase = function ( f22_arg0 )
if f22_arg0 ~= Teams.allies and f22_arg0 ~= Teams.axis then
return nil
else
local f22_local0 = GameX.GetTeamNameOverride( f22_arg0 )
if f22_local0 and f22_local0 ~= "" then
return f22_local0
elseif f22_arg0 == Teams.allies then
return Engine.Localize( "MP_GHOSTS_NAME" )
elseif f22_arg0 == Teams.axis then
return Engine.Localize( "MP_FEDERATION_NAME" )
else
end
end
end
GameX.UsesFakeLoadout = function ()
local f23_local0 = GameX.GetGameMode()
local f23_local1
if f23_local0 ~= "sotf" and f23_local0 ~= "sotf_ffa" and f23_local0 ~= "infect" and f23_local0 ~= "gun" and f23_local0 ~= "horde" then
f23_local1 = false
else
f23_local1 = true
end
return f23_local1
end