0.74B1 groupai crash help
Moderators: hoijui, Moderators
Firstly
DevC++ AIs crash spring.
Codeblocks AIs are better.
Secondly, a few things about the C ABI
This only works for Skirmish AIs, and wont work for GroupAI.
Also there are a few items missing from the ABI, and a huge list missing from the c++ wrappers.
namely:
By far the best choice is to just compile in Mingw32 or develop in C#.
DevC++ AIs crash spring.
Codeblocks AIs are better.
Secondly, a few things about the C ABI
This only works for Skirmish AIs, and wont work for GroupAI.
Also there are a few items missing from the ABI, and a huge list missing from the c++ wrappers.
namely:
Code: Select all
virtual void SendTextMsg(const char* text,int priority) = 0;
virtual void SetLastMsgPos(float3 pos) = 0;
virtual void AddNotification(float3 pos, float3 color, float alpha) = 0;
virtual bool PosInCamera(float3 pos, float radius) = 0; // checks if pos is within view of the current camera, using radius as a margin
//get the current game time, there is 30 frames per second at normal speed
virtual int GetCurrentFrame() = 0;
virtual int GetMyTeam()=0;
virtual int GetMyAllyTeam()=0;
virtual int GetPlayerTeam(int player) = 0;
virtual void* CreateSharedMemArea(char* name, int size)=0;
virtual void ReleasedSharedMemArea(char* name)=0;
virtual int CreateGroup(char* dll,unsigned aiNumber) = 0; //creates a group and return the id it was given, return -1 on failure (dll didnt exist etc)
virtual void EraseGroup(int groupid) = 0; //erases a specified group
virtual bool AddUnitToGroup(int unitid,int groupid) = 0; //adds a unit to a specific group, if it was previously in a group its removed from that, return false if the group didnt exist or didnt accept the unit
virtual bool RemoveUnitFromGroup(int unitid) = 0; //removes a unit from its group
virtual int GetUnitGroup(int unitid) = 0; //returns the group a unit belongs to, -1 if no group
virtual const std::vector<CommandDescription>* GetGroupCommands(int unitid) = 0; //the commands that this unit can understand, other commands will be ignored
virtual int GiveGroupOrder(int unitid, Command* c) = 0;
virtual const vector<CommandDescription>* GetUnitCommands(int unitid) = 0;
virtual const deque<Command>* GetCurrentUnitCommands(int unitid) = 0;
virtual int GetUnitAiHint(int unitid) = 0; //integer telling something about the units main function, not implemented yet
virtual int GetUnitTeam(int unitid) = 0;
virtual int GetUnitAllyTeam(int unitid) = 0;
virtual float GetUnitHealth(int unitid) = 0; //the units current health
virtual float GetUnitMaxHealth(int unitid) = 0; //the units max health
virtual float GetUnitSpeed(int unitid) = 0; //the units max speed
virtual float GetUnitPower(int unitid) = 0; //sort of the measure of the units overall power
virtual float GetUnitExperience(int unitid) = 0; //how experienced the unit is (0.0f-1.0f)
virtual float GetUnitMaxRange(int unitid) = 0; //the furthest any weapon of the unit can fire
virtual bool IsUnitActivated (int unitid) = 0;
virtual bool UnitBeingBuilt(int unitid) = 0; //returns true if the unit is currently being built
virtual int GetBuildingFacing(int unitid) = 0; //returns building facing (0-3)
virtual bool IsUnitCloaked(int unitid) = 0;
virtual bool IsUnitParalyzed(int unitid) = 0;
virtual bool GetUnitResourceInfo(int unitid, UnitResourceInfo* resourceInfo) = 0;
virtual const UnitDef* GetUnitDef(const char* unitName) = 0;
virtual int InitPath(float3 start,float3 end,int pathType) = 0;
virtual float3 GetNextWaypoint(int pathid) = 0;
virtual void FreePath(int pathid) = 0;
virtual float GetPathLength(float3 start,float3 end,int pathType)=0;
virtual int GetEnemyUnits(int *units)=0; //returns all known enemy units (all in los)
virtual int GetEnemyUnits(int *units,const float3& pos,float radius)=0; //returns all known enemy units within radius from pos
virtual int GetFriendlyUnits(int *units,const float3& pos,float radius)=0; //returns all friendly units within radius from pos
virtual int GetMapWidth()=0;
virtual int GetMapHeight()=0;
virtual float GetMinHeight()=0; // readmap->minHeight
virtual float GetMaxHeight()=0; // readmap->maxHeight
virtual const float* GetSlopeMap()=0; // slopemap, half the resolution of the standard map
virtual const unsigned short* GetJammerMap()=0; //a square with value zero means you dont have radar jamming on the square, this is 1/8 the resolution of the standard map
virtual const char* GetMapName()=0;
virtual const char* GetModName()=0;
virtual float GetElevation(float x,float z)=0; //Gets the elevation of the map at position x,z
virtual float GetMaxMetal()=0; //returns what metal value 255 in the metal map is worth
virtual float GetExtractorRadius()=0; //returns extraction radius for metal extractors
virtual float GetMinWind()=0;
virtual float GetMaxWind()=0;
virtual float GetTidalStrength()=0;
virtual float GetGravity()=0;
virtual void LineDrawerStartPath(const float3& pos, const float* color)=0;
virtual void LineDrawerFinishPath()=0;
virtual void LineDrawerDrawLine(const float3& endPos, const float* color)=0;
virtual void LineDrawerDrawLineAndIcon(int cmdID, const float3& endPos, const float* color)=0;
virtual void LineDrawerDrawIconAtLastPos(int cmdID)=0;
virtual void LineDrawerBreak(const float3& endPos, const float* color)=0;
virtual void LineDrawerRestart()=0;
virtual void LineDrawerRestartSameColor()=0;
virtual int CreateSplineFigure(float3 pos1,float3 pos2,float3 pos3,float3 pos4,float width,int arrow,int lifetime,int group)=0;
virtual void SetFigureColor(int group,float red,float green,float blue,float alpha)=0;
virtual void DeleteFigureGroup(int group)=0;
virtual bool GetProperty(int id, int property, void *dst)=0;
virtual bool GetValue(int id, void *dst)=0;
virtual int HandleCommand(int commandId, void *data)=0;
virtual int GetFileSize (const char *name)=0;// return -1 when the file doesn't exist
virtual bool ReadFile (const char *name, void *buffer,int bufferLen)=0;
virtual int GetSelectedUnits(int *units)=0;
virtual float3 GetMousePos()=0;
virtual int GetMapPoints(PointMarker *pm, int maxPoints)=0;
virtual int GetMapLines(LineMarker *lm, int maxLines)=0;
virtual float GetMetal() = 0; //stored metal for team
virtual float GetMetalIncome() = 0;
virtual float GetMetalUsage() = 0;
virtual float GetMetalStorage() = 0; //metal storage for team
virtual float GetEnergy() = 0; //stored energy for team
virtual float GetEnergyIncome() = 0;
virtual float GetEnergyUsage() = 0;
virtual float GetEnergyStorage() = 0; //energy storage for team
virtual int GetFeatures (int *features, int max, const float3& pos, float radius) = 0;// GetFeaturesAt
virtual float GetFeatureHealth (int feature) = 0;
virtual float GetFeatureReclaimLeft (int feature) = 0;
virtual int GetNumUnitDefs() = 0;
virtual void GetUnitDefList (const UnitDef** list) = 0;
virtual float GetUnitDefHeight(int def) = 0; // forces loading of the unit model
virtual float GetUnitDefRadius(int def) = 0; // forces loading of the unit model
virtual const WeaponDef* GetWeapon(const char* weaponname) = 0;
By far the best choice is to just compile in Mingw32 or develop in C#.
No need, just overwrite devcpp's gcc and other stuff with recent mingw stuff (http://www.mingw.org).AF wrote:The vesion of mingw32 in devc++ is really old.
Use codeblocks instead.
Code completion is so slow it's practically unusable, and that's the only imaginable reason I'd want to work on C++ in Eclipse.Erom wrote:I'd also love to hear opinions on this.ILMTitan wrote:Has anyone here tried using Eclipse as their C++ IDE. I love it for Java, but don't really know how well the C++ plugin works.
Code: Select all
DLL_EXPORT bool IsUnitSuited(unsigned aiNumber, const UnitDef* unitDef)
{
return true;
}
Edit: fixed it, i got no more problems now, apparently mingw's version of vectors dont initialize themselves when created, so a commands.clear() in initAI fixed it.
its all fixed, but i have a few of questions.
1: why is the build distance from unitdef slightly larger then the real allowable builddistance, i noticed in my nanotower manager, when it tries to reclaim something near the edge of its builddistance, it thinks it has to walk there, which it cant.
2: is there a way to tell if a wreckage was built(like dragons teeth) or from a unit dieing.
3: is there a way to tell what the unit id is of what a unit is building(not the unitdef id, but ingame id) or what a unit is currently doing.
1: why is the build distance from unitdef slightly larger then the real allowable builddistance, i noticed in my nanotower manager, when it tries to reclaim something near the edge of its builddistance, it thinks it has to walk there, which it cant.
2: is there a way to tell if a wreckage was built(like dragons teeth) or from a unit dieing.
3: is there a way to tell what the unit id is of what a unit is building(not the unitdef id, but ingame id) or what a unit is currently doing.
Figuring this out would require a parent global AI acting in tandem as a silent watcher, else the groupAI just doesnt have the necessary information available, nor the scope to derive it. It would need tor ecieve the full range of events from the entire game as and when ti happens regardless of wether a unit is under its control.2: is there a way to tell if a wreckage was built(like dragons teeth) or from a unit dieing.
3: is there a way to tell what the unit id is of what a unit is building(not the unitdef id, but ingame id) or what a unit is currently doing.
although n#1 and n#2 can still be subtly derived using inference, aka unit A has a command to build X at position Y and an unfinished unit B is at X of type Y.....