|
You last visited: Today at 10:26
Advertisement
Help!!! AimbotMath
Discussion on Help!!! AimbotMath within the AutoIt forum part of the Coders Den category.
05/29/2013, 21:37
|
#1
|
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
|
Help!!! AimbotMath
Hi Epvpers i read a lot of tutorials of memory aimbots and made one by myself with autoit x_X, the thing is that some math in the code is wrong and don't know how to fix it, caus i'm very bad at maths...
All i can say is that the rotation x is working good from left to right and the y rotation only work if the enemy is at the same yPos as you D: but fortunately it shots at head ,right to left is not aiming even if the player that is on your left is the nearest.
Is an offline aimbot that will aim the nearest bot(team too(by now the nearest bot on your right)) when you press right click.
Things to consider:
rotationX (mouseX) go between 0 to 360
rotationY (mouseY) go between -89 to +89
i'm a stupid noob that i can't calculate the angle...
Here's the video:
Here is what i get until now:
Code:
Global Const $_PI =3.14159265
;Posible something bad in here? i get it from autoit forums...
#region Math Atan2
Func atan2($x, $y)
$Pi = 4 * ATan(1)
If StringIsInt($x) Or StringIsFloat($x) Then
If StringIsInt($y) Or StringIsFloat($y) Then
; OK
Else
SetError(1)
Return ""
EndIf
Else
SetError(1)
Return ""
EndIf
Dim $PolarAnswer[3] ; $Results[0]=Radius, [1]=Theta (in Radians), [2]=Theta (in Degrees)
$r = Sqrt(($x ^ 2) + ($y ^ 2))
$PolarAnswer[0] = $r
Select
Case $x = 0 And $y = 0
$ThetaRad = 0
$ThetaDeg = 0
Case $x >= 0 And $y >= 0 ; +x/+y = 0-90deg quadrant
$ThetaRad = ATan($x / $y)
$ThetaDeg = $ThetaRad * 180 / $Pi
Case $x >= 0 And $y < 0 ; +x/-y = 90-180deg quadrant
$ThetaRad = ATan(Abs($y) / $x)
$ThetaDeg = $ThetaRad * 180 / $Pi + 90
$ThetaRad = $ThetaRad + $Pi / 2
Case $x < 0 And $y < 0 ; -x/-y = 180-270deg quadrant
$ThetaRad = ATan(Abs($x) / Abs($y))
$ThetaDeg = $ThetaRad * 180 / $Pi + 180
$ThetaRad = $ThetaRad + $Pi
Case $x < 0 And $y >= 0 ; -x/+y = 2700-360deg quadrant
$ThetaRad = ATan($y / Abs($x))
$ThetaDeg = $ThetaRad * 180 / $Pi + 270
$ThetaRad = $ThetaRad + 3 * $Pi / 2
EndSelect
$PolarAnswer[1] = $ThetaDeg
SetError(0)
Return $ThetaDeg
EndFunc ;==>atan2
#endregion
#region Aimbot Math
;EnemyVals[0,1,2] = xyz (All bots)
;PlayerVals[0,1,2] = xyz (Main Player)
Func Get3dDistance($EnemyVals,$PlayerVals)
$float=Sqrt( _
(($EnemyVals[0] - $PlayerVals[0]) * ($EnemyVals[0] - $PlayerVals[0]))+ _
(($EnemyVals[1] - $PlayerVals[1]) * ($EnemyVals[1] - $PlayerVals[1]))+ _
(($EnemyVals[2] - $PlayerVals[2]) * ($EnemyVals[2] - $PlayerVals[2])))
Return $float
EndFunc
#cs
Something here is wrong
#ce
Func AimAtTarget($EnemyVal,$PlayerVal)
; Z Z xyz xyz
$PitchX= ASin(($EnemyVal[2]-$PlayerVal[2])/Get3dDistance($EnemyVal,$PlayerVal))*180/$_PI
$PitchY= -Atan2($EnemyVal[0]-$PlayerVal[0],$EnemyVal[1]-$PlayerVal[1])/($_PI*180*88)
; X X Y Y
Local $MouseX= _MemoryWrite($MouseAdd[0][0],$Open,$PitchX,"float") ;x mouse axis
Local $MouseY= _MemoryWrite($MouseAdd[1][0],$Open,$PitchY,"float") ;y mouse axis
EndFunc
#endregion
Very sorry for my bad english the video will be uploaded in two hours (fail internet)
|
|
|
06/01/2013, 11:30
|
#2
|
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
|
Quote:
Originally Posted by FacePalmMan
just rewrite your aimbot so it works like this:
make an esp-dot/esp-image ,let autoit search for it with pixel-/imagesearch and let autoit aim&click on it.
why you should rewrite it:
1. its easier to do
2. you can even see where the enemys are
|

