mercredi 12 février 2014

[Coding] ranged 2d distance for aimbots topic




ok maybe nothing new here but i wanna share the technique i use to get range of aiming from crosshair to get cloestSoldier(credits : Lowrob, smallc, ICY, others i forget)

first of all i use numpad to toggle distance so i delacre this for vkdown and vkup and declare the integral type for disttoaim


PHP Code:







#define KEYDOWN(vkCode) ((GetAsyncKeyState(vkCode) & 0x8000) ? true : false)
#define KEYUP(vkCode) ((GetAsyncKeyState(vkCode) & 0x8000) ? false : true)

int distToAim 25









then the function to get cloest soldier



PHP Code:







float getDistFromCrosshair(ClientPlayer *pCloestSoldier)
{
    
D3DXVECTOR3 screenM;
    
D3DXVECTOR3 returningVector;
    if (
IsValidPtr(pCloestSoldier))
    {
        
D3DXMATRIX transfo;
        
DxRenderer *pDxrenderer DxRenderer::GetInstance();
        if (
IsValidPtr(pDxrenderer))
        {
            
Screen *pScreen pDxrenderer->m_pScreen;
            if (
IsValidPtr(pScreen))
            {
                
screenM.= (float)pScreen->m_Width 2;
                
screenM.= (float)pScreen->m_Height 2;
                
screenM.0;

                
ClientSoldierEntity *pSoldier pCloestSoldier->m_pControlledControllable;
                if (
IsValidPtr(pSoldier))
                {
                    
pSoldier->GetTransform(&transfo);
                    
D3DXVECTOR3 cloestSoldPos;
                    
cloestSoldPos transfo.m[3];

                    if (
WorldToScreen(&cloestSoldPos))
                    {
                        
returningVector.cloestSoldPos.screenM.x;
                        
returningVector.cloestSoldPos.screenM.y;
                        
//printf_s("X[%f]Y[%f]", returningVector.x, returningVector.y, fuck);
                        
returningVector.0;
                        
float returndist sqrtf((returningVector.returningVector.x) + (returningVector.returningVector.y));
                        
//printf_s(" Ret[%f]\n", returndist, fuck);

                        
if (returndist distToAim)
                            return 
returndist;
                        
                    }

                    else
                    {
                        return 
10000.0f;
                    }
                }
            }
        }
    }
    return 
10000.0f;










this line is very important to set your size


PHP Code:







                        if (returndist distToAim)
                            return 
returndist









some usefull drawing functions to draw a circle

PHP Code:







void Draw2DCircle(float xfloat yfloat radiusD3DCOLOR color// , LPDIRECT3DDEVICE9 dev
{
    const 
int NUMPOINTS 24 2;
    const 
float PI 3.14159;
    
D3DTLVERTEX Circle[NUMPOINTS 1];
    
int i;
    
float X;
    
float Y;
    
float Theta;
    
float WedgeAngle//Size of angle between two points on the circle (single wedge)
    //Precompute WedgeAngle
    
WedgeAngle = (float)((PI) / NUMPOINTS);
    
//Set up vertices for a circle
    //Used <= in the for statement to ensure last point meets first point (closed circle)
    
for (0<= NUMPOINTSi++)
    {
        
//Calculate theta for this vertex
        
Theta WedgeAngle;
        
//Compute X and Y locations
        
= (float)(radius cos(Theta));
        
= (float)(radius sin(Theta));
        
Circle[i] = CreateD3DTLVERTEX(XY0.0f1.0fcolor0.0f0.0f);
    }
    
//Now draw the circle
    
pDevice->SetFVF(D3DFVF_TL);
    
pDevice->SetTexture(0NULL);
    
pDevice->DrawPrimitiveUP(D3DPT_LINESTRIPNUMPOINTS, &Circle[0], sizeof(Circle[0]));











PHP Code:







void drawRangeofAim(int rom)
{
    
CenterX DxRenderer::GetInstance()->m_pScreen->m_Width 2;
    
CenterY DxRenderer::GetInstance()->m_pScreen->m_Height 2;

    
Draw2DCircle(CenterXCenterYromD3DCOLOR_RGBA(25500255));










finally in the rendering (in case you have an injected overlay you can do that to get the 2d range of aim get drawn in your screen


PHP Code:







int Render()
{
    
pDevice->Clear(0NULLD3DCLEAR_TARGET D3DCLEAR_ZBUFFERNULL1.0f0);
    
pDevice->BeginScene();
    
pDevice->CreateStateBlock(D3DSBT_ALL, &StateBlock);
    if (
TargetWindow == GetForegroundWindow())
    {
        
sprintf_s(distAimed"current 2d aim Range[%i]"distToAim);
        
DrawString(distAimed101025500pFont);

        if (
KEYDOWN(VK_NUMPAD3))
        {
            
Sleep(10);
            
drawRangeofAim(distToAim 25);

            if (
KEYUP(VK_NUMPAD3))
            {
                
distToAim += 25;
                
drawRangeofAim(distToAim);

                if (
distToAim 350)
                    
distToAim 25;
            }
        }

        if (
GetKeyState(VK_NUMPAD4))
            
drawRangeofAim(distToAim);
    }


    
pDevice->EndScene();
    
pDevice->PresentEx(00000);















1 commentaire: