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)
| + | vector '''aim'''(entity ''e'', float ''missilespeed'') |
| | | |
− | == Usage ==
| + | Returns a vector along which the entity ''e'' can shoot. |
− | 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.
| + | Usually, ''e'' is a player, and the vector returned is calculated by auto-aiming 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]]
| |