这是我在G Y J Hack for CS1.5中的路线代码,也是建立在很多别人的代码上的,同时也加入了我自己的东西,有一些功能我还没有在别的作弊器中看到过。算是首次公开。
希望有更多的人写出强大的路线代码,让更多的人加入到暴力作弊中来。
#include <windows.h>
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include "engine/wrect.h"
#include "engine/cl_dll.h"
#include "engine/cdll_int.h"
#include "engine/util_vector.h"
#include "engine/cl_entity.h"
#include "engine/usercmd.h"
#include "common/event_api.h"
#include "common/r_efx.h"
#include "aimbot.h"
#include "client.h"
#include "cvar.h"
#include "console.h"
#include "color.h"
#include "calcscreen.h"
#include "AutoWay.h"
#include "trace.h"
#include "interpreter.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
AutoWay autoway;
float GetPointDistance(float* pos)
{
me.ent = gEngfuncs.GetLocalPlayer();
double a = pos[0] - me.pmEyePos[0];
double b = pos[1] - me.pmEyePos[1];
double c = pos[2] - me.pmEyePos[2];
return (float)sqrt(a*a + b*b + c*c);
}
void CalcVec_MeToTarget(float *view)
{
float EntViewOrg[3];
VectorCopy(view, EntViewOrg);
view[0] = EntViewOrg[0] - me.pmEyePos[0];
view[1] = EntViewOrg[1] - me.pmEyePos[1];
view[2] = EntViewOrg[2] - me.pmEyePos[2];
}
void GetPointAngles(float *point,float *angles)
{
float vec_to_target[3];
VectorCopy(point, vec_to_target);
CalcVec_MeToTarget(vec_to_target);
VectorAngles(vec_to_target,angles);
angles[0] *= -1;
if (angles[0]>180) angles[0]-=360;
if (angles[1]>180) angles[1]-=360;
}
void ChangeViewAngle(float *point, usercmd_s *usercmd)
{
float aim_viewangles[3];
float vec_to_target[3];
VectorCopy(point, vec_to_target);
CalcVec_MeToTarget(vec_to_target);
VectorAngles(vec_to_target,aim_viewangles);
aim_viewangles[0] *= -1;
if (aim_viewangles[0]>180) aim_viewangles[0]-=360;
if (aim_viewangles[1]>180) aim_viewangles[1]-=360;
VectorCopy(aim_viewangles, usercmd->viewangles);
gEngfuncs.SetViewAngles (aim_viewangles);
}
bool GetAngleVisible(float *point)
{
float angles[3];
GetPointAngles(point, angles);
if ((me.viewAngles[1] - (cvar.waypointangle / 2)) < angles[1] && (me.viewAngles[1] + (cvar.waypointangle / 2)) > angles[1])
{
return true;
}
else
{
return false;
}
}
bool GetPointVisible(float *point)
{
strace_t tr;
tr.finished = false;
TraceThickness(me.pmEyePos, point, 0, &tr);
return tr.finished;
}
float CalcTwoAngle(float a,float b)
{
float c=abs(a-b);
if(c>180)
return abs(c-360);
else
return c;
}
//========================================================================================
//路线函数
//建议cvar.waydist为100,cvar.wayverifydist为230~250
void AutoWay::CreateMove(usercmd_s *usercmd)
{
bDontJump=false;
if(cvar.wayuse==0)return;
if (Record)
{
if (iWayLine > -1)
{
if (iWayPoint == waypointcount){Record = false;return;};
if (iWayPoint == -1)
{
AddPoint();
}
else
{
float dist = GetPointDistance(way_line[iWayLine].point[iWayPoint].origin);
if (dist >= cvar.waydist)
{
AddPoint();
}
}
}
return;
}
if(cvar.autowaymove) //自动路线模式,比automove强大
{
if(cvar.rush && cvar.nosky && cvar.opencheat) //手动冲刺模式
bContinueAutoWay=false;
if(cvar.rush && !cvar.nosky && cvar.opencheat) //自动冲刺模式
{
if(!(ActivePlayer!=-1 && vPlayers[ActivePlayer].getAlive() && strcmp(vPlayers[ActivePlayer].entinfo.name,"\\missing-name\\") && vPlayers[ActivePlayer].entinfo.name[0]!='\0'))
{
ActivePlayer=-1; //清除自动冲刺对象
cmd.exec("rush 0"); //自动冲刺结束
if(cvar.wayatstart!=-1 && cvar.rushatstart!=1 && bContinueAutoWay) //在开局自动游览地图模式下,自动冲刺对象清空后,继续游览地图
{
if(iWayLine>-1 && iWayPoint>-1 && abs(way_line[iWayLine].point[iWayPoint].origin[2] - me.pmEyePos[2]) < 25 && GetPointVisible(way_line[iWayLine].point[iWayPoint].origin))
{
way_mode = WAY_START;
cvar.autoway=1;
}
else
{
FindAnyWay(10000);
}
}
return;
}
}
}
if (cvar.autoway && me.alive )
{
if (gAimbot.target!=-1)
{
if(!runaway)
{
if(cvar.wayfiremode) //开木仓模式为1,站住开木仓
{
usercmd->forwardmove = 0;
usercmd->sidemove = 0;
bDontJump=true; //不要乱跳
return;
}
if(cvar.wayrushmode==0) //遇敌脱线
{
cvar.autoway = 0;
iWayLine = -1;
iWayPoint = -1;
way_mode = WAY_NONE;
return;
}
else if(cvar.wayrushmode==1) //遇敌脱线杀完回归
{
return;
}
else //遇敌不脱线
{
;
}
}
}
switch (way_mode)
{
case WAY_NONE:
{
FindFowardWay(-1);
if (iWayPoint > -1 && iWayLine > -1)
{
GotoWayPoint(way_line[iWayLine].point[iWayPoint].origin, usercmd);
way_mode = WAY_FROM;
}
break;
}
case WAY_START:
{
GotoWayPoint(way_line[iWayLine].point[iWayPoint].origin, usercmd);
way_mode = WAY_FROM;
}
break;
case WAY_FROM:
{
if(cvar.wayendmode==0) //到路线终点如果wayendmode==0,就继续寻找前方新路线(路线平滑连接)
{
if (((way_direction == WAY_ASC) && (iWayPoint == way_line[iWayLine].count - 1)) || ((way_direction == WAY_DESC) && (iWayPoint == 0)))
{
FindFowardWay(iWayLine);
if (iWayPoint > -1 && iWayLine > -1)
{
GotoWayPoint(way_line[iWayLine].point[iWayPoint].origin, usercmd);
way_mode = WAY_FROM;
}
else
way_mode = WAY_NONE;
return;
}
}
if( WayMoveEnough(way_line[iWayLine].point[iWayPoint].origin, usercmd) )
{
//已到路线终点,如果wayendmode==1,就不走了 (用于迅速到达有利地点,不用担心冲刺过头)
if (cvar.wayendmode==1 && ((way_direction == WAY_ASC) && (iWayPoint == way_line[iWayLine].count - 1)) || ((way_direction == WAY_DESC) && (iWayPoint == 0)))
{
usercmd->forwardmove = 0;
usercmd->sidemove = 0;
bDontJump=true; //不要跳
return; //返回
}
//已到路线终点,如果wayendmode==2,就沿原路线反向走
if (cvar.wayendmode==2 && ((way_direction == WAY_ASC) && (iWayPoint == way_line[iWayLine].count - 1)) || ((way_direction == WAY_DESC) && (iWayPoint == 0)))
{
switch (way_direction)
{
case WAY_ASC:
{
iWayPoint--;
way_direction=WAY_DESC;
}
break;
case WAY_DESC:
{
iWayPoint++;
way_direction=WAY_ASC;
}
break;
}
bDontJump=true; //不要跳
GotoWayPoint(way_line[iWayLine].point[iWayPoint].origin, usercmd);
return; //返回
}
//未到路线终点,继续走
int i = iWayPoint;
switch (way_direction)
{
case WAY_ASC:
{
i++;
if(i==way_line[iWayLine].count - 1)
{
ChangeViewAngle(way_line[iWayLine].point.origin, usercmd); //快到路线终点,调整视角,准备寻找前方新路线
}
}
break;
case WAY_DESC:
{
i--;
if(i==0)
{
ChangeViewAngle(way_line[iWayLine].point.origin, usercmd); //快到路线终点,调整视角,准备寻找前方新路线
}
}
break;
}
iWayPoint = i;
GotoWayPoint(way_line[iWayLine].point[iWayPoint].origin, usercmd);
}
return;
}
break;
case WAY_END:
{
iWayLine = -1;
iWayPoint = -1;
way_mode = WAY_NONE;
}
break;
}
}
else
{
iWayLine = -1;
iWayPoint = -1;
way_mode = WAY_NONE;
}
}
void AutoWay::GotoWayPoint(float *point, usercmd_s *usercmd)
{
if (cvar.waylookmode == 1)
{
ChangeViewAngle(point, usercmd);
}
usercmd->forwardmove += me_forwardmove;
usercmd->sidemove += me_sidemove;
}
bool AutoWay::WayMoveEnough(float *point, usercmd_s *usercmd)
{
if (cvar.waylookmode == 1)
{
ChangeViewAngle(point, usercmd);
}
gEngfuncs.GetViewAngles(me.viewAngles);
float addvec[2];
float dodgeDir[3];
dodgeDir[0]=dodgeDir[1]=dodgeDir[2]=0;
addvec[0] = me.pmEyePos[0] - point[0];
addvec[1] = me.pmEyePos[1] - point[1];
float dist = GetPointDistance(point);
addvec[0] /= dist;
addvec[1] /= dist;
dodgeDir[0] -= addvec[0];
dodgeDir[1] -= addvec[1];
dodgeDir[2] = 0;
float dodgeAngles[3];
VectorAngles(dodgeDir,dodgeAngles);
float angle = dodgeAngles[1] - me.viewAngles[1];
while(angle<0) { angle+=360; }
while(angle>360) { angle-=360; }
me_forwardmove = (float)cos(angle*(3.1415926/180.0))*dist;
me_sidemove = (float)-sin(angle*(3.1415926/180.0))*dist;
usercmd->forwardmove = me_forwardmove*2.5f;
usercmd->sidemove = me_sidemove*2.5f;
if( usercmd->forwardmove>0-cvar.wayverifydist && usercmd->forwardmove<cvar.wayverifydist && usercmd->sidemove>0-cvar.wayverifydist && usercmd->sidemove<cvar.wayverifydist)
return true;
return false;
}
void AutoWay::FindFowardWay(int lastway) //搜索前方路线
{
float pointdist = 99999.0;
float angles1[3];
float angles[3];
float dist1;
float dist;
float minangles=cvar.waypointangle; //寻找在前方一定角度内的路点 默认为50
float minwayangles=cvar.wayangle; //前方同路线的2个相邻路点必须小于一定的角度 默认为20
float pointangles;
float wayangle;
iWayLine = -1;
iWayPoint = -1;
for(int i = 0; i < waycount ; i++)
{
if (way_line.enabled && i!=lastway)
{
float mindist=cvar.wayfinddist; //默认为230
for(int j = 0; j < way_line.count; j++)
{
dist = GetPointDistance(way_line.point[j].origin);
if(dist < mindist)
{
if (abs(way_line.point[j].origin[2] - me.pmEyePos[2]) < 25)
{
GetPointAngles(way_line.point[j].origin, angles);
pointangles = CalcTwoAngle(me.viewAngles[1],angles[1]);
if (GetPointVisible(way_line.point[j].origin) && pointangles<=cvar.waypointangle)
{
if (j > 0 && j < way_line.count - 1)
{
dist1 = GetPointDistance(way_line.point[j+1].origin);
if(dist1>=dist)
{
GetPointAngles(way_line.point[j + 1].origin, angles1);
wayangle=CalcTwoAngle(angles1[1],angles[1]);
if(wayangle<minwayangles && CalcTwoAngle(me.viewAngles[1],angles1[1])<=cvar.waypointangle)
{
mindist=dist;
minwayangles = wayangle;
way_direction = WAY_ASC;
iWayLine = i;
iWayPoint = j;
}
}
else
{
GetPointAngles(way_line.point[j - 1].origin, angles1);
wayangle=CalcTwoAngle(angles1[1],angles[1]);
if(wayangle<minwayangles && CalcTwoAngle(me.viewAngles[1],angles1[1])<=cvar.waypointangle)
{
mindist=dist;
minwayangles = wayangle;
way_direction = WAY_DESC;
iWayLine = i;
iWayPoint = j;
}
}
}
else if(j==0)
{
dist1 = GetPointDistance(way_line.point[j+1].origin);
if(dist1>=dist)
{
GetPointAngles(way_line.point[j + 1].origin, angles1);
wayangle=CalcTwoAngle(angles1[1],angles[1]);
if(wayangle<minwayangles && CalcTwoAngle(me.viewAngles[1],angles1[1])<=cvar.waypointangle)
{
mindist=dist;
minwayangles = wayangle;
way_direction = WAY_ASC;
iWayLine = i;
iWayPoint = j;
}
}
}
else if(j==way_line.count - 1)
{
dist1 = GetPointDistance(way_line.point[j-1].origin);
if(dist1>=dist)
{
GetPointAngles(way_line.point[j - 1].origin, angles1);
wayangle=CalcTwoAngle(angles1[1],angles[1]);
if(wayangle<minwayangles && CalcTwoAngle(me.viewAngles[1],angles1[1])<=cvar.waypointangle)
{
mindist=dist;
minwayangles = wayangle;
way_direction = WAY_DESC;
iWayLine = i;
iWayPoint = j;
}
}
}
}
}
}
}
}
}
}
void AutoWay::LoadWay(char * sfilename)
{
Record = false;
char tfilename[256];
if(sfilename[0]=='\0') //地图参数为空,读取当前地图路线
{
strcpy(levelname, gEngfuncs.pfnGetLevelName() + 5);
levelname[strlen(levelname)-4] = 0;
sprintf(tfilename, "%s/%s.%s", wayfilepath,levelname,wayfileext); //目录、文件名
sprintf(filename, "%s%s", ogcdir, tfilename);
}
else //地图参数不为空,读取指定地图路线文件
{
sprintf(tfilename, "%s/%s.%s", wayfilepath,sfilename,wayfileext); //目录、文件名
sprintf(filename, "%s%s", ogcdir, tfilename);
}
//因为可以设置成读取其他地图名以及其他作弊器的路线文件,所以以上代码看起来比较复杂
ZeroMemory(way_line, sizeof(way_line));
ifstream ifs(filename);
while (ifs.good())
{
char buf[1024] = {0};
ifs.getline(buf, sizeof(buf));
cout << buf << endl;
int i,j;
float f1=0,f2=0,f3=0;
if(sscanf(buf,wayfileformat,&i,&j,&f1,&f2,&f3)) // 格式。默认的wayfileformat是"way(%d)(%d):%f,%f,%f",如果读取ghost路线文件,wayfileformat是"P[%d][%d]:%f%20%f%20%f"
{
if(f1!=0&&f2!=0&&f3!=0)
{
way_line.point[j].origin[0]=f1;
way_line.point[j].origin[1]=f2;
way_line.point[j].origin[2]=f3+wayheight;//默认的wayheight是0,如果读取ghost路线文件,wayheight是17
way_line.enabled = true;
way_line.count ++;
}
}
}
ifs.close();
char tmp[256];
sprintf(tmp,"txt %s",wayfilemode);
cmd.exec(tmp);
}
void AutoWay::SaveWay() //保存为当前地图名的路线文件
{
char tfilename[256];
strcpy(levelname, gEngfuncs.pfnGetLevelName() + 5);
levelname[strlen(levelname)-4] = 0;
sprintf(tfilename, "way/%s.way", levelname);
sprintf(filename, "%s%s", ogcdir, tfilename);
char waypoint[256];
remove(filename);
ofstream ofs(filename, ios::binary | ios::app);
char headreg[256];
sprintf(headreg, "//GYJ Hack for 1.5 Way file: %s",levelname);
ofs << headreg << (char)0x0D << (char)0x0A;
for(int i = 0; i < waycount ; i++)
{
if (way_line.enabled)
{
for(int j = 0; j < way_line.count; j++)
{
sprintf(waypoint, "way(%d)(%d):%f,%f,%f",i,j,way_line.point[j].origin[0],way_line.point[j].origin[1],way_line.point[j].origin[2]);
ofs << waypoint << (char)0x0D << (char)0x0A;
}
}
}
ofs.close();
}
void AutoWay::AddPoint()
{
if (iWayLine > -1)
{
iWayPoint ++;
if (iWayPoint == waypointcount)
{
iWayPoint = waypointcount - 1;
Record = false;
return;
}
VectorCopy(me.pmEyePos, way_line[iWayLine].point[iWayPoint].origin);
way_line[iWayLine].count ++;
}
}
void AutoWay::DrawWay()
{
if(cvar.wayhide)return;
if (way_mode == WAY_NONE && !Record){ FindFowardWay(-1);}
ColorEntry* color;
ColorEntry* color1;
float vt[3];
float vecScreen[2];
for(int i = 0; i < waycount ; i++)
{
if (way_line.enabled)
{
for(int j = 0; j < way_line.count; j++)
{
if (way_direction == WAY_ASC)
{
if (j >= iWayPoint && i == iWayLine)
{
color1 = colorList.get(8);
VectorCopy(autoway.way_line[iWayLine].point[iWayPoint].origin, vt);
vt[2]=vt[2]-30;
if (NewCalcScreen(vt,vecScreen))
{
DrawHudStringCenter((int)vecScreen[0],(int)vecScreen[1],color1->r,color1->g,color1->b,"%d",i+1);
}
color = colorList.get(16);
}
else
{
color = colorList.get(52);
}
}
else if (way_direction == WAY_DESC)
{
if (j <= iWayPoint && i == iWayLine)
{
color1 = colorList.get(8);
VectorCopy(autoway.way_line[iWayLine].point[iWayPoint].origin, vt);
vt[2]=vt[2]-30;
if (NewCalcScreen(vt,vecScreen))
{
DrawHudStringCenter((int)vecScreen[0],(int)vecScreen[1],color1->r,color1->g,color1->b,"%d",i+1);
}
color = colorList.get(16);
}
else
{
color = colorList.get(52);
}
}
float dist = GetPointDistance(autoway.way_line.point[j].origin);
if (j > 0 && dist < cvar.waydrawdist)
{
vec3_t vecBegin,vecEnd;
VectorCopy(autoway.way_line.point[j-1].origin,vecBegin);
vecBegin[2] -= 48;
VectorCopy(autoway.way_line.point[j].origin,vecEnd);
vecEnd[2] -= 48;
int beamindex = gEngfuncs.pEventAPI->EV_FindModelIndex("sprites/laserbeam.spr");
gEngfuncs.pEfxAPI->R_BeamPoints(vecBegin,vecEnd,beamindex,0.1f,2.4f,0,32,0,0,0,color->fr,color->fg,color->fb);
}
}
}
}
}
void AutoWay::ClearAllWay() //清除所有路线
{
Record = false;
ZeroMemory(way_line, sizeof(way_line));
}
void AutoWay::ClearOneWay(int index) //清除一条路线
{
if ( index > -1 && index <= waycount)
{
Record = false;
iWayLine = index;
iWayPoint = -1;
way_line[iWayLine].enabled = false;
way_line[iWayLine].count = 0;
}
}
void AutoWay::RecordOneWayStart(int index) //开始记录指定路线
{
if ( index > -1 && index <= waycount)
{
iWayLine = index;
ClearOneWay(iWayLine);
way_line[iWayLine].enabled = true;
way_line[iWayLine].count = 0;
Record = true;
}
}
void AutoWay::RecordAnyWayStart() //以最小空闲路线序号开始记录路线
{
iWayLine=waycount;
for(int i=0;i<waycount;i++)
{
if (!way_line.enabled)
{
iWayLine = i;
break;
}
}
iWayPoint=-1;
way_line[iWayLine].enabled = true;
way_line[iWayLine].count = 0;
Record = true;
}
void AutoWay::RecordWayStop()
{
Record = false;
}
//以下是扩展的路线相关函数
void AutoWay::FindOneWay(int i,float pointdist) //找到指定路线,方向是朝较长的那头。适合用在开局
{
iWayLine = -1;
iWayPoint = -1;
if (way_line.enabled)
{
iWayLine = i;
for(int j = 0; j < way_line.count; j++)
{
float dist = GetPointDistance(way_line.point[j].origin);
if (dist < pointdist && abs(way_line.point[j].origin[2] - me.pmEyePos[2]) < 25 && GetPointVisible(way_line.point[j].origin))
{
pointdist = dist;
iWayPoint = j;
}
}
}
if(iWayLine>-1&&iWayPoint>-1)
{
if(iWayPoint<=way_line[iWayLine].count-iWayPoint) //哪头较长?
way_direction = WAY_ASC;
else
way_direction = WAY_DESC;
way_mode = WAY_START;
}
else
{
way_mode = WAY_NONE;
FindAnyWay(500);
}
cvar.autoway = 1;
}
void AutoWay::FindAnyWay(float pointdist) //任意找到一条最近的路线,方向是朝较长的那头。
{
iWayLine = -1;
iWayPoint = -1;
for(int i=0;i<waycount;i++)
{
if (way_line.enabled)
{
if(way_line.count>12)
{
for(int j = 0; j < way_line.count; j++)
{
if(GetPointVisible(way_line.point[j].origin))
{
float dist = GetPointDistance(way_line.point[j].origin);
if (dist < pointdist && abs(way_line.point[j].origin[2] - me.pmEyePos[2]) < 25)
{
pointdist = dist;
iWayLine = i;
iWayPoint = j;
}
}
}
}
}
}
if(iWayLine>-1&&iWayPoint>-1)
{
if(iWayPoint<=way_line[iWayLine].count-iWayPoint) //哪头较长?
way_direction = WAY_ASC;
else
way_direction = WAY_DESC;
way_mode = WAY_START;
}
else
{
way_mode = WAY_NONE;
}
cvar.autoway = 1;
}
bool AutoWay::FindWayMeToPoint(int ax,float* pos,float targetdist,float medist,int firstline,int firstline2) //找自已和敌人位置间合适的路线(只在离敌人位置最近的3条路线中找)。
{
int iLineP = -1;
int iPointP = -1;
float targetlastdist=targetdist;
float melastdist=medist;
for(int i=0;i<waycount;i++)
{
if(i==firstline||i==firstline2)continue;
if(vPlayers[ax].distance>2500 && way_line.count<=12)continue;
if (way_line.enabled)
{
for(int j = 0; j < way_line.count; j++)
{
float dist = GetTwoPointDistance(pos,way_line.point[j].origin);
if (dist < targetlastdist)
{
targetlastdist = dist;
iLineP = i;
iPointP = j;
}
}
}
}
if(iLineP==-1&&iPointP == -1)
return false;
i=iLineP;
int iLineM=-1;
int iPointM=-1;
if (way_line.enabled)
{
iLineM = i;
for(int j = 0; j < way_line.count; j++)
{
float dist = GetPointDistance(way_line.point[j].origin);
if (dist < melastdist && way_line.point[j].origin[2] - me.pmEyePos[2] < 25 && way_line.point[j].origin[2] - me.pmEyePos[2] > -100 && GetPointVisible(way_line.point[j].origin))
{
melastdist = dist;
iPointM = j;
}
}
}
if(abs(iPointP-iPointM)>cvar.autowaymovepoints) //这条路线与敌人相距太远
return false;
if(iLineM>-1&&iPointM>-1) //找到了合适的路线,自动冲刺
{
if(iPointP>=iPointM)
way_direction = WAY_ASC;
else
way_direction = WAY_DESC;
iWayLine=iLineM;
iWayPoint=iPointM;
way_mode = WAY_START;
cmd.exec("rush 1;nosky 0"); //autowaymove自动路线冲刺和手动路线冲刺的区别就是cvar.nosky=0
bFirstKilled=true;
return true;
}
else //离敌人最近的路线不合适
{
if(firstline==-1)
return FindWayMeToPoint(ax,pos,targetdist,medist,iLineP,-1); //递归再找离敌人第2近的路线
else if(firstline2==-1)
return FindWayMeToPoint(ax,pos,targetdist,medist,firstline,iLineP); //递归再找离敌人第3近的路线
return false;
}
return false;
}
void AutoWay::WayTurn() //调转沿路线的行走方向
{
if(way_mode==WAY_FROM||way_mode==WAY_START)
{
if(way_direction==WAY_ASC)
{
way_direction=WAY_DESC;
if(iWayPoint>0)
iWayPoint--;
}
else if(way_direction==WAY_DESC)
{
way_direction=WAY_ASC;
if(iWayPoint<way_line[iWayLine].count - 1)
iWayPoint++;
}
if(way_line[iWayLine].point[iWayPoint].origin[2] - me.pmEyePos[2] < 25 && way_line[iWayLine].point[iWayPoint].origin[2] - me.pmEyePos[2] > -100 && GetPointVisible(way_line[iWayLine].point[iWayPoint].origin))
way_mode = WAY_START;
else
{
iWayLine = -1;
iWayPoint = -1;
way_mode = WAY_NONE;
FindAnyWay(cvar.turnfindwaydist);
}
}
else
{
iWayLine = -1;
iWayPoint = -1;
way_mode = WAY_NONE;
FindAnyWay(cvar.turnfindwaydist);
}
}
void AutoWay::WayKilledMode(int mode) //杀人后逃跑
{
if(mode && !runaway) //从0变成1 如:冲刺开始是设为WayKilledMode(0),杀了一人后立即改为WayKilledMode(1),再杀人还是1,不会再次调转方向,冲刺结束再改回WayKilledMode(0)
WayTurn(); //调转沿路线的行走方向,逃跑
runaway=mode;
}
void AutoWay::report_PVS_player (int index, struct cl_entity_s* ent) //敌人来了,用法跟automove中的同名函数一样,2个一起用,无比强大
{
if(!cvar.autowaymove||!cvar.wayuse) //开关未打开
{
ActivePlayer=-1;
return; //返回
}
if((cvar.rush && cvar.nosky)||!cvar.opencheat) //如果是手动冲刺,或者非狂暴力
{
ActivePlayer=-1;
return; //返回
}
if(ActivePlayer!=-1) //如果原本已经有自动冲刺对象了
{
return; //返回
}
float targetdist=cvar.targetdist;
float medist=cvar.medist;
if(isEnemy(index)) //是敌人
{
if(FindWayMeToPoint(index,ent->origin,targetdist,medist,-1,-1)) //是否能找到合适的路线
ActivePlayer=index; //设为自动冲刺对象
else
ActivePlayer=-1;
}
}
void AutoWay::ClearActivePlayer () //清除自动冲刺对象。如自己死了、自己卡住、地图换了、新局开始、冲刺对象已死等等情况,都要清除冲刺对象
{
ActivePlayer=-1;
}