Why searching for pixels in a aimbot ?
Why drawing esp ?
He asked how he calculate the position and not how he can make some bullshit of pixel aimbot .
B2T
I dont understand his problem so i cant help but i thing if you search you will find error , just test ^^
For aimbot you need your position and then calculate like this : You X - enemy X this wont work but you can test something like this
|
|
|
06/01/2013, 11:50
|
#3
|
elite*gold: 124
Join Date: Dec 2009
Posts: 2,114
Received Thanks: 3,142
|
Pixelsearch is easy to use but will fail easily.
What you need are the positions [x,y,z] of the camera and the target. Both can be read in memory.
Then you have to calculate the vector that connects both points.
So [cam_x,cam_y,cam_z]-[target_x,target_y,target_z] = [cam_x-target_x,cam_y-target_y,cam_z-target_z] is that vector.
Then you need something to define the camera direction which can be different in any game.
Hopefully the camera direction is defined as a normal-vector [x,y,z] (a normal-vector's length always is 1). The length can be calculated as sqrt(x^2+y^2+z^2). So to get the desired normal-vector for the camera you need to calculate the connector-vector's length like that and then divide it so that it's length becomes 1. For instance if the connector-vector's length is 2.5, you divide each of the parameters x,y and z by 2.5 and change the camera's normal vector to that.
Probably the game uses a different way to define the camera direction, like two angles for example. In that case you have to calculate the normal-vector by these angles and change the angles to get the desired vector vice versa.
|
|
|
06/01/2013, 13:31
|
#4
|
elite*gold: 0
Join Date: Dec 2012
Posts: 255
Received Thanks: 110
|
If you would use the search function you would have found this thread:
And you would have seen that I already answered this question.
Code:
vec3 diff = target - camPos
float distance2 = sqrt(pow(diff.x, 2) + pow(diff.y, 2))
float yaw = normalize0to2pi(atan2(diff.y, diff.x))
float pitch = normalize0to2pi(atan2(diff.z, distance2))
1. Build a vector that points from your face (camera) to your target.
2. Yaw is the opposite side (Y) / adjacent side (X) of your vectors right-angled triangle.
3. Pitch is basically the same but the opposide side "up" is Z and the adjacent side is the pythagorean XY distance between you and your target.
|
|
|
06/01/2013, 15:36
|
#5
|
elite*gold: 95
Join Date: May 2011
Posts: 982
Received Thanks: 189
|
as long as he doesnt say how the data for camera direction, player position and enemy position are given, you can not help him.
there are thousand of ways to get a position in a coordinate system. and yeah "a" coordinate system. it doesnt even have to be the cartesian.
and your linked thread is in german. i assume, that he is only speaking english... why else should he write in english^^
|
|
|
06/01/2013, 16:00
|
#6
|
elite*gold: 124
Join Date: Dec 2009
Posts: 2,114
Received Thanks: 3,142
|
When it comes to camera direction, you're right of course.
But why would one use polar coordinates or anything but cartesian coordinates to build a game?
|
|
|
06/01/2013, 16:24
|
#7
|
elite*gold: 95
Join Date: May 2011
Posts: 982
Received Thanks: 189
|
eg a game where you live on a sphere or sth...
but i was refering to the camera. im not much into game programming, but i think cartesian and spherical are both equally usefull.
|
|
|
06/01/2013, 16:51
|
#8
|
elite*gold: 124
Join Date: Dec 2009
Posts: 2,114
Received Thanks: 3,142
|
In case you're walking on a sphere, you could define that in polar coordinates indeed.
I've just never seen a game like this plus every game engine I know uses cartesic coordinates, so you couldn't simply use Unreal Engine or somthing but had to create an entire new engine.
Anyway that's of no importance. As you said, the camera direction is the main issue since there are plenty of ways to define it and every game uses a different approach.
Some games do even provide several different definitions of the camera direction while only one of them will change anything when being set to the desired value.
So you don't only have to find a way the direction is stored in memory, but find the one way that you can use to change the value.
|
|
|
06/01/2013, 20:35
|
#9
|
elite*gold: 95
Join Date: May 2011
Posts: 982
Received Thanks: 189
|
if position is cartesian and camera is in angles, then this should answer your questions
|
|
|
06/02/2013, 04:01
|
#10
|
elite*gold: 0
Join Date: Apr 2011
Posts: 363
Received Thanks: 167
|
Quote:
Originally Posted by »FlutterShy™

Why searching for pixels in a aimbot ?
Why drawing esp ?
He asked how he calculate the position and not how he can make some bullshit of pixel aimbot .
B2T
I dont understand his problem so i cant help but i thing if you search you will find error , just test ^^
For aimbot you need your position and then calculate like this : You X - enemy X this wont work but you can test something like this
|
sorry if i didn't explain well this is a memory aimbot xyz are the pos of the mainplayer and also the bots, mousex and mousey (the pos of the aim lol)
Ok heres the complete source its all commented
Code:
#include <NomadMemory.au3>
#include <Array.au3>
#include <Misc.au3>
#region Constants/Vars
#cs
OFFSETS:
xPos 0x3aC 0
yPos 0x3b4 1
zPos 0x3b0 2
hpVal 0x504 3
index 0x324 4
#ce
; 0 1 2 3 4
Global Const $offsets[5][1]=[[0x3aC] ,[0x3b4] ,[0x3b0] ,[0x504] ,[0x324]]
Global Const $ProcessName = "hl.exe"
Global Const $BaseAddr =0x25544a0
; MouseX MouseY both of them are base address
Global Const $MouseAdd[2][1] = [[0x2DE10C8],[0x2DE10C4]] ;$MouseAdd[0][0] X
;$MouseAdd[1][0] Y
Global Const $_PI =3.14159265
Global $Temp,$xAddr,$yAddr,$zAddr,$HPAddr,$VarIndex,$Enemy[4],$Player[4]
#endregion
#region GettingProcessValues
If ProcessExists($ProcessName) Then
$Pid = ProcessWait($ProcessName)
$Open =_MemoryOpen($Pid)
$Temp = _MemoryRead($BaseAddr,$Open,"long") ;Temp value that will get all other address must be in a map to the get correct value
$xAddr= $Temp + $offsets[0][0]
$yAddr= $Temp + $offsets[1][0]
$zAddr= $Temp + $offsets[2][0]
$HPAddr= $Temp + $offsets[3][0]
$VarIndex= $offsets[4][0] ;will get diferent bot values
Else
exit 0
EndIf
#endregion
#region Math Atan2
Func atan2($x, $y)
$Pi = 4 * ATan(1)
If StringIsInt($x) Or StringIsFloat($x) Then
If StringIsInt($y) Or StringIsFloat($y) Then
; OK
Else
SetError(1)
Return ""
EndIf
Else
SetError(1)
Return ""
EndIf
Dim $PolarAnswer[3] ; $Results[0]=Radius, [1]=Theta (in Radians), [2]=Theta (in Degrees)
$r = Sqrt(($x ^ 2) + ($y ^ 2))
$PolarAnswer[0] = $r
Select
Case $x = 0 And $y = 0
$ThetaRad = 0
$ThetaDeg = 0
Case $x >= 0 And $y >= 0 ; +x/+y = 0-90deg quadrant
$ThetaRad = ATan($x / $y)
$ThetaDeg = $ThetaRad * 180 / $Pi
Case $x >= 0 And $y < 0 ; +x/-y = 90-180deg quadrant
$ThetaRad = ATan(Abs($y) / $x)
$ThetaDeg = $ThetaRad * 180 / $Pi + 90
$ThetaRad = $ThetaRad + $Pi / 2
Case $x < 0 And $y < 0 ; -x/-y = 180-270deg quadrant
$ThetaRad = ATan(Abs($x) / Abs($y))
$ThetaDeg = $ThetaRad * 180 / $Pi + 180
$ThetaRad = $ThetaRad + $Pi
Case $x < 0 And $y >= 0 ; -x/+y = 2700-360deg quadrant
$ThetaRad = ATan($y / Abs($x))
$ThetaDeg = $ThetaRad * 180 / $Pi + 270
$ThetaRad = $ThetaRad + 3 * $Pi / 2
EndSelect
$PolarAnswer[1] = $ThetaDeg
SetError(0)
Return $ThetaDeg
EndFunc ;==>atan2
#endregion
#region Player/Bot data
Func GetBotValues($i);i will be 1 to number of players count (0 is MainPlayer values)
$Enemy[0]=_MemoryRead($xAddr+($VarIndex*$i),$Open,"float");X BotValues are far from each other i*$varIndex(0x324)
$Enemy[1]=_MemoryRead($yAddr+($VarIndex*$i),$Open,"float");Y
$Enemy[2]=_MemoryRead($zAddr+($VarIndex*$i),$Open,"float");Z
$Enemy[3] = _MemoryRead($HPAddr+($VarIndex*$i),$Open,"float");HP
Return $Enemy ;We need to work with arrays to make things easier
EndFunc
Func GetMainPlayerVals()
$Player[0]= _MemoryRead($xAddr,$Open,"float");Since MainPlayer index = (0*0x324) = 0 we can delete $VarIndex*$i
$Player[1]= _MemoryRead($yAddr,$Open,"float")
$Player[2]= _MemoryRead($zAddr,$Open,"float")
$Player[3]= _MemoryRead($HPAddr,$Open,"float");Don't know why but i store this value too
Return $Player
EndFunc
#endregion
#region Aimbot Math
Func Get3dDistance($EnemyVals,$PlayerVals)
$float=Sqrt( _
(($EnemyVals[0] - $PlayerVals[0]) * ($EnemyVals[0] - $PlayerVals[0]))+ _
(($EnemyVals[1] - $PlayerVals[1]) * ($EnemyVals[1] - $PlayerVals[1]))+ _
(($EnemyVals[2] - $PlayerVals[2]) * ($EnemyVals[2] - $PlayerVals[2])))
Return $float
EndFunc
Func GetMinDistanceIndex()
Local $distance[12]
For $i = 1 to 11
$distance[$i] = Get3dDistance(GetBotValues($i),GetMainPlayerVals())
$HP = GetBotValues($i)
If $HP[3] <=1 Then ;We don't want dead enemys indexes
_ArrayInsert($distance,$i,999999999999)
_ArrayDelete($distance,12); prevent adding a lot of arrays
EndIf
Next
$Index = _ArrayMinIndex($distance,1,1)
Return $Index
EndFunc
#cs
Something here is wrong
#ce
Func AimAtTarget($EnemyVal,$PlayerVal)
; Z Z
$PitchX= ASin(($EnemyVal[2]-$PlayerVal[2])/Get3dDistance($EnemyVal,$PlayerVal))*180/$_PI;180/pi
$PitchY= -Atan2($EnemyVal[0]-$PlayerVal[0],$EnemyVal[1]-$PlayerVal[1])/($_PI*180*88);/pi*360*88
; X X Y Y
Local $MouseX= _MemoryWrite($MouseAdd[0][0],$Open,$PitchX,"float") ;x mouse axis
Local $MouseY= _MemoryWrite($MouseAdd[1][0],$Open,$PitchY,"float") ;y mouse axis
EndFunc
#endregion
Aimbot()
Func Aimbot()
While 1
Local $index=GetMinDistanceIndex()
If _IsPressed("01") Then ;Right Mouse
AimAtTarget(GetBotValues($index),GetMainPlayerVals())
EndIf
WEnd
EndFunc
Quote:
Originally Posted by butter123
if position is cartesian and camera is in angles, then this should answer your questions

|
Very clear explanation thanks a lot dude!
|
|
|
06/02/2013, 08:53
|
#11
|
elite*gold: 0
Join Date: Dec 2012
Posts: 255
Received Thanks: 110
|
Quote:
Originally Posted by butter123
if position is cartesian and camera is in angles, then this should answer your questions

|
You are not even building a vector correctly. V(PE) is V(OE) - V(OP).
Also asin/acos is NEVER used to calculate rotation angles. Always use atan2, otherwise you might end up with a division by zero exception.
atan2 looks like this:
As you can see it gets around the case X = 0.
If you want a working aimbot you should just do what I posted earlier.
|
|
|
06/02/2013, 13:59
|
#12
|
elite*gold: 95
Join Date: May 2011
Posts: 982
Received Thanks: 189
|
this is a mathematical calculation. about problems with sin^-1 calculation i dont know anything...
and because i used {0,0,0} for coordinate center OE = E.
and if you want to help him with ur posted link, then translate it for him...
|
|
|
06/02/2013, 16:23
|
#13
|
elite*gold: 0
Join Date: Dec 2012
Posts: 255
Received Thanks: 110
|
Quote:
Originally Posted by butter123
this is a mathematical calculation. about problems with sin^-1 calculation i dont know anything...
and because i used {0,0,0} for coordinate center OE = E.
and if you want to help him with ur posted link, then translate it for him...
|
I used 0, 0, 0 for the origin as well but you are still not building that vector correctly. It has the wrong orientation.
If you would use asin it would result in something like this for pitch and yaw:
Code:
float yaw = normalize0to2pi(asin(Y [COLOR="Red"][B]/[/B][/COLOR] sqrt(pow(X, 2) + pow(Y, 2))));
float pitch = normalize0to2pi(asin(Z [COLOR="red"][B]/[/B][/COLOR] sqrt(pow(X, 2) + pow(Y, 2) + pow(Z, 2))));
Which is just weird, slow, and crashes if distance == 0 that is if your camera position is equal to the targets position. (Reason: You could end up with a division by zero!)
The most correct solution is to use what I posted earlier:
Code:
vec3 diff = target - camPos
float distance2 = sqrt(pow(diff.x, 2) + pow(diff.y, 2))
float yaw = normalize0to2pi(atan2(diff.y, diff.x))
float pitch = normalize0to2pi(atan2(diff.z, distance2))
You most likely won't need roll.
|
|
|
06/02/2013, 17:38
|
#14
|
elite*gold: 95
Join Date: May 2011
Posts: 982
Received Thanks: 189
|
oh ok ur right i corrected the picture, just a slip of the pen^^
|
|
|
All times are GMT +1. The time now is 10:27.
|
|