Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Gametypes
- require "lfs"
- --[[ Gametypes Table ]]--
- gametypes = table.load("gametypes")
- --[[ Gametypes Table Structure ]]--
- --[[
- gametypes
- gametypes[name]
- gametypes[name].game
- gametypes[name].team
- gametypes[name].weapons
- gametypes[name].lives
- gametypes[name].shields
- etc...
- --]]
- function LoadGametypes()
- local dir = getprofilepath() .. "\\savegames\\"
- local directories = {}
- local files = {}
- for f in lfs.dir(dir) do
- if f ~= "." and f ~= ".." then
- if lfs.attributes(dir .. f, "mode") == "file" then
- table.insert(files, dir .. f)
- elseif lfs.attributes(dir .. f, "mode") == "directory" then
- table.insert(directories, dir .. f)
- end
- end
- end
- local defdir = getprofilepath() .. "\\saved\\playlists\\default_playlist\\"
- for f in lfs.dir(defdir) do
- if f ~= "." and f ~= ".." then
- if lfs.attributes(defdir .. f, "mode") == "file" then
- table.insert(files, defdir .. f)
- elseif lfs.attributes(defdir .. f, "mode") == "directory" then
- table.insert(directories, defdir .. f)
- end
- end
- end
- for k,v in ipairs(directories) do
- local dirs = string.split(v, "\\")
- local gtname = dirs[#dirs]
- if not gametypes[gtname] then
- for f in lfs.dir(v) do
- if f == "blam.lst" then
- local blam = io.open(v .. "\\blam.lst", "r")
- local str = blam:read("*all")
- local chars = string.split(str, "")
- local name = readgame(chars, 0x0, 0x2F)
- local gametype = tonumber(readgame(chars, 0x30, 0x33, true)) -- 1 = CTF | 2 = Slayer | 3 = Oddball | 4 = KOTH | 5 = Race
- local teamplay = tonumber(readgame(chars, 0x34, 0x37, true)) -- 0 = off | 1 = on
- local parameters = formatbinary(readgame(chars, 0x38, 0x3B, true), 8)
- -- 0 = off | 1 = on
- local players_on_radar = tonumber(string.sub(parameters, 8, 8))
- local friend_indicators = tonumber(string.sub(parameters, 7, 7))
- local infinite_grenades = tonumber(string.sub(parameters, 6, 6))
- local shields = 1 - tonumber(string.sub(parameters, 5, 5))
- local invisible_players = tonumber(string.sub(parameters, 4, 4))
- local starting_equipment = tonumber(string.sub(parameters, 3, 3)) -- 0 = Generic | 1 = Custom
- local only_friends_on_radar = tonumber(string.sub(parameters, 2, 2))
- local objectives_indicator = tonumber(readgame(chars, 0x3C, 0x3F, true)) -- 0 = Motion Tracker | 1 = Navpoints | 2 = None
- local odd_man_out = tonumber(readgame(chars, 0x40, 0x43, true)) -- 0 = off | 1 = on
- local respawn_time_growth = tonumber(readgame(chars, 0x44, 0x47, true)) -- 0 = off | 150 = 5 secs | 300 = 10 secs | 450 = 15 secs
- local respawn_time = tonumber(readgame(chars, 0x48, 0x4B, true)) -- 0 = Instant | 150 = 5 secs | 300 = 10 secs | 450 = 15 secs
- local suicide_penalty = tonumber(readgame(chars, 0x4C, 0x4F, true)) -- 0 = None | 150 = 5 secs | 300 = 10 secs | 450 = 15 secs
- local lives = tonumber(readgame(chars, 0x50, 0x53, true)) -- 0 = Unlimited lives | 1, 3, 5 = 1, 3, 5 lives
- local max_health = tonumber(readgame(chars, 0x57, 0x57, true)) -- 64 = 400% | 63 = 100% (Find others)
- local scorelimit = tonumber(readgame(chars, 0x58, 0x5B, true)) -- check how this is stored for timed gametypes
- 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
- -- Insert Vehicle Stuff Here --
- local friendly_fire = tonumber(readgame(chars, 0x6C, 0x6F, true)) -- 0 = off | 1 = on
- local tk_penalty = tonumber(readgame(chars, 0x70, 0x73, true)) -- 0 = off | 150 = 5 secs | 300 = 10 secs | 450 = 15 secs
- local team_balance = tonumber(readgame(chars, 0x74, 0x77, true)) -- 0 = off | 1 = on
- 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
- local assault = tonumber(readgame(chars, 0x7C, 0x7C, true)) -- 0 = CTF | 1 = Assault
- 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)
- local moving_hill = tonumber(readgame(chars, 0x7C, 0x7F, true)) -- 0 = off | 1 = on
- local race_type = tonumber(readgame(chars, 0x7C, 0x7F, true)) -- 0 = Normal | 1 = Any Order | 2 = Rally
- local oddball_random_start = tonumber(readgame(chars, 0x7C, 0x7F, true)) -- 0 = off | 1 = on
- local oddball_speed = tonumber(readgame(chars, 0x80, 0x82, true)) -- 0 = Slow | 1 = Normal | 2 = Fast
- local oddball_trait = tonumber(readgame(chars, 0x83, 0x83, true)) -- 0 = None | 1 = Invisible | 2 = Extra Damage | 3 = Damage Resistant
- local no_oddball_trait = tonumber(readgame(chars, 0x88, 0x8B, true)) -- 0 = None | 1 = Invisible | 2 = Extra Damage | 3 = Damage Resistant
- local oddball_type = tonumber(readgame(chars, 0x8C, 0x8C, true)) -- 0 = Normal | 1 = Reverse Tag | 2 = Juggernaut
- local oddball_count = tonumber(readgame(chars, 0x90, 0x90, true)) -- From 0 - 16
- blam:close()
- local function getgame()
- if gametype == 1 then
- return "CTF"
- elseif gametype == 2 then
- return "Slayer"
- elseif gametype == 3 then
- return "Oddball"
- elseif gametype == 4 then
- return "KotH"
- elseif gametype == 5 then
- return "Race"
- end
- end
- local function getteamplay()
- if teamplay == 1 then
- return true
- end
- end
- local function getallonradar()
- if players_on_radar == 1 then
- return true
- end
- end
- local function getfriendindicators()
- if friend_indicators == 1 then
- return true
- end
- end
- local function getinfgrenades()
- if infinite_grenades == 1 then
- return true
- end
- end
- local function getshields()
- if shields == 1 then
- return true
- end
- end
- local function getinvisibleplayers()
- if invisible_players == 1 then
- return true
- end
- end
- local function getstarteqip()
- if starting_equipment == 1 then
- return "Generic"
- else
- return "Custom"
- end
- end
- local function getfriendsonradar()
- if only_friends_on_radar == 1 then
- return true
- end
- end
- local function getobjectivesindicator()
- if objectives_indicator == 0 then
- return "Motion Tracker"
- elseif objectives_indicator == 1 then
- return "Navpoints"
- elseif objectives_indicator == 2 then
- return "None"
- end
- end
- local function getoddmanout()
- if odd_man_out == 1 then
- return true
- end
- end
- local function getlives()
- if lives == 0 then
- return "Unlimited"
- else
- return lives
- end
- end
- local function getmaxhealth()
- if max_health == 63 then
- return 100
- elseif max_health == 64 then
- return 400
- end
- end
- local function getweaponset()
- if weapon_set == 0 then
- return "Normal"
- elseif weapon_set == 1 then
- return "Pistols"
- elseif weapon_set == 2 then
- return "Rifles"
- elseif weapon_set == 3 then
- return "Plasmas"
- elseif weapon_set == 4 then
- return "Snipers"
- elseif weapon_set == 5 then
- return "No Sniping"
- elseif weapon_set == 6 then
- return "Rockets"
- elseif weapon_set == 7 then
- return "Shotguns"
- elseif weapon_set == 8 then
- return "Short-Range"
- elseif weapon_set == 9 then
- return "Human"
- elseif weapon_set == 10 then
- return "Covenant"
- elseif weapon_set == 11 then
- return "Classic"
- elseif weapon_set == 12 then
- return "Heavy"
- end
- end
- local function getfriendlyfire()
- if friendly_fire == 1 then
- return true
- end
- end
- local function getteambalance()
- if team_balance == 1 then
- return true
- end
- end
- local function getassault()
- if assault == 1 then
- return true
- end
- end
- local function getalternating()
- if alternating ~= 0 then
- return true
- end
- end
- local function getmovinghill()
- if moving_hill == 1 then
- return true
- end
- end
- local function getracetype()
- if race_type == 0 then
- return "Normal"
- elseif race_type == 1 then
- return "Any Order"
- elseif race_type == 2 then
- return "Rally"
- end
- end
- local function getoddballtype()
- if oddball_type == 0 then
- return "Normal"
- elseif oddball_type == 1 then
- return "Reverse Tag"
- elseif oddball_type == 2 then
- return "Juggernaut"
- end
- end
- local function getballrandomstart()
- if oddball_random_start == 1 then
- return true
- end
- end
- local function getoddballspeed()
- if oddball_speed == 0 then
- return "Slow"
- elseif oddball_speed == 1 then
- return "Normal"
- elseif oddball_speed == 2 then
- return "Fast"
- end
- end
- local function getoddballtrait()
- if oddball_trait == 0 then
- return "None"
- elseif oddball_trait == 1 then
- return "Invisible"
- elseif oddball_trait == 2 then
- return "Extra Damage"
- elseif oddball_trait == 3 then
- return "Damage Resistant"
- end
- end
- local function getnooddballtrait()
- if no_oddball_trait == 0 then
- return "None"
- elseif no_oddball_trait == 1 then
- return "Invisible"
- elseif no_oddball_trait == 2 then
- return "Extra Damage"
- elseif no_oddball_trait == 3 then
- return "Damage Resistant"
- end
- end
- gametypes[name] = {}
- gametypes[name].game = getgame()
- gametypes[name].team = getteamplay()
- gametypes[name].allonradar = getallonradar()
- gametypes[name].friendindicators = getfriendindicators()
- gametypes[name].infinitegrenades = getinfgrenades()
- gametypes[name].shields = getshields()
- gametypes[name].invisibleplayers = getinvisibleplayers()
- gametypes[name].startingequipment = getstarteqip()
- gametypes[name].friendsonradar = getfriendsonradar()
- gametypes[name].objectivesindicator = getobjectivesindicator()
- gametypes[name].oddmanout = getoddmanout()
- gametypes[name].respawngrowth = respawn_time_growth / 30
- gametypes[name].respawntime = respawn_time / 30
- gametypes[name].suicidepenalty = suicide_penalty / 30
- gametypes[name].lives = getlives()
- gametypes[name].maxhealth = getmaxhealth()
- gametypes[name].scorelimit = scorelimit
- gametypes[name].weaponset = getweaponset()
- gametypes[name].friendlyfire = getfriendlyfire()
- gametypes[name].tkpenalty = tk_penalty / 30
- gametypes[name].teambalance = getteambalance()
- gametypes[name].timelimit = timelimit / 1800
- if gametypes[name].game == "CTF" then
- gametypes[name].assault = getassault()
- gametypes[name].alternating = getalternating()
- elseif gametypes[name].game == "KotH" then
- gametypes[name].movinghill = getmovinghill()
- elseif gametypes[name].game == "Race" then
- gametypes[name].racetype = getracetype()
- elseif gametypes[name].game == "Oddball" then
- gametypes[name].oddballtype = getoddballtype()
- gametypes[name].randomstart = getballrandomstart()
- gametypes[name].oddballspeed = getoddballspeed()
- gametypes[name].oddballtrait = getoddballtrait()
- gametypes[name].nooddballtrait = getnooddballtrait()
- gametypes[name].oddballcount = oddball_count
- end
- end
- end
- end
- end
- end
- function readgame(chars, first, last, byte)
- first = first + 1
- last = last + 1
- local str = ""
- for i = first, last do
- if string.byte(chars[i]) ~= 0 then
- str = str .. chars[i]
- end
- end
- if byte then
- if str ~= "" then
- return string.byte(str)
- else
- return 0
- end
- end
- return str
- end
- function sv_gametypes(admin, search)
- local matches = {}
- for k,v in pairs(gametypes) do
- if not search then
- table.insert(matches, k)
- else
- if string.find(string.lower(k), string.lower(search)) then
- table.insert(matches, k)
- end
- end
- end
- table.sort(matches)
- console("Gametypes matching search \"" .. (search or "") .. "\":")
- for k,v in ipairs(matches) do
- console(v)
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement