From 3a2bb75e01f9941522564826d859eac383e0f62e Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Tue, 3 Jun 2014 20:02:55 +0200 Subject: [PATCH 1/2] Check team members' health in Team.Do function --- mods/common/lua/team.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mods/common/lua/team.lua b/mods/common/lua/team.lua index 909b430137..863e904019 100644 --- a/mods/common/lua/team.lua +++ b/mods/common/lua/team.lua @@ -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) From 89b25c10d6b7cd2692b8c6d24cc135aa6c240b31 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Tue, 3 Jun 2014 20:04:02 +0200 Subject: [PATCH 2/2] Remove now redundant Actor.IsDead checks from mission scripts --- mods/cnc/maps/gdi04a/gdi04a.lua | 12 ++++-------- mods/cnc/maps/gdi04b/gdi04b.lua | 6 +----- mods/ra/maps/intervention/mission.lua | 16 ++++++---------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/mods/cnc/maps/gdi04a/gdi04a.lua b/mods/cnc/maps/gdi04a/gdi04a.lua index d9c27d5dc9..fda92a579e 100644 --- a/mods/cnc/maps/gdi04a/gdi04a.lua +++ b/mods/cnc/maps/gdi04a/gdi04a.lua @@ -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 + Actor.OnIdle(actor, Actor.Hunt) + Actor.OnKilled(actor, KillCounter) 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 + Actor.OnIdle(actor, Actor.Hunt) + Actor.OnKilled(actor, KillCounter) end) end) end diff --git a/mods/cnc/maps/gdi04b/gdi04b.lua b/mods/cnc/maps/gdi04b/gdi04b.lua index 23a4e6f061..b96b436f06 100644 --- a/mods/cnc/maps/gdi04b/gdi04b.lua +++ b/mods/cnc/maps/gdi04b/gdi04b.lua @@ -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) diff --git a/mods/ra/maps/intervention/mission.lua b/mods/ra/maps/intervention/mission.lua index 8f861fe116..d5700b24dc 100644 --- a/mods/ra/maps/intervention/mission.lua +++ b/mods/ra/maps/intervention/mission.lua @@ -77,12 +77,10 @@ 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 + Actor.Stop(actor) + Actor.Fly(actor, exitPoint.CenterPosition) + Actor.FlyOffMap(actor) + Actor.RemoveSelf(actor) end BaseRaid = function() @@ -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 + Actor.Stop(g) + Actor.AttackMove(g, h.Location, 3) end) end) end)