BuildDistance in a groupai
Moderator: Moderators
BuildDistance in a groupai
is the nanolathe range for a unit divided by something when you get it from aicb? cause i was working on a groupai the past couple days and i was having it search for units within its build range, and it wasn't working so i finally had it output the builddistance value when the unit was added and it keeps coming back as like 0.9 and 0.7, any ideas?
Code: Select all
bool CGroupAI::AddUnit(int unit)
{
// * possibly do some stuff to check upon the suitability of unit for this group
// * keep track of the unit by storing it in some array
// * return true if the unit is accepted, false otherwise
const UnitDef* ud=aicb->GetUnitDef(unit);
UnitInfo* info=new UnitInfo;
if(ud->buildSpeed==0){
aicb->SendTextMsg("i only want builder units",0);
return false;
}
char tmpstr[128];
info->radius = ud->buildDistance;
sprintf(tmpstr,"Unit Has %f Build Distance",info->radius);
aicb->SendTextMsg(tmpstr,0);
info->Status = idle;
myUnits[unit] = info;
return true;
}
im also having some weird bugs with VC++2003 itself, where after useing aicb->GetFeatures, it wont pop up any class definitions, like listing the methods in aicb, it thinks everythings "int max" after i use it.
This should be in the AI forum
should be
btw what are you making this groupAI for? If you're trying to make an estimated time groupAI I've beaten you to it....
Code: Select all
bool CGroupAI::AddUnit(int unit)
{
// * possibly do some stuff to check upon the suitability of unit for this group
// * keep track of the unit by storing it in some array
// * return true if the unit is accepted, false otherwise
const UnitDef* ud=aicb->GetUnitDef(unit);
UnitInfo* info=new UnitInfo;
if(ud->buildSpeed==0){
aicb->SendTextMsg("i only want builder units",0);
return false;
}
char tmpstr[128];
info->radius = ud->buildDistance;
sprintf(tmpstr,"Unit Has %f Build Distance",info->radius);
aicb->SendTextMsg(tmpstr,0);
info->Status = idle;
myUnits[unit] = info;
return true;
}
Code: Select all
bool CGroupAI::AddUnit(int unit)
{
// * possibly do some stuff to check upon the suitability of unit for this group
// * keep track of the unit by storing it in some array
// * return true if the unit is accepted, false otherwise
const UnitDef* ud=aicb->GetUnitDef(unit);
if(ud == 0) return false;
// check if the engine gives an error to prevent crash
UnitInfo* info = new UnitInfo();
if(ud->builder){
// if buildspeed < 0.5 then ti would give this error which we dont want
// also this is the proper method.
aicb->SendTextMsg("i only want builder units",0);
return false;
}
char tmpstr[128];
info->radius = ud->buildDistance;
sprintf(tmpstr,"Unit Has %f Build Distance",ud->buildDistance);
// use the original value nto the value you assigned it to.
aicb->SendTextMsg(tmpstr,0);
info->Status = idle;
myUnits[unit] = info;
return true;
}
The problem is that nano-towers are units, so they try to move to repair things outside of their range, ignoring everything else.AF wrote:manage them how exactly? Just going around repairing stuff? nanotowers can do that already if you give the the fight command in 0.73b1, and they sorta do it if you give them patrol commands with repeat on
exactly, and to give them a priority of sorts, im having them repair hurt friendly s first, then reclaim enemy units, then reclaim wreckages then help build.
and iam trying to use the build distance in aicb->GetFriendlyUnits, to get all allied units within its build range, which since its returning 0.9blahblah isn't working unless the AI is right up next to the damaged unit
and iam trying to use the build distance in aicb->GetFriendlyUnits, to get all allied units within its build range, which since its returning 0.9blahblah isn't working unless the AI is right up next to the damaged unit
added combat units to the AI(which shouldn't even happen cause of the build speed check) and they all return the same 0.9blahblah build distance number... i never have gotten UnitDef stuff to work in my groupais, i tried to make a ai only accept planes before, same result, same number on can fly no matter what unit type.