Merge branch 'master' of git://github.com/BTAxis/naev into testmission
[naev.git] / docs / ai / API
blobabae992dee4f8f95ca0dce4e2990d4892ca4fae6
3       C O N S T A N T S
6 number player
7    @desc players pilot ID
10       F U N C T I O N S
13    T A S K S
15 pushtask( number pos, string name, int/pointer target )
16    @desc pushes a task onto the queue
17    @param pos puts it at the beginning if 0, or end if 1
18    @param name is the function name (should be defined in the lua file)
19    @param target is an int or pointer containing target info (can be for example
20    pilot ID or a Vector2d*)
21    @return nil
23 poptask()
24    @desc pops the current task from the list
25    @return nil
27 taskname()
28    @desc returns the currnt task's name
29    @return string name of the current task
32    C O N S U L T
34 target()
35    @desc gets the current target
36    @return pointer to the current target
38 targetid()
39    @desc gets the current targets ID
40    @return number the current target's ID
42 rndpilot()
43    @desc gets a random target ID
44    @return number to a random target ID
46 dist( Vector2d vect )
47    @desc gets the distance from the position of the Vector2d vect
48    @param vect point to calculate the distance from
49    @return nil
51 pos( [number pilot] )
52    @desc gets the pilot's position or the current pilot's position if no pilot is specified
53    @param pilot ID of the pilot to get the position of, if no params are
54    called it uses the current pilot as target
55    @return Vector2d
57 minbrakedist()
58    @desc returns the minimum required braking distance assuming all goes well
59    @return number distance needed to brake
61 armour( [number pilot] )
62    @desc returns the total amount of armour left
63    @param pilot optional pilot id, if not the current pilot is used
64    @return pilots current amount of armour
66 shield( [number pilot] )
67    @desc returns the total amount of shield left
68    @param pilot optional pilot id, if not the current pilot is used
69    @return pilots current amount of shield
71 parmour( [number pilot] )
72    @desc returns the percent of armour left
73    @param pilot optional pilot id, if not the current pilot is used
74    @return percent of armour the pilot has left
76 pshield( [number pilot] )
77    @desc returns the percent of shield left
78    @param pilot optional pilot id, if not the current pilot is used
79    @return percent of shield the pilot has left
81 cargofree()
82    @desc returns how much free space the pilot has
83    @return free space of the current pilot (in tons)
86    B O O L E A N
88 exists( number id )
89    @desc checks to see if pilot id is vald
90    @param id pilot to check
91    @return true if the pilot is valid
93 ismaxvel()
94    @desc checks if velocity is maximum
95    @return true if velocity is maximum, false otherwise
97 isstopped()
98    @desc checks if is stopped
99    @return true if stopped, false otherwise
101 isenemy( number p )
102    @desc checks if p is an enemy of current pilot 
103    @param p ID of a pilot to see if he is an enemy
104    @return true if p is an enemy
106 isally( number p )
107    @desc checks if p is an ally of the current pilot
108    @param p ID of a pilot to check if he is an ally
109    @return true if p is an ally
111 incombat( [number id] )
112    @desc queries whether a pilot is in combat
113    @param id pilot to check whether is in combat or not, defaults to self
114    @return if pilot is in combat or not
118    M O V E M E N T
120 accel( [number mod] )
121    @desc accelerates the pilot
122    @param mod float that represents speed to accel to (1. is full speed, 0. is stopped)
123    @return nil
125 turn( number mod )
126    @desc turns the pilot
127    @param mod float that represents  the turning ratio between -1 (max right) and 1 (max left)
128    @return nil
130 face( number/Vector2d target, [number invert] )
131    @desc turns to face target
132    @param target pilot ID or Vector2d to face
133    @param invert faces away if 1
134    @return number offset from target in grad
136 brake()
137    @desc makes the pilot brake
138    @return nil
140 getnearestplanet()
141    @desc gets the nearest friendly planet's position
142    @return position to the nearest friendly planet
144 getrndplanet()
145    @desc gets the position of a random friendly planet
146    @return position to a random friendly planet
150    C O M B A T
152 combat( [number b] )
153    @desc makes the pilot be set as either in combat or out of combat (for comm and such)
154    @param b if 0 sets the pilot to be in combat, if 1 or ommitted sets it to be in combat
155    @return nil
157 settarget( number target )
158    @desc sets the target for the pilot, should be called each frame
159    @param target pilot to be targetted
160    @return nil
162 secondary()
163    @desc attempts to set the best secondary weapon (defaults to launchers)
164    @return the type of the secondary weapon set ("None","Weapon","Launcher","Turret")
166 hasturrets()
167    @desc checks to see if the pilot has turrets
168    @return true if the pilot has turrets
170 shoot( [number weapon] )
171    @desc makes the pilot shoot weapons
172    @param weapon weapons to shoot, 1 if primary, 2 if secondary, 3 if both.  Defaults to 1.
173    @return nil
175 getenemy()
176    @desc returns the id of the nearest enemy
177    @return Pilot id of the closest enemy or 0 if none is found
181    T I M E R S
183 settimer( number t, number delay )
184    @desc sets timer t to wait for delay ms
185    @param t timer to set
186    @param delay time in ms to wait
187    @return nil
189 timeup( number t )
190    @desc returns true if time is up for timer t
191    @param t timer to check
192    @return boolean true if timer t is up
196    M E S S A G I N G
198 comm( number id, string message )
199    @desc makes the pilot say something to the pilot of id id
200    @param id id of the pilot to talk to
201    @param message string to say to the player
202    @return nil
204 broadcast( string message )
205    @desc makes the pilot broadcast a message to everyone in the system
206    @param message string to say to everyone in the system
207    @return nil
211    L O O T
213 setcredits( number creds )
214    @desc sets the pilot's credits to creds, only works during create
215    @param creds pilot's credits
216    @return nil
218 setcargo( string cargo, number quantity )
219    @desc gives the pilot quantity of cargo, only works during create
220    @param cargo name of cargo to give the pilot
221    @param quantity amount to give the pilot
222    @return nil
224 shipprice()
225    @desc gets the price of the pilot's ship
226    @return the price of the pilot's ship
230    M I S C
232 rng( number low, number high )
233    @desc returns a random number between low and high
234    @param low minimum to return
235    @param high maximum to return
236    @return random number between low and high