Advertisement
HR_Shaft

Super Melee v1 for Phasor v2

May 11th, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.10 KB | None | 0 0
  1. --[[ ###        Super Melee v1       ###]]--
  2. --[[ ###  by H® Shaft for Phasor v2  ###]]--
  3.  
  4. -- Creates a super melee that damages enemies in or out of vehicles.  Just press your melee key (F).  
  5. -- Plus, it improves gameplay for CTF flag carriers allowing them to defend/attack vehicles.
  6.  
  7. -- don't edit --
  8. melee = {}
  9.  
  10. function GetRequiredVersion()
  11.     return 200
  12. end
  13.  
  14. function OnScriptLoad(process, game, persistent)
  15.     LoadTags()
  16. end
  17.  
  18. function OnDamageLookup(receiving, causing, tagid)
  19.     local tagname, tagtype = gettaginfo(tagid)
  20.     local melee = string.find(tagname, "melee")
  21.    
  22.     if receiving then
  23.         local r_player = objectidtoplayer(receiving)
  24.     elseif causing then
  25.         local c_player = objectidtoplayer(causing)
  26.     end
  27.    
  28.     if receiving and (causing == receiving) and tagid == rocket_expl_id then       
  29.         return false
  30.     elseif receiving and causing and (receiving ~= causing) and tagid == rocket_expl_id then   
  31.         if c_player and r_player then
  32.             if getteam(c_player) == getteam(r_player) then
  33.                 return false
  34.             else
  35.                 odl_multiplier(2)
  36.             end
  37.         end
  38.     elseif receiving and causing and (receiving ~= causing) and melee then 
  39.         if c_player and r_player then  
  40.             if getteam(c_player) == getteam(r_player) then
  41.                 return false
  42.             else
  43.                 odl_multiplier(5)
  44.             end
  45.         end
  46.     end
  47.    
  48.     return nil 
  49. end
  50.  
  51. function OnClientUpdate(player)
  52.     local m_objectId = getplayerobjectid(player)
  53.     if m_objectId then
  54.         local m_object = getobject(m_objectId) 
  55.         local supermelee = readbyte(m_object + 0x2A4)
  56.         if supermelee == 7 then
  57.             writebyte(m_object + 0x2A4, 0)
  58.             local x,y,z = getobjectcoords(m_objectId)
  59.             melee[player] = registertimer(0, "SuperMelee", {player, x, y, z})
  60.         end
  61.     end
  62. end
  63.  
  64. function SuperMelee(id, count, arg)
  65.     local player = arg[1]
  66.     local x,y,z = arg[2], arg[3], arg[4]
  67.     if count == 1 then
  68.         if player and x and y and z then
  69.             local m_objectId = getplayerobjectid(player)
  70.             if m_objectId then
  71.                 local grunt = generategrunt(grunt)
  72.                 local supermelee = createobject(rocket_id, m_objectId, 0, false, x, y, z+3)
  73.                 local m_melee = getobject(supermelee)
  74.                 writefloat(m_melee + 0x70, -5)
  75.                 sendconsoletext(player, grunt)
  76.             end    
  77.         end
  78.     end
  79.     return false
  80. end
  81.  
  82. function OnGameEnd(stage)
  83.     if stage == 1 then
  84.         for i=0,15 do
  85.             if getplayer(i) then
  86.                 if melee[i] then
  87.                     removetimer(melee[i])
  88.                     melee[i] = nil
  89.                 end            
  90.             end
  91.         end    
  92.     end
  93. end
  94.  
  95. function LoadTags()
  96.     rocket_expl_id = gettagid("jpt!", "weapons\\rocket launcher\\explosion")
  97.     rocket_id = gettagid("proj", "weapons\\rocket launcher\\rocket")
  98. end
  99.  
  100. function generategrunt(grunt)
  101.     local gruntcount = #grunt
  102.     local rand_grunt = getrandomnumber(1, gruntcount+1)
  103.     local grunt_type = string.format("%s",  grunt[rand_grunt])
  104.     if grunt_type then
  105.         return grunt_type
  106.     else
  107.         return nil
  108.     end
  109. end
  110.  
  111. grunt = {"Uhn!", "Hiyah!", "Umph!", "Doh!", "Fuuuh!", "Efff!", "Nuh!", "Arrg!", "Ack!", "Boing!", "Thwack!"}
  112.  
  113. -- Created by H® Shaft thank you to Oxide, AelitePrime, Nugget & Wizard.
  114. -- Visit http://halorace.org/forum/index.php?topic=514.0 or
  115. -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement