stoneharry

Untitled

May 18th, 2012
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. function Fill_runcoords2(player)
  2.     for i = 1, (#runcoords) do
  3.         if (runcoords2[i]) then runcoords2[i]:Despawn(1, 0); end
  4.         runcoords2[i] = player:SpawnCreature(135400, runcoords[i][1], runcoords[i][2], runcoords[i][3], 0, 35, 3600000)
  5.     end
  6. end
  7. function Fill_flyingcoords2(player)
  8.     for i = 1, (#flyingcoords) do
  9.         if (flyingcoords2[i]) then flyingcoords2[i]:Despawn(1, 0); end
  10.         flyingcoords2[i] = player:SpawnCreature(135400, flyingcoords[i][1], flyingcoords[i][2], flyingcoords[i][3], 0, 35, 3600000)
  11.     end
  12. end
  13.  
  14. function Mob_PathFind(pUnit)
  15.     if (not pUnit:IsAlive()) then return; end
  16.     local cp = pUnit:GetValue("TD_NextPoint")
  17.     local flying = pUnit:GetValue("TD_IsFlying")
  18.     local cps
  19.     if (flying) then
  20.         cps = flyingcoords2
  21.     else
  22.         cps = runcoords2
  23.     end
  24.     local x, y, z = cps[cp]:GetLocation()
  25.     local dist = pUnit:CalcToDistance(x, y, z)
  26.     if (dist < 3 and cp == (#cps)) then
  27.         creepsLeft = creepsLeft - 1
  28.         shieldvalue = shieldvalue - 5
  29.         if (shieldvalue < 1) then shieldvalue = 0; end
  30.         for _, player in pairs (pUnit:GetInRangePlayers()) do
  31.             UpdateAttempts(player, shieldvalue)
  32.         end
  33.         pUnit:RemoveEvents()
  34.         pUnit:Despawn(100, 0)
  35.     elseif (dist < 2) then
  36.         cp = cp + 1
  37.         pUnit:SetValue("TD_NextPoint", cp)
  38.         pUnit:SetUnitToFollow(cps[cp], 0, 0)
  39.     end
  40. end
  41.  
  42. function Mob_SpawnEventHandle(pUnit, Event)
  43.     pUnit:RegisterEvent("Mob_MoveAtRandom", 200, 1)
  44. end
  45.  
  46. function Mob_MoveAtRandom(pUnit)
  47.     pUnit:SetValue("TD_NextPoint", 1)
  48.     pUnit:SetValue("TD_IsFlying", false)
  49.     pUnit:SetCombatCapable(true)
  50.     pUnit:SetCombatTargetingCapable(true)
  51.     pUnit:AIDisableCombat(true)
  52.     pUnit:SetMovementFlags(1)
  53.     pUnit:SetUnitToFollow(runcoords2[1])
  54.     pUnit:RegisterEvent("Mob_PathFind", 500, 0)
  55. end
  56.  
  57. RegisterUnitEvent(17707, 18, "Mob_SpawnEventHandle")
Advertisement
Add Comment
Please, Sign In to add comment