Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "aimbot.h"
- #include "hook.h"
- //===================================================================================
- cAimbot gAimbot;
- //===================================================================================
- bool checkAim(int aimType){
- switch(aimType){
- case 1:
- return true;
- break;
- case 2:
- return GetAsyncKeyState(VK_LBUTTON);
- break;
- case 3:
- return GetAsyncKeyState(VK_RBUTTON);
- break;
- case 4:
- return GetAsyncKeyState(VK_MBUTTON);
- break;
- default:
- return false;
- break;
- }
- }
- //===================================================================================
- bool checkTeam(CBaseEntity *baseEnt){
- switch(gCvar.team){
- case 0:
- return gPlayer.isEnemy(baseEnt);
- break;
- case 1:
- return !gPlayer.isEnemy(baseEnt);
- break;
- case 2:
- return true;
- break;
- }
- return false;
- }
- //===================================================================================
- void makeVector(QAngle angle,QAngle &vector){
- float pitch = (float)(angle[0] * 0.0174532889),yaw = (float)(angle[1] * 0.0174532889),temp = (float)cos(pitch);
- vector[0] = (float)(-temp * -cos(yaw));
- vector[1] = (float)(sin(yaw) * temp);
- vector[2] = (float)-sin(pitch);
- }
- //===================================================================================
- float checkFov(QAngle angle,Vector source,Vector dest){
- float fov = 0.0f,mag = 0.0f,dot = 0.0f;
- QAngle ang,aim;
- gUtil.calcAngles(source,dest,ang);
- makeVector(angle,aim);
- makeVector(ang,ang);
- mag = sqrt(aim[0] * aim[0] + aim[1] * aim[1] + aim[2] * aim[2]);
- dot = aim[0] * ang[0] + aim[1] * ang[1] + aim[2] * ang[2];
- fov = acos(dot / (mag * mag)) * 57.2957914;
- return fov;
- }
- //===================================================================================
- cAimbot::cAimbot(){
- target = -1;
- }
- //===================================================================================
- bool cAimbot::checkVisible(Vector &vecAbsStart,Vector &vecAbsEnd,CBaseEntity *baseEnt)
- {
- player_info_t pinfo;
- trace_t tr;
- Ray_t ray;
- ray.Init(vecAbsStart,vecAbsEnd);
- m_pEngineTrace->TraceRay(ray,MASK_NPCWORLDSTATIC | MASK_SHOT,0,&tr);
- surfacedata_t *m_pSurfaceData = m_pPhysicAPI->GetSurfaceData(tr.surface.surfaceProps);
- if(tr.fraction > 0.97f)
- return true;
- if(tr.m_pEnt && baseEnt){
- if(gCvar.awall){
- switch(m_pSurfaceData->game.material){
- //case CHAR_TEX_METAL:
- case CHAR_TEX_GRATE:
- case CHAR_TEX_VENT:
- case CHAR_TEX_TILE:
- case CHAR_TEX_COMPUTER:
- case CHAR_TEX_WOOD:
- case CHAR_TEX_ANTLION:
- case CHAR_TEX_CLIP:
- case CHAR_TEX_ALIENFLESH:
- case CHAR_TEX_FOLIAGE:
- case CHAR_TEX_GLASS:
- case CHAR_TEX_PLASTIC:
- case CHAR_TEX_BLOODYFLESH:
- case CHAR_TEX_FLESH:
- return true;
- default:
- return false;
- }
- if(tr.fraction != 1.0){
- if(tr.allsolid || tr.DidHitWorld())
- return false;
- }else
- return true;
- }
- if(!tr.m_pEnt->index || tr.allsolid)
- return false;
- if((m_pEngine->GetPlayerInfo(tr.m_pEnt->index,&pinfo) || baseEnt->index == tr.m_pEnt->index) && tr.fraction > 0.92)
- return true;
- }
- return false;
- }
- //===================================================================================
- CBaseEntity* GetIndex( int idx )
- {
- __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop __asm nop
- if( m_pEntList == NULL ) return NULL;
- IClientEntity *pClient = m_pEntList->GetClientEntity( idx );
- if( pClient == NULL ) return NULL;
- return pClient->GetBaseEntity();
- }
- bool cAimbot::setupHitbox(Vector &vecOrigin, CBaseEntity* baseEnt)
- {
- matrix3x4_t pmatrix[MAXSTUDIOBONES];
- QAngle angles;
- const model_t *m_pModel = baseEnt->GetModel();
- if(m_pModel)
- {
- studiohdr_t *pStudioHdr = m_pModelInfo->GetStudiomodel(m_pModel);
- if(baseEnt->SetupBones(pmatrix, 128, BONE_USED_BY_HITBOX, m_pGlobals->curtime) == false)
- return false;
- mstudiohitboxset_t *set =pStudioHdr->pHitboxSet(0);
- Vector vMin,vMax,vecPosition, vPlayer;
- QAngle angles;mstudiobbox_t* m_pHitbox = NULL;
- for(int i = 0; i < pStudioHdr->numhitboxsets;i++)
- {
- for(int r = 0; r < pStudioHdr->iHitboxCount(i); r++)
- {
- m_pHitbox = pStudioHdr->pHitbox(r, i);
- if(!m_pHitbox)
- continue;
- if(m_pHitbox->bone == 14)
- {
- MatrixAngles(pmatrix[ m_pHitbox->bone ], angles,vecPosition);
- VectorTransform(m_pHitbox->bbmin, pmatrix[ m_pHitbox->bone ], vMin);
- VectorTransform(m_pHitbox->bbmax, pmatrix[ m_pHitbox->bone ], vMax);
- vecOrigin = (vMin + vMax) * 0.5f;
- }
- }
- }
- }
- return true;
- }
- //===================================================================================
- Vector GetEyePos(C_BaseEntity* pEntity)
- {
- return pEntity->GetAbsOrigin() + *(Vector*)((DWORD)pEntity + 0x0E4 );
- }
- float flGetDistance( Vector from,Vector to )
- {
- float x = from[0] - to[0];
- float y = from[1] - to[1];
- float z = from[2] - to[2];
- return sqrt(x*x + y*y + z*z);
- }
- void cAimbot::findTarget(CUserCmd*pCmd)
- {
- CBaseEntity *pLocal = m_pEntList->GetClientEntity(m_pEngine->GetLocalPlayer())->GetBaseEntity();
- if ( pLocal == NULL )
- return;
- Vector vEyePos = pLocal->GetAbsOrigin() + *(Vector*)((DWORD)pLocal + 0x0E4 );
- player_info_t pi;
- int m_target = -1;
- float distance = 99999.9f;
- Vector aiming_Org[64], PredOrg[64];
- for( int i = 1; i < m_pEntList->GetMaxEntities( ); i++ )
- {
- C_BaseEntity *pBaseEntity = GetIndex( i );
- if( pBaseEntity == NULL )
- continue;
- if( pBaseEntity->index == pLocal->index )
- continue;
- if( stricmp( pBaseEntity->GetClientClass()->GetName(), "CCSPlayer" ) == 0 )
- {
- player_info_t pi;
- int *health = (int*) ( (DWORD)pBaseEntity + (DWORD)0x90);
- char *lifeState = ( char* )( ( DWORD_PTR )pBaseEntity + 0x8F );
- if( *lifeState > 0 )
- continue;
- if( health <= 0 )
- continue;
- if( m_pEngine->GetPlayerInfo( pBaseEntity->index, &pi ) == false )
- continue;
- if( pBaseEntity->IsDormant() )
- continue;
- //if(bHasAmmo() == false)
- // continue;
- if( pBaseEntity->GetTeamNumber() == pLocal->GetTeamNumber())
- continue;
- //if(gVars.Aim_dmfix2 && *health > 151)
- // continue;
- if( !gAimbot.setupHitbox(aiming_Org[i],pBaseEntity) )
- continue;
- if( !gAimbot.checkVisible( vEyePos, aiming_Org[i], pBaseEntity))
- continue;
- float Tmp = flGetDistance( vEyePos, pBaseEntity->GetAbsOrigin( ) ) / 22.f;
- if( Tmp < distance )
- {
- m_target = i;
- distance = Tmp;
- //PredOrg = aiming_Org /*- delta_Org*/;
- }
- }
- }
- if(m_target == -1)
- return;
- VectorAngles( ( aiming_Org[m_target] - vEyePos ), pCmd->viewangles );
- if(gCvar.smooth != 0.0)
- {
- float diff[3];
- QAngle curViewAngles;
- m_pEngine->GetViewAngles(curViewAngles);
- diff[0] = pCmd->viewangles[0] - curViewAngles[0];
- diff[1] = pCmd->viewangles[1] - curViewAngles[1];
- if(diff[0] > 180)
- diff[0] -= 360;
- if(diff[1] > 180)
- diff[1] -= 360;
- if(diff[0] < -180)
- diff[0] += 360;
- if(diff[1] < -180)
- diff[1] += 360;
- if(diff[0] > gCvar.smooth)
- pCmd->viewangles[0] = curViewAngles[0] + gCvar.smooth;
- else if(diff[0] < -gCvar.smooth)
- pCmd->viewangles[0] = curViewAngles[0] - gCvar.smooth;
- if(diff[1] > gCvar.smooth)
- pCmd->viewangles[1] = curViewAngles[1] + gCvar.smooth;
- else if(diff[1] < -gCvar.smooth)
- pCmd->viewangles[1] = curViewAngles[1] - gCvar.smooth;
- if(pCmd->viewangles[0] > 180)
- pCmd->viewangles[0] -= 360;
- if(pCmd->viewangles[1] > 180)
- pCmd->viewangles[1] -= 360;
- if(pCmd->viewangles[0] < -180)
- pCmd->viewangles[0] += 360;
- if(pCmd->viewangles[1] < -180)
- pCmd->viewangles[1] += 360;
- }
- m_pEngine->SetViewAngles(pCmd->viewangles);
- if(gCvar.rfire==1)
- {
- static bool wSwitch = true;
- wSwitch ? pCmd->buttons &= ~IN_ATTACK : pCmd->buttons |= IN_ATTACK;
- wSwitch =! wSwitch;
- }
- m_target = -1;
- }
- //===================================================================================
- bool cAimbot::triggerBot(){
- player_info_t pInfo;
- trace_t tr;
- Ray_t ray;
- Vector vecDir;
- AngleVectors(gPlayer.baseEnt()->GetAbsAngles(),&vecDir);
- vecDir = vecDir * 8192 + gPlayer.baseEnt()->EyePosition();
- ray.Init(gPlayer.baseEnt()->EyePosition(),vecDir);
- m_pEngineTrace->TraceRay(ray,(CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_DEBRIS | CONTENTS_HITBOX),0,&tr);
- if(tr.allsolid || tr.DidHitWorld())
- return false;
- if(tr.m_pEnt && m_pEngine->GetPlayerInfo(tr.m_pEnt->index,&pInfo) && gPlayer.isEnemy(tr.m_pEnt))
- return tr.m_pEnt->index;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement