Hmmm... I do not know for sure. Normally, even if there is no plan the AI will spawn something...
As to why your own plan is not taken into account, ... There are many factors that come into play and I cannot remotely suggest anything.
Now here is the code for changing (even limiting to 0) the number of squads produced, based on plan.
What follows, is the code as appears in Chaos Daemons (latest build), you will have to modify names appropriately.
So, set the SquadLimits normally, in your YOUR_RACEstrategyinfo.ai file. Nothing changed here.
Then, use the following code in your YOUR_RACEbuildbasestrategy.ai file, and only include the squads that you want to change their SquadLimits - the others will not change, of course:
a) go into your YOUR_RACEBuildBaseStrategy:ChooseBuildProgram() function, and when your code chooses a strategy, add a call to the new function that changes the limits. Here is an example from Chaos Daemons:
function DaemonsBuildBaseStrategy:ChooseBuildProgram()
.....
if (iRandom <= iBuildProgram1) then
g_iHarassingLeader = 1
self:SetSquadLimitsBasedOnStrategy(1)
return 1
elseif (iRandom <= iBuildProgram2) then
g_iHarassingLeader = 2
self:SetSquadLimitsBasedOnStrategy(2)
return 2
.....
As you can see, there is a call to the SetSquadLimitsBasedOnStrategy function. This is the one that changes the squad limits.
And this function is VERY simple!!! (put it anywhere into your YOUR_RACEbuildbasestrategy.ai file. I have but it immediately after the DaemonsBuildBaseStrategy:ChooseBuildProgram() function, for consistency). So here it is:
function DaemonsBuildBaseStrategy:SetSquadLimitsBasedOnStrategy(iStrategy)
if iStrategy == 1 then
-- Khorne
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_flesh_hound = math.random(4,6)
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_bloodletters = math.random(5,8)
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_plague_bearers = math.random(1,2)
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_fiends = 0
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_fiends_advanced = 0
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_daemonettes = 0
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_screamers = math.random(1,2)
elseif iStrategy == 2 then
-- Slaanesh
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_flesh_hound = 0
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_bloodletters = 0
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_plague_bearers = math.random(1,2)
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_fiends = 0
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_fiends_advanced = math.random(4,6)
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_daemonettes = math.random(3,5)
BuildBaseStrategyInfo.deamons_race.SquadLimits.standard.daemon_squad_screamers = math.random(1,2)
elseif iStrategy == 3 then
...
As you can see, it CANNOT get any simpler.
What it does, is simply putting new values to the SquadLimits sub-array, based on strategy chosen.
QUITE simple :p
If you have any issues, please let me know. For Chaos Daemons - where we DO want specific roster based on strategy, it works flawlessly.
NOTE: Another update that I am ALWAYS coding in AI, (and updated the vanilla TAU ai in Unification Bugfix), is a check, on AI re-initialisation.
See, if the AI has already chosen a tactic, and this tactic is exclusive (like in chaos daemons), then you want the AI to ALWAYS re-select THAT strategy, on re-initialisation (for example after a save->load).
So in my ChooseBuildProgram() I make an additional check at the beginning, to see WHICH strategy to return.
Here is an example from Chaos Daemons.
function DaemonsBuildBaseStrategy:ChooseBuildProgram()
-- Check build program count
if (table.getn(self.info.BuildPrograms) ~= 5) then
return BuildBaseStrategy.ChooseBuildProgram(self)
end
-- If a Mark has already been chosen (from a saved game, change players wincondition, etc.),
-- continue with that Program and do not change, or the tech will be messed-up.
if cpu_manager.cpu_player:IsResearchComplete("daemons_mark_khorne") then
g_iHarassingLeader = 1
self:SetSquadLimitsBasedOnStrategy(1)
return 1
elseif cpu_manager.cpu_player:IsResearchComplete("daemons_mark_slaanesh") then
g_iHarassingLeader = 2
self:SetSquadLimitsBasedOnStrategy(2)
return 2
elseif cpu_manager.cpu_player:IsResearchComplete("daemons_mark_tzeentch") then
g_iHarassingLeader = 3
self:SetSquadLimitsBasedOnStrategy(3)
return 3
elseif cpu_manager.cpu_player:IsResearchComplete("daemons_mark_nurgle") then
g_iHarassingLeader = 4
self:SetSquadLimitsBasedOnStrategy(4)
return 4
end
-- If no strategy program has been chosen, chose one.
-- Get map size and closest enemy distance
local sMapSize, iClosestEnemyDistance = self:GetMapSize()
...
As you can see, if there IS a strategy chosen (the checks) the AI returns THAT strategy (first it sets the new limits, of course).
The above method checks for a Research. If you need code for a structure-based strategy selection, just see the Witch Hunters Code :grad: