Merge pull request #8014 from abcdefg30/hijacksurvival

Fix a problem with hijackers in the survival maps
This commit is contained in:
Oliver Brakmann
2015-05-01 15:58:47 +02:00
2 changed files with 34 additions and 2 deletions

View File

@@ -66,6 +66,7 @@ SovietBuildings = { Barrack1, SubPen, RadarDome, AdvancedPowerPlant1, AdvancedPo
IdleTrigger = function(units, dest)
Utils.Do(units, function(unit)
Trigger.OnIdle(unit, function()
local bool = Utils.All(units, function(unit) return unit.IsIdle end)
if bool then
@@ -76,22 +77,35 @@ IdleTrigger = function(units, dest)
if not unit.IsDead then
if dest then unit.AttackMove(dest, 3) end
Trigger.OnIdle(unit, unit.Hunt)
Trigger.OnCapture(unit, function()
Trigger.ClearAll(unit)
end)
end
end)
end
end)
end
end)
Trigger.OnDamaged(unit, function()
Utils.Do(units, function(unit)
if not unit.IsDead then
Trigger.ClearAll(unit)
Trigger.AfterDelay(0, function()
if not unit.IsDead then Trigger.OnIdle(unit, unit.Hunt) end
if not unit.IsDead then
Trigger.OnIdle(unit, unit.Hunt)
Trigger.OnCapture(unit, function()
Trigger.ClearAll(unit)
end)
end
end)
end
end)
end)
Trigger.OnCapture(unit, function()
Trigger.ClearAll(unit)
end)
end)
end

View File

@@ -55,6 +55,10 @@ GuardHarvester = function(unit, harvester)
unit.AttackMove(start)
end
end)
Trigger.OnCapture(unit, function()
Trigger.ClearAll(unit)
end)
end
end
@@ -118,12 +122,20 @@ SpawnSovietVehicle = function(spawnpoints, rallypoints)
local rally = Utils.RandomInteger(1, #rallypoints + 1)
local unit = Reinforcements.Reinforce(soviets, { Utils.Random(SovietVehicles) }, { spawnpoints[route].Location, rallypoints[rally].Location })[1]
IdleHunt(unit)
Trigger.OnCapture(unit, function()
Trigger.ClearAll(unit)
end)
end
SpawnAndAttack = function(types, entry)
local units = Reinforcements.Reinforce(soviets, types, { entry })
Utils.Do(units, function(unit)
IdleHunt(unit)
Trigger.OnCapture(unit, function()
Trigger.ClearAll(unit)
end)
end)
return units
end
@@ -174,7 +186,7 @@ FinalAttack = function()
insert(units4)
insert(units5)
Trigger.OnAllKilled(units, function()
Trigger.OnAllKilledOrCaptured(units, function()
if not DestroyObj then
Media.DisplayMessage("Excellent work Commander! We have reinforced our position enough to initiate a counter-attack.", "Incoming Report")
DestroyObj = allies.AddPrimaryObjective("Destroy the remaining Soviet forces in the area!")
@@ -310,6 +322,9 @@ SetupSoviets = function()
GuardHarvester(unit, Harvester1)
end)
end)
Trigger.OnCapture(Harvester1, function()
Trigger.ClearAll(Harvester1)
end)
Harvester2.FindResources()
Trigger.OnDamaged(Harvester2, function()
@@ -327,6 +342,9 @@ SetupSoviets = function()
end)
end)
end)
Trigger.OnCapture(Harvester2, function()
Trigger.ClearAll(Harvester2)
end)
Trigger.AfterDelay(0, function()
local buildings = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Owner == soviets and self.HasProperty("StartBuildingRepairs") end)