[Snippet] Aim

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: 1@ = read_memory pActor size 4 virtual_protect 0
if 1@ > 0
jf @BaseAimLoop
0A8D: 33@ = read_memory pActor size 4 virtual_protect 0
0A8E: 33@ = 0x46C + 33@
const
    pVehicle = 33@  //char* pVehicle = (char*)((*pActor) + 0x46C);
end
0A8D: 2@ = read_memory pVehicle size 1 virtual_protect 0
if not 2@ == 1
jf @BaseAimLoop
0A8D: 32@ = read_memory pActor size 4 virtual_protect 0
0A8E: 32@ = 0x14 + 32@
const
    pMtrx1 = 32@        //DWORD* pMtrx1 = (DWORD*)((*pActor) + 0x14);//matrix of player actor
end
0A8D: 31@ = read_memory pMtrx1 size 4 virtual_protect 0
0A8E: 31@ = 0x30 + 31@
0A8D: 30@ = read_memory pMtrx1 size 4 virtual_protect 0
0A8E: 30@ = 0x34 + 30@
const
    xPos1 = 31@         //float* xPos1 = (float*)((*pMtrx1) + 0x30);//player actor X position
    yPos1 = 30@         //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: 3@ = read_memory CxPos1 size 4 virtual_protect 0
0A8D: 4@ = read_memory CyPos1 size 4 virtual_protect 0
0A8D: 29@ = read_memory pTarget size 4 virtual_protect 0
0A8E: 29@ = 0x79C + 29@
const
    keyt = 0xB7347A //int* keyt = (int*)0xB7347A;//Left mouse key
    xPoint = 3@     //float xPoint = *CxPos1;
    yPoint = 4@     //float yPoint = *CyPos1;
    pPed = 29@      //DWORD* pPed = (DWORD*) ((*pTarget) + 0x79C);//pointer to target player
end
0A8D: 5@ = read_memory pPed size 4 virtual_protect 0
if 5@ > 0
jf @BaseAimLoop
0A8D: 28@ = read_memory pPed size 4 virtual_protect 0
0A8E: 28@ = 0x44 + 28@
0A8D: 27@ = read_memory pPed size 4 virtual_protect 0
0A8E: 27@ = 0x48 + 27@
0A8D: 26@ = read_memory pPed size 4 virtual_protect 0
0A8E: 26@ = 0x14 + 26@
const
    playerSpeedVectorX = 28@    //float* playerSpeedVectorX = (float*)((*pPed) + 0x44);// Player speed angle vector.
    playerSpeedVectorY = 27@    //float* playerSpeedVectorY = (float*)((*pPed) + 0x48);
    pMtrx2 = 26@                //DWORD* pMtrx2 = (DWORD*)((*pPed) + 0x14);//matrix of target player
end
0A8D: 25@ = read_memory pMtrx2 size 4 virtual_protect 0
0A8E: 25@ = 0x30 + 25@
0A8D: 24@ = read_memory pMtrx2 size 4 virtual_protect 0
0A8E: 24@ = 0x34 + 24@
0A8D: 23@ = read_memory pPed size 4 virtual_protect 0
0A8E: 23@ = 0x540 + 23@
const
    xPos2 = 25@                 //float* xPos2 = (float*)((*pMtrx2) + 0x30);//X position
    yPos2 = 24@                 //float* yPos2 = (float*)((*pMtrx2) + 0x34);//Y position
    playerHP = 23@              //float* playerHP = (float*)((*pPed) + 0x540);//health of target player
end
0A8D: 6@ = read_memory playerHP size 4 virtual_protect 0
if 6@ > 0
jf @BaseAimLoop
0A8D: 7@ = read_memory xPos2 size 4 virtual_protect 0
0A8D: 8@ = read_memory yPos2 size 4 virtual_protect 0
0A8D: 9@ = read_memory playerSpeedVectorX size 4 virtual_protect 0
0A8D: 10@ = read_memory playerSpeedVectorY size 4 virtual_protect 0
0013: 9@ *= 6
0013: 10@ *= 6
005B: 9@ += 7@  // (float)
005B: 10@ += 8@  // (float)
const
    xPos2a = 9@    //xPos2a = *xPos2+ *playerSpeedVectorX*6;//position not far from target player sceen
    yPos2a = 10@   //yPos2a = *yPos2+ *playerSpeedVectorY*6;
