@Emperor_Penguin
i have downloaded your mod and tested it.
well, there are some functions you maybe want to check.
https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/AI/aiarchetype-managerloader.lua#L106
UnitCapWatchThread will kill units if the unitcap is reached (ignoring it will not help here)
https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/AI/aiarchetype-managerloader.lua#L142
UnitCapWatchThreadSorian is same as above but also killing T3 units on cap
https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/AI/aiattackutilities.lua#L127
function GetBestThreatTarget() unitCapRatio is used for threat calculation
local unitCapRatio = GetArmyUnitCostTotal(aiBrain:GetArmyIndex()) / GetArmyUnitCap(aiBrain:GetArmyIndex())
# if we have no threat... what happened? Also don't attack things way stronger than us
if myThreat <= IgnoreStrongerTargetsIfWeakerThan
and (myThreat == 0 or enemyThreat / (myThreat + friendlyThreat) > IgnoreStrongerTargetsRatio)
and unitCapRatio < IgnoreStrongerUnitCap then
continue
end
https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/editor/UnitCountBuildConditions.lua#L906
https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/editor/UnitCountBuildConditions.lua#L915
UnitCapCheckGreater and UnitCapCheckLess are called 248 times inside the AIbuilders in 15 files:
https://github.com/FAForever/fa/tree/deploy/fafdevelop/lua/AI/AIBuilders
they all need to be checked!
Example:
{ UCBC, 'UnitCapCheckLess', { .8 } },
(thats the part that will cost the most time)
not related to AI:
In case you ignore the unitcap you need to tell the player brain that you do so.
brain.IgnoreArmyCaps = true
You used SetIgnoreArmyUnitCap(i, true)
but you need to call this funtion:
IgnoreArmyUnitCap()
https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/aibrain.lua#L932
So at the moment these functions are failing:
https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/ScenarioFramework.lua#L226
GiveUnitToArmy is disabling the SetIgnoreArmyUnitCap and would only reenable it if brain.IgnoreArmyCaps is set to true
https://github.com/FAForever/fa/blob/deploy/fafdevelop/lua/sim/Unit.lua#L789
Unit:OnCaptured() is also disabling the ignore for the unit transfer on capture
https://github.com/FAForever/fa/blob/deploy/fafdevelop/units/XEB2402/XEB2402_Script.lua#L152
The Experimental Satellite System has a hook for OnCaptured and is also failing on capture
As i posted above, just increasing or disabling the unitcap is not working.