Advertisement
HR_Shaft

Teabag Lovin

Jan 17th, 2017
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.40 KB | None | 0 0
  1. -- Teabag Lovin by H® Shaft
  2. -- a crude derivation of Teabagging Script by 002, and my own script from phasor
  3.  
  4. --When a player teabags their victim, the script will announce a random teabagging message, example:
  5.  
  6. --"H® Shaft is makin' sweet love with 002's corpse!" or
  7. --"H® Shaft is butterin' the muffin with 002's corpse!"
  8.  
  9. --etc - 25 custom messages, add your own!
  10.  
  11. --PLUS:
  12.  
  13.   --The player will be given a random BONUS if they survive for 5 more seconds:
  14.  
  15.    --1) Restored Health, or
  16.    --2) 2+ Frag Grenades, or
  17.    --3) Active Camo for 20 seconds, or
  18.    --4) Increased Speed for 20 seconds: 125% (not applicable for race game type)
  19.    --5) Over-Shield
  20.  
  21. -- Seconds until the teabag "expires"
  22. EXPIRE_TIME = 20
  23.  
  24. -- Teabag radius in world units (1 world unit = 3 meters)
  25. TEABAG_RADIUS = 2/3
  26.  
  27. -- don't edit --
  28. api_version = "1.9.0.0"
  29. crouch_time = 2
  30.  
  31. function OnScriptLoad()
  32.     register_callback(cb['EVENT_TICK'],"OnTick")
  33.     register_callback(cb['EVENT_DIE'],"OnDie")
  34.     register_callback(cb['EVENT_GAME_START'],"OnNewGame")
  35.     register_callback(cb['EVENT_JOIN'],"OnPlayerJoin")
  36.     register_callback(cb['EVENT_LEAVE'],"OnPlayerLeave")   
  37.     player_locations = {}
  38.     bodies = {}
  39.     delay = {}
  40.     crouch = {}
  41.     OnNewGame()
  42. end
  43.  
  44. function OnScriptUnload() end
  45.  
  46. function OnNewGame()
  47.     for i=1,16 do
  48.         delay[i], crouch[i] = 0, nil
  49.     end
  50. end
  51.  
  52. function OnPlayerJoin(PlayerIndex)
  53.     if player_present(PlayerIndex) then
  54.         delay[PlayerIndex], crouch[PlayerIndex] = 0, nil
  55.     end
  56. end
  57.  
  58. function OnPlayerLeave(PlayerIndex)
  59.     delay[PlayerIndex], crouch[PlayerIndex] = nil, nil
  60. end
  61.  
  62. function OnTick()
  63.     local time = os.clock()
  64.     for i=#bodies,1,-1 do
  65.         if(bodies[i].Expires < time) then
  66.             table.remove(bodies,i)
  67.         end
  68.     end
  69.     for i=1,16 do
  70.         if(player_alive(i)) then
  71.             local player_object = get_dynamic_player(i)
  72.             local x,y,z = read_vector3d(player_object + 0x5C)
  73.             local vehicle_objectid = read_dword(player_object + 0x11C)
  74.             local vehicle_object = get_object_memory(vehicle_objectid)
  75.             local id = get_var(i, "$n")
  76.             if delay[i] > 0 then delay[i] = delay[i] - 1 end
  77.             if (vehicle_object ~= 0) then
  78.                 local a,b,c = read_vector3d(vehicle_object + 0x5C)
  79.                 x=x+a
  80.                 y=y+b
  81.                 z=z+c
  82.             elseif (bit.band(read_dword(player_object + 0x208),1) == 1) and (crouch[i] == nil) and (delay[i] == 0) then
  83.                 local hash = get_var(i,"$hash")
  84.                 for k=#bodies,1,-1 do
  85.                     if(bodies[k].KillerHash == hash) then
  86.                         if(DistanceFormula(x,y,z,bodies[k].x,bodies[k].y,bodies[k].z) < TEABAG_RADIUS) then
  87.                             local sexact = generatesexact(sexslang)
  88.                             TEABAG_MESSAGE = "$KILLER is " .. sexact .. " with $VICTIM's corpse!"                      
  89.                             say_all(string.gsub(string.gsub(TEABAG_MESSAGE,"$VICTIM",bodies[k].OwnerName),"$KILLER",get_var(i,"$name")))
  90.                             table.remove(bodies,k)
  91.                             delay[i] = (crouch_time*30)
  92.                             crouch[i] = rand(1,6)
  93.                             if (crouch[i] == 1) then
  94.                                 timer(5000, "Bonus_Health", i)
  95.                             elseif (crouch[i] == 2) then
  96.                                 timer(5000, "Bonus_Frags", i)
  97.                             elseif (crouch[i] == 3) then   
  98.                                 timer(5000, "Bonus_Camo", i)
  99.                             elseif (crouch[i] == 4) then   
  100.                                 timer(5000, "Bonus_Speed", i)
  101.                             elseif (crouch[i] == 5) then
  102.                                 timer(5000, "Bonus_OverShield", i)
  103.                             end
  104.                         end
  105.                     end
  106.                 end            
  107.             elseif (bit.band(read_dword(player_object + 0x208),1) ~= 1) and (crouch[i] ~= nil) then
  108.                 crouch[i] = nil    
  109.             end
  110.             player_locations[i] = {}
  111.             player_locations[i].x = x
  112.             player_locations[i].y = y
  113.             player_locations[i].z = z
  114.         end
  115.     end
  116. end
  117.  
  118. function OnDie(PlayerIndex,KillerIndex)
  119.     delay[PlayerIndex], crouch[PlayerIndex] = 0, nil
  120.     KillerIndex = tonumber(KillerIndex)
  121.     if(player_locations[PlayerIndex] and KillerIndex > 0 and PlayerIndex ~= KillerIndex) then
  122.         local entry = {}
  123.         entry.OwnerName = get_var(PlayerIndex,"$name")
  124.         entry.KillerHash = get_var(KillerIndex,"$hash")
  125.         entry.x = player_locations[PlayerIndex].x
  126.         entry.y = player_locations[PlayerIndex].y
  127.         entry.z = player_locations[PlayerIndex].z
  128.         entry.Expires = os.clock() + EXPIRE_TIME
  129.         bodies[#bodies + 1] = entry
  130.     end
  131. end
  132.  
  133. function DistanceFormula(x1,y1,z1,x2,y2,z2)
  134.     return math.sqrt(math.pow(x1 - x2,2) + math.pow(y1 - y2,2) + math.pow(z1 - z2,2))
  135. end
  136.  
  137. function generatesexact(sexslang)
  138.     local sexsayin = {"makin' sweet love", "bumpin' uglies", "bumpin' fuzzies", "butterin' the muffin",
  139.     "doin' the funky chicken", "ridin' the wild pony", "makin' bacon", "doggie-stylin'", "playin' hide the salami",
  140.     "slappin' bellies", "glazin' the doughnut", "burying the pickle", "shuckin' the corn-cob", "chilli-doggin",
  141.     "dirty sanchezin'", "knockin' boots", "goin' to the boneyard", "sinkin' the sausage", "marinatin' the mutton",
  142.     "ridin' the skin bus to tuna town", "hidin' the canoli", "spelunkin' the bat cave", "makin' banana pudding",
  143.     "puttin' the devil into hell", "bashin' the beaver", "feedin' the kitty", "smackin' The salmon", "gettin' jiggy",
  144.     }
  145.     local sexcount = #sexsayin
  146.     local sex_verb = rand(1, sexcount+1)
  147.     local sex_type = string.format("%s",  sexsayin[sex_verb])
  148.     if (sex_type ~= nil) then
  149.         return sex_type
  150.     else
  151.         return "makin' sweet love"
  152.     end
  153. end
  154.  
  155. function Bonus_Frags(PlayerIndex)
  156.     if get_var(0, "$gt") ~= "n/a" then
  157.         if player_alive(PlayerIndex) then
  158.             execute_command("nades me +2 1", PlayerIndex)
  159.             rprint(PlayerIndex, "Bonus: 2+ Frag Grenades!")
  160.             say_all(get_var(PlayerIndex,"$name") .. " was given a tea-bagging bonus: 2+ Frag Grenades!")   
  161.         end
  162.     end    
  163.     return false
  164. end
  165.  
  166. function Bonus_Speed(PlayerIndex)
  167.     if get_var(0, "$gt") ~= "n/a" then
  168.         local game_type = get_var(0,"$gt")
  169.         if (game_type ~= "race") then
  170.             if player_alive(PlayerIndex) then
  171.                 execute_command("s me +0.25", PlayerIndex)
  172.                 rprint(PlayerIndex, "Bonus: 125% Speed!")
  173.                 say_all(get_var(PlayerIndex,"$name") .. " was given a tea-bagging bonus: 125% Speed!")
  174.                 timer(20000, "Reset_Speed", PlayerIndex)
  175.             end
  176.         end
  177.     end
  178.     return false
  179. end
  180.  
  181. function Reset_Speed(PlayerIndex)
  182.     if get_var(0, "$gt") ~= "n/a" then
  183.         local game_type = get_var(0,"$gt")
  184.         if (game_type ~= "race") then
  185.             if player_alive(PlayerIndex) then
  186.                 execute_command("s me 1", PlayerIndex)
  187.             end
  188.         end
  189.     end
  190.     return false
  191. end
  192.  
  193. function Bonus_Health(PlayerIndex)
  194.     if get_var(0, "$gt") ~= "n/a" then
  195.         if player_alive(PlayerIndex) then
  196.             local player_object = get_dynamic_player(PlayerIndex)
  197.             if (player_object ~= 0) then
  198.                 local obj_health = tonumber(get_var(PlayerIndex, "$hp"))
  199.                 if obj_health < 1 then
  200.                     write_float(player_object + 0xE0, 1)
  201.                     rprint(PlayerIndex, "Bonus: Your health has been restored!")
  202.                     say_all(get_var(PlayerIndex,"$name") .. " was given a tea-bagging bonus: Restored Health")
  203.                 end
  204.             end
  205.         end
  206.     end
  207.     return false
  208. end
  209.  
  210. function Bonus_Camo(PlayerIndex)
  211.     if get_var(0, "$gt") ~= "n/a" then
  212.         if player_alive(PlayerIndex) then
  213.             local player_object_id = read_dword(get_player(PlayerIndex) + 0x34)
  214.             local player_object = get_dynamic_player(PlayerIndex)
  215.             if (player_object ~= 0) then       
  216.                 if (read_dword(get_object_memory(player_object_id) + 0x204) ~= 0x51) then
  217.                     camo(PlayerIndex, 20*30)
  218.                     rprint(PlayerIndex, "Bonus: You have been given active-camouflage!")
  219.                     say_all(get_var(PlayerIndex,"$name") .. " was given a tea-bagging bonus: Active-Camo")
  220.                 end
  221.             end    
  222.         end
  223.     end
  224.     return false
  225. end
  226.  
  227. function Bonus_OverShield(PlayerIndex)
  228.     if get_var(0, "$gt") ~= "n/a" then
  229.         if player_alive(PlayerIndex) then
  230.             local ObjectID = spawn_object("eqip", "powerups\\over shield") 
  231.             powerup_interact(ObjectID, PlayerIndex)
  232.             rprint(PlayerIndex, "Bonus: You have been given an over-shield!")
  233.             say_all(get_var(PlayerIndex,"$name") .. " was given a tea-bagging bonus: Over-Shield")         
  234.         end
  235.     end
  236.     return false
  237. end    
  238.  
  239. function OnError(Message)
  240.     print(debug.traceback())
  241. end
  242.    
  243. -- Created by H® Shaft
  244. -- Visit http://halorace.org/forum/index.php
  245.  
  246. -- The player -db-GoNe/Juhleek - a well spoken liar, cheat.
  247. -- -db- is: "diverging from the believable" - How ironic. A race clan where admins use rcon to favor themselves to win.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement