Code:
s_axis_munition_units =
{
-- NAME, MUNITION RATE, MUNITION FLOAT, ANTICLASS(TANK, INFANTRY, LV, STRUCTURE)
[PBG_GetID(SBP.AXIS_MORTAR)] = {35, 270, {1, 3, 1, 3} },
[PBG_GetID(SBP.AXIS_GRENADIER)] = {35, 250, {0, 5, 4, 2} },
[PBG_GetID(SBP.AXIS_HALFTRACK)] = {60, 450, {6, 5, 9, 5} },
[PBG_GetID(SBP.AXIS_PIONEER)] = {40, 200, {0.5, 1, 0.5, 3} },
[PBG_GetID(SBP.AXIS_STORMTROOPER)] = {40, 425, {0, 5, 4, 2} }, -- bundled grenade factored in
[PBG_GetID(SBP.AXIS_VOLKSGRENADIER)] = {30, 280, {0, 5, 0, 1} },
[PBG_GetID(SBP.AXIS_ARMOURCAR)] = {40, 280, {1, 6, 6, 2} },
[PBG_GetID(SBP.AXIS_HEAVYMG)] = {30, 260, {0, 5, 0, 1} },
[PBG_GetID(SBP.AXIS_50MM)] = {30, 310, {4, 0, 6, 3} },
[PBG_GetID(SBP.AXIS_PANZER_FLAK)] = {45, 410, {6, 10, 10, 9} },
[PBG_GetID(SBP.AXIS_PANTHER)] = {45, 640, {10, 7, 7, 7} },
[PBG_GetID(SBP.AXIS_PANZER)] = {45, 410, {8, 7, 7, 7} },
[PBG_GetID(SBP.AXIS_STUG)] = {40, 340, {5, 4, 6, 3} },
[PBG_GetID(SBP.AXIS_150MM)] = {999, 999, {5, 4, 7, 3} },
[PBG_GetID(SBP.AXIS_KNIGHTSCROSS)] = {999, 999, {7, 7, 9, 9} },
[PBG_GetID(SBP.AXIS_OFFICER)] = {999, 999, {7, 7, 9, 9} },
}
function Axis_SpecialUnitDemand( unitPBG, currentDemand )
local demand_increase = 0
local pbgid = PBG_GetID( unitPBG )
local mun_unit = s_axis_munition_units[ pbgid ]
if (mun_unit) then
if (AIResource_GetCurrentResourceRate( s_selfplayer ).manpower > mun_unit[1] or
AIResource_GetCurrentResources( s_selfplayer ).manpower > mun_unit[2]) then
local anti_class = {[0]=mun_unit[3][1],[1]=mun_unit[3][2],[2]=mun_unit[3][3],[3]=mun_unit[3][4]}
demand_increase = SquadAntiClassDemandFromRating( anti_class )
--purchase_trace(("munition-demand-bonus:"..demand_increase)
end
end
if (PBG_IsSame( unitPBG, s_engineer )) then
return EngineerPioneerDemand() + demand_increase
elseif (PBG_IsSame( unitPBG, SBP.AXIS_HEAVYMG )) then
local count = UtilPBG_CountTotal( unitPBG )
if (count > 2) then
return DEMAND_NeverBuild
end
return demand_increase
elseif (PBG_IsSame( unitPBG, SBP.AXIS_STORMTROOPER )) then
local count = UtilPBG_CountTotal( unitPBG )
if (count > 2) then
return DEMAND_NeverBuild
end
return demand_increase
elseif (PBG_IsSame( unitPBG, SBP.AXIS_OFFICER )) then
return DEMAND_NeverBuild
elseif (PBG_IsSame( unitPBG, SBP.AXIS_KNIGHTSCROSS )) then
return DEMAND_NeverBuild
elseif (PBG_IsSame( unitPBG, SBP.AXIS_150MM )) then
return DEMAND_NeverBuild
elseif (PBG_IsSame( unitPBG, SBP.AXIS_GOLIATH )) then
-- always make sure there are at least 3 support units on your side before building a goliath
-- if (cache.military_non_engineer_count < 3) then
return DEMAND_NeverBuild
-- end
-- local count = UtilPBG_CountTotal( unitPBG )
--aitrace(("GOLIATH COUNT:"..count)
-- if (count>0) then
-- hard limit of 3-4
-- if (count>3) then
-- return DEMAND_NeverBuild
-- end
-- decrease demand by X for each additional goliath so we reduce the number of these units at the same time
-- return -count*100
-- end
elseif (PBG_IsSame( unitPBG, SBP.AXIS_HALFTRACK )) then
-- do we have or are we thinking about phase3?
local upg_count = UtilPBG_CountAliveOrProduced( UPG.AXIS_PHASE3 )
if (upg_count == 0) then
return DEMAND_NeverBuild
end
end
-- nebelwerfer - build these when what? They don't have anticlass ratings so we need to add some in here
-- if we have lots of this particular unit we can adjust its demand, possibly do a multiplier on it
return demand_increase
end
OK, This is the rules_unit_purchase.ai. I have added addtional elements to the Axis table. I switched from using .munitions as one of the primary gates to building something to .manpower, and I have created some rules for what I definitely don't want to build and what I only want a certain number of. This "works" so far, but I pulled the anti number out of my tail and things need to be refined, but it will give you an idea of what can be done.