427 lines
15 KiB
Lua
427 lines
15 KiB
Lua
Cac = {
|
|
Settings = {
|
|
DataLoc = {
|
|
squadMembers = {
|
|
maxClassSlots = 10
|
|
},
|
|
privateMatchSquadMembers = {
|
|
maxClassSlots = 6
|
|
},
|
|
coopSquadMembers = {
|
|
maxClassSlots = 1
|
|
},
|
|
loadouts = {
|
|
maxClassSlots = 10,
|
|
baseClassSlots = 6
|
|
},
|
|
defaultClassesTeam0 = {
|
|
maxClassSlots = 6,
|
|
teamName = "allies"
|
|
},
|
|
defaultClassesTeam1 = {
|
|
maxClassSlots = 6,
|
|
baseClassSlots = 6,
|
|
teamName = "axis",
|
|
infectedString = Engine.Localize( "LUA_MENU_INFECT_CAPS" ),
|
|
string = Engine.Localize( "@LUA_MENU_AXIS_CAPS" )
|
|
},
|
|
defaultClassesTeam2 = {
|
|
maxClassSlots = 6,
|
|
baseClassSlots = 6,
|
|
teamName = "allies",
|
|
infectedString = Engine.Localize( "LUA_MENU_MP_SURVIVORS_CAPS" ),
|
|
string = Engine.Localize( "@LUA_MENU_ALLIES_CAPS" )
|
|
},
|
|
defaultClassesTeam3 = {
|
|
teamName = "spectator"
|
|
}
|
|
},
|
|
minUsableSlots = 5
|
|
},
|
|
MemberCost = {
|
|
0,
|
|
3,
|
|
3,
|
|
3,
|
|
3,
|
|
3,
|
|
200,
|
|
300,
|
|
400,
|
|
500
|
|
}
|
|
}
|
|
if MatchRules then
|
|
MatchRules.AllowCustomClasses = function ( f1_arg0 )
|
|
if not MatchRules.IsUsingMatchRulesData() then
|
|
return false
|
|
else
|
|
local f1_local0
|
|
if f1_arg0 then
|
|
f1_local0 = Cac.IsDefaultClass( f1_arg0 )
|
|
if not f1_local0 then
|
|
|
|
elseif not f1_local0 then
|
|
return MatchRules.GetData( "commonOption", "allowCustomClasses" )
|
|
else
|
|
|
|
end
|
|
end
|
|
end
|
|
f1_local0 = false
|
|
end
|
|
|
|
end
|
|
Cac.GetCacConfig = function ( f2_arg0, f2_arg1, f2_arg2, ... )
|
|
local f2_local0 = {
|
|
...
|
|
}
|
|
for f2_local1 = 1, #f2_local0, 1 do
|
|
if type( f2_local0[f2_local1] ) == "string" and Cac.IsDefaultClass( f2_local0[f2_local1] ) then
|
|
local f2_local4 = Cac.Settings.DataLoc[f2_local0[f2_local1]].teamName
|
|
local f2_local5 = f2_local0[f2_local1 + 1]
|
|
table.remove( f2_local0, 1 )
|
|
table.remove( f2_local0, 1 )
|
|
return MatchRules.GetData( "defaultClasses", f2_local4, f2_local5, "class", unpack( f2_local0 ) )
|
|
end
|
|
end
|
|
local f2_local1 = CoD.GetStatsGroupForSquadLocation( f2_arg1 )
|
|
if f2_local0[1] == "loadouts" and type( f2_local0[2] ) == "number" then
|
|
local f2_local2 = f2_local0[1]
|
|
local f2_local3 = f2_local0[2]
|
|
if Cac.Settings.DataLoc[f2_local2].baseClassSlots <= f2_local3 then
|
|
table.remove( f2_local0, 1 )
|
|
table.remove( f2_local0, 1 )
|
|
return Engine.GetPlayerDataExtendedEx( f2_arg0, f2_local1, f2_arg1, f2_arg2, f2_local2, f2_local3 - Cac.Settings.DataLoc[f2_local2].baseClassSlots, unpack( f2_local0 ) )
|
|
end
|
|
end
|
|
return Engine.GetPlayerDataEx( f2_arg0, f2_local1, f2_arg1, f2_arg2, ... )
|
|
end
|
|
|
|
Cac.SetCacConfig = function ( f3_arg0, f3_arg1, f3_arg2, ... )
|
|
local f3_local0 = {
|
|
...
|
|
}
|
|
for f3_local1 = 1, #f3_local0, 1 do
|
|
if type( f3_local0[f3_local1] ) == "string" and Cac.IsDefaultClass( f3_local0[f3_local1] ) then
|
|
local f3_local4 = Cac.Settings.DataLoc[f3_local0[f3_local1]].teamName
|
|
local f3_local5 = f3_local0[f3_local1 + 1]
|
|
table.remove( f3_local0, 1 )
|
|
table.remove( f3_local0, 1 )
|
|
return MatchRules.SetData( "defaultClasses", f3_local4, f3_local5, "class", unpack( f3_local0 ) )
|
|
end
|
|
end
|
|
local f3_local1 = CoD.GetStatsGroupForSquadLocation( f3_arg1 )
|
|
if f3_local0[1] == "loadouts" and type( f3_local0[2] ) == "number" then
|
|
local f3_local2 = f3_local0[1]
|
|
local f3_local3 = f3_local0[2]
|
|
if Cac.Settings.DataLoc[f3_local2].baseClassSlots <= f3_local3 then
|
|
table.remove( f3_local0, 1 )
|
|
table.remove( f3_local0, 1 )
|
|
return Engine.SetPlayerDataExtendedEx( f3_arg0, f3_local1, f3_arg1, f3_arg2, f3_local2, f3_local3 - Cac.Settings.DataLoc[f3_local2].baseClassSlots, unpack( f3_local0 ) )
|
|
end
|
|
end
|
|
return Engine.SetPlayerDataEx( f3_arg0, f3_local1, f3_arg1, f3_arg2, ... )
|
|
end
|
|
|
|
Cac.GetNumCustomSlots = function ( f4_arg0, f4_arg1 )
|
|
if not f4_arg1 then
|
|
f4_arg1 = Cac.GetCustomClassLoc()
|
|
end
|
|
if Cac.IsDefaultClass( f4_arg1 ) or IsOnlineMatch() and (Engine.HasExtendedLoadouts( f4_arg0 ) or not IsPrivateMatch()) and Engine.GetDvarInt( "extendedLoadoutsEnable" ) == 1 then
|
|
return Cac.Settings.DataLoc[f4_arg1].maxClassSlots
|
|
else
|
|
return Cac.Settings.DataLoc[f4_arg1].baseClassSlots
|
|
end
|
|
end
|
|
|
|
Cac.IsClassInUse = function ( f5_arg0, f5_arg1, f5_arg2, f5_arg3, f5_arg4 )
|
|
local f5_local0 = nil
|
|
local f5_local1 = Cac.IsDefaultClass( f5_arg3 )
|
|
if f5_arg1 == "privateMatchSquadMembers" and not f5_local1 and f5_arg4 < Cac.Settings.DataLoc[f5_arg3].baseClassSlots then
|
|
f5_local0 = true
|
|
else
|
|
f5_local0 = Cac.GetCacConfig( f5_arg0, f5_arg1, f5_arg2, f5_arg3, f5_arg4, "inUse" )
|
|
if not f5_local1 and Engine.InFrontend() and f5_arg4 <= 2 and not f5_local0 then
|
|
Cac.SetClassInUse( f5_arg0, f5_arg1, f5_arg2, f5_arg3, f5_arg4, true )
|
|
end
|
|
end
|
|
return f5_local0
|
|
end
|
|
|
|
Cac.SetClassInUse = function ( f6_arg0, f6_arg1, f6_arg2, f6_arg3, f6_arg4, f6_arg5 )
|
|
if f6_arg5 == nil then
|
|
f6_arg5 = true
|
|
end
|
|
return Cac.SetCacConfig( f6_arg0, f6_arg1, f6_arg2, f6_arg3, f6_arg4, "inUse", f6_arg5 )
|
|
end
|
|
|
|
Cac.IsSquadMemberInUse = function ( f7_arg0, f7_arg1, f7_arg2 )
|
|
local f7_local0 = nil
|
|
if f7_arg1 == "privateMatchSquadMembers" then
|
|
f7_local0 = true
|
|
else
|
|
f7_local0 = Cac.GetCacConfig( f7_arg0, f7_arg1, f7_arg2, "inUse" )
|
|
end
|
|
return f7_local0
|
|
end
|
|
|
|
Cac.SetSquadMemberInUse = function ( f8_arg0, f8_arg1, f8_arg2 )
|
|
return Cac.SetCacConfig( f8_arg0, f8_arg1, f8_arg2, "inUse", true )
|
|
end
|
|
|
|
Cac.HasCustomClasses = function ( f9_arg0, f9_arg1, f9_arg2, f9_arg3 )
|
|
local f9_local0 = false
|
|
for f9_local1 = 0, Cac.GetNumCustomSlots( f9_arg0, f9_arg3 ) - 1, 1 do
|
|
if Cac.IsClassInUse( f9_arg0, f9_arg1, f9_arg2, f9_arg3, f9_local1 ) then
|
|
f9_local0 = true
|
|
break
|
|
end
|
|
end
|
|
return f9_local0
|
|
end
|
|
|
|
Cac.GetFirstCustomClass = function ( f10_arg0, f10_arg1, f10_arg2, f10_arg3 )
|
|
for f10_local0 = 0, Cac.GetNumCustomSlots( f10_arg0, f10_arg3 ) - 1, 1 do
|
|
if Cac.IsClassInUse( f10_arg0, f10_arg1, f10_arg2, f10_arg3, f10_local0 ) then
|
|
return f10_local0
|
|
end
|
|
end
|
|
assert( Cac.HasCustomClasses( f10_arg0, f10_arg1, f10_arg2, f10_arg3 ) )
|
|
return 0
|
|
end
|
|
|
|
Cac.IsCaCSlotRestricted = function ( f11_arg0, f11_arg1, f11_arg2, f11_arg3, f11_arg4 )
|
|
local f11_local0 = false
|
|
if MatchRules.AllowCustomClasses( f11_arg3 ) then
|
|
if not f11_arg3 then
|
|
f11_arg3 = Cac.GetCustomClassLoc()
|
|
end
|
|
if not Engine.InFrontend() and f11_arg3 == "loadouts" then
|
|
local f11_local1 = CoD.GetStatsGroupForGameMode()
|
|
if MatchRules.CustomClassIsRestricted( f11_arg0, CoD.GetStatsGroupForGameMode(), f11_arg1, f11_arg2, f11_arg3, f11_arg4 ) then
|
|
f11_local0 = true
|
|
end
|
|
end
|
|
end
|
|
return f11_local0
|
|
end
|
|
|
|
Cac.IsCaCSlotLocked = function ( f12_arg0, f12_arg1, f12_arg2, f12_arg3, f12_arg4 )
|
|
if not Cac.IsDefaultClass( f12_arg3 ) then
|
|
return not Cac.IsClassInUse( f12_arg0, f12_arg1, f12_arg2, f12_arg3, f12_arg4 )
|
|
else
|
|
|
|
end
|
|
end
|
|
|
|
Cac.GetSquadLoc = function ()
|
|
local f13_local0
|
|
if not Engine.GetDvarBool( "onlinegame" ) or Engine.GetDvarBool( "xblive_privatematch" ) then
|
|
f13_local0 = Engine.GetDvarBool( "force_ranking" )
|
|
else
|
|
f13_local0 = true
|
|
end
|
|
if Engine.IsAliensMode() then
|
|
return "coopSquadMembers"
|
|
elseif f13_local0 then
|
|
return "squadMembers"
|
|
else
|
|
return "privateMatchSquadMembers"
|
|
end
|
|
end
|
|
|
|
Cac.GetEditSquadMember = function ()
|
|
return Engine.GetDvarInt( "ui_editSquadMemberIndex" ) or 0
|
|
end
|
|
|
|
Cac.SetEditSquadMember = function ( f15_arg0 )
|
|
Engine.SetDvarInt( "ui_editSquadMemberIndex", f15_arg0 )
|
|
end
|
|
|
|
Cac.GetActiveSquadMember = function ( f16_arg0, f16_arg1 )
|
|
local f16_local0 = f16_arg1 or CoD.GetStatsGroupForGameMode()
|
|
if f16_local0 ~= CoD.StatsGroup.Ranked or not "activeSquadMember" then
|
|
local f16_local1 = "privateMatchActiveSquadMember"
|
|
end
|
|
if Engine.IsAliensMode() then
|
|
local f16_local1 = "coopActiveSquadMember"
|
|
end
|
|
return Engine.GetPlayerDataEx( f16_arg0, f16_local0, f16_local1 )
|
|
end
|
|
|
|
Cac.SetActiveSquadMember = function ( f17_arg0, f17_arg1 )
|
|
local f17_local0 = CoD.GetStatsGroupForGameMode()
|
|
local f17_local1
|
|
if f17_local0 == CoD.StatsGroup.Ranked then
|
|
f17_local1 = "activeSquadMember"
|
|
if not f17_local1 then
|
|
|
|
else
|
|
Engine.SetPlayerDataEx( f17_arg0, f17_local0, f17_local1, f17_arg1 )
|
|
if f17_local0 == CoD.StatsGroup.Ranked then
|
|
syncXP( f17_arg0, f17_arg1 )
|
|
end
|
|
Cac.SyncPrivateDataFromPlayercard( f17_arg0 )
|
|
end
|
|
end
|
|
f17_local1 = "privateMatchActiveSquadMember"
|
|
end
|
|
|
|
Cac.SyncPrivateDataFromPlayercard = function ( f18_arg0 )
|
|
local f18_local0 = Engine.GetPlayerDataEx( f18_arg0, CoD.StatsGroup.Ranked, "activeSquadMember" )
|
|
local f18_local1 = Engine.GetPlayerDataEx( f18_arg0, CoD.StatsGroup.Ranked, "squadMembers", f18_local0, "patch" )
|
|
local f18_local2 = Engine.GetPlayerDataEx( f18_arg0, CoD.StatsGroup.Ranked, "squadMembers", f18_local0, "patchbacking" )
|
|
local f18_local3 = Engine.GetPlayerDataEx( f18_arg0, CoD.StatsGroup.Ranked, "squadMembers", f18_local0, "background" )
|
|
for f18_local4 = 0, Cac.Settings.DataLoc.privateMatchSquadMembers.maxClassSlots - 1, 1 do
|
|
Engine.SetPlayerDataEx( f18_arg0, CoD.StatsGroup.Private, "privateMatchSquadMembers", f18_local4, "patch", f18_local1 )
|
|
Engine.SetPlayerDataEx( f18_arg0, CoD.StatsGroup.Private, "privateMatchSquadMembers", f18_local4, "patchbacking", f18_local2 )
|
|
Engine.SetPlayerDataEx( f18_arg0, CoD.StatsGroup.Private, "privateMatchSquadMembers", f18_local4, "background", f18_local3 )
|
|
end
|
|
end
|
|
|
|
Cac.GetCustomClassLoc = function ( f19_arg0 )
|
|
local f19_local0 = "loadouts"
|
|
if f19_arg0 ~= nil then
|
|
f19_local0 = f19_arg0
|
|
elseif not MatchRules.AllowCustomClasses( f19_arg0 ) then
|
|
if not Engine.InFrontend() then
|
|
f19_local0 = "defaultClassesTeam1"
|
|
else
|
|
f19_local0 = "defaultClassesTeam1"
|
|
end
|
|
end
|
|
return f19_local0
|
|
end
|
|
|
|
Cac.GetLoadoutName = function ( f20_arg0, f20_arg1, f20_arg2, f20_arg3, f20_arg4 )
|
|
local f20_local0 = Cac.GetCacConfig( f20_arg0, f20_arg1, f20_arg2, f20_arg3, f20_arg4, "name" )
|
|
if f20_local0 == "" then
|
|
f20_local0 = Engine.Localize( "@MP_LOADOUT_DEFAULT_NAME", f20_arg4 + 1 )
|
|
end
|
|
return f20_local0
|
|
end
|
|
|
|
Cac.MaxSquadMemberCount = function ( f21_arg0 )
|
|
return Cac.Settings.DataLoc[f21_arg0].maxClassSlots
|
|
end
|
|
|
|
Cac.ActiveSquadMemberCount = function ( f22_arg0, f22_arg1 )
|
|
local f22_local0 = 0
|
|
for f22_local1 = 0, Cac.MaxSquadMemberCount( f22_arg1 ) - 1, 1 do
|
|
if Cac.IsSquadMemberInUse( f22_arg0, f22_arg1, f22_local1 ) then
|
|
f22_local0 = f22_local0 + 1
|
|
end
|
|
end
|
|
return f22_local0
|
|
end
|
|
|
|
Cac.AddNewSquadMember = function ( f23_arg0, f23_arg1 )
|
|
local f23_local0 = Cac.ActiveSquadMemberCount( f23_arg0, f23_arg1 )
|
|
if f23_local0 + 1 <= Cac.MaxSquadMemberCount( f23_arg1 ) then
|
|
Cac.SetSquadMemberInUse( f23_arg0, f23_arg1, f23_local0 )
|
|
return f23_local0
|
|
else
|
|
DebugPrint( "WARNING: Attempting to add squad member when we are already at max. Ignoring..." )
|
|
end
|
|
end
|
|
|
|
Cac.UnlockSquadMember = function ( f24_arg0, f24_arg1, f24_arg2 )
|
|
if f24_arg2 < Cac.MaxSquadMemberCount( f24_arg1 ) then
|
|
Cac.SetSquadMemberInUse( f24_arg0, f24_arg1, f24_arg2 )
|
|
else
|
|
DebugPrint( "WARNING: Attempting to unlock squad member past the max index. Ignoring..." )
|
|
end
|
|
local f24_local0 = Cac.ActiveSquadMemberCount( f24_arg0, f24_arg1 )
|
|
for f24_local1 = 1, f24_local0, 1 do
|
|
Engine.SetPlayerDataEx( f24_arg0, CoD.GetStatsGroupForGameMode(), "challengeState", "ch_squad_member" .. f24_local1 .. "_purchase", 2 )
|
|
end
|
|
end
|
|
|
|
Cac.GetSquadMemberName = function ( f25_arg0, f25_arg1, f25_arg2 )
|
|
return Engine.GetPlayerDataEx( f25_arg0, CoD.GetStatsGroupForGameMode(), f25_arg1, f25_arg2, "name" )
|
|
end
|
|
|
|
Cac.SetSquadMemberName = function ( f26_arg0, f26_arg1, f26_arg2, f26_arg3 )
|
|
return Engine.SetPlayerDataEx( f26_arg0, CoD.GetStatsGroupForGameMode(), f26_arg1, f26_arg2, "name", f26_arg3 )
|
|
end
|
|
|
|
Cac.HasSquadMemberPrestiged = function ( f27_arg0, f27_arg1, f27_arg2 )
|
|
return Engine.GetPlayerDataEx( f27_arg0, CoD.GetStatsGroupForGameMode(), f27_arg1, f27_arg2, "squadMemXP" ) >= Rank.GetRankMaxXP( Rank.GetMaxRank() )
|
|
end
|
|
|
|
Cac.GetSquadMemberPrestigeLevel = function ( f28_arg0, f28_arg1, f28_arg2 )
|
|
if not Cac.HasSquadMemberPrestiged( f28_arg0, f28_arg1, f28_arg2 ) then
|
|
return 0
|
|
end
|
|
local f28_local0 = 1
|
|
local f28_local1 = Engine.GetPlayerDataEx( f28_arg0, CoD.GetStatsGroupForGameMode(), "characterXP", f28_arg2 )
|
|
for f28_local2 = 0, Cac.MaxSquadMemberCount( f28_arg1 ) - 1, 1 do
|
|
if f28_local2 ~= f28_arg2 and Cac.IsSquadMemberInUse( f28_arg0, f28_arg1, f28_local2 ) and Cac.HasSquadMemberPrestiged( f28_arg0, f28_arg1, f28_local2 ) and Engine.GetPlayerDataEx( f28_arg0, CoD.GetStatsGroupForGameMode(), "characterXP", f28_local2 ) < f28_local1 then
|
|
f28_local0 = f28_local0 + 1
|
|
end
|
|
end
|
|
return f28_local0
|
|
end
|
|
|
|
Cac.GetPrestigeLevel = function ( f29_arg0, f29_arg1 )
|
|
local f29_local0 = 0
|
|
for f29_local1 = 0, Cac.MaxSquadMemberCount( f29_arg1 ) - 1, 1 do
|
|
if Cac.IsSquadMemberInUse( f29_arg0, f29_arg1, f29_local1 ) and Cac.HasSquadMemberPrestiged( f29_arg0, f29_arg1, f29_local1 ) then
|
|
f29_local0 = f29_local0 + 1
|
|
end
|
|
end
|
|
return f29_local0
|
|
end
|
|
|
|
Cac.SyncPrestigeLevel = function ( f30_arg0 )
|
|
Engine.SetPlayerDataEx( f30_arg0, CoD.GetStatsGroupForGameMode(), "prestige", Cac.GetPrestigeLevel( f30_arg0, Cac.GetSquadLoc() ) )
|
|
end
|
|
|
|
Cac.GetSquadMemberLoadoutUnlockCost = function ( f31_arg0 )
|
|
if Cac.Settings.DataLoc.loadouts.baseClassSlots <= f31_arg0 then
|
|
return 0
|
|
else
|
|
return 20 + (f31_arg0 - 3) * 5
|
|
end
|
|
end
|
|
|
|
Cac.ValidateAllPlayersPrivateSquadMembers = function ()
|
|
for f32_local0 = 0, Engine.GetMaxControllerCount() - 1, 1 do
|
|
if Engine.HasActiveLocalClient( f32_local0 ) and Engine.HasPlayerData( f32_local0 ) then
|
|
if not Lobby.IsItemOfTypeUnlocked( f32_local0, "wolf", "DLC" ) then
|
|
DebugPrint( "You are not Entitled to the Wolf. So removing." )
|
|
Engine.SetPlayerDataReservedInt( f32_local0, CoD.StatsGroup.Common, "mp_dog_type", 0 )
|
|
end
|
|
for f32_local3 = 0, Cac.MaxSquadMemberCount( "privateMatchSquadMembers" ) - 1, 1 do
|
|
Cac.ValidateCustomizationItems( f32_local0, "privateMatchSquadMembers", f32_local3 )
|
|
if not Engine.IsAliensMode() then
|
|
Cac.ValidateLoadoutItems( f32_local0, "privateMatchSquadMembers", f32_local3, "loadouts" )
|
|
end
|
|
end
|
|
if not Engine.IsAliensMode() then
|
|
Cac.ValidateCustomizationItems( f32_local0, "squadMembers", Cac.GetActiveSquadMember( f32_local0, CoD.StatsGroup.Ranked ) )
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
Cac.ValidateAllPlayersPublicSquadMembers = function ()
|
|
local f33_local0 = Cac.GetSquadLoc()
|
|
assert( f33_local0 ~= "privateMatchSquadMembers", "Cac.GetSquadLoc() returned private match location in public lobby." )
|
|
for f33_local1 = 0, Engine.GetMaxControllerCount() - 1, 1 do
|
|
if Engine.HasActiveLocalClient( f33_local1 ) then
|
|
if not Lobby.IsItemOfTypeUnlocked( f33_local1, "wolf", "DLC" ) then
|
|
DebugPrint( "You are not Entitled to the Wolf. So removing." )
|
|
Engine.SetPlayerDataReservedInt( f33_local1, CoD.StatsGroup.Common, "mp_dog_type", 0 )
|
|
end
|
|
local f33_local4 = Cac.GetActiveSquadMember( f33_local1 )
|
|
Cac.ValidateCustomizationItems( f33_local1, f33_local0, f33_local4 )
|
|
if not Engine.IsAliensMode() then
|
|
Cac.ValidateLoadoutItems( f33_local1, "squadMembers", f33_local4, "loadouts" )
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|