Advertisement
Rochet2

Untitled

Jan 27th, 2012
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | None | 0 0
  1. local T = {}
  2. local function OnCombat(pUnit, event, pAttacker)
  3.     T[tostring(pUnit)] = CreateLuaEvent(function() HPCheck(pUnit) end, 5000, 17280)
  4. end
  5.  
  6. local function HPCheck(pUnit)
  7.     if(pUnit:GetHealthPct() <= 20) then
  8.         for k,target in pairs(pUnit:GetInRangePlayers()) do
  9.             target:CastSpell(9220)
  10.         end
  11.         if(T[tostring(pUnit)]) then
  12.             DestroyLuaEvent(T[tostring(pUnit)])
  13.         end
  14.     end
  15. end
  16.  
  17. do
  18.     local QUERY = WorldDBQuery("SELECT Entry FROM creature_proto WHERE boss = 1")
  19.     for i = 1, QUERY:GetRowCount() do
  20.         RegisterUnitEvent(QUERY:GetColumn(0):GetLong(), 1, OnCombat)
  21.     end
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement