HelpPseudo code for an aimlock?

Posts 1–5 of 5 · Page 1 of 1
Pseudo code for an aimlock?
I am trying to code an aimlock and I'm trying to make some pseudo code, or a list of the functions I need for the aimlock. Here's what I have on my paper:

  • Cycle thru Ent. List
  • Find closest enemy to your player
  • Get coords of target enemy's bone
  • Calculate angle between you and the bone
  • Clamp the angle


What would be next? Writing the angle to your player's viewangles?

Thanks.
Yes, then you write the calculated angles to your player viewangles. Don't forget to save the target entity and if the entity is not valid anymore, search for a new one.
Code:
int BestTarget = -1; // Save the entity index here, after you choose the best one.

if (BestTarget == -1)
	FindTarget(); // Find the best entity based on distance, fov, whatever and save the index of it into BestTarget

if (BestTarget != -1)
	AimAtTarget(); // If we have found a target, aim at it!

if (!IsEntityValid(BestTarget)) // Do your checks here - is alive, not dormant, is enemy, etc. if the entity is not valid anymore,
	BestTarget = -1;          // set BestTarget to -1 so the aimbot searches for a new target


I'm not the best at explaining stuff like this, but if you need more help, just ask

- - - Updated - - -

Also, this thread should be on Coding & Resources section.
Quote Originally Posted by 4773n0x View Post
Yes, then you write the calculated angles to your player viewangles. Don't forget to save the target entity and if the entity is not valid anymore, search for a new one.
Code:
int BestTarget = -1; // Save the entity index here, after you choose the best one.

if (BestTarget == -1)
	FindTarget(); // Find the best entity based on distance, fov, whatever and save the index of it into BestTarget

if (BestTarget != -1)
	AimAtTarget(); // If we have found a target, aim at it!

if (!IsEntityValid(BestTarget)) // Do your checks here - is alive, not dormant, is enemy, etc. if the entity is not valid anymore,
	BestTarget = -1;          // set BestTarget to -1 so the aimbot searches for a new target


I'm not the best at explaining stuff like this, but if you need more help, just ask

- - - Updated - - -

Also, this thread should be on Coding & Resources section.
Okay, then I should have all the functions. Don't close this thread til I post back results, please.
/Moved to the correct section.
1 week has passed and no further replies have been made by the OP. Assuming solved.

/Closed.
Posts 1–5 of 5 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us