reduce use of Map.Topleft and Map.Bottomright as requested in #8549

This commit is contained in:
clemty
2015-09-24 21:03:36 +02:00
parent bbdd597917
commit d4e1b1ba48
6 changed files with 49 additions and 60 deletions

View File

@@ -2,6 +2,7 @@ MCVReinforcements = { "mcv" }
InfantryReinforcements = { "e1", "e1", "e1" }
VehicleReinforcements = { "jeep" }
NodPatrol = { "e1", "e1" }
GDIBaseBuildings = { "pyle", "fact", "nuke" }
SendNodPatrol = function()
Reinforcements.Reinforce(enemy, NodPatrol, { nod0.Location, nod1.Location }, 15, function(soldier)
@@ -48,12 +49,16 @@ Reinforce = function(units)
ReinforceWithLandingCraft(units, lstStart.Location, lstEnd.Location, reinforcementsTarget.Location)
end
CheckForBase = function()
baseBuildings = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(actor)
return actor.Type == "fact" or actor.Type == "pyle" or actor.Type == "nuke"
CheckForBase = function(player)
local buildings = 0
Utils.Do(GDIBaseBuildings, function(name)
if #player.GetActorsByType(name) > 0 then
buildings = buildings + 1
end
end)
return #baseBuildings >= 3
return buildings == #GDIBaseBuildings
end
WorldLoaded = function()
@@ -102,7 +107,7 @@ Tick = function()
player.MarkFailedObjective(secureAreaObjective)
end
if DateTime.GameTime % DateTime.Seconds(1) == 0 and not player.IsObjectiveCompleted(beachheadObjective) and CheckForBase() then
if DateTime.GameTime % DateTime.Seconds(1) == 0 and not player.IsObjectiveCompleted(beachheadObjective) and CheckForBase(player) then
player.MarkCompletedObjective(beachheadObjective)
end
end

View File

@@ -53,23 +53,16 @@ OnAnyDamaged = function(actors, func)
end)
end
CheckForBase = function(player, buildings)
local checked = { }
local baseBuildings = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(actor)
if actor.Owner ~= Nod or Utils.Any(checked, function(bldng) return bldng.Type == actor.Type end) then
return false
end
CheckForBase = function(player)
local buildings = 0
local found = false
for i = 1, #buildings, 1 do
if actor.Type == buildings[i] then
found = true
checked[#checked + 1] = actor
end
Utils.Do(NodBaseBuildings, function(name)
if #player.GetActorsByType(name) > 0 then
buildings = buildings + 1
end
return found
end)
return #baseBuildings >= 3
return buildings == #NodBaseBuildings
end
DfndTriggerFunction = function()
@@ -231,7 +224,7 @@ Tick = function()
end
end
if DateTime.GameTime % DateTime.Seconds(1) == 0 and not Nod.IsObjectiveCompleted(NodObjective1) and CheckForBase(Nod, NodBaseBuildings) then
if DateTime.GameTime % DateTime.Seconds(1) == 0 and not Nod.IsObjectiveCompleted(NodObjective1) and CheckForBase(Nod) then
Nod.MarkCompletedObjective(NodObjective1)
end

View File

@@ -149,7 +149,7 @@ Tick = function()
Nod.MarkCompletedObjective(NodObjective2)
end
if DateTime.GameTime % DateTime.Seconds(1) == 0 and not Nod.IsObjectiveCompleted(NodObjective1) and CheckForBase(Nod, NodBaseBuildings) then
if DateTime.GameTime % DateTime.Seconds(1) == 0 and not Nod.IsObjectiveCompleted(NodObjective1) and CheckForBase(Nod) then
Nod.MarkCompletedObjective(NodObjective1)
end
@@ -158,23 +158,16 @@ Tick = function()
end
end
CheckForBase = function(player, buildings)
local checked = { }
local baseBuildings = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(actor)
if actor.Owner ~= Nod or Utils.Any(checked, function(bldng) return bldng.Type == actor.Type end) then
return false
end
CheckForBase = function(player)
local buildings = 0
local found = false
for i = 1, #buildings, 1 do
if actor.Type == buildings[i] then
found = true
checked[#checked + 1] = actor
end
Utils.Do(NodBaseBuildings, function(name)
if #player.GetActorsByType(name) > 0 then
buildings = buildings + 1
end
return found
end)
return #baseBuildings >= 3
return buildings == #NodBaseBuildings
end
OnAnyDamaged = function(actors, func)

View File

@@ -270,10 +270,8 @@ IdleHunt = function(unit)
end
CheckForSams = function(player)
local baseBuildings = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(actor)
return actor.Owner == Nod and actor.Type == 'sam' end)
return #baseBuildings >= 3
local sams = Nod.GetActorsByType("sam")
return #sams >= 3
end
checkProduction = function(player)