Advertisement
encoree1996

Untitled

Jun 21st, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.84 KB | None | 0 0
  1. void LeftClick ( )
  2. {
  3. INPUT Input = { 0 };
  4. // left down
  5. Input.type = INPUT_MOUSE;
  6. Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
  7. ::SendInput ( 1, &Input, sizeof ( INPUT ) );
  8.  
  9. // left up
  10. ::ZeroMemory ( &Input, sizeof ( INPUT ) );
  11. Input.type = INPUT_MOUSE;
  12. Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
  13. ::SendInput ( 1, &Input, sizeof ( INPUT ) );
  14. }
  15.  
  16.  
  17.  
  18. bool triggerBot ( )
  19. {
  20. player_info_t pInfo;
  21. trace_t tr;
  22. Ray_t ray;
  23. CTraceFilter filter;
  24. Vector vecDir, playerAngles;
  25. C_BaseEntity* pLocalPlayer = ( C_BaseEntity* )entitylist->GetClientEntity ( engine->GetLocalPlayer ( ) );
  26. if ( !pLocalPlayer )
  27. return false;
  28. filter.pSkip = pLocalPlayer;
  29. QAngle localAngles;
  30. engine->GetViewAngles ( localAngles );
  31. AngleVectors ( localAngles /*+ pLocalPlayer->GetPunchAngle ( ) *2.0f*/, &vecDir );
  32. vecDir = vecDir * 8192 + pLocalPlayer->GetEyePos ( );
  33. ray.Init ( pLocalPlayer->GetEyePos ( ), vecDir );
  34. //ray, 0x4600400B, &filter, &tr
  35. enginetrace->TraceRay ( ray, 0x4600400B, &filter, &tr );
  36. //g_pEngineTrace->TraceRay ( ray, ( CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_DEBRIS | CONTENTS_HITBOX ), /*&filter*/0, &tr );
  37.  
  38. if ( tr.allsolid || tr.m_pEnt == entitylist->GetClientEntity ( 0 ) )
  39. return 0;
  40.  
  41. if ( tr.m_pEnt && engine->GetPlayerInfo ( tr.m_pEnt->index, &pInfo ) && pLocalPlayer->team ( ) != tr.m_pEnt->team ( ) )
  42. {
  43. if ( tr.m_pEnt->index )
  44. {
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50.  
  51. void normalizeAngle ( QAngle& input )
  52. {
  53. if ( input.x < -89.0f )
  54. input.x = -89.0f;
  55.  
  56. if ( input.x > 89.0f )
  57. input.x = 89.0f;
  58.  
  59. while ( input.y > 180.0f )
  60. input.y -= 360.0f;
  61.  
  62. while ( input.y < -180.0f )
  63. input.y += 360.0f;
  64.  
  65. input.z = 0.0f;
  66. }
  67.  
  68. DWORD spotOffset = 0x00000935, shotsFiredOffset = 0x00001D6C;
  69.  
  70.  
  71. QAngle angle;
  72. QAngle m_ViewAngle;
  73. QAngle OldAngle;
  74.  
  75. void __fastcall hkPaintTraverse ( void* ecx, void* edx, unsigned int vguiPanel, bool forceRepaint, bool allowForce )
  76. {
  77. oPaintTraverse ( ecx, vguiPanel, forceRepaint, allowForce );
  78.  
  79. static DWORD lastShoot = 0;
  80.  
  81. if ( engine->IsInGame ( ) && engine->IsConnected ( ) && !engine->IsTakingScreenshot ( ) )
  82. {
  83.  
  84. if ( GetAsyncKeyState ( 6 ) )
  85. {
  86. if ( triggerBot ( ) )
  87. {
  88. DWORD currentCount = GetTickCount ( );
  89. if ( currentCount - lastShoot > 20 )
  90. {
  91. LeftClick ( );
  92. lastShoot = currentCount;
  93. }
  94. }
  95. }
  96.  
  97. C_BaseEntity *pLocalEntity = ( C_BaseEntity* )entitylist->GetClientEntity ( engine->GetLocalPlayer ( ) );
  98. if ( !pLocalEntity )
  99. return;
  100.  
  101. for ( int i = 0; i < entitylist->GetHighestEntityIndex ( ); i++ ) //spotter
  102. {
  103. C_BaseEntity* pBaseEntity = ( C_BaseEntity* )entitylist->GetClientEntity ( i );
  104. if ( !pBaseEntity )
  105. continue;
  106. if ( pBaseEntity->health ( ) < 1 )
  107. continue;
  108. if ( pBaseEntity == pLocalEntity )
  109. continue;
  110. if ( pLocalEntity->team ( ) == pBaseEntity->team ( ) )
  111. continue;
  112.  
  113. *( BYTE* )( ( DWORD )pBaseEntity + spotOffset ) = 1;
  114. }
  115.  
  116.  
  117. if ( GetAsyncKeyState ( VK_LBUTTON ) )
  118. {
  119. if ( *( DWORD* )( ( DWORD )pLocalEntity + shotsFiredOffset ) > 1 )
  120. {
  121. engine->GetViewAngles ( m_ViewAngle );
  122.  
  123. QAngle* m_PunchAngle = pLocalEntity->GetAimPunchPtr ( );
  124. if ( !m_PunchAngle )
  125. return;
  126.  
  127. //g_pCVar->ConsolePrintf ( "PunchAngles: %f %f\n", m_PunchAngle->x, m_PunchAngle->y );
  128.  
  129.  
  130. m_ViewAngle.x = m_ViewAngle.x + OldAngle.x;
  131. m_ViewAngle.y = m_ViewAngle.y + OldAngle.y;
  132. // Add the old "viewpunch" so we get the "center" of the screen again
  133.  
  134. angle.x = m_ViewAngle.x - m_PunchAngle->x * 2.0f;
  135. angle.y = m_ViewAngle.y - m_PunchAngle->y * 2.0f;
  136. // remove the new "viewpunch" from the viewangles
  137. normalizeAngle ( angle );
  138. //g_pCVar->ConsolePrintf ( "OriginalAngles: %f %f\nSetting angles to %f %f\n", m_ViewAngle.x, m_ViewAngle.y, angle.x, angle.y );
  139. engine->SetViewAngles ( angle );
  140.  
  141. OldAngle.x = m_PunchAngle->x * 2;
  142. OldAngle.y = m_PunchAngle->y * 2;
  143. // save the old "viewpunch"
  144.  
  145.  
  146. } else
  147. {
  148. OldAngle.x = 0;
  149. OldAngle.y = 0;
  150. }
  151. } else
  152. {
  153. OldAngle.x = 0;
  154. OldAngle.y = 0;
  155. }
  156.  
  157.  
  158.  
  159. }
  160.  
  161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement