Results 1 to 2 of 2
  1. #1
    exp111's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0

    Question Aimbot aiming in the wrong direction

    Hey so game is pretty dead, but I still wanted to write some shitty code

    Currently working on the aimbot but I'm probably doing the calculation wrong (just setting the viewangles to VectorAngles(delta))

    Code:
    Code:
    Vector3 VectorAngles(const Vector3 forward)
    {
    	Vector3 angles = Vector3();
    	float tmp, yaw, pitch;
    
    	if (forward.x == 0 && forward.y == 0)
    	{
    		yaw = 0;
    
    		if (forward.z > 0)
    			pitch = 90.f;
    		else
    			pitch = 270.f;
    	}
    	else
    	{
    		yaw = RAD2DEG(atan2f(forward.y, forward.x));
    		if (yaw < 0)
    			yaw += 360;
    
    		tmp = forward.Length2D();
    		pitch = RAD2DEG(atan2f(forward.z, tmp));
    
    		if (pitch < 0)
    			pitch += 360;
    	}
    
    	angles.x = -pitch;
    	angles.y = yaw;
    	angles.z = 0;
    
    	return angles;
    }
    
    Vector2 VectorToViewangles(Vector3 src, Vector3 dst)
    {
    	RefDef* refDef = Functions::GetRefDef();
    	Vector3 vecEntity = Vector3();
    	Vector3 vecAngle = Vector3();
    
    	vecEntity = dst - src;
    	vecAngle = VectorAngles(vecEntity);
    	
    	if (vecAngle.y > 180.0f)
    		vecAngle.y -= 360.0f;
    	else if (vecAngle.y < -180.0f)
    		vecAngle.y += 360.0f;
    
    	if (vecAngle.x > 180.0f)
    		vecAngle.x -= 360.0f;
    	else if (vecAngle.x < -180.0f)
    		vecAngle.x += 360.0f;
    
    	return Vector2(vecAngle.x, vecAngle.y);
    }
    And calling that in Draw2D hook:
    Code:
    if (closestPlayer != nullptr)
    {
    	void* font = Functions::RegisterFont(FONT_NORMAL, 1);
    	ClientInfo* client = Functions::GetClientByIndex(closestPlayerNum);
    	Functions::CmdDrawText(client->Name, font, 100, 375, Color::white);
    
    	Vector3 headPos = Functions::GetBonePos(closestPlayer, Enums::Bones::HEAD);
    
    	Vector3 eyePos = refDef->eyePos
    	Vector2 angle = VectorToViewangles(eyePos, headPos);
    	viewAngles->x = angle.x;
    	viewAngles->y = angle.y;
    }
    ViewAngles = 0xBC7750 (can change them and they look right)
    RefDef = 0x90B648
    Code:
    class RefDef
    {
    	char stub[8];
    	int scrWidth;
    	int scrHeight;
    	Vector2 fov;
    	Vector3 eyePos;
    	Vector3 viewAxis[3];
    	char stub2[16200];
    	Vector3 rdViewAngles;
    };
    It sometimes locks to the sky or the exact opposite direction. Most of the time pitch is right but yaw fucks up.

    Would be great if someone knew how to fix this

  2. #2
    avalanche33's Avatar
    Join Date
    Oct 2020
    Gender
    male
    Posts
    16
    Reputation
    10
    Thanks
    4
    The code looks right, I'll test it and report back

Similar Threads

  1. My Aimbot Starts Aiming At the Floor??
    By DjTapia( in forum Fortnite Discussion & Help
    Replies: 2
    Last Post: 10-16-2017, 01:22 PM
  2. [Help] Am I heading in the wrong direction?
    By Mezmaa in forum Coders Lounge
    Replies: 3
    Last Post: 08-21-2015, 01:29 PM
  3. [Help] Are there any working aimbots that aim at the head?
    By oooooooooo in forum CrossFire Hacks & Cheats
    Replies: 9
    Last Post: 09-13-2009, 04:20 PM
  4. Following The Wrong Path
    By Haxors in forum General
    Replies: 44
    Last Post: 09-12-2007, 03:37 AM
  5. sorry to put this in the wrong place but
    By l3artt in forum WarRock - International Hacks
    Replies: 14
    Last Post: 07-20-2007, 02:16 PM