stoneharry

Untitled

Nov 14th, 2012
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. function ZG.VAR.FireBallSpawn(pUnit, Event)
  2.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) -- unselectable
  3.     pUnit:Root()
  4.     pUnit:SetCombatCapable(false)
  5.     pUnit:RegisterEvent("ZG.VAR.SendFireballVisual", 1000, 1)
  6.     pUnit:RegisterEvent("ZG.VAR.GrowBiggerFireball", 2000, 14)
  7.     pUnit:RegisterEvent("ZG.VAR.FireballExplode", 29000, 1)
  8. end
  9.  
  10. function ZG.VAR.SendFireballVisual(pUnit)
  11.     pUnit:CastSpell(71706) -- perm visual
  12.     pUnit:CastSpell(74710) -- spawn visual
  13. end
  14.  
  15. function ZG.VAR.GrowBiggerFireball(pUnit)
  16.     pUnit:SetScale(math.random(5, 20) / 10)
  17. end
  18.  
  19. function ZG.VAR.FireballExplode(pUnit)
  20.  
  21.     local x2 = pUnit:GetX()
  22.     local y2 = pUnit:GetY()
  23.    
  24.     pUnit:CastSpell(76010) -- visual
  25.     pUnit:RemoveAura(71706) -- main visual
  26.    
  27.     for k,plr in pairs(pUnit:GetInRangePlayers()) do
  28.         local distance = plr:GetDistanceYards(pUnit)
  29.         if plr:GetPhase() == 2 and distance < 20 then
  30.        
  31.             local x1 = plr:GetX()
  32.             local y1 = plr:GetY()
  33.  
  34.             local x = x2 - x1
  35.             local y = y2 - y1
  36.            
  37.             local angle = math.pi + math.atan2(-y, -x)
  38.  
  39.             local x = x1 - ((math.random(25,30)-distance) * math.cos(angle))
  40.             local y = y1 - ((math.random(25,30)-distance) * math.sin(angle))
  41.            
  42.             local z = pUnit:GetLandHeight(x, y)
  43.             if z > 200 or z < 20 then
  44.                 z = plr:GetZ()
  45.             end
  46.            
  47.             local minimum = distance*40
  48.             local maximum = distance*50
  49.            
  50.             pUnit:Strike(plr, 2, 72134, minimum, maximum, 1)
  51.             plr:MoveKnockback(x, y, z, 2, 9)
  52.            
  53.         end
  54.     end
  55. end
  56.  
  57. RegisterUnitEvent(71706, 18, "ZG.VAR.FireBallSpawn")
Advertisement
Add Comment
Please, Sign In to add comment