Merge pull request #5537 from obrakmann/more-lua-crash-fixes

More lua crash fixes
This commit is contained in:
Matthias Mailänder
2014-06-04 11:03:19 +02:00
4 changed files with 16 additions and 24 deletions

View File

@@ -43,10 +43,8 @@ end
BuildNod1 = function()
Production.BuildTeamFromTemplate(nod, Nod1Template, function(team)
Team.Do(team, function(actor)
if not Actor.IsDead(actor) then
Actor.OnIdle(actor, Actor.Hunt)
Actor.OnKilled(actor, KillCounter)
end
end)
Team.AddEventHandler(team.OnAllKilled, BuildNod1)
end)
@@ -55,10 +53,8 @@ end
BuildAuto1 = function()
Production.BuildTeamFromTemplate(nod, Auto1Template, function(team)
Team.Do(team, function(actor)
if not Actor.IsDead(actor) then
Actor.OnIdle(actor, Actor.Hunt)
Actor.OnKilled(actor, KillCounter)
end
end)
end)
end

View File

@@ -38,11 +38,7 @@ end
Build = function(template, repeats, func)
Production.BuildTeamFromTemplate(nod, template, function(team)
Team.Do(team, function(actor)
if not Actor.IsDead(actor) then
func(actor)
end
end)
Team.Do(team, func)
if repeats then
Team.AddEventHandler(team.OnAllKilled, function()
Build(template, repeats, func)

View File

@@ -57,7 +57,11 @@ Team.Contains = function(team, actor)
end
Team.Do = function(team, func)
Utils.Do(team.Actors, func)
Utils.Do(team.Actors, function(actor)
if not Actor.IsDead(actor) then
func(actor)
end
end)
end
Team.Patrol = function(team, waypoints, wait, loop)

View File

@@ -77,13 +77,11 @@ FollowWaypoints = function(team, waypoints)
end
PlaneExitMap = function(actor, exitPoint)
if not Actor.IsDead(actor) then
Actor.Stop(actor)
Actor.Fly(actor, exitPoint.CenterPosition)
Actor.FlyOffMap(actor)
Actor.RemoveSelf(actor)
end
end
BaseRaid = function()
local base = Map.FindStructuresInBox(player, AlliedAreaTopLeft, AlliedAreaBottomRight)
@@ -192,10 +190,8 @@ SetupWorld = function()
Utils.Do(SovietHarvesters, function(harvester)
Actor.OnDamaged(harvester, function(h)
Team.Do(harvesterGuard, function(g)
if not Actor.IsDead(g) then
Actor.Stop(g)
Actor.AttackMove(g, h.Location, 3)
end
end)
end)
end)