Actor.Patrol*: make sure that the actor is still alive
This commit is contained in:
@@ -214,19 +214,23 @@ Actor.Guard = function(actor, target)
|
||||
end
|
||||
|
||||
Actor.Patrol = function(actor, waypoints, wait, loop)
|
||||
Utils.Do(waypoints, function(wpt)
|
||||
Actor.AttackMove(actor, wpt.Location, 3)
|
||||
Actor.Wait(actor, wait or 0)
|
||||
end)
|
||||
if loop or loop == nil then
|
||||
Actor.CallFunc(actor, function() Actor.Patrol(actor, waypoints, wait, loop) end)
|
||||
if not Actor.IsDead(actor) then
|
||||
Utils.Do(waypoints, function(wpt)
|
||||
Actor.AttackMove(actor, wpt.Location, 3)
|
||||
Actor.Wait(actor, wait or 0)
|
||||
end)
|
||||
if loop or loop == nil then
|
||||
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
|
||||
Actor.Patrol(actor, waypoints, wait, false)
|
||||
if not func(actor) then
|
||||
Actor.CallFunc(actor, function() Actor.PatrolUntil(actor, waypoints, wait, func) 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
|
||||
|
||||
Reference in New Issue
Block a user