Advertisement
HR_Shaft

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

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