Advertisement
rockbandcheeseman

Gametype Info

Jun 24th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.95 KB | None | 0 0
  1. -- Gametypes
  2.  
  3. require "lfs"
  4.  
  5. --[[ Gametypes Table ]]--
  6.  
  7.     gametypes = table.load("gametypes")
  8.    
  9. --[[ Gametypes Table Structure ]]--
  10.  
  11. --[[
  12.  
  13.     gametypes
  14.         gametypes[name]
  15.             gametypes[name].game
  16.             gametypes[name].team
  17.             gametypes[name].weapons
  18.             gametypes[name].lives
  19.             gametypes[name].shields
  20.             etc...
  21.            
  22. --]]
  23.  
  24. function LoadGametypes()
  25.  
  26.     local dir = getprofilepath() .. "\\savegames\\"
  27.     local directories = {}
  28.     local files = {}
  29.     for f in lfs.dir(dir) do
  30.         if f ~= "." and f ~= ".." then
  31.             if lfs.attributes(dir .. f, "mode") == "file" then
  32.                 table.insert(files, dir .. f)
  33.             elseif lfs.attributes(dir .. f, "mode") == "directory" then
  34.                 table.insert(directories, dir .. f)
  35.             end
  36.         end
  37.     end
  38.    
  39.     local defdir = getprofilepath() .. "\\saved\\playlists\\default_playlist\\"
  40.     for f in lfs.dir(defdir) do
  41.         if f ~= "." and f ~= ".." then
  42.             if lfs.attributes(defdir .. f, "mode") == "file" then
  43.                 table.insert(files, defdir .. f)
  44.             elseif lfs.attributes(defdir .. f, "mode") == "directory" then
  45.                 table.insert(directories, defdir .. f)
  46.             end
  47.         end
  48.     end
  49.    
  50.     for k,v in ipairs(directories) do
  51.         local dirs = string.split(v, "\\")
  52.         local gtname = dirs[#dirs]
  53.         if not gametypes[gtname] then
  54.             for f in lfs.dir(v) do
  55.                 if f == "blam.lst" then
  56.                     local blam = io.open(v .. "\\blam.lst", "r")
  57.                     local str = blam:read("*all")
  58.                     local chars = string.split(str, "")
  59.                     local name = readgame(chars, 0x0, 0x2F)
  60.                     local gametype = tonumber(readgame(chars, 0x30, 0x33, true)) -- 1 = CTF | 2 = Slayer | 3 = Oddball | 4 = KOTH | 5 = Race
  61.                     local teamplay = tonumber(readgame(chars, 0x34, 0x37, true)) -- 0 = off | 1 = on
  62.                     local parameters = formatbinary(readgame(chars, 0x38, 0x3B, true), 8)
  63.                     -- 0 = off | 1 = on
  64.                     local players_on_radar = tonumber(string.sub(parameters, 8, 8))
  65.                     local friend_indicators = tonumber(string.sub(parameters, 7, 7))
  66.                     local infinite_grenades = tonumber(string.sub(parameters, 6, 6))
  67.                     local shields = 1 - tonumber(string.sub(parameters, 5, 5))
  68.                     local invisible_players = tonumber(string.sub(parameters, 4, 4))
  69.                     local starting_equipment = tonumber(string.sub(parameters, 3, 3)) -- 0 = Generic | 1 = Custom
  70.                     local only_friends_on_radar = tonumber(string.sub(parameters, 2, 2))
  71.                     local objectives_indicator = tonumber(readgame(chars, 0x3C, 0x3F, true)) -- 0 = Motion Tracker | 1 = Navpoints | 2 = None
  72.                     local odd_man_out = tonumber(readgame(chars, 0x40, 0x43, true)) -- 0 = off | 1 = on
  73.                     local respawn_time_growth = tonumber(readgame(chars, 0x44, 0x47, true)) -- 0 = off | 150 = 5 secs | 300 = 10 secs | 450 = 15 secs
  74.                     local respawn_time = tonumber(readgame(chars, 0x48, 0x4B, true)) -- 0 = Instant | 150 = 5 secs | 300 = 10 secs | 450 = 15 secs
  75.                     local suicide_penalty = tonumber(readgame(chars, 0x4C, 0x4F, true)) -- 0 = None | 150 = 5 secs | 300 = 10 secs | 450 = 15 secs
  76.                     local lives = tonumber(readgame(chars, 0x50, 0x53, true)) -- 0 = Unlimited lives | 1, 3, 5 = 1, 3, 5 lives
  77.                    
  78.                     local max_health = tonumber(readgame(chars, 0x57, 0x57, true)) -- 64 = 400% | 63 = 100% (Find others)
  79.                    
  80.                     local scorelimit = tonumber(readgame(chars, 0x58, 0x5B, true)) -- check how this is stored for timed gametypes
  81.                     local weapon_set = tonumber(readgame(chars, 0x5C, 0x5F, true)) -- 0 = Normal | 1 = Pistols | 2 = Rifles | 3 = Plasma | 4 = Sniper | 5 = No Sniping | 6 = Rockets | 7 = Shotguns | 8 = Shortrange | 9 = Human | 10 = Covenant | 11 = Classic | 12 = Heavy
  82.                    
  83.                     -- Insert Vehicle Stuff Here --
  84.                    
  85.                     local friendly_fire = tonumber(readgame(chars, 0x6C, 0x6F, true)) -- 0 = off | 1 = on
  86.                     local tk_penalty = tonumber(readgame(chars, 0x70, 0x73, true)) -- 0 = off | 150 = 5 secs | 300 = 10 secs | 450 = 15 secs
  87.                     local team_balance = tonumber(readgame(chars, 0x74, 0x77, true)) -- 0 = off | 1 = on
  88.                     local timelimit = tonumber(readgame(chars, 0x78, 0x7B, true)) -- 0 = No Timelimit | 18000 = 10 min | 27000 = 15 min | 36000 = 20 min | 45000 = 25 min | 54000 = 30 min | 81000 = 45 min
  89.                     local assault = tonumber(readgame(chars, 0x7C, 0x7C, true)) -- 0 = CTF | 1 = Assault
  90.                     local alternating = tonumber(readgame(chars, 0x81, 0x81, true)) -- 0 = Not Alternating | 14 = Alternating Assault | 35 = Alternating CTF (could have to do with single flag time)
  91.                     local moving_hill = tonumber(readgame(chars, 0x7C, 0x7F, true)) -- 0 = off | 1 = on
  92.                     local race_type = tonumber(readgame(chars, 0x7C, 0x7F, true)) -- 0 = Normal | 1 = Any Order | 2 = Rally
  93.                     local oddball_random_start = tonumber(readgame(chars, 0x7C, 0x7F, true)) -- 0 = off | 1 = on                   
  94.                     local oddball_speed = tonumber(readgame(chars, 0x80, 0x82, true)) -- 0 = Slow | 1 = Normal | 2 = Fast                  
  95.                     local oddball_trait = tonumber(readgame(chars, 0x83, 0x83, true)) -- 0 = None | 1 = Invisible | 2 = Extra Damage | 3 = Damage Resistant
  96.                     local no_oddball_trait = tonumber(readgame(chars, 0x88, 0x8B, true)) -- 0 = None | 1 = Invisible | 2 = Extra Damage | 3 = Damage Resistant
  97.                     local oddball_type = tonumber(readgame(chars, 0x8C, 0x8C, true)) -- 0 = Normal | 1 = Reverse Tag | 2 = Juggernaut
  98.                     local oddball_count = tonumber(readgame(chars, 0x90, 0x90, true)) -- From 0 - 16
  99.                    
  100.                     blam:close()
  101.                    
  102.                     local function getgame()
  103.                         if gametype == 1 then
  104.                             return "CTF"
  105.                         elseif gametype == 2 then
  106.                             return "Slayer"
  107.                         elseif gametype == 3 then
  108.                             return "Oddball"
  109.                         elseif gametype == 4 then
  110.                             return "KotH"
  111.                         elseif gametype == 5 then
  112.                             return "Race"
  113.                         end
  114.                     end
  115.                    
  116.                     local function getteamplay()
  117.                    
  118.                         if teamplay == 1 then
  119.                             return true
  120.                         end
  121.                     end
  122.                    
  123.                     local function getallonradar()
  124.                    
  125.                         if players_on_radar == 1 then
  126.                             return true
  127.                         end
  128.                     end
  129.                    
  130.                     local function getfriendindicators()
  131.                    
  132.                         if friend_indicators == 1 then
  133.                             return true
  134.                         end
  135.                     end
  136.                    
  137.                     local function getinfgrenades()
  138.                    
  139.                         if infinite_grenades == 1 then
  140.                             return true
  141.                         end
  142.                     end
  143.                    
  144.                     local function getshields()
  145.                    
  146.                         if shields == 1 then
  147.                             return true
  148.                         end
  149.                     end
  150.                    
  151.                     local function getinvisibleplayers()
  152.                    
  153.                         if invisible_players == 1 then
  154.                             return true
  155.                         end
  156.                     end
  157.                    
  158.                     local function getstarteqip()
  159.                    
  160.                         if starting_equipment == 1 then
  161.                             return "Generic"
  162.                         else
  163.                             return "Custom"
  164.                         end
  165.                     end
  166.                    
  167.                     local function getfriendsonradar()
  168.                    
  169.                         if only_friends_on_radar == 1 then
  170.                             return true
  171.                         end
  172.                     end
  173.                    
  174.                     local function getobjectivesindicator()
  175.                    
  176.                         if objectives_indicator == 0 then
  177.                             return "Motion Tracker"
  178.                         elseif objectives_indicator == 1 then
  179.                             return "Navpoints"
  180.                         elseif objectives_indicator == 2 then
  181.                             return "None"
  182.                         end
  183.                     end
  184.                    
  185.                     local function getoddmanout()
  186.                    
  187.                         if odd_man_out == 1 then
  188.                             return true
  189.                         end
  190.                     end
  191.                    
  192.                     local function getlives()
  193.                    
  194.                         if lives == 0 then
  195.                             return "Unlimited"
  196.                         else
  197.                             return lives
  198.                         end
  199.                     end
  200.                    
  201.                     local function getmaxhealth()
  202.                    
  203.                         if max_health == 63 then
  204.                             return 100
  205.                         elseif max_health == 64 then
  206.                             return 400
  207.                         end
  208.                     end
  209.                    
  210.                     local function getweaponset()
  211.                    
  212.                         if weapon_set == 0 then
  213.                             return "Normal"
  214.                         elseif weapon_set == 1 then
  215.                             return "Pistols"
  216.                         elseif weapon_set == 2 then
  217.                             return "Rifles"
  218.                         elseif weapon_set == 3 then
  219.                             return "Plasmas"
  220.                         elseif weapon_set == 4 then
  221.                             return "Snipers"
  222.                         elseif weapon_set == 5 then
  223.                             return "No Sniping"
  224.                         elseif weapon_set == 6 then
  225.                             return "Rockets"
  226.                         elseif weapon_set == 7 then
  227.                             return "Shotguns"
  228.                         elseif weapon_set == 8 then
  229.                             return "Short-Range"
  230.                         elseif weapon_set == 9 then
  231.                             return "Human"
  232.                         elseif weapon_set == 10 then
  233.                             return "Covenant"
  234.                         elseif weapon_set == 11 then
  235.                             return "Classic"
  236.                         elseif weapon_set == 12 then
  237.                             return "Heavy"
  238.                         end
  239.                     end
  240.                    
  241.                     local function getfriendlyfire()
  242.                    
  243.                         if friendly_fire == 1 then
  244.                             return true
  245.                         end
  246.                     end
  247.                    
  248.                     local function getteambalance()
  249.                    
  250.                         if team_balance == 1 then
  251.                             return true
  252.                         end
  253.                     end
  254.                    
  255.                     local function getassault()
  256.                    
  257.                         if assault == 1 then
  258.                             return true
  259.                         end
  260.                     end
  261.                    
  262.                     local function getalternating()
  263.                    
  264.                         if alternating ~= 0 then
  265.                             return true
  266.                         end
  267.                     end
  268.                    
  269.                     local function getmovinghill()
  270.                    
  271.                         if moving_hill == 1 then
  272.                             return true
  273.                         end
  274.                     end
  275.                    
  276.                     local function getracetype()
  277.                    
  278.                         if race_type == 0 then
  279.                             return "Normal"
  280.                         elseif race_type == 1 then
  281.                             return "Any Order"
  282.                         elseif race_type == 2 then
  283.                             return "Rally"
  284.                         end
  285.                     end
  286.                    
  287.                     local function getoddballtype()
  288.                    
  289.                         if oddball_type == 0 then
  290.                             return "Normal"
  291.                         elseif oddball_type == 1 then
  292.                             return "Reverse Tag"
  293.                         elseif oddball_type == 2 then
  294.                             return "Juggernaut"
  295.                         end
  296.                     end
  297.                    
  298.                     local function getballrandomstart()
  299.                    
  300.                         if oddball_random_start == 1 then
  301.                             return true
  302.                         end
  303.                     end
  304.                    
  305.                     local function getoddballspeed()
  306.                    
  307.                         if oddball_speed == 0 then
  308.                             return "Slow"
  309.                         elseif oddball_speed == 1 then
  310.                             return "Normal"
  311.                         elseif oddball_speed == 2 then
  312.                             return "Fast"
  313.                         end
  314.                     end
  315.                    
  316.                     local function getoddballtrait()
  317.                    
  318.                         if oddball_trait == 0 then
  319.                             return "None"
  320.                         elseif oddball_trait == 1 then
  321.                             return "Invisible"
  322.                         elseif oddball_trait == 2 then
  323.                             return "Extra Damage"
  324.                         elseif oddball_trait == 3 then
  325.                             return "Damage Resistant"
  326.                         end
  327.                     end
  328.                    
  329.                     local function getnooddballtrait()
  330.                    
  331.                         if no_oddball_trait == 0 then
  332.                             return "None"
  333.                         elseif no_oddball_trait == 1 then
  334.                             return "Invisible"
  335.                         elseif no_oddball_trait == 2 then
  336.                             return "Extra Damage"
  337.                         elseif no_oddball_trait == 3 then
  338.                             return "Damage Resistant"
  339.                         end
  340.                     end
  341.                    
  342.                     gametypes[name] = {}
  343.                     gametypes[name].game = getgame()
  344.                     gametypes[name].team = getteamplay()
  345.                     gametypes[name].allonradar = getallonradar()
  346.                     gametypes[name].friendindicators = getfriendindicators()
  347.                     gametypes[name].infinitegrenades = getinfgrenades()
  348.                     gametypes[name].shields = getshields()
  349.                     gametypes[name].invisibleplayers = getinvisibleplayers()
  350.                     gametypes[name].startingequipment = getstarteqip()
  351.                     gametypes[name].friendsonradar = getfriendsonradar()
  352.                     gametypes[name].objectivesindicator = getobjectivesindicator()
  353.                     gametypes[name].oddmanout = getoddmanout()
  354.                     gametypes[name].respawngrowth = respawn_time_growth / 30
  355.                     gametypes[name].respawntime = respawn_time / 30
  356.                     gametypes[name].suicidepenalty = suicide_penalty / 30
  357.                     gametypes[name].lives = getlives()
  358.                     gametypes[name].maxhealth = getmaxhealth()
  359.                     gametypes[name].scorelimit = scorelimit
  360.                     gametypes[name].weaponset = getweaponset()
  361.                     gametypes[name].friendlyfire = getfriendlyfire()
  362.                     gametypes[name].tkpenalty = tk_penalty / 30
  363.                     gametypes[name].teambalance = getteambalance()
  364.                     gametypes[name].timelimit = timelimit / 1800
  365.                     if gametypes[name].game == "CTF" then
  366.                         gametypes[name].assault = getassault()
  367.                         gametypes[name].alternating = getalternating()
  368.                     elseif gametypes[name].game == "KotH" then
  369.                         gametypes[name].movinghill = getmovinghill()
  370.                     elseif gametypes[name].game == "Race" then
  371.                         gametypes[name].racetype = getracetype()
  372.                     elseif gametypes[name].game == "Oddball" then
  373.                         gametypes[name].oddballtype = getoddballtype()
  374.                         gametypes[name].randomstart = getballrandomstart()
  375.                         gametypes[name].oddballspeed = getoddballspeed()
  376.                         gametypes[name].oddballtrait = getoddballtrait()
  377.                         gametypes[name].nooddballtrait = getnooddballtrait()
  378.                         gametypes[name].oddballcount = oddball_count
  379.                     end
  380.                 end
  381.             end
  382.         end
  383.     end
  384. end
  385.  
  386. function readgame(chars, first, last, byte)
  387.  
  388.     first = first + 1
  389.     last = last + 1
  390.     local str = ""
  391.     for i = first, last do
  392.         if string.byte(chars[i]) ~= 0 then
  393.             str = str .. chars[i]
  394.         end
  395.     end
  396.    
  397.     if byte then
  398.         if str ~= "" then
  399.             return string.byte(str)
  400.         else
  401.             return 0
  402.         end
  403.     end
  404.    
  405.     return str
  406. end
  407.  
  408. function sv_gametypes(admin, search)
  409.  
  410.     local matches = {}
  411.    
  412.     for k,v in pairs(gametypes) do
  413.         if not search then
  414.             table.insert(matches, k)
  415.         else
  416.             if string.find(string.lower(k), string.lower(search)) then
  417.                 table.insert(matches, k)
  418.             end
  419.         end
  420.     end
  421.    
  422.     table.sort(matches)
  423.     console("Gametypes matching search \"" .. (search or "") .. "\":")
  424.     for k,v in ipairs(matches) do
  425.         console(v)
  426.     end
  427.    
  428.     return true
  429. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement