to add boneaim!
first of all you have to add the aimbot part for boneaim
k got o your aimbot.cpp #include "console.h"
now look for:
OriginAimbot gAimbot;
change that to:
BoneAimbot gAimbot;
now at the bottom of your aimbot where your CalcViewAngles below add this for bone
Code:
//===================================================================================
class DrawPoints
{
public:
void aggregate(float* _origin, DWORD _color=0xFFFFFFFF, int _size=1);
void draw_all ();
protected:
// scheduled draw points
struct ScheduledDrawPoint
{
ScheduledDrawPoint() : active(false) {}
vec3_t origin;
DWORD color_compiled;
int size;
bool active;
};
enum { MAX_DRAW_POINTS=64 };
std::vector<ScheduledDrawPoint> vecDrawPoints;//(64);
int DrawPointsNextIndex;
public:
DrawPoints() : DrawPointsNextIndex(0), vecDrawPoints(MAX_DRAW_POINTS) {}
};
//===================================================================================
void DrawPoints::aggregate(float* _origin, DWORD _color , int _size )
{
VectorCopy(_origin,vecDrawPoints[DrawPointsNextIndex].origin);
vecDrawPoints[DrawPointsNextIndex].color_compiled = _color;
vecDrawPoints[DrawPointsNextIndex].size = _size;
vecDrawPoints[DrawPointsNextIndex].active = true;
DrawPointsNextIndex++;
if( DrawPointsNextIndex>=(int)vecDrawPoints.size() ) DrawPointsNextIndex=0;
}
// ======= DrawAllHudPoints
void DrawPoints::draw_all()
{
typedef vector<ScheduledDrawPoint> vp;
for( vp::iterator pos=vecDrawPoints.begin(); pos!=vecDrawPoints.end(); ++pos )
{
if( (*pos).active )
{
ScheduledDrawPoint& point = (*pos);
point.active=false;
gDrawFilledBoxAtLocation(point.origin,point.color_compiled,point.size);
}
}
}
// global DrawPoints
static DrawPoints gDrawPoints;
//==========================================================================================
void BoneAimbot::CalcTargetSpot(float* out)
{
if( vPlayers[target].numTargetSpots && cvar.modelaim )
{
ModelBasedAim(out);
}
else
{
OriginAimbot::CalcTargetSpot(out);
}
}
// ========================================================================
void BoneAimbot::ModelBasedAim(float* TargetVec)
{
// try first spot:
int i = firstaimspot;
if( i<vPlayers[target].numTargetSpots && i>=0 )
{
float* testvec = vPlayers[target].TargetSpots;
if(pathFree(me.pmEyePos,testvec))
{
VectorCopy(testvec,TargetVec);
return;
}
}
for(i=0;i<vPlayers[target].numTargetSpots;i++)
{
if(i==firstaimspot) continue;
float* testvec = vPlayers[target].TargetSpots;
if(pathFree(me.pmEyePos,testvec))
{
VectorCopy(testvec,TargetVec);
return;
}
}
VectorCopy(vPlayers[target].TargetSpots[0], TargetVec );
}
//==========================================================================================
BoneAimbot::ModelInfo* BoneAimbot::getModelInfo(const char* arg_name)
{
assert(arg_name);
if(hashToInfo.size()>32)
{
gConsole.echo("&rerror: Model limit reached.");
return NULL;
}
ModelInfo& info = hashToInfo[arg_name];
info.name = arg_name;
return &info;
}
//==========================================================================================
void BoneAimbot::draw()
{
if(cvar.avdraw<=2) { OriginAimbot::draw(); return; };
gDrawPoints.draw_all();
}
//==============================================================================
void BoneAimbot::load(const char* filename)
{
}
//==============================================================================
void BoneAimbot::save(const char* filename)
{
ofstream ofs(filename);
if(!ofs) { gConsole.echo( "&w%s&r write error.",filename); return; }
else { gConsole.echo( "&w%s&g saved." ,filename); }
ofs<<"// this file is generated automatically. do not edit!"<<endl;
ofs<<"mdl clear_models"<<endl;
for( iterator pos = hashToInfo.begin(); pos!=hashToInfo.end(); ++pos )
{
ModelInfo& info = (*pos).second;
ofs<<endl<<"mdl new "<<info.name<<endl;
for(int i=0;i<info.numAimspots;i++)
{
ModelAimSpot& spot = info.aimspots;
if(spot.boneindex)
ofs<<"mdl add_spot "<<spot.boneindex<<" "<<spot.boneindex2<<" "<<spot.factor2<<endl;
else
ofs<<"mdl add_spot "<<spot.boneindex<<endl;
}
}
ofs<<endl<<"mdl ov "<<offset_first.h<<" "<<offset_first.f<<" "<<offset_first.r<<endl;
}
// ==================================================================
static void calcPredictDelta(cl_entity_s* ent, float *delta)
{
if (cvar.pred)
{
int historyIndex = (ent->current_position+HISTORY_MAX-cvar.predback)%HISTORY_MAX;
float* vFromOrigin = ent->ph[historyIndex].origin;
float* vToOrigin = ent->ph[ent->current_position].origin;
delta[0] = vToOrigin[0] - vFromOrigin[0];
delta[1] = vToOrigin[1] - vFromOrigin[1];
delta[2] = vToOrigin[2] - vFromOrigin[2];
delta[0] *= cvar.predahead;
delta[1] *= cvar.predahead;
delta[2] *= cvar.predahead;
}
else
{
delta[0]=delta[1]=delta[2]=0;
}
}
////==============================================================================
void BoneAimbot::PostStudioDrawPlayer( int flags, struct entity_state_s *pplayer )
{
int ax = pplayer->number;
if(!vPlayers[ax].getPVS()) return;
// non visible players return wrong bones!
if(GetAimingFov(ax) < (40.0-180.0)/-180.0) return;
cl_entity_s* ent = vPlayers[ax].getEnt();
model_s* pModel = pstudio->SetupPlayerModel(ax-1);
studiohdr_t* pStudioHeader = (studiohdr_t*)pstudio->Mod_Extradata( pModel );
// get bone transform
typedef float TransformMatrix[ MAXSTUDIOBONES ][ 3 ][ 4 ];
TransformMatrix* pbonetransform = (TransformMatrix*)pstudio->StudioGetBoneTransform();
// get model info
if(cvar.avdraw==3) gSetHudMessage(pStudioHeader->name);
ModelInfo* l_modelInfo = getModelInfo(pStudioHeader->name);
if(!l_modelInfo) return;
// grab target spots:
vec3_t predictDelta;
calcPredictDelta(ent, predictDelta );
for( int i=0;i<l_modelInfo->numAimspots;i++ )
{
ModelAimSpot& spot = l_modelInfo->aimspots;
vec3_t& pos = vPlayers[ax].TargetSpots;
pos [ 0 ] = (*pbonetransform)[ spot.boneindex ][ 0 ][ 3 ];
pos [ 1 ] = (*pbonetransform)[ spot.boneindex ][ 1 ][ 3 ];
pos [ 2 ] = (*pbonetransform)[ spot.boneindex ][ 2 ][ 3 ];
// interpolate between two bones
if( spot.boneindex2 )
{
vec3_t to, diff;
to [ 0 ] = (*pbonetransform)[ spot.boneindex2 ][ 0 ][ 3 ];
to [ 1 ] = (*pbonetransform)[ spot.boneindex2 ][ 1 ][ 3 ];
to [ 2 ] = (*pbonetransform)[ spot.boneindex2 ][ 2 ][ 3 ];
diff = to - pos;
pos[0] += (spot.factor2 * diff[0]);
pos[1] += (spot.factor2 * diff[1]);
pos[2] += (spot.factor2 * diff[2]);
}
// predict
pos[0] += predictDelta[0];
pos[1] += predictDelta[1];
pos[2] += predictDelta[2];
// offset first spot
if(!i)
{
vec3_t anglevec, forward, right, up, offset;
anglevec[0] = 0;
anglevec[1] = pplayer->angles[1];
anglevec[2] = 0;
gEngfuncs.pfnAngleVectors(pplayer->angles,forward,right,up);
offset = forward*offset_first.f + right*offset_first.r + up*offset_first.h;
vPlayers[ax].TargetSpots[0][0] += offset[0];
vPlayers[ax].TargetSpots[0][1] += offset[1];
vPlayers[ax].TargetSpots[0][2] += offset[2];
}
{
// log for drawing
if( cvar.avdraw==4 )
{
if( i==firstaimspot ) gDrawPoints.aggregate(pos,0xFF1111FF,2);
else gDrawPoints.aggregate(pos,0xFFFFFFFF);
} else
if( cvar.avdraw==5 )
{
if( i==firstaimspot ) gDrawPoints.aggregate(pos,0xFF1111FF,2);
}
}
}
// handle Drawing
if(cvar.avdraw>=3)
{
int i = my_curSelectedBone;
if( i>=0 && i<pStudioHeader->numbones )
{
vec3_t pos;
pos[ 0 ] = (*pbonetransform)[ i ][ 0 ][ 3 ];
pos[ 1 ] = (*pbonetransform)[ i ][ 1 ][ 3 ];
pos[ 2 ] = (*pbonetransform)[ i ][ 2 ][ 3 ];
gDrawPoints.aggregate( pos, 0xFFFFAAFF, 2 );
mstudiobone_t *pbones = (mstudiobone_t *)((byte *)pStudioHeader + pStudioHeader->boneindex);
char tmp[64];sprintf(tmp,"#%d: %s",i,pbones.name);
gSetHudMessage2(tmp);
}
}
// update info:
vPlayers[ax].numTargetSpots = l_modelInfo->numAimspots;
}
//==================================================================================
void BoneAimbot::command()
{
const char* thecommand = cmd.argC(1);
if(0){}
else if(!strcmp(thecommand,"first"))
{
firstaimspot = cmd.argI(2);
}
else if(!strcmp(thecommand,"list"))
{
//
int i=0;
for(HashToInfoMap::iterator pos=hashToInfo.begin();pos!=hashToInfo.end();++pos,++i)
{
gConsole.echo("&g#%d: &w%s, spots: %d",i,(*pos).first.c_str(),(*pos).second.numAimspots );
}
}
else if(!strcmp(thecommand,"select"))
{
//
int scan = cmd.argI(2);
int i=0;
for(HashToInfoMap::iterator pos=hashToInfo.begin();pos!=hashToInfo.end();++pos,++i)
{
if(i==scan)
{
gConsole.echo("current model: &r%s",(*pos).first.c_str());
my_curModelInfo = getModelInfo( (*pos).first.c_str() );
break;
}
}
}
else if(!strcmp(thecommand,"new"))
{
if(*cmd.argC(2))
{
my_curModelInfo = getModelInfo( cmd.argC(2) );
}
}
else if(!strcmp(thecommand,"clear_models"))
{
my_curModelInfo=NULL;
hashToInfo.clear();
}
else if(!strcmp(thecommand,"set_team"))
{
if(!my_curModelInfo) return;
my_curModelInfo->team = cmd.argI(2);
}
else if(!strcmp(thecommand,"add_spot"))
{
if(!my_curModelInfo) return;
int insert_index = my_curModelInfo->numAimspots;
if( insert_index>=MAX_TARGET_SPOTS )
{
gConsole.echo( "too many target spots" );
return;
}
int arg1 = cmd.argI(2);
int arg2 = cmd.argI(3);
float arg3 = cmd.argF(4);
if( arg1<0 || arg1>=MAXSTUDIOBONES || arg2<0 || arg2>=MAXSTUDIOBONES )
{
gConsole.echo( "bone index out of bounds" );
return;
}
my_curModelInfo->numAimspots++;
ModelAimSpot& spot = my_curModelInfo->aimspots[insert_index];
spot.boneindex = arg1;
spot.boneindex2 = arg2;
spot.factor2 = arg3;
}
else if(!strcmp(thecommand,"clear_spots"))
{
if(!my_curModelInfo) return;
my_curModelInfo->numAimspots=0;
}
else if(!strcmp(thecommand,"info"))
{
if(!my_curModelInfo) return;
for(int i=0;i<my_curModelInfo->numAimspots;i++)
{
ModelAimSpot& spot = my_curModelInfo->aimspots;
if(!spot.boneindex2)
{
gConsole.echo("&w#%d&a: bone: %d",i,spot.boneindex);
}
else
{
gConsole.echo("&w#%d&a: %d -> %d , %5.3f",i,spot.boneindex,spot.boneindex2,spot.factor2);
}
}
gConsole.echo( "mdl=&w%s&a team=&w%d&a n=&w%d", my_curModelInfo->name.c_str(), my_curModelInfo->team, my_curModelInfo->numAimspots);
}
else if(!strcmp(thecommand,"save"))
{
string getOgcDirFile(const char* basename);
save( getOgcDirFile(cmd.argC(2)).c_str() );
}
else if(!strcmp(thecommand,"ov"))
{
offset_first.h = cmd.argF(2);
offset_first.f = cmd.argF(3);
offset_first.r = cmd.argF(4);
}
else
{
gConsole.echo("unrecognized sub-command");
}
}
ok now go into your aimbot.h
at the bottom where you see:
extern OriginAimbot gAimbot;
#endif
replace that with: Code:
class BoneAimbot
:public OriginAimbot
{
//
// This class intercepts the StudioDrawPlayer call
// and updates vPlayer target spots, but only for the currently
// targeted player ( this->target )
// it also assists in team detection by providing a model
// based team detection.
//
public:
virtual void command();
// draw aiming info according to avdraw. call this in hud_redraw
virtual void draw();
virtual void save(const char* filename);
virtual void load(const char* filename);
// updates vPlayer target spots for current target
virtual void PostStudioDrawPlayer( int flags, struct entity_state_s *pplayer );
// used for avdraw 3 type. selects which bone to highlight. used for editing.
int my_curSelectedBone;
protected:
struct ModelAimSpot
{
ModelAimSpot() : boneindex(0), boneindex2(0), factor2(0.5) {}
int boneindex; // bone to aim at
int boneindex2; // if boneindex2 != 0, we are using 2-bone based aiming
float factor2; // scale factor for bone1->bone2 vector
//vec3_t offset; // optional offset
};
struct ModelInfo
{
ModelInfo() : team(0), numAimspots(0){}
int numAimspots;
ModelAimSpot aimspots[MAX_TARGET_SPOTS];
int team;
string name;
};
typedef std::map< std::string, ModelInfo > HashToInfoMap;
typedef HashToInfoMap::iterator iterator;
// used to map a model hash to a ModelInfo
HashToInfoMap hashToInfo;
// model info currently active (targeted)
struct ModelInfo* my_curModelInfo;
// optional offset for first aim spot only (head)
aimvec offset_first;
// returns NULL if not found, creates if cretenew set.
virtual ModelInfo* getModelInfo(const char* arg_name);
void init()
{
target = -1;
my_curSelectedBone = 0;
my_curModelInfo = NULL;
offset_first.f=offset_first.h=offset_first.r=0;
}
// origin aimbot hook. calculates a better target spot if data available
virtual void CalcTargetSpot(float *out);
virtual void ModelBasedAim (float* out);
public:
BoneAimbot() {init();}
};
extern BoneAimbot gAimbot;
#endif
thats it for the aimbot work make sure your Draw or draw is spelt correct, It must match case!
ok now go to your client.cpp
and look for this undernieth: UpdateScreenInfo Code:
int (*pHUD_GetStudioModelInterface)( int, struct r_studio_interface_s **, struct engine_studio_api_s *);
int HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio )
{
int nResult = pHUD_GetStudioModelInterface(version,ppinterface,pstudio);
memcpy( &IEngineStudio, pstudio, sizeof( IEngineStudio ) );
pIEngineStudio = &IEngineStudio;
if(ppinterface && *ppinterface)
{
OrigStudioDrawPlayer = (*ppinterface)->StudioDrawPlayer;
}
return nResult;
}
replace that with this: Code:
r_studio_interface_s **ppinterface = (r_studio_interface_s**) 0x01ECF2B4; <--- offset for bone aim
int (*pStudioDrawPlayer) ( int flags, entity_state_s *pplayer );
int StudioDrawPlayer( int flags, entity_state_s *player )
{
int ret = pStudioDrawPlayer(flags, player);
gAimbot.PostStudioDrawPlayer( flags, player);
return ret;
}
now go to your hud_redraw in it at top add this: Code:
static bool qwert = true;
if(qwert)
{
pStudioDrawPlayer = (*ppinterface)->StudioDrawPlayer;
(*ppinterface)->StudioDrawPlayer = &StudioDrawPlayer;
qwert=false;
}
now go to where your Init_Command_Interpreter
above that add these func_'s Code:
void func_mdl()
{
gAimbot.command();
}
//===================================================================================
string mdlov(float h, float f, float r)
{
char tmp[256] = "";
sprintf(tmp,"mdl ov %2.2f %2.2f %2.2f",h,f,r);
string ret=tmp;
return tmp;
}
//===================================================================================
void func_testbone1()
{
cmd.exec( "modelaim 1;avdraw 5" );
cmd.exec( mdlov( 1.21, 1.5, 1.09 ).c_str() );
cmd.exec( "txt [-uCa-]RucKuS's TesT BoNE AuT0M4TiC!" );
}
void func_testbone2()
{
cmd.exec( "modelaim 1;avdraw 5" );
cmd.exec( mdlov( 1.13, 1.9, 1.103 ).c_str() );
cmd.exec( "txt [-uCa-]RucKuS's TesT BoNE PiSt0l!" );
}
void func_testbone3()
{
cmd.exec( "modelaim 1;avdraw 5" );
cmd.exec( mdlov( 0.91, 1.7, 1.26 ).c_str() );
cmd.exec( "txt [-uCa-]g3n0cId3's TesT BoNE AuT0m4TiC!" );
}
void func_testbone4()
{
cmd.exec( "modelaim 1;avdraw 5" );
cmd.exec( mdlov( 1.3, 1.4, 1.009 ).c_str() );
cmd.exec( "txt [-uCa-]g3n0cId3's TesT BoNE D34GL3!" );
}
register them in: Init_Command_Interpreter Code:
REGISTER_COMMAND(mdl )
REGISTER_COMMAND(testbone1 )
REGISTER_COMMAND(testbone2 )
REGISTER_COMMAND(testbone3 )
REGISTER_COMMAND(testbone4 )
register this too: Code:
cmd.AddCvarInt( "bone", &gAimbot.my_curSelectedBone );
put it above this: Code:
cmd.AddCvarInt( "alive", (int*)&me.alive );
cmd.AddCvarInt( "target", (int*)&gAimbot.target );
example: Code:
cmd.AddCvarInt( "bone", &gAimbot.my_curSelectedBone );
cmd.AddCvarInt( "alive", (int*)&me.alive );
cmd.AddCvarInt( "target", (int*)&gAimbot.target );
now go to the bottom of your client.cpp where your OnlyHook
delete this: Code:
r_studio_interface_t *pOrigEngineStudioInterface;
int GetPlayerByIndex(int index)
{
for (unsigned int ax=0;ax<vPlayers.size();ax++)
if (vPlayers[ax].index == index) return ax;
return -1;
}
int R_StudioDrawPlayer(int flags, entity_state_t *pplayer)
{
int retval = 0;
const char PROC_NAME[50] = "R_StudioDrawPlayer\0";
retval = (*pOrigEngineStudioInterface->StudioDrawPlayer)(flags, pplayer);
if (!hackActive) return retval;
cl_entity_t *curEntity;
curEntity = IEngineStudio.GetCurrentEntity();
int ax;
ax = GetPlayerByIndex(curEntity->index);
studiohdr_t *a;
model_t *b;
b = IEngineStudio.SetupPlayerModel(pplayer->number-1);
a = (studiohdr_t *)IEngineStudio.Mod_Extradata(b);
model_t *mdl;
mdl = IEngineStudio.GetModelByIndex(pplayer->modelindex);
mstudiobone_t *testbone;
testbone = (mstudiobone_t *)((byte *)a + a->boneindex);
int bonenumber = -1;
static bool doneThisOnce = false;
doneThisOnce = true;
return retval;
}
int R_StudioDrawModel(int flags)
{
return (*pOrigEngineStudioInterface->StudioDrawModel)(flags);
}
r_studio_interface_t HookGameStudioInterface =
{
STUDIO_INTERFACE_VERSION,
R_StudioDrawModel,
R_StudioDrawPlayer,
};
int HUD_GetStudioModelInterface_Hook (int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio)
{
const char PROC_NAME[50] = "HUD_GetStudioModelInterface_Hook\0";
int retval;
// Do patching here....
retval = pHUD_GetStudioModelInterface (version,&pOrigEngineStudioInterface,pstudio);
*ppinterface = &HookGameStudioInterface;
return retval;
}
void PatchClientFunc( DWORD *ClientFunc_ADDR )
{
*( ( DWORD * )&pHUD_GetStudioModelInterface ) = *( ( DWORD * )( *( ( DWORD * )&ClientFunc_ADDR ) + 0x9C ) );
*( ( DWORD * )( *( ( DWORD * )&ClientFunc_ADDR ) + 0x9C ) ) = ( DWORD )&HUD_GetStudioModelInterface_Hook;
}
now that its deleted
add this instead Code:
r_studio_interface_t *pOrigEngineStudioInterface;
int GetPlayerByIndex(int index)
{
for (unsigned int ax=0;ax<vPlayers.size();ax++)
if (vPlayers[ax].index == index) return ax;
return -1;
}
void PatchClientFunc( DWORD *ClientFunc_ADDR )
{
}
go into your client.h look for: extern struct engine_studio_api_s* pIEngineStudio;
above it add: Code:
extern engine_studio_api_s* pstudio;
extern cl_enginefuncs_s* pEngfuncs;
add your cvars for modelaim Code:
REGISTER_CVAR_INT( modelaim ,0)
int modelaim;