ah, there is such function:
Code: Select all
--returns how many kdroneengineer and kdroneminingtowers a team has
function countTowersAndEngineer (teamID)
return #Spring.GetTeamUnitsByDefs (teamID, {UnitDefNames["kdroneminingtower"].id}) + Spring.GetTeamUnitsByDefs (teamID, {UnitDefNames["kdroneengineer"].id})
end
It is never used though.
You could modify the unitCount function like this:
Code: Select all
function unitCount (teamID, unitName)
if (unitname=="kdroneminingtower" or unitname=="kdroneengineer") then return countTowersAndEngineer
else
return #Spring.GetTeamUnitsByDefs (teamID, {UnitDefNames[unitName].id}) or 0
end
end
Though it is hacky.
Better would be if in the stages table you could define multiple conditions (and how many must be fullfilled)
Code: Select all
stages[2]= {
["unitNumbers"]={
{-----A
["kdroneengineer"]=2,
["kdroneminingtower"]=2,
total = 3,
},-----B
{"kdronewarrior]=5,
"kdronefighter]=3,
total = 6,
}-------
So there would be "substages", (commentated with A and B) and AI continues to next stage once all substages are completed. (or maybe only a defineable amount of substages must be completed)
A substage is complete once the
total amount of unit is reached (3 for A) so for A it could either build:
2x kdroneengineer, 1x kdroneminingtower
or
1x kdroneengineer, 2x kdroneminingtower
Sounds a bit complicated, hope it made sense.
-----------
Btw, for military logic I thought of some simple mechanics that work surprisingly good (not in CT but my game, ideas are same though)
eg this is what the AI does when it has build a new jeep (some light scout)
Code: Select all
if (unitName (unitID)=="tpjeep") then
if (math.random (1,100) > 80) then
guardRandomHarvester (unitID, "shift")
revengeMe[unitID] = 0.75
else
doRevengeScouting (unitID, 0.2, "shift")
end
return
end
So for the jeep it has 2 behaviours, that are randomly chosen.
First one is guarding a random harvester, which simply means following it everywhere.
(
Spring.GiveOrderToUnit(unitID, CMD.GUARD , {guardedUnit}, {}))
Now the lolpart is the
revengeMe[unitID] = 0.75
When the jeep is killed, 75% of all units will get a fight command to the last position of the jeep. Since the jeep was following the harvester, it looks like the AI is protecting his harvesters.
(while it is actually just suiciding more units into every battle because it always reacts too late, when stuff has already died.)
The second behaviour is
doRevengeScouting which simply means to drive around the map via random waypoints, until getting killed. Once killed, units will rush to that position.