Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

aim

From Quake Wiki

vector aim(entity player, float missileSpeed)

Usage[edit]

Gets a valid target for the player to auto aim at. The sv_aim console variable determines the maximum angle from the check position the entity can be. This is the cosine of the angle, so an angle range of 20 degrees would be ~0.9397. The aim direction uses the v_forward global so makevectors(player.v_angle) should be called beforehand. The position of the check is 20 units above the player's origin and has a max range of 2048 map units. The angle is considered from the check position to the center of the possible entity to aim at.

Only entities that have the takedamage type of DAMAGE_AIM will be auto aimed at and there must be line of sight.

Parameters[edit]

  • player
The player doing the auto aim check.
  • missileSpeed
Unused.

Return[edit]

The new aim direction as a unit vector. This is either the direction facing towards the auto aimed entity or v_forward if no valid one was found.

Example[edit]

// Aim a player's missile at potential valid monsters
makevectors(self.v_angle);
entity missile = spawn();

vector aimDir = aim(self, 0);
missile.velocity = aimDir * 1024;
// ...