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

Editing aim

From Quake Wiki

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
''vector'' '''aim'''(''entity'' player, ''float'' missileSpeed)
+
====Syntax:====
 +
<code>vector aim(entity e, float speed)</code>
  
== Usage ==
+
Used for player weapons and links to the sv_aim console variable for autoaim.
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.
+
====Parameters:====
 +
:<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]]

Please note that all contributions to Quake Wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see Quake Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)