ChooseSIL1 = { { type = "silo", pos = CPos.New(39, 36), cost = 150 } } BuildSIL1 = function() if not CheckExistenceForFAC1() then Trigger.AfterDelay(DateTime.Seconds(1), BuildSIL1) return end for i,v in ipairs(ChooseSIL1) do if not v.exists then PlaceSIL1(v) return end end Trigger.AfterDelay(DateTime.Seconds(5), BuildSIL1) end PlaceSIL1 = function(building) Trigger.AfterDelay(Actor.BuildTime(building.type), function() if not CheckExistenceForFAC1() then Trigger.AfterDelay(DateTime.Seconds(1), BuildSIL1) return elseif Player1.Resources <= 299 then Trigger.AfterDelay(DateTime.Seconds(1),BuildSIL1) return end local actor = Actor.Create(building.type, true, { Owner = Player1, Location = building.pos }) Player1.Cash = Player1.Cash - building.cost building.exists = true Trigger.OnRemovedFromWorld(actor, function() building.exists = false end) Trigger.OnDamaged(actor, function(building) if building.Owner == Player1 and building.Health < building.MaxHealth * 3/4 then building.StartBuildingRepairs() end if building.Owner == Player1 and building.Health < building.MaxHealth * 1/4 then building.Sell() end SendDefence() end) Trigger.AfterDelay(DateTime.Seconds(1), BuildSIL1) end) end CheckHealthForSIL1 = function() Trigger.OnDamaged(SIL1, function() if SIL1.Owner == Player1 and SIL1.Health < SIL1.MaxHealth * 3/4 then SIL1.StartBuildingRepairs() end if SIL1.Owner == Player1 and SIL1.Health < SIL1.MaxHealth * 1/4 then SIL1.Sell() end SendDefence() end) Trigger.OnRemovedFromWorld(SIL1, BuildSIL1) end ChooseSIL2 = { { type = "silo", pos = CPos.New(49, 36), cost = 150 } } BuildSIL2 = function() if not CheckExistenceForFAC1() then Trigger.AfterDelay(DateTime.Seconds(1), BuildSIL2) return end for i,v in ipairs(ChooseSIL2) do if not v.exists then PlaceSIL2(v) return end end Trigger.AfterDelay(DateTime.Seconds(5), BuildSIL2) end PlaceSIL2 = function(building) Trigger.AfterDelay(Actor.BuildTime(building.type), function() if not CheckExistenceForFAC1() then Trigger.AfterDelay(DateTime.Seconds(1), BuildSIL2) return elseif Player1.Resources <= 299 then Trigger.AfterDelay(DateTime.Seconds(1),BuildSIL2) return end local actor = Actor.Create(building.type, true, { Owner = Player1, Location = building.pos }) Player1.Cash = Player1.Cash - building.cost building.exists = true Trigger.OnRemovedFromWorld(actor, function() building.exists = false end) Trigger.OnDamaged(actor, function(building) if building.Owner == Player1 and building.Health < building.MaxHealth * 3/4 then building.StartBuildingRepairs() end if building.Owner == Player1 and building.Health < building.MaxHealth * 1/4 then building.Sell() end SendDefence() end) Trigger.AfterDelay(DateTime.Seconds(1), BuildSIL2) end) end CheckHealthForSIL2 = function() Trigger.OnDamaged(SIL2, function() if SIL2.Owner == Player1 and SIL2.Health < SIL2.MaxHealth * 3/4 then SIL2.StartBuildingRepairs() end if SIL2.Owner == Player1 and SIL2.Health < SIL2.MaxHealth * 1/4 then SIL2.Sell() end SendDefence() end) Trigger.OnRemovedFromWorld(SIL2, BuildSIL2) end ChooseSIL3 = { { type = "silo", pos = CPos.New(39, 46), cost = 150 } } BuildSIL3 = function() if not CheckExistenceForFAC1() then Trigger.AfterDelay(DateTime.Seconds(1), BuildSIL3) return end for i,v in ipairs(ChooseSIL3) do if not v.exists then PlaceSIL3(v) return end end Trigger.AfterDelay(DateTime.Seconds(5), BuildSIL3) end PlaceSIL3 = function(building) Trigger.AfterDelay(Actor.BuildTime(building.type), function() if not CheckExistenceForFAC1() then Trigger.AfterDelay(DateTime.Seconds(1), BuildSIL3) return elseif Player1.Resources <= 299 then Trigger.AfterDelay(DateTime.Seconds(1),BuildSIL3) return end local actor = Actor.Create(building.type, true, { Owner = Player1, Location = building.pos }) Player1.Cash = Player1.Cash - building.cost building.exists = true Trigger.OnRemovedFromWorld(actor, function() building.exists = false end) Trigger.OnDamaged(actor, function(building) if building.Owner == Player1 and building.Health < building.MaxHealth * 3/4 then building.StartBuildingRepairs() end if building.Owner == Player1 and building.Health < building.MaxHealth * 1/4 then building.Sell() end SendDefence() end) Trigger.AfterDelay(DateTime.Seconds(1), BuildSIL3) end) end CheckHealthForSIL3 = function() Trigger.OnDamaged(SIL3, function() if SIL3.Owner == Player1 and SIL3.Health < SIL3.MaxHealth * 3/4 then SIL3.StartBuildingRepairs() end if SIL3.Owner == Player1 and SIL3.Health < SIL3.MaxHealth * 1/4 then SIL3.Sell() end SendDefence() end) Trigger.OnRemovedFromWorld(SIL3, BuildSIL3) end ChooseSIL4 = { { type = "silo", pos = CPos.New(49, 46), cost = 150 } } BuildSIL4 = function() if not CheckExistenceForFAC1() then Trigger.AfterDelay(DateTime.Seconds(1), BuildSIL4) return end for i,v in ipairs(ChooseSIL4) do if not v.exists then PlaceSIL4(v) return end end Trigger.AfterDelay(DateTime.Seconds(5), BuildSIL4) end PlaceSIL4 = function(building) Trigger.AfterDelay(Actor.BuildTime(building.type), function() if not CheckExistenceForFAC1() then Trigger.AfterDelay(DateTime.Seconds(1), BuildSIL4) return elseif Player1.Resources <= 299 then Trigger.AfterDelay(DateTime.Seconds(1),BuildSIL4) return end local actor = Actor.Create(building.type, true, { Owner = Player1, Location = building.pos }) Player1.Cash = Player1.Cash - building.cost building.exists = true Trigger.OnRemovedFromWorld(actor, function() building.exists = false end) Trigger.OnDamaged(actor, function(building) if building.Owner == Player1 and building.Health < building.MaxHealth * 3/4 then building.StartBuildingRepairs() end if building.Owner == Player1 and building.Health < building.MaxHealth * 1/4 then building.Sell() end SendDefence() end) Trigger.AfterDelay(DateTime.Seconds(1), BuildSIL4) end) end CheckHealthForSIL4 = function() Trigger.OnDamaged(SIL4, function() if SIL4.Owner == Player1 and SIL4.Health < SIL4.MaxHealth * 3/4 then SIL4.StartBuildingRepairs() end if SIL4.Owner == Player1 and SIL4.Health < SIL4.MaxHealth * 1/4 then SIL4.Sell() end SendDefence() end) Trigger.OnRemovedFromWorld(SIL4, BuildSIL4) end