Actor.Patrol*: make sure that the actor is still alive

This commit is contained in:
Oliver Brakmann
2014-03-17 17:55:40 +01:00
parent 64a18389b7
commit 0eb1e2cc6d

View File

@@ -214,6 +214,7 @@ Actor.Guard = function(actor, target)
end
Actor.Patrol = function(actor, waypoints, wait, loop)
if not Actor.IsDead(actor) then
Utils.Do(waypoints, function(wpt)
Actor.AttackMove(actor, wpt.Location, 3)
Actor.Wait(actor, wait or 0)
@@ -222,11 +223,14 @@ Actor.Patrol = function(actor, waypoints, wait, loop)
Actor.CallFunc(actor, function() Actor.Patrol(actor, waypoints, wait, loop) end)
end
end
end
Actor.PatrolUntil = function(actor, waypoints, wait, func)
if func == nil then error("No function specified", 2) end
if not Actor.IsDead(actor) then
Actor.Patrol(actor, waypoints, wait, false)
if not func(actor) then
Actor.CallFunc(actor, function() Actor.PatrolUntil(actor, waypoints, wait, func) end)
end
end
end