AI DE Script bugs Main thread

This is going to be the main thread for all AI script bugs and issues

Current issues
V 100.12.4087.0
Ai is unable to build trading post on railroad sites(native sites are working)
Untitled

In TAD the ai was unable to upgrade to ironHorse for trading post (stageCoach worked) so this could still be an issue for DE.

If kbSetPlayerHandicap(cMyID, value) is updated it can cause an OOS. If the client changes the aiMain file and adds a function that updates the kbSetPlayerHandicap that will also cause an OOS. This has the potential to allow players to cause OOS when losing a game.

New AI functions needed
kbUnitGetWorkersCountIfSeeable(int resourceID)
Returns the count of settlers currently working on a mine, a tree or whatever, but ONLY if those settlers are seen by the current player context. (I did not want the AI to cheat and know if there were settlers on something while the AI isn’t supposed to see them.

kbUnitGetInventoryCapacity(int unitID, int resourceID)
Returns the max resource capacity of a unit.

kbUnitGetCurrentInventory(int unitID, int resourceID)
Returns the current resource capacity of a unit.

int kbUnitGetNumberTargeters(int unitID)
Returns the number of units that is tasked to a resource

kbUnitGetNumberWorkersIfSeeable(int resourceID)
Returns the number of units the AI sees on a resource

aiTaskUnitRepair(int unitID)
Repairs a unit if repairable

aiTaskUnitRepairAvailability(int unitID)
Is the repair option available

aiTaskUnitEject(int unitID)
Ejects all units from a unit

kbIsNomad()
Is the game a nomad game

kbIsFFA()
Is the game a FFA

kbIsKOTH( void )
Is the game King of the hill

kbVPSiteGetRouteID(int socketID)
Returns the ID of the trade route (when there is more than 1).

kbUnitGetNumberContained( int unitID )
Returns the number of units inside a unit

unitMaxGatherers(int unitID)
Returns the max amount of gatherers from a unit (e.g livestock pen)

unitCurrentGatherers(int unitID)
Returns the current amount of gatherers from a unit

unitSpecialAttack(int unitID ,int unitID, int specialType)
Units that have a special attack (like ships) allow them to use them.

createSimpleResearchPlan(cTechLevy, buildingID, cMilitaryEscrowID, 99);
Is broken, AI is unable to make Minuteman from town centers, outpost etc

Why on earth is this text box so tiny?

Now regarding the above post:
aiTaskUnitRepair(int unitID)
aiTaskUnitRepairAvailability(int unitID)
Already exists as the RepairPlan used by the stock script.

aiTaskUnitEject(int unitID)
Already exists:
bool aiTaskUnitEject( int unitID, vector position ):
bool aiTaskUnitEnter( int unitID, int targetID )

unitMaxGatherers(int unitID)
Its 10 for most buildings. 4 for shrines. A function is pointless.

unitCurrentGatherers(int unitID)
Use kbUnitGetNumberWorkers( int unitID ) with the context set to the owner.

unitSpecialAttack(int unitID ,int unitID, int specialType)
Already exists:
bool aiTaskUnitSpecialPower( int unitID, int powerID, long targetID, vector position )

Hi
does kbUnitGetNumberWorkers( int unitID ) count how many sheep are gathered at a livestock pen?
aiTaskUnitSpecialPower does not work for ship attacks as far as i know

I am going through all the new functions that were added atm

kbUnitGetNumberWorkers() works for any units “tasked”.

There’s also this:
int aiGetNumberGatherers( int unitPUID, int resourceID, int resourceSubType, int resourcePUID )

Broadside and long range bombard are special powers. The latter is used by the stock script. The former should work too.

Too bad there’s no functions for build rotation, treaty time or queued unit ID/cancel.

A few major ones i need are
int kbUnitGetNumberContained( int unitID );
kbUnitGetCurrentInventory(int unitID, resourceID);
kbUnitIsInventoryFull(int unitID);
kbUnitGetNumberWorkersIfSeeable(int resourceID);
kbUnitGetNumberTargeters(int resourceID);

Also int aiGetNumberGatherers( int unitPUID, int resourceID, int resourceSubType, int resourcePUID ): Returns the number of gatherers for the given resource.
I think that only tells you how many are on a food coin or a wood resource, not how many have been tasked to a mine so if the ai is mining from 2 mines it will return the total number of miners , would need to test this