Aim Angles

Prefixobjekt

Active member
Joined
Aug 1, 2014
Messages
55
Reaction score
0
Hello,

does anyone know how to calculate the current aim angles?
i need it to make a fov check

im idiot at this math.

have anyone a simple example?

plz help :D
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
Prefixobjekt said:
Hello,

does anyone know how to calculate the current aim angles?
i need it to make a fov check

im idiot at this math.

have anyone a simple example?

plz help :D

Get the z Angle between your camera and the target as degrees: 0-360°.
And then turn the degrees to radians. Now u have the angles to your target.
Then take them and stick it up your ass :gtfo:

Angles are reversed in GTA:SA; 90 degrees would be East in the real world, but in GTA:SA 90 degrees is in fact West. North and South are still 0/360 and 180. To convert this, simply do 360 - angle.
 

Prefixobjekt

Active member
Joined
Aug 1, 2014
Messages
55
Reaction score
0
zAngle = sinus Distance between myPos and targetPos?

i got distance from mypos to targetpos.

i found this picture, how to calculate?
S6khhXF.png


id like to have a alpha FOV like 30
 

Prefixobjekt

Active member
Joined
Aug 1, 2014
Messages
55
Reaction score
0
yep, but i think its like csgo to calculate this?
can u giv me an example ? idk plz

im found this address for camera Z

0x00B6F248

atm im doin this here for the z angle

sqrt((sb[0] - me[0])^2 + (sb[1] - me[1])^2 + (sb[2] - me[2])^2)
it returns the distance.....
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
151
hi, idk if that's what you're looking for but I used something like this to check if player is on screen


Code:
typedef bool (__cdecl *WorldCoords2ScreenCoords_t)(myVector*, myVector*, float * , float * , char, char);
WorldCoords2ScreenCoords_t WorldCoords2ScreenCoords = (WorldCoords2ScreenCoords_t)0x70CE30;

bool Players::IsOnScreen()
{
	XYZ position = GetPos();
	myVector inPoint = { position.x, position.y, position.z};
	if(!(position.x == 0.0f) && !(position.y == 0.0f) && !(position.z == 0.0f))
	{
		tuple<float, float, bool> result = Convert3DposTo2Dscreen(inPoint);
		if(get<2>(result) == true)
		{
			screenPos[0] = get<0>(result);
			screenPos[1] = get<1>(result);
			return true;
		}
	}
	return false;
}


tuple<float, float, bool> Convert3DposTo2Dscreen(myVector inPoint)
{
	bool isOnScreen;
	float x, y;
	myVector outPoint;
	WorldCoords2ScreenCoords(&inPoint, &outPoint, &x, &y, 0, 0);


	outPoint.pos[0] /= x;
	outPoint.pos[0] /= outPoint.pos[2];
	outPoint.pos[1] /= y;
	outPoint.pos[1] /= outPoint.pos[2];
	outPoint.pos[0] *= resolutionX; //or use 1650.0  //640.0
	outPoint.pos[1] *= resolutionY; //or use 1050.0  //448.0
	if(x > 0.0 && y > 0.0)
	{
		isOnScreen = true;
	}
	else
	{
		isOnScreen = false;
	}
	return make_tuple(outPoint.pos[0], outPoint.pos[1], isOnScreen);
}
 

Prefixobjekt

Active member
Joined
Aug 1, 2014
Messages
55
Reaction score
0
im doin this before with worldtoscreen but:
the problem ist when the player is far away, the FOV is fucked up

-.-
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
Aim angles  => X: 0xB6F248 Y: 0xB6F258

There are also some functions to check if the player is on screen,
Code:
#define FUNC_IsOnScreen 0x534540
#define FUNC_IsVisible 0x536BC0
 

Prefixobjekt

Active member
Joined
Aug 1, 2014
Messages
55
Reaction score
0
ah nice, thx  but how to calculate it?
like when my angles to the targetplayer like <=30° (FOV)
return 1

and the crosshair is not in the mid on screen its like mid + 22 pixels

aim angles are from mid right?
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
Get your current viewangles and the targets viewangle
and calculate the distance between it. The result is the FoV 0.0 - M_PI
 

Prefixobjekt

Active member
Joined
Aug 1, 2014
Messages
55
Reaction score
0
i found a little snippet from an old MTA Aimbot

can i get the FOV from this here?

im comment it a little bit.
Code:
        aa = fabs(camposXY[0] - targetpos[0]); // my target angleX ?
        ab = fabs(camposXY[1] - targetpos[1]); // my target angleY
        ac = Sqrt( aa * aa + ab * ab );  // its pythagoras but idk what math 
        alpha1 = asin( aa / ac );  // maybe x angle to player??
        beta = acos( aa / ac ); // maybe y angle to player??

im converted alpha1 and beta to degree to the player Id 270

f23f2df60d.png



and now
how to get now the FOV?
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
151
Code:
#define PI           3.14159265358979323846f

struct XYZ
{
	float x;
	float y;
	float z;
};


////this should be in your main function
float angle = GetCameraXAngle() - GetAngleBetween_Camera_Player(playerID);
angle -= 180.0f;
if(angle < 0.0f){angle += 360.0f;}
//here you should add check for the field of view by trial and error but the variable called "angle" is something you should base on if you're going to do it this way
//




float GetAngleBetween_Camera_Player(int id)
{
	XYZ cam = GetCameraPos();//You'd have to make your own GetCameraPos() function definition
	XYZ p = player[id].GetPos();
	return 180.0f + atan2(cam.x - p.x, cam.y - p.y) * 180.0f / PI;
}

float GetCameraXAngle()
{
	float angle = 360.0f + atan2(*(float*)0x00B6F104, *(float*)0x00B6F108) * 180 / PI;
	if(angle > 360.0f){angle -= 360.0f;}
	return angle;
}
 

Prefixobjekt

Active member
Joined
Aug 1, 2014
Messages
55
Reaction score
0
thanx, it works.
Im only need a fix for the distance, FOV is too big when im far away

how to make it always same distance?
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
151
maybe that's just wrong way of doing this...
cdHj1ce.png


Blue dot - camera position
Black lines - camera vision
Red lines - players perception by angle

This would explain why there are problems with this way, but why you had issues with the "3d_to_2dOnScreen" way I can't tell because I used that code and it worked well...
 

Prefixobjekt

Active member
Joined
Aug 1, 2014
Messages
55
Reaction score
0
have anyone a idea?

if im doin it with W2S or Angles, any calculation method to solve range problem?
 
Top