end
0063: 3@ -= xPos2a  // (float)
0063: 4@ -= yPos2a  // (float)
0097: make 3@ absolute_float    //float Aa = fabs(xPoint-xPos2a);
0097: make 4@ absolute_float    //float Ab = fabs(yPoint-yPos2a);
const
    Aa = 3@
    Ab = 4@
end
0007: 11@ = 3@
0007: 12@ = 4@
0013: 11@ *= 11@
0013: 12@ *= 12@
005B: 12@ += 11@  // (float)
01FB: 12@ = square_root 12@ //float Ac = sqrt(Aa*Aa+Ab*Ab);
const
    Ac = 12@
end
0007: 11@ = Aa
0017: 11@ /= Ac
0013: 11@ *= 180.0
0017: 11@ /= 3.1415
const
    alpha = 11@ //float alpha = asin(Aa/Ac);
end
0007: 13@ = Aa
0017: 13@ /= Ac
0013: 13@ *= 180.0
0017: 13@ /= 3.1415
const
    beta = 13@ //float beta = acos(Aa/Ac);
end
0A8D: 14@ = read_memory xPos1 size 4 virtual_protect 0
0A8D: 15@ = read_memory yPos1 size 4 virtual_protect 0

if and                          //if((*xPos1 > *xPos2)&&(*yPos1 < *yPos2)){beta = -beta;}//1 part
0025:   14@ > 7@  // (float)
8035:   15@ >= 8@  // (float)
    then
        0007: 16@ = 0
        000F: 16@ -= beta
    end

if and                          //if((*xPos1 > *xPos2)&&(*yPos1 > *yPos2)){beta = beta;}//2 part            
    0025:   14@ > 7@  // (float)
    0025:   15@ > 8@  // (float)
    then
        0007: 16@ = beta
    end

if and                          //if((*xPos1 < *xPos2)&&(*yPos1 > *yPos2)){beta = (alpha + (1.5707));}//3 part
    8035:   14@ >= 7@  // (float)
    0025:   15@ > 8@  // (float)
    then
        0007: 16@ = alpha
        000B: 16@ += 1.5707
    end
if and                          //if((*xPos1 < *xPos2)&&(*yPos1 < *yPos2)){beta = (-alpha - (1.5707));}//4 part
    8035:   14@ >= 7@  // (float)
    8035:   15@ >= 8@  // (float)
    then
        0007: 16@ = 0
        000F: 16@ -= 1.5707
        000F: 16@ -= alpha
    end
const
    beta = 16@
end
0A8D: 0@ = read_memory keyt size 4 virtual_protect 0
if 0@ > 0
jf @BaseAimLoop
000B: 16@ += 0.0389
0A8C: write_memory camXpos size 4 value 16@ 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

Expert
Joined
Feb 18, 2013
Messages
1,495
Reaction score
238
Location
( ͡° ͜ʖ ͡°)
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: 0@ = player $PLAYER_CHAR targeted_actor
     THEN
         Actor.StorePos(0@, 1@, 2@, 3@)
         0AB1: @AIM_AT_POS 4 XYZ: 1@ 2@ 3@ ADD_CAMERA_OFFSET 0.04253
     END
 END
 //0AB1: @AIM_AT_POS 3 XYZ: 1@ 2@ 3@
 :AIM_AT_POS
 0087: 8@ = 3@
 068D: get_camera_position_to 3@ 4@ 5@
 0063: 0@ -= 3@
 0063: 1@ -= 4@
 0604: get_Z_angle_for_point 0@ 1@ store_to 6@
 6@ -= 90.0
 0017: 6@ /= 57.2957795            
 005B: 6@ += 8@  // (float)                           
 0A8D: 7@ = read_memory 0xB6F248 size 4 virtual_protect 0
 0A25: set_camera_on_players_X_angle 7@ Z_angle 6@
 0661: "by Opcode.eXe | UGBASE.EU"
 0AB2: 0
 
Top