naev 0.12.6
Lua AI Bindings

Handles how the AI interacts with the universe. More...

Functions

static int aiL_pushtask (lua_State *L)
 Pushes a task onto the pilot's task list. Lua function parameter: string func Name of function to call for task. Lua function parameter:[opt] data Data to pass to the function. Supports any lua type.
static int aiL_poptask (lua_State *L)
 Pops the current running task.
static int aiL_taskname (lua_State *L)
 Gets the current task's name. Lua return parameter: string The current task name or nil if there are no tasks.
static int aiL_taskdata (lua_State *L)
 Gets the pilot's task data. Lua return parameter: The pilot's task data or nil if there is no task data. See also: pushtask.
static int aiL_pushsubtask (lua_State *L)
 Pushes a subtask onto the pilot's task's subtask list. Lua function parameter: string func Name of function to call for task. Lua function parameter:[opt] data Data to pass to the function. Supports any lua type.
static int aiL_popsubtask (lua_State *L)
 Pops the current running task.
static int aiL_subtaskname (lua_State *L)
 Gets the current subtask's name. Lua return parameter: string The current subtask name or nil if there are no subtasks.
static int aiL_subtaskdata (lua_State *L)
 Gets the pilot's subtask target. Lua return parameter: The pilot's target ship identifier or nil if no target. See also: pushsubtask.
static int aiL_pilot (lua_State *L)
 Gets the AI's pilot. Lua return parameter: Pilot The AI's pilot.
static int aiL_getrndpilot (lua_State *L)
 Gets a random pilot in the system. Lua return parameter: Pilot|nil.
static int aiL_getnearestpilot (lua_State *L)
 gets the nearest pilot to the current pilot
static int aiL_getdistance (lua_State *L)
 Gets the distance from the pointer.
static int aiL_getdistance2 (lua_State *L)
 Gets the squared distance from the pointer.
static int aiL_getflybydistance (lua_State *L)
 Gets the distance from the pointer perpendicular to the current pilot's flight vector.
static int aiL_minbrakedist (lua_State *L)
 Gets the minimum braking distance.
static int aiL_isbribed (lua_State *L)
 Checks to see if target has bribed pilot.
static int aiL_instantJump (lua_State *L)
 Checks to see if pilot can instant jump.
static int aiL_ismaxvel (lua_State *L)
 Checks to see if pilot is at maximum velocity.
static int aiL_isstopped (lua_State *L)
 Checks to see if pilot is stopped.
static int aiL_isenemy (lua_State *L)
 Checks to see if target is an enemy.
static int aiL_isally (lua_State *L)
 Checks to see if target is an ally.
static int aiL_haslockon (lua_State *L)
 Checks to see if pilot has a missile lockon.
static int aiL_hasprojectile (lua_State *L)
 Checks to see if pilot has a projectile after him.
static int aiL_scandone (lua_State *L)
 Checks to see if pilot has finished scanning their target.
static int aiL_accel (lua_State *L)
 Starts accelerating the pilot.
static int aiL_turn (lua_State *L)
 Starts turning the pilot.
static int aiL_face (lua_State *L)
 Faces the target.
static int aiL_careful_face (lua_State *L)
 Gives the direction to follow in order to reach the target while minimizating risk.
static int aiL_aim (lua_State *L)
 Aims at a pilot, trying to hit it rather than move to it.
static int aiL_iface (lua_State *L)
 Maintains an intercept pursuit course.
static int aiL_dir (lua_State *L)
 calculates the direction that the target is relative to the current pilot facing.
static int aiL_idir (lua_State *L)
 Calculates angle between pilot facing and intercept-course to target.
static int aiL_drift_facing (lua_State *L)
 Calculate the offset between the pilot's current direction of travel and the pilot's current facing.
static int aiL_brake (lua_State *L)
 Brakes the pilot.
static int aiL_getnearestspob (lua_State *L)
 Get the nearest friendly spob to the pilot.
static int aiL_getspobfrompos (lua_State *L)
 Get the nearest friendly spob to a given position.
static int aiL_getrndspob (lua_State *L)
 Get a random spob.
static int aiL_getlandspob (lua_State *L)
 Get a random friendly spob.
static int aiL_land (lua_State *L)
 Lands on a spob.
static int aiL_hyperspace (lua_State *L)
 Tries to enter hyperspace.
static int aiL_sethyptarget (lua_State *L)
 Sets hyperspace target.
static int aiL_nearhyptarget (lua_State *L)
 Gets the nearest hyperspace target.
static int aiL_rndhyptarget (lua_State *L)
 Gets a random hyperspace target.
static int aiL_canHyperspace (lua_State *L)
 Gets whether or not the pilot can hyperspace.
static int aiL_hyperspaceAbort (lua_State *L)
 Has the AI abandon hyperspace if applicable.
static int aiL_relvel (lua_State *L)
 Gets the relative velocity of a pilot.
static int aiL_follow_accurate (lua_State *L)
 Computes the point to face in order to follow another pilot using a PD controller.
static int aiL_face_accurate (lua_State *L)
 Computes the point to face in order to follow a moving object.
static int aiL_stop (lua_State *L)
 Completely stops the pilot if it is below minimum vel error (no insta-stops).
static int aiL_dock (lua_State *L)
 Docks the ship.
static int aiL_combat (lua_State *L)
 Sets the combat flag.
static int aiL_settarget (lua_State *L)
 Sets the pilot's target.
static int aiL_setasterotarget (lua_State *L)
 Sets the pilot's asteroid target.
static int aiL_getGatherable (lua_State *L)
 Gets the closest gatherable within a radius.
static int aiL_gatherablePos (lua_State *L)
 Gets the pos and vel of a given gatherable.
static int aiL_weapSet (lua_State *L)
 Sets the active weapon set, fires another weapon set or activate an outfit.
static int aiL_hascannons (lua_State *L)
 Does the pilot have cannons?
static int aiL_hasturrets (lua_State *L)
 Does the pilot have turrets?
static int aiL_hasfighterbays (lua_State *L)
 Does the pilot have fighter bays?
static int aiL_hasafterburner (lua_State *L)
 Does the pilot have afterburners?
static int aiL_getenemy (lua_State *L)
 Gets the nearest enemy.
static int aiL_hostile (lua_State *L)
 Sets the enemy hostile (basically notifies of an impending attack).
static int aiL_getweaprangemin (lua_State *L)
 Gets the minimum range of a weapon set.
static int aiL_getweaprange (lua_State *L)
 Gets the range of a weapon set.
static int aiL_getweapspeed (lua_State *L)
 Gets the speed of a weapon.
static int aiL_getweapammo (lua_State *L)
 Gets the ammo of a weapon.
static int aiL_canboard (lua_State *L)
 Checks to see if pilot can board the target.
static int aiL_relsize (lua_State *L)
 Gets the relative size (ship mass) between the current pilot and the specified target.
static int aiL_reldps (lua_State *L)
 Gets the relative damage output (total DPS) between the current pilot and the specified target.
static int aiL_relhp (lua_State *L)
 Gets the relative health (total shields and armour) between the current pilot and the specified target.
static int aiL_board (lua_State *L)
 Attempts to board the pilot's target.
static int aiL_refuel (lua_State *L)
 Attempts to refuel the pilot's target.
static int aiL_settimer (lua_State *L)
 Sets a timer.
static int aiL_timeup (lua_State *L)
 Checks a timer.
static int aiL_set_shoot_indicator (lua_State *L)
 Set the seeker shoot indicator.
static int aiL_shoot_indicator (lua_State *L)
 Access the seeker shoot indicator (that is put to true each time a seeker is shot).
static int aiL_distress (lua_State *L)
 Sends a distress signal.
static int aiL_getBoss (lua_State *L)
 Picks a pilot that will command the current pilot.
static int aiL_credits (lua_State *L)
 Sets the pilots credits. Only call in create().
static int aiL_messages (lua_State *L)
 Returns and clears the pilots message queue.
static int aiL_stealth (lua_State *L)
 Tries to stealth or destealth the pilot.
static int aiL_outfitOffAll (lua_State *L)
 Tries to turn off all outfits.

Detailed Description

Handles how the AI interacts with the universe.

Usage is:

ai.function( params )

Function Documentation

◆ aiL_accel()

int aiL_accel ( lua_State * L)
static

Starts accelerating the pilot.

Lua function parameter:[opt=1.] number acceleration Fraction of pilot's maximum acceleration from 0 to 1.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: accel

Definition at line 1802 of file ai.c.

◆ aiL_aim()

int aiL_aim ( lua_State * L)
static

Aims at a pilot, trying to hit it rather than move to it.

This method uses a polar UV decomposition to get a more accurate time-of-flight

Lua function parameter: Pilot|Asteroid target The pilot to aim at Lua return parameter: number The offset from the target aiming position (in radians).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: aim

Definition at line 2027 of file ai.c.

◆ aiL_board()

int aiL_board ( lua_State * L)
static

Attempts to board the pilot's target.

Lua return parameter: boolean true if was able to board the target.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: board

Definition at line 3308 of file ai.c.

◆ aiL_brake()

int aiL_brake ( lua_State * L)
static

Brakes the pilot.

Lua function parameter:[opt=false] boolean prefer_reverse Whether or not to prefer reverse thrusters. Lua return parameter: boolean Whether braking is finished.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: brake

Definition at line 2269 of file ai.c.

◆ aiL_canboard()

int aiL_canboard ( lua_State * L)
static

Checks to see if pilot can board the target.

Lua function parameter: Pilot target Target to see if pilot can board. Lua return parameter: boolean true if pilot can board, false if it can't.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: canboard

Definition at line 3242 of file ai.c.

◆ aiL_canHyperspace()

int aiL_canHyperspace ( lua_State * L)
static

Gets whether or not the pilot can hyperspace.

Lua return parameter: boolean Whether or not the pilot can hyperspace.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: canHyperspace

Definition at line 2747 of file ai.c.

◆ aiL_careful_face()

int aiL_careful_face ( lua_State * L)
static

Gives the direction to follow in order to reach the target while minimizating risk.

This method is based on a simplified version of trajectory generation in mobile robotics using the potential method.

The principle is to consider the mobile object (ship) as a mechanical object. Obstacles (enemies) and the target exert attractive or repulsive force on this object.

Only visible ships are taken into account.

Lua function parameter: Pilot|Vec2|number target Target to go to. Lua return parameter: number Angle offset in radians.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: careful_face

Definition at line 1925 of file ai.c.

◆ aiL_combat()

int aiL_combat ( lua_State * L)
static

Sets the combat flag.

Lua function parameter:[opt=true] boolean val Value to set flag to.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: combat

Definition at line 2936 of file ai.c.

◆ aiL_credits()

int aiL_credits ( lua_State * L)
static

Sets the pilots credits. Only call in create().

Lua function parameter: number num Number of credits.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setcredits

Definition at line 3427 of file ai.c.

◆ aiL_dir()

int aiL_dir ( lua_State * L)
static

calculates the direction that the target is relative to the current pilot facing.

Lua function parameter: Pilot|Vec2 target Position or pilot to compare facing to Lua return parameter: number The facing offset to the target (in radians).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: dir

Definition at line 2141 of file ai.c.

◆ aiL_distress()

int aiL_distress ( lua_State * L)
static

Sends a distress signal.

Lua function parameter: string|nil msg Message to send or nil.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: distress

Definition at line 3387 of file ai.c.

◆ aiL_dock()

int aiL_dock ( lua_State * L)
static

Docks the ship.

Lua function parameter: Pilot target Pilot to dock with.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: dock

Definition at line 2922 of file ai.c.

◆ aiL_drift_facing()

int aiL_drift_facing ( lua_State * L)
static

Calculate the offset between the pilot's current direction of travel and the pilot's current facing.

Lua return parameter: number Offset (radians)

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: drift_facing

Definition at line 2253 of file ai.c.

◆ aiL_face()

int aiL_face ( lua_State * L)
static

Faces the target.

Lua usage parameter: ai.face( a_pilot ) – Face a pilot Lua usage parameter: ai.face( a_pilot, true ) – Face away from a pilot Lua usage parameter: ai.face( a_pilot, nil, true ) – Compensate velocity facing a pilot

Lua function parameter: Pilot|Vec2|number target Target to face. Can be either a pilot, position (Vec2), or an orientation (number representing angle in radians). Lua function parameter:[opt=false] boolean invert Invert away from target. Lua function parameter:[opt=false] boolean compensate Compensate for velocity? Lua return parameter: number Absolute angle offset in radians.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: face

Definition at line 1835 of file ai.c.

◆ aiL_face_accurate()

int aiL_face_accurate ( lua_State * L)
static

Computes the point to face in order to follow a moving object.

Lua function parameter: vec2 pos The objective vector Lua function parameter: vec2 vel The objective velocity Lua function parameter:[opt=0.] number radius The requested distance between p and target Lua function parameter:[opt=0.] number angle The requested angle between p and target (radians) Lua function parameter:[opt=10.] number Kp The first controller parameter Lua function parameter:[opt=20.] number Kd The second controller parameter Lua return parameter: The point to go to as a vector2.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: face_accurate

Definition at line 2870 of file ai.c.

◆ aiL_follow_accurate()

int aiL_follow_accurate ( lua_State * L)
static

Computes the point to face in order to follow another pilot using a PD controller.

Lua function parameter: Pilot target The pilot to follow Lua function parameter:[opt=0.] number radius The requested distance between p and target Lua function parameter:[opt=0.] number angle The requested angle between p and target (radians) Lua function parameter:[opt=10.] number Kp The first controller parameter Lua function parameter:[opt=20.] number Kd The second controller parameter Lua function parameter:[opt] string method Method to compute goal angle Lua return parameter: The point to go to as a vector2.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: follow_accurate

Definition at line 2814 of file ai.c.

◆ aiL_gatherablePos()

int aiL_gatherablePos ( lua_State * L)
static

Gets the pos and vel of a given gatherable.

Lua function parameter: int id Id of the gatherable. Lua return parameter: vec2 pos position of the gatherable. Lua return parameter: vec2 vel velocity of the gatherable.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: gatherablepos

Definition at line 3020 of file ai.c.

◆ aiL_getBoss()

int aiL_getBoss ( lua_State * L)
static

Picks a pilot that will command the current pilot.

Lua return parameter: Pilot|nil

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getBoss

Definition at line 3409 of file ai.c.

◆ aiL_getdistance()

int aiL_getdistance ( lua_State * L)
static

Gets the distance from the pointer.

Lua function parameter: Vec2|Pilot pointer Lua return parameter: number The distance from the pointer.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: dist

Definition at line 1523 of file ai.c.

◆ aiL_getdistance2()

int aiL_getdistance2 ( lua_State * L)
static

Gets the squared distance from the pointer.

Lua function parameter: Vec2|Pilot pointer Lua return parameter: number The squared distance from the pointer.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: dist2

Definition at line 1550 of file ai.c.

◆ aiL_getenemy()

int aiL_getenemy ( lua_State * L)
static

Gets the nearest enemy.

Lua function parameter:[opt=nil] Vec2 radius Distance to search for an enemy. If not specified tries to find the nearest enemy. Lua return parameter: Pilot|nil

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getenemy

Definition at line 3120 of file ai.c.

◆ aiL_getflybydistance()

int aiL_getflybydistance ( lua_State * L)
static

Gets the distance from the pointer perpendicular to the current pilot's flight vector.

Lua function parameter: Vec2|Pilot pointer Lua return parameter: number offset_distance

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: flyby_dist

Definition at line 1578 of file ai.c.

◆ aiL_getGatherable()

int aiL_getGatherable ( lua_State * L)
static

Gets the closest gatherable within a radius.

Lua function parameter: float rad Radius to search in. Lua return parameter: int i Id of the gatherable or nil if none found.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getgatherable

Definition at line 2992 of file ai.c.

◆ aiL_getlandspob()

int aiL_getlandspob ( lua_State * L)
static

Get a random friendly spob.

