local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local ScenarioFramework = import('/lua/ScenarioFramework.lua')
function OnPopulate()
ScenarioUtils.InitializeArmies()
ScenarioFramework.SetPlayableArea('AREA_1' , false)
end
function OnStart(self)
ScenarioInfo.MapAlreadyExpanded = false
ForkThread(MapExpandConditions)
end
function MapExpandConditions()
-- This will make map expand after 90% of the mexes are built or after 10 minutes.
ScenarioFramework.CreateTimerTrigger(MapExpand, 60*10, true) -- This function is using seconds, change as needed.
local MexToBuild = CountMexMarkersInArea('AREA_1') * 0.9 -- Currently set to 90% of all mexes, change it as you need.
while not ScenarioInfo.MapAlreadyExpanded do
local curMexies = 0
for _, brain in ArmyBrains do
curMexies = curMexies + table.getn(ScenarioFramework.GetCatUnitsInArea(categories.MASSEXTRACTION, 'AREA_1', brain))
end
if curMexies > MexToBuild then
if not ScenarioInfo.MapAlreadyExpanded then
MapExpand()
end
break
end
WaitSeconds(1)
end
end
function MapExpand()
if ScenarioInfo.MapAlreadyExpanded == false then
ScenarioInfo.MapAlreadyExpanded = true
ScenarioFramework.SetPlayableArea('AREA_2' , true)
end
end
function CountMexMarkersInArea(area)
local rect = ScenarioUtils.AreaToRect(area)
local mexNum = 0
for markerName, markerTable in Scenario.MasterChain['_MASTERCHAIN_'].Markers do
if string.find(markerName, "Mass*") then
if ScenarioUtils.InRect(markerTable.position, rect) then
mexNum = mexNum + 1
end
end
end
return mexNum
end
Statistics: Posted by speed2 — 20 Apr 2016, 09:37
Statistics: Posted by biass — 20 Apr 2016, 08:19
Statistics: Posted by Ithilis_Quo — 14 Apr 2016, 17:26