Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ ### Roaming Slayer Targets v1 ###]]--
- --[[ ### by H® Shaft for Phasor ###]]--
- -- puts a target over the head of each player in the game, which blinks/rotates between players
- -- Gametype notes:
- -- The slayer gametype MUST have "kill in order" set, AND objectives indicators set to "nav points"
- -- This script is ONLY compatible with Team Slayer and Free for All Slayer for both Halo PC and Halo CE.
- -- Premade gametypes for pc and ce games: FFA 15 kills, Team 25 kills - Link:
- -- http://www.mediafire.com/download/pkfvby8dtzez552/roaming_target_gametypes.zip
- -- don't edit --
- roaming_targets = {}
- team_change = {}
- playerscore = {}
- teamscore = {}
- map_reset = false
- team_play = false
- game_started = false
- showtargets = nil
- cur_players = 0
- timerCount = 0
- score_limit = 100
- -- edit or add map name edit true/false
- -- Roaming Targets Map: Boolean: true = enable, false = disable
- roaming_targets. beavercreek = false
- roaming_targets. bloodgulch = true
- roaming_targets. boardingaction = false
- roaming_targets. carousel = false
- roaming_targets. chillout = false
- roaming_targets. damnation = false
- roaming_targets. dangercanyon = true
- roaming_targets. deathisland = true
- roaming_targets. gephyrophobia = true
- roaming_targets. hangemhigh = false
- roaming_targets. icefields = true
- roaming_targets. infinity = true
- roaming_targets. longest = false
- roaming_targets. prisoner = false
- roaming_targets. putput = false
- roaming_targets. ratrace = true
- roaming_targets. sidewinder = false
- roaming_targets. timberland = true
- roaming_targets. wizard = false
- function GetRequiredVersion()
- return 200
- end
- function OnScriptLoad(process, game, persistent)
- GAME = game
- GetGameAddresses(game)
- Persistent = persistent
- ScriptLoad()
- end
- function ApplyPatches()
- writebyte(slayer_score_patch, 0xEB)
- writebyte(slayer_score_patch2, 0xEB)
- end
- function OnScriptUnload()
- writebyte(slayer_score_patch, 0x74)
- writebyte(slayer_score_patch2, 0x75)
- end
- function OnNewGame(map)
- ScriptLoad()
- team_play = getteamplay()
- gametype = readbyte(gametype_base + 0x30)
- game_started = false
- if not new_game_timer then
- new_game_timer = registertimer(0, "NewGameTimer")
- end
- end
- function NewGameTimer(id, count)
- if map_reset == true then
- map_reset = false
- end
- game_started = true
- team_play = getteamplay()
- score_limit = readbyte(gametype_base + 0x58)
- if team_play then
- teamscore[0] = 0
- teamscore[1] = 0
- end
- for i = 0,15 do
- if getplayer(i) then
- playerscore[i] = 0
- team_change[i] = false
- cur_players = cur_players + 1
- stats_base = (stats_globals + i*0x30)
- end
- end
- if not updatescores and game_started then
- updatescores = registertimer(100, "Update_Scores")
- end
- new_game_timer = nil
- return false
- end
- function OnPlayerJoin(player)
- if getplayer(player) then
- cur_players = cur_players + 1
- team_change[player] = false
- playerscore[player] = 0
- if gametype == 2 then
- if map_name then roaming_targets[map_name] = roaming_targets[map_name] or false end
- if roaming_targets[map_name] and game_started and cur_players > 0 and not showtargets then
- score_limit = readbyte(gametype_base + 0x58)
- showtargets = registertimer(250, "Show_Targets")
- end
- end
- end
- end
- function OnPlayerLeave(player)
- if getplayer(player) then
- cur_players = cur_players - 1
- team_change[player] = {}
- playerscore[player] = 0
- if cur_players < 1 and showtargets then
- showtargets = nil
- end
- end
- end
- function ScriptLoad()
- if Persistent then
- cur_players = 0
- timerCount = 0
- team_change = {}
- playerscore = {}
- teamscore = {}
- game_started = false
- team_play = false
- if not new_game_timer then
- new_game_timer = registertimer(0, "NewGameTimer")
- end
- end
- GetGameAddresses(game)
- ApplyPatches()
- showtargets = nil
- game_started = false
- team_play = false
- team_play = getteamplay()
- gametype = readbyte(gametype_base + 0x30)
- cur_players = readword(network_base, 0x1A0)
- if gametype == 2 then
- if map_name then roaming_targets[map_name] = roaming_targets[map_name] or false end
- if roaming_targets[map_name] then
- score_limit = readbyte(gametype_base + 0x58)
- showtargets = registertimer(250, "Show_Targets")
- end
- end
- for i = 0,15 do
- if getplayer(i) then
- playerscore[i] = 0
- team_change[i] = false
- cur_players = cur_players + 1
- stats_base = (stats_globals + i*0x30)
- end
- end
- if not new_game_timer then
- new_game_timer = registertimer(0, "NewGameTimer")
- end
- end
- function OnServerCommand(player, command)
- local allow = nil
- local cmd = tokenizecmdstring(command)
- local tokencount = #cmd
- if tokencount > 0 then
- if cmd[1] == "sv_map_reset" then
- map_reset = true
- showtargets = nil
- if team_play then
- teamscore[0] = 0
- teamscore[1] = 0
- for i=0,15 do
- if getplayer(i) then
- playerscore[i] = 0
- end
- end
- else
- for i=0,15 do
- if getplayer(i) then
- playerscore[i] = 0
- end
- end
- end
- ScriptLoad()
- for i=0,15 do
- if getplayer(i) then
- kill(i)
- end
- end
- allow = true
- elseif cmd[1] == "sv_script_reload" then
- map_reset = true
- showtargets = nil
- writedword(gametime_base + 0x10, 0)
- map_reset = true
- showtargets = nil
- if team_play then
- teamscore[0] = 0
- teamscore[1] = 0
- Write_Team_Score(0, teamscore[0])
- Write_Team_Score(1, teamscore[1])
- for i=0,15 do
- if getplayer(i) then
- local m_player = getplayer(i)
- playerscore[i] = 0
- Write_Player_Score(i, playerscore[i])
- stats_base = (stats_globals + i*0x30)
- writeword(stats_base + 0x8, 0) -- kills
- writeword(stats_base + 0x10, 0) -- assists
- writeword(stats_base + 0x1A, 0) -- deaths
- writeword(getplayer(i) + 0x9C, 0) -- kills
- writeword(getplayer(i) + 0xA4, 0) -- assists
- writeword(getplayer(i) + 0xAE, 0) -- deaths
- writeword(m_player + 0x9C, 0) -- kills
- writeword(m_player + 0xA4, 0) -- assists
- writeword(m_player + 0xAE, 0) -- deaths
- end
- end
- else
- for i=0,15 do
- if getplayer(i) then
- local m_player = getplayer(i)
- playerscore[i] = 0
- Write_Player_Score(i, playerscore[i])
- stats_base = (stats_globals + i*0x30)
- writeword(stats_base + 0x8, 0) -- kills
- writeword(stats_base + 0x10, 0) -- assists
- writeword(stats_base + 0x1A, 0) -- deaths
- writeword(getplayer(i) + 0x9C, 0) -- kills
- writeword(getplayer(i) + 0xA4, 0) -- assists
- writeword(getplayer(i) + 0xAE, 0) -- deaths
- writeword(m_player + 0x9C, 0) -- kills
- writeword(m_player + 0xA4, 0) -- assists
- writeword(m_player + 0xAE, 0) -- deaths
- end
- end
- end
- ScriptLoad()
- --privatesay(player, "**RELOAD** The game has been reset and scripts reloaded. ")
- for i=0,15 do
- if getplayer(i) then
- kill(i)
- playerscore[i] = 0
- --privatesay(i, "The game has been reset. ")
- end
- end
- svcmd("sv_map_reset")
- allow = true
- end
- end
- return allow
- end
- function OnPlayerKill(killer, victim, mode)
- if game_started then
- if mode == 1 then -- player was killed by falling or team-change
- if getplayer(victim) then
- local vname = getname(victim)
- if not team_change[victim] and not map_reset then
- say(vname .. " fell and died.")
- return false
- elseif team_change[victim] and not map_reset then
- team_change[victim] = false
- say(vname .. " changed teams.")
- return false
- end
- end
- elseif mode == 4 then -- player was killed by another player
- if getplayer(killer) then
- local kteam = getteam(killer)
- playerscore[killer] = playerscore[killer] + 1
- if team_play then kteam = getteam(killer) teamscore[kteam] = teamscore[kteam] + 1 end
- end
- elseif mode == 5 then -- player was killed/betrayed by teammate
- if getplayer(killer) then
- local kteam = getteam(killer)
- -- prevents negative score sabotage, but deducts 1 point per betray if score > 0
- if (playerscore[killer] - 1) >= 0 then playerscore[killer] = playerscore[killer] - 1 end
- if team_play then if (teamscore[kteam] - 1) >= 0 then teamscore[kteam] = teamscore[kteam] - 1 end end
- end
- elseif mode == 6 then --suicides - killer is victim/self
- if getplayer(victim) then
- local vteam = getteam(victim)
- -- prevents negative score sabotage, but deducts 1 point per suicide if score > 0
- if (playerscore[victim] - 1) >= 0 then playerscore[victim] = playerscore[victim] - 1 end
- if team_play then if (teamscore[vteam] - 1) >= 0 then teamscore[vteam] = teamscore[vteam] - 1 end end
- end
- end
- end
- end
- function OnClientUpdate(player)
- if getplayer(player) then
- if not team_play then
- local score = playerscore[player]
- if score ~= nil then
- -- monitors and initiates FFA game win announcement
- if score >= score_limit and game_started then
- game_started = false
- announcewin = registertimer(0, "AnnounceWin", player)
- end
- end
- elseif team_play then
- local team = getteam(player)
- local score = teamscore[team]
- -- monitors and initiates Team game win announcement
- if score >= score_limit and game_started then
- game_started = false
- announcewin = registertimer(0, "AnnounceWin", player)
- end
- end
- end
- end
- function AnnounceWin(id, count, player)
- -- announces game winner
- if player and game_started == false then
- local name = getname(player)
- svcmd("sv_map_next")
- if not team_play then
- say(name .. " WINS THE GAME! ")
- else
- local team = getteam(player)
- if team == 0 then team = "RED TEAM" elseif team == 1 then team = "BLUE TEAM" end
- say(team .. " WINS THE GAME! ")
- end
- end
- return false
- end
- function Update_Scores(id, count)
- -- continuous score updating
- if not team_play then
- for i = 0,15 do
- if getplayer(i) then
- local team = getteam(i) -- in FFA, each player is a team
- if playerscore[i] == nil or playerscore[i] < 0 then playerscore[i] = 0 end
- Write_Player_Score(i, playerscore[i])
- end
- end
- else
- for i = 0,15 do
- if getplayer(i) then
- if playerscore[i] == nil or playerscore[i] < 0 then playerscore[i] = 0 end
- Write_Player_Score(i, playerscore[i])
- end
- end
- if teamscore[0] == nil or teamscore[0] < 0 then teamscore[0] = 0 end
- if teamscore[1] == nil or teamscore[1] < 0 then teamscore[1] = 0 end
- Write_Team_Score(0, teamscore[0])
- Write_Team_Score(1, teamscore[1])
- end
- return true
- end
- function Write_Player_Score(player, score)
- -- writes the players score
- if gametype == 2 then
- if player then
- writedword(slayer_globals + 0x40 + player*4, score)
- end
- end
- end
- function Write_Team_Score(team, score)
- -- writes the team score
- if gametype == 2 then
- writedword(slayer_globals + team*4, score)
- end
- end
- function GetGameAddresses(game)
- if game == "PC" or GAME == "PC" then
- map_name = readstring(0x698F21)
- gametype_base = 0x671340
- network_base = 0x745BA8
- gametime_base = 0x671420
- slayer_globals = 0x63A0E8
- slayer_score_patch = 0x48F428
- slayer_score_patch2 = 0x48F23E
- stats_globals = 0x639898
- else
- map_name = readstring(0x61D151)
- gametype_base = 0x5F5498
- network_base = 0x6C7988
- gametime_base = 0x5F55BC
- slayer_globals = 0x5BE108
- slayer_score_patch = 0x469CF8
- slayer_score_patch2 = 0x4691CE
- stats_globals = 0x5BD8B8
- end
- end
- function getteamplay()
- if readbyte(gametype_base + 0x34) == 1 then
- return true
- else
- return false
- end
- end
- function Show_Targets(id, count)
- Roaming_Targets()
- return true
- end
- function Roaming_Targets()
- local response = nil
- if game_started and cur_players > 0 and gametype == 2 then
- if team_play then
- local target = SelectRoamingPlayer(player)
- if target then
- local team = getteam(target)
- for i = 0,15 do
- if getplayer(i) and getplayer(i) ~= getplayer(target) and getteam(i) ~= team then
- writeword(getplayer(i) + 0x88, target)
- end
- end
- response = true
- else
- response = false
- end
- else
- local target = SelectRoamingPlayer(player)
- if target then
- for i = 0,15 do
- if getplayer(i) and getplayer(i) ~= getplayer(target) then
- writeword(getplayer(i) + 0x88, target)
- end
- end
- response = true
- else
- response = false
- end
- end
- end
- return response
- end
- -- inspired by a different original from Aelite while working on targets for flying hogs, thanks!
- function SelectRoamingPlayer(player)
- local target = {}
- for i=0,15 do
- if getplayer(i) then
- table.insert(target, i)
- end
- end
- if #target >= 1 then
- if (timerCount > #target) then
- timerCount = 0
- else
- timerCount = timerCount + 1
- end
- return target[timerCount]
- end
- end
- function OnTeamChange(player, old_team, new_team, relevant)
- -- prevent unbalancing teams by team change
- local response = nil
- if getplayer(player) then
- local newteam = "New Team"
- local oldteam = "Old Team"
- if not team_play then response = false return response end
- if new_team == 0 then
- oldteam = "Blue Team"
- newteam = "Red Team"
- elseif new_team == 1 then
- oldteam = "Red Team"
- newteam = "Blue Team"
- end
- if relevant == true or relevant == 1 then
- if getteamsize(old_team) == getteamsize(new_team) then
- privatesay(player, "You cannot change teams.")
- response = false
- elseif getteamsize(old_team) + 1 == getteamsize(new_team) then
- privatesay(player, "You cannot change teams.")
- response = false
- elseif getteamsize(old_team) == getteamsize(new_team) + 1 then
- privatesay(player, "You cannot change teams.")
- response = false
- elseif getteamsize(old_team) > getteamsize(new_team) then
- team_change[player] = true
- -- transfer player score to new team score, and deduct new player score from old team score
- if team_play then
- teamscore[new_team] = teamscore[new_team] + playerscore[player]
- teamscore[old_team] = teamscore[old_team] - playerscore[player]
- end
- say(getname(player) .. " switched to the " .. newteam)
- response = true
- elseif getteamsize(old_team) < getteamsize(new_team) then
- team_change[player] = true
- -- transfer player score to new team score, and deduct new player score from old team score
- if team_play then
- teamscore[new_team] = teamscore[new_team] + playerscore[player]
- teamscore[old_team] = teamscore[old_team] - playerscore[player]
- end
- say(getname(player) .. " switched to the " .. newteam)
- response = true
- end
- elseif relevant == false or relevant == 0 then
- team_change[player] = true
- -- transfer player score to new team score, and deduct new player score from old team score
- if team_play then
- teamscore[new_team] = teamscore[new_team] + playerscore[player]
- teamscore[old_team] = teamscore[old_team] - playerscore[player]
- end
- say(getname(player) .. " was team-switched by the server to the " .. newteam .. ".")
- response = true
- end
- end
- return response
- end
- function OnGameEnd(stage)
- if stage == 1 then
- game_started = false
- if announcewin then
- announcewin = nil
- end
- if showtargets then
- showtargets = nil
- end
- if updatescores then
- updatescores = nil
- end
- if new_game_timer then
- new_game_timer = nil
- end
- end
- end
- -- Created by H® Shaft.
- -- Thanks to Oxide, AelitePrime, Nugget & Wizard.
- -- Visit http://halorace.org/forum/index.php?topic=514.0 or
- -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement