1、在AutoRoue.cpp中,我们看到函数AddPoint在void AutoRoute::CreateMove(usercmd_s *usercmd)中用到,这表明当你录制线路时,“我”的每个步点都会被录制。其实对于bot而言,需要的是路标,顺着路标前进就可以了,不需要每个步点都成为路标!路标多了,计算也就多了,CPU频率也就越高,以dust2地图为例,倘若以3-5个步点设置一个路标,则原来环绕一周的270多个Point将会降为30多个,对于bot也足够用了。所以第一,你要减少Point,至于怎么减少,聪明的你不用我多说了。
if (Record)
{
if (iLine > -1)
{
if (iPoint == cvar.pointcount){Record = false;return;};
if (iPoint == -1)
{
//AddPoint();
}
else
{
float dist = GetPointDistance(route_line[iLine].point[iPoint].origin);
if (dist >= cvar.routedist)
{
//AddPoint();
}
}
}
return;
}
2、改进void CheckRoutePoint(float *point, usercmd_s *usercmd)函数
在函数前加上
float FForward = 0;
float FSide = 0;
找到末尾几行改为
// 0...360
while(angle<0) { angle+=360; }
while(angle>360) { angle-=360; }
//Add By Softwind
FForward = (float)cos(angle*(3.1415926/180.0))*dist;
FSide = (float)-sin(angle*(3.1415926/180.0))*dist;
usercmd->forwardmove = FForward*2.5;
usercmd->sidemove = FSide*2.5;
3、在CreateMove函数中找到以下位置改为
if (cvar.walkmode == 3)
{
cvar.spin = 1;
}
iPoint = i;
//GotoRoutePoint(route_line[iLine].point[iPoint].origin, usercmd);
usercmd->forwardmove = FForward;
usercmd->sidemove = FSide;
OK,这下CPU的占用频率我的机器已经在90%以下