Advertisement
encoree1996

Untitled

Apr 23rd, 2015
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.73 KB | None | 0 0
  1. #include "aimbot.h"
  2. #include "hook.h"
  3. //===================================================================================
  4. cAimbot gAimbot;
  5. //===================================================================================
  6. bool checkAim(int aimType){
  7. switch(aimType){
  8. case 1:
  9. return true;
  10. break;
  11. case 2:
  12. return GetAsyncKeyState(VK_LBUTTON);
  13. break;
  14. case 3:
  15. return GetAsyncKeyState(VK_RBUTTON);
  16. break;
  17. case 4:
  18. return GetAsyncKeyState(VK_MBUTTON);
  19. break;
  20. default:
  21. return false;
  22. break;
  23. }
  24. }
  25. //===================================================================================
  26. bool checkTeam(CBaseEntity *baseEnt){
  27. switch(gCvar.team){
  28. case 0:
  29. return gPlayer.isEnemy(baseEnt);
  30. break;
  31. case 1:
  32. return !gPlayer.isEnemy(baseEnt);
  33. break;
  34. case 2:
  35. return true;
  36. break;
  37. }
  38. return false;
  39. }
  40. //===================================================================================
  41. void makeVector(QAngle angle,QAngle &vector){
  42. float pitch = (float)(angle[0] * 0.0174532889),yaw = (float)(angle[1] * 0.0174532889),temp = (float)cos(pitch);
  43. vector[0] = (float)(-temp * -cos(yaw));
  44. vector[1] = (float)(sin(yaw) * temp);
  45. vector[2] = (float)-sin(pitch);
  46. }
  47. //===================================================================================
  48. float checkFov(QAngle angle,Vector source,Vector dest){
  49. float fov = 0.0f,mag = 0.0f,dot = 0.0f;
  50. QAngle ang,aim;
  51. gUtil.calcAngles(source,dest,ang);
  52. makeVector(angle,aim);
  53. makeVector(ang,ang);
  54. mag = sqrt(aim[0] * aim[0] + aim[1] * aim[1] + aim[2] * aim[2]);
  55. dot = aim[0] * ang[0] + aim[1] * ang[1] + aim[2] * ang[2];
  56. fov = acos(dot / (mag * mag)) * 57.2957914;
  57. return fov;
  58. }
  59. //===================================================================================
  60. cAimbot::cAimbot(){
  61. target = -1;
  62. }
  63. //===================================================================================
  64. bool cAimbot::checkVisible(Vector &vecAbsStart,Vector &vecAbsEnd,CBaseEntity *baseEnt)
  65. {
  66. player_info_t pinfo;
  67. trace_t tr;
  68. Ray_t ray;
  69. ray.Init(vecAbsStart,vecAbsEnd);
  70. m_pEngineTrace->TraceRay(ray,MASK_NPCWORLDSTATIC | MASK_SHOT,0,&tr);
  71. surfacedata_t *m_pSurfaceData = m_pPhysicAPI->GetSurfaceData(tr.surface.surfaceProps);
  72. if(tr.fraction > 0.97f)
  73. return true;
  74. if(tr.m_pEnt && baseEnt){
  75. if(gCvar.awall){
  76. switch(m_pSurfaceData->game.material){
  77. //case CHAR_TEX_METAL:
  78. case CHAR_TEX_GRATE:
  79. case CHAR_TEX_VENT:
  80. case CHAR_TEX_TILE:
  81. case CHAR_TEX_COMPUTER:
  82. case CHAR_TEX_WOOD:
  83. case CHAR_TEX_ANTLION:
  84. case CHAR_TEX_CLIP:
  85. case CHAR_TEX_ALIENFLESH:
  86. case CHAR_TEX_FOLIAGE:
  87. case CHAR_TEX_GLASS:
  88. case CHAR_TEX_PLASTIC:
  89. case CHAR_TEX_BLOODYFLESH:
  90. case CHAR_TEX_FLESH:
  91. return true;
  92. default:
  93. return false;
  94. }
  95. if(tr.fraction != 1.0){
  96. if(tr.allsolid || tr.DidHitWorld())
  97. return false;
  98. }else
  99. return true;
  100. }
  101. if(!tr.m_pEnt->index || tr.allsolid)
  102. return false;
  103. if((m_pEngine->GetPlayerInfo(tr.m_pEnt->index,&pinfo) || baseEnt->index == tr.m_pEnt->index) && tr.fraction > 0.92)
  104. return true;
  105. }
  106. return false;
  107. }
  108. //===================================================================================
  109. CBaseEntity* GetIndex( int idx )
  110. {
  111. __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
  112. if( m_pEntList == NULL ) return NULL;
  113. IClientEntity *pClient = m_pEntList->GetClientEntity( idx );
  114. if( pClient == NULL ) return NULL;
  115. return pClient->GetBaseEntity();
  116. }
  117. bool cAimbot::setupHitbox(Vector &vecOrigin, CBaseEntity* baseEnt)
  118. {
  119. matrix3x4_t pmatrix[MAXSTUDIOBONES];
  120. QAngle angles;
  121. const model_t *m_pModel = baseEnt->GetModel();
  122. if(m_pModel)
  123. {
  124. studiohdr_t *pStudioHdr = m_pModelInfo->GetStudiomodel(m_pModel);
  125.  
  126. if(baseEnt->SetupBones(pmatrix, 128, BONE_USED_BY_HITBOX, m_pGlobals->curtime) == false)
  127. return false;
  128.  
  129. mstudiohitboxset_t *set =pStudioHdr->pHitboxSet(0);
  130. Vector vMin,vMax,vecPosition, vPlayer;
  131. QAngle angles;mstudiobbox_t* m_pHitbox = NULL;
  132. for(int i = 0; i < pStudioHdr->numhitboxsets;i++)
  133. {
  134. for(int r = 0; r < pStudioHdr->iHitboxCount(i); r++)
  135. {
  136. m_pHitbox = pStudioHdr->pHitbox(r, i);
  137. if(!m_pHitbox)
  138. continue;
  139.  
  140. if(m_pHitbox->bone == 14)
  141. {
  142. MatrixAngles(pmatrix[ m_pHitbox->bone ], angles,vecPosition);
  143. VectorTransform(m_pHitbox->bbmin, pmatrix[ m_pHitbox->bone ], vMin);
  144. VectorTransform(m_pHitbox->bbmax, pmatrix[ m_pHitbox->bone ], vMax);
  145. vecOrigin = (vMin + vMax) * 0.5f;
  146. }
  147. }
  148. }
  149. }
  150. return true;
  151. }
  152.  
  153. //===================================================================================
  154. Vector GetEyePos(C_BaseEntity* pEntity)
  155. {
  156. return pEntity->GetAbsOrigin() + *(Vector*)((DWORD)pEntity + 0x0E4 );
  157. }
  158. float flGetDistance( Vector from,Vector to )
  159. {
  160. float x = from[0] - to[0];
  161. float y = from[1] - to[1];
  162. float z = from[2] - to[2];
  163.  
  164. return sqrt(x*x + y*y + z*z);
  165. }
  166. void cAimbot::findTarget(CUserCmd*pCmd)
  167. {
  168. CBaseEntity *pLocal = m_pEntList->GetClientEntity(m_pEngine->GetLocalPlayer())->GetBaseEntity();
  169.  
  170. if ( pLocal == NULL )
  171. return;
  172.  
  173. Vector vEyePos = pLocal->GetAbsOrigin() + *(Vector*)((DWORD)pLocal + 0x0E4 );
  174.  
  175. player_info_t pi;
  176.  
  177. int m_target = -1;
  178.  
  179. float distance = 99999.9f;
  180.  
  181. Vector aiming_Org[64], PredOrg[64];
  182.  
  183. for( int i = 1; i < m_pEntList->GetMaxEntities( ); i++ )
  184. {
  185. C_BaseEntity *pBaseEntity = GetIndex( i );
  186. if( pBaseEntity == NULL )
  187. continue;
  188.  
  189. if( pBaseEntity->index == pLocal->index )
  190. continue;
  191.  
  192. if( stricmp( pBaseEntity->GetClientClass()->GetName(), "CCSPlayer" ) == 0 )
  193. {
  194. player_info_t pi;
  195. int *health = (int*) ( (DWORD)pBaseEntity + (DWORD)0x90);
  196. char *lifeState = ( char* )( ( DWORD_PTR )pBaseEntity + 0x8F );
  197. if( *lifeState > 0 )
  198. continue;
  199.  
  200. if( health <= 0 )
  201. continue;
  202.  
  203. if( m_pEngine->GetPlayerInfo( pBaseEntity->index, &pi ) == false )
  204. continue;
  205.  
  206. if( pBaseEntity->IsDormant() )
  207. continue;
  208.  
  209. //if(bHasAmmo() == false)
  210. // continue;
  211.  
  212. if( pBaseEntity->GetTeamNumber() == pLocal->GetTeamNumber())
  213. continue;
  214.  
  215. //if(gVars.Aim_dmfix2 && *health > 151)
  216. // continue;
  217.  
  218. if( !gAimbot.setupHitbox(aiming_Org[i],pBaseEntity) )
  219. continue;
  220.  
  221. if( !gAimbot.checkVisible( vEyePos, aiming_Org[i], pBaseEntity))
  222. continue;
  223.  
  224. float Tmp = flGetDistance( vEyePos, pBaseEntity->GetAbsOrigin( ) ) / 22.f;
  225. if( Tmp < distance )
  226. {
  227. m_target = i;
  228. distance = Tmp;
  229. //PredOrg = aiming_Org /*- delta_Org*/;
  230. }
  231. }
  232. }
  233. if(m_target == -1)
  234. return;
  235.  
  236. VectorAngles( ( aiming_Org[m_target] - vEyePos ), pCmd->viewangles );
  237. if(gCvar.smooth != 0.0)
  238. {
  239. float diff[3];
  240. QAngle curViewAngles;
  241. m_pEngine->GetViewAngles(curViewAngles);
  242. diff[0] = pCmd->viewangles[0] - curViewAngles[0];
  243. diff[1] = pCmd->viewangles[1] - curViewAngles[1];
  244. if(diff[0] > 180)
  245. diff[0] -= 360;
  246. if(diff[1] > 180)
  247. diff[1] -= 360;
  248. if(diff[0] < -180)
  249. diff[0] += 360;
  250. if(diff[1] < -180)
  251. diff[1] += 360;
  252. if(diff[0] > gCvar.smooth)
  253. pCmd->viewangles[0] = curViewAngles[0] + gCvar.smooth;
  254. else if(diff[0] < -gCvar.smooth)
  255. pCmd->viewangles[0] = curViewAngles[0] - gCvar.smooth;
  256. if(diff[1] > gCvar.smooth)
  257. pCmd->viewangles[1] = curViewAngles[1] + gCvar.smooth;
  258. else if(diff[1] < -gCvar.smooth)
  259. pCmd->viewangles[1] = curViewAngles[1] - gCvar.smooth;
  260. if(pCmd->viewangles[0] > 180)
  261. pCmd->viewangles[0] -= 360;
  262. if(pCmd->viewangles[1] > 180)
  263. pCmd->viewangles[1] -= 360;
  264. if(pCmd->viewangles[0] < -180)
  265. pCmd->viewangles[0] += 360;
  266. if(pCmd->viewangles[1] < -180)
  267. pCmd->viewangles[1] += 360;
  268. }
  269. m_pEngine->SetViewAngles(pCmd->viewangles);
  270.  
  271. if(gCvar.rfire==1)
  272. {
  273. static bool wSwitch = true;
  274. wSwitch ? pCmd->buttons &= ~IN_ATTACK : pCmd->buttons |= IN_ATTACK;
  275. wSwitch =! wSwitch;
  276. }
  277.  
  278. m_target = -1;
  279. }
  280. //===================================================================================
  281. bool cAimbot::triggerBot(){
  282. player_info_t pInfo;
  283. trace_t tr;
  284. Ray_t ray;
  285. Vector vecDir;
  286. AngleVectors(gPlayer.baseEnt()->GetAbsAngles(),&vecDir);
  287. vecDir = vecDir * 8192 + gPlayer.baseEnt()->EyePosition();
  288. ray.Init(gPlayer.baseEnt()->EyePosition(),vecDir);
  289. m_pEngineTrace->TraceRay(ray,(CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_DEBRIS | CONTENTS_HITBOX),0,&tr);
  290. if(tr.allsolid || tr.DidHitWorld())
  291. return false;
  292. if(tr.m_pEnt && m_pEngine->GetPlayerInfo(tr.m_pEnt->index,&pInfo) && gPlayer.isEnemy(tr.m_pEnt))
  293. return tr.m_pEnt->index;
  294. return false;
  295. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement