[Snippet] Aim

Ninja FTW

Well-Known Member
Joined
Aug 11, 2017
Messages
61
Likes
0
Points
6
Location
Saturn
5
#1
This was long and kinda complicated but still somehow manage...:

Code:
{$CLEO}
0000:

:isSampAvailable
0001: 0
0AFA:
004D: @isSampAvailable
0002: @BaseAimLoop

:BaseAimLoop
0001: 0
const
    pTarget = 0xB6F3B8  //DWORD* pTarget = (DWORD*)0xB6F3B8;//pointer of target object.
    pActor = 0xB6F5F0   //DWORD* pActor = (DWORD*)0xB6F5F0;//pointer of player actor
    pCamera = 0xB6F99C  //DWORD* pCamera = (DWORD*)0xB6F99C;//camera pointer
    camXpos = 0xB6F258  //float* camXpos = (float*)0xB6F258;//writeable camera Z angle
end
0A8D: [email protected] = read_memory pActor size 4 virtual_protect 0
if [email protected] > 0
jf @BaseAimLoop
0A8D: [email protected] = read_memory pActor size 4 virtual_protect 0
0A8E: [email protected] = 0x46C + [email protected]
const
    pVehicle = [email protected]  //char* pVehicle = (char*)((*pActor) + 0x46C);
end
0A8D: [email protected] = read_memory pVehicle size 1 virtual_protect 0
if not [email protected] == 1
jf @BaseAimLoop
0A8D: [email protected] = read_memory pActor size 4 virtual_protect 0
0A8E: [email protected] = 0x14 + [email protected]
const
    pMtrx1 = [email protected]        //DWORD* pMtrx1 = (DWORD*)((*pActor) + 0x14);//matrix of player actor
end
0A8D: [email protected] = read_memory pMtrx1 size 4 virtual_protect 0
0A8E: [email protected] = 0x30 + [email protected]
0A8D: [email protected] = read_memory pMtrx1 size 4 virtual_protect 0
0A8E: [email protected] = 0x34 + [email protected]
const
    xPos1 = [email protected]         //float* xPos1 = (float*)((*pMtrx1) + 0x30);//player actor X position
    yPos1 = [email protected]         //float* yPos1 = (float*)((*pMtrx1) + 0x34);//player actor Y position
    CxPos1 = 0xB6F9CC   //float* CxPos1 = (float*)(0xB6F9CC);//camera X position
    CyPos1 = 0xB6F9D0   //float* CyPos1 = (float*)(0xB6F9D0);//camera Y position
end
0A8D: [email protected] = read_memory CxPos1 size 4 virtual_protect 0
0A8D: [email protected] = read_memory CyPos1 size 4 virtual_protect 0
0A8D: [email protected] = read_memory pTarget size 4 virtual_protect 0
0A8E: [email protected] = 0x79C + [email protected]
const
    keyt = 0xB7347A //int* keyt = (int*)0xB7347A;//Left mouse key
    xPoint = [email protected]     //float xPoint = *CxPos1;
    yPoint = [email protected]     //float yPoint = *CyPos1;
    pPed = [email protected]      //DWORD* pPed = (DWORD*) ((*pTarget) + 0x79C);//pointer to target player
end
0A8D: [email protected] = read_memory pPed size 4 virtual_protect 0
if [email protected] > 0
jf @BaseAimLoop
0A8D: [email protected] = read_memory pPed size 4 virtual_protect 0
0A8E: [email protected] = 0x44 + [email protected]
0A8D: [email protected] = read_memory pPed size 4 virtual_protect 0
0A8E: [email protected] = 0x48 + [email protected]
0A8D: [email protected] = read_memory pPed size 4 virtual_protect 0
0A8E: [email protected] = 0x14 + [email protected]
const
    playerSpeedVectorX = [email protected]    //float* playerSpeedVectorX = (float*)((*pPed) + 0x44);// Player speed angle vector.
    playerSpeedVectorY = [email protected]    //float* playerSpeedVectorY = (float*)((*pPed) + 0x48);
    pMtrx2 = [email protected]                //DWORD* pMtrx2 = (DWORD*)((*pPed) + 0x14);//matrix of target player
end
0A8D: [email protected] = read_memory pMtrx2 size 4 virtual_protect 0
0A8E: [email protected] = 0x30 + [email protected]
0A8D: [email protected] = read_memory pMtrx2 size 4 virtual_protect 0
0A8E: [email protected] = 0x34 + [email protected]
0A8D: [email protected] = read_memory pPed size 4 virtual_protect 0
0A8E: [email protected] = 0x540 + [email protected]
const
    xPos2 = [email protected]                 //float* xPos2 = (float*)((*pMtrx2) + 0x30);//X position
    yPos2 = [email protected]                 //float* yPos2 = (float*)((*pMtrx2) + 0x34);//Y position
    playerHP = [email protected]              //float* playerHP = (float*)((*pPed) + 0x540);//health of target player
end
0A8D: [email protected] = read_memory playerHP size 4 virtual_protect 0
if [email protected] > 0
jf @BaseAimLoop
0A8D: [email protected] = read_memory xPos2 size 4 virtual_protect 0
0A8D: [email protected] = read_memory yPos2 size 4 virtual_protect 0
0A8D: [email protected] = read_memory playerSpeedVectorX size 4 virtual_protect 0
0A8D: [email protected] = read_memory playerSpeedVectorY size 4 virtual_protect 0
0013: [email protected] *= 6
0013: [email protected] *= 6
005B: [email protected] += [email protected]  // (float)
005B: [email protected] += [email protected]  // (float)
const
    xPos2a = [email protected]    //xPos2a = *xPos2+ *playerSpeedVectorX*6;//position not far from target player sceen
    yPos2a = [email protected]   //yPos2a = *yPos2+ *playerSpeedVectorY*6;
end
0063: [email protected] -= xPos2a  // (float)
0063: [email protected] -= yPos2a  // (float)
0097: make [email protected] absolute_float    //float Aa = fabs(xPoint-xPos2a);
0097: make [email protected] absolute_float    //float Ab = fabs(yPoint-yPos2a);
const
    Aa = [email protected]
    Ab = [email protected]
end
0007: [email protected] = [email protected]
0007: [email protected] = [email protected]
0013: [email protected] *= [email protected]
0013: [email protected] *= [email protected]
005B: [email protected] += [email protected]  // (float)
01FB: [email protected] = square_root [email protected] //float Ac = sqrt(Aa*Aa+Ab*Ab);
const
    Ac = [email protected]
end
0007: [email protected] = Aa
0017: [email protected] /= Ac
0013: [email protected] *= 180.0
0017: [email protected] /= 3.1415
const
    alpha = [email protected] //float alpha = asin(Aa/Ac);
end
0007: [email protected] = Aa
0017: [email protected] /= Ac
0013: [email protected] *= 180.0
0017: [email protected] /= 3.1415
const
    beta = [email protected] //float beta = acos(Aa/Ac);
end
0A8D: [email protected] = read_memory xPos1 size 4 virtual_protect 0
0A8D: [email protected] = read_memory yPos1 size 4 virtual_protect 0

if and                          //if((*xPos1 > *xPos2)&&(*yPos1 < *yPos2)){beta = -beta;}//1 part
0025:   [email protected] > [email protected]  // (float)
8035:   [email protected] >= [email protected]  // (float)
    then
        0007: [email protected] = 0
        000F: [email protected] -= beta
    end

if and                          //if((*xPos1 > *xPos2)&&(*yPos1 > *yPos2)){beta = beta;}//2 part            
    0025:   [email protected] > [email protected]  // (float)
    0025:   [email protected] > [email protected]  // (float)
    then
        0007: [email protected] = beta
    end

if and                          //if((*xPos1 < *xPos2)&&(*yPos1 > *yPos2)){beta = (alpha + (1.5707));}//3 part
    8035:   [email protected] >= [email protected]  // (float)
    0025:   [email protected] > [email protected]  // (float)
    then
        0007: [email protected] = alpha
        000B: [email protected] += 1.5707
    end
if and                          //if((*xPos1 < *xPos2)&&(*yPos1 < *yPos2)){beta = (-alpha - (1.5707));}//4 part
    8035:   [email protected] >= [email protected]  // (float)
    8035:   [email protected] >= [email protected]  // (float)
    then
        0007: [email protected] = 0
        000F: [email protected] -= 1.5707
        000F: [email protected] -= alpha
    end
const
    beta = [email protected]
end
0A8D: [email protected] = read_memory keyt size 4 virtual_protect 0
if [email protected] > 0
jf @BaseAimLoop
000B: [email protected] += 0.0389
0A8C: write_memory camXpos size 4 value [email protected] virtual_protect 0
0002: @BaseAimLoop
Here for C++:

Code:
#include "stdafx.h"
#include <windows.h>
#include <math.h>

void main()
{
   DWORD* pTarget = (DWORD*)0xB6F3B8;//pointer of target object.
   DWORD* pActor = (DWORD*)0xB6F5F0;//pointer of player actor
   DWORD* pCamera = (DWORD*)0xB6F99C;//camera pointer
   float* camXpos = (float*)0xB6F258;//writeable camera Z angle

   while(1)
  {

    if(*pActor > 0)
        {
         char* pVehicle = (char*)((*pActor) + 0x46C);
         if(*pVehicle != 1)
         {
             DWORD* pMtrx1 = (DWORD*)((*pActor) + 0x14);//matrix of player actor
             float* xPos1 = (float*)((*pMtrx1) + 0x30);//player actor X position
             float* yPos1 = (float*)((*pMtrx1) + 0x34);//player actor Y position

             float* CxPos1 = (float*)(0xB6F9CC);//camera X position
             float* CyPos1 = (float*)(0xB6F9D0);//camera Y position
 
             float xPoint = *CxPos1;
             float yPoint = *CyPos1;
 
             int* keyt = (int*)0xB7347A;//Left mouse key
             DWORD* pPed = (DWORD*) ((*pTarget) + 0x79C);//pointer to target player
   
            if(*pPed > 0) {
           
                  float* playerSpeedVectorX = (float*)((*pPed) + 0x44);// Player speed angle vector.
                  float* playerSpeedVectorY = (float*)((*pPed) + 0x48);

                  DWORD* pMtrx2 = (DWORD*)((*pPed) + 0x14);//matrix of target player
                  float* xPos2 = (float*)((*pMtrx2) + 0x30);//X position
                  float* yPos2 = (float*)((*pMtrx2) + 0x34);//Y position
   
                   float xPos2a;
                   float yPos2a;
 
                   float* playerHP = (float*)((*pPed) + 0x540);//health of target player
                   if(*playerHP > 0){
         
                      xPos2a = *xPos2+ *playerSpeedVectorX*6;//position not far from target player sceen
                      yPos2a = *yPos2+ *playerSpeedVectorY*6;
       
                      float Aa = fabs(xPoint-xPos2a);
                      float Ab = fabs(yPoint-yPos2a);
                      float Ac = sqrt(Aa*Aa+Ab*Ab);
                      float alpha = asin(Aa/Ac);
                      float beta = acos(Aa/Ac);
                     if((*xPos1 > *xPos2)&&(*yPos1 < *yPos2)){beta = -beta;}//1 part
                     if((*xPos1 > *xPos2)&&(*yPos1 > *yPos2)){beta = beta;}//2 part
                     if((*xPos1 < *xPos2)&&(*yPos1 > *yPos2)){beta = (alpha + (1.5707));}//3 part
                     if((*xPos1 < *xPos2)&&(*yPos1 < *yPos2)){beta = (-alpha - (1.5707));}//4 part
         
                     if(*keyt > 0){
                         *camXpos = beta+0.0389;//for deagle.
                     }
                }
             }
        }
    }
    Sleep(10);
  }
ExitThread(0);
}


BOOL APIENTRY DllMain(HINSTANCE hDll, DWORD callReason, LPVOID lpReserved)
{
if(callReason == DLL_PROCESS_ATTACH)
{
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&main, 0, 0, 0);
}
return 1;
}
 

Opcode.eXe

Well-Known Member
Joined
Feb 18, 2013
Messages
1,278
Likes
27
Points
98
Location
( ͡° ͜ʖ ͡°)
Website
www.youtube.com
10
#2
You really wasted your time. All you did is convert copypasta to scm. That has already been done 100 times. Also there is this doing the same:
http://ugbase.eu/Thread-SNIPPET-AIM-AT-POSITION

Code:
{$CLEO .cs}
 0000:
 
 WHILE TRUE
     WAIT 0
     IF 0AD2: [email protected] = player $PLAYER_CHAR targeted_actor
     THEN
         Actor.StorePos([email protected], [email protected], [email protected], [email protected])
         0AB1: @AIM_AT_POS 4 XYZ: [email protected] [email protected] [email protected] ADD_CAMERA_OFFSET 0.04253
     END
 END
 //0AB1: @AIM_AT_POS 3 XYZ: [email protected] [email protected] [email protected]
 :AIM_AT_POS
 0087: [email protected] = [email protected]
 068D: get_camera_position_to [email protected] [email protected] [email protected]
 0063: [email protected] -= [email protected]
 0063: [email protected] -= [email protected]
 0604: get_Z_angle_for_point [email protected] [email protected] store_to [email protected]
 [email protected] -= 90.0
 0017: [email protected] /= 57.2957795            
 005B: [email protected] += [email protected]  // (float)                           
 0A8D: [email protected] = read_memory 0xB6F248 size 4 virtual_protect 0
 0A25: set_camera_on_players_X_angle [email protected] Z_angle [email protected]
 0661: "by Opcode.eXe | UGBASE.EU"
 0AB2: 0
 
Top