Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 212.27 KB | None | 0 0
  1. function PlayerUpdate(idx)
  2.     local as = gSportsRNA
  3.     local player = as:GetTable("wvPlayer", idx)
  4.     local state = as:GetTable("wvState")
  5.  
  6.     db.player[idx].envLighting = as:GetInt(state, "wvAttribEnvLighting")
  7.     db.player[idx].stadiumLightID = as:GetInt(state, "wvAttribStadLightID")
  8.     db.player[idx].stadiumID = as:GetInt(state, "wvAttribStadID")
  9.    
  10.  
  11.  
  12.     local weather = as:GetInt(state, "wvAttribStadWeather")
  13.     local climate = as:GetInt(state, "wvAttribStadClimate") -- 0: warm, 1: cold
  14.  
  15.     if (weather == 1 or weather == 2) then
  16.         db.player[idx].wet = 1
  17.     else
  18.         db.player[idx].wet = 0
  19.     end
  20.  
  21.     if (weather == 1 or weather == 2 or climate == 1) then
  22.         db.player[idx].cold = 1
  23.     else
  24.         db.player[idx].cold = 0
  25.     end
  26.  
  27.     db.player[idx].stadiumType = as:GetInt(player, "stadiumType")
  28.  
  29.     db.player[idx].playerassetid = as:GetInt(player, "playerassetid")
  30.     db.player[idx].teamid = as:GetInt(player, "teamid")
  31.     db.player[idx].teamside = as:GetInt(player, "teamside")
  32.     db.player[idx].isgoalie = as:GetInt(player, "goalie")
  33.    
  34.     -- female added in fifa 2016
  35.     db.player[idx].gender = as:GetInt(player, "gender")  -- 0=male, 1=female
  36.     db.player[idx].strgender = "male"
  37.    
  38.     if (db.player[idx].gender == 1) then
  39.         db.player[idx].strgender = "female"
  40.     end
  41.    
  42.  
  43.     db.player[idx].kit = as:GetInt(player, "kit")
  44.     db.player[idx].kitType = as:GetInt(player, "kitType") %20
  45.     db.player[idx].kitYear = as:GetInt(player, "kitYear")
  46.  
  47.     local kitNumber = as:GetInt(player, "kitNumber")
  48.     db.player[idx].kitNumberTens = math.floor ( kitNumber / 10 )
  49.     db.player[idx].kitNumberUnits = math.floor ( math.fmod(kitNumber, 10) )
  50.  
  51.     db.player[idx].kitNameFont = as:GetInt(player, "kitNameFont")
  52.     db.player[idx].kitNumberFont = as:GetInt(player, "kitNumberFont")
  53.     db.player[idx].kitNumberColor = as:GetInt(player, "kitNumberColor")
  54.     db.player[idx].kitNameColor = as:GetInt(player, "kitNameColor")
  55.  
  56.     db.player[idx].shortsNumberFont = as:GetInt(player, "shortsNumberFont")
  57.     db.player[idx].shortsNumberColor = as:GetInt(player, "shortsNumberColor")
  58.     db.player[idx].jerseyNameVisible = as:GetInt(player, "jerseyNameVisible")
  59.     db.player[idx].jerseyNameLayout = as:GetInt(player, "jerseyNameLayout")
  60.  
  61.     db.player[idx].head = as:GetInt(player, "playerHead")
  62.     db.player[idx].headClass = as:GetInt(player, "playerHeadClass")
  63.  
  64.     db.player[idx].jerseyCollarType = as:GetInt(player, "jerseyCollarType")
  65.     db.player[idx].jerseySleeveLength = as:GetInt(player, "jerseySleeveLength")
  66.     db.player[idx].jerseyArmBand = as:GetInt(player, "jerseyArmBand")
  67.     db.player[idx].jerseyTucked = as:GetInt(player, "jerseyTucked")
  68.     db.player[idx].jerseyfit = as:GetInt(player, "jerseyfit")
  69.     db.player[idx].socklength = as:GetInt(player, "socklength")
  70.     db.player[idx].shortstyle = as:GetInt(player, "shortstyle")
  71.  
  72.     db.player[idx].bodySkinToneType = as:GetInt(player, "playerBodySkinToneType")
  73.     db.player[idx].headSkinToneType = as:GetInt(player, "playerHeadSkinToneType")
  74.     db.player[idx].headSkinType = as:GetInt(player, "playerHeadSkinType")
  75.     db.player[idx].playerBodySkinColor = as:GetInt(player, "playerBodySkinColor")
  76.     db.player[idx].faceGenSkinToneType = as:GetInt(player, "faceGenSkinToneType")
  77.  
  78.     db.player[idx].shoeType = as:GetInt(player, "shoeType")
  79.     db.player[idx].shoeDesign = as:GetInt(player, "shoeDesign")
  80.     db.player[idx].shoeColorPri = as:GetInt(player, "shoeColorPrim")
  81.     db.player[idx].shoeColorSec = as:GetInt(player, "shoeColorSec")
  82.     db.player[idx].shoeColorTer = as:GetInt(player, "shoeColorTer")
  83.  
  84.     db.player[idx].faceType = as:GetInt(player, "faceType")
  85.     db.player[idx].faceProxyHeadClass = as:GetInt(player, "faceProxyHeadClass")
  86.     -- Faceproxyheadclass should never be greater than one including createplayer
  87.     if (db.player[idx].faceProxyHeadClass == 2) then
  88.         db.player[idx].faceProxyHeadClass = 1
  89.     end
  90.  
  91.     db.player[idx].faceSideBurn = 0--as:GetInt(player, "faceSideBurn")
  92.     db.player[idx].facialHairColor = as:GetInt(player, "facialHairColor")
  93.     db.player[idx].facialHairType = as:GetInt(player, "facialHairType")
  94.     db.player[idx].eyebrow = as:GetInt(player, "eyebrow")
  95.  
  96.     db.player[idx].isVirtualPro = as:GetInt(player, "isVirtualPro")
  97.     db.player[idx].isCreatePlayer = as:GetInt(player, "isCreatePlayer")
  98.     db.player[idx].faceTexExtension = "rx3"
  99.  
  100.     db.player[idx].isCreationZone = as:GetInt(player, "isFCZ")
  101.     db.player[idx].hasCzCrestImage = as:GetInt(player, "hasCzCrestImage")
  102.     db.player[idx].crestAssetId = as:GetInt(player, "crestAssetId")
  103.     db.player[idx].forceunderarm = as:GetInt(player, "forceunderarm")
  104.     db.player[idx].forceundershorts = as:GetInt(player, "forceundershorts")
  105.     db.player[idx].forceunderneck = as:GetInt(player, "forceunderneck")
  106.  
  107.     db.player[idx].sponsorAssetId = as:GetInt(player, "sponsorAssetId")
  108.     db.player[idx].hotspotJerseySponsorL = as:GetFloat(player, "hotspotJerseySponsorL")
  109.     db.player[idx].hotspotJerseySponsorT = as:GetFloat(player, "hotspotJerseySponsorT")
  110.     db.player[idx].hotspotJerseySponsorR = as:GetFloat(player, "hotspotJerseySponsorR")
  111.     db.player[idx].hotspotJerseySponsorB = as:GetFloat(player, "hotspotJerseySponsorB")
  112.  
  113.     db.player[idx].kitColourJerseyPri = as:GetInt(player, "kitColourJerseyPri")
  114.     db.player[idx].kitColourJerseySec = as:GetInt(player, "kitColourJerseySec")
  115.     db.player[idx].kitColourJerseyTer = as:GetInt(player, "kitColourJerseyTer")
  116.  
  117.     db.player[idx].kitColourShortPri = as:GetInt(player, "kitColourShortPri")
  118.     db.player[idx].kitColourShortSec = as:GetInt(player, "kitColourShortSec")
  119.     db.player[idx].kitColourShortTer = as:GetInt(player, "kitColourShortTer")
  120.  
  121.     db.player[idx].kitColourSocksPri = as:GetInt(player, "kitColourSocksPri")
  122.     db.player[idx].kitColourSocksSec = as:GetInt(player, "kitColourSocksSec")
  123.     db.player[idx].kitColourSocksTer = as:GetInt(player, "kitColourSocksTer")
  124.  
  125.     db.player[idx].kitColourMaskPri = 0x00FF0000
  126.     db.player[idx].kitColourMaskSec = 0x0000FF00
  127.     db.player[idx].kitColourMaskTer = 0x000000FF
  128.  
  129.     db.player[idx].teamColorPri = 0x00FF0000
  130.     db.player[idx].teamColorSec = 0x0000FF00
  131.     db.player[idx].teamColorTer = 0x000000FF
  132.    
  133.     if (((db.player[idx].cold == 1) or trackSuitMode) and GetRMTracksuitType(idx)) then
  134.         db.player[idx].teamColorPri = as:GetInt(player, "homeColourPri")
  135.         db.player[idx].teamColorSec = as:GetInt(player, "homeColourSec")
  136.         db.player[idx].teamColorTer = as:GetInt(player, "homeColourTer")
  137.     end
  138.  
  139.     db.player[idx].sponsorcolour = as:GetInt(player, "sponsorcolour")
  140.  
  141.     db.player[idx].crestTexName = "crest_cm"
  142.  
  143.     if (db.player[idx].isCreationZone == 1 and db.player[idx].hasCzCrestImage > 0) then
  144.         db.player[idx].crestTexName = "png";
  145.     end
  146.  
  147.     db.player[idx].faceTexName = "head_"
  148.     if (db.player[idx].isVirtualPro == 1) then
  149.         db.player[idx].faceTexExtension = "dds"
  150.         db.player[idx].faceTexName = "head.dds"
  151.     end
  152.  
  153.     db.player[idx].faceTypeFallback = 0
  154.     db.player[idx].headFallback = 0
  155.     db.player[idx].faceSideBurnFallback = db.player[idx].faceSideBurn
  156.     db.player[idx].facialHairColorFallback = db.player[idx].facialHairColor
  157.     db.player[idx].facialHairTypeFallback = db.player[idx].facialHairType
  158.     db.player[idx].headSkinTypeFallback = db.player[idx].headSkinType
  159.     db.player[idx].headSkinToneTypeFallback = db.player[idx].headSkinToneType
  160.  
  161.     if(db.player[idx].headSkinToneTypeFallback == 1 or db.player[idx].headSkinToneTypeFallback == 3 or db.player[idx].headSkinToneTypeFallback == 7) then
  162.         db.player[idx].headSkinToneTypeFallback = db.player[idx].headSkinToneTypeFallback + 1
  163.     end
  164.  
  165.     -- If create player then we need the create player head
  166.     -- head_{id}_{headClass}.rx2
  167.     -- {id} == 0 is create player
  168.     -- {id} == 1 is create player copy
  169.     -- {id} == 2 is facegen head
  170.     -- {id} == 3 is facegen head copy
  171.     if (db.player[idx].isCreatePlayer == 1) then
  172.         db.player[idx].headClass = 2
  173.         db.player[idx].faceProxyHeadClass = 1
  174.  
  175.         if (db.player[idx].isVirtualPro == 1) then
  176.             db.player[idx].faceSideBurn = 0
  177.             db.player[idx].facialHairColor = 0
  178.             db.player[idx].facialHairType = 0
  179.             db.player[idx].headSkinType = 0
  180.             db.player[idx].headSkinToneType = 0
  181.             db.player[idx].bodySkinToneType = 11 -- force body skin tone type to 11 (greyscale) for face gen
  182.  
  183.         end
  184.  
  185.     end
  186.  
  187.  
  188.     db.player[idx].eyeColor = as:GetInt(player, "eyeColor")
  189.     db.player[idx].hair = as:GetInt(player, "hair")
  190.     db.player[idx].hairColor = as:GetInt(player, "hairColor")
  191.     db.player[idx].compsuffix = ".rx3"
  192.  
  193.    
  194.    
  195.     --IF REFEREE
  196.     if (db.player[idx].kitType == 5) then
  197.     db.player[idx].playerassetid = db.player[idx].playerassetid + 500000
  198.     db.player[idx].teamid = 6004
  199.     end
  200.    
  201.     --IF VP
  202.     if (db.player[idx].playerassetid == 30999) then
  203.     identifyVP[1] = db.player[idx].shoeType
  204.     identifyVP[2] = db.player[idx].hair
  205.     identifyVP[3] = db.player[idx].hairColor
  206.     identifyVP[4] = db.player[idx].eyeColor
  207.     identifyVP[5] = db.player[idx].bodySkinToneType
  208.     identifyVP[6] = kitNumber
  209.     end
  210.    
  211.    
  212.     -- local xb = tostring(db.player[idx].playerassetid)
  213.     -- db.player[idx].kitNumberTens = tonumber(string.sub(xb,4,4))
  214.     -- db.player[idx].kitNumberUnits = tonumber(string.sub(xb,5,5))
  215.     -- if (string.len(xb) > (xidx-1)-1) then
  216.    
  217.    
  218.     --if (db.player[idx].isCreatePlayer == 1) then
  219.     if (db.player[idx].isVirtualPro == 1) then
  220.     db.player[idx].playerassetid = 30999
  221.    
  222.     else
  223.     if (db.player[idx].isCreatePlayer == 1) then
  224.    
  225.    
  226.     if (db.player[idx].shoeType == identifyVP[1]) then
  227.     if (db.player[idx].hair == identifyVP[2]) then
  228.     if (db.player[idx].hairColor == identifyVP[3]) then
  229.     if (db.player[idx].eyeColor == identifyVP[4]) then
  230.     if (db.player[idx].bodySkinToneType == identifyVP[5]) then
  231.     if ((kitNumber == identifyVP[6]) or (kitNumber == 1)) then
  232.     -- if (db.player[idx].isCreatePlayer == identifyVP[7]) then
  233.     -- if (db.player[idx].isCreatePlayer == identifyVP[8]) then
  234.     -- if (db.player[idx].isCreatePlayer == identifyVP[9]) then
  235.     -- if (db.player[idx].isCreatePlayer == identifyVP[10]) then
  236.    
  237.     db.player[idx].playerassetid = 30999
  238.    
  239.     end
  240.     end
  241.     end
  242.     end
  243.     end
  244.     end
  245.    
  246.  
  247.  
  248.  
  249.    
  250.    
  251.    
  252.     end
  253.     end
  254.    
  255.    
  256.     local stadium = as:GetTable("wvStadium", 1)
  257.        
  258.     db.player[idx].homeKitTeamID = as:GetInt(stadium, "homeKitTeamID" )
  259.     db.player[idx].awayKitTeamID = as:GetInt(stadium, "awayKitTeamID" )
  260.     db.player[idx].homeKitTypeID = as:GetInt(stadium, "homeKitTypeID" )
  261.     db.player[idx].awayKitTypeID = as:GetInt(stadium, "awayKitTypeID" )
  262.    
  263.     local outidx = 9
  264.     if (db.player[idx].teamside == 1) then
  265.     outidx = 20
  266.     end
  267.    
  268.     local outplayer = as:GetTable("wvPlayer", outidx)
  269.    
  270.     local kitOutfield = as:GetInt(outplayer, "kit")
  271.     local kitTypeOutfield = as:GetInt(outplayer, "kitType") %20
  272.     local kitYearOutfield = as:GetInt(outplayer, "kitYear")
  273.    
  274.     if (db.player[idx].kitYear > 0) then
  275.     kitYearOutfield = db.player[idx].kitYear
  276.     end
  277.    
  278.     db.player[idx].outfieldKitType = kitTypeOutfield
  279.    
  280.     --FUT FIX
  281.     if (db.player[idx].teamid == 130000) then
  282.     -- if ((futCustom) and ((futKits[db.player[idx].kitType] == db.player[idx].kit) or (futKits[db.player[idx].kitType] == nil))) then
  283.     if ((futCustom) and ((futKits[kitTypeOutfield] == db.player[idx].kit) or (futKits[kitTypeOutfield] == nil))) then
  284.     db.player[idx].kit = db.player[idx].teamid
  285.     else
  286.     db.player[idx].teamid = db.player[idx].kit
  287.     end
  288.     end
  289.    
  290.    
  291.     -- local skyCategoryId = as:GetInt(state, "wvAttribSkyCategory")
  292.     -- local skyAssetId = as:GetInt(state, "wvAttribSkyID")
  293.    
  294.     -- seed = (seed + (db.player[idx].playerassetid*idx) + (skyCategoryId*631) + (skyAssetId*983))%1000000
  295.    
  296.     --PLAYER FILES
  297.     if (oldidx ~= idx) then
  298.     if ((db.player[idx].isCreatePlayer ~= 1) or (db.player[idx].teamside ~= -1)) then
  299.     if (db.player[idx].kit ~= db.player[idx].teamid) then
  300.     LoadAsync("data/fifarna/lua/assignments/teams/team_"..db.player[idx].kit..".lua")
  301.     end
  302.     LoadAsync("data/fifarna/lua/assignments/teams/team_"..db.player[idx].teamid..".lua")
  303.     LoadAsync("data/fifarna/lua/assignments/players/player_"..db.player[idx].playerassetid..".lua")
  304.     LoadAsync("data/fifarna/lua/assignments/playershoes/playershoe_"..db.player[idx].playerassetid..".lua")
  305.     LoadAsyncWait()
  306.     end
  307.  
  308.    
  309.     if (idx == 0) then
  310.     local temp = math.random(1,1000000)
  311.     math.randomseed(seed + temp + 123456)
  312.     math.random()
  313.     math.random()
  314.     math.random()
  315.     end
  316.    
  317.     local randl = (idx + db.player[idx].playerassetid)%10
  318.     for i=0,randl do
  319.     math.random()
  320.     end
  321.    
  322.    
  323.    
  324.     end
  325.     oldidx = idx
  326.    
  327.     --FACE
  328.     db.player[idx].headClass = getPlayerFace(db.player[idx].playerassetid,db.player[idx].headClass)
  329.     db.player[idx].faceProxyHeadClass = getPlayerFace(db.player[idx].playerassetid,db.player[idx].faceProxyHeadClass)
  330.    
  331.    
  332.    
  333.    
  334.    
  335.    
  336.  
  337.     if (db.player[idx].headClass == 0) then
  338.  
  339.         local playerassetid = db.player[idx].playerassetid
  340.  
  341.         db.player[idx].head = playerassetid
  342.         -- db.player[idx].eyeColor = playerassetid
  343.  
  344.         db.player[idx].eyebrow = 0
  345.         db.player[idx].faceType = playerassetid
  346.         db.player[idx].faceSideBurn = 0
  347.         db.player[idx].facialHairColor = 0
  348.         db.player[idx].facialHairType = 0
  349.         db.player[idx].headSkinType = 0
  350.         db.player[idx].headSkinToneType = 0
  351.  
  352.         db.player[idx].hair = playerassetid
  353.         db.player[idx].hairColor = 0
  354.         db.player[idx].useFaceTextureComposition = 0
  355.         db.player[idx].compsuffix = "_-1.rx3" -- avvoid loading layers for compositing if star head.
  356.     else
  357.         if(db.player[idx].headSkinToneType == 1 or db.player[idx].headSkinToneType == 3 or db.player[idx].headSkinToneType == 7) then
  358.             db.player[idx].headSkinToneType = db.player[idx].headSkinToneType + 1
  359.         end
  360.  
  361.         db.player[idx].useFaceTextureComposition = as:GetInt(player, "useFaceTextureComposition")
  362.    
  363.         if(db.player[idx].useFaceTextureComposition == 1) then
  364.             db.player[idx].dxttype = "dxt1"
  365.         elseif (db.player[idx].useFaceTextureComposition == 2) then
  366.             db.player[idx].dxttype = "eadxt1"
  367.         elseif (db.player[idx].useFaceTextureComposition == 3) then
  368.             db.player[idx].dxttype = "rnadxt1"
  369.         else
  370.             db.player[idx].dxttype = "argb"
  371.         end
  372.  
  373.         --tmp
  374.         -- db.player[idx].hairColorIdx = db.player[idx].hairColor
  375.         -- db.player[idx].hairColor = 0
  376.     end
  377.    
  378.    
  379.    
  380.    
  381.    
  382.    
  383.    
  384.    
  385.    
  386.    
  387.    
  388.    
  389.    
  390.    
  391.    
  392.    
  393.     --RMCUSTOMSTART
  394.     if (isPlayerGK(db.player[idx].playerassetid)) then
  395.     db.player[idx].isgoalie = 1
  396.     db.player[idx].kitType = 2
  397.     end
  398.    
  399.     if ((db.player[idx].shoeType == 0) and repGenBoots) then
  400.     if (not getPlayerGenericBoot(db.player[idx].playerassetid)) then
  401.     db.player[idx].shoeType = getGenericBootReplacement(db.player[idx].playerassetid,db.player[idx].kitType)
  402.     db.player[idx].shoeDesign = 0
  403.     db.player[idx].shoeColorPri = hex("FF0000")
  404.     db.player[idx].shoeColorSec = hex("00FF00")
  405.     db.player[idx].shoeColorTer = hex("0000FF")
  406.     end
  407.     end
  408.    
  409.    
  410.    
  411.    
  412.     -- local stadium = as:GetTable("wvStadium", 1)
  413.        
  414.     -- db.player[idx].homeKitTeamID = as:GetInt(stadium, "homeKitTeamID" )
  415.     -- db.player[idx].awayKitTeamID = as:GetInt(stadium, "awayKitTeamID" )
  416.     -- db.player[idx].homeKitTypeID = as:GetInt(stadium, "homeKitTypeID" )
  417.     -- db.player[idx].awayKitTypeID = as:GetInt(stadium, "awayKitTypeID" )
  418.    
  419.     -- local outidx = 3
  420.     -- if (db.player[idx].teamside == 1) then
  421.     -- outidx = 14
  422.     -- end
  423.    
  424.     -- local outplayer = as:GetTable("wvPlayer", outidx)
  425.    
  426.     -- local kitOutfield = as:GetInt(outplayer, "kit")
  427.     -- local kitTypeOutfield = as:GetInt(outplayer, "kitType")
  428.     -- local kitYearOutfield = as:GetInt(outplayer, "kitYear")
  429.    
  430.     -- db.player[idx].outfieldKitType = kitTypeOutfield
  431.    
  432.     local wipe3d = as:GetTable("wvWipe", 1)
  433.    
  434.     db.player[idx].tournid = as:GetInt(wipe3d, "leagueID")
  435.     db.player[idx].tournid = getTournamentGraphics(db.player[idx].tournid)
  436.  
  437.  
  438.     --IF GENERIC KIT
  439.     db.player[idx].speckitType = -1
  440.     if (db.player[idx].teamid == db.player[idx].kit) then
  441.     db.player[idx].genkit = db.player[idx].teamid
  442.     else
  443.     db.player[idx].genkit = db.player[idx].kit
  444.     if (db.player[idx].kitType ~= 5) then
  445.     if ((db.player[idx].kit >= 5000) and (db.player[idx].kit < 8000)) then
  446.     db.player[idx].kit = db.player[idx].teamid
  447.     else
  448.     db.player[idx].teamid = db.player[idx].kit
  449.     end
  450.     end
  451.     end
  452.    
  453.     --PL REF KIT FIX
  454.     if ((db.player[idx].kitType == 5) and (db.player[idx].kit > 6100)) then
  455.     --db.player[idx].kit = db.player[idx].kit - 100
  456.     db.player[idx].kit = 6000 + (db.player[idx].kit%10)
  457.     end
  458.    
  459.     if ((db.player[idx].kitType == 5) and (db.player[idx].kit < 6004)) then
  460.     db.player[idx].kit = 6004
  461.     end
  462.    
  463.     --IF CLASSIC KIT
  464.     if (db.player[idx].kitYear > 0) then
  465.    
  466.     db.player[idx].tournid = db.player[idx].kitYear
  467.     end
  468.    
  469.    
  470.    
  471.    
  472.     db.player[idx].defaulttournid = -1
  473.     if (db.player[idx].kitType == 5) then
  474.     if (kitYearOutfield > 0) then
  475.     db.player[idx].tournid = kitYearOutfield
  476.     end
  477.     if (teamTournament[db.player[idx].homeKitTeamID] ~= nil) then
  478.     db.player[idx].defaulttournid = getCloneTournamentRefereeKits(teamTournament[db.player[idx].homeKitTeamID])
  479.     end
  480.     else
  481.     if (teamTournament[db.player[idx].teamid] ~= nil) then
  482.     db.player[idx].defaulttournid = teamTournament[db.player[idx].teamid]
  483.     end
  484.     end
  485.    
  486.     --CLASSIC KIT BOOT DECADE
  487.     db.player[idx].kitYearDecade = -1
  488.     if (kitYearOutfield > 0) then
  489.     db.player[idx].kitYearDecade = math.floor(kitYearOutfield/10)*10
  490.     end
  491.    
  492.     --CLASSIC KIT ARMBAND
  493.     if (kitYearOutfield > 0) then
  494.     if (kitYearOutfield <= classicKitCaptainArmbandYear) then
  495.     db.player[idx].jerseyArmBand = 0
  496.     end
  497.     end
  498.    
  499.    
  500.     --CLASSIC GK KIT
  501.     if ((db.player[idx].isgoalie == 1) and (kitYearOutfield > 0)) then
  502.  
  503.     db.player[idx].tournid = kitYearOutfield
  504.     end
  505.    
  506.     --ARENA PLAYER KIT
  507.     if ((idx < 8) and (db.player[idx].isgoalie == 0)) then
  508.     db.player[idx].speckitType = 91
  509.     end
  510.  
  511.     --ARENA GK KIT
  512.     if ((idx < 8) and (db.player[idx].isgoalie == 1)) then
  513.     db.player[idx].speckitType = 92
  514.     end
  515.    
  516.     --TRAINING KIT HOME
  517.     if ((db.player[idx].genkit == 7000) and (db.player[idx].kitType == 6)) then
  518.     db.player[idx].speckitType = 93
  519.     db.player[idx].kitType = 93
  520.     db.player[idx].kitColourJerseyPri = 0x00FF0000
  521.     db.player[idx].kitColourJerseySec = 0x0000FF00
  522.     db.player[idx].kitColourJerseyTer = 0x000000FF
  523.     db.player[idx].kitColourShortPri = 0x00FF0000
  524.     db.player[idx].kitColourShortSec = 0x0000FF00
  525.     db.player[idx].kitColourShortTer = 0x000000FF
  526.     db.player[idx].kitColourSocksPri = 0x00FF0000
  527.     db.player[idx].kitColourSocksSec = 0x0000FF00
  528.     db.player[idx].kitColourSocksTer = 0x000000FF
  529.     end
  530.    
  531.     --TRAINING KIT AWAY
  532.     if ((db.player[idx].genkit == 7000) and (db.player[idx].kitType == 7)) then
  533.     db.player[idx].speckitType = 94
  534.     db.player[idx].kitType = 94
  535.     db.player[idx].kitColourJerseyPri = 0x00FF0000
  536.     db.player[idx].kitColourJerseySec = 0x0000FF00
  537.     db.player[idx].kitColourJerseyTer = 0x000000FF
  538.     db.player[idx].kitColourShortPri = 0x00FF0000
  539.     db.player[idx].kitColourShortSec = 0x0000FF00
  540.     db.player[idx].kitColourShortTer = 0x000000FF
  541.     db.player[idx].kitColourSocksPri = 0x00FF0000
  542.     db.player[idx].kitColourSocksSec = 0x0000FF00
  543.     db.player[idx].kitColourSocksTer = 0x000000FF
  544.     end
  545.    
  546.     if ((db.player[idx].isgoalie == 1) and (idx > 7)) then
  547.    
  548.     --TRAINING KIT HOME GK
  549.     if ((kitOutfield == 7000) and (kitTypeOutfield == 6)) then
  550.     db.player[idx].speckitType = 95
  551.     end
  552.    
  553.     --TRAINING KIT HOME GK
  554.     if ((kitOutfield == 7000) and (kitTypeOutfield == 7)) then
  555.     db.player[idx].speckitType = 96
  556.     end
  557.    
  558.     end
  559.    
  560.     --GK KITS
  561.     if ((db.player[idx].isgoalie == 1) and (idx > 7)) then
  562.    
  563.     if (fixGenGK) then
  564.     db.player[idx].kitNameFont = as:GetInt(outplayer, "kitNameFont")
  565.     db.player[idx].kitNumberFont = as:GetInt(outplayer, "kitNumberFont")
  566.     db.player[idx].shortsNumberFont = as:GetInt(outplayer, "shortsNumberFont")
  567.     if ((db.player[idx].kitYearDecade > 0) and (classicGKMode)) then
  568.     db.player[idx].kitNumberColor = 1
  569.     db.player[idx].jerseyCollarType = 0
  570.     db.player[idx].jerseyNameVisible = 0
  571.     db.player[idx].kitNameColor = 0x00FFFFFF
  572.     end
  573.     -- db.player[idx].kitNameColor = hex("EEEEEE")
  574.     end
  575.    
  576.     end
  577.    
  578.     --ALTERNATE GK
  579.     -- if ((kitOutfield ~= 7000)) then
  580.     -- db.player[idx].speckitType = kitTypeOutfield + 30
  581.     -- end
  582.    
  583.     --
  584.     -- if (db.player[idx].kitYear == 0) then
  585.     -- if (db.player[idx].teamside == 0) then
  586.     -- db.player[idx].speckitType = getGKKit(db.player[idx].kit,db.player[idx].homeKitTypeID,db.player[idx].homeKitTeamID,db.player[idx].awayKitTeamID,db.player[idx].kitType,db.player[idx].speckitType)
  587.     -- else
  588.     -- db.player[idx].speckitType = getGKKit(db.player[idx].kit,db.player[idx].awayKitTypeID,db.player[idx].homeKitTeamID,db.player[idx].awayKitTeamID,db.player[idx].kitType,db.player[idx].speckitType)
  589.     -- end
  590.     -- end
  591.    
  592.     -- end
  593.    
  594.    
  595.    
  596.    
  597.  
  598.     -- --NON GK KIT
  599.     -- if ((db.player[idx].isgoalie == 0) and (idx > 1)) then
  600.    
  601.     -- --SPECIFIC MATCH KIT
  602.     -- if (db.player[idx].kitYear == 0) then
  603.     -- db.player[idx].speckitType = getGameKit(db.player[idx].kit,db.player[idx].homeKitTeamID,db.player[idx].awayKitTeamID,db.player[idx].kitType,db.player[idx].speckitType)
  604.     -- end
  605.    
  606.     -- end
  607.  
  608.    
  609.     db.player[idx].tournidnum = getCloneTournamentNumbers(db.player[idx].tournid)
  610.     db.player[idx].tournidkit = getCloneTournamentKits(db.player[idx].tournid,db.player[idx].teamid)
  611.     db.player[idx].tournidref = getCloneTournamentRefereeKits(db.player[idx].tournid)
  612.     db.player[idx].bibType = -1
  613.  
  614.    
  615.    
  616.     if (db.player[idx].kitYear == 0) then
  617.     db.player[idx].kitType = getSwapKit(db.player[idx].kit,db.player[idx].kitType,db.player[idx].tournidkit)
  618.     end
  619.    
  620.    
  621.     --NEW KIT STUFF
  622.    
  623.     db.player[idx].speckitTypeShort = db.player[idx].speckitType
  624.     db.player[idx].speckitTypeSock = db.player[idx].speckitType
  625.    
  626.     if (idx == 0) then
  627.     homeoutfieldkittypechoice = -1
  628.     awayoutfieldkittypechoice = -1
  629.     homegkkittypechoice = -1
  630.     awaygkkittypechoice = -1
  631.     refereekittypechoice = -1
  632.     homebibchoice = -1
  633.     awaybibchoice = -1
  634.     end
  635.    
  636.    
  637.     local homeplayer = as:GetTable("wvPlayer", 9)
  638.     local awayplayer = as:GetTable("wvPlayer", 20)
  639.     local homegk = as:GetTable("wvPlayer", 8)
  640.     local referee = as:GetTable("wvPlayer", 54)
  641.    
  642.     local matchhometeamid = as:GetInt(homeplayer, "teamid")
  643.     local matchawayteamid = as:GetInt(awayplayer, "teamid")
  644.     local matchhomegkteamid = as:GetInt(homegk, "teamid")
  645.    
  646.     local matchhomekitteam = as:GetInt(homeplayer, "kit")
  647.     local matchhomekittype = as:GetInt(homeplayer, "kitType") %20
  648.     local matchhomekityear = as:GetInt(homeplayer, "kitYear")
  649.    
  650.     local matchawaykitteam = as:GetInt(awayplayer, "kit")
  651.     local matchawaykittype = as:GetInt(awayplayer, "kitType") %20
  652.     local matchawaykityear = as:GetInt(awayplayer, "kitYear")
  653.    
  654.     local matchhomegkkitteam = as:GetInt(homegk, "kit")
  655.     local matchhomegkkittype = as:GetInt(homegk, "kitType") %20
  656.    
  657.     local refereekittype = as:GetInt(referee, "kit")
  658.    
  659.     local temphomegk = -1
  660.     local tempawaygk = -1
  661.    
  662.     local tournamentid = as:GetInt(wipe3d, "leagueID")
  663.     tournamentid = getTournamentGraphics(tournamentid)
  664.     tournamentid = getCloneTournamentKits(tournamentid,matchhometeamid)
  665.    
  666.     local matchhomekittourn = tournamentid
  667.     local matchawaykittourn = tournamentid
  668.    
  669.     if (matchhomekityear > 0) then
  670.     matchhomekittourn = matchhomekityear
  671.     end
  672.    
  673.     if (matchawaykityear > 0) then
  674.     matchawaykittourn = matchawaykityear
  675.     end
  676.    
  677.    
  678.     --FUT FIX
  679.     if (matchhometeamid == 130000) then
  680.     if ((futCustom) and ((futKits[matchhomekittype] == matchhomekitteam) or (futKits[matchhomekittype] == nil))) then
  681.     matchhomekitteam = 130000
  682.     end
  683.     end
  684.    
  685.     if (matchawayteamid == 130000) then
  686.     if ((futCustom) and ((futKits[matchawaykittype] == matchawaykitteam) or (futKits[matchawaykittype] == nil))) then
  687.     matchawaykitteam = 130000
  688.     end
  689.     end
  690.    
  691.     if (matchhomekityear == 0) then
  692.     matchhomekittype = getSwapKit(matchhomekitteam,matchhomekittype,matchhomekittourn)
  693.     end
  694.     if (matchawaykityear == 0) then
  695.     matchawaykittype = getSwapKit(matchawaykitteam,matchawaykittype,matchawaykittourn)
  696.     end
  697.    
  698.    
  699.     if (idx > 7) then
  700.     if (matchhomegkkittype == 2) then
  701.     if (matchhomekitteam ~= 7000) then
  702.     if (homeoutfieldkittypechoice == -1) then
  703.     local newKitType = -1
  704.    
  705.     --HOME KIT
  706.     homeoutfieldkittypechoice = matchhomekittype
  707.     if (matchhomekityear == 0) then
  708.     homeoutfieldkittypechoice = getGameKit(matchhomekitteam,matchhomekitteam,matchawaykitteam,tournamentid,matchhomekittype,matchhomekittype)
  709.     end
  710.     newKitType = -1
  711.    
  712.     --AWAY KIT
  713.     if (matchawaykityear == 0) then
  714.     awayoutfieldkittypechoice = getGameKit(matchawaykitteam,matchhomekitteam,matchawaykitteam,tournamentid,matchawaykittype,-1)
  715.     end
  716.     if (awayoutfieldkittypechoice == -1) then
  717.     newKitType = getAltKit(matchawaykitteam,matchhomekitteam,matchawaykittype,homeoutfieldkittypechoice,matchawaykittourn,matchhomekittourn,matchawaykityear,matchhomekityear)
  718.     newKitType = getAltKitColour(matchawaykitteam,matchhomekitteam,newKitType,homeoutfieldkittypechoice,matchawaykittourn,matchhomekittourn,matchawaykityear,matchhomekityear,-1)
  719.     if (newKitType ~= -1) then
  720.     awayoutfieldkittypechoice = newKitType
  721.     else
  722.     awayoutfieldkittypechoice = matchawaykittype
  723.     end
  724.     end
  725.    
  726.     --end
  727.     newKitType = -1
  728.    
  729.     --HOME GK KIT
  730.     if (matchhomekityear == 0) then
  731.     homegkkittypechoice = getGameKit(matchhomekitteam,matchhomekitteam,matchawaykitteam,tournamentid,2,-1)
  732.     end
  733.     if (homegkkittypechoice == -1) then
  734.     newKitType = getGKKitColour(matchhomekitteam,matchawaykitteam,homeoutfieldkittypechoice,awayoutfieldkittypechoice,matchhomekittourn,matchawaykittourn,matchhomekityear,matchawaykityear,matchhomekittype,matchawaykittype,-1)
  735.     if (newKitType ~= -1) then
  736.     homegkkittypechoice = newKitType
  737.     else
  738.     homegkkittypechoice = 2
  739.     temphomegk = matchhomekittype + 30
  740.     end
  741.     end
  742.    
  743.     newKitType = getAltKitColour(matchhomekitteam,matchawaykitteam,homegkkittypechoice,awayoutfieldkittypechoice,matchhomekittourn,matchawaykittourn,matchhomekityear,matchawaykityear,homeoutfieldkittypechoice)
  744.     if (newKitType ~= -1) then
  745.     homegkkittypechoice = newKitType
  746.     temphomegk = -1
  747.     end
  748.  
  749.    
  750.     --end
  751.     newKitType = -1
  752.    
  753.     --AWAY GK KIT
  754.     if (matchawaykityear == 0) then
  755.     awaygkkittypechoice = getGameKit(matchawaykitteam,matchhomekitteam,matchawaykitteam,tournamentid,2,-1)
  756.     end
  757.     if (awaygkkittypechoice == -1) then
  758.     newKitType = getGKKitColour(matchawaykitteam,matchhomekitteam,awayoutfieldkittypechoice,homeoutfieldkittypechoice,matchawaykittourn,matchhomekittourn,matchawaykityear,matchhomekityear,matchawaykittype,matchhomekittype,homegkkittypechoice)
  759.     if (newKitType ~= -1) then
  760.     awaygkkittypechoice = newKitType
  761.     else
  762.     awaygkkittypechoice = 2
  763.     tempawaygk = matchawaykittype + 30
  764.     end
  765.     end
  766.    
  767.     newKitType = getAltKitColour(matchawaykitteam,matchhomekitteam,awaygkkittypechoice,homeoutfieldkittypechoice,matchawaykittourn,matchhomekittourn,matchawaykityear,matchhomekityear,awayoutfieldkittypechoice)
  768.     if (newKitType ~= -1) then
  769.     awaygkkittypechoice = newKitType
  770.     tempawaygk = -1
  771.     end
  772.    
  773.     --end
  774.    
  775.    
  776.    
  777.     newKitType = -1
  778.    
  779.     --HOME GK KIT (SECOND PASS)
  780.     homegkkittypechoice = -1
  781.     if (matchhomekityear == 0) then
  782.     homegkkittypechoice = getGameKit(matchhomekitteam,matchhomekitteam,matchawaykitteam,tournamentid,2,-1)
  783.     end
  784.     if (homegkkittypechoice == -1) then
  785.     newKitType = getGKKitColour(matchhomekitteam,matchawaykitteam,homeoutfieldkittypechoice,awayoutfieldkittypechoice,matchhomekittourn,matchawaykittourn,matchhomekityear,matchawaykityear,matchhomekittype,matchawaykittype,awaygkkittypechoice)
  786.     if (newKitType ~= -1) then
  787.     homegkkittypechoice = newKitType
  788.     else
  789.     homegkkittypechoice = 2
  790.     temphomegk = matchhomekittype + 30
  791.     end
  792.     end
  793.    
  794.     newKitType = getAltKitColour(matchhomekitteam,matchawaykitteam,homegkkittypechoice,awayoutfieldkittypechoice,matchhomekittourn,matchawaykittourn,matchhomekityear,matchawaykityear,homeoutfieldkittypechoice)
  795.     if (newKitType ~= -1) then
  796.     homegkkittypechoice = newKitType
  797.     temphomegk = -1
  798.     end
  799.  
  800.    
  801.     --end
  802.    
  803.    
  804.    
  805.    
  806.    
  807.    
  808.     if ((temphomegk ~= -1) and (matchhomekityear == 0)) then
  809.     homegkkittypechoice = temphomegk
  810.     end
  811.    
  812.     if ((tempawaygk ~= -1) and (matchawaykityear == 0)) then
  813.     awaygkkittypechoice = tempawaygk
  814.     end
  815.    
  816.    
  817.    
  818.    
  819.    
  820.    
  821.    
  822.    
  823.    
  824.    
  825.    
  826.     --REFEREE KIT
  827.     newKitType = -1
  828.     newKitType = getRefereeKitColour(matchhomekitteam,matchawaykitteam,homeoutfieldkittypechoice,awayoutfieldkittypechoice,matchhomekittourn,matchawaykittourn,matchhomekityear,matchawaykityear,refereekittype,db.player[idx].tournidref,homegkkittypechoice,awaygkkittypechoice)
  829.     if (newKitType ~= -1) then
  830.     refereekittypechoice = newKitType
  831.     else
  832.     refereekittypechoice = refereekittype
  833.     end
  834.  
  835.    
  836.  
  837.    
  838.    
  839.    
  840.    
  841.    
  842.  
  843.  
  844.     --HOME BIB
  845.     homebibchoice = getBibColourType(matchhomekitteam,matchawaykitteam,homeoutfieldkittypechoice,awayoutfieldkittypechoice,matchhomekittourn,matchawaykittourn,matchhomekityear,matchawaykityear,db.player[idx].tournid,homegkkittypechoice,awaygkkittypechoice,refereekittypechoice,db.player[idx].tournidref,matchhomekitteam,-1)
  846.  
  847.     --AWAY BIB
  848.     awaybibchoice = getBibColourType(matchawaykitteam,matchhomekitteam,awayoutfieldkittypechoice,homeoutfieldkittypechoice,matchawaykittourn,matchhomekittourn,matchawaykityear,matchhomekityear,db.player[idx].tournid,awaygkkittypechoice,homegkkittypechoice,refereekittypechoice,db.player[idx].tournidref,matchhomekitteam,homebibchoice)
  849.  
  850.     --HOME BIB (SECOND PASS)
  851.     homebibchoice = getBibColourType(matchhomekitteam,matchawaykitteam,homeoutfieldkittypechoice,awayoutfieldkittypechoice,matchhomekittourn,matchawaykittourn,matchhomekityear,matchawaykityear,db.player[idx].tournid,homegkkittypechoice,awaygkkittypechoice,refereekittypechoice,db.player[idx].tournidref,matchhomekitteam,awaybibchoice)
  852.  
  853.    
  854.    
  855.    
  856.    
  857.    
  858.    
  859.    
  860.    
  861.    
  862.    
  863.     --end
  864.     end
  865.    
  866.    
  867.    
  868.    
  869.    
  870.    
  871.    
  872.    
  873.    
  874.    
  875.  
  876.  
  877.    
  878.    
  879.     if (db.player[idx].teamside == 0) then
  880.     db.player[idx].bibType = homebibchoice
  881.     if (db.player[idx].isgoalie == 0) then
  882.     db.player[idx].speckitType = getIndividualKitPart(homeoutfieldkittypechoice,1)
  883.     db.player[idx].speckitTypeShort = getIndividualKitPart(homeoutfieldkittypechoice,2)
  884.     db.player[idx].speckitTypeSock = getIndividualKitPart(homeoutfieldkittypechoice,3)
  885.     else
  886.     db.player[idx].speckitType = getIndividualKitPart(homegkkittypechoice,1)
  887.     db.player[idx].speckitTypeShort = getIndividualKitPart(homegkkittypechoice,2)
  888.     db.player[idx].speckitTypeSock = getIndividualKitPart(homegkkittypechoice,3)
  889.     end
  890.     end
  891.    
  892.     if (db.player[idx].teamside == 1) then
  893.     db.player[idx].bibType = awaybibchoice
  894.     if (db.player[idx].isgoalie == 0) then
  895.     db.player[idx].speckitType = getIndividualKitPart(awayoutfieldkittypechoice,1)
  896.     db.player[idx].speckitTypeShort = getIndividualKitPart(awayoutfieldkittypechoice,2)
  897.     db.player[idx].speckitTypeSock = getIndividualKitPart(awayoutfieldkittypechoice,3)
  898.     else
  899.     db.player[idx].speckitType = getIndividualKitPart(awaygkkittypechoice,1)
  900.     db.player[idx].speckitTypeShort = getIndividualKitPart(awaygkkittypechoice,2)
  901.     db.player[idx].speckitTypeSock = getIndividualKitPart(awaygkkittypechoice,3)
  902.     end
  903.     end
  904.    
  905.     if (idx >= 54) then
  906.     db.player[idx].kit = refereekittypechoice
  907.     end
  908.    
  909.    
  910.    
  911.    
  912.     end
  913.     else
  914.    
  915.     --KIT SELECTION STUFF
  916.    
  917.    
  918.    
  919.    
  920.    
  921.     if (kitMenuClashing) then
  922.     if (matchhomekitteam ~= 7000) then 
  923.     if (db.player[idx].teamside == 1) then
  924.    
  925.    
  926.     --HOME KIT
  927.     if (matchhomegkteamid == 130000) then
  928.     if ((futCustom) and ((futKits[0] == matchhomegkkitteam) or (futKits[0] == nil))) then
  929.     matchhomegkkitteam = 130000
  930.     end
  931.     end
  932.    
  933.     local temphomekit = getSwapKit(matchhomegkkitteam,matchhomegkkittype,tournamentid) --getGameKit(matchhomegkkitteam,matchhomegkkitteam,db.player[idx].kit,matchhomegkkittype,matchhomegkkittype)
  934.    
  935.    
  936.     --AWAY KIT
  937.     local awaytourn = tournamentid
  938.     if (db.player[idx].kitYear > 0) then
  939.     awaytourn = db.player[idx].kitYear
  940.     end
  941.    
  942.    
  943.     local temptype = -1
  944.     if (db.player[idx].kitYear == 0) then
  945.     temptype = getGameKit(db.player[idx].kit,matchhomegkkitteam,db.player[idx].kit,tournamentid,db.player[idx].kitType,-1)
  946.     end
  947.     if (temptype == -1) then
  948.     temptype = getAltKit(db.player[idx].kit,matchhomegkkitteam,db.player[idx].kitType,temphomekit,awaytourn,tournamentid,db.player[idx].kitYear,0)
  949.     temptype = getAltKitColour(db.player[idx].kit,matchhomegkkitteam,temptype,temphomekit,awaytourn,tournamentid,db.player[idx].kitYear,0,-1)
  950.     end
  951.     db.player[idx].speckitType = getIndividualKitPart(temptype,1)
  952.     db.player[idx].speckitTypeShort = getIndividualKitPart(temptype,2)
  953.     db.player[idx].speckitTypeSock = getIndividualKitPart(temptype,3)
  954.     end
  955.    
  956.     end
  957.     end
  958.    
  959.    
  960.    
  961.    
  962.    
  963.     end
  964.     end
  965.    
  966.     --END NEW KIT STUFF
  967.    
  968.    
  969.     --db.player[idx].speckitType = db.player[idx].teamside + 1
  970.     -- db.player[idx].speckitTypeShort = db.player[idx].speckitType + 1
  971.     -- db.player[idx].speckitTypeSock = db.player[idx].speckitType + 2
  972.    
  973.    
  974.     --KIT DETAILS
  975.     db.player[idx].kitNameFont = getKitNameFont(db.player[idx].kit,db.player[idx].kitType,db.player[idx].kitNameFont,db.player[idx].tournidnum,db.player[idx].teamid,as:GetInt(wipe3d, "leagueID"))
  976.     db.player[idx].kitNumberFont = getKitNumberSet(db.player[idx].kit,db.player[idx].kitType,db.player[idx].kitNumberFont,db.player[idx].tournidnum,db.player[idx].teamid,as:GetInt(wipe3d, "leagueID"))
  977.     db.player[idx].kitNumberColor = getKitNumberColourShirt(db.player[idx].kit,db.player[idx].kitType,db.player[idx].kitNumberColor,db.player[idx].tournidnum,as:GetInt(wipe3d, "leagueID"))
  978.     db.player[idx].kitNameColor = getKitNameColour(db.player[idx].kit,db.player[idx].kitType,db.player[idx].kitNameColor,db.player[idx].tournidnum,as:GetInt(wipe3d, "leagueID"))
  979.     db.player[idx].shortsNumberFont = getKitNumberSet(db.player[idx].kit,db.player[idx].kitType,db.player[idx].shortsNumberFont,db.player[idx].tournidnum,db.player[idx].teamid,as:GetInt(wipe3d, "leagueID"))
  980.     db.player[idx].shortsNumberColor = getKitNumberColourShort(db.player[idx].kit,db.player[idx].kitType,db.player[idx].shortsNumberColor,db.player[idx].tournidnum,as:GetInt(wipe3d, "leagueID"))
  981.     db.player[idx].jerseyNameLayout = getKitNameCurve(db.player[idx].kit,db.player[idx].kitType,db.player[idx].jerseyNameLayout,db.player[idx].tournidnum,as:GetInt(wipe3d, "leagueID"))
  982.     db.player[idx].jerseyCollarType = getKitCollar(db.player[idx].kit,db.player[idx].kitType,db.player[idx].jerseyCollarType,db.player[idx].tournidnum,as:GetInt(wipe3d, "leagueID"))
  983.     db.player[idx].jerseyfit = getKitFit(db.player[idx].kit,db.player[idx].kitType,db.player[idx].jerseyfit,db.player[idx].tournidnum,db.player[idx].playerassetid,as:GetInt(wipe3d, "leagueID"))
  984.     --KIT DETAILS ARENA/TRAINING/ALT GK
  985.     if (db.player[idx].speckitType ~= -1) then
  986.     db.player[idx].kitNameFont = getKitNameFont(db.player[idx].kit,db.player[idx].speckitType,db.player[idx].kitNameFont,db.player[idx].tournidnum,db.player[idx].teamid,as:GetInt(wipe3d, "leagueID"))
  987.     db.player[idx].kitNumberFont = getKitNumberSet(db.player[idx].kit,db.player[idx].speckitType,db.player[idx].kitNumberFont,db.player[idx].tournidnum,db.player[idx].teamid,as:GetInt(wipe3d, "leagueID"))
  988.     db.player[idx].kitNumberColor = getKitNumberColourShirt(db.player[idx].kit,db.player[idx].speckitType,db.player[idx].kitNumberColor,db.player[idx].tournidnum,as:GetInt(wipe3d, "leagueID"))
  989.     db.player[idx].kitNameColor = getKitNameColour(db.player[idx].kit,db.player[idx].speckitType,db.player[idx].kitNameColor,db.player[idx].tournidnum,as:GetInt(wipe3d, "leagueID"))
  990.     db.player[idx].shortsNumberFont = getKitNumberSet(db.player[idx].kit,db.player[idx].speckitTypeShort,db.player[idx].shortsNumberFont,db.player[idx].tournidnum,db.player[idx].teamid,as:GetInt(wipe3d, "leagueID"))
  991.     db.player[idx].shortsNumberColor = getKitNumberColourShort(db.player[idx].kit,db.player[idx].speckitTypeShort,db.player[idx].shortsNumberColor,db.player[idx].tournidnum,as:GetInt(wipe3d, "leagueID"))
  992.     db.player[idx].jerseyNameLayout = getKitNameCurve(db.player[idx].kit,db.player[idx].speckitType,db.player[idx].jerseyNameLayout,db.player[idx].tournidnum,as:GetInt(wipe3d, "leagueID"))
  993.     db.player[idx].jerseyCollarType = getKitCollar(db.player[idx].kit,db.player[idx].speckitType,db.player[idx].jerseyCollarType,db.player[idx].tournidnum,as:GetInt(wipe3d, "leagueID"))
  994.     db.player[idx].jerseyfit = getKitFit(db.player[idx].kit,db.player[idx].speckitType,db.player[idx].jerseyfit,db.player[idx].tournidnum,db.player[idx].playerassetid,as:GetInt(wipe3d, "leagueID"))
  995.     end
  996.    
  997.    
  998.  
  999.     --REF KIT COLLAR
  1000.     if (db.player[idx].kitType == 5) then
  1001.     db.player[idx].jerseyCollarType = getTournamentRefereeKitsCollar(db.player[idx].tournidref,db.player[idx].jerseyCollarType,db.player[idx].defaulttournid)
  1002.     end
  1003.    
  1004.     --GK PANTS
  1005.     db.player[idx].shortstyle = getGKPants(db.player[idx].playerassetid,db.player[idx].shortstyle,db.player[idx].speckitType,weather,climate)
  1006.    
  1007.     --JERSEY TUCK
  1008.     db.player[idx].jerseyTucked = getJerseyTuck(db.player[idx].playerassetid,db.player[idx].jerseyTucked)
  1009.    
  1010.     --SOCK HEIGHT
  1011.     db.player[idx].socklength = getSockHeight(db.player[idx].playerassetid,db.player[idx].socklength)
  1012.    
  1013.     --ARMBAND
  1014.     db.player[idx].jerseyArmBandCustom = -1
  1015.     if (db.player[idx].jerseyArmBand == 1) then
  1016.     db.player[idx].jerseyArmBandCustom = getArmbandModel(db.player[idx].playerassetid,db.player[idx].jerseyArmBand)
  1017.     end
  1018.    
  1019.    
  1020.    
  1021.  
  1022.     --RANDOM BOOT
  1023.     db.player[idx].bootrand = math.random(0,3)
  1024.     db.player[idx].bootname = getPlayerShoe(db.player[idx].playerassetid,"-1")
  1025.    
  1026.     if (type(db.player[idx].bootname) == "number") then
  1027.     db.player[idx].shoeType = db.player[idx].bootname
  1028.     db.player[idx].shoeDesign = 0
  1029.     end
  1030.    
  1031.     --RANDOM FACE
  1032.     db.player[idx].facerand = math.random(0,3)
  1033.    
  1034.     --CROWD FIX
  1035.     -- db.player[idx].crowd = ""
  1036.     -- if (idx < 2) then
  1037.     -- db.player[idx].crowd = "xxx"
  1038.     -- end
  1039.    
  1040.    
  1041.     db.player[idx].shortstyle = getTournamentShorts(db.player[idx].kit,db.player[idx].kitType,db.player[idx].tournid,db.player[idx].shortstyle)
  1042.    
  1043.    
  1044.     db.player[idx].shirtid = 1
  1045.    
  1046.     if (db.player[idx].teamside == 0) then
  1047.     if (idx < 19) then
  1048.     db.player[idx].shirtid = idx - 7
  1049.     else
  1050.     if (db.player[idx].isgoalie == 1) then
  1051.     db.player[idx].shirtid = 12
  1052.     else
  1053.     db.player[idx].shirtid = idx - 17
  1054.     end
  1055.     end
  1056.     end
  1057.    
  1058.     if (db.player[idx].teamside == 1) then
  1059.     if (idx < 30) then
  1060.     db.player[idx].shirtid = idx - 18
  1061.     else
  1062.     if (db.player[idx].isgoalie == 1) then
  1063.     db.player[idx].shirtid = 12
  1064.     else
  1065.     db.player[idx].shirtid = idx - 29
  1066.     end
  1067.     end
  1068.     end
  1069.    
  1070.    
  1071.    
  1072.     --TRACKSUIT MODE
  1073.     if (trackSuitMode) then
  1074.     db.player[idx].jerseyCollarType = -1
  1075.     db.player[idx].jerseySleeveLength  = -1
  1076.     db.player[idx].underneck = -1
  1077.     db.player[idx].underarms = -1
  1078.     db.player[idx].armLength = 1
  1079.     db.player[idx].shortstyle = -1
  1080.     db.player[idx].socklength = -1
  1081.     db.player[idx].cold = 1
  1082.     end
  1083.    
  1084.     if (bibMode) then
  1085.     db.player[idx].cold = 0
  1086.     end
  1087.    
  1088.    
  1089.    
  1090.    
  1091.    
  1092.    
  1093.    
  1094.    
  1095.    
  1096.    
  1097.     -- Seasonal Assets --
  1098.     -- These exist only here and not in the code:
  1099.     local seasonal = as:GetInt(player, "seasonaljersey")
  1100.    
  1101.     db.player[idx].useTextureComposition = as:GetInt(player, "useTextureComposition")
  1102.    
  1103.     --GET ACCESSORY WEATHER
  1104.     local winterAcc = getWinterAccessoriesWeather(weather,climate)
  1105.     db.player[idx].useWinterAcc = -1
  1106.     if (winterAcc) then
  1107.     db.player[idx].useWinterAcc = 1
  1108.     end
  1109.    
  1110.     --GET PLAYER WINTER ACCESSORIES
  1111.     if (db.player[idx].kitType == 5) then
  1112.     seasonal = getRefereeWinterAccessories(seasonal)
  1113.     end
  1114.     seasonal = getWinterAccessories(db.player[idx].playerassetid,seasonal)
  1115.    
  1116.     --SLEEVE LENGTH
  1117.     db.player[idx].jerseySleeveLength = getSleeveLength(db.player[idx].playerassetid,db.player[idx].jerseySleeveLength)
  1118.  
  1119.     if (db.player[idx].isVirtualPro == 1 or db.player[idx].isCreatePlayer == 1) then
  1120.     if ((seasonal < 0) or (seasonal > 4)) then
  1121.     seasonal = db.player[idx].jerseySleeveLength
  1122.     end
  1123.     end
  1124.    
  1125.    
  1126.         -- if ((getWinterAccessories(db.player[idx].playerassetid,seasonal) ~= nil) and winterAcc)
  1127.    
  1128.         -- if ((seasonal < 2) and not) then
  1129.             -- seasonal = db.player[idx].jerseySleeveLength
  1130.         -- end
  1131.     --elseif(db.player[idx].cold == 0) then
  1132.     --elseif (not winterAcc) then
  1133.     if (not winterAcc) then
  1134.         seasonal = db.player[idx].jerseySleeveLength
  1135.     end
  1136.    
  1137.     seasonal = getSleeveAndUndershirtType(db.player[idx].playerassetid,weather,climate,seasonal)
  1138.    
  1139.     if ((kitYearOutfield > 0) and (seasonal > 1)) then
  1140.     if (kitYearOutfield <= classicKitUndershirtYear) then
  1141.     if (seasonal == 2) then
  1142.     seasonal = 1
  1143.     else
  1144.     seasonal = 0
  1145.     end
  1146.     end
  1147.     end
  1148.    
  1149.     if (kitYearOutfield > 0) then
  1150.     if (db.player[idx].isgoalie == 1) then
  1151.     if (kitYearOutfield <= classicKitShortSleevesGKYear) then
  1152.     seasonal = 1
  1153.     end
  1154.     else
  1155.     if (kitYearOutfield <= classicKitShortSleevesOutfieldYear) then
  1156.     seasonal = 1
  1157.     end
  1158.     end
  1159.     end
  1160.    
  1161.    
  1162.     --FOURTH OFFICIAL
  1163.     db.player[idx].fourthofficialoption = getFourthOfficialKitType(weather,climate)
  1164.    
  1165.     if (db.player[idx].fourthofficialoption > 0) then
  1166.     if (idx == 57) then
  1167.     db.player[idx].jerseyCollarType = 0
  1168.     seasonal = 1
  1169.     db.player[idx].jerseyTucked = 1
  1170.     if (db.player[idx].fourthofficialoption == 2) then
  1171.     db.player[idx].shortstyle = 1
  1172.     end
  1173.     end
  1174.     end
  1175.    
  1176.    
  1177.    
  1178.  
  1179.     if (seasonal == 0) then
  1180.         -- Short Sleeves
  1181.         db.player[idx].jerseySleeveLength  = 0
  1182.         db.player[idx].underneck = -1
  1183.         db.player[idx].underarms = -1
  1184.         db.player[idx].armLength = 0
  1185.     elseif (seasonal == 1) then
  1186.         -- Long Sleeves
  1187.         db.player[idx].jerseySleeveLength  = 1
  1188.         db.player[idx].underneck = -1
  1189.         db.player[idx].underarms = -1
  1190.         db.player[idx].armLength = 1
  1191.     elseif (seasonal == 2) then
  1192.         -- Long Sleeves and just underarmor neck
  1193.         db.player[idx].jerseySleeveLength = 1
  1194.         db.player[idx].underneck = 0
  1195.         db.player[idx].underarms = -1
  1196.         db.player[idx].armLength = 1
  1197.     elseif (seasonal == 3) then
  1198.         -- Short sleeves with underarmor arms no neck
  1199.         db.player[idx].jerseySleeveLength  = 0
  1200.         db.player[idx].underneck = -1
  1201.         db.player[idx].underarms = 0
  1202.         db.player[idx].armLength = 1
  1203.     elseif (seasonal == 4) then
  1204.         -- Short sleeves with underarmor neck and arms
  1205.         db.player[idx].jerseySleeveLength  = 0
  1206.         db.player[idx].underneck = 0
  1207.         db.player[idx].underarms = 0
  1208.         db.player[idx].armLength = 1
  1209.     end
  1210.  
  1211.     if (db.player[idx].cold > 0 or db.player[idx].isVirtualPro == 1 or db.player[idx].isCreatePlayer == 1) then
  1212.         db.player[idx].undershorts = 0
  1213.     else
  1214.         db.player[idx].undershorts = -1
  1215.     end
  1216.    
  1217.     --UNDERSHORTS
  1218.     db.player[idx].undershorts = getUndershorts(db.player[idx].playerassetid,db.player[idx].undershorts,kitYearOutfield,db.player[idx].kit)
  1219.  
  1220.     -- end of seasonal assets
  1221.  
  1222.     -- check if we need to force underwear for injuries
  1223.     if ( db.player[idx].forceunderarm == 1 ) then
  1224.         db.player[idx].jerseySleeveLength = 0
  1225.         db.player[idx].underarms = 0
  1226.         db.player[idx].armLength = 1
  1227.     end
  1228.  
  1229.     if ( db.player[idx].forceundershorts == 1 ) then
  1230.         db.player[idx].undershorts = 0
  1231.     end
  1232.  
  1233.     if ( db.player[idx].forceunderneck == 1 ) then
  1234.         db.player[idx].underneck = 0
  1235.     end
  1236.  
  1237.     -- Goalie long pants, turn off necessary assets.
  1238.     if( db.player[idx].shortstyle == 1 ) then
  1239.         db.player[idx].socklength = -1
  1240.         db.player[idx].undershorts = -1
  1241.     end
  1242.  
  1243.     db.player[idx].useTextureComposition = as:GetInt(player, "useTextureComposition")
  1244.  
  1245.     -- Females will not have tight jersey fit
  1246.     if (db.player[idx].gender == 1) then
  1247.         db.player[idx].jerseyfit = 0
  1248.        
  1249.     end
  1250.    
  1251.    
  1252.     if (((db.player[idx].isCreationZone == 0) and (db.player[idx].kitType ~= 5)) and (db.player[idx].speckitType < 91)) then
  1253.     --db.player[idx].sponsorAssetId = 1 --TEMP
  1254.     db.player[idx].sponsorcolour = 0xFFFFFFFF
  1255.     db.player[idx].hotspotJerseySponsorL = 0
  1256.     db.player[idx].hotspotJerseySponsorT = 0
  1257.     db.player[idx].hotspotJerseySponsorR = 1
  1258.     db.player[idx].hotspotJerseySponsorB = 1
  1259.     db.player[idx].useTextureComposition = 1
  1260.     end
  1261.    
  1262.     local crowd = as:GetTable("wvCrowd", 1)
  1263.     db.player[idx].crowdDistribution = as:GetInt(crowd, "crowdDistribution")
  1264.    
  1265.    
  1266.  
  1267.    
  1268.    
  1269.     db.player[idx].genTexString = db.player[idx].speckitType.."_"..db.player[idx].speckitTypeShort.."_"..db.player[idx].speckitTypeSock.."_"..db.player[idx].tournid.."_"..db.player[idx].crowdDistribution.."_"..db.player[idx].gender
  1270.     if (getIndividualKitsTeam(db.player[idx].kit,db.player[idx].kitType,db.player[idx].tournid,kitYearOutfield)) then
  1271.     db.player[idx].genTexString = db.player[idx].genTexString.."_"..db.player[idx].playerassetid.."_"..idx
  1272.     end
  1273.    
  1274.     --0-13
  1275.     --0,1,3,4,10
  1276.     -- db.player[idx].kit = as:GetInt(state, "wvAttribSkyID")
  1277.     -- db.player[idx].kitType = as:GetInt(state, "wvAttribSkyCategory")
  1278.    
  1279.     -- if (db.player[idx].kit == 0) then
  1280.     -- db.player[idx].kit = 21
  1281.     -- end
  1282.     -- if (db.player[idx].kit == 6) then
  1283.     -- db.player[idx].kit = 22
  1284.     -- end
  1285.    
  1286.     -- if (db.player[idx].kitType == 4) then
  1287.     -- db.player[idx].kitType = 2
  1288.     -- end
  1289.    
  1290.     -- db.player[idx].genkit = db.player[idx].kit
  1291.    
  1292.    
  1293.     -- db.player[idx].isfinal = getTournamentFinal(db.player[idx].tournid,db.player[idx].stadiumID,crowdDistribution)
  1294.    
  1295.     -- db.player[idx].kit = idx
  1296.     -- db.player[idx].kitType = 0
  1297.    
  1298.     --db.player[idx].cold = 0
  1299.     -- col1 = "000000"
  1300.     -- col2 = "FFFFFF"
  1301.    
  1302. -- r1 = tonumber(string.sub(col1,1,2),16)
  1303. -- g1 = tonumber(string.sub(col1,3,4),16)
  1304. -- b1 = tonumber(string.sub(col1,5,6),16)
  1305.  
  1306. -- r2 = tonumber(string.sub(col2,1,2),16)
  1307. -- g2 = tonumber(string.sub(col2,3,4),16)
  1308. -- b2 = tonumber(string.sub(col2,5,6),16)
  1309.  
  1310. -- val = math.sqrt(math.pow((r1-r2),2)+math.pow((g1-g2),2)+math.pow((b1-b2),2))
  1311.  
  1312.  
  1313.    
  1314.     --colx1 = getShirt1Colour(db.player[idx].kit,db.player[idx].kitType,db.player[idx].tournidkit,kitYearOutfield)
  1315.  
  1316.     -- homecolour1 = getShirt1Colour(db.player[idx].homeKitTeamID,db.player[idx].homeKitTypeID,db.player[idx].tournidkit,kitYearOutfield)
  1317.     -- awaycolour1 = getShirt1Colour(db.player[idx].awayKitTeamID,db.player[idx].awayKitTypeID,db.player[idx].tournidkit,kitYearOutfield)
  1318.    
  1319.     -- if (getColourDistance(homecolour1,awaycolour1) < 100) then
  1320.     -- db.player[idx].kitType = 2
  1321.     -- end
  1322.    
  1323.     -- homecolour1 = getShirt1Colour(db.player[idx].homeKitTeamID,db.player[idx].homeKitTypeID,db.player[idx].tournidkit,kitYearOutfield)
  1324.     -- homecolour2 = getShirt2Colour(db.player[idx].homeKitTeamID,db.player[idx].homeKitTypeID,db.player[idx].tournidkit,kitYearOutfield)
  1325.     -- awaycolour1 = getShirt1Colour(db.player[idx].awayKitTeamID,db.player[idx].awayKitTypeID,db.player[idx].tournidkit,kitYearOutfield)
  1326.     -- awaycolour2 = getShirt2Colour(db.player[idx].awayKitTeamID,db.player[idx].awayKitTypeID,db.player[idx].tournidkit,kitYearOutfield)
  1327.    
  1328.    
  1329.    
  1330.    
  1331.     -- if (idx == 8) then
  1332.     -- if (db.player[idx].kitType == 2) then
  1333.     --db.player[idx].speckitType = getGKKitColour(db.player[idx].homeKitTeamID,db.player[idx].awayKitTeamID,db.player[idx].homeKitTypeID,db.player[idx].awayKitTypeID,team1tourn,team2tourn,team1year,team2year)
  1334.    
  1335.    
  1336.     -- end
  1337.     -- end
  1338.    
  1339.    
  1340.    
  1341.    
  1342.    
  1343.  
  1344.    
  1345.    
  1346.    
  1347.    
  1348.     -- db.player[idx].kit = db.player[idx].kit%10
  1349.     -- db.player[idx].kitType = 0
  1350.  
  1351.    
  1352. -- if (idx == 54) then
  1353.     -- db.player[idx].kit = getRefereeKitColour(db.player[idx].homeKitTeamID,db.player[idx].awayKitTeamID,db.player[idx].homeKitTypeID,db.player[idx].awayKitTypeID,db.player[idx].tournidkit,db.player[idx].tournidkit,kitYearOutfield,kitYearOutfield,db.player[idx].kit,db.player[idx].tournid)
  1354.     -- end
  1355.    
  1356.    
  1357.    
  1358.  
  1359.    
  1360.    
  1361.     db.player[idx].overlayoffset = getKitOverlayVarient(db.player[idx].kit)
  1362.  
  1363.    
  1364.    
  1365.     --db.player[idx].speckitType = db.player[idx].bibType
  1366.    
  1367.    
  1368.     -- if (idx == 0) then
  1369.     -- homeid = 0
  1370.     -- awayid = 0
  1371.     -- --hometype = 0
  1372.     -- awaytype = 0
  1373.     -- end
  1374.    
  1375.     -- if (idx > 7) then
  1376.     -- if (homeid == 0) then
  1377.     -- homeid = math.random(14)
  1378.     -- hometype = hometype + 1
  1379.     -- end
  1380.     -- end
  1381.    
  1382.     -- db.player[idx].kit = homeid
  1383.     -- --db.player[idx].speckitType = 99999999
  1384.     -- db.player[idx].kitType = hometype
  1385.    
  1386.    
  1387.    
  1388.    
  1389.     -- if (db.player[idx].tournid < 0) then
  1390.     -- db.player[idx].kitNumberTens = -1
  1391.     -- db.player[idx].kitNumberUnits = -1
  1392.     -- else
  1393.     -- local xb = tostring(db.player[idx].tournid)
  1394.     -- if (idx > 7) then
  1395.     -- if (string.len(xb) > idx-8) then
  1396.     -- db.player[idx].kitNumberTens = -1
  1397.     -- db.player[idx].kitNumberUnits = tonumber(string.sub(xb,idx-7,idx-7))
  1398.     -- else
  1399.     -- db.player[idx].kitNumberTens = -1
  1400.     -- db.player[idx].kitNumberUnits = -1
  1401.     -- end
  1402.     -- end
  1403.     -- end
  1404.    
  1405.    
  1406.    
  1407.    
  1408.    
  1409.     --Force Players As Female
  1410.     if (forceFemale) then
  1411.     if (idx < 54) then
  1412.     if ((db.player[idx].kit < 112998) or (db.player[idx].kit > 113012)) then
  1413.     if ((db.player[idx].gender == 0) or ((db.player[idx].head < 5500) and (db.player[idx].headClass == 1))) then
  1414.     db.player[idx].gender = 1
  1415.     db.player[idx].strgender = "female"
  1416.     db.player[idx].jerseyfit = 0
  1417.    
  1418.     db.player[idx].head = 5500
  1419.     db.player[idx].eyebrow = 4
  1420.     --db.player[idx].faceType = 5500
  1421.     db.player[idx].facialHairType = 0
  1422.     db.player[idx].headSkinType = 5
  1423.     db.player[idx].headSkinToneType = db.player[idx].bodySkinToneType
  1424.  
  1425.     db.player[idx].hair = 512
  1426.     db.player[idx].headClass = 1
  1427.     db.player[idx].faceProxyHeadClass = 1
  1428.     db.player[idx].hairColor = as:GetInt(player, "hairColor")
  1429.     db.player[idx].facialHairColor = as:GetInt(player, "facialHairColor")
  1430.     db.player[idx].compsuffix = ".rx3"
  1431.     db.player[idx].dxttype = "dxt1"
  1432.     db.player[idx].useFaceTextureComposition = 1
  1433.    
  1434.     if(db.player[idx].headSkinToneType == 1 or db.player[idx].headSkinToneType == 3 or db.player[idx].headSkinToneType == 7) then
  1435.             db.player[idx].headSkinToneType = db.player[idx].headSkinToneType + 1
  1436.         end
  1437.    
  1438.     db.player[idx].playerassetid = -1
  1439.     end
  1440.     end
  1441.     end
  1442.     end
  1443.    
  1444.    
  1445.    
  1446.    
  1447.     --Female Hair Physics Fix
  1448.     db.player[idx].generichair = -1
  1449.     db.player[idx].genericfaceProxyHeadClass = -1
  1450.     if (db.player[idx].gender == 1) then
  1451.     db.player[idx].generichair = as:GetInt(player, "hair")
  1452.     db.player[idx].genericfaceProxyHeadClass = 1
  1453.     end
  1454.    
  1455.    
  1456.  
  1457.    
  1458.  
  1459.    
  1460. end
  1461.  
  1462. ---------------------------------------------------------------------------------------------------
  1463. -- Get hair color for generic hair recoloring
  1464. function GetHairColorARGB(idx)
  1465.     hairColourList = { 0x00edac57, 0x000e0e0d, 0x00a07741, 0x001f160e,
  1466.                        0x00ffd286, 0x006e4d2b, 0x003b2816, 0x00782c08,
  1467.                        0x00c8c9cf, 0x00525355, 0x00345a34, 0x00263f67,
  1468.                        0x00f62f0a }
  1469.  
  1470.     local clr = 0x00FF0000
  1471.     if (db.player[idx].headClass > 0) then
  1472.         clr = hairColourList[db.player[idx].hairColor + 1]
  1473.         if (clr == nil) then
  1474.             clr = 0x00FF0000
  1475.         end
  1476.         clr = getGenericHairColour(db.player[idx].playerassetid,clr)
  1477.     else
  1478.         clr = 0x00808080
  1479.     end
  1480.     return clr
  1481. end
  1482.  
  1483. ---------------------------------------------------------------------------------------------------
  1484. function GetSkinTexture(idx)
  1485.    
  1486.     local skintexture = "data/sceneassets/tattoo/tattoo_${db.player[?].playerassetid}_0.rx3;data/sceneassets/body/skin_${db.player[?].bodySkinToneType}_${db.player[?].gender}_textures.rx3"
  1487.    
  1488.     -- TODO: hardcoded for messi for now.
  1489.     -- if(db.player[idx].playerassetid == 158023) then
  1490.         -- return "data/sceneassets/tattoo/tattoo_${db.player[?].playerassetid}_${db.player[idx].headClass}.rx3;" .. skintexture
  1491.     -- end
  1492.  
  1493.     return skintexture
  1494. end
  1495.  
  1496. ---------------------------------------------------------------------------------------------------
  1497. function EASWMorphFile(idx)
  1498.     if (db.player[idx].isVirtualPro == 1) then
  1499.         return string.format("data/easw/deltas.easwmorph") --12366)
  1500.     else
  1501.         return "dummyasset.easwmorph"
  1502.     end
  1503. end
  1504.  
  1505. ---------------------------------------------------------------------------------------------------
  1506. function GetHeadAndHairAssetType(idx)
  1507.     if (db.player[idx].isCreatePlayer == 1) then
  1508.         return "cloneasset"
  1509.     else
  1510.         return ""
  1511.     end
  1512. end
  1513.  
  1514. ---------------------------------------------------------------------------------------------------
  1515. function MorphFile(idx)
  1516.     if (db.player[idx].isCreatePlayer == 1 and db.player[idx].isVirtualPro == 0) then
  1517.         return "data/sceneassets/createplayer/head_0_2_0_1_morphtargets.rx3"
  1518.     else
  1519.         return "dummyasset.rx3"
  1520.     end
  1521. end
  1522.  
  1523. ---------------------------------------------------------------------------------------------------
  1524. function PlayerAssetShadow(player, lod)
  1525.     local gr = gRenderables
  1526.     gr:AddAsset(player, lod, "shadow", "data/sceneassets/body/playershadow_5_1_0.rx3")
  1527.     gr:CreateMaterial(player, lod, "shadow", "missingShader.fx")
  1528. end
  1529.  
  1530. ---------------------------------------------------------------------------------------------------
  1531. function GetCrestAsset(idx)
  1532.     if (db.player[idx].isCreationZone == 1) then
  1533.         if (db.player[idx].hasCzCrestImage > 0) then
  1534.             -- // The "\\" is so that the mounted image can be found properly by Apt
  1535.             return "data\\ugc/cz_crest/${db.player[?].crestAssetId}.png;data/ugc/cz_crest/1.png"
  1536.         else
  1537.             return "data/sceneassets/crest/crest_${db.player[?].crestAssetId}.rx3"
  1538.         end
  1539.     else
  1540.         return "${GetRMKit(?,0)}"
  1541.     end
  1542.  
  1543. end
  1544.  
  1545. ---------------------------------------------------------------------------------------------------
  1546. function GetSkinTone(idx, lod)
  1547.     local useLight = false
  1548.     if (db.player[idx].isVirtualPro == 1) then
  1549.         -- // 0 is light, 1 is dark
  1550.         useLight = ( db.player[idx].faceGenSkinToneType == 0 )
  1551.     else
  1552.         useLight = ( db.player[idx].bodySkinToneType < 5 )
  1553.     end
  1554.  
  1555.     if ( useLight ) then
  1556.         return ( lod == 0 ) and "skin_light" or "skin_lod_light"
  1557.     else
  1558.         return ( lod == 0 ) and "skin_dark" or "skin_lod_dark"
  1559.     end
  1560. end
  1561.  
  1562. ---------------------------------------------------------------------------------------------------
  1563. function GetFaceTone(idx, lod)
  1564.     local useLight = false
  1565.     if (db.player[idx].isVirtualPro == 1) then
  1566.         -- // 0 is light, 1 is dark
  1567.         useLight = ( db.player[idx].faceGenSkinToneType == 0 )
  1568.     else
  1569.         useLight = ( db.player[idx].bodySkinToneType < 5 )
  1570.     end
  1571.  
  1572.     if ( useLight ) then
  1573.         return ( lod == 0 ) and "face_light" or "face_lod_light"
  1574.     else
  1575.         return ( lod == 0 ) and "face_dark" or "face_lod_dark"
  1576.     end
  1577. end
  1578.  
  1579. -- these values match those in player.cpp
  1580. -- local VISIBILITY_GROUP_DEFAULT               = 1
  1581. -- local VISIBILITY_GROUP_JACKET                = "${GetRMTracksuitOption()}" -- visible on the bench, but not in game
  1582. -- local VISIBILITY_GROUP_JERSEY_ARMBAND        = "${GetRMBibOption(4)}"
  1583. -- local VISIBILITY_GROUP_JERSEY_NOARMBAND      = "${GetRMBibOption(8)}"
  1584. -- local VISIBILITY_GROUP_SHORTS                = "${GetRMBibOption(16)}"
  1585. -- local VISIBILITY_GROUP_HAIR                  = 32
  1586. -- local VISIBILITY_GROUP_INGAME                = "${GetRMBibOption(64)}" -- for parts visible in game, but not on the bench
  1587. -- local VISIBILITY_GROUP_LEGS                  = "${GetRMBibOption(128)}" -- socks, legs, and underwear, turn this stuff off when the player is wearing track pants, need a better name for this
  1588. local VISIBILITY_GROUP_DEFAULT              = 1
  1589. local VISIBILITY_GROUP_JACKET               = 2 -- visible on the bench, but not in game
  1590. local VISIBILITY_GROUP_JERSEY_ARMBAND       = 4
  1591. local VISIBILITY_GROUP_JERSEY_NOARMBAND     = 8
  1592. local VISIBILITY_GROUP_SHORTS               = 16
  1593. local VISIBILITY_GROUP_HAIR                 = 32
  1594. local VISIBILITY_GROUP_INGAME               = 64 -- for parts visible in game, but not on the bench
  1595. local VISIBILITY_GROUP_LEGS                 = 128 -- socks, legs, and underwear, turn this stuff off when the player is wearing track pants, need a better name for this
  1596. ---------------------------------------------------------------------------------------------------
  1597. function PlayerAssetHighLod(player, lod)
  1598.     local gr = gRenderables
  1599.  
  1600.     local priority = 0  -- default priority
  1601.  
  1602.  
  1603.     -- rigamate assets
  1604.     gr:AddAsset(player, lod, "rigamatebody_rbo", "data/sceneassets/rigamate/player_rigamate_body_lod"..(lod).."_${db.player[?].strgender}.rbo")
  1605.     gr:AddAsset(player, lod, "rigamateface_rbo", "data/sceneassets/rigamate/player_rigamate_face_${db.player[?].strgender}.rbo")
  1606.     gr:AddAsset(player, lod, "rigamateface_rbt", "data/sceneassets/rigamate/fp_tuning_${db.player[?].head}_${db.player[?].headClass}.rbt;data/sceneassets/rigamate/fp_tuning_0_0.rbt")
  1607.     gr:AddAsset(player, lod, "rigamatejersey_wrinkle_rbo", "data/sceneassets/rigamate/player_rigamate_jersey_wrinkle_${db.player[?].strgender}.rbo")
  1608.     gr:AddAsset(player, lod, "rigamate_face_wrinkle_rbo", "data/sceneassets/rigamate/player_rigamate_face_wrinkle_${db.player[?].strgender}.rbo")
  1609.  
  1610.     -- GEO's
  1611.     gr:AddAsset(player, lod, "jersey_noarmband", "data/sceneassets/body/jersey_"..(lod).."_${db.player[?].jerseyCollarType}_${db.player[?].jerseySleeveLength}_0_${db.player[?].jerseyTucked}_${db.player[?].jerseyfit}_${db.player[?].gender}.rx3", priority, ASSET_MAKE_CPU_COPY)
  1612.     gr:AddAsset(player, lod, "jersey_armband", "${GetRMArmbandModel(?,"..(lod)..")}data/sceneassets/body/jersey_"..(lod).."_${db.player[?].jerseyCollarType}_${db.player[?].jerseySleeveLength}_${db.player[?].jerseyArmBand}_${db.player[?].jerseyTucked}_${db.player[?].jerseyfit}_${db.player[?].gender}.rx3", priority, ASSET_MAKE_CPU_COPY)
  1613.     gr:AddAsset(player, lod, "arms", "data/sceneassets/body/arms_"..(lod).."_${db.player[?].armLength}_${db.player[?].gender}.rx3")
  1614.     gr:AddAsset(player, lod, "shorts", "${GetRMShortModel(?,"..(lod)..")}data/sceneassets/body/shorts_"..(lod).."_${db.player[?].shortstyle}_${db.player[?].gender}.rx3", priority, ASSET_MAKE_CPU_COPY)
  1615.     gr:AddAsset(player, lod, "shoes",  "${GetRMBoot(?,0)}data/sceneassets/shoe/shoe_${db.player[?].shoeType}.rx3;data/sceneassets/shoe/shoe_15.rx3")
  1616.     gr:AddAsset(player, lod, "socks", "data/sceneassets/body/sock_"..(lod).."_${db.player[?].socklength}_${db.player[?].gender}.rx3")
  1617.     gr:AddAsset(player, lod, "legs",  "data/sceneassets/body/legs_"..(lod).."_${db.player[?].socklength}_${db.player[?].gender}.rx3")
  1618.     gr:AddAssetEx(player, lod, "${GetHeadAndHairAssetType(?)}", "hair1", "${GetRMHairMod(?)}data/sceneassets/hair/hair_${db.player[?].hair}_${db.player[?].faceProxyHeadClass}_0.rx3", priority, ASSET_MAKE_CPU_COPY)
  1619.     gr:AddAssetEx(player, lod, "${GetHeadAndHairAssetType(?)}", "hair2", "${GetRMHairMod(?)}data/sceneassets/hair/hair_${db.player[?].hair}_${db.player[?].faceProxyHeadClass}_0.rx3", priority, ASSET_MAKE_CPU_COPY)
  1620.     gr:AddAssetEx(player, lod, "${GetHeadAndHairAssetType(?)}", "head",  "${GetRMFaceMod(?)}data/sceneassets/heads/head_${db.player[?].head}_${db.player[?].headClass}.rx3", priority, ASSET_MAKE_CPU_COPY)
  1621.     -- Point the eyes to the same asset the head uses, whether it being cloned or not.
  1622.     gr:AddAssetEx(player, lod, "fromasset", "eyes", "head")
  1623.  
  1624.     -- Add the morph files
  1625.     local temporary = 1 -- mark as temporary asset
  1626.     gr:AddAsset(player, lod, "morphhead", "${MorphFile(?)}", priority, ASSET_NO_COPY, temporary)
  1627.     gr:AddAsset(player, lod, "easwmorph", "${EASWMorphFile(?)}")
  1628.    
  1629.     skinTone = "${GetSkinTone(?,"..lod..")}"
  1630.  
  1631.  
  1632.     part = "arms"
  1633.     gr:CreateMaterialFromAttribulator(player, lod, part, "body_material",  skinTone)
  1634.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "skintex", "body_")
  1635.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1636.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  1637.     gr:SetTexture(player, lod, part, "textures", "normalMap", "bodycmn", "body_nm")
  1638.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "bodycmn", "body_coeff")
  1639.     gr:SetTexture(player, lod, part, "textures", "dirtMapArray", "bodydk", "body_dk")
  1640.     gr:SetTexture(player, lod, part, "textures", "dirtMaskTexture", "bodydk", "body_region")
  1641.     gr:SetTextureFromRuntime(player, lod, part, "textures", "skin_brdf", "skinbrdf_texture")
  1642.     gr:SetTextureFromRuntime(player, lod, part, "textures", "skin_indirect_brdf", "skinindirectbrdf_texture")
  1643.     gr:SetConstantARGB(player, lod, part, "global", "skincolor", "${db.player[?].playerBodySkinColor}")
  1644.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1645.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1646.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1647.  
  1648.     part = "legs"
  1649.     gr:CreateMaterialFromAttribulator(player, lod, part, "body_material", skinTone )
  1650.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "skintex", "body_")
  1651.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1652.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  1653.     gr:SetTexture(player, lod, part, "textures", "normalMap", "bodycmn", "body_nm")
  1654.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "bodycmn", "body_coeff")
  1655.     gr:SetTexture(player, lod, part, "textures", "dirtMapArray", "bodydk", "body_dk")
  1656.     gr:SetTexture(player, lod, part, "textures", "dirtMaskTexture", "bodydk", "body_region")
  1657.     gr:SetTextureFromRuntime(player, lod, part, "textures", "skin_brdf", "skinbrdf_texture")
  1658.     gr:SetTextureFromRuntime(player, lod, part, "textures", "skin_indirect_brdf", "skinindirectbrdf_texture")
  1659.     gr:SetConstantARGB(player, lod, part, "global", "skincolor", "${db.player[?].playerBodySkinColor}")
  1660.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1661.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1662.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1663.     gr:SetVisibilityGroup(player, lod, part, VISIBILITY_GROUP_LEGS)
  1664.  
  1665.     -- hair1
  1666.     part = "hair1"
  1667.     gr:CreateMaterialFromAttribulator(player, lod, part, "hair_material", "${AttribMaterial('player_hair_kk_alphaA')}")
  1668.     gr:SetSubMesh(player, lod, part, "alphaA")
  1669.     gr:SetPriority(player, lod, part, 1)             -- haircap render before hair 2
  1670.     gr:SetSelfShadowAlpha(player, lod, part)          -- will use different self shadow shader that accounts for alpha
  1671.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "hairtex", "hair_cm")
  1672.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "hairtex", "hair_coeff")
  1673.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1674.     gr:SetConstantARGB(player, lod, part, "global", "hairColor", "${GetHairColorARGB(?)}")
  1675.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1676.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1677.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1678.  
  1679.     -- hair2
  1680.     part = "hair2"
  1681.     gr:CreateMaterialFromAttribulator(player, lod, part, "hair_material2", "${AttribMaterial('player_hair_kk_alphaB')}")
  1682.     gr:SetSubMesh(player, lod, part, "alphaB")
  1683.     gr:SetPriority(player, lod, part, 2)             -- strands render after hair 1
  1684.     gr:SetSelfShadowAlpha(player, lod, part)          -- will use different self shadow shader that accounts for alpha
  1685.     --gr:DisableSelfShadow(player, lod, part)          -- Don't render the hairstrands into the selfshadow.
  1686.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "hairtex", "hair_cm")
  1687.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "hairtex", "hair_coeff")
  1688.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1689.     gr:SetConstantARGB(player, lod, part, "global", "hairColor", "${GetHairColorARGB(?)}")
  1690.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1691.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1692.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1693.     gr:SetVisibilityGroup(player, lod, part, VISIBILITY_GROUP_HAIR)
  1694.    
  1695. end
  1696.  
  1697. ---------------------------------------------------------------------------------------------------
  1698. function PlayerAssetLowLod(player, lod)
  1699.     local gr = gRenderables
  1700.  
  1701.     skinLodTone = "${GetSkinTone(?,"..lod..")}"
  1702.  
  1703.     local priority = 0  -- default priority
  1704.  
  1705.     -- rigamate lod assets
  1706.     gr:AddAsset(player, lod, "rigamatebody_rbo", "data/sceneassets/rigamate/player_rigamate_body_lod"..(lod).."_${db.player[?].strgender}.rbo")
  1707.  
  1708.     -- GEO's
  1709.     gr:AddAsset(player, lod, "shorts", "${GetRMShortModel(?,"..(lod)..")}data/sceneassets/body/shorts_"..(lod).."_${db.player[?].shortstyle}_${db.player[?].gender}.rx3", priority, ASSET_MAKE_CPU_COPY)
  1710.     gr:AddAsset(player, lod, "bodyskinlod", "data/sceneassets/body/body_"..(lod).."_${db.player[?].armLength}_${db.player[?].gender}.rx3")
  1711.     gr:AddAsset(player, lod, "shoes", "${GetRMBoot(?,0)}data/sceneassets/body/shoes_"..(lod).."_${db.player[?].gender}.rx3")
  1712.     gr:AddAsset(player, lod, "socks", "data/sceneassets/body/sock_"..(lod).."_${db.player[?].socklength}_${db.player[?].gender}.rx3")
  1713.     gr:AddAsset(player, lod, "head",  "data/sceneassets/body/head_"..(lod).."_${db.player[?].gender}.rx3")
  1714.     gr:AddAsset(player, lod, "eyes",  "data/sceneassets/body/head_"..(lod).."_${db.player[?].gender}.rx3")
  1715.    
  1716.     if (lod == 1) then
  1717.         gr:AddAsset(player, lod, "jersey_noarmband", "data/sceneassets/body/jersey_"..(lod).."_${db.player[?].jerseyCollarType}_${db.player[?].jerseySleeveLength}_0_${db.player[?].jerseyTucked}_${db.player[?].jerseyfit}_${db.player[?].gender}.rx3", priority, ASSET_MAKE_CPU_COPY)
  1718.         gr:AddAsset(player, lod, "jersey_armband", "${GetRMArmbandModel(?,"..(lod)..")}data/sceneassets/body/jersey_"..(lod).."_${db.player[?].jerseyCollarType}_${db.player[?].jerseySleeveLength}_${db.player[?].jerseyArmBand}_${db.player[?].jerseyTucked}_${db.player[?].jerseyfit}_${db.player[?].gender}.rx3", priority, ASSET_MAKE_CPU_COPY)
  1719.        
  1720.     elseif (lod == 2) then
  1721.         gr:AddAsset(player, lod, "jersey_noarmband", "data/sceneassets/body/jersey_"..(lod).."_${db.player[?].jerseySleeveLength}_0_${db.player[?].jerseyTucked}_${db.player[?].gender}.rx3", priority, ASSET_MAKE_CPU_COPY)
  1722.         gr:AddAsset(player, lod, "jersey_armband", "${GetRMArmbandModel(?,"..(lod)..")}data/sceneassets/body/jersey_"..(lod).."_${db.player[?].jerseySleeveLength}_${db.player[?].jerseyArmBand}_${db.player[?].jerseyTucked}_${db.player[?].gender}.rx3", priority, ASSET_MAKE_CPU_COPY)
  1723.     end
  1724.  
  1725.     gr:AddAsset(player, lod, "hairlod",  "${GetRMHairModLod(?)}data/sceneassets/hairlod/hairlod_${db.player[?].hair}_${db.player[idx].faceProxyHeadClass}_0.rx3", priority, ASSET_MAKE_CPU_COPY)
  1726.  
  1727.     part = "bodyskinlod"
  1728.     gr:CreateMaterialFromAttribulator(player, lod, part, "body_material", skinLodTone )
  1729.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "skintex", "body_")
  1730.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1731.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  1732.     gr:SetTexture(player, lod, part, "textures", "normalMap", "bodycmn", "body_nm")
  1733.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "bodycmn", "body_coeff")
  1734.     gr:SetTexture(player, lod, part, "textures", "dirtMapArray", "bodydk", "body_dk")
  1735.     gr:SetTexture(player, lod, part, "textures", "dirtMaskTexture", "bodydk", "body_region")
  1736.     gr:SetConstantARGB(player, lod, part, "global", "skincolor", "${db.player[?].playerBodySkinColor}")
  1737.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1738.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1739.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1740.  
  1741.     -- hair
  1742.     part = "hairlod"
  1743.     gr:CreateMaterialFromAttribulator(player, lod, part, "hair_material", "${AttribMaterial('player_hair_kk_alphaA_lod')}")
  1744.     gr:SetSubMesh(player, lod, part, "alphaA")
  1745.     gr:SetPriority(player, lod, part, 1)
  1746.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "hairtex", "hair_cm")
  1747.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "hairtex", "hair_coeff")
  1748.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1749.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1750.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1751.     gr:SetConstantARGB(player, lod, part, "global", "hairColor", "${GetHairColorARGB(?)}")
  1752.  
  1753. end
  1754.  
  1755. ---------------------------------------------------------------------------------------------------
  1756. function PlayerCommonBinding(player, lod)
  1757.     local gr = gRenderables
  1758.  
  1759.     local lodString = (lod == 0) and "" or "lod"
  1760.  
  1761.     faceTone = "${GetFaceTone(?,"..lod..")}"
  1762.  
  1763.     -- head
  1764.     part = "head"
  1765.     gr:CreateMaterialFromAttribulator(player, lod, part, "head_material", faceTone )
  1766.     gr:SetSubMesh(player, lod, part, "head")
  1767.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "facetex", "${db.player[?].faceTexName}")
  1768.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "headcmn", "head_coeff")
  1769.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1770.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  1771.  
  1772.     gr:SetTextureFromRuntime(player, lod, part, "textures", "skin_brdf", "skinbrdf_texture")
  1773.     gr:SetTextureFromRuntime(player, lod, part, "textures", "skin_indirect_brdf", "skinindirectbrdf_texture")
  1774.    
  1775.    
  1776.     gr:SetTexture(player, lod, part, "textures", "specularScaleMap", "facespectex", "head_sk")
  1777.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1778.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1779.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1780.  
  1781.     gr:SetTexture(player, lod, part, "textures", "wrinkleMask", "headcmn", "head_mask_nm")
  1782.  
  1783.     -- Eyes
  1784.     part = "eyes"
  1785.     gr:CreateMaterialFromAttribulator(player, lod, part, "eye_material", "${AttribMaterial('eyes"..lodString.."')}" )
  1786.     gr:SetSubMesh(player, lod, part, "eyes")
  1787.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "eyetex", "eyes_cm")
  1788.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "headcmn", "eye_coeff")
  1789.  
  1790.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1791.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "env_")
  1792.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1793.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1794.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1795.     gr:SetTexture(player, lod, part, "textures", "normalMap", "headcmn", "eyes_nm")
  1796.     gr:SetTexture(player, lod, part, "textures", "eye_generic_ambient", "headcmn", "eyes_am")
  1797.     gr:SetTexture(player, lod, part, "textures", "eye_reflection", "headcmn", "eye_reflection")
  1798.  
  1799.     local part = "jersey_noarmband"
  1800.     gr:CreateMaterialFromAttribulator(player, lod, part, "jersey_material", "${AttribMaterial('jersey"..lodString.."')}" )
  1801.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "jersey_tex", "jersey_cm")
  1802.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "kittex_common", "jersey_coeff")
  1803.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_dry", "jerseyam_dry", "jersey_am")
  1804.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_wet", "jerseyam_wet", "jersey_am")
  1805.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1806.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  1807.     gr:SetTexture(player, lod, part, "textures", "weavePatternNormalMap", "cmnweave", "kit_weave_nm")
  1808.     gr:SetTexture(player, lod, part, "textures", "wrinkleMap", "jerseybnm", "jersey_nm")
  1809.     gr:SetTexture(player, lod, part, "textures", "jerseyPullMap", "jersey_pull_tex", "jersey_pull_mask")
  1810.  
  1811.     gr:SetTexture(player, lod, part, "textures", "dirtMapArray", "jerseydk", "jersey_dk")
  1812.     gr:SetTexture(player, lod, part, "textures", "dirtMaskTexture", "jerseydk", "jersey_region")
  1813.     gr:SetTexture(player, lod, part, "textures", "numberTens", "kitnumbers", GetRMNumberStringTens())
  1814.     gr:SetTexture(player, lod, part, "textures", "numberUnits", "kitnumbers", GetRMNumberStringUnits())
  1815.     gr:SetTexture(player, lod, part, "textures", "tex_decalmap", "cresttex", "${db.player[?].crestTexName}")
  1816.     gr:SetTextureFromRuntime(player, lod, part, "textures", "jerseyName", "namestamp${?}")
  1817.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1818.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1819.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1820.     gr:SetHotSpot(player, lod, part, "global", "jersey_decalBounds", "kithotspots", "jersey", "team")
  1821.     gr:SetHotSpot(player, lod, part, "global", "jersey_nameBound", "kithotspots", "jersey", "name")
  1822.     gr:SetHotSpot(player, lod, part, "global", "jersey_nameArcCenter", "kithotspots", "jersey", "name_arccenter")
  1823.     gr:SetConstantInt(player, lod, part, "global", "jersey_nameLayout", "${db.player[?].jerseyNameLayout}")
  1824.     gr:SetConstantARGB(player, lod, part, "global", "jersey_nameColor", "${db.player[?].kitNameColor}")
  1825.     gr:SetVisibilityGroup(player, lod, part, VISIBILITY_GROUP_JERSEY_NOARMBAND)
  1826.     gr:SetTexture(player, lod, part, "textures", "twistMaskTexture", "jerseywrinklemask", "jersey_twist_mask")
  1827.  
  1828.  
  1829.  
  1830.     local part = "jersey_armband"
  1831.     gr:CreateMaterialFromAttribulator(player, lod, part, "jersey_material", "${AttribMaterial('jersey"..lodString.."')}" )
  1832.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "jersey_tex", "jersey_cm")
  1833.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "kittex_common", "jersey_coeff")
  1834.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_dry", "jerseyam_dry", "jersey_am")
  1835.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_wet", "jerseyam_wet", "jersey_am")
  1836.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1837.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  1838.     gr:SetTexture(player, lod, part, "textures", "weavePatternNormalMap", "cmnweave", "kit_weave_nm")
  1839.     gr:SetTexture(player, lod, part, "textures", "wrinkleMap", "jerseybnm", "jersey_nm")
  1840.     gr:SetTexture(player, lod, part, "textures", "jerseyPullMap", "jersey_pull_tex", "jersey_pull_mask")
  1841.  
  1842.     gr:SetTexture(player, lod, part, "textures", "dirtMapArray", "jerseydk", "jersey_dk")
  1843.     gr:SetTexture(player, lod, part, "textures", "dirtMaskTexture", "jerseydk", "jersey_region")
  1844.     gr:SetTexture(player, lod, part, "textures", "numberTens", "kitnumbers", GetRMNumberStringTens())
  1845.     gr:SetTexture(player, lod, part, "textures", "numberUnits", "kitnumbers", GetRMNumberStringUnits())
  1846.     gr:SetTexture(player, lod, part, "textures", "tex_decalmap", "cresttex", "${db.player[?].crestTexName}")
  1847.     gr:SetTextureFromRuntime(player, lod, part, "textures", "jerseyName", "namestamp${?}")
  1848.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1849.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1850.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1851.     gr:SetHotSpot(player, lod, part, "global", "jersey_decalBounds", "kithotspots", "jersey", "team")
  1852.     gr:SetHotSpot(player, lod, part, "global", "jersey_nameBound", "kithotspots", "jersey", "name")
  1853.     gr:SetHotSpot(player, lod, part, "global", "jersey_nameArcCenter", "kithotspots", "jersey", "name_arccenter")
  1854.     gr:SetConstantInt(player, lod, part, "global", "jersey_nameLayout", "${db.player[?].jerseyNameLayout}")
  1855.     gr:SetConstantARGB(player, lod, part, "global", "jersey_nameColor", "${db.player[?].kitNameColor}")
  1856.     gr:SetVisibilityGroup(player, lod, part, VISIBILITY_GROUP_JERSEY_ARMBAND)
  1857.     gr:SetTexture(player, lod, part, "textures", "twistMaskTexture", "jerseywrinklemask", "jersey_twist_mask")
  1858.  
  1859.  
  1860.     part = "shorts"
  1861.     gr:CreateMaterialFromAttribulator(player, lod, part, "shorts_material", "${AttribMaterial('shorts"..lodString.."')}" )
  1862.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "shortstex", "shorts_cm")
  1863.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "shortstex", "shorts_coeff")
  1864.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_dry", "shortsam_dry", "shorts_am")
  1865.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_wet", "shortsam_wet", "shorts_am")
  1866.     gr:SetTexture(player, lod, part, "textures", "wrinkleMap", "shortsbnm", "shorts_nm")
  1867.     gr:SetTexture(player, lod, part, "textures", "dirtMapArray", "shortsdk", "shorts_dk")
  1868.     gr:SetTexture(player, lod, part, "textures", "dirtMaskTexture", "shortsdk", "shorts_region")
  1869.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1870.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  1871.     gr:SetTexture(player, lod, part, "textures", "weavePatternNormalMap", "cmnweave", "kit_weave_nm")
  1872.     gr:SetTexture(player, lod, part, "textures", "tex_decalmap", "cresttex", "${db.player[?].crestTexName}")
  1873.     gr:SetTexture(player, lod, part, "textures", "numberTens", "shortsnumbers", GetRMNumberStringTensShorts())
  1874.     gr:SetTexture(player, lod, part, "textures", "numberUnits", "shortsnumbers", GetRMNumberStringUnitsShorts())
  1875.     gr:SetHotSpot(player, lod, part, "global", "shorts_decalBounds", "shortshotspots", "shorts", "team")
  1876.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1877.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1878.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1879.     gr:SetVisibilityGroup(player, lod, part, VISIBILITY_GROUP_SHORTS)
  1880.     gr:SetTexture(player, lod, part, "textures", "twistMaskTexture", "shortswrinklemask", "shorts_twist_mask")
  1881.  
  1882.  
  1883.     gr:SetConstantARGB(player, lod, part, "global", "customColorPri", "${db.player[?].kitColourShortPri}")
  1884.     gr:SetConstantARGB(player, lod, part, "global", "customColorSec", "${db.player[?].kitColourShortSec}")
  1885.     gr:SetConstantARGB(player, lod, part, "global", "customColorTer", "${db.player[?].kitColourShortTer}")
  1886.  
  1887.     part = "shoes"
  1888.     gr:CreateMaterialFromAttribulator(player, lod, part, "shoe_material", "${AttribMaterial('shoe"..lodString.."')}" )
  1889.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "shoetex", "shoe_cm")
  1890.     gr:SetTexture(player, lod, part, "textures", "normalMap", "shoetex", "shoe_nm")
  1891.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "shoetex", "shoe_coeff")
  1892.     gr:SetTexture(player, lod, part, "textures", "dirtMapArray", "shoesdk", "shoes_dk")
  1893.     gr:SetTexture(player, lod, part, "textures", "dirtMaskTexture", "shoesdk", "shoe_region")
  1894.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1895.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  1896.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1897.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1898.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1899.  
  1900.     gr:SetConstantARGB(player, lod, part, "global", "customColorPri", "${db.player[?].shoeColorPri}")
  1901.     gr:SetConstantARGB(player, lod, part, "global", "customColorSec", "${db.player[?].shoeColorSec}")
  1902.     gr:SetConstantARGB(player, lod, part, "global", "customColorTer", "${db.player[?].shoeColorTer}")
  1903.  
  1904.     part = "socks"
  1905.     gr:CreateMaterialFromAttribulator(player, lod, part, "socks_material", "${AttribMaterial('sock"..lodString.."')}" )
  1906.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "shortstex2", "shorts_cm")
  1907.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "shortstex2", "shorts_coeff")
  1908.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_dry", "shortsam_dry", "shorts_am")
  1909.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_wet", "shortsam_wet", "shorts_am")
  1910.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1911.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  1912.     gr:SetTexture(player, lod, part, "textures", "weavePatternNormalMap", "cmnweave", "kit_weave_nm")
  1913.     gr:SetTexture(player, lod, part, "textures", "wrinkleMap", "shortsbnm", "shorts_nm")
  1914.     gr:SetTexture(player, lod, part, "textures", "dirtMapArray", "shortsdk", "shorts_dk")
  1915.     gr:SetTexture(player, lod, part, "textures", "dirtMaskTexture", "shortsdk", "shorts_region")
  1916.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1917.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1918.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1919.     gr:SetVisibilityGroup(player, lod, part, VISIBILITY_GROUP_LEGS)
  1920.  
  1921.     gr:SetConstantARGB(player, lod, part, "global", "customColorPri", "${db.player[?].kitColourSocksPri}")
  1922.     gr:SetConstantARGB(player, lod, part, "global", "customColorSec", "${db.player[?].kitColourSocksSec}")
  1923.     gr:SetConstantARGB(player, lod, part, "global", "customColorTer", "${db.player[?].kitColourSocksTer}")
  1924.  
  1925.     local jacketLodString = (lod == 0) and "" or "_lod"
  1926.     local part = "warmup_top"
  1927.     gr:CreateMaterialFromAttribulator(player, lod, part, "jacket_material", "jacket"..jacketLodString )
  1928.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "warmuptextures", "top_cm")
  1929.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "warmuptextures", "top_coeff")
  1930.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_dry", "jerseyam_dry", "jersey_am")
  1931.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_wet", "jerseyam_wet", "jersey_am")
  1932.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1933.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  1934.     gr:SetTexture(player, lod, part, "textures", "wrinkleMap", "warmuptextures", "top_nm")
  1935.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1936.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1937.     gr:SetConstantARGB(player, lod, part, "global", "customColorPri", "${db.player[?].teamColorPri}")
  1938.     gr:SetConstantARGB(player, lod, part, "global", "customColorSec", "${db.player[?].teamColorSec}")
  1939.     gr:SetConstantARGB(player, lod, part, "global", "customColorTer", "${db.player[?].teamColorTer}")
  1940.     gr:SetVisibilityGroup(player, lod, part, GetRMTracksuitOption())
  1941.  
  1942.     local part = "warmup_bottom"
  1943.     gr:CreateMaterialFromAttribulator(player, lod, part, "jacket_material", "jacket"..jacketLodString )
  1944.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "warmuptextures", "bottom_cm")
  1945.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "warmuptextures", "bottom_coeff")
  1946.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_dry", "jerseyam_dry", "jersey_am")
  1947.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_wet", "jerseyam_wet", "jersey_am")
  1948.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1949.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  1950.     gr:SetTexture(player, lod, part, "textures", "wrinkleMap", "warmuptextures", "bottom_nm")
  1951.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1952.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1953.     gr:SetConstantARGB(player, lod, part, "global", "customColorPri", "${db.player[?].teamColorPri}")
  1954.     gr:SetConstantARGB(player, lod, part, "global", "customColorSec", "${db.player[?].teamColorSec}")
  1955.     gr:SetConstantARGB(player, lod, part, "global", "customColorTer", "${db.player[?].teamColorTer}")
  1956.     gr:SetVisibilityGroup(player, lod, part, GetRMTracksuitOption())
  1957.  
  1958.  
  1959.     local undergearMat = (lod == 0) and "undergear" or "socklod"
  1960.  
  1961.     --underarmor neck
  1962.     local part = "underneck"
  1963.     gr:CreateMaterialFromAttribulator(player, lod, part, "underneck_material", "${AttribMaterial('"..undergearMat.."')}" )
  1964.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "jersey_tex", "jersey_cm")
  1965.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "kittex_common", "jersey_coeff")
  1966.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_dry", "jerseyam_dry", "jersey_am")
  1967.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_wet", "jerseyam_wet", "jersey_am")
  1968.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1969.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  1970.     gr:SetTexture(player, lod, part, "textures", "weavePatternNormalMap", "cmnweave", "kit_weave_nm")
  1971.     gr:SetTexture(player, lod, part, "textures", "wrinkleMap", "jerseybnm", "jersey_nm")
  1972.     gr:SetTexture(player, lod, part, "textures", "dirtMapArray", "jerseydk", "jersey_dk")
  1973.     gr:SetTexture(player, lod, part, "textures", "dirtMaskTexture", "jerseydk", "jersey_region")
  1974.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1975.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1976.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1977.     gr:SetVisibilityGroup(player, lod, part, VISIBILITY_GROUP_LEGS)
  1978.  
  1979.     gr:SetConstantARGB(player, lod, part, "global", "customColorPri", "${db.player[?].kitColourMaskPri}")
  1980.     gr:SetConstantARGB(player, lod, part, "global", "customColorSec", "${db.player[?].kitColourMaskSec}")
  1981.     gr:SetConstantARGB(player, lod, part, "global", "customColorTer", "${db.player[?].kitColourMaskTer}")
  1982.  
  1983.     --underarmor sleeves
  1984.     local part = "underarms"
  1985.     gr:CreateMaterialFromAttribulator(player, lod, part, "underarms_material", "${AttribMaterial('"..undergearMat.."')}" )
  1986.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "jersey_tex", "jersey_cm")
  1987.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "kittex_common", "jersey_coeff")
  1988.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_dry", "jerseyam_dry", "jersey_am")
  1989.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_wet", "jerseyam_wet", "jersey_am")
  1990.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  1991.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  1992.     gr:SetTexture(player, lod, part, "textures", "weavePatternNormalMap", "cmnweave", "kit_weave_nm")
  1993.     gr:SetTexture(player, lod, part, "textures", "wrinkleMap", "jerseybnm", "jersey_nm")
  1994.     gr:SetTexture(player, lod, part, "textures", "dirtMapArray", "jerseydk", "jersey_dk")
  1995.     gr:SetTexture(player, lod, part, "textures", "dirtMaskTexture", "jerseydk", "jersey_region")
  1996.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1997.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  1998.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  1999.     gr:SetVisibilityGroup(player, lod, part, VISIBILITY_GROUP_LEGS) -- as the legs are turned off underneath the track suit
  2000.  
  2001.     gr:SetConstantARGB(player, lod, part, "global", "customColorPri", "${db.player[?].kitColourMaskPri}")
  2002.     gr:SetConstantARGB(player, lod, part, "global", "customColorSec", "${db.player[?].kitColourMaskSec}")
  2003.     gr:SetConstantARGB(player, lod, part, "global", "customColorTer", "${db.player[?].kitColourMaskTer}")
  2004.  
  2005.     --undershorts
  2006.     local part = "undershorts"
  2007.     gr:CreateMaterialFromAttribulator(player, lod, part, "undershorts_material", "${AttribMaterial('"..undergearMat.."')}")
  2008.     gr:SetTexture(player, lod, part, "textures", "diffuseTexture", "shortstex", "shorts_cm")
  2009.     gr:SetTexture(player, lod, part, "textures", "coeffMap", "shortstex", "shorts_coeff")
  2010.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_dry", "shortsam_dry", "shorts_am")
  2011.     gr:SetTexture(player, lod, part, "textures", "occlusionMap_wet", "shortsam_wet", "shorts_am")
  2012.     gr:SetTexture(player, lod, part, "textures", "wrinkleMap", "shortsbnm", "shorts_nm")
  2013.     gr:SetTexture(player, lod, part, "textures", "dirtMapArray", "shortsdk", "shorts_dk")
  2014.     gr:SetTexture(player, lod, part, "textures", "dirtMaskTexture", "shortsdk", "shorts_region")
  2015.     gr:SetTexture(player, lod, part, "textures", "envDiffuseTexture", "charcmn", "envd_")
  2016.     gr:SetTexture(player, lod, part, "textures", "envSpecTexture", "charcmn", "envs_")
  2017.     gr:SetTexture(player, lod, part, "textures", "weavePatternNormalMap", "cmnweave", "kit_weave_nm")
  2018.     gr:SetTextureFromRuntime(player, lod, part, "textures", "coverageMap", "covmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  2019.     gr:SetTextureFromRuntime(player, lod, part, "textures", "stadiumShadowMap", "shadowmap_${db.player[?].stadiumID}_${db.player[?].stadiumLightID}_${db.player[?].stadiumType}")
  2020.     gr:SetTextureFromRuntime(player, lod, part, "textures", "ssao_texture", "ssao")
  2021.     gr:SetVisibilityGroup(player, lod, part, VISIBILITY_GROUP_LEGS)
  2022.  
  2023.     gr:SetConstantARGB(player, lod, part, "global", "customColorPri", "${db.player[?].kitColourShortPri}")
  2024.     gr:SetConstantARGB(player, lod, part, "global", "customColorSec", "${db.player[?].kitColourShortSec}")
  2025.     gr:SetConstantARGB(player, lod, part, "global", "customColorTer", "${db.player[?].kitColourShortTer}")
  2026.  
  2027. end
  2028.  
  2029. ---------------------------------------------------------------------------------------------------
  2030. function GetFaceTextureOperation(idx)
  2031.     if(db.player[idx].isVirtualPro == 1) then
  2032.         return "extracttexture head.dds"
  2033.     elseif (db.player[idx].useFaceTextureComposition > 0) then
  2034.         -- assetOperation generatetexture: "generatetexture texname width, height, mipCount, compression"
  2035.         --return "generatetexture head_ 512,1024,6,${db.player[?].dxttype}"
  2036.         return "generatetexture head_ 1024,1024,6,${db.player[?].dxttype}"
  2037.     else
  2038.         -- For others we do not need to generate the texture, so we just extract the source asset
  2039.         return "extracttexture head_"
  2040.     end
  2041. end
  2042.  
  2043. ---------------------------------------------------------------------------------------------------
  2044. function GetFaceSpecTextureOperation(idx)
  2045.     if(db.player[idx].isVirtualPro == 1) then
  2046.         -- gameface, no information about facial hair type
  2047.         return "extracttexture head_sk"
  2048.     elseif (db.player[idx].useFaceTextureComposition > 0) then
  2049.         -- assetOperation generatetexture: "generatetexture texname width, height, mipCount, compression"
  2050.         return "generatetexture head_sk 512,512,6,${db.player[?].dxttype}"
  2051.     else
  2052.         -- For others we do not need to generate the texture, so we just extract the source asset
  2053.         return "extracttexture head_sk"
  2054.     end
  2055. end
  2056.  
  2057. ---------------------------------------------------------------------------------------------------
  2058. function GetFaceTexTemplate(idx)
  2059.     if(db.player[idx].isVirtualPro == 1) then
  2060.         return "data/easw/head.dds;data/sceneassets/gameface/head.dds"
  2061.     elseif(db.player[idx].useFaceTextureComposition > 0) then
  2062.         return "gentex_face_"..db.player[idx].faceType.."_"..db.player[idx].faceProxyHeadClass.."_0_"..db.player[idx].eyebrow.."_"..db.player[idx].faceSideBurn.."_"..db.player[idx].facialHairColor.."_"..db.player[idx].facialHairType.."_"..db.player[idx].headSkinType.."_"..db.player[idx].headSkinToneType.."_textures."..db.player[idx].faceTexExtension
  2063.     else
  2064.         return "${GetRMFaceTex(?)}data/sceneassets/faces/face_"..db.player[idx].faceType.."_"..db.player[idx].faceProxyHeadClass.."_0_"..db.player[idx].eyebrow.."_"..db.player[idx].faceSideBurn.."_"..db.player[idx].facialHairColor.."_"..db.player[idx].facialHairType.."_"..db.player[idx].headSkinType.."_"..db.player[idx].headSkinToneType.."_textures."..db.player[idx].faceTexExtension
  2065.     end
  2066. end
  2067.  
  2068. ---------------------------------------------------------------------------------------------------
  2069. function GetFaceSpecAoTexTemplate(idx)
  2070.     if(db.player[idx].isVirtualPro == 1) then
  2071.         return "data/sceneassets/heads/head_common_${db.player[?].gender}_textures.rx3"
  2072.     elseif(db.player[idx].headClass > 0) then
  2073.         return "gentex_facespec_"..db.player[idx].faceType.."_"..db.player[idx].faceProxyHeadClass.."_0_"..db.player[idx].eyebrow.."_"..db.player[idx].faceSideBurn.."_"..db.player[idx].facialHairColor.."_"..db.player[idx].facialHairType.."_"..db.player[idx].headSkinType.."_"..db.player[idx].headSkinToneType.."_textures."..db.player[idx].faceTexExtension
  2074.     else
  2075.         return "${GetRMFaceTex(?)}data/sceneassets/faces/face_"..db.player[idx].faceType.."_"..db.player[idx].faceProxyHeadClass.."_0_"..db.player[idx].eyebrow.."_"..db.player[idx].faceSideBurn.."_"..db.player[idx].facialHairColor.."_"..db.player[idx].facialHairType.."_"..db.player[idx].headSkinType.."_"..db.player[idx].headSkinToneType.."_textures."..db.player[idx].faceTexExtension
  2076.     end
  2077. end
  2078.  
  2079. ---------------------------------------------------------------------------------------------------
  2080. function GetFaceNormalTexTemplate(idx)
  2081.     if(db.player[idx].headClass == 0) then
  2082.         return "${GetRMFaceTex(?)}data/sceneassets/faces/face_"..db.player[idx].faceType.."_"..db.player[idx].faceProxyHeadClass.."_0_"..db.player[idx].eyebrow.."_"..db.player[idx].faceSideBurn.."_"..db.player[idx].facialHairColor.."_"..db.player[idx].facialHairType.."_"..db.player[idx].headSkinType.."_"..db.player[idx].headSkinToneType.."_textures."..db.player[idx].faceTexExtension
  2083.     else
  2084.         return "data/sceneassets/heads/head_common_${db.player[?].gender}_textures.rx3"
  2085.     end
  2086. end
  2087.  
  2088. ---------------------------------------------------------------------------------------------------
  2089. function GetJerseyBMN(idx)
  2090.     return "data/sceneassets/kitcmn/jersey_${db.player[?].jerseyTucked}_${db.player[?].jerseyfit}_${db.player[?].gender}_bnm.rx3"
  2091. end
  2092.  
  2093. ---------------------------------------------------------------------------------------------------
  2094. function GetShortsBMN(idx)
  2095.     return "data/sceneassets/kitcmn/shorts_${db.player[idx].shortstyle}_${db.player[?].gender}_bnm.rx3"
  2096. end
  2097.  
  2098. ---------------------------------------------------------------------------------------------------
  2099. -- returns kit texture or goalie pants kit 5200
  2100. function GetShortsTex(idx,pos)
  2101.     if (db.player[idx].fourthofficialoption == 2) then
  2102.     if (idx == 57) then
  2103.     return "${GetRMKit(?,"..pos..")}"
  2104.     end
  2105.     end
  2106.     if(db.player[idx].shortstyle == 1) then
  2107.         return "data/sceneassets/kit/kit_${db.player[?].kit}_99_0.rx3;data/sceneassets/kit/kit_5200_0_0.rx3"
  2108.     else
  2109.         return "${GetRMKit(?,"..pos..")}"
  2110.     end
  2111. end
  2112.  
  2113. function GetKitTextureOperation(idx)
  2114.     if (db.player[idx].useTextureComposition == 1) then
  2115.         -- Creation Zone requires generated textures, describe the operation
  2116.         -- assetOperation generatetexture: "generatetexture texname width, height, mipCount, compression"
  2117.         --return "generatetexture jersey_cm 1024,1024,9,eadxt1"
  2118.         return "generatetexture jersey_cm "..gentexsize..","..gentexsize..","..gentexmip..","..gentexformat
  2119.     else
  2120.         -- For others we do not need to generate the texture, so we just extract the source asset
  2121.         return "extracttexture jersey_cm"
  2122.     end
  2123. end
  2124.  
  2125. function GetKitTextureAssetName(idx)
  2126.     if (db.player[idx].useTextureComposition == 1) then
  2127.         -- Creation Zone requires generated textures, thus give the asset a unique name
  2128.         -- For CZ, kittype is always home, and year is always zero.
  2129.         --return "gentex_kit_${db.player[?].kit}_${db.player[?].kitType}_${db.player[?].kitYear}_${db.player[?].teamside}_${db.player[?].kitColourJerseyPri}_${db.player[?].kitColourJerseySec}_${db.player[?].kitColourJerseyTer}_${db.player[?].playerassetid}"
  2130.         return "gentex_kit_${db.player[?].kit}_${db.player[?].kitType}_${db.player[?].kitYear}_${db.player[?].teamside}_${db.player[?].kitColourJerseyPri}_${db.player[?].kitColourJerseySec}_${db.player[?].kitColourJerseyTer}_${db.player[?].genTexString}"
  2131.     else
  2132.         -- Keep regular rx3 name as this is the source of the texture
  2133.         return "${GetRMKit(?,1)}"
  2134.     end
  2135. end
  2136.  
  2137. ---------------------------------------------------------------------------------------------------
  2138. function GetSimpleClothJersey(idx)
  2139.     if(db.player[idx].jerseyfit == 0) then
  2140.         return "data/sceneassets/simplecloth/simjersey_0_0_${db.player[?].jerseySleeveLength}_${db.player[?].jerseyArmBand}_${db.player[?].jerseyTucked}_${db.player[?].gender}.rx3"
  2141.         --return "data/sceneassets/simplecloth/simjersey_0_0_0_0_1.rx3"
  2142.     else
  2143.         return "data/sceneassets/simplecloth/dummy_-1.rx3"
  2144.     end
  2145. end
  2146.  
  2147. function GetSimpleClothShorts(idx)
  2148.     if(db.player[idx].shortstyle == 0) then
  2149.         return "data/sceneassets/simplecloth/simshorts_0_${db.player[?].shortstyle}_${db.player[?].gender}.rx3"
  2150.         --return "data/sceneassets/simplecloth/simshorts_0_0.rx3"
  2151.     else
  2152.         return "data/sceneassets/simplecloth/dummy_-1.rx3"
  2153.     end
  2154. end
  2155.  
  2156. ---------------------------------------------------------------------------------------------------
  2157. function PlayerAssetLod(player, lod)
  2158.     local gr = gRenderables
  2159.  
  2160.     local defaultpriority = 0   -- default priority
  2161.  
  2162.     gr:AddCallback(player, lod, "PlayerUpdate(?)")
  2163.  
  2164.     local kitTexAsset = "${GetRMKit(?,1)}"
  2165.     local kitTexAssetPos = "${GetRMKit(?,1)}"
  2166.  
  2167.     -- Generic files needed by all LODs
  2168.     gr:AddAsset(player, lod, "shader", "data/fifarna/shader.big")
  2169.     gr:AddAsset(player, lod, "charcmn", "data/sceneassets/charactercmn/charactercmn_${db.player[?].envLighting}.rx3")
  2170.     gr:AddAsset(player, lod, "bodycmn", "data/sceneassets/body/body_common_${db.player[?].gender}_textures.rx3")
  2171.     gr:AddAsset(player, lod, "headcmn", "${GetRMFaceBump(?)}data/sceneassets/heads/head_common_${db.player[?].gender}_textures.rx3")
  2172.        
  2173.     local faceNRMTemplate = "${GetFaceNormalTexTemplate(?)}"
  2174.     gr:AddAsset(player, lod, "facenormaltex", faceNRMTemplate)
  2175.     gr:AddAsset(player, lod, "facenormaltex_common", "${GetRMFaceBump(?)}data/sceneassets/heads/head_common_${db.player[?].gender}_textures.rx3")
  2176.    
  2177.     -- Sponsor image for stamping onto kit
  2178.     gr:AddAsset(player, lod, "sponsortex", "${GetRMKitOverlay(?)}data/ugc/cz_sponsor/${db.player[?].sponsorAssetId}.png;data/ugc/cz_sponsor/1.png", defaultpriority, ASSET_NO_COPY, ALLOCTYPE_TEMP_AUTO_RELEASE)
  2179.  
  2180.     -- gr:AddAssetEx(asset, lod, assetOperation, assetPart, containerName)
  2181.     -- extracttexture will create an asset with just the texture you extract from the source asset, this way we can free the original rx3, freeing unused textures.
  2182.     gr:AddAssetEx(player, lod, "extracttexture jersey_coeff", "kittex_common" , kitTexAsset)
  2183.     gr:AddAssetEx(player, lod, "extracttexture shorts_cm,shorts_coeff", "shortstex" , "${GetShortsTex(?,2)}")
  2184.     gr:AddAssetEx(player, lod, "extracttexture shorts_cm,shorts_coeff", "shortstex2" , "${GetShortsTex(?,3)}")
  2185.     gr:AddAssetEx(player, lod, "extracthotspots", "kithotspots" , kitTexAssetPos)
  2186.     gr:AddAssetEx(player, lod, "extracthotspots", "shortshotspots",  "${GetShortsTex(?,2)}")
  2187.     gr:AddAssetEx(player, lod, "extracttexture ${db.player[?].crestTexName}", "cresttex", "${GetCrestAsset(?)}")
  2188.  
  2189.  
  2190.     -- Texture composition code
  2191.     -- Add the template asset as a temporary asset, auto releasing it when it's not being used (after texture generation in this case)
  2192.     gr:AddAssetEx(player, lod, "extracttexture jersey_cm", "kittex_cm_template" , kitTexAsset, defaultpriority, ASSET_NO_COPY, ALLOCTYPE_TEMP_AUTO_RELEASE)
  2193.     local part = "jersey_tex"
  2194.     -- GetKitTextureOperation will determine if texture composition is needed.
  2195.     gr:AddAssetEx(player, lod, "${GetKitTextureOperation(?)}", part , "${GetKitTextureAssetName(?)}")
  2196.     -- Describe texture composition in case we have to generate the texture, this material won't be created if no composition is needed.
  2197.     gr:CreateMaterial(player, lod, part, "texcomp.fx" )
  2198.     gr:SetTexture(player, lod, part, "textures", "texcomp_tex0", "kittex_cm_template", "jersey_cm")
  2199.     gr:SetTexture(player, lod, part, "textures", "texcomp_tex1", "sponsortex", "png")
  2200.     gr:SetConstantARGB(player, lod, part, "global", "recolorCustomColorPri", "${db.player[?].kitColourJerseyPri}")
  2201.     gr:SetConstantARGB(player, lod, part, "global", "recolorCustomColorSec", "${db.player[?].kitColourJerseySec}")
  2202.     gr:SetConstantARGB(player, lod, part, "global", "recolorCustomColorTer", "${db.player[?].kitColourJerseyTer}")
  2203.     gr:SetConstantARGB(player, lod, part, "global", "recolourMult", "${db.player[?].sponsorcolour}")
  2204.     gr:SetConstantHotSpot(player, lod, part, "global", "samplerBounds1", "${db.player[?].hotspotJerseySponsorL};${db.player[?].hotspotJerseySponsorT};${db.player[?].hotspotJerseySponsorR};${db.player[?].hotspotJerseySponsorB}")
  2205.     -- End of texture composition
  2206.  
  2207.     -- Set the jersey texture as a runtime texture so we can use it outside of player
  2208.     gr:SetRuntimeTexture(player, lod, "jersey_${db.player[?].kit}_${db.player[?].kitType}_${db.player[?].isgoalie}_${db.player[?].teamside}" , "jersey_tex", "jersey_cm")
  2209.     gr:SetRuntimeTexture(player, lod, "jersey_coeff_${db.player[?].kit}_${db.player[?].kitType}_${db.player[?].isgoalie}_${db.player[?].teamside}", "kittex_common",  "jersey_coeff")
  2210.  
  2211.     gr:AddAsset(player, lod, "shoetex", "${GetRMBoot(?,1)}data/sceneassets/shoe/shoe_${db.player[?].shoeType}_${db.player[?].shoeDesign}_textures.rx3;data/sceneassets/shoe/shoe_15_0_textures.rx3")
  2212.     gr:AddAsset(player, lod, "skintex", "${GetRMSkin(?)}${GetSkinTexture(?)}")
  2213.  
  2214.     gr:AddAsset(player, lod, "hairtex", "${GetRMHairTex(?)}data/sceneassets/hair/hair_${db.player[?].hair}_${db.player[?].faceProxyHeadClass}_textures.rx3")
  2215.     gr:AddAsset(player, lod, "shortsam_dry", "data/sceneassets/kitcmn/shorts_${db.player[?].shortstyle}_0_${db.player[?].gender}_textures.rx3")
  2216.     gr:AddAsset(player, lod, "shortsam_wet", "data/sceneassets/kitcmn/shorts_${db.player[?].shortstyle}_1_${db.player[?].gender}_textures.rx3")
  2217.     gr:AddAsset(player, lod, "jerseyam_dry", "data/sceneassets/kitcmn/jersey_${db.player[?].jerseyTucked}_0_${db.player[?].gender}_textures.rx3")
  2218.     gr:AddAsset(player, lod, "jerseyam_wet", "data/sceneassets/kitcmn/jersey_${db.player[?].jerseyTucked}_1_${db.player[?].gender}_textures.rx3")
  2219.     local jerseyBNM = "${GetJerseyBMN(?)}"
  2220.     gr:AddAsset(player, lod, "jerseybnm", jerseyBNM)
  2221.     gr:AddAsset(player, lod, "jersey_pull_tex", "data/sceneassets/kitcmn/jersey_${db.player[?].gender}_pull_mask.rx3")
  2222.  
  2223.     gr:AddAsset(player, lod, "cmnweave", "data/sceneassets/kitcmn/kitweave.rx3")
  2224.     local shortsBNM = "${GetShortsBMN(?)}"
  2225.     gr:AddAsset(player, lod, "shortsbnm", shortsBNM)
  2226.  
  2227.     -- Dirt masks
  2228.     gr:AddAsset(player, lod, "bodydk", "data/sceneassets/body/body_dk.rx3")
  2229.     gr:AddAsset(player, lod, "shortsdk", "data/sceneassets/kitcmn/shorts_${db.player[?].shortstyle}_${db.player[?].gender}_dk.rx3")
  2230.     gr:AddAsset(player, lod, "jerseydk", "data/sceneassets/kitcmn/jersey_${db.player[?].gender}_dk.rx3")
  2231.     gr:AddAsset(player, lod, "shoesdk", "data/sceneassets/shoe/shoes_dk.rx3")
  2232.    
  2233.     gr:AddAsset(player, lod, "jerseywrinklemask", "data/sceneassets/kitcmn/jersey_${db.player[?].gender}_twist_mask.rx3");
  2234.     gr:AddAsset(player, lod, "shortswrinklemask", "data/sceneassets/kitcmn/shorts_${db.player[?].gender}_twist_mask.rx3");
  2235.  
  2236.     -- gr:AddAsset(player, lod, "eyetex", "data/sceneassets/heads/eyes_${db.player[?].eyeColor}_${db.player[?].faceProxyHeadClass}_textures.rx3")
  2237.     gr:AddAsset(player, lod, "eyetex", "${GetRMEyeTex(?)}data/sceneassets/heads/eyes_${db.player[?].eyeColor}_1_textures.rx3")
  2238.  
  2239.     -- Add font as a temporary asset, because the font is used after the load (bind time), we still have to manually release it from the renderable
  2240.     -- TODO: add font stamping support to composite instead of having the renderable do this at bind time
  2241.     gr:AddAsset(player, lod, "font", "${GetRMNameFont(?)}data/sceneassets/jerseyfonts/font_${db.player[?].kitNameFont}.ttf", defaultpriority, ASSET_NO_COPY, ALLOCTYPE_PERM)
  2242.     gr:AddAsset(player, lod, "kitnumbers", "${GetRMNumberSet(?,0)}data/sceneassets/kitnumbers/kitnumbers_${db.player[?].kitNumberFont}_${db.player[?].kitNumberColor}.rx3;data/sceneassets/kitnumbers/kitnumbers_0_0.rx3")
  2243.     gr:AddAsset(player, lod, "shortsnumbers", "${GetRMNumberSet(?,1)}data/sceneassets/kitnumbers/kitnumbers_${db.player[?].shortsNumberFont}_${db.player[?].shortsNumberColor}.rx3;data/sceneassets/kitnumbers/kitnumbers_0_0.rx3")
  2244.  
  2245.     local faceGenTemplate = "${GetFaceTexTemplate(?)}"
  2246.     local faceSpecAoTemplate = "${GetFaceSpecAoTexTemplate(?)}"
  2247.  
  2248.     --FACE PARTS
  2249.     gr:AddAsset(player, lod, "facepart1", "${GetRMFaceTex(?)}data/sceneassets/genheadtex/skin_${db.player[?].headSkinToneType}_${db.player[?].headSkinType}${db.player[?].compsuffix}", defaultpriority, ASSET_NO_COPY, ALLOCTYPE_TEMP_AUTO_RELEASE)
  2250.     gr:AddAsset(player, lod, "facepart2", "${GetRMFaceTex(?)}data/sceneassets/genheadtex/brow_${db.player[?].headSkinToneType}_${db.player[?].eyebrow}_${db.player[?].facialHairColor}${db.player[?].compsuffix}", defaultpriority, ASSET_NO_COPY, ALLOCTYPE_TEMP_AUTO_RELEASE)
  2251.     gr:AddAsset(player, lod, "facepart3", "${GetRMFaceTex(?)}data/sceneassets/genheadtex/beard_${db.player[?].headSkinToneType}_${db.player[?].facialHairType}_${db.player[?].facialHairColor}${db.player[?].compsuffix}", defaultpriority, ASSET_NO_COPY, ALLOCTYPE_TEMP_AUTO_RELEASE)
  2252.     gr:AddAsset(player, lod, "facepart4", "${GetRMFaceTex(?)}data/sceneassets/genheadtex/sideburn_${db.player[?].headSkinToneType}_${db.player[?].faceSideBurn}_${db.player[?].facialHairColor}${db.player[?].compsuffix}", defaultpriority, ASSET_NO_COPY, ALLOCTYPE_TEMP_AUTO_RELEASE)
  2253.     --END FACE PARTS
  2254.    
  2255.     part = "facetex"
  2256.     gr:AddAssetEx(player, lod, "${GetFaceTextureOperation(?)}", part , faceGenTemplate)
  2257.  
  2258.     -- Describe texture composition in case we have to generate the texture, this material won't be created if no composition is needed.
  2259.     gr:CreateMaterial(player, lod, part, "texcompface.fx" )
  2260.     gr:SetTexture(player, lod, part, "textures", "texcomp_tex0", "facepart1", "cm") -- base skin
  2261.     gr:SetTexture(player, lod, part, "textures", "texcomp_tex1", "facepart2", "cm") -- eye brow
  2262.     gr:SetTexture(player, lod, part, "textures", "texcomp_tex2", "facepart3", "cm") -- beard
  2263.     gr:SetTexture(player, lod, part, "textures", "texcomp_tex3", "facepart4", "cm") -- sideburn
  2264.  
  2265.     gr:AddAsset(player, lod, "specpart", "${GetRMFaceBump(?)}data/sceneassets/heads/head_common_${db.player[?].gender}_textures.rx3", defaultpriority, ASSET_NO_COPY, ALLOCTYPE_TEMP_AUTO_RELEASE)
  2266.  
  2267.     part = "facespectex"
  2268.     gr:AddAssetEx(player, lod, "${GetFaceSpecTextureOperation(?)}", part, faceSpecAoTemplate)
  2269.  
  2270.     -- Describe texture composition in case we have to generate the texture, this material won't be created if no composition is needed.
  2271.     gr:CreateMaterial(player, lod, part, "texcompspec.fx" )
  2272.     gr:SetTexture(player, lod, part, "textures", "texcomp_tex0", "specpart", "head_sk") -- base spec/ao
  2273.     gr:SetTexture(player, lod, part, "textures", "texcomp_tex1", "facepart3", "cm") -- beard
  2274.     gr:SetTexture(player, lod, part, "textures", "texcomp_tex2", "facepart2", "cm") -- brow
  2275.    
  2276.     -- No lods for undergear
  2277.     gr:AddAsset(player, lod, "underarms", "data/sceneassets/body/underarms_0_${db.player[?].underarms}_${db.player[?].gender}.rx3")
  2278.     gr:AddAsset(player, lod, "underneck", "data/sceneassets/body/underneck_0_${db.player[?].underneck}_${db.player[?].gender}.rx3")
  2279.     gr:AddAsset(player, lod, "undershorts", "data/sceneassets/body/undershorts_0_${db.player[?].undershorts}_${db.player[?].gender}.rx3")
  2280.  
  2281.     gr:AddAsset(player, lod, "warmup_top", "data/sceneassets/body/warmup_"..(lod).."_${db.player[?].cold}_0_${db.player[?].gender}.rx3")
  2282.     gr:AddAsset(player, lod, "warmup_bottom", "data/sceneassets/body/warmup_"..(lod).."_${db.player[?].cold}_1_${db.player[?].gender}.rx3")
  2283.     gr:AddAsset(player, lod, "warmuptextures", "${GetRMBench(?)}data/sceneassets/warmup/warmup_${db.player[?].cold}_0_textures.rx3")
  2284.  
  2285.     -- simple cloth assets
  2286.     local jerseyCloth = "${GetSimpleClothJersey(?)}"
  2287.     local shortsCloth = "${GetSimpleClothShorts(?)}"
  2288.     gr:AddAsset(player, lod, "jerseycloth", jerseyCloth)
  2289.     gr:AddAsset(player, lod, "shortscloth", shortsCloth)
  2290.    
  2291.  
  2292.     if (lod == 0) then
  2293.         gr:AddAsset(player, lod, "haircloth", "data/sceneassets/simplecloth/simhair_${db.player[?].hair}_${db.player[?].faceProxyHeadClass}_0.rx3;data/sceneassets/simplecloth/simhair_${db.player[?].generichair}_${db.player[?].genericfaceProxyHeadClass}_0.rx3")
  2294.     end
  2295.  
  2296.     if (lod == 0) then
  2297.         PlayerAssetHighLod(player, lod)
  2298.     elseif (lod == 1) then
  2299.         PlayerAssetLowLod(player, lod)
  2300.     elseif (lod == 2) then
  2301.         PlayerAssetLowLod(player, lod)
  2302.     elseif (lod == 3) then
  2303.         PlayerAssetShadow(player, lod)
  2304.     end
  2305.  
  2306.     if (lod < 3) then
  2307.         PlayerCommonBinding(player,lod)
  2308.     end
  2309.  
  2310. end
  2311.  
  2312. ---------------------------------------------------------------------------------------------------
  2313. function PlayerAssetBind(player)
  2314.     PlayerAssetLod(player, 0)
  2315.     PlayerAssetLod(player, 1)
  2316.     PlayerAssetLod(player, 2)
  2317.     PlayerAssetLod(player, 3)
  2318.  
  2319. end
  2320.  
  2321.  
  2322.  
  2323.  
  2324.  
  2325.  
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.  
  2332. function GetRMNameFont(idx)
  2333.     local kitnamestring = ""
  2334.    
  2335.     --variables needed for new precedence:
  2336.         local as = gSportsRNA
  2337.         local wipe3d = as:GetTable("wvWipe", 1)
  2338.         local orgtournid = as:GetInt(wipe3d, "leagueID")   
  2339.        
  2340.     --specificfont_teamid_item_tournamentassetid_kittype.ttf
  2341.    
  2342.     kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/specificfont_"..db.player[idx].teamid.."_1_"..db.player[idx].tournidnum.."_"..db.player[idx].speckitType..".ttf;"
  2343.    
  2344.         if (db.player[idx].kitYear == 0) then
  2345.         kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/specificfont_"..db.player[idx].teamid.."_1_"..db.player[idx].defaulttournid.."_"..db.player[idx].speckitType..".ttf;"
  2346.         kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/specificfont_"..db.player[idx].teamid.."_1_0_"..db.player[idx].speckitType..".ttf;"
  2347.         end
  2348.    
  2349.     kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/specificfont_"..db.player[idx].teamid.."_1_"..db.player[idx].tournidnum.."_"..db.player[idx].kitType..".ttf;"
  2350.    
  2351.         if (db.player[idx].kitYear == 0) then
  2352.         kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/specificfont_"..db.player[idx].teamid.."_1_"..db.player[idx].defaulttournid.."_"..db.player[idx].kitType..".ttf;"
  2353.         kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/specificfont_"..db.player[idx].teamid.."_1_0_"..db.player[idx].kitType..".ttf;"
  2354.         end
  2355.    
  2356.    
  2357.     -- new precedence: look for font based on year and tournament (team specific first)
  2358.     kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/"..db.player[idx].kitYear.."/specificfont_"..db.player[idx].teamid.."_0_"..orgtournid.."_0.ttf;"
  2359.     kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/"..db.player[idx].kitYear.."/specificfont_0_0_"..orgtournid.."_0.ttf;"
  2360.    
  2361.     -- new precedence end
  2362.    
  2363.     kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/specificfont_"..db.player[idx].teamid.."_0_"..db.player[idx].tournidnum.."_0.ttf;"
  2364.    
  2365.         if (db.player[idx].kitYear == 0) then
  2366.         kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/specificfont_0_0_"..db.player[idx].tournidnum.."_0.ttf;"
  2367.         kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/specificfont_"..db.player[idx].teamid.."_0_0_0.ttf;"
  2368.        
  2369.             if (db.player[idx].tournidnum == -1) then
  2370.             kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/specificfont_0_0_0_"..db.player[idx].defaulttournid..".ttf;"
  2371.             else
  2372.             kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/specificfont_0_0_"..db.player[idx].tournidnum.."_"..db.player[idx].defaulttournid..".ttf;"
  2373.             end
  2374.         kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/specificfont_0_0_"..db.player[idx].defaulttournid.."_0.ttf;"
  2375.         kitnamestring = kitnamestring.."data/sceneassets/jerseyfonts/specificfont_0_0_0_0.ttf;"
  2376.         end
  2377.    
  2378.     return kitnamestring
  2379. end
  2380.  
  2381. function GetRMNumberSet(idx,short)
  2382.     local colour = 0
  2383.     local kitnumberstring = ""
  2384.    
  2385.     if (short == 0) then
  2386.     colour = db.player[idx].kitNumberColor
  2387.     else
  2388.     colour = db.player[idx].shortsNumberColor
  2389.     end
  2390.    
  2391.     --variables needed for new precedence:
  2392.         local as = gSportsRNA
  2393.         local wipe3d = as:GetTable("wvWipe", 1)
  2394.         local orgtournid = as:GetInt(wipe3d, "leagueID")
  2395.    
  2396.     --specifickitnumbers_teamid_item_tournamentassetid_numbercolour.rx3
  2397.    
  2398.     --new precedence 1:
  2399.     kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/"..db.player[idx].kitYear.."/specifickitnumbers_"..db.player[idx].teamid.."_"..(short+1).."_"..orgtournid.."_"..db.player[idx].speckitType..".rx3;"
  2400.     --  np1 end
  2401.    
  2402.     kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/specifickitnumbers_"..db.player[idx].teamid.."_"..(short+1).."_"..db.player[idx].tournidnum.."_"..db.player[idx].speckitType..".rx3;"
  2403.    
  2404.         if (db.player[idx].kitYear == 0) then
  2405.         kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/specifickitnumbers_"..db.player[idx].teamid.."_"..(short+1).."_"..db.player[idx].defaulttournid.."_"..db.player[idx].speckitType..".rx3;"
  2406.         kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/specifickitnumbers_"..db.player[idx].teamid.."_"..(short+1).."_0_"..db.player[idx].speckitType..".rx3;"
  2407.         end
  2408.        
  2409.     --new precedence 2:
  2410.     kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/"..db.player[idx].kitYear.."/specifickitnumbers_"..db.player[idx].teamid.."_"..(short+1).."_"..orgtournid.."_"..db.player[idx].kitType..".rx3;"
  2411.     -- np2end
  2412.     kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/specifickitnumbers_"..db.player[idx].teamid.."_"..(short+1).."_"..db.player[idx].tournidnum.."_"..db.player[idx].kitType..".rx3;"
  2413.    
  2414.         if (db.player[idx].kitYear == 0) then
  2415.         kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/specifickitnumbers_"..db.player[idx].teamid.."_"..(short+1).."_"..db.player[idx].defaulttournid.."_"..db.player[idx].kitType..".rx3;"
  2416.         kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/specifickitnumbers_"..db.player[idx].teamid.."_"..(short+1).."_0_"..db.player[idx].kitType..".rx3;"
  2417.         end
  2418.        
  2419.  
  2420.    
  2421.         -- new precedence 3 start: look for numbers based on year and tournament
  2422.         kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/"..db.player[idx].kitYear.."/specifickitnumbers_"..db.player[idx].teamid.."_0_"..orgtournid.."_"..colour..".rx3;"
  2423.         kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/"..db.player[idx].kitYear.."/specifickitnumbers_0_0_"..orgtournid.."_"..colour..".rx3;"
  2424.        
  2425.         -- new precedence end
  2426.    
  2427.     kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/specifickitnumbers_"..db.player[idx].teamid.."_0_"..db.player[idx].tournidnum.."_"..colour..".rx3;"
  2428.    
  2429.         if (db.player[idx].kitYear == 0) then
  2430.         kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/specifickitnumbers_0_0_"..db.player[idx].tournidnum.."_"..colour..".rx3;"
  2431.         kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/specifickitnumbers_"..db.player[idx].teamid.."_0_"..db.player[idx].kitYear.."_"..colour..".rx3;"
  2432.         kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/specifickitnumbers_0_0_"..db.player[idx].defaulttournid.."_"..colour..".rx3;"
  2433.         kitnumberstring = kitnumberstring.."data/sceneassets/kitnumbers/specifickitnumbers_0_0_"..db.player[idx].kitYear.."_"..colour..".rx3;"
  2434.         end
  2435.        
  2436.     return kitnumberstring
  2437. end
  2438.  
  2439.  
  2440.  
  2441.  
  2442. repGenBoots = true
  2443.  
  2444. --FIFA 14 > ADAPT FOR 15
  2445. function getGenericBootReplacement(id,kitType)
  2446.  
  2447. if (playerBootFallback[id] ~= nil) then
  2448. if (playerBootFallback[id] ~= 0) then
  2449. return playerBootFallback[id]
  2450. end
  2451. end
  2452.  
  2453. --BLACK BOOTS FOR REFS
  2454. if (kitType == 5) then
  2455. local bootarray = {22,69,79,133,150,157,160,175,179,247}
  2456. local rboot = (id % #bootarray)+1
  2457. return bootarray[rboot]
  2458. end
  2459.  
  2460. local rand = (id%230)+21
  2461.  
  2462.  
  2463.  
  2464. if (rand == 34) then
  2465. rand = 23
  2466. end
  2467.  
  2468. if (rand == 35) then
  2469. rand = 23
  2470. end
  2471.  
  2472. if (rand == 59) then
  2473. rand = 23
  2474. end
  2475.  
  2476. if (rand == 60) then
  2477. rand = 23
  2478. end
  2479.  
  2480. if (rand == 61) then
  2481. rand = 23
  2482. end
  2483.  
  2484. if (rand == 62) then
  2485. rand = 23
  2486. end
  2487. if (rand == 126) then
  2488. rand = 23
  2489. end
  2490.  
  2491. if (rand == 127) then
  2492. rand = 23
  2493. end
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499. return rand
  2500. end
  2501.  
  2502. --FIFA 15 DEMO ONLY
  2503. -- function getGenericBootReplacement(id,boot)
  2504. -- local rand = (id%6)+1
  2505. -- local bootarray = {131,185,25,40,33,44}
  2506. -- return bootarray[rand]
  2507. -- end
  2508.  
  2509.  
  2510.  
  2511.  
  2512. function disableGenericBootReplacement()
  2513. repGenBoots = false
  2514. end
  2515.  
  2516. genBootsPlayer = {}
  2517.  
  2518. function enablePlayerGenericBoot(id)
  2519. genBootsPlayer[id] = 1
  2520. end
  2521.  
  2522.  
  2523.  
  2524. function getPlayerGenericBoot(id)
  2525. if (genBootsPlayer[id] ~= nil) then
  2526. if (genBootsPlayer[id] == 1) then
  2527. return true
  2528. end
  2529. end
  2530.  
  2531. return false
  2532. end
  2533.  
  2534.  
  2535. --FIFA15VERSION
  2536. function GetRMBoot(idx,model)
  2537.     local bootstring = ""
  2538.     local tex = ""
  2539.  
  2540.     if (model == 1) then
  2541.     tex = "_textures"
  2542.     end
  2543.    
  2544.     if (repGenBoots or (db.player[idx].shoeType ~= 0)) then
  2545.     if (not getPlayerGenericBoot(db.player[idx].playerassetid)) then
  2546.    
  2547.     --bootstring = bootstring.."data/sceneassets/shoe/playershoe_0_0_"..db.player[idx].bootrand.."_0"..tex..".rx3;"
  2548.    
  2549.     bootstring = bootstring.."data/sceneassets/shoe/playershoe_"..db.player[idx].playerassetid.."_"..db.player[idx].teamid.."_"..db.player[idx].speckitType.."_"..db.player[idx].tournid..""..tex..".rx3;"
  2550.     bootstring = bootstring.."data/sceneassets/shoe/playershoe_"..db.player[idx].playerassetid.."_"..db.player[idx].teamid.."_"..db.player[idx].kitType.."_"..db.player[idx].tournid..""..tex..".rx3;"
  2551.     bootstring = bootstring.."data/sceneassets/shoe/playershoe_"..db.player[idx].playerassetid.."_"..db.player[idx].teamid.."_0_"..db.player[idx].tournid..""..tex..".rx3;"
  2552.     bootstring = bootstring.."data/sceneassets/shoe/playershoe_0_"..db.player[idx].teamid.."_0_"..db.player[idx].tournid..""..tex..".rx3;"
  2553.    
  2554.     bootstring = bootstring.."data/sceneassets/shoe/playershoe_0_0_0_"..db.player[idx].kitYearDecade..""..tex..".rx3;"
  2555.    
  2556.     bootstring = bootstring.."data/sceneassets/shoe/playershoe_0_"..db.player[idx].teamid.."_0_0"..tex..".rx3;"
  2557.     bootstring = bootstring.."data/sceneassets/shoe/playershoe_"..db.player[idx].playerassetid.."_"..db.player[idx].teamid.."_"..db.player[idx].speckitType.."_0"..tex..".rx3;"
  2558.     bootstring = bootstring.."data/sceneassets/shoe/playershoe_"..db.player[idx].playerassetid.."_"..db.player[idx].teamid.."_"..db.player[idx].kitType.."_0"..tex..".rx3;"
  2559.     bootstring = bootstring.."data/sceneassets/shoe/playershoe_"..db.player[idx].playerassetid.."_"..db.player[idx].teamid.."_0_0"..tex..".rx3;"
  2560.     bootstring = bootstring.."data/sceneassets/shoe/playershoe_"..db.player[idx].playerassetid.."_0_0_"..db.player[idx].tournid..""..tex..".rx3;"
  2561.    
  2562.     bootstring = bootstring.."data/sceneassets/shoe/playershoe_"..db.player[idx].playerassetid.."_0_"..db.player[idx].bootrand.."_0"..tex..".rx3;"
  2563.     bootstring = bootstring.."data/sceneassets/shoe/playershoe_"..db.player[idx].playerassetid.."_0_0_0"..tex..".rx3;"
  2564.    
  2565.     bootstring = bootstring.."data/sceneassets/shoelib/"..db.player[idx].bootname.."/shoe"..tex..".rx3;"
  2566.     end
  2567.     end
  2568.    
  2569.     return bootstring
  2570. end
  2571.  
  2572.  
  2573.  
  2574.    
  2575.  
  2576.  
  2577.  
  2578.  
  2579. function GetRMKit(idx,pos)
  2580.     local kitstring = ""
  2581.    
  2582.     local isfinal = getTournamentFinal(db.player[idx].tournid,db.player[idx].stadiumID,db.player[idx].crowdDistribution)
  2583.    
  2584.     if (db.player[idx].kitType ~= 5) then
  2585.    
  2586.     local speckitTypeItem = db.player[idx].speckitType
  2587.    
  2588.     if (pos == 2) then
  2589.     speckitTypeItem = db.player[idx].speckitTypeShort
  2590.     end
  2591.    
  2592.     if (pos == 3) then
  2593.     speckitTypeItem = db.player[idx].speckitTypeSock
  2594.     end
  2595.    
  2596.     -- if (pos == 1) then
  2597.     -- kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_999_"..db.player[idx].tournid..".rx3;"
  2598.     -- end
  2599.    
  2600.     if (isfinal) then
  2601.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(speckitTypeItem+200).."_"..db.player[idx].tournid..".rx3;"
  2602.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(db.player[idx].kitType+200).."_"..db.player[idx].tournid..".rx3;"
  2603.     end
  2604.    
  2605.  
  2606.  
  2607.    
  2608.     --new precedence year and tourn, only needed for "hotspots" (number positioning)
  2609.  
  2610.         --variables needed for new precedence:
  2611.         local as = gSportsRNA
  2612.         local wipe3d = as:GetTable("wvWipe", 1)
  2613.         local orgtournid = as:GetInt(wipe3d, "leagueID")
  2614.        
  2615.         kitstring = kitstring.."data/sceneassets/kit/"..db.player[idx].kitYear.."/kit_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..orgtournid..".rx3;"
  2616.  
  2617.     --end np
  2618.  
  2619.  
  2620.    
  2621.    
  2622.     --if (speckitTypeItem > -1) then
  2623.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(300000000+(speckitTypeItem*1000000)+db.player[idx].playerassetid).."_"..db.player[idx].tournidkit..".rx3;"
  2624.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(speckitTypeItem+100)..db.player[idx].kitNumberTens..db.player[idx].kitNumberUnits.."_"..db.player[idx].tournidkit..".rx3;"
  2625.     if (db.player[idx].kit < 10000) then
  2626.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(20000+(speckitTypeItem*100)+db.player[idx].shirtid).."_"..db.player[idx].tournidkit..".rx3;"
  2627.     end
  2628.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..((db.player[idx].gender*100)+speckitTypeItem).."_"..db.player[idx].tournidkit..".rx3;" --F
  2629.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..speckitTypeItem.."_"..db.player[idx].tournidkit..".rx3;"
  2630.  
  2631.     -- if ((db.player[idx].kitYearDecade > 0) and (pos == 1)) then
  2632.     -- kitstring = kitstring.."data/sceneassets/kit/kit_9_2_1984.rx3;"
  2633.     -- end
  2634.    
  2635.     if ((db.player[idx].kitYearDecade > 0) and (classicGKMode)) then
  2636.     if (db.player[idx].speckitType == 2) then
  2637.     if (pos == 1) then
  2638.     kitstring = kitstring.."data/sceneassets/kit/kit_5002_2_0.rx3;"
  2639.     else
  2640.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..db.player[idx].outfieldKitType.."_"..db.player[idx].tournidkit..".rx3;"
  2641.     end
  2642.     end
  2643.     end
  2644.    
  2645.    
  2646.    
  2647.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(300000000+(speckitTypeItem*1000000)+db.player[idx].playerassetid).."_0.rx3;"
  2648.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(speckitTypeItem+100)..db.player[idx].kitNumberTens..db.player[idx].kitNumberUnits.."_0.rx3;"
  2649.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(20000+(speckitTypeItem*100)+db.player[idx].shirtid).."_0.rx3;"
  2650.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..((db.player[idx].gender*100)+speckitTypeItem).."_0.rx3;" --F
  2651.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..speckitTypeItem.."_0.rx3;"
  2652.     --end
  2653.  
  2654.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(300000000+(db.player[idx].kitType*1000000)+db.player[idx].playerassetid).."_"..db.player[idx].tournidkit..".rx3;"
  2655.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(db.player[idx].kitType+100)..db.player[idx].kitNumberTens..db.player[idx].kitNumberUnits.."_"..db.player[idx].tournidkit..".rx3;"
  2656.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(20000+(db.player[idx].kitType*100)+db.player[idx].shirtid).."_"..db.player[idx].tournidkit..".rx3;"
  2657.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..((db.player[idx].gender*100)+db.player[idx].kitType).."_"..db.player[idx].tournidkit..".rx3;" --F
  2658.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..db.player[idx].tournidkit..".rx3;"
  2659.  
  2660.     -- if ((db.player[idx].kitYearDecade > 0) and (classicGKMode)) then
  2661.     -- if (pos == 1) then
  2662.     -- kitstring = kitstring.."data/sceneassets/kit/kit_5002_2_0.rx3;"
  2663.     -- else
  2664.     -- kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..db.player[idx].outfieldKitType.."_"..db.player[idx].tournidkit..".rx3;"
  2665.     -- end
  2666.     -- end
  2667.    
  2668.     if not ((db.player[idx].kitYearDecade > 0) and (classicGKMode)) then
  2669.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(300000000+(db.player[idx].kitType*1000000)+db.player[idx].playerassetid).."_0.rx3;"
  2670.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(db.player[idx].kitType+100)..db.player[idx].kitNumberTens..db.player[idx].kitNumberUnits.."_0.rx3;"
  2671.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..(20000+(db.player[idx].kitType*100)+db.player[idx].shirtid).."_0.rx3;"
  2672.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..((db.player[idx].gender*100)+db.player[idx].kitType).."_0.rx3;" --F
  2673.     end
  2674.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_0.rx3;"
  2675.    
  2676.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].genkit.."_"..db.player[idx].kitType.."_"..db.player[idx].kitYear..".rx3"
  2677.     end
  2678.    
  2679.  
  2680.  
  2681.    
  2682.    
  2683.     if (db.player[idx].kitType == 5) then
  2684.    
  2685.     --FOURTH OFFICIAL
  2686.     if ((db.player[idx].fourthofficialoption == 2) or ((db.player[idx].fourthofficialoption == 1) and (pos == 1))) then
  2687.     if (idx == 57) then
  2688.     kitstring = kitstring.."data/sceneassets/kit/kit_6004_99_"..db.player[idx].tournidref..".rx3;"
  2689.     kitstring = kitstring.."data/sceneassets/kit/kit_6004_99_"..db.player[idx].defaulttournid..".rx3;"
  2690.     kitstring = kitstring.."data/sceneassets/kit/kit_6004_99_0.rx3;"
  2691.     end
  2692.     end
  2693.    
  2694.     kitstring = kitstring.."data/sceneassets/kit/specifickit_6004_"..db.player[idx].kitType.."_"..db.player[idx].tournidref.."_"..db.player[idx].homeKitTeamID.."_"..db.player[idx].awayKitTeamID..".rx3;"
  2695.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..((db.player[idx].gender*100)+db.player[idx].kitType).."_"..db.player[idx].tournidref..".rx3;"
  2696.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..db.player[idx].tournidref..".rx3;"
  2697.     kitstring = kitstring.."data/sceneassets/kit/kit_6004_"..((db.player[idx].gender*100)+db.player[idx].kitType).."_"..db.player[idx].tournidref..".rx3;"
  2698.     kitstring = kitstring.."data/sceneassets/kit/kit_6004_"..db.player[idx].kitType.."_"..db.player[idx].tournidref..".rx3;"
  2699.    
  2700.     --kitstring = kitstring.."data/sceneassets/kit/specifickit_6004_"..db.player[idx].kitType.."_"..db.player[idx].kitYearDecade.."_"..db.player[idx].homeKitTeamID.."_"..db.player[idx].awayKitTeamID..".rx3;"
  2701.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..db.player[idx].kitYearDecade..".rx3;"
  2702.     kitstring = kitstring.."data/sceneassets/kit/kit_6004_"..db.player[idx].kitType.."_"..db.player[idx].kitYearDecade..".rx3;"
  2703.    
  2704.     kitstring = kitstring.."data/sceneassets/kit/specifickit_6004_"..db.player[idx].kitType.."_"..db.player[idx].defaulttournid.."_"..db.player[idx].homeKitTeamID.."_"..db.player[idx].awayKitTeamID..".rx3;"
  2705.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..((db.player[idx].gender*100)+db.player[idx].kitType).."_"..db.player[idx].defaulttournid..".rx3;"
  2706.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..db.player[idx].defaulttournid..".rx3;"
  2707.     kitstring = kitstring.."data/sceneassets/kit/kit_6004_"..((db.player[idx].gender*100)+db.player[idx].kitType).."_"..db.player[idx].defaulttournid..".rx3;"
  2708.     kitstring = kitstring.."data/sceneassets/kit/kit_6004_"..db.player[idx].kitType.."_"..db.player[idx].defaulttournid..".rx3;"
  2709.    
  2710.     if ((db.player[idx].gender == 0) or (enableEAFemaleRefereeKits)) then
  2711.     if (db.player[idx].genkit > 6100) then
  2712.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].genkit.."_"..((db.player[idx].gender*100)+db.player[idx].kitType).."_0.rx3;"
  2713.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].genkit.."_"..db.player[idx].kitType.."_0.rx3;"
  2714.     end
  2715.     end
  2716.    
  2717.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..((db.player[idx].gender*100)+db.player[idx].kitType).."_0.rx3;"
  2718.     kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_0.rx3;"
  2719.    
  2720.    
  2721.     kitstring = kitstring.."data/sceneassets/kit/kit_6004_"..((db.player[idx].gender*100)+db.player[idx].kitType).."_0.rx3;"
  2722.     kitstring = kitstring.."data/sceneassets/kit/kit_6004_"..db.player[idx].kitType.."_0.rx3"
  2723.     end
  2724.    
  2725.    
  2726.    
  2727.     return kitstring
  2728. end
  2729.  
  2730.  
  2731. function GetRMSkin(idx)
  2732.     local skinstring = ""
  2733.     skinstring = skinstring.."data/sceneassets/body/playerskin_"..db.player[idx].playerassetid.."_"..db.player[idx].kit.."_"..db.player[idx].speckitType.."_"..db.player[idx].useWinterAcc.."_textures.rx3;"
  2734.     skinstring = skinstring.."data/sceneassets/body/playerskin_"..db.player[idx].playerassetid.."_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..db.player[idx].useWinterAcc.."_textures.rx3;"
  2735.     skinstring = skinstring.."data/sceneassets/body/playerskin_"..db.player[idx].playerassetid.."_"..db.player[idx].kit.."_"..db.player[idx].speckitType.."_0_textures.rx3;"
  2736.     skinstring = skinstring.."data/sceneassets/body/playerskin_"..db.player[idx].playerassetid.."_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_0_textures.rx3;"
  2737.     skinstring = skinstring.."data/sceneassets/body/playerskin_"..db.player[idx].playerassetid.."_textures.rx3;"
  2738.     skinstring = skinstring.."data/sceneassets/body/playerskin_0_"..db.player[idx].kit.."_0_0_textures.rx3;"
  2739.     return skinstring
  2740. end
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.  
  2749. tournamentRefereeKitsCollar = {}
  2750.  
  2751. function assignTournamentRefereeKitCollar(tournament,collar)
  2752. tournamentRefereeKitsCollar[tournament] = collar
  2753. end
  2754.  
  2755.  
  2756.  
  2757. function getTournamentRefereeKitsCollar(tourn,id,teamtourn)
  2758.  
  2759. if (tournamentRefereeKitsCollar[tourn] ~= nil) then
  2760. return tournamentRefereeKitsCollar[tourn]
  2761. end
  2762.  
  2763. if (tournamentRefereeKitsCollar[teamtourn] ~= nil) then
  2764. return tournamentRefereeKitsCollar[teamtourn]
  2765. end
  2766.  
  2767. return id
  2768. end
  2769.  
  2770.  
  2771.  
  2772. gkPants = {}
  2773. gkPantsTraining = {}
  2774. gkPantsWinter = {}
  2775. gkPantsSnow = {}
  2776.  
  2777. function assignGKPants(id)
  2778. gkPants[id] = 1
  2779. end
  2780.  
  2781. function assignGKPantsTraining(id)
  2782. gkPantsTraining[id] = 1
  2783. end
  2784.  
  2785. function assignGKPantsWinter(id)
  2786. gkPantsWinter[id] = 1
  2787. end
  2788.  
  2789. function assignGKPantsSnow(id)
  2790. gkPantsSnow[id] = 1
  2791. end
  2792.  
  2793. function getGKPants(id,pant,tr,weather,winter)
  2794.  
  2795. if ((tr > 90) and (tr < 97)) then
  2796. if (gkPantsTraining[id] ~= nil) then
  2797. return gkPantsTraining[id]
  2798. end
  2799. end
  2800.  
  2801. if (weather == 2) then
  2802. if (gkPantsSnow[id] ~= nil) then
  2803. return gkPantsSnow[id]
  2804. end
  2805. end
  2806.  
  2807. if (winter == 1) then
  2808. if (gkPantsWinter[id] ~= nil) then
  2809. return gkPantsWinter[id]
  2810. end
  2811. end
  2812.  
  2813. if (gkPants[id] ~= nil) then
  2814. return gkPants[id]
  2815. end
  2816.  
  2817. return pant
  2818. end
  2819.  
  2820.  
  2821. playerFace = {}
  2822.  
  2823. function assignPlayerFace(id)
  2824. playerFace[id] = 0
  2825. end
  2826.  
  2827. function getPlayerFace(id,headtype)
  2828.  
  2829. if (playerFace[id] ~= nil) then
  2830. return playerFace[id]
  2831. end
  2832.  
  2833. return headtype
  2834. end
  2835.  
  2836.  
  2837. gkKits = {}
  2838.  
  2839. function assignGKKit(team,player,gk)
  2840.  
  2841. if (type(gk) == "number") then
  2842. assignGKKitPrecedence(team,player,1,{gk})
  2843. else
  2844. assignGKKitPrecedence(team,player,1,gk)
  2845. end
  2846.  
  2847.  
  2848. -- if (gkKits[team] == nil) then
  2849. -- gkKits[team] = {}
  2850. -- end
  2851.  
  2852. -- if (type(gk) == "number") then
  2853. -- gkKits[team][player] = gk
  2854. -- else
  2855. -- if (gkKits[team][player] == nil)then
  2856. -- gkKits[team][player] = gk[math.random(#gk)]
  2857. -- end
  2858. -- end
  2859.  
  2860. end
  2861.  
  2862. function getGKKit(team,player,home,away,gk,spec)
  2863.  
  2864. -- if (matchKit[team] ~= nil) then
  2865. -- if (matchKit[team][home] ~= nil) then
  2866. -- if (matchKit[team][home][away] ~= nil) then
  2867. -- if (matchKit[team][home][away][gk] ~= nil) then
  2868. -- return matchKit[team][home][away][gk]
  2869. -- end
  2870. -- end
  2871. -- end
  2872. -- end
  2873.  
  2874. -- if (swapKit[team] ~= nil) then
  2875. -- if (swapKit[team][gk] ~= nil) then
  2876. -- return swapKit[team][gk]
  2877. -- end
  2878. -- end
  2879.  
  2880. -- if (gkKits[team] ~= nil) then
  2881. -- if (gkKits[team][player] ~= nil) then
  2882. -- return gkKits[team][player]
  2883. -- end
  2884. -- end
  2885.  
  2886. return spec
  2887. end
  2888.  
  2889.  
  2890. --KIT DETAILS START
  2891.  
  2892. kitCollar = {}
  2893. kitNumberSet = {}
  2894. kitNumberColourShirt = {}
  2895. kitNumberColourShort = {}
  2896. kitNameFont = {}
  2897. kitNameColour = {}
  2898. kitFit = {}
  2899. kitNameCurve = {}
  2900.  
  2901.  
  2902. function assignKitDetails(team,kit,namefont,namecolour,lay,numberset,numbercolourshirt,numbercolourshort,fit,collar)
  2903.  
  2904. if (kitCollar[team] == nil) then
  2905. kitCollar[team] = {}
  2906. end
  2907.  
  2908. if (kitNumberSet[team] == nil) then
  2909. kitNumberSet[team] = {}
  2910. end
  2911.  
  2912. if (kitNumberColourShirt[team] == nil) then
  2913. kitNumberColourShirt[team] = {}
  2914. end
  2915.  
  2916. if (kitNumberColourShort[team] == nil) then
  2917. kitNumberColourShort[team] = {}
  2918. end
  2919.  
  2920. if (kitNameFont[team] == nil) then
  2921. kitNameFont[team] = {}
  2922. end
  2923.  
  2924. if (kitNameColour[team] == nil) then
  2925. kitNameColour[team] = {}
  2926. end
  2927.  
  2928. if (kitFit[team] == nil) then
  2929. kitFit[team] = {}
  2930. end
  2931.  
  2932. if (kitNameCurve[team] == nil) then
  2933. kitNameCurve[team] = {}
  2934. end
  2935.  
  2936.  
  2937. kitCollar[team][kit] = collar
  2938. kitNumberSet[team][kit] = numberset
  2939. kitNumberColourShirt[team][kit] = numbercolourshirt
  2940. kitNumberColourShort[team][kit] = numbercolourshort
  2941. kitNameFont[team][kit] = namefont
  2942.  
  2943. if (namecolour ~= -1) then
  2944. kitNameColour[team][kit] = hex(namecolour)
  2945. end
  2946.  
  2947. kitFit[team][kit] = fit
  2948. kitNameCurve[team][kit] = lay
  2949. end
  2950.  
  2951.  
  2952. kitCollarTournament = {}
  2953. kitNumberSetTournament = {}
  2954. kitNumberColourShirtTournament = {}
  2955. kitNumberColourShortTournament = {}
  2956. kitNameFontTournament = {}
  2957. kitNameColourTournament = {}
  2958. kitFitTournament = {}
  2959. kitNameCurveTournament = {}
  2960.  
  2961.  
  2962. function assignTournamentKitDetails(team,kit,tournament,namefont,namecolour,lay,numberset,numbercolourshirt,numbercolourshort,fit,collar)
  2963.  
  2964. if (kitCollarTournament[team] == nil) then
  2965. kitCollarTournament[team] = {}
  2966. end
  2967.  
  2968. if (kitNumberSetTournament[team] == nil) then
  2969. kitNumberSetTournament[team] = {}
  2970. end
  2971.  
  2972. if (kitNumberColourShirtTournament[team] == nil) then
  2973. kitNumberColourShirtTournament[team] = {}
  2974. end
  2975.  
  2976. if (kitNumberColourShortTournament[team] == nil) then
  2977. kitNumberColourShortTournament[team] = {}
  2978. end
  2979.  
  2980. if (kitNameFontTournament[team] == nil) then
  2981. kitNameFontTournament[team] = {}
  2982. end
  2983.  
  2984. if (kitNameColourTournament[team] == nil) then
  2985. kitNameColourTournament[team] = {}
  2986. end
  2987.  
  2988. if (kitFitTournament[team] == nil) then
  2989. kitFitTournament[team] = {}
  2990. end
  2991.  
  2992. if (kitNameCurveTournament[team] == nil) then
  2993. kitNameCurveTournament[team] = {}
  2994. end
  2995.  
  2996.  
  2997.  
  2998. if (kitCollarTournament[team][kit] == nil) then
  2999. kitCollarTournament[team][kit] = {}
  3000. end
  3001.  
  3002. if (kitNumberSetTournament[team][kit] == nil) then
  3003. kitNumberSetTournament[team][kit] = {}
  3004. end
  3005.  
  3006. if (kitNumberColourShirtTournament[team][kit] == nil) then
  3007. kitNumberColourShirtTournament[team][kit] = {}
  3008. end
  3009.  
  3010. if (kitNumberColourShortTournament[team][kit] == nil) then
  3011. kitNumberColourShortTournament[team][kit] = {}
  3012. end
  3013.  
  3014. if (kitNameFontTournament[team][kit] == nil) then
  3015. kitNameFontTournament[team][kit] = {}
  3016. end
  3017.  
  3018. if (kitNameColourTournament[team][kit] == nil) then
  3019. kitNameColourTournament[team][kit] = {}
  3020. end
  3021.  
  3022. if (kitFitTournament[team][kit] == nil) then
  3023. kitFitTournament[team][kit] = {}
  3024. end
  3025.  
  3026. if (kitNameCurveTournament[team][kit] == nil) then
  3027. kitNameCurveTournament[team][kit] = {}
  3028. end
  3029.  
  3030.  
  3031.  
  3032. kitCollarTournament[team][kit][tournament] = collar
  3033. kitNumberSetTournament[team][kit][tournament] = numberset
  3034. kitNumberColourShirtTournament[team][kit][tournament] = numbercolourshirt
  3035. kitNumberColourShortTournament[team][kit][tournament] = numbercolourshort
  3036. kitNameFontTournament[team][kit][tournament] = namefont
  3037.  
  3038. if (namecolour ~= -1) then
  3039. kitNameColourTournament[team][kit][tournament] = hex(namecolour)
  3040. end
  3041.  
  3042. kitFitTournament[team][kit][tournament] = fit
  3043. kitNameCurveTournament[team][kit][tournament] = lay
  3044. end
  3045.  
  3046.  
  3047. --this is new
  3048.  
  3049. kitYearCollarTournament = {}
  3050. kitYearNumberSetTournament = {}
  3051. kitYearNumberColourShirtTournament = {}
  3052. kitYearNumberColourShortTournament = {}
  3053. kitYearNameFontTournament = {}
  3054. kitYearNameColourTournament = {}
  3055. kitYearFitTournament = {}
  3056. kitYearNameCurveTournament = {}
  3057.  
  3058.  
  3059. function assignKitYearTournamentDetails(kityear,team,kit,tournament,namefont,namecolour,lay,numberset,numbercolourshirt,numbercolourshort,fit,collar)
  3060.  
  3061. if (kitYearCollarTournament[team] == nil) then
  3062. kitYearCollarTournament[team] = {}
  3063. end
  3064.  
  3065. if (kitYearNumberSetTournament[team] == nil) then
  3066. kitYearNumberSetTournament[team] = {}
  3067. end
  3068.  
  3069. if (kitYearNumberColourShirtTournament[team] == nil) then
  3070. kitYearNumberColourShirtTournament[team] = {}
  3071. end
  3072.  
  3073. if (kitYearNumberColourShortTournament[team] == nil) then
  3074. kitYearNumberColourShortTournament[team] = {}
  3075. end
  3076.  
  3077. if (kitYearNameFontTournament[team] == nil) then
  3078. kitYearNameFontTournament[team] = {}
  3079. end
  3080.  
  3081. if (kitYearNameColourTournament[team] == nil) then
  3082. kitYearNameColourTournament[team] = {}
  3083. end
  3084.  
  3085. if (kitYearFitTournament[team] == nil) then
  3086. kitYearFitTournament[team] = {}
  3087. end
  3088.  
  3089. if (kitYearNameCurveTournament[team] == nil) then
  3090. kitYearNameCurveTournament[team] = {}
  3091. end
  3092.  
  3093.  
  3094.  
  3095. if (kitYearCollarTournament[team][kit] == nil) then
  3096. kitYearCollarTournament[team][kit] = {}
  3097. end
  3098.  
  3099. if (kitYearNumberSetTournament[team][kit] == nil) then
  3100. kitYearNumberSetTournament[team][kit] = {}
  3101. end
  3102.  
  3103. if (kitYearNumberColourShirtTournament[team][kit] == nil) then
  3104. kitYearNumberColourShirtTournament[team][kit] = {}
  3105. end
  3106.  
  3107. if (kitYearNumberColourShortTournament[team][kit] == nil) then
  3108. kitYearNumberColourShortTournament[team][kit] = {}
  3109. end
  3110.  
  3111. if (kitYearNameFontTournament[team][kit] == nil) then
  3112. kitYearNameFontTournament[team][kit] = {}
  3113. end
  3114.  
  3115. if (kitYearNameColourTournament[team][kit] == nil) then
  3116. kitYearNameColourTournament[team][kit] = {}
  3117. end
  3118.  
  3119. if (kitYearFitTournament[team][kit] == nil) then
  3120. kitYearFitTournament[team][kit] = {}
  3121. end
  3122.  
  3123. if (kitYearNameCurveTournament[team][kit] == nil) then
  3124. kitYearNameCurveTournament[team][kit] = {}
  3125. end
  3126.  
  3127.  
  3128.  
  3129.  
  3130.  
  3131. if (kitYearCollarTournament[team][kit][kityear] == nil) then
  3132. kitYearCollarTournament[team][kit][kityear] = {}
  3133. end
  3134.  
  3135. if (kitYearNumberSetTournament[team][kit][kityear] == nil) then
  3136. kitYearNumberSetTournament[team][kit][kityear] = {}
  3137. end
  3138.  
  3139. if (kitYearNumberColourShirtTournament[team][kit][kityear] == nil) then
  3140. kitYearNumberColourShirtTournament[team][kit][kityear] = {}
  3141. end
  3142.  
  3143. if (kitYearNumberColourShortTournament[team][kit][kityear] == nil) then
  3144. kitYearNumberColourShortTournament[team][kit][kityear] = {}
  3145. end
  3146.  
  3147. if (kitYearNameFontTournament[team][kit][kityear] == nil) then
  3148. kitYearNameFontTournament[team][kit][kityear] = {}
  3149. end
  3150.  
  3151. if (kitYearNameColourTournament[team][kit][kityear] == nil) then
  3152. kitYearNameColourTournament[team][kit][kityear] = {}
  3153. end
  3154.  
  3155. if (kitYearFitTournament[team][kit][kityear] == nil) then
  3156. kitYearFitTournament[team][kit][kityear] = {}
  3157. end
  3158.  
  3159. if (kitYearNameCurveTournament[team][kit][kityear] == nil) then
  3160. kitYearNameCurveTournament[team][kit][kityear] = {}
  3161. end
  3162.  
  3163. kitYearCollarTournament[team][kit][kityear][tournament] = collar
  3164. kitYearNumberSetTournament[team][kit][kityear][tournament] = numberset
  3165. kitYearNumberColourShirtTournament[team][kit][kityear][tournament] = numbercolourshirt
  3166. kitYearNumberColourShortTournament[team][kit][kityear][tournament] = numbercolourshort
  3167. kitYearNameFontTournament[team][kit][kityear][tournament] = namefont
  3168.  
  3169. if (namecolour ~= -1) then
  3170. kitYearNameColourTournament[team][kit][kityear][tournament] = hex(namecolour)
  3171. end
  3172.  
  3173. kitYearFitTournament[team][kit][kityear][tournament] = fit
  3174. kitYearNameCurveTournament[team][kit][kityear][tournament] = lay
  3175. end
  3176.  
  3177. function getKitCollar(team,kit,item,tournament)
  3178.  
  3179. if (kitCollarTournament[team] ~= nil) then
  3180. if (kitCollarTournament[team][kit] ~= nil) then
  3181. if ((kitCollarTournament[team][kit][tournament] ~= nil) and (kitCollarTournament[team][kit][tournament] ~= -1)) then
  3182. return kitCollarTournament[team][kit][tournament]
  3183. end
  3184. end
  3185. end
  3186.  
  3187. if (tournament < 1800) then
  3188.  
  3189. if (kitCollar[team] ~= nil) then
  3190. if ((kitCollar[team][kit] ~= nil) and (kitCollar[team][kit] ~= -1)) then
  3191. return kitCollar[team][kit]
  3192. end
  3193. end
  3194.  
  3195. end
  3196.  
  3197. return item
  3198. end
  3199.  
  3200. function getKitNumberSet(team,kit,item,tournament,teamdef)
  3201.  
  3202. if (kitNumberSetTournament[team] ~= nil) then
  3203. if (kitNumberSetTournament[team][kit] ~= nil) then
  3204. if ((kitNumberSetTournament[team][kit][tournament] ~= nil) and (kitNumberSetTournament[team][kit][tournament] ~= -1)) then
  3205. return kitNumberSetTournament[team][kit][tournament]
  3206. end
  3207. end
  3208. end
  3209.  
  3210.  
  3211. if (tournament < 1800) then
  3212.  
  3213. if (kitNumberSet[team] ~= nil) then
  3214. if ((kitNumberSet[team][kit] ~= nil) and (kitNumberSet[team][kit] ~= -1)) then
  3215. return kitNumberSet[team][kit]
  3216. end
  3217. end
  3218.  
  3219. end
  3220.  
  3221. return item
  3222. end
  3223.  
  3224. --edited
  3225. function getKitNumberColourShirt(team,kit,item,tournament,orgtourn)
  3226.  
  3227. if (kitYearNumberColourShirtTournament[team] ~= nil) then
  3228.     if (kitYearNumberColourShirtTournament[team][kit] ~= nil) then
  3229.         if (kitYearNumberColourShirtTournament[team][kit][tournament] ~= nil) then
  3230.             if ((kitYearNumberColourShirtTournament[team][kit][tournament][orgtourn] ~= nil) and (kitYearNumberColourShirtTournament[team][kit][tournament][orgtourn] ~= -1)) then
  3231.                 return kitYearNumberColourShirtTournament[team][kit][tournament][orgtourn]
  3232.             end
  3233.         end
  3234.     end
  3235. end
  3236.  
  3237. if (kitNumberColourShirtTournament[team] ~= nil) then
  3238. if (kitNumberColourShirtTournament[team][kit] ~= nil) then
  3239. if ((kitNumberColourShirtTournament[team][kit][tournament] ~= nil) and (kitNumberColourShirtTournament[team][kit][tournament] ~= -1)) then
  3240. return kitNumberColourShirtTournament[team][kit][tournament]
  3241. end
  3242. end
  3243. end
  3244.  
  3245. if (tournament < 1800) then
  3246.  
  3247. if (kitNumberColourShirt[team] ~= nil) then
  3248. if ((kitNumberColourShirt[team][kit] ~= nil) and (kitNumberColourShirt[team][kit] ~= -1)) then
  3249. return kitNumberColourShirt[team][kit]
  3250. end
  3251. end
  3252.  
  3253. end
  3254.  
  3255. return item
  3256. end
  3257.  
  3258. --edited
  3259. function getKitNumberColourShort(team,kit,item,tournament,orgtourn)
  3260.  
  3261. if (kitYearNumberColourShortTournament[team] ~= nil) then
  3262.     if (kitYearNumberColourShortTournament[team][kit] ~= nil) then
  3263.         if (kitYearNumberColourShortTournament[team][kit][tournament] ~= nil) then
  3264.             if ((kitYearNumberColourShortTournament[team][kit][tournament][orgtourn] ~= nil) and (kitYearNumberColourShortTournament[team][kit][tournament][orgtourn] ~= -1)) then
  3265.                 return kitYearNumberColourShortTournament[team][kit][tournament][orgtourn]
  3266.             end
  3267.         end
  3268.     end
  3269. end
  3270.  
  3271. if (kitNumberColourShortTournament[team] ~= nil) then
  3272. if (kitNumberColourShortTournament[team][kit] ~= nil) then
  3273. if ((kitNumberColourShortTournament[team][kit][tournament] ~= nil) and (kitNumberColourShortTournament[team][kit][tournament] ~= -1)) then
  3274. return kitNumberColourShortTournament[team][kit][tournament]
  3275. end
  3276. end
  3277. end
  3278.  
  3279. if (tournament < 1800) then
  3280.  
  3281. if (kitNumberColourShort[team] ~= nil) then
  3282. if ((kitNumberColourShort[team][kit] ~= nil) and (kitNumberColourShort[team][kit] ~= -1)) then
  3283. return kitNumberColourShort[team][kit]
  3284. end
  3285. end
  3286.  
  3287. end
  3288.  
  3289. return item
  3290. end
  3291.  
  3292. function getKitNameFont(team,kit,item,tournament,teamdef)
  3293.  
  3294. if (kitNameFontTournament[team] ~= nil) then
  3295. if (kitNameFontTournament[team][kit] ~= nil) then
  3296. if ((kitNameFontTournament[team][kit][tournament] ~= nil) and (kitNameFontTournament[team][kit][tournament] ~= -1)) then
  3297. return kitNameFontTournament[team][kit][tournament]
  3298. end
  3299. end
  3300. end
  3301.  
  3302.  
  3303. if (tournament < 1800) then
  3304.  
  3305. if (kitNameFont[team] ~= nil) then
  3306. if ((kitNameFont[team][kit] ~= nil) and (kitNameFont[team][kit] ~= -1)) then
  3307. return kitNameFont[team][kit]
  3308. end
  3309. end
  3310.  
  3311. end
  3312.  
  3313. return item
  3314. end
  3315.  
  3316. --edited
  3317. function getKitNameColour(team,kit,item,tournament,orgtourn)
  3318.  
  3319. if (kitYearNameColourTournament[team] ~= nil) then
  3320.     if (kitYearNameColourTournament[team][kit] ~= nil) then
  3321.         if (kitYearNameColourTournament[team][kit][tournament] ~= nil) then
  3322.             if ((kitYearNameColourTournament[team][kit][tournament][orgtourn] ~= nil) and (kitYearNameColourTournament[team][kit][tournament][orgtourn] ~= -1)) then
  3323.                 return kitYearNameColourTournament[team][kit][tournament][orgtourn]
  3324.             end
  3325.         end
  3326.     end
  3327. end
  3328.  
  3329. if (kitNameColourTournament[team] ~= nil) then
  3330. if (kitNameColourTournament[team][kit] ~= nil) then
  3331. if ((kitNameColourTournament[team][kit][tournament] ~= nil) and (kitNameColourTournament[team][kit][tournament] ~= -1)) then
  3332. return kitNameColourTournament[team][kit][tournament]
  3333. end
  3334. end
  3335.  
  3336. end
  3337.  
  3338. if (tournament < 1800) then
  3339.  
  3340. if (kitNameColour[team] ~= nil) then
  3341. if ((kitNameColour[team][kit] ~= nil) and (kitNameColour[team][kit] ~= -1)) then
  3342. return kitNameColour[team][kit]
  3343. end
  3344. end
  3345.  
  3346. end
  3347.  
  3348. return item
  3349. end
  3350.  
  3351. function getKitFit(team,kit,item,tournament,player)
  3352.  
  3353. if (globalJerseyFit ~= nil) then
  3354. return globalJerseyFit
  3355. end
  3356.  
  3357. if (kitFitTournament[team] ~= nil) then
  3358. if (kitFitTournament[team][kit] ~= nil) then
  3359. if ((kitFitTournament[team][kit][tournament] ~= nil) and (kitFitTournament[team][kit][tournament] ~= -1)) then
  3360. return kitFitTournament[team][kit][tournament]
  3361. end
  3362. end
  3363. end
  3364.  
  3365. if (tournament < 1800) then
  3366.  
  3367. if (kitFit[team] ~= nil) then
  3368. if ((kitFit[team][kit] ~= nil) and (kitFit[team][kit] ~= -1)) then
  3369. return kitFit[team][kit]
  3370. end
  3371. end
  3372.  
  3373. end
  3374.  
  3375. if (kitFitPlayer[player] ~= nil) then
  3376. return kitFitPlayer[player]
  3377. end
  3378.  
  3379. return item
  3380. end
  3381.  
  3382. --edited
  3383. function getKitNameCurve(team,kit,lay,tournament,orgtourn)
  3384.  
  3385. if (kitYearNameCurveTournament[team] ~= nil) then
  3386.     if (kitYearNameCurveTournament[team][kit] ~= nil) then
  3387.         if (kitYearNameCurveTournament[team][kit][tournament] ~= nil) then
  3388.             if ((kitYearNameCurveTournament[team][kit][tournament][orgtourn] ~= nil) and (kitYearNameCurveTournament[team][kit][tournament][orgtourn] ~= -1)) then
  3389.                 return kitYearNameCurveTournament[team][kit][tournament][orgtourn]
  3390.             end
  3391.         end
  3392.     end
  3393. end
  3394.  
  3395. if (kitNameCurveTournament[team] ~= nil) then
  3396. if (kitNameCurveTournament[team][kit] ~= nil) then
  3397. if ((kitNameCurveTournament[team][kit][tournament] ~= nil) and (kitNameCurveTournament[team][kit][tournament] ~= -1)) then
  3398. return kitNameCurveTournament[team][kit][tournament]
  3399. end
  3400. end
  3401. end
  3402.  
  3403. if (tournament < 1800) then
  3404.  
  3405. if (kitNameCurve[team] ~= nil) then
  3406. if ((kitNameCurve[team][kit] ~= nil) and (kitNameCurve[team][kit] ~= -1)) then
  3407. return kitNameCurve[team][kit]
  3408. end
  3409. end
  3410.  
  3411. end
  3412.  
  3413. return lay
  3414.  
  3415.  
  3416.  
  3417. end
  3418.  
  3419.  
  3420.  
  3421. --new end
  3422.  
  3423. --KIT DETAILS END
  3424.  
  3425.  
  3426. jerseyTuck = {}
  3427.  
  3428. function setJerseyTuck(player,option)
  3429.  
  3430. if (type(option) == "number") then
  3431. jerseyTuck[player] = option
  3432. else
  3433. jerseyTuck[player] = option[math.random(#option)]
  3434. end
  3435.  
  3436. --jerseyTuck[player] = tuck
  3437. end
  3438.  
  3439. function getJerseyTuck(player,tuck)
  3440.  
  3441. if (jerseyTuck[player] ~= nil) then
  3442. return jerseyTuck[player]
  3443. end
  3444.  
  3445. return tuck
  3446. end
  3447.  
  3448.  
  3449. sockHeight = {}
  3450.  
  3451. function setSockHeight(player,sock)
  3452. sockHeight[player] = sock
  3453. end
  3454.  
  3455. function getSockHeight(player,sock)
  3456.  
  3457. if (sockHeight[player] ~= nil) then
  3458. return sockHeight[player]
  3459. end
  3460.  
  3461. return sock
  3462. end
  3463.  
  3464.  
  3465.  
  3466. matchKit = {}
  3467. matchKitTourn = {}
  3468.  
  3469. function assignGameKit(team,home,away,type1,type2)
  3470.  
  3471. if (matchKit[team] == nil) then
  3472. matchKit[team] = {}
  3473. end
  3474.  
  3475. if (matchKit[team][home] == nil) then
  3476. matchKit[team][home] = {}
  3477. end
  3478.  
  3479. if (matchKit[team][home][away] == nil) then
  3480. matchKit[team][home][away] = {}
  3481. end
  3482.  
  3483. if (type(type2) == "number") then
  3484. matchKit[team][home][away][type1] = type2
  3485. else
  3486. if (matchKit[team][home][away][type1] == nil) then
  3487. matchKit[team][home][away][type1] = type2[math.random(#type2)]
  3488. end
  3489. end
  3490.  
  3491. end
  3492.  
  3493. function assignGameKitTournament(team,home,away,tourn,type1,type2)
  3494.  
  3495. if (matchKitTourn[team] == nil) then
  3496. matchKitTourn[team] = {}
  3497. end
  3498.  
  3499. if (matchKitTourn[team][home] == nil) then
  3500. matchKitTourn[team][home] = {}
  3501. end
  3502.  
  3503. if (matchKitTourn[team][home][away] == nil) then
  3504. matchKitTourn[team][home][away] = {}
  3505. end
  3506.  
  3507. if (matchKitTourn[team][home][away][tourn] == nil) then
  3508. matchKitTourn[team][home][away][tourn] = {}
  3509. end
  3510.  
  3511. if (type(type2) == "number") then
  3512. matchKitTourn[team][home][away][tourn][type1] = type2
  3513. else
  3514. if (matchKitTourn[team][home][away][tourn][type1] == nil) then
  3515. matchKitTourn[team][home][away][tourn][type1] = type2[math.random(#type2)]
  3516. end
  3517. end
  3518.  
  3519. end
  3520.  
  3521. function getGameKit(team,home,away,tourn,type1,type2)
  3522.  
  3523. if (matchKitTourn[team] ~= nil) then
  3524. if (matchKitTourn[team][home] ~= nil) then
  3525. if (matchKitTourn[team][home][away] ~= nil) then
  3526. if (matchKitTourn[team][home][away][tourn] ~= nil) then
  3527. if (matchKitTourn[team][home][away][tourn][type1] ~= nil) then
  3528. return matchKitTourn[team][home][away][tourn][type1]
  3529. end
  3530. end
  3531. end
  3532. end
  3533. end
  3534.  
  3535. if (matchKit[team] ~= nil) then
  3536. if (matchKit[team][home] ~= nil) then
  3537. if (matchKit[team][home][away] ~= nil) then
  3538. if (matchKit[team][home][away][type1] ~= nil) then
  3539. return matchKit[team][home][away][type1]
  3540. end
  3541. end
  3542. end
  3543. end
  3544.  
  3545. -- if (swapKit[team] ~= nil) then
  3546. -- if (swapKit[team][type1] ~= nil) then
  3547. -- return swapKit[team][type1]
  3548. -- end
  3549. -- end
  3550.  
  3551. return type2
  3552. end
  3553.  
  3554.  
  3555. function getSwapKit(team,type1,tourn)
  3556.  
  3557. -- if (swapKitSet[team] ~= nil) then
  3558. -- if (swapKitSet[team][kitsetactiveid] ~= nil) then
  3559. -- if (swapKitSet[team][kitsetactiveid][type1] ~= nil) then
  3560. -- return swapKitSet[team][kitsetactiveid][type1]
  3561. -- end
  3562. -- end
  3563. -- end
  3564.  
  3565. if (swapKitTourn[team] ~= nil) then
  3566. if (swapKitTourn[team][tourn] ~= nil) then
  3567. if (swapKitTourn[team][tourn][type1] ~= nil) then
  3568. return swapKitTourn[team][tourn][type1]
  3569. end
  3570. end
  3571. end
  3572.  
  3573. if (swapKit[team] ~= nil) then
  3574. if (swapKit[team][type1] ~= nil) then
  3575. return swapKit[team][type1]
  3576. end
  3577. end
  3578.  
  3579. return type1
  3580. end
  3581.  
  3582.  
  3583. function hex(s)
  3584.  
  3585. return tonumber(s,16) + 4278190080
  3586.  
  3587. end
  3588.  
  3589.  
  3590.  
  3591.  
  3592. --nameColourCodes = {"d5d9d5", "0d0c0d", "0046b0", "a00005", "e8d628", "007a00", "f88500", "7a19b8", "553210", "ed80b0", "750e05", "7dc1f0", "001450", "a0a2a0", "c5c965", "98864d", "f8c932", "c53232", "003c00"}
  3593.  
  3594.  
  3595. kitFitPlayer = {}
  3596.  
  3597. function setJerseyFit(player,fit)
  3598. kitFitPlayer[player] = fit
  3599. end
  3600.  
  3601.  
  3602.  
  3603.  
  3604. winterAccessoriesRef = nil
  3605.  
  3606. function useGlobalRefereeWinterAccessories(option)
  3607. winterAccessoriesRef = option
  3608. end
  3609.  
  3610. function getRefereeWinterAccessories(option)
  3611.  
  3612. if (winterAccessoriesRef ~= nil) then
  3613. return winterAccessoriesRef
  3614. end
  3615.  
  3616. return option
  3617. end
  3618.  
  3619.  
  3620. globalJerseyFit = nil
  3621.  
  3622. function useGlobalJerseyFit(option)
  3623. globalJerseyFit = option
  3624. end
  3625.  
  3626.  
  3627. swapKit = {}
  3628. swapKitTourn = {}
  3629. --swapKitSet = {}
  3630.  
  3631. function swapTeamKit(team,type1,type2)
  3632.  
  3633. if (swapKit[team] == nil) then
  3634. swapKit[team] = {}
  3635. end
  3636.  
  3637. if (type(type2) == "number") then
  3638. swapKit[team][type1] = type2
  3639. else
  3640. if (swapKit[team][type1] == nil) then
  3641. swapKit[team][type1] = type2[math.random(#type2)]
  3642. end
  3643. end
  3644.  
  3645. end
  3646.  
  3647. function swapTeamKitTournament(team,tourn,type1,type2)
  3648.  
  3649. if (swapKitTourn[team] == nil) then
  3650. swapKitTourn[team] = {}
  3651. end
  3652.  
  3653. if (swapKitTourn[team][tourn] == nil) then
  3654. swapKitTourn[team][tourn] = {}
  3655. end
  3656.  
  3657. if (type(type2) == "number") then
  3658. swapKitTourn[team][tourn][type1] = type2
  3659. else
  3660. if (swapKitTourn[team][tourn][type1] == nil) then
  3661. swapKitTourn[team][tourn][type1] = type2[math.random(#type2)]
  3662. end
  3663. end
  3664.  
  3665. end
  3666.  
  3667. function swapTeamKitSet(team,set,type1,type2)
  3668.  
  3669. if (kitsetactiveid[set] ~= nil) then
  3670. if (kitsetactiveid[set] == 1) then
  3671. swapTeamKit(team,type1,type2)
  3672. end
  3673. end
  3674.  
  3675. -- if (swapKitSet[team] == nil) then
  3676. -- swapKitSet[team] = {}
  3677. -- end
  3678.  
  3679. -- if (swapKitSet[team][set] == nil) then
  3680. -- swapKitSet[team][set] = {}
  3681. -- end
  3682.  
  3683. -- if (type(type2) == "number") then
  3684. -- swapKitSet[team][set][type1] = type2
  3685. -- else
  3686. -- if (swapKitSet[team][set][type1] == nil) then
  3687. -- swapKitSet[team][set][type1] = type2[math.random(#type2)]
  3688. -- end
  3689. -- end
  3690.  
  3691. end
  3692.  
  3693. function swapTeamKitTournamentSet(team,tourn,set,type1,type2)
  3694.  
  3695. if (kitsetactiveid[set] ~= nil) then
  3696. if (kitsetactiveid[set] == 1) then
  3697. swapTeamKitTournament(team,tourn,type1,type2)
  3698. end
  3699. end
  3700.  
  3701. end
  3702.  
  3703.  
  3704. fixGenGK = true
  3705.  
  3706. function disableOutfieldFontForGK()
  3707. fixGenGK = false
  3708. end
  3709.  
  3710.  
  3711. undershortsPlayer = {}
  3712. undershortsTeam = {}
  3713.  
  3714. function setUndershorts(player,option)
  3715. undershortsPlayer[player] = option
  3716. end
  3717.  
  3718. function setTeamUndershorts(team,option)
  3719. undershortsTeam[team] = option
  3720. end
  3721.  
  3722.  
  3723. function getUndershorts(player,option,year,team)
  3724.  
  3725. if ((year <= classicKitUndershortsYear) and (year > 0)) then
  3726. return -1
  3727. end
  3728.  
  3729. if (globalundershort ~= -1) then
  3730. return globalundershort
  3731. end
  3732.  
  3733. if (undershortsTeam[team] ~= nil) then
  3734. return undershortsTeam[team] - 1
  3735. end
  3736.  
  3737. if (undershortsPlayer[player] ~= nil) then
  3738. return undershortsPlayer[player] - 1
  3739. end
  3740.  
  3741. return option
  3742. end
  3743.  
  3744.  
  3745. function GetRMFaceTex(idx)
  3746.     local hpart = ""
  3747.     hpart = hpart.."data/sceneassets/faces/specificface_"..db.player[idx].playerassetid.."_"..db.player[idx].facerand.."_textures.rx3;"
  3748.     hpart = hpart.."data/sceneassets/faces/specificface_"..db.player[idx].playerassetid.."_0_textures.rx3;"
  3749.     hpart = hpart.."data/sceneassets/faces/specificface_0_"..db.player[idx].teamid.."_textures.rx3;"
  3750.     hpart = hpart.."data/sceneassets/faces/face_"..db.player[idx].playerassetid.."_0_0_0_0_0_0_0_0_textures.rx3;"
  3751.     if(db.player[idx].isVirtualPro == 0) then
  3752.     hpart = hpart.."data/sceneassets/faces/face_"..db.player[idx].faceType.."_"..db.player[idx].faceProxyHeadClass.."_0_"..db.player[idx].eyebrow.."_"..db.player[idx].faceSideBurn.."_"..db.player[idx].facialHairColor.."_"..db.player[idx].facialHairType.."_"..db.player[idx].headSkinType.."_"..db.player[idx].headSkinToneType.."_textures.rx3;"
  3753.     end
  3754.     return hpart
  3755. end
  3756.  
  3757. function GetRMHairTex(idx)
  3758.     local hpart = ""
  3759.     hpart = hpart.."data/sceneassets/hair/specifichair_"..db.player[idx].playerassetid.."_"..db.player[idx].facerand.."_textures.rx3;"
  3760.     hpart = hpart.."data/sceneassets/hair/specifichair_"..db.player[idx].playerassetid.."_0_textures.rx3;"
  3761.     hpart = hpart.."data/sceneassets/hair/specifichair_0_"..db.player[idx].teamid.."_textures.rx3;"
  3762.     hpart = hpart.."data/sceneassets/hair/hair_"..db.player[idx].playerassetid.."_0_textures.rx3;"
  3763.     return hpart
  3764. end
  3765.  
  3766. function GetRMEyeTex(idx)
  3767.     local hpart = ""
  3768.     hpart = hpart.."data/sceneassets/heads/specificeyes_"..db.player[idx].playerassetid.."_"..db.player[idx].facerand.."_textures.rx3;"
  3769.     hpart = hpart.."data/sceneassets/heads/specificeyes_"..db.player[idx].playerassetid.."_0_textures.rx3;"
  3770.     hpart = hpart.."data/sceneassets/heads/specificeyes_0_"..db.player[idx].teamid.."_textures.rx3;"
  3771.     hpart = hpart.."data/sceneassets/heads/eyes_"..db.player[idx].playerassetid.."_0_textures.rx3;"
  3772.     return hpart
  3773. end
  3774.  
  3775. function GetRMHairMod(idx)
  3776.     local hpart = ""
  3777.     hpart = hpart.."data/sceneassets/hair/specifichair_"..db.player[idx].playerassetid.."_"..db.player[idx].facerand..".rx3;"
  3778.     hpart = hpart.."data/sceneassets/hair/specifichair_"..db.player[idx].playerassetid.."_0.rx3;"
  3779.     hpart = hpart.."data/sceneassets/hair/specifichair_0_"..db.player[idx].teamid..".rx3;"
  3780.     hpart = hpart.."data/sceneassets/hair/hair_"..db.player[idx].playerassetid.."_0_0.rx3;"
  3781.     return hpart
  3782. end
  3783.  
  3784. function GetRMFaceMod(idx)
  3785.     local hpart = ""
  3786.     hpart = hpart.."data/sceneassets/heads/specifichead_"..db.player[idx].playerassetid.."_"..db.player[idx].facerand..".rx3;"
  3787.     hpart = hpart.."data/sceneassets/heads/specifichead_"..db.player[idx].playerassetid.."_0.rx3;"
  3788.     hpart = hpart.."data/sceneassets/heads/specifichead_0_"..db.player[idx].teamid..".rx3;"
  3789.     hpart = hpart.."data/sceneassets/heads/head_"..db.player[idx].playerassetid.."_0.rx3;"
  3790.     return hpart
  3791. end
  3792.  
  3793. function GetRMHairModLod(idx)
  3794.     local hpart = ""
  3795.     hpart = hpart.."data/sceneassets/hairlod/specifichairlod_"..db.player[idx].playerassetid.."_"..db.player[idx].facerand..".rx3;"
  3796.     hpart = hpart.."data/sceneassets/hairlod/specifichairlod_"..db.player[idx].playerassetid.."_0.rx3;"
  3797.     hpart = hpart.."data/sceneassets/hairlod/specifichairlod_0_"..db.player[idx].teamid..".rx3;"
  3798.     hpart = hpart.."data/sceneassets/hairlod/hairlod_"..db.player[idx].playerassetid.."_0_0.rx3;"
  3799.     return hpart
  3800. end
  3801.  
  3802. function GetRMFaceBump(idx)
  3803.     local hpart = ""
  3804.     hpart = hpart.."data/sceneassets/heads/specifichead_"..db.player[idx].playerassetid.."_"..db.player[idx].facerand.."_bump.rx3;"
  3805.     hpart = hpart.."data/sceneassets/heads/specifichead_"..db.player[idx].playerassetid.."_0_bump.rx3;"
  3806.     hpart = hpart.."data/sceneassets/heads/specifichead_0_"..db.player[idx].teamid.."_bump.rx3;"
  3807.     hpart = hpart.."data/sceneassets/heads/head_"..db.player[idx].playerassetid.."_bump.rx3;"
  3808.     return hpart
  3809. end
  3810.  
  3811.  
  3812. kitBottomTournament = {}
  3813.  
  3814. function assignTournamentShorts(team,kit,tournament,bottom)
  3815.  
  3816. if (kitBottomTournament[team] == nil) then
  3817. kitBottomTournament[team] = {}
  3818. end
  3819.  
  3820. if (kitBottomTournament[team][kit] == nil) then
  3821. kitBottomTournament[team][kit] = {}
  3822. end
  3823.  
  3824. kitBottomTournament[team][kit][tournament] = bottom
  3825.  
  3826. end
  3827.  
  3828.  
  3829. function getTournamentShorts(team,kit,tournament,bottom)
  3830.  
  3831. if (kitBottomTournament[team] ~= nil) then
  3832. if (kitBottomTournament[team][kit] ~= nil) then
  3833. if (kitBottomTournament[team][kit][tournament] ~= nil) then
  3834. return kitBottomTournament[team][kit][tournament]
  3835. end
  3836. end
  3837. end
  3838.  
  3839.  
  3840. return bottom
  3841. end
  3842.  
  3843.  
  3844.  
  3845.  
  3846.  
  3847. playerBoot = {}
  3848. playerBootFallback = {}
  3849.  
  3850. function assignPlayerShoe(id,boot)
  3851.  
  3852. --if (type(boot) == "number") then
  3853. playerBoot[id] = boot
  3854.  
  3855.  
  3856. end
  3857.  
  3858. function getPlayerShoe(id,boot)
  3859.  
  3860. if (playerBoot[id] ~= nil) then
  3861. return playerBoot[id]
  3862. end
  3863.  
  3864. return boot
  3865. end
  3866.  
  3867. function assignPlayerShoeFallback(id,boot)
  3868.  
  3869. playerBootFallback[id] = boot
  3870.  
  3871. end
  3872.  
  3873.  
  3874.  
  3875.  
  3876. function GetRMBench(idx)
  3877.     local kitstring = ""
  3878.    
  3879.     local name = "bib"
  3880.    
  3881.     local ven = 0
  3882.    
  3883.     if (db.player[idx].teamside == 1) then
  3884.     ven = 100
  3885.     end
  3886.    
  3887.     if (db.player[idx].cold == 1) then
  3888.     name = "tracksuit"
  3889.     end
  3890.    
  3891.     if ((GetRMTracksuitType(idx) == false) or (db.player[idx].cold == 0)) then
  3892.    
  3893.    
  3894.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_"..db.player[idx].kit.."_"..(db.player[idx].outfieldKitType+ven).."_"..db.player[idx].tournid.."_textures.rx3;"
  3895.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_"..db.player[idx].kit.."_"..ven.."_"..db.player[idx].tournid.."_textures.rx3;"
  3896.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_"..db.player[idx].kit.."_"..db.player[idx].outfieldKitType.."_"..db.player[idx].tournid.."_textures.rx3;"
  3897.     --kitstring = kitstring.."data/sceneassets/warmup/"..name.."_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..db.player[idx].tournid.."_textures.rx3;"
  3898.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_"..db.player[idx].kit.."_0_"..db.player[idx].tournid.."_textures.rx3;"
  3899.    
  3900.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_0_"..db.player[idx].bibType.."_"..db.player[idx].tournid.."_textures.rx3;"
  3901.    
  3902.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_0_"..ven.."_"..db.player[idx].tournid.."_textures.rx3;"
  3903.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_0_0_"..db.player[idx].tournid.."_textures.rx3;"
  3904.    
  3905.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_"..db.player[idx].kit.."_"..db.player[idx].bibType.."_0_textures.rx3;"
  3906.    
  3907.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_"..db.player[idx].kit.."_"..(db.player[idx].outfieldKitType+ven).."_0_textures.rx3;"
  3908.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_"..db.player[idx].kit.."_"..ven.."_0_textures.rx3;"
  3909.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_"..db.player[idx].kit.."_"..db.player[idx].outfieldKitType.."_0_textures.rx3;"
  3910.     --kitstring = kitstring.."data/sceneassets/warmup/"..name.."_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_0_textures.rx3;"
  3911.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_"..db.player[idx].kit.."_0_0_textures.rx3;"
  3912.    
  3913.     --if (db.player[idx].cold == 0) then
  3914.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_0_"..db.player[idx].bibType.."_0_textures.rx3;"
  3915.     --end
  3916.    
  3917.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_0_"..ven.."_0_textures.rx3;"
  3918.     kitstring = kitstring.."data/sceneassets/warmup/"..name.."_0_0_0_textures.rx3;"
  3919.     end
  3920.  
  3921.     return kitstring
  3922. end
  3923.  
  3924.  
  3925.  
  3926.  
  3927. newNumberType = true
  3928.  
  3929.  
  3930. function useOriginalKitNumberIdentifier()
  3931. newNumberType = false
  3932. end
  3933.  
  3934.  
  3935. function GetRMNumberStringTens()
  3936.  
  3937. if (newNumberType) then
  3938. return "_${db.player[?].kitNumberTens}."
  3939. end
  3940.  
  3941. return "numbers_${db.player[?].kitNumberFont}_${db.player[?].kitNumberColor}_${db.player[?].kitNumberTens}"
  3942. end
  3943.  
  3944.  
  3945. function GetRMNumberStringUnits()
  3946.  
  3947. if (newNumberType) then
  3948. return "_${db.player[?].kitNumberUnits}."
  3949. end
  3950.  
  3951. return "numbers_${db.player[?].kitNumberFont}_${db.player[?].kitNumberColor}_${db.player[?].kitNumberUnits}"
  3952. end
  3953.  
  3954.  
  3955. function GetRMNumberStringTensShorts()
  3956.  
  3957. if (newNumberType) then
  3958. return "_${db.player[?].kitNumberTens}."
  3959. end
  3960.  
  3961. return "numbers_${db.player[?].shortsNumberFont}_${db.player[?].shortsNumberColor}_${db.player[?].kitNumberTens}"
  3962. end
  3963.  
  3964.  
  3965. function GetRMNumberStringUnitsShorts()
  3966.  
  3967. if (newNumberType) then
  3968. return "_${db.player[?].kitNumberUnits}."
  3969. end
  3970.  
  3971. return "numbers_${db.player[?].shortsNumberFont}_${db.player[?].shortsNumberColor}_${db.player[?].kitNumberUnits}"
  3972. end
  3973.  
  3974.  
  3975. trackSuitMode = false
  3976. bibMode = false
  3977. recolourTracksuits = false
  3978.  
  3979. teamTracksuit = {}
  3980. leagueTracksuit = {}
  3981.  
  3982. function GetRMTracksuitOption()
  3983.  
  3984. if ((trackSuitMode) or (bibMode)) then
  3985. return 1
  3986. end
  3987.  
  3988. return 2
  3989. end
  3990.  
  3991. function GetRMBibOption(x)
  3992.  
  3993. if (bibMode) then
  3994. return 1
  3995. end
  3996.  
  3997. return x
  3998. end
  3999.  
  4000.  
  4001. function activateTracksuitMode()
  4002. trackSuitMode = true
  4003. end
  4004.  
  4005. function activateBibMode()
  4006. bibMode = true
  4007. end
  4008.  
  4009. function disableAutomaticTracksuits()
  4010. recolourTracksuits = true
  4011. end
  4012.  
  4013. function GetRMTracksuitType(idx)
  4014.  
  4015. if (teamTracksuit[db.player[idx].teamid] ~= nil) then
  4016. return (teamTracksuit[db.player[idx].teamid] == 1)
  4017. end
  4018.  
  4019. if (leagueTracksuit[db.player[idx].defaulttournid] ~= nil) then
  4020. return (leagueTracksuit[db.player[idx].defaulttournid] == 1)
  4021. end
  4022.  
  4023. return recolourTracksuits
  4024. end
  4025.  
  4026. function setTeamTracksuitType(team,option)
  4027. teamTracksuit[team] = option
  4028. end
  4029.  
  4030. function setLeagueTracksuitType(league,option)
  4031. leagueTracksuit[league] = option
  4032. end
  4033.  
  4034.  
  4035.  
  4036.  
  4037. classicKitUndershirtYear = 0
  4038. classicKitUndershortsYear = 0
  4039. classicKitCaptainArmbandYear = 0
  4040. classicKitShortSleevesGKYear = 0
  4041. classicKitShortSleevesOutfieldYear = 0
  4042.  
  4043. function removeClassicKitUndershirt(year)
  4044. classicKitUndershirtYear = year
  4045. end
  4046.  
  4047. function removeClassicKitUndershorts(year)
  4048. classicKitUndershortsYear = year
  4049. end
  4050.  
  4051. function removeClassicKitCaptainArmband(year)
  4052. classicKitCaptainArmbandYear = year
  4053. end
  4054.  
  4055. function removeClassicKitShortSleevesGK(year)
  4056. classicKitShortSleevesGKYear = year
  4057. end
  4058.  
  4059. function removeClassicKitShortSleevesOutfield(year)
  4060. classicKitShortSleevesOutfieldYear = year
  4061. end
  4062.  
  4063.  
  4064. tournClone = {}
  4065.  
  4066. function copyTournamentNameAndNumberAssets(old,new)
  4067. tournClone[old] = new
  4068. end
  4069.  
  4070. function getCloneTournamentNumbers(old)
  4071.  
  4072. if (tournClone[old] ~= nil) then
  4073. return tournClone[old]
  4074. end
  4075.  
  4076. return old
  4077. end
  4078.  
  4079.  
  4080. tournCloneKit = {}
  4081. tournCloneKitLeague = {}
  4082.  
  4083. function copyTournamentKitAssets(old,new)
  4084. tournCloneKit[old] = new
  4085. end
  4086.  
  4087. function copyTournamentKitAssetsByLeague(old,new,league)
  4088.  
  4089. if (tournCloneKitLeague[old] == nil) then
  4090. tournCloneKitLeague[old] = {}
  4091. end
  4092.  
  4093. tournCloneKitLeague[old][league] = new
  4094. end
  4095.  
  4096. function getCloneTournamentKits(old,team)
  4097.  
  4098. if (tournCloneKitLeague[old] ~= nil) then
  4099. if (tournCloneKitLeague[old][teamTournament[team]] ~= nil) then
  4100. return tournCloneKitLeague[old][teamTournament[team]]
  4101. end
  4102. end
  4103.  
  4104.  
  4105. if (tournCloneKit[old] ~= nil) then
  4106. return tournCloneKit[old]
  4107. end
  4108.  
  4109. return old
  4110. end
  4111.  
  4112.  
  4113. tournCloneKitRef = {}
  4114.  
  4115. function copyTournamentRefereeKitAssets(old,new)
  4116. tournCloneKitRef[old] = new
  4117. end
  4118.  
  4119. function getCloneTournamentRefereeKits(old)
  4120.  
  4121. if (tournCloneKitRef[old] ~= nil) then
  4122. return tournCloneKitRef[old]
  4123. end
  4124.  
  4125. return old
  4126. end
  4127.  
  4128.  
  4129. isGK = {}
  4130.  
  4131. function identifyGK(id)
  4132. isGK[id] = 1
  4133. end
  4134.  
  4135. function isPlayerGK(id)
  4136.  
  4137. if (isGK[id] == 1) then
  4138. return true
  4139. end
  4140.  
  4141. return false
  4142. end
  4143.  
  4144.  
  4145. futKits = {}
  4146. -- futKits[0] = nil
  4147. -- futKits[1] = nil
  4148. -- futKits[3] = nil
  4149.  
  4150. function restrictFUTCustomKits(h,a,t)
  4151. futKits[0] = h
  4152. futKits[1] = a
  4153. futKits[3] = t
  4154. end
  4155.  
  4156.  
  4157.  
  4158. -- function GetRMShirtBNM(idx)
  4159.     -- local kitstring = ""
  4160.     -- kitstring = kitstring.."data/sceneassets/kitcmn/specificjersey_"..db.player[idx].kit.."_"..db.player[idx].specKitType.."_"..db.player[idx].tournid.."_"..db.player[idx].jerseyTucked.."_"..db.player[idx].jerseyfit.."_bnm.rx3;"
  4161.     -- kitstring = kitstring.."data/sceneassets/kitcmn/specificjersey_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..db.player[idx].tournid.."_"..db.player[idx].jerseyTucked.."_"..db.player[idx].jerseyfit.."_bnm.rx3;"
  4162.     -- kitstring = kitstring.."data/sceneassets/kitcmn/specificjersey_"..db.player[idx].kit.."_"..db.player[idx].specKitType.."_0_"..db.player[idx].jerseyTucked.."_"..db.player[idx].jerseyfit.."_bnm.rx3;"
  4163.     -- kitstring = kitstring.."data/sceneassets/kitcmn/specificjersey_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_0_"..db.player[idx].jerseyTucked.."_"..db.player[idx].jerseyfit.."_bnm.rx3;"
  4164.    
  4165.     -- kitstring = kitstring.."data/sceneassets/kitcmn/specificjersey_"..db.player[idx].kit.."_0_0_"..db.player[idx].jerseyTucked.."_"..db.player[idx].jerseyfit.."_bnm.rx3;"
  4166.     -- return kitstring
  4167. -- end
  4168.  
  4169. -- function GetRMShortsBNM(idx)
  4170.     -- local kitstring = ""
  4171.     -- kitstring = kitstring.."data/sceneassets/kitcmn/specificshorts_"..db.player[idx].kit.."_"..db.player[idx].specKitType.."_"..db.player[idx].tournid.."_"..db.player[idx].shortstyle.."_bnm.rx3;"
  4172.     -- kitstring = kitstring.."data/sceneassets/kitcmn/specificshorts_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..db.player[idx].tournid.."_"..db.player[idx].shortstyle.."_bnm.rx3;"
  4173.     -- kitstring = kitstring.."data/sceneassets/kitcmn/specificshorts_"..db.player[idx].kit.."_"..db.player[idx].specKitType.."_0_"..db.player[idx].shortstyle.."_bnm.rx3;"
  4174.     -- kitstring = kitstring.."data/sceneassets/kitcmn/specificshorts_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_0_"..db.player[idx].shortstyle.."_bnm.rx3;"
  4175.    
  4176.     -- kitstring = kitstring.."data/sceneassets/kitcmn/specificshorts_"..db.player[idx].kit.."_0_0_"..db.player[idx].shortstyle.."_bnm.rx3;"
  4177.     -- return kitstring
  4178. -- end
  4179.  
  4180.  
  4181. function GetRMShortModel(idx,lod)
  4182.     local short = ""
  4183.    
  4184.     if (db.player[idx].shortstyle == 0) then
  4185.     -- short = short.."data/sceneassets/body/specificshorts_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..db.player[idx].tournid.."_"..lod..".rx3;"
  4186.     -- short = short.."data/sceneassets/body/specificshorts_"..db.player[idx].kit.."_0_"..db.player[idx].tournid.."_"..lod..".rx3;"
  4187.     -- short = short.."data/sceneassets/body/specificshorts_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_0_"..lod..".rx3;"
  4188.     -- short = short.."data/sceneassets/body/specificshorts_"..db.player[idx].kit.."_0_0_"..lod..".rx3;"
  4189.     -- short = short.."data/sceneassets/body/specificshorts_0_0_"..db.player[idx].tournid.."_"..lod..".rx3;"
  4190.     -- short = short.."data/sceneassets/body/specificshorts_0_0_"..db.player[idx].kitYearDecade.."_"..lod..".rx3;"
  4191.    
  4192.     -- short = short.."data/sceneassets/body/specificshorts_0_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..db.player[idx].tournid.."_"..lod..".rx3;"
  4193.     -- short = short.."data/sceneassets/body/specificshorts_0_"..db.player[idx].kit.."_0_"..db.player[idx].tournid.."_"..lod..".rx3;"
  4194.     -- short = short.."data/sceneassets/body/specificshorts_0_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_0_"..lod..".rx3;"
  4195.     -- short = short.."data/sceneassets/body/specificshorts_0_"..db.player[idx].kit.."_0_0_"..lod..".rx3;"
  4196.     -- short = short.."data/sceneassets/body/specificshorts_0_0_0_"..db.player[idx].tournid.."_"..lod..".rx3;"
  4197.     -- short = short.."data/sceneassets/body/specificshorts_0_0_0_"..db.player[idx].kitYearDecade.."_"..lod..".rx3;"
  4198.    
  4199.     short = short.."data/sceneassets/body/specificshorts_0_"..db.player[idx].kit.."_"..(db.player[idx].kitType+(db.player[idx].gender*100)).."_"..db.player[idx].tournid.."_"..lod..".rx3;"
  4200.     short = short.."data/sceneassets/body/specificshorts_0_"..db.player[idx].kit.."_"..(db.player[idx].gender*100).."_"..db.player[idx].tournid.."_"..lod..".rx3;"
  4201.     short = short.."data/sceneassets/body/specificshorts_0_"..db.player[idx].kit.."_"..(db.player[idx].kitType+(db.player[idx].gender*100)).."_0_"..lod..".rx3;"
  4202.     short = short.."data/sceneassets/body/specificshorts_0_"..db.player[idx].kit.."_"..(db.player[idx].gender*100).."_0_"..lod..".rx3;"
  4203.     short = short.."data/sceneassets/body/specificshorts_0_0_"..(db.player[idx].gender*100).."_"..db.player[idx].tournid.."_"..lod..".rx3;"
  4204.     short = short.."data/sceneassets/body/specificshorts_0_0_"..(db.player[idx].gender*100).."_"..db.player[idx].kitYearDecade.."_"..lod..".rx3;"
  4205.    
  4206.     short = short.."data/sceneassets/body/specificshorts_"..db.player[idx].playerassetid.."_0_0_0_"..lod..".rx3;"
  4207.     end
  4208.  
  4209.     return short
  4210. end
  4211.  
  4212.  
  4213. function GetRMKitOverlay(idx)
  4214.     local kitstring = ""
  4215.    
  4216.     local isfinal = getTournamentFinal(db.player[idx].tournid,db.player[idx].stadiumID,db.player[idx].crowdDistribution)
  4217.    
  4218.         --variables needed for new precedence:
  4219.         local as = gSportsRNA
  4220.         local wipe3d = as:GetTable("wvWipe", 1)
  4221.         local orgtournid = as:GetInt(wipe3d, "leagueID")
  4222.    
  4223.     if (db.player[idx].kitType ~= 5) then
  4224.     if (isfinal) then
  4225.    
  4226.  
  4227.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..db.player[idx].speckitType.."_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+2)..".png;"
  4228.     --kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+2)..".png;"
  4229.    
  4230.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_0_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+3)..".png;"
  4231.     --kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_0_"..db.player[idx].defaulttournid.."_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+3)..".png;"
  4232.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_0_0_"..db.player[idx].tournid.."_"..(((db.player[idx].gender*10)+3)+db.player[idx].overlayoffset)..".png;"
  4233.     --kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_0_0_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+3)..".png;"
  4234.     end
  4235.  
  4236.                     --kit_teamid_kittype_tournamentassetid_type.png
  4237.                    
  4238.                     --new precedence: look for overlay in year subfolder first
  4239.                    
  4240.                     kitstring = kitstring.."data/sceneassets/kitoverlay/"..db.player[idx].kitYear.."/kitoverlay_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..orgtournid.."_0.png;"
  4241.                     --kitstring = kitstring.."data/sceneassets/kitoverlay/"..db.player[idx].kitYear.."/kitoverlay_"..db.player[idx].kit.."_0_"..orgtournid.."_0.png;"
  4242.                     kitstring = kitstring.."data/sceneassets/kitoverlay/"..db.player[idx].kitYear.."/kitoverlay_0_0_"..orgtournid.."_0.png;"
  4243.                    
  4244.                     --new precedence end
  4245.    
  4246.     --kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..(300000000+(db.player[idx].speckitType*1000000)+db.player[idx].playerassetid).."_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+0)..".png;"
  4247.     --kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..(db.player[idx].speckitType+100)..db.player[idx].kitNumberTens..db.player[idx].kitNumberUnits.."_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+0)..".png;"
  4248.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..(20000+(db.player[idx].speckitType*100)+db.player[idx].shirtid).."_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+0)..".png;"
  4249.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..db.player[idx].speckitType.."_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+0)..".png;"
  4250.    
  4251.     --kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..(300000000+(db.player[idx].kitType*1000000)+db.player[idx].playerassetid).."_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+0)..".png;"
  4252.     --kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..(db.player[idx].kitType+100)..db.player[idx].kitNumberTens..db.player[idx].kitNumberUnits.."_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+0)..".png;"
  4253.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..(20000+(db.player[idx].kitType*100)+db.player[idx].shirtid).."_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+0)..".png;"
  4254.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+0)..".png;"
  4255.    
  4256.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_0_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+1)..".png;"
  4257.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_0_"..db.player[idx].defaulttournid.."_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+1)..".png;"
  4258.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_0_0_"..db.player[idx].tournid.."_"..(((db.player[idx].gender*10)+1)+db.player[idx].overlayoffset)..".png;"
  4259.     --kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_0_0_"..db.player[idx].tournid.."_"..((db.player[idx].gender*10)+1)..".png;"
  4260.  
  4261.     if (db.player[idx].kitYearDecade == -1) then
  4262.    
  4263.     --kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..(300000000+(db.player[idx].speckitType*1000000)+db.player[idx].playerassetid).."_0_"..((db.player[idx].gender*10)+0)..".png;"
  4264.     --kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..(db.player[idx].speckitType+100)..db.player[idx].kitNumberTens..db.player[idx].kitNumberUnits.."_0_"..((db.player[idx].gender*10)+0)..".png;"
  4265.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..(20000+(db.player[idx].speckitType*100)+db.player[idx].shirtid).."_0_"..((db.player[idx].gender*10)+0)..".png;"
  4266.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..db.player[idx].speckitType.."_0_"..((db.player[idx].gender*10)+0)..".png;"
  4267.  
  4268.     --kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..(300000000+(db.player[idx].kitType*1000000)+db.player[idx].playerassetid).."_0_"..((db.player[idx].gender*10)+0)..".png;"
  4269.     --kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..(db.player[idx].kitType+100)..db.player[idx].kitNumberTens..db.player[idx].kitNumberUnits.."_0_"..((db.player[idx].gender*10)+0)..".png;"
  4270.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..(20000+(db.player[idx].kitType*100)+db.player[idx].shirtid).."_0_"..((db.player[idx].gender*10)+0)..".png;"
  4271.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_"..db.player[idx].kitType.."_0_"..((db.player[idx].gender*10)+0)..".png;"
  4272.    
  4273.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_0_"..db.player[idx].defaulttournid.."_"..((db.player[idx].gender*10)+1)..".png;"
  4274.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_"..db.player[idx].kit.."_0_0_"..((db.player[idx].gender*10)+1)..".png;"
  4275.     kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_0_0_"..db.player[idx].defaulttournid.."_"..(((db.player[idx].gender*10)+1)+db.player[idx].overlayoffset)..".png;"
  4276.     --kitstring = kitstring.."data/sceneassets/kitoverlay/kitoverlay_0_0_"..db.player[idx].defaulttournid.."_"..((db.player[idx].gender*10)+1)..".png;"
  4277.    
  4278.     --kitstring = kitstring.."data/sceneassets/kit/kit_"..db.player[idx].genkit.."_"..db.player[idx].kitType.."_"..db.player[idx].kitYear..".rx3"
  4279.     end
  4280.    
  4281.     end
  4282.    
  4283.  
  4284.    
  4285.     --REFS CLASSIC KITS TRAINING KITS
  4286.     --data/sceneassets/kitoverlay/kitoverlay_team_type_tourn_target.png
  4287.     --disable for players unless use is found, maybe shirt numbers
  4288.     --default tournament
  4289.     --ensure blank texture is present
  4290.     --allow numbers for classic kits
  4291.    
  4292.    
  4293.     return kitstring
  4294. end
  4295.  
  4296.  
  4297. -- refereeKitList = {}
  4298.  
  4299. -- function setRefereeKits(team,kittype,tournament,opt4,opt5,opt6,opt7,opt8,opt9)
  4300.  
  4301. -- if (refereeKitList[team] == nil) then
  4302. -- refereeKitList[team] = {}
  4303. -- end
  4304.  
  4305. -- if (refereeKitList[team][kittype] == nil) then
  4306. -- refereeKitList[team][kittype] = {}
  4307. -- end
  4308.  
  4309. -- if (refereeKitList[team][kittype][tournament] == nil) then
  4310. -- refereeKitList[team][kittype][tournament] = {}
  4311. -- end
  4312.  
  4313. -- if (refereeKitList[team][kittype][tournament][opt4] == nil) then
  4314. -- refereeKitList[team][kittype][tournament][opt4] = {}
  4315. -- end
  4316.  
  4317.  
  4318. -- end
  4319.  
  4320.  
  4321. gentexsize = 2048
  4322. gentexmip = 9
  4323. gentexformat = "eadxt1"
  4324.  
  4325. function setGentexSettings(size,mip,formatt)
  4326. gentexsize = size
  4327. gentexmip = mip
  4328. gentexformat = formatt
  4329. end
  4330.  
  4331. indivKits = false
  4332. indivKitsTeam = {}
  4333.  
  4334. function enableIndividualKitsGlobal()
  4335. indivKits = true
  4336. end
  4337.  
  4338. function enableIndividualKitsTeam(team,kittype,kityear)
  4339. if (indivKitsTeam[team] == nil) then
  4340. indivKitsTeam[team] = {}
  4341. end
  4342.  
  4343. if (indivKitsTeam[team][kittype] == nil) then
  4344. indivKitsTeam[team][kittype] = {}
  4345. end
  4346.  
  4347. if (indivKitsTeam[team][kittype][kityear] == nil) then
  4348. indivKitsTeam[team][kittype][kityear] = 1
  4349. end
  4350. end
  4351.  
  4352. function getIndividualKitsTeam(team,kittype,kityear,year)
  4353.  
  4354. if (indivKitsTeam[team] ~= nil) then
  4355. if (indivKitsTeam[team][kittype] ~= nil) then
  4356. if (indivKitsTeam[team][kittype][kityear] ~= nil) then
  4357. if (indivKitsTeam[team][kittype][kityear] == 1) then
  4358. return true
  4359. end
  4360. end
  4361. end
  4362. end
  4363.  
  4364. if (year == 0) then
  4365. if (indivKitsTeam[team] ~= nil) then
  4366. if (indivKitsTeam[team][kittype] ~= nil) then
  4367. if (indivKitsTeam[team][kittype][0] ~= nil) then
  4368. if (indivKitsTeam[team][kittype][0] == 1) then
  4369. return true
  4370. end
  4371. end
  4372. end
  4373. end
  4374. end
  4375.  
  4376.  
  4377. return indivKits
  4378. end
  4379.  
  4380.  
  4381.  
  4382. function getColourDistance(col1,col2)
  4383. r1 = tonumber(string.sub(col1,1,2),16)
  4384. g1 = tonumber(string.sub(col1,3,4),16)
  4385. b1 = tonumber(string.sub(col1,5,6),16)
  4386.  
  4387. r2 = tonumber(string.sub(col2,1,2),16)
  4388. g2 = tonumber(string.sub(col2,3,4),16)
  4389. b2 = tonumber(string.sub(col2,5,6),16)
  4390.  
  4391. val = math.sqrt(math.pow((r1-r2),2)+math.pow((g1-g2),2)+math.pow((b1-b2),2))
  4392.  
  4393. return val
  4394. end
  4395.  
  4396.  
  4397.  
  4398. teamKitColoursShirt1 = {}
  4399. teamKitColoursShirt2 = {}
  4400. teamKitColoursShort = {}
  4401. teamKitColoursSock = {}
  4402.  
  4403. teamKitColoursTournamentShirt1 = {}
  4404. teamKitColoursTournamentShirt2 = {}
  4405. teamKitColoursTournamentShort = {}
  4406. teamKitColoursTournamentSock = {}
  4407.  
  4408. refereeKitColoursTournament = {}
  4409.  
  4410. function identifyTeamKitColours(team,kittype,shirt1,shirt2,short,sock)
  4411.  
  4412. if (teamKitColoursShirt1[team] == nil) then
  4413. teamKitColoursShirt1[team] = {}
  4414. teamKitColoursShirt2[team] = {}
  4415. teamKitColoursShort[team] = {}
  4416. teamKitColoursSock[team] = {}
  4417. end
  4418.  
  4419.  
  4420. teamKitColoursShirt1[team][kittype] = shirt1
  4421. teamKitColoursShirt2[team][kittype] = shirt2
  4422. teamKitColoursShort[team][kittype] = short
  4423. teamKitColoursSock[team][kittype] = sock
  4424.  
  4425. end
  4426.  
  4427. function identifyTeamKitColoursTournament(team,kittype,tourn,shirt1,shirt2,short,sock)
  4428.  
  4429. if (teamKitColoursTournamentShirt1[team] == nil) then
  4430. teamKitColoursTournamentShirt1[team] = {}
  4431. teamKitColoursTournamentShirt2[team] = {}
  4432. teamKitColoursTournamentShort[team] = {}
  4433. teamKitColoursTournamentSock[team] = {}
  4434. end
  4435.  
  4436. if (teamKitColoursTournamentShirt1[team][kittype] == nil) then
  4437. teamKitColoursTournamentShirt1[team][kittype] = {}
  4438. teamKitColoursTournamentShirt2[team][kittype] = {}
  4439. teamKitColoursTournamentShort[team][kittype] = {}
  4440. teamKitColoursTournamentSock[team][kittype] = {}
  4441. end
  4442.  
  4443. teamKitColoursTournamentShirt1[team][kittype][tourn] = shirt1
  4444. teamKitColoursTournamentShirt2[team][kittype][tourn] = shirt2
  4445. teamKitColoursTournamentShort[team][kittype][tourn] = short
  4446. teamKitColoursTournamentSock[team][kittype][tourn] = sock
  4447.  
  4448. end
  4449.  
  4450. function identifyRefereeKitColoursTournament(tourn,kit4,kit5,kit6,kit7,kit8,kit9)
  4451.  
  4452. if (refereeKitColoursTournament[tourn] == nil) then
  4453. refereeKitColoursTournament[tourn] = {}
  4454. end
  4455.  
  4456. refereeKitColoursTournament[tourn][4] = kit4
  4457. refereeKitColoursTournament[tourn][5] = kit5
  4458. refereeKitColoursTournament[tourn][6] = kit6
  4459. refereeKitColoursTournament[tourn][7] = kit7
  4460. refereeKitColoursTournament[tourn][8] = kit8
  4461. refereeKitColoursTournament[tourn][9] = kit9
  4462.  
  4463. end
  4464.  
  4465.  
  4466. function getRefereeKitColours(tourn,home,kittype)
  4467.  
  4468. if (refereeKitColoursTournament[tourn] ~= nil) then
  4469. if (refereeKitColoursTournament[tourn][kittype] ~= nil) then
  4470. return refereeKitColoursTournament[tourn][kittype]
  4471. end
  4472. end
  4473.  
  4474. if (teamTournament[home] ~= nil) then
  4475. if (refereeKitColoursTournament[teamTournament[home]] ~= nil) then
  4476. if (refereeKitColoursTournament[teamTournament[home]][kittype] ~= nil) then
  4477. return refereeKitColoursTournament[teamTournament[home]][kittype]
  4478. end
  4479. end
  4480. end
  4481.  
  4482. if (refereeKitColoursTournament[0] ~= nil) then
  4483. if (refereeKitColoursTournament[0][kittype] ~= nil) then
  4484. return refereeKitColoursTournament[0][kittype]
  4485. end
  4486. end
  4487.  
  4488. return -1
  4489. end
  4490.  
  4491.  
  4492.  
  4493.  
  4494.  
  4495.  
  4496. function getShirt1Colour(team,kittype,tournament,kityear)
  4497.  
  4498. if (teamKitColoursTournamentShirt1[team] ~= nil) then
  4499. if (teamKitColoursTournamentShirt1[team][kittype] ~= nil) then
  4500. if (teamKitColoursTournamentShirt1[team][kittype][tournament] ~= nil) then
  4501. return teamKitColoursTournamentShirt1[team][kittype][tournament]
  4502. end
  4503. end
  4504. end
  4505.  
  4506. if (kityear == 0) then
  4507. if (teamKitColoursShirt1[team] ~= nil) then
  4508. if (teamKitColoursShirt1[team][kittype] ~= nil) then
  4509. return teamKitColoursShirt1[team][kittype]
  4510. end
  4511. end
  4512. end
  4513.  
  4514. return -1
  4515. end
  4516.  
  4517. function getShirt2Colour(team,kittype,tournament,kityear)
  4518.  
  4519. if (teamKitColoursTournamentShirt2[team] ~= nil) then
  4520. if (teamKitColoursTournamentShirt2[team][kittype] ~= nil) then
  4521. if (teamKitColoursTournamentShirt2[team][kittype][tournament] ~= nil) then
  4522. return teamKitColoursTournamentShirt2[team][kittype][tournament]
  4523. end
  4524. end
  4525. end
  4526.  
  4527. if (kityear == 0) then
  4528. if (teamKitColoursShirt2[team] ~= nil) then
  4529. if (teamKitColoursShirt2[team][kittype] ~= nil) then
  4530. return teamKitColoursShirt2[team][kittype]
  4531. end
  4532. end
  4533. end
  4534.  
  4535. return -1
  4536. end
  4537.  
  4538. function getShortColour(team,kittype,tournament,kityear)
  4539.  
  4540. if (teamKitColoursTournamentShort[team] ~= nil) then
  4541. if (teamKitColoursTournamentShort[team][kittype] ~= nil) then
  4542. if (teamKitColoursTournamentShort[team][kittype][tournament] ~= nil) then
  4543. return teamKitColoursTournamentShort[team][kittype][tournament]
  4544. end
  4545. end
  4546. end
  4547.  
  4548. if (kityear == 0) then
  4549. if (teamKitColoursShort[team] ~= nil) then
  4550. if (teamKitColoursShort[team][kittype] ~= nil) then
  4551. return teamKitColoursShort[team][kittype]
  4552. end
  4553. end
  4554. end
  4555.  
  4556. return -1
  4557. end
  4558.  
  4559. function getSockColour(team,kittype,tournament,kityear)
  4560.  
  4561. if (teamKitColoursTournamentSock[team] ~= nil) then
  4562. if (teamKitColoursTournamentSock[team][kittype] ~= nil) then
  4563. if (teamKitColoursTournamentSock[team][kittype][tournament] ~= nil) then
  4564. return teamKitColoursTournamentSock[team][kittype][tournament]
  4565. end
  4566. end
  4567. end
  4568.  
  4569. if (kityear == 0) then
  4570. if (teamKitColoursSock[team] ~= nil) then
  4571. if (teamKitColoursSock[team][kittype] ~= nil) then
  4572. return teamKitColoursSock[team][kittype]
  4573. end
  4574. end
  4575. end
  4576.  
  4577. return -1
  4578. end
  4579.  
  4580.  
  4581. altShorts = {}
  4582. altSocks = {}
  4583. altShortsSocks = {}
  4584.  
  4585.  
  4586. function assignKitAlternates(team,kittype,altshort,altsock,altshortsock)
  4587.  
  4588. if (altShorts[team] == nil) then
  4589. altShorts[team] = {}
  4590. altSocks[team] = {}
  4591. altShortsSocks[team] = {}
  4592. end
  4593.  
  4594. altShorts[team][kittype] = altshort
  4595. altSocks[team][kittype] = altsock
  4596. altShortsSocks[team][kittype] = altshortsock
  4597.  
  4598. end
  4599.  
  4600. function getAltShorts(team,kittype,tourn,year)
  4601.  
  4602. if (year == 0) then
  4603. if (altShorts[team] ~= nil) then
  4604. if (altShorts[team][kittype] ~= nil) then
  4605. return altShorts[team][kittype]
  4606. end
  4607. end
  4608. end
  4609.  
  4610. return -1
  4611. end
  4612.  
  4613. function getAltSocks(team,kittype,tourn,year)
  4614.  
  4615. if (year == 0) then
  4616. if (altSocks[team] ~= nil) then
  4617. if (altSocks[team][kittype] ~= nil) then
  4618. return altSocks[team][kittype]
  4619. end
  4620. end
  4621. end
  4622.  
  4623. return -1
  4624. end
  4625.  
  4626. function getAltShortsSocks(team,kittype,tourn,year)
  4627.  
  4628. if (year == 0) then
  4629. if (altShortsSocks[team] ~= nil) then
  4630. if (altShortsSocks[team][kittype] ~= nil) then
  4631. return altShortsSocks[team][kittype]
  4632. end
  4633. end
  4634. end
  4635.  
  4636. return -1
  4637. end
  4638.  
  4639.  
  4640.  
  4641.  
  4642.  
  4643. gkKitOrder = {}
  4644. gkKitOrderRand = {}
  4645. gkKitOrderTourn = {}
  4646. gkKitOrderRandTourn = {}
  4647.  
  4648. function assignGKKitPrecedence(team,kittype,randomused,list)
  4649.  
  4650. if (gkKitOrder[team] == nil) then
  4651. gkKitOrder[team] = {}
  4652. gkKitOrderRand[team] = {}
  4653. end
  4654.  
  4655. gkKitOrder[team][kittype] = list
  4656. gkKitOrderRand[team][kittype] = randomused
  4657.  
  4658. end
  4659.  
  4660. function assignTournamentGKKitPrecedence(team,kittype,tourn,randomused,list)
  4661.  
  4662. if (gkKitOrderTourn[team] == nil) then
  4663. gkKitOrderTourn[team] = {}
  4664. gkKitOrderRandTourn[team] = {}
  4665. end
  4666.  
  4667. if (gkKitOrderTourn[team][kittype] == nil) then
  4668. gkKitOrderTourn[team][kittype] = {}
  4669. gkKitOrderRandTourn[team][kittype] = {}
  4670. end
  4671.  
  4672. gkKitOrderTourn[team][kittype][tourn] = list
  4673. gkKitOrderRandTourn[team][kittype][tourn] = randomused
  4674.  
  4675. end
  4676.  
  4677. function getGKKitPrecedenceList(team,kittype,tourn,year)
  4678.  
  4679.  
  4680. if (gkKitOrderTourn[team] ~= nil) then
  4681. if (gkKitOrderTourn[team][kittype] ~= nil) then
  4682. if (gkKitOrderTourn[team][kittype][tourn] ~= nil) then
  4683. return gkKitOrderTourn[team][kittype][tourn]
  4684. end
  4685. end
  4686. end
  4687.  
  4688.  
  4689. if (year == 0) then
  4690. if (gkKitOrder[team] ~= nil) then
  4691. if (gkKitOrder[team][kittype] ~= nil) then
  4692. return gkKitOrder[team][kittype]
  4693. end
  4694. end
  4695. end
  4696.  
  4697. return -1
  4698. end
  4699.  
  4700. function getGKKitPrecedenceRand(team,kittype,tourn,year)
  4701.  
  4702.  
  4703. if (gkKitOrderRandTourn[team] ~= nil) then
  4704. if (gkKitOrderRandTourn[team][kittype] ~= nil) then
  4705. if (gkKitOrderRandTourn[team][kittype][tourn] ~= nil) then
  4706. return gkKitOrderRandTourn[team][kittype][tourn]
  4707. end
  4708. end
  4709. end
  4710.  
  4711. if (year == 0) then
  4712. if (gkKitOrderRand[team] ~= nil) then
  4713. if (gkKitOrderRand[team][kittype] ~= nil) then
  4714. return gkKitOrderRand[team][kittype]
  4715. end
  4716. end
  4717. end
  4718.  
  4719. return -1
  4720. end
  4721.  
  4722.  
  4723.  
  4724.  
  4725.  
  4726. function getGKKitColour(team1,team2,team1type,team2type,team1tourn,team2tourn,team1year,team2year,team1origtype,team2origtype,team2gktype)
  4727.  
  4728. team1typeshirt = getIndividualKitPart(team1type,1)
  4729.  
  4730. team2typeshirt = getIndividualKitPart(team2type,1)
  4731. team2typesock = getIndividualKitPart(team2type,3)
  4732.  
  4733. team1origtypeshirt = getIndividualKitPart(team1origtype,1)
  4734.  
  4735. team2gktypeshirt = getIndividualKitPart(team2gktype,1)
  4736.  
  4737.  
  4738.  
  4739. opponentcolour1 = getShirt1Colour(team2,team2typeshirt,team2tourn,team2year)
  4740. opponentcolour2 = getShirt2Colour(team2,team2typeshirt,team2tourn,team2year)
  4741. opponentcoloursock = getSockColour(team2,team2typesock,team2tourn,team2year)
  4742.  
  4743. opponentgkcolour1 = getShirt1Colour(team2,team2gktypeshirt,team2tourn,team2year)
  4744. opponentgkcolour2 = getShirt2Colour(team2,team2gktypeshirt,team2tourn,team2year)
  4745. --opponentgkcoloursock = getSockColour(team2,team2gktype,team2tourn,team2year)
  4746.  
  4747. rchoice1 = -1
  4748. rchoice2 = -1
  4749.  
  4750. gklist = getGKKitPrecedenceList(team1,team1typeshirt,team1tourn,team1year)
  4751. isrand = getGKKitPrecedenceRand(team1,team1typeshirt,team1tourn,team1year)
  4752.  
  4753. if (gklist == -1) then
  4754. gklist = getGKKitPrecedenceList(team1,team1origtypeshirt,team1tourn,team1year)
  4755. isrand = getGKKitPrecedenceRand(team1,team1origtypeshirt,team1tourn,team1year)
  4756. end
  4757.  
  4758. if (gklist ~= -1) then
  4759. gklistsize = #gklist
  4760.  
  4761. if (gklistsize == 1) then
  4762. return gklist[1]
  4763. end
  4764.  
  4765. gkkitfirst = 1
  4766.  
  4767.  
  4768. if (isrand == 1) then
  4769. gkkitfirst = math.random(gklistsize)
  4770. end
  4771.  
  4772. gkitcount = gkkitfirst
  4773.  
  4774. doloop = true
  4775.  
  4776. while (doloop) do
  4777. test = true
  4778. test2 = true
  4779. test3 = true
  4780.  
  4781. gkcolour1 = getShirt1Colour(team1,gklist[gkitcount],team1tourn,team1year)
  4782. gkcolour2 = getShirt2Colour(team1,gklist[gkitcount],team1tourn,team1year)
  4783. gkcoloursock = getSockColour(team1,gklist[gkitcount],team1tourn,team1year)
  4784.  
  4785. if (gkcolour1 ~= -1) then
  4786. if (opponentcolour1 ~= -1) then
  4787. if (getColourDistance(opponentcolour1,gkcolour1) < gkoutshirttol) then
  4788. test = false
  4789. end
  4790. end
  4791. if (opponentcolour2 ~= -1) then
  4792. if (getColourDistance(opponentcolour2,gkcolour1) < gkoutshirttol) then
  4793. test = false
  4794. end
  4795. end
  4796. end
  4797. if (gkcolour2 ~= -1) then
  4798. if (opponentcolour1 ~= -1) then
  4799. if (getColourDistance(opponentcolour1,gkcolour2) < gkoutshirttol) then
  4800. test = false
  4801. end
  4802. end
  4803. if (opponentcolour2 ~= -1) then
  4804. if (getColourDistance(opponentcolour2,gkcolour2) < gkoutshirttol) then
  4805. test = false
  4806. end
  4807. end
  4808. end
  4809.  
  4810. if (gkcolour1 ~= -1) then
  4811. if (opponentgkcolour1 ~= -1) then
  4812. if (getColourDistance(opponentgkcolour1,gkcolour1) < gkgkshirttol) then
  4813. test2 = false
  4814. end
  4815. end
  4816. if (opponentgkcolour2 ~= -1) then
  4817. if (getColourDistance(opponentgkcolour2,gkcolour1) < gkgkshirttol) then
  4818. test2 = false
  4819. end
  4820. end
  4821. end
  4822. if (gkcolour2 ~= -1) then
  4823. if (opponentgkcolour1 ~= -1) then
  4824. if (getColourDistance(opponentgkcolour1,gkcolour2) < gkgkshirttol) then
  4825. test2 = false
  4826. end
  4827. end
  4828. if (opponentgkcolour2 ~= -1) then
  4829. if (getColourDistance(opponentgkcolour2,gkcolour2) < gkgkshirttol) then
  4830. test2 = false
  4831. end
  4832. end
  4833. end
  4834.  
  4835. if (gkcoloursock ~= -1) then
  4836. if (opponentcoloursock ~= -1) then
  4837. if (getColourDistance(opponentcoloursock,gkcoloursock) < gkoutsocktol) then
  4838. test3 = false
  4839. end
  4840. end
  4841. end
  4842.  
  4843. if ((test and test2) and test3) then
  4844. return gklist[gkitcount]
  4845. end
  4846.  
  4847. if ((test and (rchoice1 == -1)) and test2) then
  4848. rchoice1 = gklist[gkitcount]
  4849. end
  4850.  
  4851. if (test and (rchoice2 == -1)) then
  4852. rchoice2 = gklist[gkitcount]
  4853. end
  4854.  
  4855. gkitcount = gkitcount + 1
  4856. if (gkitcount > gklistsize) then
  4857. gkitcount = 1
  4858. end
  4859.  
  4860.  
  4861. if (gkitcount == gkkitfirst) then
  4862. doloop = false
  4863. end
  4864.  
  4865. end
  4866. end
  4867.    
  4868.  
  4869. if (rchoice1 ~= -1) then
  4870. return rchoice1
  4871. end
  4872.  
  4873. if (rchoice2 ~= -1) then
  4874. return rchoice2
  4875. end
  4876.  
  4877. if (gklist ~= -1) then
  4878. return gklist[1]
  4879. end
  4880.  
  4881.  
  4882. return -1
  4883. end
  4884.  
  4885.  
  4886.  
  4887.  
  4888.  
  4889.  
  4890. function getRefereeKitColour(team1,team2,team1type,team2type,team1tourn,team2tourn,team1year,team2year,refkit,tourn,team1gktype,team2gktype)
  4891.  
  4892. rrchoice1 = -1
  4893.  
  4894. homecolour1 = getShirt1Colour(team1,getIndividualKitPart(team1type,1),team1tourn,team1year)
  4895. homecolour2 = getShirt2Colour(team1,getIndividualKitPart(team1type,1),team1tourn,team1year)
  4896. awaycolour1 = getShirt1Colour(team2,getIndividualKitPart(team2type,1),team2tourn,team2year)
  4897. awaycolour2 = getShirt2Colour(team2,getIndividualKitPart(team2type,1),team2tourn,team2year)
  4898.  
  4899. homegkcolour1 = getShirt1Colour(team1,getIndividualKitPart(team1gktype,1),team1tourn,team1year)
  4900. homegkcolour2 = getShirt2Colour(team1,getIndividualKitPart(team1gktype,1),team1tourn,team1year)
  4901. awaygkcolour1 = getShirt1Colour(team2,getIndividualKitPart(team2gktype,1),team2tourn,team2year)
  4902. awaygkcolour2 = getShirt2Colour(team2,getIndividualKitPart(team2gktype,1),team2tourn,team2year)
  4903.  
  4904. rkit = refkit%10
  4905.  
  4906. if (rkit < 4) then
  4907. rkit = 4
  4908. end
  4909.  
  4910. rkitcount = rkit
  4911.  
  4912. doloop = true
  4913.  
  4914. while (doloop) do
  4915. test = true
  4916. test2 = true
  4917.  
  4918. refereecolour = getRefereeKitColours(tourn,team1,rkitcount)
  4919.  
  4920. -- if (refereecolour ~= -1) then
  4921. -- useGlobalTournamentGraphics(980)
  4922. -- end
  4923.  
  4924. if (refereecolour ~= -1) then
  4925. if (homecolour1 ~= -1) then
  4926. if (getColourDistance(homecolour1,refereecolour) < refoutshirttol) then
  4927. test = false
  4928. end
  4929. end
  4930. if (homecolour2 ~= -1) then
  4931. if (getColourDistance(homecolour2,refereecolour) < refoutshirttol) then
  4932. test = false
  4933. end
  4934. end
  4935. if (awaycolour1 ~= -1) then
  4936. if (getColourDistance(awaycolour1,refereecolour) < refoutshirttol) then
  4937. test = false
  4938. end
  4939. end
  4940. if (awaycolour2 ~= -1) then
  4941. if (getColourDistance(awaycolour2,refereecolour) < refoutshirttol) then
  4942. test = false
  4943. end
  4944. end
  4945. end
  4946.  
  4947. if (refereecolour ~= -1) then
  4948. if (homegkcolour1 ~= -1) then
  4949. if (getColourDistance(homegkcolour1,refereecolour) < refgkshirttol) then
  4950. test2 = false
  4951. end
  4952. end
  4953. if (homegkcolour2 ~= -1) then
  4954. if (getColourDistance(homegkcolour2,refereecolour) < refgkshirttol) then
  4955. test2 = false
  4956. end
  4957. end
  4958. if (awaygkcolour1 ~= -1) then
  4959. if (getColourDistance(awaygkcolour1,refereecolour) < refgkshirttol) then
  4960. test2 = false
  4961. end
  4962. end
  4963. if (awaygkcolour2 ~= -1) then
  4964. if (getColourDistance(awaygkcolour2,refereecolour) < refgkshirttol) then
  4965. test2 = false
  4966. end
  4967. end
  4968. end
  4969.  
  4970. if (test and test2) then
  4971. return rkitcount + 6000
  4972. --doloop = false
  4973. end
  4974.  
  4975. if (test and (rrchoice1 == -1)) then
  4976. rrchoice1 = rkitcount + 6000
  4977. end
  4978.  
  4979. rkitcount = rkitcount + 1
  4980. if (rkitcount > 9) then
  4981. rkitcount = 4
  4982. end
  4983.  
  4984. if (rkitcount == rkit) then
  4985. doloop = false
  4986. end
  4987.  
  4988. end
  4989.  
  4990. return rrchoice1
  4991. end
  4992.  
  4993.  
  4994.  
  4995. altKitParts = {}
  4996. altKitPartsOption = {}
  4997. altKitPartsTourn = {}
  4998. altKitPartsOptionTourn = {}
  4999.  
  5000. function assignKitAlternateParts(team,kittype,altkittype,option)
  5001.  
  5002. if (altKitParts[team] == nil) then
  5003. altKitParts[team] = {}
  5004. altKitPartsOption[team] = {}
  5005. end
  5006.  
  5007. altKitParts[team][kittype] = altkittype
  5008. altKitPartsOption[team][kittype] = option
  5009. end
  5010.  
  5011. function assignTournamentKitAlternateParts(team,kittype,tourn,altkittype,option)
  5012.  
  5013. if (altKitPartsTourn[team] == nil) then
  5014. altKitPartsTourn[team] = {}
  5015. altKitPartsOptionTourn[team] = {}
  5016. end
  5017.  
  5018. if (altKitPartsTourn[team][kittype] == nil) then
  5019. altKitPartsTourn[team][kittype] = {}
  5020. altKitPartsOptionTourn[team][kittype] = {}
  5021. end
  5022.  
  5023. altKitPartsTourn[team][kittype][tourn] = altkittype
  5024. altKitPartsOptionTourn[team][kittype][tourn] = option
  5025. end
  5026.  
  5027. function getKitAlternateParts(team,kittype,tourn,year)
  5028.  
  5029. if (altKitPartsTourn[team] ~= nil) then
  5030. if (altKitPartsTourn[team][kittype] ~= nil) then
  5031. if (altKitPartsTourn[team][kittype][tourn] ~= nil) then
  5032. return altKitPartsTourn[team][kittype][tourn]
  5033. end
  5034. end
  5035. end
  5036.  
  5037. if (year == 0) then
  5038. if (altKitParts[team] ~= nil) then
  5039. if (altKitParts[team][kittype] ~= nil) then
  5040. return altKitParts[team][kittype]
  5041. end
  5042. end
  5043. end
  5044.  
  5045. return -1
  5046. end
  5047.  
  5048. function getKitAlternatePartsOption(team,kittype,tourn,year)
  5049.  
  5050. if (altKitPartsOptionTourn[team] ~= nil) then
  5051. if (altKitPartsOptionTourn[team][kittype] ~= nil) then
  5052. if (altKitPartsOptionTourn[team][kittype][tourn] ~= nil) then
  5053. return altKitPartsOptionTourn[team][kittype][tourn]
  5054. end
  5055. end
  5056. end
  5057.  
  5058. if (year == 0) then
  5059. if (altKitPartsOption[team] ~= nil) then
  5060. if (altKitPartsOption[team][kittype] ~= nil) then
  5061. return altKitPartsOption[team][kittype]
  5062. end
  5063. end
  5064. end
  5065.  
  5066. return -1
  5067. end
  5068.  
  5069.  
  5070.  
  5071. globalAltShortOutfieldOption = false
  5072. globalAltSockOutfieldOption = false
  5073.  
  5074. globalAltShortGKOption = false
  5075. globalAltSockGKOption = false
  5076.  
  5077. function setGlobalKitAlternateOptions(outoption,gkoption)
  5078.  
  5079. if (outoption == 0) then
  5080. globalAltShortOutfieldOption = false
  5081. globalAltSockOutfieldOption = false
  5082. end
  5083.  
  5084. if (outoption == 1) then
  5085. globalAltShortOutfieldOption = true
  5086. globalAltSockOutfieldOption = false
  5087. end
  5088.  
  5089. if (outoption == 2) then
  5090. globalAltShortOutfieldOption = false
  5091. globalAltSockOutfieldOption = true
  5092.  
  5093. end
  5094.  
  5095. if (outoption == 3) then
  5096. globalAltShortOutfieldOption = true
  5097. globalAltSockOutfieldOption = true
  5098. end
  5099.  
  5100.  
  5101. if (gkoption == 0) then
  5102. globalAltShortGKOption = false
  5103. globalAltSockGKOption = false
  5104. end
  5105.  
  5106. if (gkoption == 1) then
  5107. globalAltShortGKOption = true
  5108. globalAltSockGKOption = false
  5109. end
  5110.  
  5111. if (gkoption == 2) then
  5112. globalAltShortGKOption = false
  5113. globalAltSockGKOption = true
  5114. end
  5115.  
  5116. if (gkoption == 3) then
  5117. globalAltShortGKOption = true
  5118. globalAltSockGKOption = true
  5119. end
  5120.  
  5121. end
  5122.  
  5123.  
  5124.  
  5125.  
  5126. function getAltKitColour(team1,team2,team1type,team2type,team1tourn,team2tourn,team1year,team2year,team1outfieldtype)
  5127.  
  5128. team1typeshirt = getIndividualKitPart(team1type,1)
  5129. team1typeshort = getIndividualKitPart(team1type,2)
  5130. team1typesock = getIndividualKitPart(team1type,3)
  5131.  
  5132. --team2typeshirt = getIndividualKitPart(team2type,1)
  5133. team2typeshort = getIndividualKitPart(team2type,2)
  5134. team2typesock = getIndividualKitPart(team2type,3)
  5135.  
  5136. team1outfieldtypeshort = getIndividualKitPart(team1outfieldtype,2)
  5137. team1outfieldtypesock = getIndividualKitPart(team1outfieldtype,3)
  5138.  
  5139.  
  5140. altShortsType = getAltShorts(team1,team1typeshirt,team1tourn,team1year)
  5141. altSocksType = getAltSocks(team1,team1typeshirt,team1tourn,team1year)
  5142. altShortsSocksType = getAltShortsSocks(team1,team1typeshirt,team1tourn,team1year)
  5143.  
  5144. altPartsTypeShorts = getKitAlternateParts(team1,team1typeshirt,team1tourn,team1year)
  5145. altPartsTypeSocks = getKitAlternateParts(team1,team1typeshirt,team1tourn,team1year)
  5146.  
  5147. altPartsTypeOption = getKitAlternatePartsOption(team1,team1typeshirt,team1tourn,team1year)
  5148.  
  5149. if (team1year == 0) then
  5150.  
  5151. if (globalAltShortOutfieldOption) then
  5152. if (team1outfieldtypesock == -1) then
  5153. if (altPartsTypeShorts == -1) then
  5154. if (team1typeshirt == 0) then
  5155. altPartsTypeShorts = 1
  5156. end
  5157. if (team1typeshirt == 1) then
  5158. altPartsTypeShorts = 0
  5159. end
  5160. if (team1typeshirt == 3) then
  5161. altPartsTypeShorts = 0
  5162. end
  5163. end
  5164. end
  5165. end
  5166.  
  5167. if (globalAltSockOutfieldOption) then
  5168. if (team1outfieldtypesock == -1) then
  5169. if (altPartsTypeSocks == -1) then
  5170. if (team1typeshirt == 0) then
  5171. altPartsTypeSocks = 1
  5172. end
  5173. if (team1typeshirt == 1) then
  5174. altPartsTypeSocks = 0
  5175. end
  5176. if (team1typeshirt == 3) then
  5177. altPartsTypeSocks = 0
  5178. end
  5179. end
  5180. end
  5181. end
  5182.  
  5183. if (globalAltShortGKOption) then
  5184. if (team1outfieldtypesock ~= -1) then
  5185. if (altPartsTypeShorts == -1) then
  5186. altPartsTypeShorts = team1outfieldtypeshort
  5187. end
  5188. end
  5189. end
  5190.  
  5191. if (globalAltSockGKOption) then
  5192. if (team1outfieldtypesock ~= -1) then
  5193. if (altPartsTypeSocks == -1) then
  5194. altPartsTypeSocks = team1outfieldtypesock
  5195. end
  5196. end
  5197. end
  5198.  
  5199. end
  5200.  
  5201.  
  5202.  
  5203. if (altPartsTypeOption == 0) then
  5204. altPartsTypeShorts = -1
  5205. altPartsTypeSocks = -1
  5206. end
  5207.  
  5208. if (altPartsTypeOption == 1) then
  5209. altPartsTypeSocks = -1
  5210. end
  5211.  
  5212. if (altPartsTypeOption == 2) then
  5213. altPartsTypeShorts = -1
  5214. end
  5215.  
  5216.  
  5217. if (altPartsTypeOption == 4) then
  5218. altPartsTypeShorts = team1outfieldtypeshort
  5219. altPartsTypeSocks = -1
  5220. end
  5221.  
  5222. if (altPartsTypeOption == 5) then
  5223. altPartsTypeShorts = -1
  5224. altPartsTypeSocks = team1outfieldtypesock
  5225. end
  5226.  
  5227. if (altPartsTypeOption == 6) then
  5228. altPartsTypeShorts = team1outfieldtypeshort
  5229. altPartsTypeSocks = team1outfieldtypesock
  5230. end
  5231.  
  5232. -- if (altPartsTypeOption == 1) then
  5233. -- altPartsTypeShorts = -1
  5234. -- altPartsTypeSocks = -1
  5235. -- end
  5236.  
  5237.  
  5238.  
  5239. testshort = true
  5240. testsock = true
  5241.  
  5242. testshortalt = true
  5243. testsockalt = true
  5244.  
  5245. opponentcolourshort = getShortColour(team2,team2typeshort,team2tourn,team2year)
  5246. opponentcoloursock = getSockColour(team2,team2typesock,team2tourn,team2year)
  5247.  
  5248. teamcolourshort = getShortColour(team1,team1typeshort,team1tourn,team1year)
  5249. teamcoloursock = getSockColour(team1,team1typesock,team1tourn,team1year)
  5250.  
  5251. teamcolourshortalt = getShortColour(team1,altPartsTypeShorts,team1tourn,team1year)
  5252. teamcoloursockalt = getSockColour(team1,altPartsTypeSocks,team1tourn,team1year)
  5253.  
  5254. if (teamcolourshort ~= -1) then
  5255. if (opponentcolourshort ~= -1) then
  5256. if (getColourDistance(opponentcolourshort,teamcolourshort) < outoutshorttol) then
  5257. testshort = false
  5258. end
  5259. end
  5260. end
  5261.  
  5262. if (teamcoloursock ~= -1) then
  5263. if (opponentcoloursock ~= -1) then
  5264. if (getColourDistance(opponentcoloursock,teamcoloursock) < outoutsocktol) then
  5265. testsock = false
  5266. end
  5267. end
  5268. end
  5269.  
  5270.  
  5271.  
  5272.  
  5273. if (teamcolourshortalt ~= -1) then
  5274. if (opponentcolourshort ~= -1) then
  5275. if (getColourDistance(opponentcolourshort,teamcolourshortalt) < outoutshorttol) then
  5276. testshortalt = false
  5277. end
  5278. end
  5279. end
  5280.  
  5281. if (teamcoloursockalt ~= -1) then
  5282. if (opponentcoloursock ~= -1) then
  5283. if (getColourDistance(opponentcoloursock,teamcoloursockalt) < outoutsocktol) then
  5284. testsockalt = false
  5285. end
  5286. end
  5287. end
  5288.  
  5289.  
  5290. if ((not testshort) and (not testshortalt)) then
  5291. if (getColourDistance(opponentcolourshort,teamcolourshortalt) - getColourDistance(opponentcolourshort,teamcolourshort) > 20) then
  5292. testshortalt = true
  5293. end
  5294. end
  5295.  
  5296. if ((not testsock) and (not testsockalt)) then
  5297. if (getColourDistance(opponentcoloursock,teamcoloursockalt) - getColourDistance(opponentcoloursock,teamcoloursock) > 20) then
  5298. testsockalt = true
  5299. end
  5300. end
  5301.  
  5302.  
  5303. if (altPartsTypeOption == 7) then
  5304. testshort = false
  5305. testsock = true
  5306. testshortalt = true
  5307. testsockalt = true
  5308. altPartsTypeShorts = team1outfieldtypeshort
  5309. altPartsTypeSocks = team1outfieldtypesock
  5310. end
  5311.  
  5312. if (altPartsTypeOption == 8) then
  5313. testshort = true
  5314. testsock = false
  5315. testshortalt = true
  5316. testsockalt = true
  5317. altPartsTypeShorts = team1outfieldtypeshort
  5318. altPartsTypeSocks = team1outfieldtypesock
  5319. end
  5320.  
  5321. if (altPartsTypeOption == 9) then
  5322. testshort = false
  5323. testsock = false
  5324. testshortalt = true
  5325. testsockalt = true
  5326. altPartsTypeShorts = team1outfieldtypeshort
  5327. altPartsTypeSocks = team1outfieldtypesock
  5328. end
  5329.  
  5330.  
  5331.  
  5332.  
  5333. -- if (testshort and testsock) then
  5334. -- return -1
  5335. -- end
  5336.  
  5337. if ((not testshort) and testsock) then
  5338. if (altShortsType ~= -1) then
  5339. return altShortsType
  5340. else
  5341. if ((altPartsTypeShorts ~= -1) and testshortalt) then
  5342. return 4000000 + (team1type * 10000) + (altPartsTypeShorts * 100) + team1type
  5343. end
  5344. end
  5345. end
  5346.  
  5347.  
  5348. if (testshort and (not testsock)) then
  5349. if (altSocksType ~= -1) then
  5350. return altSocksType
  5351. else
  5352. if ((altPartsTypeSocks ~= -1) and testsockalt) then
  5353. return 4000000 + (team1type * 10000) + (team1type * 100) + altPartsTypeSocks
  5354. end
  5355. end
  5356. end
  5357.  
  5358.  
  5359. if ((not testshort) and (not testsock)) then
  5360. if (altShortsSocksType ~= -1) then
  5361. return altShortsSocksType
  5362. else
  5363.  
  5364. if (((altPartsTypeShorts ~= -1) and (altPartsTypeSocks ~= -1)) and (testshortalt and testsockalt)) then
  5365. return 4000000 + (team1type * 10000) + (altPartsTypeShorts * 100) + altPartsTypeSocks
  5366. end
  5367.  
  5368. if ((altPartsTypeShorts ~= -1) and testshortalt) then
  5369. return 4000000 + (team1type * 10000) + (altPartsTypeShorts * 100) + team1type
  5370. end
  5371.  
  5372.  
  5373. if ((altPartsTypeSocks ~= -1) and testsockalt) then
  5374. return 4000000 + (team1type * 10000) + (team1type * 100) + altPartsTypeSocks
  5375. end
  5376.  
  5377. end
  5378. end
  5379.  
  5380.  
  5381.  
  5382.  
  5383. return team1type
  5384. end
  5385.  
  5386.  
  5387.  
  5388.  
  5389. function getAltKit(team1,team2,team1type,team2type,team1tourn,team2tourn,team1year,team2year)
  5390.  
  5391. altkittypenew = getAlternateKitFile(team1,getIndividualKitPart(team1type,1),team1tourn,team1year)
  5392.  
  5393. if (altkittypenew ~= -1) then
  5394.  
  5395. homecolour1 = getShirt1Colour(team1,getIndividualKitPart(team1type,1),team1tourn,team1year)
  5396. homecolour2 = getShirt2Colour(team1,getIndividualKitPart(team1type,1),team1tourn,team1year)
  5397. awaycolour1 = getShirt1Colour(team2,getIndividualKitPart(team2type,1),team2tourn,team2year)
  5398. awaycolour2 = getShirt2Colour(team2,getIndividualKitPart(team2type,1),team2tourn,team2year)
  5399.  
  5400. homecolouralt1 = getShirt1Colour(team1,getIndividualKitPart(altkittypenew,1),team1tourn,team1year)
  5401. homecolouralt2 = getShirt2Colour(team1,getIndividualKitPart(altkittypenew,1),team1tourn,team1year)
  5402.  
  5403. test = true
  5404. test2 = true
  5405.  
  5406. if (awaycolour1 ~= -1) then
  5407. if (homecolour1 ~= -1) then
  5408. if (getColourDistance(homecolour1,awaycolour1) < refoutshirttol) then
  5409. test = false
  5410. end
  5411. end
  5412. if (homecolour2 ~= -1) then
  5413. if (getColourDistance(homecolour2,awaycolour1) < refoutshirttol) then
  5414. test = false
  5415. end
  5416. end
  5417. end
  5418.  
  5419. if (awaycolour2 ~= -1) then
  5420. if (homecolour1 ~= -1) then
  5421. if (getColourDistance(homecolour1,awaycolour2) < refoutshirttol) then
  5422. test = false
  5423. end
  5424. end
  5425. if (homecolour2 ~= -1) then
  5426. if (getColourDistance(homecolour2,awaycolour2) < refoutshirttol) then
  5427. test = false
  5428. end
  5429. end
  5430. end
  5431.  
  5432. if (awaycolour1 ~= -1) then
  5433. if (homecolouralt1 ~= -1) then
  5434. if (getColourDistance(homecolouralt1,awaycolour1) < refoutshirttol) then
  5435. test2 = false
  5436. end
  5437. end
  5438. if (homecolouralt2 ~= -1) then
  5439. if (getColourDistance(homecolouralt2,awaycolour1) < refoutshirttol) then
  5440. test2 = false
  5441. end
  5442. end
  5443. end
  5444.  
  5445. if (awaycolour2 ~= -1) then
  5446. if (homecolouralt1 ~= -1) then
  5447. if (getColourDistance(homecolouralt1,awaycolour2) < refoutshirttol) then
  5448. test2 = false
  5449. end
  5450. end
  5451. if (homecolouralt2 ~= -1) then
  5452. if (getColourDistance(homecolouralt2,awaycolour2) < refoutshirttol) then
  5453. test2 = false
  5454. end
  5455. end
  5456. end
  5457.  
  5458. if (not test and test2) then
  5459. return altkittypenew
  5460. end
  5461.  
  5462. end
  5463.  
  5464. return team1type
  5465. end
  5466.  
  5467.  
  5468.  
  5469. altKitFile = {}
  5470. altKitFileTourn = {}
  5471.  
  5472. function assignAlternateKit(team,kittype,new)
  5473.  
  5474. if (altKitFile[team] == nil) then
  5475. altKitFile[team] = {}
  5476. end
  5477.  
  5478. altKitFile[team][kittype] = new
  5479.  
  5480. end
  5481.  
  5482. function assignTournamentAlternateKit(team,kittype,tourn,new)
  5483.  
  5484. if (altKitFileTourn[team] == nil) then
  5485. altKitFileTourn[team] = {}
  5486. end
  5487.  
  5488. if (altKitFileTourn[team][kittype] == nil) then
  5489. altKitFileTourn[team][kittype] = {}
  5490. end
  5491.  
  5492. altKitFileTourn[team][kittype][tourn] = new
  5493.  
  5494. end
  5495.  
  5496. function getAlternateKitFile(team,kittype,tourn,year)
  5497.  
  5498. if (altKitFileTourn[team] ~= nil) then
  5499. if (altKitFileTourn[team][kittype] ~= nil) then
  5500. if (altKitFileTourn[team][kittype][tourn] ~= nil) then
  5501. return altKitFileTourn[team][kittype][tourn]
  5502. end
  5503. end
  5504. end
  5505.  
  5506.  
  5507. if (year == 0) then
  5508. if (altKitFile[team] ~= nil) then
  5509. if (altKitFile[team][kittype] ~= nil) then
  5510. return altKitFile[team][kittype]
  5511. end
  5512. end
  5513. end
  5514.  
  5515. return -1
  5516. end
  5517.  
  5518.  
  5519.  
  5520.  
  5521. outoutshorttol = 100
  5522. outoutsocktol = 100
  5523. gkoutshirttol = 100
  5524. gkoutsocktol = 100
  5525. gkgkshirttol = 100
  5526. refoutshirttol = 100
  5527. refgkshirttol = 100
  5528.  
  5529.  
  5530. function setOutfieldOutfieldClashThreshold(short,sock)
  5531. outoutshorttol = short
  5532. outoutsocktol = sock
  5533. end
  5534.  
  5535. function setOutfieldGKClashThreshold(shirt,sock)
  5536. gkoutshirttol = shirt
  5537. gkoutsocktol = sock
  5538. end
  5539.  
  5540. function setGKGKClashThreshold(shirt)
  5541. gkgkshirttol = shirt
  5542. end
  5543.  
  5544. function setOutfieldRefereeClashThreshold(shirt)
  5545. refoutshirttol = shirt
  5546. end
  5547.  
  5548. function setGKRefereeClashThreshold(shirt)
  5549. refgkshirttol = shirt
  5550. end
  5551.  
  5552.  
  5553. globalundershort = -1
  5554.  
  5555.  
  5556. function useGlobalUndershorts(option)
  5557. globalundershort = option
  5558. end
  5559.  
  5560.  
  5561.  
  5562. function getIndividualKitPart(number,option)
  5563.  
  5564. if (number >= 4000000) then
  5565.  
  5566. local sock = number%100
  5567.  
  5568. if (option == 3) then
  5569. return sock
  5570. end
  5571.  
  5572. local short = (number-sock)%10000 / 100
  5573.  
  5574. if (option == 2) then
  5575. return short
  5576. end
  5577.  
  5578. return (number-(short*100)-sock)%1000000 / 10000
  5579. end
  5580.  
  5581. return number
  5582. end
  5583.  
  5584.  
  5585. classicGKMode = false
  5586.  
  5587. function enableGenericClassicGKKits()
  5588. classicGKMode = true
  5589. end
  5590.  
  5591. kitsetactiveid = {}
  5592.  
  5593.  
  5594. function enableSwapTeamKitSet(id)
  5595. kitsetactiveid[id] = 1
  5596. end
  5597.  
  5598.  
  5599. fourthofficialdry = 0
  5600. fourthofficialwet = 0
  5601. fourthofficialdrywin = 0
  5602. fourthofficialwetwin = 0
  5603. fourthofficialsnow = 0
  5604.  
  5605.  
  5606. function setFourthOfficialKitType(dry,wet,drywin,wetwin,snow)
  5607. fourthofficialdry = dry
  5608. fourthofficialwet = wet
  5609. fourthofficialdrywin = drywin
  5610. fourthofficialwetwin = wetwin
  5611. fourthofficialsnow = snow
  5612. end
  5613.  
  5614. function getFourthOfficialKitType(weather,climate)
  5615.  
  5616. if (weather == 2) then
  5617. return fourthofficialsnow
  5618. end
  5619.  
  5620. if ((climate == 1) and (weather == 1)) then
  5621. return fourthofficialwetwin
  5622. end
  5623.  
  5624. if (climate == 1) then
  5625. return fourthofficialdrywin
  5626. end
  5627.  
  5628. if ((climate == 0) and (weather == 1)) then
  5629. return fourthofficialwet
  5630. end
  5631.  
  5632. return fourthofficialdry
  5633. end
  5634.  
  5635.  
  5636.  
  5637.  
  5638. function GetRMArmbandModel(idx,lod)
  5639.     local model = ""
  5640.    
  5641.     if (lod ~= 2) then
  5642.     model = model.."data/sceneassets/body/jersey_"..(lod).."_"..db.player[idx].jerseyCollarType.."_"..db.player[idx].jerseySleeveLength.."_"..db.player[idx].jerseyArmBandCustom.."_"..db.player[idx].jerseyTucked.."_"..db.player[idx].jerseyfit.."_"..db.player[idx].gender..".rx3;"
  5643.     else
  5644.     model = model.."data/sceneassets/body/jersey_"..(lod).."_"..db.player[idx].jerseySleeveLength.."_"..db.player[idx].jerseyArmBandCustom.."_"..db.player[idx].jerseyTucked.."_"..db.player[idx].gender..".rx3;"
  5645.     end
  5646.  
  5647.     return model
  5648. end
  5649.  
  5650. customArmband = {}
  5651.  
  5652. function assignArmbandModel(player,model)
  5653. customArmband[player] = model
  5654. end
  5655.  
  5656. function getArmbandModel(player,model)
  5657.  
  5658. if (customArmband[player] ~= nil) then
  5659. return customArmband[player]
  5660. end
  5661.  
  5662. return model
  5663. end
  5664.  
  5665.  
  5666. kitMenuClashing = true
  5667.  
  5668. function disableKitSelectionMenuKitClashPreview()
  5669. kitMenuClashing = false
  5670. end
  5671.  
  5672.  
  5673.  
  5674.  
  5675.  
  5676.  
  5677. teamBibColours = {}
  5678. teamBibColoursTournament = {}
  5679.  
  5680. genericBibColours = {}
  5681. genericBibColoursTournament = {}
  5682.  
  5683. function identifyTeamBibColour(team,bibtype,colour)
  5684.  
  5685. if (teamBibColours[team] == nil) then
  5686. teamBibColours[team] = {}
  5687. end
  5688.  
  5689. teamBibColours[team][bibtype] = colour
  5690.  
  5691. end
  5692.  
  5693.  
  5694. function identifyTeamBibColourTournament(team,bibtype,tourn,colour)
  5695.  
  5696. if (teamBibColoursTournament[team] == nil) then
  5697. teamBibColoursTournament[team] = {}
  5698. end
  5699.  
  5700. if (teamBibColoursTournament[team][bibtype] == nil) then
  5701. teamBibColoursTournament[team][bibtype] = {}
  5702. end
  5703.  
  5704. teamBibColoursTournament[team][bibtype][tourn] = colour
  5705.  
  5706. end
  5707.  
  5708. function identifyGenericBibColour(bibtype,colour)
  5709.  
  5710. genericBibColours[bibtype] = colour
  5711.  
  5712. end
  5713.  
  5714.  
  5715. function identifyBibColourTournament(bibtype,tourn,colour)
  5716.  
  5717.  
  5718. if (genericBibColoursTournament[bibtype] == nil) then
  5719. genericBibColoursTournament[bibtype] = {}
  5720. end
  5721.  
  5722. genericBibColoursTournament[bibtype][tourn] = colour
  5723.  
  5724. end
  5725.  
  5726.  
  5727. function getBibColour(team,bibtype,tourn)
  5728.  
  5729. if (teamBibColoursTournament[team] ~= nil) then
  5730. if (teamBibColoursTournament[team][bibtype] ~= nil) then
  5731. if (teamBibColoursTournament[team][bibtype][tourn] ~= nil) then
  5732. return teamBibColoursTournament[team][bibtype][tourn]
  5733. end
  5734. end
  5735. end
  5736.  
  5737. if (genericBibColoursTournament[bibtype] ~= nil) then
  5738. if (genericBibColoursTournament[bibtype][tourn] ~= nil) then
  5739. return genericBibColoursTournament[bibtype][tourn]
  5740. end
  5741. end
  5742.  
  5743. if (teamBibColours[team] ~= nil) then
  5744. if (teamBibColours[team][bibtype] ~= nil) then
  5745. return teamBibColours[team][bibtype]
  5746. end
  5747. end
  5748.  
  5749. if (genericBibColours[bibtype] ~= nil) then
  5750. return genericBibColours[bibtype]
  5751. end
  5752.  
  5753. return -1
  5754. end
  5755.  
  5756.  
  5757.  
  5758.  
  5759.  
  5760.  
  5761.  
  5762. bibOrderTeam = {}
  5763. bibOrderRandTeam = {}
  5764. bibOrderTourn = {}
  5765. bibOrderRandTourn = {}
  5766. bibOrderTeamTourn = {}
  5767. bibOrderRandTeamTourn = {}
  5768.  
  5769. bibOrderGeneric = -1
  5770. bibOrderRandGeneric = -1
  5771.  
  5772. function assignTeamBibPrecedence(team,bibtype,randomused,list)
  5773.  
  5774. if (bibOrderTeam[team] == nil) then
  5775. bibOrderTeam[team] = {}
  5776. bibOrderRandTeam[team] = {}
  5777. end
  5778.  
  5779. bibOrderTeam[team][bibtype] = list
  5780. bibOrderRandTeam[team][bibtype] = randomused
  5781.  
  5782. end
  5783.  
  5784. function assignTeamTournamentBibPrecedence(team,bibtype,tourn,randomused,list)
  5785.  
  5786. if (bibOrderTourn[team] == nil) then
  5787. bibOrderTourn[team] = {}
  5788. bibOrderRandTourn[team] = {}
  5789. end
  5790.  
  5791. if (bibOrderTourn[team][bibtype] == nil) then
  5792. bibOrderTourn[team][bibtype] = {}
  5793. bibOrderRandTourn[team][bibtype] = {}
  5794. end
  5795.  
  5796. bibOrderTourn[team][bibtype][tourn] = list
  5797. bibOrderRandTourn[team][bibtype][tourn] = randomused
  5798.  
  5799. end
  5800.  
  5801. function assignTournamentBibPrecedence(tourn,randomused,list)
  5802.  
  5803. bibOrderTourn[tourn] = list
  5804. bibOrderRandTourn[tourn] = randomused
  5805.  
  5806. end
  5807.  
  5808. function getBibPrecedenceList(team,bibtype,tourn,year)
  5809.  
  5810.  
  5811. if (bibOrderTeamTourn[team] ~= nil) then
  5812. if (bibOrderTeamTourn[team][bibtype] ~= nil) then
  5813. if (bibOrderTeamTourn[team][bibtype][tourn] ~= nil) then
  5814. return bibOrderTeamTourn[team][bibtype][tourn]
  5815. end
  5816. end
  5817. end
  5818.  
  5819.  
  5820. if (bibOrderTourn[tourn] ~= nil) then
  5821. return bibOrderTourn[tourn]
  5822. end
  5823.  
  5824.  
  5825. if (year == 0) then
  5826. if (bibOrderTeam[team] ~= nil) then
  5827. if (bibOrderTeam[team][bibtype] ~= nil) then
  5828. return bibOrderTeam[team][bibtype]
  5829. end
  5830. end
  5831. end
  5832.  
  5833. if (bibOrderGeneric ~= -1) then
  5834. return bibOrderGeneric
  5835. end
  5836.  
  5837. return -1
  5838. end
  5839.  
  5840. function assignGenericBibPrecedence(randomused,list)
  5841.  
  5842. bibOrderGeneric = list
  5843. bibOrderRandGeneric = randomused
  5844.  
  5845. end
  5846.  
  5847. function getBibPrecedenceRand(team,bibtype,tourn,year)
  5848.  
  5849.  
  5850. if (bibOrderRandTourn[team] ~= nil) then
  5851. if (bibOrderRandTourn[team][bibtype] ~= nil) then
  5852. if (bibOrderRandTourn[team][bibtype][tourn] ~= nil) then
  5853. return bibOrderRandTourn[team][bibtype][tourn]
  5854. end
  5855. end
  5856. end
  5857.  
  5858. if (bibOrderRand[team] ~= nil) then
  5859. if (bibOrderRand[team][bibtype] ~= nil) then
  5860. return bibOrderRand[team][bibtype]
  5861. end
  5862. end
  5863.  
  5864. if (bibOrderRandGeneric ~= nil) then
  5865. return bibOrderRandGeneric
  5866. end
  5867.  
  5868. return -1
  5869. end
  5870.  
  5871.  
  5872.  
  5873.  
  5874.  
  5875. function getBibColourType(team1,team2,team1type,team2type,team1tourn,team2tourn,team1year,team2year,tourn,team1gktype,team2gktype,refkittype,refkittourn,hometeam,otherbib)
  5876.  
  5877. rrchoice1 = -1
  5878. rrchoice2 = -1
  5879. rrchoice3 = -1
  5880.  
  5881. homecolour1 = getShirt1Colour(team1,getIndividualKitPart(team1type,1),team1tourn,team1year)
  5882. homecolour2 = getShirt2Colour(team1,getIndividualKitPart(team1type,1),team1tourn,team1year)
  5883. awaycolour1 = getShirt1Colour(team2,getIndividualKitPart(team2type,1),team2tourn,team2year)
  5884. awaycolour2 = getShirt2Colour(team2,getIndividualKitPart(team2type,1),team2tourn,team2year)
  5885.  
  5886. homegkcolour1 = getShirt1Colour(team1,getIndividualKitPart(team1gktype,1),team1tourn,team1year)
  5887. homegkcolour2 = getShirt2Colour(team1,getIndividualKitPart(team1gktype,1),team1tourn,team1year)
  5888. awaygkcolour1 = getShirt1Colour(team2,getIndividualKitPart(team2gktype,1),team2tourn,team2year)
  5889. awaygkcolour2 = getShirt2Colour(team2,getIndividualKitPart(team2gktype,1),team2tourn,team2year)
  5890.  
  5891. refereecolour = getRefereeKitColours(refkittourn,hometeam,(refkittype-6000))
  5892.  
  5893. otherbibcolour = getBibColour(team2,otherbib,tourn)
  5894.  
  5895. -- refereecolour2 = getRefereeKitColours(tourn,team1,refkittype)
  5896. -- if (ishome == 2) then
  5897. -- refereecolour2 = getRefereeKitColours(tourn,team2,refkittype)
  5898. -- end
  5899.  
  5900.  
  5901. --gklist = getGKKitPrecedenceList(team1,team1typeshirt,team1tourn,team1year)
  5902. --isrand = getGKKitPrecedenceRand(team1,team1typeshirt,team1tourn,team1year)
  5903.  
  5904. --biblist = getBibPrecedenceList(team,bibtype,tourn,year)
  5905. biblist = getBibPrecedenceList(team1,0,tourn,year)
  5906. isrand = 0
  5907.  
  5908.  
  5909. if (biblist ~= -1) then
  5910. biblistsize = #biblist
  5911.  
  5912. if (biblistsize == 1) then
  5913. return biblist[1]
  5914. end
  5915.  
  5916. bibfirst = 1
  5917.  
  5918.  
  5919. if (isrand == 1) then
  5920. bibfirst = math.random(biblistsize)
  5921. end
  5922.  
  5923. bibcount = bibfirst
  5924.  
  5925.  
  5926.  
  5927.  
  5928.  
  5929.  
  5930.  
  5931.  
  5932.  
  5933.  
  5934.  
  5935.  
  5936.  
  5937. doloop = true
  5938.  
  5939. while (doloop) do
  5940. test = true
  5941. test2 = true
  5942. test3 = true
  5943. test4 = true
  5944.  
  5945. bibcolour = getBibColour(team1,biblist[bibcount],tourn)
  5946.  
  5947. if (bibcolour ~= -1) then
  5948. if (homecolour1 ~= -1) then
  5949. if (getColourDistance(homecolour1,bibcolour) < refoutshirttol) then
  5950. test = false
  5951. end
  5952. end
  5953. if (homecolour2 ~= -1) then
  5954. if (getColourDistance(homecolour2,bibcolour) < refoutshirttol) then
  5955. test = false
  5956. end
  5957. end
  5958. if (awaycolour1 ~= -1) then
  5959. if (getColourDistance(awaycolour1,bibcolour) < refoutshirttol) then
  5960. test = false
  5961. end
  5962. end
  5963. if (awaycolour2 ~= -1) then
  5964. if (getColourDistance(awaycolour2,bibcolour) < refoutshirttol) then
  5965. test = false
  5966. end
  5967. end
  5968. end
  5969.  
  5970. if (bibcolour ~= -1) then
  5971. if (homegkcolour1 ~= -1) then
  5972. if (getColourDistance(homegkcolour1,bibcolour) < refgkshirttol) then
  5973. test2 = false
  5974. end
  5975. end
  5976. if (homegkcolour2 ~= -1) then
  5977. if (getColourDistance(homegkcolour2,bibcolour) < refgkshirttol) then
  5978. test2 = false
  5979. end
  5980. end
  5981. if (awaygkcolour1 ~= -1) then
  5982. if (getColourDistance(awaygkcolour1,bibcolour) < refgkshirttol) then
  5983. test2 = false
  5984. end
  5985. end
  5986. if (awaygkcolour2 ~= -1) then
  5987. if (getColourDistance(awaygkcolour2,bibcolour) < refgkshirttol) then
  5988. test2 = false
  5989. end
  5990. end
  5991. end
  5992.  
  5993.  
  5994.  
  5995.  
  5996. if (bibcolour ~= -1) then
  5997. if (otherbibcolour ~= -1) then
  5998. if (getColourDistance(otherbibcolour,bibcolour) < refgkshirttol) then
  5999. test3 = false
  6000. end
  6001. end
  6002. end
  6003.  
  6004.  
  6005. if (bibcolour ~= -1) then
  6006. if (refereecolour ~= -1) then
  6007. if (getColourDistance(refereecolour,bibcolour) < refgkshirttol) then
  6008. test4 = false
  6009. end
  6010. end
  6011. end
  6012.  
  6013.  
  6014.  
  6015.  
  6016. if ((test and test2) and (test3 and test4)) then
  6017. return biblist[bibcount]
  6018. --doloop = false
  6019. end
  6020.  
  6021.  
  6022. if (((test and test2) and test3) and (rrchoice1 == -1)) then
  6023. rrchoice1 = biblist[bibcount]
  6024. end
  6025.  
  6026. if ((test and test2) and (rrchoice2 == -1)) then
  6027. rrchoice2 = biblist[bibcount]
  6028. end
  6029.  
  6030. if (test and (rrchoice3 == -1)) then
  6031. rrchoice3 = biblist[bibcount]
  6032. end
  6033.  
  6034.  
  6035. bibcount = bibcount + 1
  6036. if (bibcount > biblistsize) then
  6037. bibcount = 1
  6038. end
  6039.  
  6040. if (bibcount == bibfirst) then
  6041. doloop = false
  6042. end
  6043.  
  6044. end
  6045.  
  6046. end
  6047.  
  6048. if (rrchoice1 ~= -1) then
  6049. return rrchoice1
  6050. end
  6051.  
  6052. if (rrchoice2 ~= -1) then
  6053. return rrchoice2
  6054. end
  6055.  
  6056. if (rrchoice3 ~= -1) then
  6057. return rrchoice3
  6058. end
  6059.  
  6060. return -1
  6061. end
  6062.  
  6063.  
  6064.  
  6065.  
  6066.  
  6067. overlayOffsetTeam = {}
  6068.  
  6069. function setTeamKitOverlayVarient(team,offset)
  6070.  
  6071. overlayOffsetTeam[team] = offset
  6072.  
  6073. end
  6074.  
  6075. function getKitOverlayVarient(team)
  6076.  
  6077. if (overlayOffsetTeam[team] ~= nil) then
  6078. return overlayOffsetTeam[team]
  6079. end
  6080.  
  6081. return 0
  6082. end
  6083.  
  6084.  
  6085.  
  6086.  
  6087.  
  6088. genPlayerHairColour = {}
  6089.  
  6090. function setGenericHairColour(player,col)
  6091.  
  6092. genPlayerHairColour[player] = hex(col)
  6093.  
  6094. end
  6095.  
  6096. function getGenericHairColour(player,col)
  6097.  
  6098. if (genPlayerHairColour[player] ~= nil) then
  6099. return genPlayerHairColour[player]
  6100. end
  6101.  
  6102. return col
  6103. end
  6104.  
  6105.  
  6106. forceFemale = false
  6107.  
  6108. function setAllPlayersAsFemale()
  6109.  
  6110. forceFemale = true
  6111.  
  6112. end
  6113.  
  6114.  
  6115. enableEAFemaleRefereeKits = true
  6116.  
  6117.  
  6118. function disableEAFemaleRefereeKits()
  6119. enableEAFemaleRefereeKits = false
  6120. end
  6121.  
  6122.  
  6123.  
  6124. homeoutfieldkittypechoice = -2
  6125. awayoutfieldkittypechoice = -2
  6126. homegkkittypechoice = -2
  6127. awaygkkittypechoice = -2
  6128. refereekittypechoice = -2
  6129. homebibchoice = -2
  6130. awaybibchoice = -2
  6131.  
  6132. seed = 848498027
  6133.  
  6134. oldidx = -1
  6135.  
  6136. --Revolution Mod 16 V1.3.2
  6137. --Edited by scouser09
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement