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) IdleTrigger = function(units, dest)
Utils.Do(units, function(unit) Utils.Do(units, function(unit)
Trigger.OnIdle(unit, function() Trigger.OnIdle(unit, function()
local bool = Utils.All(units, function(unit) return unit.IsIdle end) local bool = Utils.All(units, function(unit) return unit.IsIdle end)
if bool then if bool then
@@ -76,21 +77,34 @@ IdleTrigger = function(units, dest)
if not unit.IsDead then if not unit.IsDead then
if dest then unit.AttackMove(dest, 3) end if dest then unit.AttackMove(dest, 3) end
Trigger.OnIdle(unit, unit.Hunt) Trigger.OnIdle(unit, unit.Hunt)
Trigger.OnCapture(unit, function()
Trigger.ClearAll(unit)
end)
end end
end) end)
end end
end) end)
end end
end) end)
Trigger.OnDamaged(unit, function() Trigger.OnDamaged(unit, function()
Utils.Do(units, function(unit) Utils.Do(units, function(unit)
if not unit.IsDead then if not unit.IsDead then
Trigger.ClearAll(unit) Trigger.ClearAll(unit)
Trigger.AfterDelay(0, function() 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)
end
end)
end)
Trigger.OnCapture(unit, function()
Trigger.ClearAll(unit)
end) end)
end) end)
end end

View File

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