Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Arms Race
- -- Created by Wizard in 2012/2013.
- -- I found a cool gametype in Counter-strike: Global Offensive called Arms Race and thought
- -- it would make a cool gametype in Halo.
- --
- -- Objective is to get to the last weapon, and get a kill with it.
- --
- -- Number of kills required to next level
- -- Number must be an integer, 1 or greater
- kills_to_next_lvl = 2
- -- Penalty for committing suicide. If you suicide, you will either lose a whole level, or your last kill
- -- must be set to "level" or "kill"
- suicide_penalty = "kill"
- --Don't touch this stuff
- WeaponCycle = {}
- player_level = {}
- kills_with_weap = {}
- teamscore = {}
- playerIsMeleeing = {}
- function GetRequiredVersion()
- return 200
- end
- function OnScriptLoad(processId, game, persistent)
- getTagIds()
- registertimer(0, "cmdDelay")
- GetGameAddresses(game)
- writebyte(slayer_score_patch, 0xEB)
- writebyte(slayer_score_patch2, 0xEB)
- teamplay = readbyte(gametype_base + 0x34)
- teamscore[0] = 0
- teamscore[1] = 0
- if teamplay then
- setTeamScore(0, 0)
- setTeamScore(1, 0)
- end
- for i = 0,15 do
- local m_player = getplayer(i)
- if m_player then
- local name = getname(i)
- if name then
- player_level[name] = 1
- kills_with_weap[name] = 0
- setScore(i, 1)
- end
- end
- end
- starting_equipment = readbit(gametype_base + 0x38, 2) -- Generic = 0, Custom = 1
- if starting_equipment == 1 then
- starting_equipment = "Generic"
- else
- starting_equipment = "Custom"
- end
- end
- function GetGameAddresses(game)
- if game == "PC" then
- slayer_globals = 0x63A0E8
- gametype_base = 0x671340
- slayer_score_patch = 0x48F428
- slayer_score_patch2 = 0x48F23E
- else
- slayer_globals = 0x5BE108
- gametype_base = 0x5F5498
- slayer_score_patch = 0x469CF8
- slayer_score_patch2 = 0x4691CE
- end
- end
- function cmdDelay(id, count)
- --svcmd("cheat_infinite_ammo 1")
- return false
- end
- function getTagIds()
- WeaponCycle = {
- gettagid("weap", "weapons\\rocket launcher\\rocket launcher"),
- gettagid("weap", "weapons\\plasma_cannon\\plasma_cannon"),
- gettagid("weap", "weapons\\flamethrower\\flamethrower"),
- --gettagid("weap", "weapons\\gravity rifle\\gravity rifle"),
- gettagid("weap", "weapons\\pistol\\pistol"),
- gettagid("weap", "weapons\\shotgun\\shotgun"),
- gettagid("weap", "weapons\\sniper rifle\\sniper rifle"),
- gettagid("weap", "weapons\\assault rifle\\assault rifle"),
- gettagid("weap", "weapons\\plasma rifle\\plasma rifle"),
- gettagid("weap", "weapons\\needler\\mp_needler"),
- --gettagid("weap", "weapons\\gravity rifle\\gravity rifle"),
- gettagid("weap", "weapons\\plasma pistol\\plasma pistol")
- }
- rocketlauncher_tag_id = gettagid("weap", "weapons\\rocket launcher\\rocket launcher")
- fuelrod_tag_id = gettagid("weap", "weapons\\plasma_cannon\\plasma_cannon")
- flamethrower_tag_id = gettagid("weap", "weapons\\flamethrower\\flamethrower")
- gravitygun_tag_id = gettagid("weap", "weapons\\gravity rifle\\gravity rifle")
- pistol_tag_id = gettagid("weap", "weapons\\pistol\\pistol")
- shotgun_tag_id = gettagid("weap", "weapons\\shotgun\\shotgun")
- sniper_tag_id = gettagid("weap", "weapons\\sniper rifle\\sniper rifle")
- rifle_tag_id = gettagid("weap", "weapons\\assault rifle\\assault rifle")
- plasmarifle_tag_id = gettagid("weap", "weapons\\plasma rifle\\plasma rifle")
- needler_tag_id = gettagid("weap", "weapons\\needler\\mp_needler")
- plasmapistol_tag_id = gettagid("weap", "weapons\\plasma pistol\\plasma pistol")
- camouflage_tag_id = gettagid("eqip", "powerups\\active camouflage")
- healthpack_tag_id = gettagid("eqip", "powerups\\health pack")
- overshield_tag_id = gettagid("eqip", "powerups\\over shield")
- end
- function DelayGetIds(id, count)
- say("FAIL")
- getTagIds()
- return false
- end
- function OnScriptUnload()
- writebyte(slayer_score_patch, 0x74)
- writebyte(slayer_score_patch2, 0x75)
- end
- function OnNewGame(map)
- getTagIds()
- writebyte(slayer_score_patch, 0xEB)
- writebyte(slayer_score_patch2, 0xEB)
- end
- --[[
- function OnGameEnd(stage)
- end
- --]]
- --[[
- function OnServerChat(player, type, message)
- --return true
- end
- --]]
- --[[
- function OnServerCommandAttempt(player, command, password)
- --return true
- end
- --]]
- --[[
- function OnServerCommand(admin, command)
- --return true
- end
- --]]
- --[[
- function OnNameRequest(hash, name)
- --return true, name
- end
- --]]
- --[[
- function OnBanCheck(hash, ip)
- --return true
- end
- --]]
- function OnPlayerJoin(player)
- if player then
- local name = getname(player)
- if name then
- if not player_level[name] then
- player_level[name] = 1
- kills_with_weap[name] = 0
- setScore(player, 1)
- else
- setScore(player, player_level[name])
- end
- end
- end
- end
- --[[
- function OnPlayerLeave(player)
- end
- --]]
- function OnPlayerKill(killer, victim, mode)
- -- mode 0: Killed by server
- -- mode 1: Killed by fall damage
- -- mode 2: Killed by guardians
- -- mode 3: Killed by vehicle
- -- mode 4: Killed by killer
- -- mode 5: Betrayed by killer
- -- mode 6: Suicide
- if mode == 6 or mode == 2 then
- if victim then
- local m_player = getplayer(victim)
- if m_player then
- local name = getname(victim)
- if name then
- privatesay(victim, "You lost one level for suiciding!")
- if kills_with_weap[name] ~= 0 and suicide_penalty == "kill" then
- kills_with_weap[name] = kills_with_weap[name] - 1
- elseif player_level[name] ~= 1 then
- player_level[name] = player_level[name] - 1
- setScore(victim, player_level[name] - 1)
- if teamplay then
- local team = getteam(victim)
- if not teamscore[team] then teamscore[team] = 0 end
- --fuck signed addresses in phasor 2.0
- if teamscore[team] >= 1 then
- teamscore[team] = teamscore[team] - 1
- setTeamScore(team, teamscore[team])
- end
- end
- end
- local level = tostring(player_level[name])
- local weapon = tostring(getWeaponLevel(player_level[name]))
- local kills
- if kills_with_weap[name] then
- kills = " (" .. tostring(kills_with_weap[name]) .. "/" .. tostring(kills_to_next_lvl) .. ")"
- end
- sendconsoletext(victim, "Level " .. level .. ": " .. weapon .. kills .. " kills")
- end
- end
- end
- elseif mode == 4 then
- if killer then
- local m_player = getplayer(killer)
- if m_player then
- local name = getname(killer)
- if name then
- if not tonumber(player_level[name]) then player_level[name] = 1 end
- if not tonumber(kills_with_weap[name]) then kills_with_weap[name] = 0 end
- kills_with_weap[name] = kills_with_weap[name] + 1
- if kills_with_weap[name] == kills_to_next_lvl then
- player_level[name] = player_level[name] + 1
- setScore(killer, player_level[name])
- if teamplay then
- local team = getteam(killer)
- if not teamscore[team] then teamscore[team] = 0 end
- teamscore[team] = teamscore[team] + 1
- setTeamScore(team, teamscore[team])
- end
- kills_with_weap[name] = 0
- if player_level[name] == #WeaponCycle+1 then
- say(name .. " has won the game!")
- svcmd("sv_map_next")
- return
- else
- if player_level[name] == #WeaponCycle then
- say(name .. " is on the final weapon!")
- end
- end
- local m_objectId = getplayerobjectid(killer)
- if tonumber(m_objectId) and m_objectId ~= 0xFFFFFFFF then
- local m_object = getobject(m_objectId)
- if m_object then
- for i = 0,3 do
- local weapId = readdword(m_object + 0x2F8 + i*4)
- local m_weapon = getobject(weapId)
- if m_weapon then
- destroyobject(weapId)
- end
- end
- local x,y,z = getobjectcoords(m_objectId)
- local newweapId = createobject(WeaponCycle[player_level[name]], 0, 60, false, x, y, z+0.5)
- assignweapon(killer, newweapId)
- local m_weapon = getobject(newweapId)
- if m_weapon then
- writeword(m_weapon + 0x2B6, 600)
- end
- end
- end
- sendconsoletext(killer, "**LEVEL UP**")
- end
- local level = tostring(player_level[name])
- local weapon = tostring(getWeaponLevel(player_level[name]))
- local kills
- if kills_with_weap[name] then
- kills = " (" .. tostring(kills_with_weap[name]) .. "/" .. tostring(kills_to_next_lvl) .. ")"
- end
- sendconsoletext(killer, "Level " .. level .. ": " .. weapon .. kills .. " kills")
- end
- end
- end
- end
- end
- --[[
- function OnKillMultiplier(player, multiplier)
- -- Multipliers:
- -- 7: Double Kill
- -- 9: Triple Kill
- -- 10: Killtacular
- -- 11: Killing Spree
- -- 12: Running Riot
- -- 16: Double Kill w/ Score
- -- 17: Triple Kill w/ Score
- -- 14: Killtacular w/ Score
- -- 18: Killing Spree w/ Score
- -- 17: Running Riot w/ Score
- end
- --]]
- function OnPlayerSpawn(player)
- if starting_equipment == "Custom" then
- registertimer(0, "replaceWeaps", player)
- end
- local m_objectId = getplayerobjectid(player)
- if m_objectId and m_objectId ~= 0xFFFFFFFF then
- local m_object = getobject(m_objectId)
- if m_object then
- writebyte(m_object + 0x31E, 0)
- writebyte(m_object + 0x31F, 0)
- end
- end
- local m_player = getplayer(player)
- if m_player then
- local name = getname(player)
- if name then
- local level = tostring(player_level[name])
- local weapon = tostring(getWeaponLevel(player_level[name]))
- local kills
- if kills_with_weap[name] then
- kills = " (" .. tostring(kills_with_weap[name]) .. "/" .. tostring(kills_to_next_lvl) .. ")"
- end
- sendconsoletext(player, "Level " .. level .. ": " .. weapon .. kills .. " kills")
- end
- end
- end
- function getWeaponLevel(level)
- local mapId = WeaponCycle[level]
- if mapId == rocketlauncher_tag_id then
- level = "Rocket Launcher"
- elseif mapId == fuelrod_tag_id then
- level = "FuelRod"
- elseif mapId == flamethrower_tag_id then
- level = "Flamethrower"
- elseif mapId == pistol_tag_id then
- level = "Pistols"
- elseif mapId == shotgun_tag_id then
- level = "Shotgun"
- elseif mapId == sniper_tag_id then
- level = "Sniper Rifle"
- elseif mapId == rifle_tag_id then
- level = "Assault Rifle"
- elseif mapId == plasmarifle_tag_id then
- level = "Plasma Rifle"
- elseif mapId == needler_tag_id then
- level = "Needler"
- elseif mapId == plasmapistol_tag_id then
- level = "Plasma Pistol - FINAL WEAPON!"
- else
- level = "UNKNOWN WEAPON!"
- end
- return level
- end
- function replaceWeaps(id, count, player)
- if getplayer(player) then
- local name = getname(player)
- local m_objectId = getplayerobjectid(player)
- if m_objectId then
- local m_object = getobject(m_objectId)
- if m_object then
- for i = 0,3 do
- local weapID = readdword(m_object + 0x2F8 + i*4)
- local weap = getobject(weapID)
- if weap then
- destroyobject(weapID)
- end
- end
- if WeaponCycle[player_level[name]] then
- local x,y,z = getobjectcoords(m_objectId)
- local newweap = createobject(WeaponCycle[player_level[name]], 0, 60, false, x, y, z+0.5)
- assignweapon(player, newweap)
- --[[if math.floor(player_level[name]) == 4 then
- writebyte(m_object + 0x31E, 7)
- writebyte(m_object + 0x31F, 0)
- elseif math.floor(player_level[name]) == 11 then
- writebyte(m_object + 0x31E, 0)
- writebyte(m_object + 0x31F, 7)
- else--]]
- writebyte(m_object + 0x31E, 0)
- writebyte(m_object + 0x31F, 0)
- --end
- local m_weapon = getobject(newweap)
- if m_weapon then
- writeword(m_weapon + 0x2B6, 600)
- end
- end
- end
- end
- end
- return false
- end
- function setScore(player, score)
- writedword(slayer_globals + 0x40 + player*4, score)
- end
- function setTeamScore(team, score)
- writedword(slayer_globals + team*4, score)
- end
- function writewordsigned(address, value)
- if value and value > 0x7FFF then
- local max = 0xFFFF
- local difference = max - value
- value = -1 - difference
- end
- writeword(address, value)
- end
- function writedwordsigned(address, value)
- if value < -1 then
- value = 0xFFFFFFFF + value
- elseif value == -1 then
- value = 0xFFFFFFFF
- end
- writedword(address, value)
- end
- --[[
- function OnPlayerSpawnEnd(player)
- end
- --]]
- function OnWeaponAssignment(player, objId, slot, weapId)
- if player then
- local m_player = getplayer(player)
- if m_player then
- local name = getname(player)
- if name then
- if slot == 0 then
- return WeaponCycle[player_level[name]]
- end
- end
- end
- end
- return -1
- end
- --[[
- function OnWeaponReload(player, weapId)
- --return true
- end
- --]]
- --[[
- function OnObjectCreationAttempt(mapId, parentId, player)
- return nil
- end
- --]]
- --[[
- function OnObjectCreation(m_objId)
- local m_object = getobject(m_objId)
- if m_object then
- end
- end
- --]]
- function OnObjectInteraction(player, objId, mapId)
- if player then
- local name = getname(player)
- if name then
- if WeaponCycle[player_level[name]] == mapId or mapId == overshield_tag_id or mapId == healthpack_tag_id or mapId == camouflage_tag_id then
- return true
- else
- return false
- end
- end
- end
- end
- --[[
- function OnTeamDecision(team)
- --return team
- end
- --]]
- --[[
- function OnTeamChange(player, old_team, new_team, voluntary)
- --return true
- end
- --]]
- function OnDamageLookup(receiving_obj, causing_obj, mapId, tagdata)
- if tonumber(receiving_obj) and tonumber(causing_obj) then
- local causer = objectidtoplayer(causing_obj)
- local receiver = objectidtoplayer(receiving_obj)
- if causer and receiver and getplayer(causer) and getplayer(receiver) then
- --say("Causer: " .. tostring(getname(causer)))
- --say("Receiver: " .. tostring(getname(receiver)))
- if playerIsMeleeing[causer] then
- --say("PLAYER APPLYING MELEE DAMAGE")
- odl_multiplier(0.65)
- end
- end
- end
- --return true
- end
- function OnDamageApplication(receiver, causer, mapId, location, backtap)
- end
- function OnVehicleEntry(player, vehiId, seat, mapId, voluntary)
- return false
- end
- --[[
- function OnVehicleEject(player, voluntary)
- --return true
- end
- --]]
- function OnClientUpdate(player)
- local m_object = getplayerobject(player)
- if m_object then
- local melee_key = readbyte(m_object, 0x2A4)
- if melee_key == 7 and not playerIsMeleeing[player] then
- playerIsMeleeing[player] = true
- --say("MELEEING")
- elseif melee_key ~= 7 and playerIsMeleeing[player] then
- --say("NOT MELEEING")
- playerIsMeleeing[player] = nil
- end
- end
- end
- function getplayerobject(player)
- local m_player = getplayer(player)
- if m_player then
- local m_objectId = readdword(m_player + 0x34)
- if m_objectId and m_objectId ~= 0xFFFFFFFF then
- local m_object = getobject(m_objectId)
- if m_object then
- return m_object
- end
- end
- end
- end
- function getplayerobjectid(player)
- local m_player = getplayer(player)
- if m_player then
- local m_objectId = readdword(m_player + 0x34)
- if m_objectId and m_objectId ~= 0xFFFFFFFF then
- return m_objectId
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement