All pastes #952607 Raw Edit

Anonymous

public text v1 · immutable
#952607 ·published 2008-03-22 11:06 UTC
rendered paste body
#include "CAimbot.h"
#include "sdk.h"
//=====================================================================
bool isPistol(const char *szWeaponName){
	if ( strstr( szWeaponName, "_knife_t.mdl" ) )return true;
	else if ( strstr( szWeaponName, "_knife_ct.mdl" ) )return true;
	else if ( strstr( szWeaponName, "_pist_deagle.mdl" ) )return true;
	else if ( strstr( szWeaponName, "_pist_elite.mdl" ) )return true;
	else if ( strstr( szWeaponName, "_pist_fiveseven.mdl" ) )return true;
	else if ( strstr( szWeaponName, "_pist_glock18.mdl" ) )return true;
	else if ( strstr( szWeaponName, "_pist_p228.mdl" ) )return true;
	else if ( strstr( szWeaponName, "_pist_usp.mdl" ) )return true;
	else return false;
}
//=====================================================================
void cCAimbot::MakeVector( QAngle angle, QAngle& vector ) 
{ 
	float pitch; 
	float yaw; 
	float tmp;           
	pitch	= (float)(angle[0] * M_PI/180); 
	yaw		= (float)(angle[1] * M_PI/180); 
	tmp		= (float) cos(pitch);
	vector[0] = (float) (-tmp * -cos(yaw)); 
	vector[1] = (float) (sin(yaw)*tmp);
	vector[2] = (float) -sin(pitch);
}
//=====================================================================
void cCAimbot::CalcAngle( Vector &src, Vector &dst, QAngle &angles )
{
	double delta[3] = { (src[0]-dst[0]), (src[1]-dst[1]), (src[2]-dst[2]) };
	double hyp = sqrt(delta[0]*delta[0] + delta[1]*delta[1]);
	angles[0] = (float) (atan(delta[2]/hyp) * M_RADPI);
	angles[1] = (float) (atan(delta[1]/delta[0]) * M_RADPI);
	angles[2] = 0.0f;
	if(delta[0] >= 0.0) { angles[1] += 180.0f; }
}
//=====================================================================
float cCAimbot::GetFov( QAngle angle, Vector src, Vector dst ) 
{ 
	QAngle ang,aim; 
	float fov; 
	CalcAngle(src, dst, ang); 
	MakeVector(angle, aim); 
	MakeVector(ang, ang);      
	float mag_s = sqrt((aim[0]*aim[0]) + (aim[1]*aim[1]) + (aim[2]*aim[2])); 
	float mag_d = sqrt((aim[0]*aim[0]) + (aim[1]*aim[1]) + (aim[2]*aim[2])); 
	float u_dot_v = aim[0]*ang[0] + aim[1]*ang[1] + aim[2]*ang[2]; 
	fov = acos(u_dot_v / (mag_s*mag_d)) * (180.0 / M_PI); 
	return fov; 
}
//=====================================================================
/*bool cCAimbot::GetVisible( Vector& vecAbsStart, Vector& vecAbsEnd, C_BaseEntity* pBaseEnt ) 
{ 
	player_info_t pinfo;
	trace_t tr;
	Ray_t ray;
	ray.Init( vecAbsStart, vecAbsEnd );
	m_pEnginetrace->TraceRay( ray, MASK_NPCWORLDSTATIC|CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX, NULL, &tr );
	if ( tr.fraction > 0.97f )return true;
	if ( tr.m_pEnt && pBaseEnt ){
		if ( tr.m_pEnt->index == 0 || tr.allsolid )return false;
		if (( m_pEngine->GetPlayerInfo( tr.m_pEnt->index, &pinfo )|| pBaseEnt->index == tr.m_pEnt->index) && tr.fraction > 0.92)return true;
	}
	return false;
}*/
//=====================================================================
 bool cCAimbot::GetVisible( Vector& vAbsStart, Vector& vAbsEnd, C_BaseEntity* pBaseEnt ) { 
player_info_t pInfo; 
trace_t pTrace;
Ray_t pRay;
pRay.Init( vAbsStart, vAbsEnd );
m_pEnginetrace->TraceRay( pRay, MASK_NPCWORLDSTATIC|CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX, NULL, &pTrace );
//surfacedata_t *m_pSurfaceData = m_pPhysicAPI->GetSurfaceData(pTrace.surface.surfaceProps);
if ( pTrace.fraction > 0.97f ) return true;
if ( pTrace.m_pEnt && pBaseEnt ){ 
if ( pTrace.m_pEnt->index == 0 || pTrace.allsolid ) return false;
if (( m_pEngine->GetPlayerInfo( pTrace.m_pEnt->index, &pInfo ) || pBaseEnt->index == pTrace.m_pEnt->index) && pTrace.fraction > 0.92) return true; //the 85 is the % player has to be visible
}
return false;
}
//=====================================================================
bool GetBonePosition ( int iBone, Vector& vecOrigin, QAngle qAngles, int index )
{
	if( iBone < 0 || iBone >= 20 )return false;
	matrix3x4_t pmatrix[MAXSTUDIOBONES];
	IClientEntity* ClientEntity = m_pEntList->GetClientEntity( index );
	if ( ClientEntity == NULL )return false;
	if ( ClientEntity->IsDormant() )return false;
	IClientRenderable* RenderEntity =  ClientEntity->GetClientRenderable();
	if(	RenderEntity == NULL/* nothing */ )return false;
	if( RenderEntity->SetupBones( pmatrix, 128, BONE_USED_BY_HITBOX, m_pGlobals->curtime ) == false )return false;
	MatrixAngles( pmatrix[ iBone ], qAngles, vecOrigin );
	return true;
}
//=====================================================================

//=====================================================================
//=====================================================================
void cCAimbot::AimAtTarget( CUserCmd* c )
{ 
	if( m_pEngine->IsInGame() == false 
	||	m_pEngine->IsHLTV() == true  
	||	m_pMyPlayer->BaseEnt() == NULL )
		return;

	m_nTarget = -1;

	player_info_t pinfo;

	for( int index = 1; index <= m_pEntList->NumberOfEntities( false ); ++index )
	{
		if ( index == m_pEngine->GetLocalPlayer() )
			continue;

		IClientEntity* ClientEntity = m_pEntList->GetClientEntity( index );

		if (	ClientEntity == NULL
			||	ClientEntity->IsDormant() )
				continue;

		CBaseEntity* pBaseEntity = ClientEntity->GetBaseEntity();
		int iLifestate = *(int*) ( ( DWORD )pBaseEntity + ( DWORD )0x87 );

		if(		pBaseEntity == NULL
			||	pBaseEntity->IsDormant()
			||	!(iLifestate  == LIFE_ALIVE)
			||	m_pEngine->GetPlayerInfo( index, &pinfo ) == false
			||	pBaseEntity->GetTeamNumber() == m_pMyPlayer->BaseEnt()->GetTeamNumber()
			||	!GetBonePosition( 14, vPlayer, c->viewangles, index )
			||	GetFov( m_pMyPlayer->BaseEnt()->GetAbsAngles(), m_pMyPlayer->BaseEnt()->EyePosition(), vPlayer )>gCvar.aim_fov
			||	!GetVisible( m_pMyPlayer->BaseEnt()->EyePosition(), vPlayer, pBaseEntity ))
				continue;

		m_nTarget = index;
	}
	if( m_nTarget == -1 )	
		return;

	CalcAngle( m_pMyPlayer->BaseEnt()->EyePosition(), vPlayer, c->viewangles );

	m_pEngine->SetViewAngles( c->viewangles );

	char szWeapon[255];
	C_BaseCombatWeapon *cWeapon = m_pNeeded->GetBaseCombatActiveWeapon(m_pMyPlayer->BaseEnt());
	strcat(szWeapon,m_pModelinfo->GetModelName(cWeapon->GetModel()));

	c->buttons |= IN_ATTACK;
			
	if ( c->buttons & IN_ATTACK && isPistol(szWeapon)){
		static bool o = false;
		if(o) c->buttons |= IN_ATTACK;    
		else c->buttons &= (~IN_ATTACK); 
		o = !o;
	}
}
//=====================================================================