常见的穿墙代码,一般在aimbot.cpp
int CanPenetrate( float *start, float *end, int power )
{
static pmtrace_t* tr = (pmtrace_t*)0x02252DF0;
float view[3];
float dir[3];
view[0] = end[0] - start[0];
view[1] = end[1] - start[1];
view[2] = end[2] - start[2];
float length = VectorLength(view);
dir[0] = view[0] / length;
dir[1] = view[1] / length;
dir[2] = view[2] / length;
float position[3];
position[0] = start[0];
position[1] = start[1];
position[2] = start[2];
tr->startsolid = true;
while( power )
{
if( !tr->startsolid )
power--;
tr = gEngfuncs.PM_TraceLine( position, end, PM_TRACELINE_PHYSENTSONLY, 2, -1);
if( tr->fraction==1.0f )
return 1;
if( tr->allsolid )
return 0;
position[0] = tr->endpos[0] + dir[0] * 8.0f;
position[1] = tr->endpos[1] + dir[1] * 8.0f;
position[2] = tr->endpos[2] + dir[2] * 8.0f;
}
return 0;
}
//====================================================================================
int CheckCurGun ()
{
if (currentWeaponID == WEAPON_SG550 || currentWeaponID == WEAPON_G3SG1 || currentWeaponID == WEAPON_SCOUT || currentWeaponID == WEAPON_AWP)
{ return 3; }
if (currentWeaponID == WEAPON_AUG || currentWeaponID == WEAPON_PARA || currentWeaponID == WEAPON_COLT || currentWeaponID == WEAPON_DEAGLE || currentWeaponID == WEAPON_SIG || currentWeaponID == WEAPON_AK)
{ return 2; }
{ return 0; }
}
//====================================================================================
int PathFree (float * from, float * to)
{
pmtrace_t tr;
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( from, to, PM_GLASS_IGNORE, me.ent->index, &tr );
int pathtest = (tr.fraction == 1.0f);
if (!pathtest && cvar.autowall && CheckCurGun())
{
pathtest = CanPenetrate(from, to, CheckCurGun());
}
return pathtest;
}
cpp改完拉别忘拉h文件,aimbot.h
int CanPenetrate( float *start, float *end, int power ) ;
int PathFree (float * from, float * to) ;
int CheckCurGun () ;
——↑——这分号可是落不得的,要不非郁闷死你不可!!
下面这个比较长,而且得利用trace.cpp里面的功能,我有带附件,自己下载
aimbot.cpp文件,别忘拉,在开头部分加上#include "trace.h"
bool canpenetrate(float *start, float *end)
{
int maxhits = 10, count = 0;
float damage = 120;
strace_t tr;
pmtrace_t beam_tr, beam_tr1, *tmptr;
float srcorigin[3];
float diff[3], length, viewvec[3], unityview[3], position[3];
viewvec[0] = end[0] - start[0];
viewvec[1] = end[1] - start[1];
viewvec[2] = end[2] - start[2];
length = VectorLength(viewvec);
unityview[0] = viewvec[0] / length;
unityview[1] = viewvec[1] / length;
unityview[2] = viewvec[2] / length;
srcorigin[0] = start[0];
srcorigin[1] = start[1];
srcorigin[2] = start[2];
while (damage > 10 && maxhits > 0)
{
maxhits--;
TraceThickness(srcorigin, end, 0, &tr);
if (tr.finished)
break;
if (srcorigin[0] != tr.endpos[0] || srcorigin[1] != tr.endpos[1] || srcorigin[2] != tr.endpos[2])
count++;
if (count >= (GetCurPenetration() + 1) && !tr.finished)
{
damage = 0;
break;
}
position[0] = tr.endpos[0] + unityview[0] * 8.0;
position[1] = tr.endpos[1] + unityview[1] * 8.0;
position[2] = tr.endpos[2] + unityview[2] * 8.0;
tmptr = gEngfuncs.PM_TraceLine(position, end, PM_TRACELINE_PHYSENTSONLY, 2, -1);
memcpy(&beam_tr, tmptr, sizeof(pmtrace_t));
if (!beam_tr.allsolid)
{
tmptr = gEngfuncs.PM_TraceLine(beam_tr.endpos, tr.endpos, PM_TRACELINE_PHYSENTSONLY, 2, -1);
memcpy(&beam_tr1, tmptr, sizeof(pmtrace_t));
diff[0] = beam_tr1.endpos[0] - tr.endpos[0];
diff[1] = beam_tr1.endpos[1] - tr.endpos[1];
diff[2] = beam_tr1.endpos[2] - tr.endpos[2];
length = VectorLength(diff);
if (length < damage)
{
damage -= length;
srcorigin[0] = beam_tr1.endpos[0] + unityview[0];
srcorigin[1] = beam_tr1.endpos[1] + unityview[1];
srcorigin[2] = beam_tr1.endpos[2] + unityview[2];
}
}
else
damage = 0;
}
if (maxhits == 0 && damage)
{
tr.finished = false;
while (!tr.finished)
{
TraceThickness(srcorigin, end, 0, &tr);
if (tr.allsolid)
return false;
if (!tr.startsolid)
{
if (tr.finished)
return damage > 0.0;
return false;
}
srcorigin[0] = tr.endpos[0] + unityview[0];
srcorigin[1] = tr.endpos[1] + unityview[1];
srcorigin[2] = tr.endpos[2] + unityview[2];
}
}
return damage > 0.0;
}
int penetrate;
bool CorrectGun()
{
if(currentWeaponID==WEAPON_DEAGLE)
{
penetrate = WALL_PEN1;
return true;
}
else if(currentWeaponID==WEAPON_SCOUT)
{
penetrate = WALL_PEN2;
return true;
}
else if(currentWeaponID==WEAPON_AWP)
{
penetrate = WALL_PEN2;
return true;
}
else if(currentWeaponID==WEAPON_SIG)
{
penetrate = WALL_PEN2;
return true;
}
else if(currentWeaponID==WEAPON_COLT)
{
penetrate = WALL_PEN2;
return true;
}
else if(currentWeaponID==WEAPON_GALIL)
{
penetrate = WALL_PEN1;
return true;
}
else if(currentWeaponID==WEAPON_FAMAS)
{
penetrate = WALL_PEN1;
return true;
}
else if(currentWeaponID==WEAPON_PARA)
{
penetrate = WALL_PEN2;
return true;
}
else if(currentWeaponID==WEAPON_AUG)
{
penetrate = WALL_PEN1;
return true;
}
else if(currentWeaponID==WEAPON_AK)
{
penetrate = WALL_PEN2;
return true;
}
else if(currentWeaponID==WEAPON_SG550)
{
penetrate = WALL_PEN2;
return true;
}
else if(currentWeaponID==WEAPON_G3SG1)
{
penetrate = WALL_PEN2;
return true;
}
else
{
penetrate = WALL_PEN0;
return true;
}
}
int CurPenetration(void)
{
if (CorrectGun())
return penetrate;
return WALL_PEN0;
}
bool pathFree(float *start, float *end)
{
bool pathtest;
strace_t tr;
if (cvar.autowall && CurPenetration())
{
pathtest = CanPenetrate(start, end);
}
else
{
TraceThickness(start, end, 0, &tr);
if (tr.finished)
pathtest = true;
else
pathtest = false;
}
return pathtest;
}
aimbot.h文件
bool pathFree(float *start, float *end) ;
bool canpenetrate(float *start, float *end);
int CurPenetration(void);
bool CorrectGun();
还有一种很麻烦的穿墙代码,涉及到十来个文件,有点麻烦,在这儿不说拉。
添加中需要注意的是,你代码里原来的名字可能和我的不一样,会出问题。所以添加的时候注意你原来的名字
另外,如果操作中有遇到问题,问我。最好把错的,和错的地方告诉我。