Advertisement
llBeastModell

AW AIMBOT.cpp

Nov 23rd, 2015
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.31 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "Utilities.h"
  3. #include "AW_game.h"
  4. #include "ServComm.h"
  5. #include <time.h>
  6.  
  7. extern _SERVER_GET_CUSTOM_RESPONCE cData;
  8.  
  9. addrs_s addrs;
  10. aimbot bot;
  11. toggles_s toggles;
  12.  
  13. vec4 engine_white = vec4(1, 1, 1, 1);
  14. vec4 engine_black = vec4(0, 0, 0, 1);
  15. vec4 engine_red  = vec4(1, 0, 0, 0.8f);
  16. vec4 engine_green = vec4(0, 1, 0, 1);
  17. vec4 engine_blue  = vec4(0, 0, 1, 1);
  18. vec4 engine_orange = vec4(1.0f, 0.5f, 0.0f, 0.8f);
  19.  
  20. pclientActive_t LocalClient;
  21. pcentity_s Entities;
  22. pcgs_t cgs;
  23. pcg_s cg;
  24.  
  25. bool worldToScreen(vec3& WorldLocation, vec2& Screen)
  26. {
  27.     vec3 Local = WorldLocation - cg->refdef.ViewOrigin, Transform;
  28.     Transform.x = Local.DotProduct(cg->refdef.ViewAxis[1]);
  29.     Transform.y = Local.DotProduct(cg->refdef.ViewAxis[2]);
  30.     Transform.z = Local.DotProduct(cg->refdef.ViewAxis[0]);
  31.  
  32.     if(Transform.z < 0.01) return false;
  33.  
  34.     Screen.x = (cg->refdef.Width / 2) * ( 1 - (Transform.x / cg->refdef.Fov.x / Transform.z));
  35.     Screen.y = (cg->refdef.Height / 2) * ( 1 - (Transform.y / cg->refdef.Fov.y / Transform.z));
  36.  
  37.     return (Transform.z > 0);
  38. }
  39.  
  40. vec3 VectorToAngles(vec3 &Delta)
  41. {
  42.     float Forward, Yaw, Pitch;
  43.    
  44.     if(Delta.x == 0 && Delta.y == 0)
  45.     {
  46.         Yaw = 0;
  47.         if(Delta.z > 0)
  48.         { Pitch = 90; }
  49.         else { Pitch = 270; }
  50.     }
  51.     else
  52.     {
  53.         if(Delta.x)
  54.         { Yaw = (atan2(Delta.y, Delta.x) * 180 / 3.14159265358979323846); }
  55.         else if(Delta.y > 0)
  56.         { Yaw = 90; }
  57.         else { Yaw = 270; }
  58.         if(Yaw < 0)
  59.         { Yaw += 360; }
  60.  
  61.         Forward = sqrt((Delta.x * Delta.x) + (Delta.y * Delta.y));
  62.         Pitch = (atan2(Delta.z, Forward) * 180 / 3.14159265358979323846);
  63.         if(Pitch < 0)
  64.         { Pitch += 360; }
  65.     }
  66.  
  67.     return vec3(-Pitch, Yaw, 0);
  68. }
  69.  
  70. DWORD __declspec(naked) CL_WritePacketHookStub(DWORD LocalClientNumber)
  71. {
  72.     __asm
  73.     {
  74.         li r3, 1
  75.         nop
  76.         nop
  77.         nop
  78.         nop
  79.         nop
  80.         nop
  81.         blr
  82.     }
  83. }
  84.  
  85. int aimbot::closestClient(DWORD Client, bool VisibilityCheck)
  86. {
  87.     DWORD Closest = -1;
  88.     float Distance = 9999999999999999999;
  89.     vec3 Player = Entities[Client].Origin;
  90.     for(DWORD i = 0; i < cgs->MaxClients; i++)
  91.     {
  92.         if(i == Client || !(Entities[i].Alive & 1)) continue;
  93.  
  94.         if(cg->clientInfo[i].Team == cg->clientInfo[Client].Team)
  95.             if(cg->clientInfo[i].Team != 0) continue;
  96.        
  97.         if(!CG_CanSeePlayer(0, &Entities[i], 0x2805823) && VisibilityCheck) continue;
  98.        
  99.         float DistanceToTarget = Player.Distance(Entities[i].Origin);
  100.  
  101.         if(DistanceToTarget < Distance)
  102.         {
  103.             Distance = DistanceToTarget;
  104.             Closest = i;
  105.         }
  106.     }
  107.  
  108.     if(VisibilityCheck && Closest == -1){
  109.         return closestClient(Client, false);
  110.     }
  111.     return Closest;
  112. }
  113.  
  114. vec3 aimbot::tagPosition(DWORD ClientNumber, CONST PCHAR Tag)
  115. {
  116.     vec3 Position;
  117.     AimAssist_GetTagPos(0, &Entities[ClientNumber], SL_GetStringOfSize(Tag, 1, strlen(Tag) + 1, 8), Position);
  118.     Position.z -= (cg->Flags & CLIENT_FLAG_CROUCHED) ? 35 : 50;
  119.     return Position;
  120. }
  121.  
  122. void aimbot::addPrediction(int client, vec3 in, vec3 old, vec3 *out, float Prediction)
  123. {
  124.     *out = in - old;
  125.     out->x *= Prediction;
  126.     out->y *= Prediction;
  127.     out->z *= Prediction;
  128. }  
  129.  
  130. void engine::DrawLine(float X1, float Y1, float X2, float Y2, float Width, vec4& Color)
  131. {
  132.     float X, Y, Angle, L1, L2, H1;
  133.     H1 = Y2 - Y1;
  134.     L1 = X2 - X1;
  135.     L2 = sqrt(L1 * L1 + H1 * H1);
  136.     X = X1 + ((L1 - L2) / 2);
  137.     Y = Y1 + (H1 / 2);
  138.     Angle = (float)atan(H1 / L1) * (180 / 3.14159265358979323846);
  139.     CG_DrawRotatedPicPhysical(addrs.screenPlacement, X, Y, L2, Width, Angle, Color, DB_FindXAssetHeader(material, "white", 1));
  140. }
  141.  
  142. void engine::MakeESPLine(vec3 Center, float X1, float Y1, float Z1, float X2, float Y2, float Z2, vec4 Color)
  143. {
  144.     vec2 XY1, XY2;
  145.     if(worldToScreen(vec3(Center.x + X1, Center.y + Y1, Center.z + Z1), XY1) && worldToScreen(vec3(Center.x + X2, Center.y + Y2, Center.z+ Z2), XY2)){
  146.             DrawLine(XY1.x, XY1.y, XY2.x, XY2.y, 2, Color);
  147.     }
  148. }
  149.  
  150. void engine::Make3DBox(vec3 Center, float W, float H, vec4 Color)
  151. {
  152.     MakeESPLine(Center, -W, -W, 0, W, -W, 0, Color);
  153.     MakeESPLine(Center, -W, -W, 0, -W, W, 0, Color);
  154.     MakeESPLine(Center, W, W, 0, W, -W, 0, Color);
  155.     MakeESPLine(Center, W, W, 0, -W, W, 0, Color);
  156.  
  157.     MakeESPLine(Center, -W, -W, 0, -W, -W, H, Color);
  158.     MakeESPLine(Center, -W, W, 0, -W, W, H, Color);
  159.     MakeESPLine(Center, W, -W, 0, W, -W, H, Color);
  160.     MakeESPLine(Center, W, W, 0, W, W, H, Color);
  161.  
  162.     MakeESPLine(Center, -W, -W, H, W, -W, H, Color);
  163.     MakeESPLine(Center, -W, -W, H, -W, W, H, Color);
  164.     MakeESPLine(Center, W, W, H, W, -W, H, Color);
  165.     MakeESPLine(Center, W, W, H, -W, W, H, Color);
  166. }
  167.  
  168. UINT ui_menuOptionCount = 0;
  169. float ui_x = 60.0f;
  170. float ui_y = 240.0f;
  171. float ui_width = 160.0f;
  172. float ui_height = 200.0f;
  173. bool test = false;
  174.  
  175. void ui_render_option(char option[255], bool enabled){
  176.     float optionYcalc = ui_menuOptionCount > 0?20 * ui_menuOptionCount:0;
  177.     CL_DrawTextPhysical(va("%s ^7[%s^7]", option, enabled?"^2ON":"^1OFF"), 0x7FFFFFFF, DB_FindXAssetHeader(font, "fonts/bodyFont", 0), ui_x+5, (ui_y + 30) + optionYcalc, 1, 1, 0, engine_white, 0);
  178.     ui_menuOptionCount++;
  179. };
  180.  
  181. void ui_render(){
  182.     CG_DrawRotatedPicPhysical(addrs.screenPlacement, ui_x, ui_y, ui_width, ui_height, 0, engine_black, DB_FindXAssetHeader(material, "white", 1));
  183.     ui_render_option("Aimbot:", false);
  184.     ui_render_option("ESP:", false);
  185.     ui_render_option("UAV:", true);
  186.     test = true;
  187.     ui_menuOptionCount = 0;
  188. }
  189.  
  190. void engine(bool ingame){
  191.     vec4 color = engine_green;
  192.     CL_DrawTextPhysical("XBLParanoid - Bypassed", 0x7FFFFFFF, DB_FindXAssetHeader(font, "fonts/bodyFont", 0), 40, 40, 1, 1, 0, color, 0);
  193.     return;
  194.  
  195.     char *aimbot;
  196.     switch(toggles.mode){
  197.     case MODE_DISABLED: aimbot = "^1Off"; break;
  198.     case MODE_NORMAL: aimbot = "^2Normal"; break;
  199.     case MODE_PREDICT: aimbot = "^2Prediction"; break;
  200.     }
  201.  
  202.     CL_DrawTextPhysical(ingame?"XBLParanoid":va("Toggle aimbot/ESP with (LS) | Aimbot/ESP: %s", aimbot), 0x7FFFFFFF, DB_FindXAssetHeader(font, "fonts/bodyFont", 0), 40, 40, 1, 1, 0, color, 0);
  203.     if(!ingame || !toggles.mode>MODE_DISABLED) return;
  204.  
  205.     float CenterX = cg->refdef.Width / 2, CenterY = cg->refdef.Height / 2;
  206.     engine::DrawLine(CenterX, CenterY - 15, CenterX, CenterY + 15, 3, engine_black);
  207.     engine::DrawLine(CenterX - 15, CenterY, CenterX + 15, CenterY, 3, engine_black);
  208.  
  209.     for(DWORD i = 0; i < cgs->MaxClients; i++)
  210.     {
  211.         vec2 Screen;
  212.         vec3 Origin = aimbot::tagPosition(i, "j_head");
  213.         if(worldToScreen(Origin, Screen))
  214.         {
  215.             bool friendly = (cg->clientInfo[i].Team == cg->clientInfo[cg->ClientNumber].Team);
  216.             if(i == cg->ClientNumber || !(Entities[i].Alive & 1)) continue;
  217.  
  218.             if(friendly) color = engine_green;
  219.             else
  220.             {
  221.                 if(CG_CanSeePlayer(0, &Entities[i], 0x2805823)){
  222.                     color = engine_red;
  223.                     PCHAR text = "!!!ENEMY VISIBLE KILL THAT NIGGER BEFORE HE KILLS YOU!!!"; //Added alil nigger joke text lol
  224.                     DWORD tmpfont = DB_FindXAssetHeader(font, "fonts/bigDevFont", 0);
  225.                     CL_DrawTextPhysical(text, 0x7FFFFFFF, tmpfont, 500 - (R_TextWidth(text, 0x7FFFFFFF, tmpfont) / 2), 50, 2, 1, 0, color, 0);
  226.                     engine::DrawLine(CenterX, CenterY - 20, CenterX, CenterY + 20, 4.5, engine_red);
  227.                     engine::DrawLine(CenterX - 20, CenterY, CenterX + 20, CenterY, 4.5, engine_red);
  228.                 }
  229.                 else color = engine_orange;
  230.             }
  231.  
  232.             if(!friendly) engine::DrawLine(Screen.x, Screen.y, CenterX, CenterY, 1, color);
  233.            
  234.             engine::Make3DBox(Entities[i].Origin, 12, 60, color);
  235.             DWORD tmpfont = DB_FindXAssetHeader(font, "fonts/smallDevFont", 0);
  236.             CONST PCHAR Text = va("%s ^5[%0.2fm]", cg->playerNames[i].PlayerName, Origin.Distance(Entities[cg->ClientNumber].Origin) * 0.0254);
  237.             CL_DrawTextPhysical(Text, 0x7FFFFFFF, tmpfont, Screen.x - (R_TextWidth(Text, 0x7FFFFFFF, tmpfont) / 2), Screen.y, 1, 1, 0, color, 0);
  238.         }
  239.     }
  240. }
  241.  
  242. DWORD CL_WritePacketHook(DWORD localClient)
  243. {
  244.     if(Dvar_Getbool("cl_ingame") && toggles.mode>MODE_DISABLED)
  245.     {
  246.         LocalClient = (pclientActive_t)*(PDWORD)addrs.clientActive;
  247.         Entities = (pcentity_s)*(PDWORD)addrs.centity;
  248.         cg = (pcg_s)*(PDWORD)addrs.cg;
  249.         cgs = (pcgs_t)*(PDWORD)addrs.cgs;
  250.         pusercmd_s UserCommand = LocalClient->GetUserCommand(LocalClient->GetUserCommandNumber());
  251.         //DbgPrint("IN GAME");
  252.  
  253.         if(UserCommand->Buttons & 0x80800) // LT
  254.         {
  255.             //DbgPrint("Ingame button DOWN!");
  256.             DWORD ClosestClientNumber = aimbot::closestClient(cg->ClientNumber);
  257.             if(ClosestClientNumber != -1)
  258.             {
  259.                 vec3 targetAngles;
  260.                 if(toggles.mode == MODE_PREDICT){
  261.                     vec3 currentPos = aimbot::tagPosition(ClosestClientNumber, "j_head");
  262.                     vec3 myCurrentPos = aimbot::tagPosition(cg->ClientNumber, "j_head");
  263.                     vec3 predictedPos, myPredictedPos;
  264.  
  265.                     if(ClosestClientNumber == bot.lastClient)
  266.                     {
  267.                         aimbot::addPrediction(ClosestClientNumber, currentPos, bot.lastPos, &predictedPos, 1.316f);
  268.                         predictedPos.x += currentPos.x;
  269.                         predictedPos.y += currentPos.y;
  270.                         predictedPos.z += currentPos.z;
  271.                     }else predictedPos = currentPos;
  272.  
  273.                     aimbot::addPrediction((int)cg->ClientNumber, myCurrentPos, bot.lastPos, &myPredictedPos, 1.316f);
  274.                     myPredictedPos.x += myCurrentPos.x;
  275.                     myPredictedPos.y += myCurrentPos.y;
  276.                     myPredictedPos.z += myCurrentPos.z;
  277.  
  278.                     bot.lastPos = currentPos;
  279.                     bot.myLastPos = myCurrentPos;
  280.  
  281.                     targetAngles = VectorToAngles(predictedPos - myPredictedPos);
  282.                 }else if(toggles.mode==MODE_NORMAL) targetAngles = VectorToAngles(aimbot::tagPosition(ClosestClientNumber, "j_head") - Entities[cg->ClientNumber].Origin);
  283.                 LocalClient->ViewAngles = targetAngles - LocalClient->SpawnAngles;
  284.             }
  285.         }
  286.     }
  287.     return CL_WritePacketHookStub(localClient);
  288. }
  289.  
  290. void CG_DrawFPSHook(){
  291.     bool ingame = Dvar_Getbool("cl_ingame");
  292.     engine(ingame);
  293.     if(!ingame){
  294.         if(toggles.clicked){
  295.             if(toggles.click++>55){
  296.                 toggles.click = 0;
  297.                 toggles.clicked = false;
  298.             }
  299.             return;
  300.         }
  301.  
  302.         if(Key_IsDown(0, KEY_LS)){
  303.             if(toggles.mode++>1) toggles.mode = MODE_DISABLED;
  304.             toggles.clicked = true;
  305.             //DbgPrint("getstringofsize = %i", SL_GetStringOfSize("j_head", 1, strlen("j_head") + 1, 8));
  306.             //DbgPrint("LS Down");
  307.         }
  308.     }
  309. }
  310.  
  311. int XNetXnAddrToMachineHook(int xnaddr, unsigned long long * pqwMachineId)
  312. {
  313.     srand(time(0));
  314.     if(!*(int*)(xnaddr + 0x4)) *pqwMachineId = 0; return -1;
  315.     *pqwMachineId = 0xFA00000000000000 | (0x2000000 | rand() % 0x7FFFFF);
  316.     return 0;
  317. }
  318.  
  319. void aw_ini(){
  320.     addrs.ini();
  321.     bot.reset();
  322.     toggles.reset();
  323.  
  324.     *(QWORD*)(0x822EB2EC) = 0x8921005061490000; //XboxLive Gold - TU12
  325.     *(QWORD*)(0x822EB344) = 0x8921005061490000; //XBDM - TU12
  326.     *(DWORD*)0x82306018 = 0x60000000; //TU12
  327.     *(DWORD*)0x8230601C = 0x60000000; //TU12
  328.     *(DWORD*)0x821B6998 = 0x60000000; //TU12
  329.     *(DWORD*)0x821B699C = 0x60000000; //TU12
  330.     *(DWORD*)0x821B5F14 = 0x60000000; //TU12
  331.     *(DWORD*)0x8230603C = 0x60000000; //TU12
  332.     *(DWORD*)0x82306040 = 0x60000000; //TU12
  333.     *(DWORD*)0x821DA574 = 0x60000000; //TU12
  334.     *(DWORD*)0x821B58F8 = 0x60000000; //TU12
  335.  
  336.     //*(PDWORD)addrs.getTagPos_error = cData.ppc_nop;
  337.     //*(PDWORD)addrs.crosshair = 0x3F800000;
  338.     //*(PDWORD)addrs.recoil = cData.ppc_nop;
  339.     *(PDWORD)addrs.chams = 0x38C00005;
  340.     //*(PDWORD)addrs.uav = 0x3B200001;
  341.  
  342.     /**(DWORD*)0x826919DC = 0x3B200001; // UAV
  343.     *(DWORD*)0x826919E0 = 0x3B200001; // UAV
  344.     *(DWORD*)0x826919E4 = 0x3B200001; // UAV*/
  345.  
  346.     //PatchInJump((DWORD*)0x82193950, (DWORD)XNetXnAddrToMachineHook);
  347.     //PatchInJump((PDWORD)addrs.drawFps_ptr, (DWORD)CG_DrawFPSHook, false); //removed for xbls
  348.     //HookFunctionStart((PDWORD)addrs.writePacket_ptr, (PDWORD)CL_WritePacketHookStub, (DWORD)CL_WritePacketHook);
  349. }
  350.  
  351. //0x826B8080 + 0x224 | nop | redbox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement