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

Difference between revisions of "aim"

From Quake Wiki

 
Line 1: Line 1:
====Syntax:====
+
''vector'' '''aim'''(''entity'' player, ''float'' missileSpeed)
<code>vector aim(entity e, float speed)</code>
 
  
Used for player weapons and links to the sv_aim console variable for autoaim.
+
== Usage ==
====Parameters:====
+
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 <code>makevectors(player.v_angle)</code> 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.
:<code>f</code> - The float value to convert
 
====Returns:====
 
:Returns a vector along which the entity ''e'' can shoot. The vector is calculated based on the sv_aim console variable to the closest enemy entity.
 
  
 +
Only entities that have the '''takedamage''' type of <code>DAMAGE_AIM</code> will be auto aimed at and there must be line of sight.
 +
 +
=== Parameters ===
 +
*''player''
 +
:The player doing the auto aim check.
 +
*''missileSpeed''
 +
:Unused.
 +
 +
=== Return ===
 +
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 ==
 +
// 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;
 +
// ...
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Latest revision as of 13:32, 1 August 2023

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;
// ...