Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Fill_runcoords2(player)
- for i = 1, (#runcoords) do
- if (runcoords2[i]) then runcoords2[i]:Despawn(1, 0); end
- runcoords2[i] = player:SpawnCreature(135400, runcoords[i][1], runcoords[i][2], runcoords[i][3], 0, 35, 3600000)
- end
- end
- function Fill_flyingcoords2(player)
- for i = 1, (#flyingcoords) do
- if (flyingcoords2[i]) then flyingcoords2[i]:Despawn(1, 0); end
- flyingcoords2[i] = player:SpawnCreature(135400, flyingcoords[i][1], flyingcoords[i][2], flyingcoords[i][3], 0, 35, 3600000)
- end
- end
- function Mob_PathFind(pUnit)
- if (not pUnit:IsAlive()) then return; end
- local cp = pUnit:GetValue("TD_NextPoint")
- local flying = pUnit:GetValue("TD_IsFlying")
- local cps
- if (flying) then
- cps = flyingcoords2
- else
- cps = runcoords2
- end
- local x, y, z = cps[cp]:GetLocation()
- local dist = pUnit:CalcToDistance(x, y, z)
- if (dist < 3 and cp == (#cps)) then
- creepsLeft = creepsLeft - 1
- shieldvalue = shieldvalue - 5
- if (shieldvalue < 1) then shieldvalue = 0; end
- for _, player in pairs (pUnit:GetInRangePlayers()) do
- UpdateAttempts(player, shieldvalue)
- end
- pUnit:RemoveEvents()
- pUnit:Despawn(100, 0)
- elseif (dist < 2) then
- cp = cp + 1
- pUnit:SetValue("TD_NextPoint", cp)
- pUnit:SetUnitToFollow(cps[cp], 0, 0)
- end
- end
- function Mob_SpawnEventHandle(pUnit, Event)
- pUnit:RegisterEvent("Mob_MoveAtRandom", 200, 1)
- end
- function Mob_MoveAtRandom(pUnit)
- pUnit:SetValue("TD_NextPoint", 1)
- pUnit:SetValue("TD_IsFlying", false)
- pUnit:SetCombatCapable(true)
- pUnit:SetCombatTargetingCapable(true)
- pUnit:AIDisableCombat(true)
- pUnit:SetMovementFlags(1)
- pUnit:SetUnitToFollow(runcoords2[1])
- pUnit:RegisterEvent("Mob_PathFind", 500, 0)
- end
- RegisterUnitEvent(17707, 18, "Mob_SpawnEventHandle")
Advertisement
Add Comment
Please, Sign In to add comment