ChooseHBO1 = { { type = "hbox", pos = CPos.New(32, 91), cost = 750 } } BuildHBO1 = function() if not CheckExistenceForFAC1() then Trigger.AfterDelay(DateTime.Seconds(1), BuildHBO1) return end for i,v in ipairs(ChooseHBO1) do if not v.exists then PlaceHBO1(v) return end end Trigger.AfterDelay(DateTime.Seconds(5), BuildHBO1) end PlaceHBO1 = function(building) Trigger.AfterDelay(Actor.BuildTime(building.type), function() if not CheckExistenceForFAC1() then Trigger.AfterDelay(DateTime.Seconds(1), BuildHBO1) return elseif Player1.Resources <= 299 then Trigger.AfterDelay(DateTime.Seconds(1),BuildHBO1) 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), BuildHBO1) end) end CheckHealthForHBO1 = function() Trigger.OnDamaged(HBO1, function() if HBO1.Owner == Player1 and HBO1.Health < HBO1.MaxHealth * 3/4 then HBO1.StartBuildingRepairs() end if HBO1.Owner == Player1 and HBO1.Health < HBO1.MaxHealth * 1/4 then HBO1.Sell() end SendDefence() end) Trigger.OnRemovedFromWorld(HBO1, BuildHBO1) end ChooseHBO2 = { { type = "hbox", pos = CPos.New(153, 103), cost = 750 } } BuildHBO2 = function() if not CheckExistenceForFAC1() then Trigger.AfterDelay(DateTime.Seconds(1), BuildHBO2) return end for i,v in ipairs(ChooseHBO2) do if not v.exists then PlaceHBO2(v) return end end Trigger.AfterDelay(DateTime.Seconds(5), BuildHBO2) end PlaceHBO2 = function(building) Trigger.AfterDelay(Actor.BuildTime(building.type), function() if not CheckExistenceForFAC1() then Trigger.AfterDelay(DateTime.Seconds(1), BuildHBO2) return elseif Player1.Resources <= 299 then Trigger.AfterDelay(DateTime.Seconds(1),BuildHBO2) 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), BuildHBO2) end) end CheckHealthForHBO2 = function() Trigger.OnDamaged(HBO2, function() if HBO2.Owner == Player1 and HBO2.Health < HBO2.MaxHealth * 3/4 then HBO2.StartBuildingRepairs() end if HBO2.Owner == Player1 and HBO2.Health < HBO2.MaxHealth * 1/4 then HBO2.Sell() end SendDefence() end) Trigger.OnRemovedFromWorld(HBO2, BuildHBO2) end