Hi, I am porting over the AI i have been developing and improving from The Improvement Mod. However there are a few key new AI functions that were added to The Improvement Mod that I would like to be added also to aoe3DE.
I used the following new functions to create a livestock management system.
int kbUnitGetCurrentInventory(int unitID, resourceID) //returns the current amount of resources left for the unit (e.g sheep 100f)
bool kbUnitIsInventoryFull(int unitID) returns true if resources from unit is full (e.g sheep is fatten has max food)
Maybe a simple kbUnitStartingInventory and kbUnitCurrentInventory would do.
These functions are also used to check how much resources are left before assigning settlers to them.
The next critical function i use is
kbUnitGetNumberWorkersIfSeeable(int resourceID) returns the number of settlers that has been assigned to a resource. This includes settlers walking to the resource as well.
I also am going to need the following
int kbUnitGetNumberContained( int unitID ); //returns the number of units inside a unit (e.g number of units inside a transport ship)
void aiTaskUnitEject( int unitID ); //ejects a unit from inside a unit
bool kbIsFFA( void ); //is this a free for all game
While you guys are at it, I’d love an AI function that returns a player’s currently selected deck’s index (long deckIndex), e.g. long aiHCDeckGetIndex(), to be able to actually use functions like aiHCDeckGetCardTechID( long deckIndex, long cardIndex ) in a non-AI script context. Testing 0, 1 etc doesn’t work so I assume it’s making full use of the “long” type.
That is stuff I had to add myself for the The Asian Dynasties version of the game, to add a bit more context on what exactly those are doing:
The kbUnitGetNumberWorkersIfSeeable(int resourceID) could have been called kbUnitGetWorkersCountIfSeeable(int resourceID) it 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.
For the inventory functions i also made a kbUnitGetInventoryCapacity(int unitID, int resourceID). Allows AI modders to know how much the sheep is fattened by doing a simple division between the result of that one and the result of kbUnitGetCurrentInventory(int unitID, int resourceID)
Both have a default value for the resourceID of 2 which corresponds to Food as it’s where that function was the most wanted.
CurrentInventory can both be used to know how close to be fat a unit is or how close to be empty a corpse is.
@ageekhere the getNumberTargeters is no more of use to you?
So yeahr int kbUnitGetNumberTargeters(int unitID) allows to know how many units were tasked to something (attacking a specific unit, mining a specific mine, etc) but that are not yet doing it. int kbUnitGetNumberTargeters(int unitID) result + kbUnitGetNumberWorkersIfSeeable(int resourceID) result help to know if you’re going to reach the max amount of settlers on a gold mine for example.
Example say there are max settlers on a gold mine and the ai wants to assign more, the ai will overload the mine and the settlers will sit there waiting, be retasked again to the same mine. This is also the same for hunts, livestock and berry bushes.