# [Help] Princip of an Aimbot

#### Blackvz

##### Newbie
Hello all

So can someone explain me the main princip of an aimbot ?

I've found the (x|y) coordinates of me and the enemy. And I have my cursor position. I want to make an Aimbot for a simple 2D game.
But how to combine the player-coordinates and the mouse coordinates ?
How to calculate it ?
I dont get , how I can set my mouse position on the enemy (x|y) :/

Please explain and help me a little

Thanks and sorry for my english :/

#### Szaka

##### Coder
So if its a 2D game u see everything from top. Get your screen position by moving cursor on your char and caling GetCursorPos. Then do the same for one enemy. Count distance with pythagoran (i dont know english version but u knwo what i mean). Then count the distance with ingame coords and count proportion. Thats all, this is just a basic math, so you know the screen distance using ingame coords. Then get angle and ur done

Btw game name?

#### Blackvz

##### Newbie
Game name is Counter Strike 2D. I dont want to ruin the game so I won't release it or play with it online...just btw.
Yea I know what you mean . I used the GetCursorPos in C++. I wrote down my Pos but how I do it with the enemy Pos ? I mean it changes everytime he moves and I cant read it from the client mhhh

#### Szaka

##### Coder
I understand you got memory addresses with actual, live X Y of enemies in the game. Then its just math

#### Blackvz

##### Newbie
Mh it's still not clear to me.
I can calculate the Ingame-distance with pytagoras. Okay
But even if i have the distance , I still dont know which direction he is ?

What I got is :

Mouse Position in client (got it with C++ GetCursorPos)
Player and Enemy (XY) Coordinates Ingame.

Maybe you can do an example or something. Im still new to this sorry :/

#### Szaka

##### Coder
You have your world XY and enemy XY. Count angle and ur done

#### c5

##### Kim Kong Trasher
Legacy Donator
Dank Tier VIP
You don't need to get your mouse position, it's totally irrelevant.

#### Szaka

##### Coder
Thats it? My paint skillz

#### Icyvel

##### Newbie
Thats it? My paint skillz
27 is that just a constant when transforming points to pixels, or how'd you figure that out

#### Szaka

##### Coder
i cound distance between pixels and between world coords and divided it

#### Icyvel

##### Newbie
i cound distance between pixels and between world coords and divided it
Yeah i figured that 27 is the result of 135 divided by 5. I guess my real question is, where did you get the 5 from.

As looking at all 3 points, none of them are in fact 5 in distance.

Let me demonstrate:

// A +5
7 + 5 = 12
5 + 5 = 10

// B + 5
11 + 5 = 16
2 + 5 = 7

// C + 5
13 + 5 = 18
13 + 5 = 18

And tryed with your paint, you said 135 distance on screen, i can't see any of the points having 135 distance to each other either.

You gotta be more specific, I'm worried if it's just a typo of you that you actually ment 4 in game, as the distance between A & B seems to be 4, 7 + 4 = 11

#### Szaka

##### Coder
lol maybe i made a typo but its so damn easy, just try to calcualte it on a paper and everything is clear..

#### c5

##### Kim Kong Trasher
Legacy Donator
Dank Tier VIP
2nd grade math can get overwhelming sometimes lol

#### Icyvel

##### Newbie
2nd grade math can get overwhelming sometimes lol
It's not overhelming but when it's a new concept, typos can make it seem unclear.

#### Szaka

##### Coder
Just start coding and if it wont work let us know

#### till0sch

##### Respected Hacker
Legacy Donator
Dank Tier VIP
I remember for Fruit Ninja (2D..) it was like ScreenWidth/2 +- (ScreenWidth/2)*(X/285) or sth similar for the X coord.. (I created an aimbot for the game once...)

#### Szaka

##### Coder
yea! Thats it... its simple linear function. Get 2 points ingame with same X, count proprtion and same with Y, then u get function y=ax+b for both coords