ACL and CL. CL was for idle construction units. ACL was at 2 points, all construction units and at another point Active construction units.
Suffice to say ACL is no longer used and I havent gotten around to dealing with it.
Right now I am tryign to get it so that the engine generates a vector<Bbo> builds where Bbo is a structure containing the name of a builder and somethign ti can build. Such as CORCOM and CORWIN. That his how JCAI works, exept instead of dynamically generating the data absed on a list of unit names, it's instead written down in a config file.
As it stands I am trying tog et LUA to work, the only obstacle to that left being luabind and compiling it into a static library and thus getting rid of the need for everyone to downlaod the 10MB boost 1.32 files and the luabind source. I'll then use the same method as Zaphod and write it all down in LUA, exept it'll be better than simply using a text config file as I'll have an entire language with classes comments etc implemented for me. Once I've got ti workign and I can add that way using the Unit class that I've defined in BOUI.h I can add extra's. For one you'll see I've added techlevel and difficulty values for the build options in the Unit class, so I'll have support for difficulty and more accurate information.
I'll thus work on integrating the cheat interface into LUA for mission support and scripted cutscenes (remind me to ask for a few things to control the camera to be added to the cheats interface, and maybe to display arbitrary images and text outside the console.). That shouldnt be too hard as luabind does all the hard work.
As for CUtil(), the whole point was to keep track of and manage construction units, and make build orders easy by shoving them away in a small class so I'd never need bother with ti again. Or so I thought at the time.
void InitCUtil();
Initialises the class
void AddtoCL(int unit, UnitInfo* ug);
Add a construction unti to the list (idle con units) Units are added in UnitFinished and UnitIdle functions in CGlobalAI.
void RemCL(int unit);
To remove from the above list.
bool FindUnitCL(int unit);
Find a unit that was added through AddtoCL()
bool FindTypeCL(int id);
Find a unit in the idle list that is of this type, it might have been rpeferrable to use a string for unti name so that you could get a unitdef through callback. It simply looks for one btu it doesnt return it it justs ays if there is one.
int GetTypeSCL(string name);
Oh and the above as a string parametre but it returns the unti ID so that it can eb removed and used.
int GetTypeCL(int id);
Above but with Integer type. This isnt really of much use.
int GetTypecanBuildCL(int id);
Here's the problem function. There have been many versions of this (some are still ther ejust commented out, soem take strigns instead of integers).
int GetTypecanBuildACL(int id);
Same as above but for any unit.
void SetParent(IGlobalAI* ppointer);
Points to main CGlobalAI of the dll. Not really much use, should be changed to CGlobalAI*
void SetCallback(IGlobalAICallback* c);
Important, provides class with a GlobalAI callback interface to use.
//void SetUtility(Util* u);
This was supposed to give ti access tot he Util class, but it didnt work and I didnt think it was that important so I left it.
void PurgeList();
Erases the idle and active lists
float Distance(float3 pos1, float3 pos2);
Fidns the distance between 2 float3 co-ordinates
int RandomNum (int low, int high);
random number generator
void RegCon(int unit);
Add to active unit list
void RemCon(int unit);
Remove from Active unit list
void SetBuildOpt(map<int,BuildOption*> bO);
When a new con unit or factory was built, the map<int, BuildOption*> thign in CGlobalAI was updated, thent eh unitwas added tot he idle list, to save processing it's options voer again I just copied the structure.
Put in hat would parse the OTA AI def. It would sort all unitnames into categories and add them to an array. Such as PMex or PEnergy which are of type vector<string>.
When a type was needed PullOutOfHat was called given a type as a parametre. PullOutOfHat would then search through the respective array iterating through each item. It would see if it was better than the best currently found. Then it would check to see if it was buildable aka do we have any construction units that can build this. This si where the fabled GetCanBuildCL came in. GetCanBuildCL returned the unti ID of an idle unti capable of building it. If it returned zero then it skipped the item and carried on till there where no more left resulting in a return value of zero, btu there isnt a unit called zero.
The problem was the GetTypeCanBuildCL ALWAYS returned zero. Thus a suitable building could never be found and a command would always be issued saying unti zero is to build a unit of type zero at these co-ordinates, which the engine simply passes voer and does nothing because it cant do anything. Thus the AI never builds anything. If GetTypeCanBuildCL is fixed then PullOutHat is fixed and so is Util::CBuild and cosntruction occurs. The AI will thus attempt to build resource structures. Defences and factories and other units have no support yet as it was more important to get the AI to build anything first. It is also why Attack agents havent been implemented and only a set of 3 or 4 functions dealing with setting targets where ever written. Those should be deleted too anyways as they arent used.
In future the entire Util class should be re-written in LUA exept for the building placement algorithm, which needs hefty optimizing. The Map class could also be moved to LUA too as it isnt too complex.
Code: Select all
void CUtil::PurgeList()//BROKEN
{
IdleCons.erase(IdleCons.begin(),IdleCons.end());
}
The STL documentation says that the one overloaded function of the erase method is that it takes 2 iterators and erases everything inbetween. Here it erases starting from the beginning uptill the end.