Advertisement
HR_Shaft

Pro-Racing with Anti-Slayer v1.7 for SAPP Stock PC/CE

Jul 26th, 2016
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 31.53 KB | None | 0 0
  1. -- Pro-Racing v1.7 by H® Shaft for Stock PC/CE maps
  2. -- auto-heal, anti-hog camp, anti-slayer, out-of-bounds, medic, grenade refills, rockethogs spawn first, replacement weapons, betray-karma, splatter damage
  3.  
  4. -- Edit 7-20-2016  changelog:
  5.     -- 7-20-2016 corrected typo in refill chat command changed ..plasma.. to ..plasmas..
  6.     -- 7-20-2016 guarded against nil in CountReduction
  7.     -- 7-20-2016 updated isinvehicle function
  8.     -- 7-25-2016 updated betray delayed kick function
  9.  
  10. --**** START CONFIGURATION ****--
  11. grenade_delay = 15              -- | amount of time in seconds after game start to give players grenades if delay_grenades is set for the map
  12. frags = 1                       -- | amount of frag grenades players spawn with
  13. plasmas = 1                     -- | amount of frag grenades players spawn with
  14. eject_time = 3                  -- | amount of time in seconds before a gunner/passenger is ejected if no driver. 3 is minimum - 3 to 4 is good for race
  15. slayer_threshhold = 4           -- | amount of kills on foot which sets the slayer-play threshold (more than this: player is killed, if less than slayer_threshhold + kick_margin)
  16. betray_threshhold = 3           -- | amount of betrays which sets the team killer threshold
  17. spawn_penalty = 15              -- | amount of time in seconds to penalize BOTH team killers and Out-of-Bounds players on re-spawn
  18. kick_margin = 2                 -- | amount of kills on foot added to the slayer-play threshold which results in a kick
  19. slay_forgiveness_rate = 60      -- | amount of time in seconds before a single kill on foot/betray point is forgiven
  20. hp_limit = 3                    -- | amount of times a player may type MEDIC each game to get healed
  21. nade_refill_limit = 2           -- | amount of times a player may type REFILL each game to get a grenade refill
  22. replace_sniper = false          -- | If set to true, sniper rifles will be replaced with the replacement weapon
  23. replace_fuelrod = true          -- | If set to true, fuel rod gun (FRG) will be replaced with the replacement weapon
  24. delete_dropped_grenades = true  -- | If set to true, and player dies - their grenades will be deleted/destroyed (reduces slayer)
  25. replacement_weapon = "weapons\\shotgun\\shotgun"  -- | weapon tag name which will replace the sniper/FRG see bottom of script for weapons tag list
  26. -- message to notify players when Anti-Slayer is active:
  27. anti_slayer_msg = "|cAnti-Slayer is ACTIVE!: Slayer-Play results in automatic kill/kick by the server."
  28. --**** END CONFIGURATION ****--
  29.  
  30. -- See function LoadDefaults line 674 (near bottom) to set/edit values for:
  31. -- health_coord, anti_slayer, delay_grenades, grenade_refill and rockethogs_spawn_first, splatter_damage
  32. -- added splatter_damage to reduce chase-kills - if set to true, a player cannot be run over/killed by an enemy player in a hog
  33.  
  34. -- don't edit unless you know what you are doing --
  35. kills_on_foot = {}
  36. betrays = {}
  37. hp_delay = {}
  38. hp_player = {}
  39. nade_refills = {}
  40. players_in_vehicle = {}
  41. remaining_delay = true
  42. api_version = "1.9.0.0"
  43.  
  44. function OnScriptLoad()
  45.     register_callback(cb['EVENT_GAME_START'], "OnNewGame")
  46.     register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
  47.     register_callback(cb['EVENT_DIE'], "OnPlayerDie")
  48.     register_callback(cb['EVENT_BETRAY'], "OnPlayerBetray")
  49.     register_callback(cb['EVENT_JOIN'], "OnPlayerJoin")
  50.     register_callback(cb['EVENT_LEAVE'], "OnPlayerLeave")
  51.     register_callback(cb['EVENT_OBJECT_SPAWN'], "OnObjectSpawn")
  52.     register_callback(cb['EVENT_DAMAGE_APPLICATION'], "OnDamageApplication")
  53.     register_callback(cb['EVENT_TICK'], "OnEventTick")
  54.     register_callback(cb['EVENT_CHAT'], "OnPlayerChat")
  55.     register_callback(cb['EVENT_SPAWN'], "OnPlayerSpawn")
  56.     if get_var(0, "$gt") ~= "n/a" then
  57.         OnNewGame()
  58.     end
  59. end
  60.    
  61. function OnScriptUnload()
  62.     kills_on_foot = {}
  63.     betrays = {}
  64.     hp_delay = {}
  65.     hp_player = {}
  66.     health_coord = {}
  67.     anti_slayer = {}
  68.     delay_grenades = {}
  69.     grenade_refills = {}
  70.     players_in_vehicle = {}
  71.     replace_camo = {}
  72. end
  73.  
  74. function OnNewGame()
  75.     game_started = true
  76.     map_name = get_var(0,"$map")
  77.     LoadDefaults()
  78.        
  79.     if rockethogs_spawn_first[map_name] then
  80.         if get_var(0, "$gt") ~= "n/a" then
  81.             SwapHogs()
  82.         end
  83.     end
  84.    
  85.     for i = 1,16 do
  86.         if player_present(i) then
  87.             kills_on_foot[i] = 0
  88.             betrays[i] = 0
  89.             hp_delay[i] = 0
  90.             hp_player[i] = 0
  91.             nade_refills[i] = 0
  92.             if player_alive(i) then
  93.                 execute_command("nades me 0", i)
  94.             end
  95.         end
  96.     end
  97.    
  98.     if not delay_grenades[map_name] then
  99.         remaining_delay = false
  100.     else
  101.         remaining_delay = true
  102.         updatedelay = timer(grenade_delay * 1000, "UpdateDelay")
  103.         give_everyone_nades = timer(grenade_delay * 1000 + 1000, "GivePlayersGrenades")
  104.     end
  105.    
  106.     forgivecount = timer(slay_forgiveness_rate * 1000, "CountReduction")   
  107. end
  108.  
  109. function OnGameEnd()
  110.     game_started = false
  111.     remaining_delay = true
  112.     if rockethogs_spawn_first[map_name] then
  113.         if get_var(0, "$gt") ~= "n/a" then
  114.             UnSwapHogs()
  115.         end
  116.     end
  117.     for i = 1,16 do
  118.         if player_present(i) then
  119.             kills_on_foot[i] = 0
  120.             betrays[i] = 0
  121.             hp_delay[i] = 0
  122.             hp_player[i] = 0
  123.             nade_refills[i] = 0        
  124.         end
  125.     end    
  126. end
  127.  
  128. function OnPlayerJoin(PlayerIndex)
  129.     kills_on_foot[PlayerIndex] = 0
  130.     betrays[PlayerIndex] = 0
  131.     hp_delay[PlayerIndex] = 0
  132.     hp_player[PlayerIndex] = 0
  133.     nade_refills[PlayerIndex] = 0
  134.     timedwelcome = timer(20000, "TimedWelcome", PlayerIndex)
  135. end
  136.  
  137. function OnPlayerLeave(PlayerIndex)
  138.     kills_on_foot[PlayerIndex] = nil
  139.     betrays[PlayerIndex] = nil
  140.     hp_delay[PlayerIndex] = nil
  141.     hp_player[PlayerIndex] = nil
  142.     nade_refills[PlayerIndex] = nil
  143. end
  144.  
  145. function UpdateDelay()
  146.     remaining_delay = false
  147.     return false
  148. end
  149.    
  150. function OnPlayerSpawn(PlayerIndex)
  151.     if player_present(PlayerIndex) then
  152.         execute_command("nades me 0", PlayerIndex)
  153.         if game_started then
  154.             if not remaining_delay then
  155.                 execute_command("nades me " .. frags .. " 1", PlayerIndex)
  156.                 execute_command("nades me " .. plasmas .. " 2", PlayerIndex)
  157.             end
  158.         end
  159.     end
  160. end
  161.  
  162. function OnPlayerChat(PlayerIndex, Message)
  163.     local response = nil
  164.     if Message == nil then
  165.         return true
  166.     end
  167.     local isadmin = nil
  168.     local name = get_var(PlayerIndex,"$name")
  169.     local Message = string.lower(Message)
  170.    
  171.     if Message ~= nil then
  172.    
  173.         if (tonumber(get_var(PlayerIndex,"$lvl"))) >= 1 then
  174.             isadmin = true
  175.         else
  176.             isadmin = false
  177.         end
  178.  
  179.         if (Message == "medic") or (Message == "/medic")  then
  180.             if hp_player[PlayerIndex] < hp_limit then
  181.                 if game_started then
  182.                     if player_alive(PlayerIndex) then
  183.                         local obj_health = tonumber(get_var(PlayerIndex, "$hp"))
  184.                         if obj_health < 1 then
  185.                             hp_player[PlayerIndex] = hp_player[PlayerIndex] + 1
  186.                             health = timer(3500, "ApplyHP", PlayerIndex)
  187.                             say(PlayerIndex, name.. ": You will be healed. You have " .. hp_limit - hp_player[PlayerIndex] .. " MEDIC calls remaining.")
  188.                             say_all(string.format("%s requested a MEDIC (health pack). ", tostring(name)))                         
  189.                         elseif obj_health == 1 then
  190.                             say(PlayerIndex, "**OOPS!** You are already at full health!")
  191.                         end
  192.    
  193.                     end
  194.                 end
  195.             else
  196.                 say(PlayerIndex, "You have reached the limit of " .. hp_limit .. " medic calls per game")  
  197.             end
  198.             response = false   
  199.         end
  200.        
  201.         if (Message == "coord") then
  202.             local player_object = get_dynamic_player(PlayerIndex)
  203.             local player_static = get_player(PlayerIndex)
  204.             local x,y,z = read_vector3d(player_object + 0x5C)
  205.             local data = string.format("%s,%s,%s,%s", tostring(map_name),tostring(x),tostring(y),tostring(z))
  206.             execute_command("log_note \""..data.."\"")     
  207.             say(PlayerIndex, "X: " .. x .. " Y: " .. y .. " Z: " .. z)
  208.             response = false
  209.         end    
  210.        
  211.         if (Message == "nademe") or (Message == "/nademe") or (Message == "nade me") or (Message == "refill") then
  212.             if game_started then
  213.                 if (remaining_delay == false) then
  214.                     if nade_refills[PlayerIndex] < nade_refill_limit then
  215.                         if player_alive(PlayerIndex) then          
  216.                             nade_refills[PlayerIndex] = nade_refills[PlayerIndex] + 1
  217.                             nades = timer(500, "GiveNades", PlayerIndex)
  218.                             say(PlayerIndex, "Grenades: " .. plasmas .. " Plasmas, " .. frags .. " Frags. You have " .. nade_refill_limit - nade_refills[PlayerIndex] .. " grenade refills remaining.")
  219.                             say_all(string.format("%s requested a grenade REFILL. ", tostring(name)))
  220.                         end
  221.                     else
  222.                         say(PlayerIndex, "You have reached the grenade refill limit of " .. nade_refill_limit .. " per game")
  223.                     end
  224.                 else
  225.                     say(PlayerIndex, "you cannot use this function until the delay has expired.")
  226.                 end        
  227.             else
  228.                 say(PlayerIndex, "Oops! Can't do that until the next game!")
  229.             end
  230.             response = false   
  231.         end    
  232.        
  233.     end
  234.    
  235.     return response
  236. end
  237.  
  238. function CountReduction()
  239.     if game_started then
  240.         for i = 1,16 do
  241.             if player_present(i) then
  242.                 if kills_on_foot[i] ~= nil then
  243.                     if kills_on_foot[i] > 0 then
  244.                         kills_on_foot[i] = kills_on_foot[i] - 1
  245.                     end
  246.                 end
  247.                 if betrays[i] ~= nil then
  248.                     if betrays[i] > 0 then  
  249.                         betrays[i] = betrays[i] - 1
  250.                     end
  251.                 end
  252.             end
  253.         end
  254.         return true
  255.     else   
  256.         return false
  257.     end
  258. end
  259.  
  260. function OnPlayerDie(PlayerIndex, KillerIndex)
  261.     if KillerIndex ~= "-1" then
  262.         local kname = get_var(KillerIndex,"$name")
  263.         if PlayerIndex ~= KillerIndex then
  264.             if get_var(KillerIndex, "$team") ~= get_var(PlayerIndex, "$team") then
  265.                 if kills_on_foot[KillerIndex] == nil then kills_on_foot[KillerIndex] = 0 end
  266.                 if not isinvehicle(KillerIndex) then
  267.                     local Reason = "Slayer-Play"
  268.                     kills_on_foot[KillerIndex] = kills_on_foot[KillerIndex] + 1
  269.                     local killcount = kills_on_foot[KillerIndex]
  270.                     if kills_on_foot[KillerIndex] > slayer_threshhold + kick_margin then
  271.                         say_all("**Anti-Slayer**  ".. kname .. " is being auto-kicked for Slayer-Play.")
  272.                         rprint(KillerIndex, "**Anti-Slayer**  " .. kname .. "! Slayer-Play will NOT be tolerated!")
  273.                         delayedkick = timer(3000, "DelayedKick", KillerIndex, Reason, killcount)
  274.                     elseif kills_on_foot[KillerIndex] > slayer_threshhold then
  275.                         say_all("**Anti-Slayer**  ".. kname .. " was force-killed for " .. Reason .. ".")
  276.                         rprint(KillerIndex, "**Anti-Slayer**  " .. kname .. "! Slayer-Play will NOT be tolerated!")
  277.                         kill(KillerIndex)
  278.                     elseif not isinvehicle(KillerIndex) and kills_on_foot[KillerIndex] <= slayer_threshhold then
  279.                         rprint(KillerIndex, "**Anti-Slayer**  " .. kname .. "! Caution: Slayer-Play will NOT be tolerated!")               
  280.                     end
  281.                 end
  282.             end
  283.         end
  284.     end
  285.     if delete_dropped_grenades then
  286.         execute_command('nades me 0', PlayerIndex)
  287.     end
  288. end
  289.  
  290. function OnPlayerBetray(PlayerIndex, VictimIndex)
  291.     if not player_present(PlayerIndex) then return end
  292.     local pname = get_var(PlayerIndex,"$name")
  293.     local vname = get_var(VictimIndex,"$name")
  294.     local Reason = "Excess Betrayals"
  295.     if betrays[PlayerIndex] == nil then betrays[PlayerIndex] = 0 end
  296.     if betrays[PlayerIndex] >= betray_threshhold then
  297.         say_all("**Anti-Slayer**  ".. pname .. " is being auto-kicked for excess betrayals.")
  298.         rprint(PlayerIndex, "**Anti-Slayer**  " .. pname .. "! Team-Killing will NOT be tolerated!")
  299.         local killcount = betrays[PlayerIndex]
  300.         if player_present(PlayerIndex) then
  301.             delayedkick = timer(3000, "DelayedKick", PlayerIndex, Reason, killcount)
  302.         end
  303.     else   
  304.         if player_alive(PlayerIndex) then
  305.             say_all("**Anti-Slayer**  ".. pname .. " was force-killed for betraying " .. vname)
  306.             rprint(PlayerIndex, "**Anti-Slayer**  " .. pname .. "! Team-Killing will NOT be tolerated!")
  307.             local respawn_time_old = read_dword(get_player(PlayerIndex) + 0x30)
  308.             write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old + 30 * spawn_penalty)         
  309.             kill(PlayerIndex)
  310.             write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old)
  311.         end
  312.     end
  313. end
  314.  
  315. function DelayedKick(PlayerIndex, Reason, Count)
  316.     if not player_present(PlayerIndex) then return end
  317.     if player_present(PlayerIndex) then
  318.         if Reason == nil then Reason = "Unspecified" end
  319.         if Count == nil then Count = "Unspecified" end     
  320.         local namekicked = get_var(PlayerIndex,"$name")
  321.         local str1 = string.format("%s was kicked by Anti-Slayer for %s | %s", tostring(namekicked),tostring(Reason),tostring(Count))
  322.         execute_command("log_note \""..str1.."\"")
  323.         kills_on_foot[PlayerIndex] = nil
  324.         betrays[PlayerIndex] = nil
  325.         hp_delay[PlayerIndex] = nil
  326.         hp_player[PlayerIndex] = nil
  327.         nade_refills[PlayerIndex] = nil    
  328.         execute_command("k " .. PlayerIndex .. " " .. Reason)
  329.     end
  330. end
  331.  
  332. function TimedWelcome(PlayerIndex)
  333.     if game_started then
  334.         if player_present(PlayerIndex) then
  335.             if anti_slayer[map_name] then
  336.                 rprint(PlayerIndex, " ")
  337.                 rprint(PlayerIndex, " ")
  338.                 rprint(PlayerIndex, " ")
  339.                 rprint(PlayerIndex, anti_slayer_msg)
  340.             end
  341.         end
  342.     end
  343.     return false
  344. end
  345.  
  346. function OnObjectSpawn(PlayerIndex, MapID, ParentID, ObjectID)
  347.     -- replace sniper rifle with replacement weapon
  348.     if game_started then
  349.         if get_var(0, "$gt") ~= "n/a" then
  350.             if replace_sniper then
  351.                 if MapID == get_tag_info("weap", "weapons\\sniper rifle\\sniper rifle") then
  352.                     return true, get_tag_info("weap", replacement_weapon)
  353.                 end
  354.             end
  355.         end    
  356.     end
  357.     -- replace fuel rod gun with replacement weapon
  358.     if game_started then
  359.         if get_var(0, "$gt") ~= "n/a" then
  360.             if replace_fuelrod then
  361.                 if MapID == get_tag_info("weap", "weapons\\plasma_cannon\\plasma_cannon") then
  362.                     return true, get_tag_info("weap", replacement_weapon)
  363.                 end
  364.             end
  365.         end
  366.     end
  367.     -- replace active camo with overshield
  368.     if game_started then
  369.         if get_var(0, "$gt") ~= "n/a" then
  370.             if replace_camo[map_name] then
  371.                 if MapID == get_tag_info("eqip", "powerups\\active camouflage") then
  372.                     return true, get_tag_info("eqip", "powerups\\over shield")
  373.                 end
  374.             end
  375.         end
  376.     end
  377.     -- end
  378.     return true
  379. end
  380.  
  381. function OnEventTick()
  382.     for PlayerIndex = 1,16 do
  383.         if player_alive(PlayerIndex) then
  384.             local player_object = get_dynamic_player(PlayerIndex)
  385.             local name = get_var(PlayerIndex,"$name")
  386.             local obj_health = tonumber(get_var(PlayerIndex, "$hp"))
  387.             if hp_delay[PlayerIndex] == nil then hp_delay[PlayerIndex] = 0 end
  388.             if hp_delay[PlayerIndex] > 0 then hp_delay[PlayerIndex] = hp_delay[PlayerIndex] - 1 end
  389.             local time = os.clock()
  390.            
  391.             -- ejects hog campers (passengers and gunners) if there is no driver
  392.             if (player_object ~= 0) then
  393.                 local player_obj_id = read_dword(get_player(PlayerIndex) + 0x34)
  394.                 local vehicleId = read_dword(player_object + 0x11C)
  395.                 local m_vehicle = get_object_memory(vehicleId)
  396.                 if isinvehicle(PlayerIndex) then
  397.                     player_obj_id = vehicleId
  398.                 end            
  399.                 if (m_vehicle ~= 0) then
  400.                     if (PlayerIsGunner(PlayerIndex) and VehicleHasDriver(vehicleId) == false) then
  401.                         if (players_in_vehicle[PlayerIndex] == nil) then
  402.                             players_in_vehicle[PlayerIndex] = time
  403.                         elseif (time > (players_in_vehicle[PlayerIndex] + eject_time)) then
  404.                             exit_vehicle(PlayerIndex)
  405.                             say(PlayerIndex, " |*EJECTED!*|  No Driver! Please drive or gun " .. name .. "!")
  406.                             players_in_vehicle[PlayerIndex] = nil
  407.                         end
  408.                     elseif (VehicleHasDriver(vehicleId) == false) then
  409.                         if (players_in_vehicle[PlayerIndex] == nil) then
  410.                             players_in_vehicle[PlayerIndex] = time
  411.                         elseif (time > (players_in_vehicle[PlayerIndex] + eject_time)) then
  412.                             exit_vehicle(PlayerIndex)
  413.                             say(PlayerIndex, " |*EJECTED!*|  No Driver! Please drive or gun " .. name .. "!")
  414.                             players_in_vehicle[PlayerIndex] = nil
  415.                         end        
  416.                     else
  417.                         players_in_vehicle[PlayerIndex] = nil
  418.                     end
  419.                 end    
  420.                
  421.                 -- walk thru/drive-thru health - first nav of each map
  422.                 if health_coord[map_name] ~= nil then
  423.                     local drivethru = inSphere(player_obj_id, health_coord[map_name][1], health_coord[map_name][2], health_coord[map_name][3], 2.5)
  424.                     local walkthru = inSphere(player_obj_id, health_coord[map_name][1], health_coord[map_name][2], health_coord[map_name][3], 2.5)
  425.                     if isinvehicle(PlayerIndex) then
  426.                         if drivethru then                      
  427.                             if (hp_delay[PlayerIndex] == 0) then
  428.                                 if (obj_health < 1) then
  429.                                     bonushealth = timer(3000, "Bonus_HP", PlayerIndex)
  430.                                 end
  431.                             end
  432.                         end
  433.                     elseif not isinvehicle(PlayerIndex) then   
  434.                         if walkthru then
  435.                             if (hp_delay[PlayerIndex] == 0) then
  436.                                 if (obj_health < 1) then
  437.                                     bonushealth = timer(3000, "Bonus_HP", PlayerIndex)
  438.                                 end
  439.                             end
  440.                         end
  441.                     end
  442.                 end
  443.                 -- end drive-thru walk-thru health
  444.                
  445.                 -- Out-of-Bounds  -- Sets respawn penalty, warns player then kills them
  446.                 local respawn_time_old = read_dword(get_player(PlayerIndex) + 0x30)
  447.                 if map_name == "gephyrophobia" then
  448.                     local bluebasetop1 = inSphere(player_obj_id, -24.30, -28.16, -1.25, 4)
  449.                     local bluebasetop2 = inSphere(player_obj_id, 74.69, -38.07, -1.06, 4)
  450.                     local redbasetop1 = inSphere(player_obj_id, 74.76, -112.56, -1.06, 4)
  451.                     local redbasetop2 = inSphere(player_obj_id, -27.73, -107.17, -1.25, 4) 
  452.                     if bluebasetop1 or bluebasetop2 or redbasetop1 or redbasetop2 then
  453.                         write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old + 30 * spawn_penalty)         
  454.                         kill(PlayerIndex)
  455.                         write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old)
  456.                         say_all("**Anti-Slayer**  " .. name .. " is being force-killed for going Out-of-Bounds.")
  457.                         rprint(PlayerIndex, "**Anti-Slayer**  " .. name .. "! Going Out-of-Bounds will NOT be tolerated!")
  458.                     end
  459.                    
  460.                 elseif map_name == "dangercanyon" then
  461.                     local topcenterfoot = inSphere(player_obj_id, -0.05, 30.59,0.23, 3)
  462.                     local bottommiddle = inSphere(player_obj_id, -0.06, 53.18, -8.44, 3)
  463.                     local bluerocket = inSphere(player_obj_id, 26.81, 26.52, 0.18, 3)
  464.                     local redrocket = inSphere(player_obj_id, -26.77, 26.45, 0.18, 3)
  465.                     -- moves player to bottom center ramp
  466.                     if topcenterfoot and not isinvehicle(PlayerIndex) then
  467.                         moveobject(player_obj_id, 0.17, 52.84, -8.42)
  468.                     end
  469.                     if redrocket or bluerocket then
  470.                         say_all("**Anti-Slayer**  " .. name .. " is being force-killed for going Out-of-Bounds.")
  471.                         rprint(PlayerIndex, "**Anti-Slayer**  " .. name .. "! Going Out-of-Bounds will NOT be tolerated!")
  472.                         write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old + 30 * spawn_penalty)         
  473.                         kill(PlayerIndex)
  474.                         write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old)  
  475.                     end
  476.                    
  477.                 elseif map_name == "deathisland" then
  478.                     local bluebasetop = inSphere(player_obj_id, 24.592, 16.076, 20.983, 6)
  479.                     local bluebaseturret = inSphere(player_obj_id, 46.845, -35.882, 14.003, 6)
  480.                     local redbasetop = inSphere(player_obj_id, -21.454, -6.950, 22.373, 6)
  481.                     local redbaseturret = inSphere(player_obj_id, -68.724, 17.680, 15.322, 6)
  482.                     local cementFRG = inSphere(player_obj_id, -30.84, 28.56, 14.27, 3)
  483.                     local grassFRG = inSphere(player_obj_id, 13.55, -12.48, 20.75, 3)
  484.                     if bluebasetop or redbasetop or cementFRG or grassFRG or bluebaseturret or redbaseturret then
  485.                         if not isinvehicle(PlayerIndex) then
  486.                             say_all("**Anti-Slayer**  " .. name .. " is being force-killed for going Out-of-Bounds.")
  487.                             rprint(PlayerIndex, "**Anti-Slayer**  " .. name .. "! Going Out-of-Bounds will NOT be tolerated!")
  488.                             write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old + 30 * spawn_penalty)         
  489.                             kill(PlayerIndex)
  490.                             write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old)
  491.                         end
  492.                     end
  493.                    
  494.                 elseif map_name == "icefields" then
  495.                     local top_bridge = inSphere(player_obj_id, -30.91, 41.97, 11.10, 2.5)
  496.                     if top_bridge and not isinvehicle(PlayerIndex) then
  497.                         say_all("**Anti-Slayer**  " .. name .. " is being force-killed for going Out-of-Bounds.")
  498.                         rprint(PlayerIndex, "**Anti-Slayer**  " .. name .. "! Going Out-of-Bounds will NOT be tolerated!")
  499.                         write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old + 30 * spawn_penalty)         
  500.                         kill(PlayerIndex)
  501.                         write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old)                      
  502.                     end
  503.                 end            
  504.                 -- End Out-of-Bounds
  505.                
  506.             end
  507.         end
  508.     end    
  509. end
  510.  
  511. function GivePlayersGrenades()
  512.     if game_started and (remaining_delay == false) then
  513.         for i = 1,16 do
  514.             if player_present(i) then  
  515.                 if player_alive(i) then
  516.                     execute_command("nades me " .. frags .. " 1", i)
  517.                     execute_command("nades me " .. plasmas .. " 2", i)
  518.                 end    
  519.             end
  520.         end
  521.     end    
  522.     return false
  523. end
  524.  
  525. function GiveNades(PlayerIndex)
  526.     if game_started then
  527.         if player_present(PlayerIndex) then
  528.             if player_alive(PlayerIndex) then
  529.                 execute_command("nades me " .. frags .. " 1", PlayerIndex)
  530.                 execute_command("nades me " .. plasmas .. " 2", PlayerIndex)                   
  531.             end
  532.         end
  533.     end    
  534.     return false
  535. end
  536.  
  537. function Bonus_HP(PlayerIndex)
  538.     if game_started then
  539.         if player_alive(PlayerIndex) then
  540.             local player_object = get_dynamic_player(PlayerIndex)
  541.             if player_object ~= 0 then
  542.                 local obj_health = tonumber(get_var(PlayerIndex, "$hp"))
  543.                 if obj_health < 1 then
  544.                     write_float(player_object + 0xE0, 1)
  545.                     rprint(PlayerIndex, "Bonus: Your health has been restored.")
  546.                     hp_delay[PlayerIndex] = math.floor(30*30)
  547.                 end
  548.             end
  549.         end
  550.     end
  551.     return false
  552. end
  553.  
  554. function ApplyHP(PlayerIndex)
  555.     if game_started then
  556.         if player_present(PlayerIndex) then
  557.             if player_alive(PlayerIndex) then
  558.                 local name = get_var(PlayerIndex,"$name")
  559.                 local player_object = get_dynamic_player(PlayerIndex)
  560.                 local obj_health = tonumber(get_var(PlayerIndex, "$hp"))
  561.                 if obj_health < 1 then
  562.                     write_float(player_object + 0xE0, 1)
  563.                     rprint(PlayerIndex, name.. " You were healed!")                                        
  564.                 else
  565.                     say(PlayerIndex, "Oops! You are already at full health!")
  566.                 end        
  567.             else
  568.                 say(PlayerIndex, "Oops! You are dead, a healthpack won't help you.")
  569.             end
  570.         end
  571.     end    
  572.     return false
  573. end
  574.    
  575. function isinvehicle(PlayerIndex)  -- edited 7/20/2016
  576.     local player_object = get_dynamic_player(PlayerIndex)
  577.     if player_object ~= 0 then
  578.         local vehicleId = read_dword(player_object + 0x11C)
  579.         if vehicleId == 0xFFFFFFFF then
  580.             return false
  581.         else
  582.             return true
  583.         end
  584.     else
  585.         return false
  586.     end
  587. end
  588.  
  589. function inSphere(ObjectID, X, Y, Z, R)
  590.     if get_object_memory(ObjectID) ~= 0 then
  591.         local object = get_object_memory(ObjectID)
  592.         local x,y,z = read_vector3d(object + 0x5C)
  593.         if (X - x)^2 + (Y - y)^2 + (Z - z)^2 <= R then
  594.             return true
  595.         else
  596.             return false
  597.         end
  598.     end
  599. end
  600.  
  601. function moveobject(ObjectID, x, y, z)
  602.     local object = get_object_memory(ObjectID)
  603.     if get_object_memory(ObjectID) ~= 0 then
  604.         local veh_obj = get_object_memory(read_dword(object + 0x11C))
  605.         write_vector3d((veh_obj ~= 0 and veh_obj or object) + 0x5C, x, y, z)
  606.     end
  607. end
  608.  
  609. function OnDamageApplication(PlayerIndex, CauserIndex, MetaID, Damage, HitString, Backtap)
  610.     if get_var(0, "$gt") ~= "n/a" then
  611.         if MetaID == splatter_damage then
  612.             if block_splatter[map_name] then
  613.                 return true, 0
  614.             end
  615.         end
  616.     end
  617. end
  618.  
  619. function get_tag_info(tagclass,tagname) -- Thanks to 002, return metaid
  620.     local tagarray = read_dword(0x40440000)
  621.     for i=0,read_word(0x4044000C)-1 do
  622.         local tag = tagarray + i * 0x20
  623.         local class = string.reverse(string.sub(read_string(tag),1,4))
  624.         if (class == tagclass) then
  625.             if (read_string(read_dword(tag + 0x10)) == tagname) then
  626.                 return read_dword(tag + 0xC)
  627.             end
  628.         end
  629.     end
  630.     return nil
  631. end
  632.  
  633. function SwapDependency(Address,ToTag,ToClass)
  634.     local tag_address = read_dword(0x40440000)
  635.     local tag_count = read_dword(0x4044000C)
  636.     for i=0,tag_count-1 do
  637.         local tag = tag_address + 0x20 * i
  638.         if (read_dword(tag) == ToClass and read_string(read_dword(tag + 0x10)) == ToTag) then
  639.             write_dword(Address,read_dword(tag + 0xC))
  640.             return
  641.         end
  642.     end
  643. end
  644.  
  645. function SwapHogs() -- rockethogs spawn first
  646.     local tag_address = read_dword(0x40440000)
  647.     local tag_count = read_dword(0x4044000C)
  648.     for i=0,tag_count-1 do
  649.         local tag = tag_address + 0x20 * i
  650.         local tag_name = read_string(read_dword(tag + 0x10))
  651.         local tag_class = read_dword(tag)
  652.         if(tag_class == 1835103335 and tag_name == "globals\\globals") then
  653.             local tag_data = read_dword(tag + 0x14)
  654.             write_dword(tag_data + 0xa50, 1078313799)
  655.             SwapDependency(tag_data + 0xa58, "vehicles\\rwarthog\\rwarthog", 1986357353)
  656.             write_dword(tag_data + 0xaa0, 1078301885)
  657.             SwapDependency(tag_data + 0xaa8, "vehicles\\warthog\\mp_warthog", 1986357353)
  658.             break
  659.         end
  660.     end
  661. end
  662.  
  663. function UnSwapHogs() -- chainhogs spawn first (normal)
  664.     local tag_address = read_dword(0x40440000)
  665.     local tag_count = read_dword(0x4044000C)
  666.     for i=0,tag_count-1 do
  667.         local tag = tag_address + 0x20 * i
  668.         local tag_name = read_string(read_dword(tag + 0x10))
  669.         local tag_class = read_dword(tag)
  670.         if(tag_class == 1835103335 and tag_name == "globals\\globals") then
  671.             local tag_data = read_dword(tag + 0x14)
  672.             write_dword(tag_data + 0xa50, 1078301885)
  673.             SwapDependency(tag_data + 0xa58, "vehicles\\warthog\\mp_warthog", 1986357353)
  674.             write_dword(tag_data + 0xaa0, 1078313799)
  675.             SwapDependency(tag_data + 0xaa8, "vehicles\\rwarthog\\rwarthog", 1986357353)
  676.             break
  677.         end
  678.     end
  679. end
  680.  
  681. function VehicleHasDriver(VehicleID)
  682.     local vehicle_object = get_object_memory(VehicleID)
  683.     if (vehicle_object == 0) then return false end
  684.     return read_dword(vehicle_object + 0x324) ~= 0xFFFFFFFF
  685. end
  686.  
  687. function PlayerIsGunner(PlayerIndex)
  688.     if (player_present(PlayerIndex) == false) then return false end
  689.     local player_object = get_dynamic_player(PlayerIndex)
  690.     local pid = read_dword(get_player(PlayerIndex) + 0x34)
  691.     local vehicleId = read_dword(player_object + 0x11C)
  692.     if (vehicleId == 0xFFFFFFFF) then return false end
  693.     local obj_id = get_object_memory(vehicleId)
  694.     return read_dword(obj_id + 0x328) == pid
  695. end
  696.  
  697. function LoadDefaults()
  698.     -- if coordinates (x, y, z) are set for the map, players will be healed when they walk/drive thru the coordinates (lap nav)
  699.     health_coord = {
  700.         ["bloodgulch"]          =       {59.785, -121.995, 0.268},
  701.         ["dangercanyon"]        =       {-0.800, 40.452, -6.000},
  702.         ["deathisland"]         =       {1.499, -55.629, 1.645},
  703.         ["gephyrophobia"]       =       {42.076, -71.727, -12.711},
  704.         ["icefields"]           =       {-26.061, 32.583, 9.008},
  705.         ["infinity"]            =       {0.461, -158.781, 13.574},
  706.         ["sidewinder"]          =       {1.800, 54.512, -2.801},
  707.         ["timberland"]          =       {17.330, -1.847, -21.034},
  708.         ["hangemhigh"]          =       {20.244, 12.534, -7.949},
  709.         ["ratrace"]             =       {-3.937, -8.287, -1.379},
  710.         ["beavercreek"]         =       {13.633, 13.249, -0.606},
  711.         ["damnation"]           =       {-0.646, -1.527, 8.201},
  712.         ["boardingaction"]      =       {16.896, -0.245, -2.280},
  713.         ["carousel"]            =       {0.898, 10.113, 0.747},
  714.         ["putput"]              =       {-3.753, -20.851, 0.903},
  715.         ["prisoner"]            =       {9.959, 4.606, -0.407},
  716.         ["wizard"]              =       {5.555, -3.075, -2.749}
  717.     }
  718.     -- if set to true, all kills made while on foot will count towards the players slayer_threshhold
  719.     anti_slayer = {
  720.         ["bloodgulch"]          =       true,
  721.         ["dangercanyon"]        =       true,
  722.         ["deathisland"]         =       true,
  723.         ["gephyrophobia"]       =       true,
  724.         ["icefields"]           =       true,
  725.         ["infinity"]            =       true,
  726.         ["sidewinder"]          =       true,
  727.         ["timberland"]          =       true,
  728.         ["hangemhigh"]          =       false,
  729.         ["ratrace"]             =       false,
  730.         ["beavercreek"]         =       false,
  731.         ["damnation"]           =       false,
  732.         ["boardingaction"]      =       false,
  733.         ["carousel"]            =       false,
  734.         ["putput"]              =       false,
  735.         ["prisoner"]            =       false,
  736.         ["wizard"]              =       false
  737.     }
  738.     -- if set to true, when the game starts, grenade counts will be set to zero, until the delay expires
  739.     delay_grenades = {
  740.         ["bloodgulch"]          =       true,
  741.         ["dangercanyon"]        =       true,
  742.         ["deathisland"]         =       true,
  743.         ["gephyrophobia"]       =       true,
  744.         ["icefields"]           =       true,
  745.         ["infinity"]            =       true,
  746.         ["sidewinder"]          =       true,
  747.         ["timberland"]          =       true,
  748.         ["hangemhigh"]          =       false,
  749.         ["ratrace"]             =       false,
  750.         ["beavercreek"]         =       false,
  751.         ["damnation"]           =       false,
  752.         ["boardingaction"]      =       false,
  753.         ["carousel"]            =       false,
  754.         ["putput"]              =       false,
  755.         ["prisoner"]            =       false,
  756.         ["wizard"]              =       false
  757.     }
  758.     -- if set to true, players may type REFILL to get a grenade refill (amounts are set by frags and plasmas at the top)
  759.     grenade_refill = {
  760.         ["bloodgulch"]          =       true,
  761.         ["dangercanyon"]        =       true,
  762.         ["deathisland"]         =       true,
  763.         ["gephyrophobia"]       =       true,
  764.         ["icefields"]           =       true,
  765.         ["infinity"]            =       true,
  766.         ["sidewinder"]          =       true,
  767.         ["timberland"]          =       true,
  768.         ["hangemhigh"]          =       false,
  769.         ["ratrace"]             =       false,
  770.         ["beavercreek"]         =       false,
  771.         ["damnation"]           =       false,
  772.         ["boardingaction"]      =       false,
  773.         ["carousel"]            =       false,
  774.         ["putput"]              =       false,
  775.         ["prisoner"]            =       false,
  776.         ["wizard"]              =       false
  777.     }
  778.     -- if set to true, rocket hogs will spawn first, then chain hogs
  779.     rockethogs_spawn_first = {
  780.         ["bloodgulch"]          =       true,
  781.         ["dangercanyon"]        =       true,
  782.         ["deathisland"]         =       true,
  783.         ["gephyrophobia"]       =       true,
  784.         ["icefields"]           =       true,
  785.         ["infinity"]            =       true,
  786.         ["sidewinder"]          =       true,
  787.         ["timberland"]          =       true,
  788.         ["hangemhigh"]          =       false,
  789.         ["ratrace"]             =       false,
  790.         ["beavercreek"]         =       false,
  791.         ["damnation"]           =       false,
  792.         ["boardingaction"]      =       false,
  793.         ["carousel"]            =       false,
  794.         ["putput"]              =       false,
  795.         ["prisoner"]            =       false,
  796.         ["wizard"]              =       false
  797.     }
  798.     -- if set to true, active camo will be replaced by an overshield
  799.     replace_camo = {
  800.         ["bloodgulch"]          =       true,
  801.         ["dangercanyon"]        =       true,
  802.         ["deathisland"]         =       true,
  803.         ["gephyrophobia"]       =       true,
  804.         ["icefields"]           =       true,
  805.         ["infinity"]            =       true,
  806.         ["sidewinder"]          =       true,
  807.         ["timberland"]          =       true,
  808.         ["hangemhigh"]          =       true,
  809.         ["ratrace"]             =       true,
  810.         ["beavercreek"]         =       true,
  811.         ["damnation"]           =       true,
  812.         ["boardingaction"]      =       true,
  813.         ["carousel"]            =       true,
  814.         ["putput"]              =       true,
  815.         ["prisoner"]            =       true,
  816.         ["wizard"]              =       true
  817.     }
  818.     -- if set to true, players cannot kill other players by running them over      
  819.     block_splatter = {
  820.         ["bloodgulch"]          =       false,
  821.         ["dangercanyon"]        =       false,
  822.         ["deathisland"]         =       false,
  823.         ["gephyrophobia"]       =       false,
  824.         ["icefields"]           =       false,
  825.         ["infinity"]            =       false,
  826.         ["sidewinder"]          =       false,
  827.         ["timberland"]          =       false,
  828.         ["hangemhigh"]          =       false,
  829.         ["ratrace"]             =       false,
  830.         ["beavercreek"]         =       false,
  831.         ["damnation"]           =       false,
  832.         ["boardingaction"]      =       false,
  833.         ["carousel"]            =       false,
  834.         ["putput"]              =       false,
  835.         ["prisoner"]            =       false,
  836.         ["wizard"]              =       false
  837.     }
  838.     -- metaid of vehicle damage for blocking of splatter_damage
  839.     if block_splatter[map_name] then
  840.         if get_var(0, "$gt") ~= "n/a" then
  841.             splatter_damage = get_tag_info("jpt!", "globals\\vehicle_collision")
  842.         end
  843.     end
  844. end
  845.  
  846. function OnError(Message)
  847.     print(debug.traceback())
  848. end
  849.  
  850. -- WEAPON TAG NAMES: for use with replacement_weapon on line 24 at the top for replacing sniper and/or FRG
  851.  
  852. -- "weapons\\assault rifle\\assault rifle" --  Assault Rifle
  853. -- "weapons\\flamethrower\\flamethrower" --  Flamethrower
  854. -- "weapons\\gravity rifle\\gravity rifle" --  Gravity Rifle
  855. -- "weapons\\needler\\mp_needler" --  Needler
  856. -- "weapons\\pistol\\pistol" --  Pistol
  857. -- "weapons\\plasma pistol\\plasma pistol" --  Plasma Pistol
  858. -- "weapons\\plasma rifle\\plasma rifle" --  Plasma Rifle
  859. -- "weapons\\plasma_cannon\\plasma_cannon" --  Fuel Rod
  860. -- "weapons\\rocket launcher\\rocket launcher" --  Rocket Launcher
  861. -- "weapons\\shotgun\\shotgun" --  Shotgun
  862. -- "weapons\\sniper rifle\\sniper rifle" --  Sniper Rifle
  863.  
  864. -- Created by H® Shaft
  865. -- Visit http://halorace.org
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement