Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Roaming FFA Slayer Targets v1 for SAPP
- -- by H® Shaft
- -- *** Roaming FFA Slayer Targets is designed for 3 or more players for Free-For-All SLAYER game-types ONLY ***
- -- Puts a target over the head of other players in the game, which blinks/roams between all living players.
- -- Targets reduce the ability to hide or camp during slayer on large or multilevel maps.
- -- If you kill another player, even if they DON'T have a target - you STILL get a point.
- -- Normal death messages are blocked, and show the killers score as normal, but to shown to ALL players:
- -- "sehé°° was killed by H® Shaft (12)" << "12" shows that H® Shaft has 12 kills
- -- Enable or disable targets per map, and add your own map (see line 267) in LoadDefaults() near the bottom
- -- Gametype notes:
- -- The slayer gametype MUST have "kill in order" set, AND objective indicators set to "nav points"
- -- This script is ONLY compatible with Free for All Slayer gametypes for both Halo PC/CE.
- -- *** if loaded during a non-slayer map, it will skip the map and notify you by console and record it in the sapp log ***
- -- *** if script is reloaded during game play, it resets all player scores, and re-starts rotating targets if 2 or more players ***
- -- sapp api version
- api_version = "1.9.0.0"
- -- don't edit --
- team_play = false
- game_started = false
- cur_players = 0
- timerCount = 0
- function OnScriptLoad()
- register_callback(cb['EVENT_GAME_START'], "OnNewGame")
- register_callback(cb['EVENT_JOIN'], "OnPlayerJoin")
- register_callback(cb['EVENT_LEAVE'], "OnPlayerLeave")
- register_callback(cb['EVENT_DIE'], "OnPlayerDie")
- register_callback(cb['EVENT_COMMAND'], "OnServerCommand")
- register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
- disable_killmsg_addr = sig_scan("8B42348A8C28D500000084C9") + 3
- original_code_1 = read_dword(disable_killmsg_addr)
- safe_write(true)
- write_dword(disable_killmsg_addr, 0x03EB01B1)
- safe_write(false)
- map_name = get_var(0,"$map")
- LoadDefaults()
- LoadScript()
- if halo_type == "PC" then
- gametime_base = 0x671420
- elseif halo_type == "CE" then
- gametime_base = 0x5F55BC
- end
- end
- function OnScriptUnload()
- safe_write(true)
- write_dword(disable_killmsg_addr, original_code_1)
- safe_write(false)
- enable_targets = {}
- end
- function OnNewGame()
- game_started = true
- map_name = get_var(0,"$map")
- gametype = get_var(0, "$gt")
- team_play = getteamplay()
- LoadDefaults()
- LoadScript()
- -- check for compatibility
- if (gametype ~= "slayer") or (team_play == true) then
- local mode = get_var(0,"$mode")
- local str1 = string.format("**Roaming FFA Targets script isn't compatible with %s gametype, ONLY FFA SLAYER game types. Skipping map.", tostring(mode))
- execute_command("log_note \""..str1.."\"")
- cprint(str1)
- execute_command("sv_map_next")
- end
- end
- function LoadScript()
- game_started = true
- team_play = getteamplay()
- gametype = get_var(0, "$gt")
- map_name = get_var(0,"$map")
- cur_players = 0
- timerCount = 0
- if map_name then enable_targets[map_name] = enable_targets[map_name] or false end
- for i = 1,16 do
- if player_present(i) then
- cur_players = cur_players + 1
- end
- end
- if game_started and gametype == "slayer" then
- if enable_targets[map_name] then
- if not showtargets then
- if cur_players > 2 then
- showtargets = timer(300, "Show_Targets")
- end
- end
- end
- end
- end
- function OnPlayerJoin(PlayerIndex)
- cur_players = cur_players + 1
- if player_present(PlayerIndex) then
- if game_started and gametype == "slayer" then
- if enable_targets[map_name] then
- if not showtargets then
- if cur_players > 2 then
- showtargets = timer(300, "Show_Targets")
- end
- end
- end
- end
- end
- end
- function OnPlayerLeave(PlayerIndex)
- cur_players = cur_players - 1
- end
- function OnPlayerDie(PlayerIndex, KillerIndex)
- -- Killer Index is: -- falling = -1, server = -1, team-switch = -1, vehicle = 0, other players = 1 or greater
- if game_started then
- local vname = get_var(PlayerIndex, "$name")
- local killer = tonumber(KillerIndex)
- if (killer == -1) then -- server, falling or team change
- if not map_reset then
- say_all(vname.. " died.")
- end
- elseif (killer == 0) then -- vehicle
- say_all(vname.. " was killed by a vehicle.")
- elseif (killer > 0) then
- local kname = get_var(KillerIndex, "$name")
- if (PlayerIndex == killer) then -- suicide
- execute_command('say * "$name committed suicide."', PlayerIndex)
- elseif (PlayerIndex ~= KillerIndex) then -- killed by another player
- if cur_players > 2 then
- execute_command("slayer_score " .. KillerIndex .. " +1")
- local playerscore = get_var(KillerIndex, "$score")
- say_all(vname.. " was killed by " .. kname .. " (" .. playerscore .. ")")
- else
- local playerscore = get_var(KillerIndex, "$score")
- say_all(vname.. " was killed by " .. kname .. " (" .. playerscore .. ")")
- end
- else
- say_all(vname.. " was killed by the guardians. ")
- end
- end
- end
- if map_reset == true then
- map_reset = false
- end
- end
- function getteamplay()
- if get_var(0,"$ffa") == "0" then
- return true
- else
- return false
- end
- end
- function Show_Targets()
- if game_started and cur_players > 2 then
- Roaming_Targets()
- return true
- else
- return false
- end
- end
- function Roaming_Targets()
- if not team_play then
- local target = SelectTarget()
- if target then
- if player_present(target) and player_alive(target) then
- for PlayerIndex = 1,16 do
- if player_present(PlayerIndex) and player_alive(PlayerIndex) then
- if get_player(PlayerIndex) and get_player(PlayerIndex) ~= get_player(target) then
- write_word(get_player(PlayerIndex) + 0x88, target)
- end
- end
- end
- end
- end
- end
- end
- function SelectTarget()
- local t = {}
- for i=1,16 do
- if player_present(i) and player_alive(i) then
- local PlayerIndex = i
- table.insert(t, PlayerIndex)
- end
- end
- if #t > 0 then
- if (timerCount > #t) then
- timerCount = 0
- else
- timerCount = timerCount + 1
- end
- return t[timerCount]
- end
- end
- function OnServerCommand(PlayerIndex, Command, Environment, Password)
- -- Enviroment: 0: console, 1: rcon, 2: chat, Password is the password used in the rcon, otherwise a nil
- local allow = nil
- local name = get_var(PlayerIndex, "$name")
- if (tonumber(get_var(PlayerIndex,"$lvl"))) >= 1 then
- isadmin = true
- else
- isadmin = false
- end
- if (Environment == 1) or (Environment == 2) then
- if Command ~= nil then
- if isadmin then
- if Command == "sv_map_reset" then
- map_reset = true
- game_started = false
- say_all("The game has been reset and scripts reloaded.")
- LoadDefaults()
- LoadScript()
- allow = true
- elseif Command == "reload" or Command == "/reload" then
- map_reset = true
- game_started = false
- timerCount = 0
- write_dword(gametime_base + 0x10, 0)
- for i =1,16 do
- if player_present(i) then
- write_dword(get_player(i) + 0x2C, 0)
- kill(i)
- execute_command("slayer_score " .. i .. " 0")
- execute_command("kills " .. i .. " 0")
- execute_command("assists " .. i .. " 0")
- execute_command("deaths " .. i .. " 0")
- end
- end
- LoadDefaults()
- LoadScript()
- say_all("The game has been reset and scripts reloaded.")
- allow = true
- end
- else
- allow = false
- end
- end
- end
- return allow
- end
- function OnGameEnd()
- game_started = false
- cur_players = 0
- end
- function LoadDefaults()
- -- default enable/disable targets for the specified map: true = enable, false = disable
- enable_targets = {
- ["beavercreek"] = true,
- ["bloodgulch"] = true,
- ["boardingaction"] = true,
- ["carousel"] = true,
- ["chillout"] = true,
- ["damnation"] = true,
- ["dangercanyon"] = true,
- ["deathisland"] = true,
- ["gephyrophobia"] = true,
- ["hangemhigh"] = true,
- ["icefields"] = true,
- ["infinity"] = true,
- ["longest"] = true,
- ["prisoner"] = true,
- ["putput"] = true,
- ["ratrace"] = true,
- ["sidewinder"] = true,
- ["timberland"] = true,
- ["wizard"] = true,
- }
- end
- function OnError(Message)
- print(debug.traceback())
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement