Replace abused Map.ActorsInBox calls by Map.ActorsInWorld in all ra missions

This commit is contained in:
abcdefg30
2016-04-08 17:38:17 +02:00
parent b02a9a188d
commit ec602f2090
10 changed files with 20 additions and 24 deletions

View File

@@ -145,11 +145,12 @@ InitTriggers = function()
end)
Trigger.OnKilled(ExplosiveBarrel, function()
local bridge = Map.ActorsInBox(USSRReinforcementsCameraWaypoint.CenterPosition, USSRReinforcementsEntryWaypoint.CenterPosition,
function(self) return self.Type == "bridge1" end)
if not bridge[1].IsDead then
bridge[1].Kill()
-- We need the first bridge which is returned
local bridge = Utils.Where(Map.ActorsInWorld, function(actor) return actor.Type == "bridge1" end)[1]
if not bridge.IsDead then
bridge.Kill()
end
end)
@@ -237,7 +238,7 @@ InitTriggers = function()
end)
Trigger.AfterDelay(0, function()
local bridges = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Type == "bridge1" end)
local bridges = Utils.Where(Map.ActorsInWorld, function(actor) return actor.Type == "bridge1" end)
Trigger.OnAllKilled(bridges, function()
player.MarkCompletedObjective(KillBridges)

View File

@@ -348,7 +348,7 @@ InitTriggers = function()
end)
Trigger.AfterDelay(0, function()
local bridges = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Type == "bridge1" or self.Type == "bridge2" end)
local bridges = Utils.Where(Map.ActorsInWorld, function(actor) return actor.Type == "bridge1" or actor.Type == "bridge2" end)
ExplodingBridge = bridges[1]
Trigger.OnAllKilled(bridges, function()

View File

@@ -105,9 +105,9 @@ ProtectHarvester = function(unit)
end
InitAIUnits = function()
IdlingUnits = Map.ActorsInBox(MainBaseTopLeft.CenterPosition, Map.BottomRight, function(self) return self.Owner == ussr and self.HasProperty("Hunt") end)
IdlingUnits = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == ussr and self.HasProperty("Hunt") and self.Location.Y > MainBaseTopLeft.Location.Y end)
local buildings = Map.ActorsInBox(MainBaseTopLeft.CenterPosition, Map.BottomRight, function(self) return self.Owner == ussr and self.HasProperty("StartBuildingRepairs") end)
local buildings = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == ussr and self.HasProperty("StartBuildingRepairs") end)
Utils.Do(buildings, function(actor)
Trigger.OnDamaged(actor, function(building)
if building.Owner == ussr and building.Health < building.MaxHealth * 3/4 then
@@ -255,7 +255,7 @@ ProduceAircraft = function()
Trigger.OnIdle(units[1], function()
if not target or target.IsDead or (not target.IsInWorld) then
local enemies = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Owner == greece and self.HasProperty("Health") end)
local enemies = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == greece and self.HasProperty("Health") end)
if #enemies > 0 then
target = Utils.Random(enemies)
units[1].Attack(target)

View File

@@ -168,9 +168,7 @@ SuperTankDomeInfiltrated = function()
end
SuperTanksDestruction = function()
local badGuys = Map.ActorsInBox(Map.TopLeft, Map.BottomRight,
function(self) return self.Owner == badguy and self.HasProperty("Health") end)
local badGuys = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == badguy and self.HasProperty("Health") end)
Utils.Do(badGuys, function(unit)
unit.Kill()
end)

View File

@@ -36,7 +36,7 @@ WorldLoaded = function()
end)
Trigger.AfterDelay(0, function()
local buildings = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Owner == germany and self.HasProperty("StartBuildingRepairs") end)
local buildings = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == germany and self.HasProperty("StartBuildingRepairs") end)
Utils.Do(buildings, function(actor)
Trigger.OnDamaged(actor, function(building, attacker)
if building.Owner == germany and building.Health < building.MaxHealth * 0.8 then

View File

@@ -128,7 +128,7 @@ WorldLoaded = function()
end
end)
Trigger.AfterDelay(0, function()
local buildings = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Owner == enemy and self.HasProperty("StartBuildingRepairs") end)
local buildings = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == enemy and self.HasProperty("StartBuildingRepairs") end)
Utils.Do(buildings, function(actor)
Trigger.OnDamaged(actor, function(building, attacker)
if building.Owner == enemy and building.Health < building.MaxHealth * 0.8 then

View File

@@ -1,7 +1,7 @@
IdleHunt = function(unit) if not unit.IsDead then Trigger.OnIdle(unit, unit.Hunt) end end
IdlingUnits = function()
local lazyUnits = Map.ActorsInBox(NWIdlePoint.CenterPosition, Map.BottomRight, function(actor)
local lazyUnits = Utils.Where(Map.ActorsInWorld, function(actor)
return actor.HasProperty("Hunt") and (actor.Owner == GoodGuy or actor.Owner == Greece) end)
Utils.Do(lazyUnits, function(unit)
@@ -12,7 +12,8 @@ IdlingUnits = function()
end)
end
BaseBuildings = {
BaseBuildings =
{
{ type = "powr", pos = CVec.New(3, -2), cost = 300 },
{ type = "tent", pos = CVec.New(0, 4), cost = 400 },
{ type = "hbox", pos = CVec.New(3, 6), cost = 600 },

View File

@@ -15,11 +15,7 @@ CheckForCYard = function()
end
CheckForSPen = function()
SPens = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(actor)
return actor.Type == "spen"
end)
return #SPens >=1
return Utils.Any(Map.ActorsInWorld, function(actor) return actor.Type == "spen" end)
end
RunInitialActivities = function()
@@ -36,7 +32,7 @@ RunInitialActivities = function()
IdlingUnits()
Media.PlaySpeechNotification(player, "ReinforcementsArrived")
local buildings = Map.ActorsInBox(NWIdlePoint.CenterPosition, Map.BottomRight, function(self) return self.Owner == Greece and self.HasProperty("StartBuildingRepairs") end)
local buildings = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == Greece and self.HasProperty("StartBuildingRepairs") end)
Utils.Do(buildings, function(actor)
Trigger.OnDamaged(actor, function(building)
if building.Owner == Greece and building.Health < building.MaxHealth * 3/4 then

View File

@@ -382,7 +382,7 @@ SetupSoviets = function()
end)
Trigger.AfterDelay(0, function()
local buildings = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Owner == soviets and self.HasProperty("StartBuildingRepairs") end)
local buildings = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == soviets and self.HasProperty("StartBuildingRepairs") end)
Utils.Do(buildings, function(actor)
Trigger.OnDamaged(actor, function(building)
if building.Owner == soviets and building.Health < building.MaxHealth * DamageModifier then

View File

@@ -378,7 +378,7 @@ SetupSoviets = function()
end)
Trigger.AfterDelay(0, function()
local buildings = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Owner == soviets and self.HasProperty("StartBuildingRepairs") end)
local buildings = Utils.Where(Map.ActorsInWorld, function(self) return self.Owner == soviets and self.HasProperty("StartBuildingRepairs") end)
Utils.Do(buildings, function(actor)
Trigger.OnDamaged(actor, function(building)
if building.Owner == soviets and building.Health < building.MaxHealth * 3/4 then