Lua function parameter:[opt=false] boolean only_friend Only check for ally spobs. Lua return parameter: Spob|nil

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: landspob

Definition at line 2410 of file ai.c.

◆ aiL_getnearestpilot()

int aiL_getnearestpilot ( lua_State * L)
static

gets the nearest pilot to the current pilot

Lua return parameter: Pilot|nil

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: nearestpilot

Definition at line 1488 of file ai.c.

◆ aiL_getnearestspob()

int aiL_getnearestspob ( lua_State * L)
static

Get the nearest friendly spob to the pilot.

Lua return parameter: Spob|nil

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: nearestspob

Definition at line 2305 of file ai.c.

◆ aiL_getrndpilot()

int aiL_getrndpilot ( lua_State * L)
static

Gets a random pilot in the system. Lua return parameter: Pilot|nil.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: rndpilot

Returns
Number of Lua parameters.

Definition at line 1464 of file ai.c.

◆ aiL_getrndspob()

int aiL_getrndspob ( lua_State * L)
static

Get a random spob.

Lua return parameter: Spob|nil

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: rndspob

Definition at line 2384 of file ai.c.

◆ aiL_getspobfrompos()

int aiL_getspobfrompos ( lua_State * L)
static

Get the nearest friendly spob to a given position.

Lua function parameter: vec2 pos Position close to the spob. Lua return parameter: Spob|nil

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: spobfrompos

Definition at line 2344 of file ai.c.

◆ aiL_getweapammo()

int aiL_getweapammo ( lua_State * L)
static

Gets the ammo of a weapon.

Lua function parameter:[opt] number id Optional parameter indicating id of weapon set to get ammo of, defaults to selected one. Lua return parameter: number The range of the weapon set.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getweapammo

Definition at line 3228 of file ai.c.

◆ aiL_getweaprange()

int aiL_getweaprange ( lua_State * L)
static

Gets the range of a weapon set.

Lua function parameter:[opt] number id Optional parameter indicating id of weapon set to get range of, defaults to selected one. Lua return parameter: number The range of the weapon set.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getweaprange

Definition at line 3198 of file ai.c.

◆ aiL_getweaprangemin()

int aiL_getweaprangemin ( lua_State * L)
static

Gets the minimum range of a weapon set.

Lua function parameter:[opt] number id Optional parameter indicating id of weapon set to get range of, defaults to selected one. Lua return parameter: number The range of the weapon set.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getweaprangemin

Definition at line 3183 of file ai.c.

◆ aiL_getweapspeed()

int aiL_getweapspeed ( lua_State * L)
static

Gets the speed of a weapon.

Lua function parameter:[opt] number id Optional parameter indicating id of weapon set to get speed of, defaults to selected one. Lua return parameter: number The range of the weapon set.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getweapspeed

Definition at line 3213 of file ai.c.

◆ aiL_hasafterburner()

int aiL_hasafterburner ( lua_State * L)
static

Does the pilot have afterburners?

Lua return parameter: boolean True if the pilot has afterburners.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hasafterburners

Definition at line 3106 of file ai.c.

◆ aiL_hascannons()

int aiL_hascannons ( lua_State * L)
static

Does the pilot have cannons?

Lua return parameter: boolean True if the pilot has cannons.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hascannons

Definition at line 3070 of file ai.c.

◆ aiL_hasfighterbays()

int aiL_hasfighterbays ( lua_State * L)
static

Does the pilot have fighter bays?

Lua return parameter: boolean True if the pilot has fighter bays.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hasfighterbays

Definition at line 3094 of file ai.c.

◆ aiL_haslockon()

int aiL_haslockon ( lua_State * L)
static

Checks to see if pilot has a missile lockon.

Lua return parameter: boolean Whether the pilot has a missile lockon.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: haslockon

Definition at line 1761 of file ai.c.

◆ aiL_hasprojectile()

int aiL_hasprojectile ( lua_State * L)
static

Checks to see if pilot has a projectile after him.

Lua return parameter: boolean Whether the pilot has a projectile after him.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hasprojectile

Definition at line 1774 of file ai.c.

◆ aiL_hasturrets()

int aiL_hasturrets ( lua_State * L)
static

Does the pilot have turrets?

Lua return parameter: boolean True if the pilot has turrets.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hasturrets

Definition at line 3082 of file ai.c.

◆ aiL_hostile()

int aiL_hostile ( lua_State * L)
static

Sets the enemy hostile (basically notifies of an impending attack).

Lua function parameter: Pilot target Pilot to set hostile.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hostile

Definition at line 3167 of file ai.c.

◆ aiL_hyperspace()

int aiL_hyperspace ( lua_State * L)
static

Tries to enter hyperspace.

Lua function parameter:[opt] System sys System to jump to Lua return parameter: number|nil Distance if too far away.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hyperspace

Definition at line 2562 of file ai.c.

◆ aiL_hyperspaceAbort()

int aiL_hyperspaceAbort ( lua_State * L)
static

Has the AI abandon hyperspace if applicable.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: hyperspaceAbort

Definition at line 2758 of file ai.c.

◆ aiL_idir()

int aiL_idir ( lua_State * L)
static

Calculates angle between pilot facing and intercept-course to target.

Lua function parameter: Pilot|Vec2 target Position or pilot to compare facing to Lua return parameter: number The facing offset to intercept-course to the target (in radians).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: idir

Definition at line 2172 of file ai.c.

◆ aiL_iface()

int aiL_iface ( lua_State * L)
static

Maintains an intercept pursuit course.

Lua function parameter: Pilot|Vec2 target Position or pilot to intercept. Lua return parameter: number The offset from the proper intercept course (in radians).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: iface

Definition at line 2056 of file ai.c.

◆ aiL_instantJump()

int aiL_instantJump ( lua_State * L)
static

Checks to see if pilot can instant jump.

Lua return parameter: boolean Whether the pilot can instant jump.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: instantJump

Definition at line 1675 of file ai.c.

◆ aiL_isally()

int aiL_isally ( lua_State * L)
static

Checks to see if target is an ally.

Lua function parameter: Pilot target Lua return parameter: boolean Whether the target is an ally.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: isally

Definition at line 1739 of file ai.c.

◆ aiL_isbribed()

int aiL_isbribed ( lua_State * L)
static

Checks to see if target has bribed pilot.

Lua function parameter: Pilot target Lua return parameter: boolean Whether the target has bribed pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: isbribed

Definition at line 1661 of file ai.c.

◆ aiL_isenemy()

int aiL_isenemy ( lua_State * L)
static

Checks to see if target is an enemy.

Lua function parameter: Pilot target Lua return parameter: boolean Whether the target is an enemy.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: isenemy

Definition at line 1717 of file ai.c.

◆ aiL_ismaxvel()

int aiL_ismaxvel ( lua_State * L)
static

Checks to see if pilot is at maximum velocity.

Lua return parameter: boolean Whether the pilot is at maximum velocity.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: ismaxvel

Definition at line 1687 of file ai.c.

◆ aiL_isstopped()

int aiL_isstopped ( lua_State * L)
static

Checks to see if pilot is stopped.

Lua return parameter: boolean Whether the pilot is stopped.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: isstopped

Definition at line 1704 of file ai.c.

◆ aiL_land()

int aiL_land ( lua_State * L)
static

Lands on a spob.

Lua function parameter:[opt] Spob pnt spob to land on Lua return parameter: boolean Whether landing was successful.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: land

Definition at line 2472 of file ai.c.

◆ aiL_messages()

int aiL_messages ( lua_State * L)
static

Returns and clears the pilots message queue.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: messages Lua return parameter: {{},...} Messages.

Definition at line 3445 of file ai.c.

◆ aiL_minbrakedist()

int aiL_minbrakedist ( lua_State * L)
static

Gets the minimum braking distance.

braking vel ==> 0 = v - a*dt add turn around time (to initial vel) ==> 180.*360./cur_pilot->turn add it to general euler equation x = v * t + 0.5 * a * t^2 and voila!

I hate this function and it'll probably need to get changed in the future

Lua function parameter: number vel Velocity of target. Lua return parameter: number Minimum braking distance. Lua return parameter: number Time it will take to brake.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: minbrakedist

Definition at line 1621 of file ai.c.

◆ aiL_nearhyptarget()

int aiL_nearhyptarget ( lua_State * L)
static

Gets the nearest hyperspace target.

Lua return parameter: JumpPoint|nil

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: nearhyptarget

Definition at line 2623 of file ai.c.

◆ aiL_outfitOffAll()

int aiL_outfitOffAll ( lua_State * L)
static

Tries to turn off all outfits.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: outfitOffAll

Definition at line 3482 of file ai.c.

◆ aiL_pilot()

int aiL_pilot ( lua_State * L)
static

Gets the AI's pilot. Lua return parameter: Pilot The AI's pilot.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: pilot

Returns
Number of Lua parameters.

Definition at line 1452 of file ai.c.

◆ aiL_popsubtask()

int aiL_popsubtask ( lua_State * L)
static

Pops the current running task.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: popsubtask

Returns
Number of Lua parameters.

Definition at line 1389 of file ai.c.

◆ aiL_poptask()

int aiL_poptask ( lua_State * L)
static

Pops the current running task.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: poptask

Returns
Number of Lua parameters.

Definition at line 1325 of file ai.c.

◆ aiL_pushsubtask()

int aiL_pushsubtask ( lua_State * L)
static

Pushes a subtask onto the pilot's task's subtask list. Lua function parameter: string func Name of function to call for task. Lua function parameter:[opt] data Data to pass to the function. Supports any lua type.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: pushsubtask

Returns
Number of Lua parameters.

Definition at line 1378 of file ai.c.

◆ aiL_pushtask()

int aiL_pushtask ( lua_State * L)
static

Pushes a task onto the pilot's task list. Lua function parameter: string func Name of function to call for task. Lua function parameter:[opt] data Data to pass to the function. Supports any lua type.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: pushtask

Returns
Number of Lua parameters.

Definition at line 1314 of file ai.c.

◆ aiL_refuel()

int aiL_refuel ( lua_State * L)
static

Attempts to refuel the pilot's target.

Lua return parameter: boolean true if pilot has begun refueling, false if it hasn't.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: refuel

Definition at line 3320 of file ai.c.

◆ aiL_reldps()

int aiL_reldps ( lua_State * L)
static

Gets the relative damage output (total DPS) between the current pilot and the specified target.

Lua function parameter: Pilot target The pilot whose DPS we will compare. Lua return parameter: number A number from 0 to 1 mapping the relative DPSes.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: reldps

Definition at line 3280 of file ai.c.

◆ aiL_relhp()

int aiL_relhp ( lua_State * L)
static

Gets the relative health (total shields and armour) between the current pilot and the specified target.

Lua function parameter: Pilot target The pilot whose health we will compare. Lua return parameter: number A number from 0 to 1 mapping the relative healths.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: relhp

Definition at line 3295 of file ai.c.

◆ aiL_relsize()

int aiL_relsize ( lua_State * L)
static

Gets the relative size (ship mass) between the current pilot and the specified target.

Lua function parameter: Pilot target The pilot whose mass we will compare. Lua return parameter: number A number from 0 to 1 mapping the relative masses.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: relsize

Definition at line 3265 of file ai.c.

◆ aiL_relvel()

int aiL_relvel ( lua_State * L)
static

Gets the relative velocity of a pilot.

Lua return parameter: number Relative velocity.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: relvel

Definition at line 2771 of file ai.c.

◆ aiL_rndhyptarget()

int aiL_rndhyptarget ( lua_State * L)
static

Gets a random hyperspace target.

Lua return parameter: JumpPoint|nil

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: rndhyptarget

Definition at line 2673 of file ai.c.

◆ aiL_scandone()

int aiL_scandone ( lua_State * L)
static

Checks to see if pilot has finished scanning their target.

Lua return parameter: boolean Whether the pilot has scanned their target.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: scandone

Definition at line 1787 of file ai.c.

◆ aiL_set_shoot_indicator()

int aiL_set_shoot_indicator ( lua_State * L)
static

Set the seeker shoot indicator.

Lua function parameter: boolean value to set the shoot indicator to.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: set_shoot_indicator

Definition at line 3362 of file ai.c.

◆ aiL_setasterotarget()

int aiL_setasterotarget ( lua_State * L)
static

Sets the pilot's asteroid target.

Lua function parameter: int field Id of the field to target. Lua function parameter: int ast Id of the asteroid to target.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: setasterotarget

Definition at line 2970 of file ai.c.

◆ aiL_sethyptarget()

int aiL_sethyptarget ( lua_State * L)
static

Sets hyperspace target.

Lua function parameter: Jump target Hyperspace target Lua return parameter: Vec2 Where to go to jump

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: sethyptarget

Definition at line 2587 of file ai.c.

◆ aiL_settarget()

int aiL_settarget ( lua_State * L)
static

Sets the pilot's target.

Lua function parameter: target Pilot to target.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: settarget

Definition at line 2956 of file ai.c.

◆ aiL_settimer()

int aiL_settimer ( lua_State * L)
static

Sets a timer.

Lua function parameter: number timer Timer number. Lua function parameter:[opt=0] number time Number of seconds to set timer to.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: settimer

Definition at line 3333 of file ai.c.

◆ aiL_shoot_indicator()

int aiL_shoot_indicator ( lua_State * L)
static

Access the seeker shoot indicator (that is put to true each time a seeker is shot).

Lua return parameter: boolean true if the shoot_indicator is true.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: set_shoot_indicator

Definition at line 3375 of file ai.c.

◆ aiL_stealth()

int aiL_stealth ( lua_State * L)
static

Tries to stealth or destealth the pilot.

Lua function parameter:[opt=true] boolean enable Whether or not to try to stealth the pilot. Lua return parameter: boolean Whether or not the stealthing or destealthing succeeded.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: stealth

Definition at line 3462 of file ai.c.

◆ aiL_stop()

int aiL_stop ( lua_State * L)
static

Completely stops the pilot if it is below minimum vel error (no insta-stops).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: stop

Definition at line 2906 of file ai.c.

◆ aiL_subtaskdata()

int aiL_subtaskdata ( lua_State * L)
static

Gets the pilot's subtask target. Lua return parameter: The pilot's target ship identifier or nil if no target. See also: pushsubtask.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: subtaskdata

Returns
Number of Lua parameters.

Definition at line 1436 of file ai.c.

◆ aiL_subtaskname()

int aiL_subtaskname ( lua_State * L)
static

Gets the current subtask's name. Lua return parameter: string The current subtask name or nil if there are no subtasks.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: subtaskname

Returns
Number of Lua parameters.

Definition at line 1419 of file ai.c.

◆ aiL_taskdata()

int aiL_taskdata ( lua_State * L)
static

Gets the pilot's task data. Lua return parameter: The pilot's task data or nil if there is no task data. See also: pushtask.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: taskdata

Returns
Number of Lua parameters.

Definition at line 1362 of file ai.c.

◆ aiL_taskname()

int aiL_taskname ( lua_State * L)
static

Gets the current task's name. Lua return parameter: string The current task name or nil if there are no tasks.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: taskname

Returns
Number of Lua parameters.

Definition at line 1346 of file ai.c.

◆ aiL_timeup()

int aiL_timeup ( lua_State * L)
static

Checks a timer.

Lua function parameter: number timer Timer number. Lua return parameter: boolean Whether time is up.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: timeup

Definition at line 3349 of file ai.c.

◆ aiL_turn()

int aiL_turn ( lua_State * L)
static

Starts turning the pilot.

Lua function parameter: number vel Directional velocity from -1 to 1.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: turn

Definition at line 1815 of file ai.c.

◆ aiL_weapSet()

int aiL_weapSet ( lua_State * L)
static

Sets the active weapon set, fires another weapon set or activate an outfit.

Lua function parameter: number id ID of the weapon set to switch to or fire. Lua function parameter:[opt=true] boolean type true to activate, false to deactivate.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: weapset

Definition at line 3046 of file ai.c.