naev 0.10.4
Functions
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. More...
 
static int aiL_poptask (lua_State *L)
 Pops the current running task. More...
 
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. More...
 
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. More...
 
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. More...
 
static int aiL_popsubtask (lua_State *L)
 Pops the current running task. More...
 
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. More...
 
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. More...
 
static int aiL_pilot (lua_State *L)
 Gets the AI's pilot. Lua return parameter: Pilot The AI's pilot. More...
 
static int aiL_getrndpilot (lua_State *L)
 Gets a random pilot in the system. Lua return parameter: Pilot|nil. More...
 
static int aiL_getnearestpilot (lua_State *L)
 gets the nearest pilot to the current pilot More...
 
static int aiL_getdistance (lua_State *L)
 Gets the distance from the pointer. More...
 
static int aiL_getdistance2 (lua_State *L)
 Gets the squared distance from the pointer. More...
 
static int aiL_getflybydistance (lua_State *L)
 Gets the distance from the pointer perpendicular to the current pilot's flight vector. More...
 
static int aiL_minbrakedist (lua_State *L)
 Gets the minimum braking distance. More...
 
static int aiL_isbribed (lua_State *L)
 Checks to see if target has bribed pilot. More...
 
static int aiL_instantJump (lua_State *L)
 Checks to see if pilot can instant jump. More...
 
static int aiL_ismaxvel (lua_State *L)
 Checks to see if pilot is at maximum velocity. More...
 
static int aiL_isstopped (lua_State *L)
 Checks to see if pilot is stopped. More...
 
static int aiL_isenemy (lua_State *L)
 Checks to see if target is an enemy. More...
 
static int aiL_isally (lua_State *L)
 Checks to see if target is an ally. More...
 
static int aiL_haslockon (lua_State *L)
 Checks to see if pilot has a missile lockon. More...
 
static int aiL_hasprojectile (lua_State *L)
 Checks to see if pilot has a projectile after him. More...
 
static int aiL_scandone (lua_State *L)
 Checks to see if pilot has finished scanning their target. More...
 
static int aiL_accel (lua_State *L)
 Starts accelerating the pilot. More...
 
static int aiL_turn (lua_State *L)
 Starts turning the pilot. More...
 
static int aiL_face (lua_State *L)
 Faces the target. More...
 
static int aiL_careful_face (lua_State *L)
 Gives the direction to follow in order to reach the target while minimizating risk. More...
 
static int aiL_aim (lua_State *L)
 Aims at a pilot, trying to hit it rather than move to it. More...
 
static int aiL_iface (lua_State *L)
 Maintains an intercept pursuit course. More...
 
static int aiL_dir (lua_State *L)
 calculates the direction that the target is relative to the current pilot facing. More...
 
static int aiL_idir (lua_State *L)
 calculates angle between pilot facing and intercept-course to target. More...
 
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. More...
 
static int aiL_brake (lua_State *L)
 Brakes the pilot. More...
 
static int aiL_getnearestspob (lua_State *L)
 Get the nearest friendly spob to the pilot. More...
 
static int aiL_getspobfrompos (lua_State *L)
 Get the nearest friendly spob to a given position. More...
 
static int aiL_getrndspob (lua_State *L)
 Get a random spob. More...
 
static int aiL_getlandspob (lua_State *L)
 Get a random friendly spob. More...
 
static int aiL_land (lua_State *L)
 Lands on a spob. More...
 
static int aiL_hyperspace (lua_State *L)
 Tries to enter hyperspace. More...
 
static int aiL_sethyptarget (lua_State *L)
 Sets hyperspace target. More...
 
static int aiL_nearhyptarget (lua_State *L)
 Gets the nearest hyperspace target. More...
 
static int aiL_rndhyptarget (lua_State *L)
 Gets a random hyperspace target. More...
 
static int aiL_relvel (lua_State *L)
 Gets the relative velocity of a pilot. More...
 
static int aiL_follow_accurate (lua_State *L)
 Computes the point to face in order to follow another pilot using a PD controller. More...
 
static int aiL_face_accurate (lua_State *L)
 Computes the point to face in order to follow a moving object. More...
 
static int aiL_stop (lua_State *L)
 Completely stops the pilot if it is below minimum vel error (no insta-stops). More...
 
static int aiL_dock (lua_State *L)
 Docks the ship. More...
 
static int aiL_combat (lua_State *L)
 Sets the combat flag. More...
 
static int aiL_settarget (lua_State *L)
 Sets the pilot's target. More...
 
static int aiL_setasterotarget (lua_State *L)
 Sets the pilot's asteroid target. More...
 
static int aiL_getGatherable (lua_State *L)
 Gets the closest gatherable within a radius. More...
 
static int aiL_gatherablePos (lua_State *L)
 Gets the pos and vel of a given gatherable. More...
 
static int aiL_weapSet (lua_State *L)
 Sets the active weapon set, fires another weapon set or activate an outfit. More...
 
static int aiL_hascannons (lua_State *L)
 Does the pilot have cannons? More...
 
static int aiL_hasturrets (lua_State *L)
 Does the pilot have turrets? More...
 
static int aiL_hasfighterbays (lua_State *L)
 Does the pilot have fighter bays? More...
 
static int aiL_hasafterburner (lua_State *L)
 Does the pilot have afterburners? More...
 
static int aiL_shoot (lua_State *L)
 Makes the pilot shoot. More...
 
static int aiL_getenemy (lua_State *L)
 Gets the nearest enemy. More...
 
static int aiL_getenemy_size (lua_State *L)
 Gets the nearest enemy within specified size bounds. More...
 
static int aiL_getenemy_heuristic (lua_State *L)
 Gets the nearest enemy within specified heuristic. More...
 
static int aiL_hostile (lua_State *L)
 Sets the enemy hostile (basically notifies of an impending attack). More...
 
static int aiL_getweaprange (lua_State *L)
 Gets the range of a weapon. More...
 
static int aiL_getweapspeed (lua_State *L)
 Gets the speed of a weapon. More...
 
static int aiL_getweapammo (lua_State *L)
 Gets the ammo of a weapon. More...
 
static int aiL_canboard (lua_State *L)
 Checks to see if pilot can board the target. More...
 
static int aiL_relsize (lua_State *L)
 Gets the relative size (ship mass) between the current pilot and the specified target. More...
 
static int aiL_reldps (lua_State *L)
 Gets the relative damage output (total DPS) between the current pilot and the specified target. More...
 
static int aiL_relhp (lua_State *L)
 Gets the relative health (total shields and armour) between the current pilot and the specified target. More...
 
static int aiL_board (lua_State *L)
 Attempts to board the pilot's target. More...
 
static int aiL_refuel (lua_State *L)
 Attempts to refuel the pilot's target. More...
 
static int aiL_settimer (lua_State *L)
 Sets a timer. More...
 
static int aiL_timeup (lua_State *L)
 Checks a timer. More...
 
static int aiL_set_shoot_indicator (lua_State *L)
 Set the seeker shoot indicator. More...
 
static int aiL_shoot_indicator (lua_State *L)
 Access the seeker shoot indicator (that is put to true each time a seeker is shot). More...
 
static int aiL_distress (lua_State *L)
 Sends a distress signal. More...
 
static int aiL_getBoss (lua_State *L)
 Picks a pilot that will command the current pilot. More...
 
static int aiL_credits (lua_State *L)
 Sets the pilots credits. Only call in create(). More...
 
static int aiL_messages (lua_State *L)
 Returns and clears the pilots message queue. More...
 
static int aiL_stealth (lua_State *L)
 Tries to stealth or destealth the pilot. More...
 

Detailed Description

Handles how the AI interacts with the universe.

Usage is:

ai.function( params )

Function Documentation

◆ aiL_accel()

static 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 1665 of file ai.c.

◆ aiL_aim()

static 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 1876 of file ai.c.

◆ aiL_board()

static 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 3167 of file ai.c.

◆ aiL_brake()

static int aiL_brake ( lua_State *  L)
static

Brakes the pilot.

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 2117 of file ai.c.

◆ aiL_canboard()

static 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 3104 of file ai.c.

◆ aiL_careful_face()

static 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 1787 of file ai.c.

◆ aiL_combat()

static 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 2731 of file ai.c.

◆ aiL_credits()

static 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 3286 of file ai.c.

◆ aiL_dir()

static 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 1993 of file ai.c.

◆ aiL_distress()

static 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 3245 of file ai.c.

◆ aiL_dock()

static 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 2717 of file ai.c.

◆ aiL_drift_facing()

static 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 2104 of file ai.c.

◆ aiL_face()

static 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. 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 Angle offset in radians.

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

Lua function: face

Definition at line 1697 of file ai.c.

◆ aiL_face_accurate()

static 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: number radius The requested distance between p and target Lua function parameter: number angle The requested angle between p and target (radians) Lua function parameter: number Kp The first controller parameter Lua function parameter: 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 2666 of file ai.c.

◆ aiL_follow_accurate()

static 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: number radius The requested distance between p and target Lua function parameter: number angle The requested angle between p and target (radians) Lua function parameter: number Kp The first controller parameter Lua function parameter: 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 2607 of file ai.c.

◆ aiL_gatherablePos()

static 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 2816 of file ai.c.

◆ aiL_getBoss()

static 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 3266 of file ai.c.

◆ aiL_getdistance()

static 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 1391 of file ai.c.

◆ aiL_getdistance2()

static 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 1418 of file ai.c.

◆ aiL_getenemy()

static int aiL_getenemy ( lua_State *  L)
static

Gets 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 2960 of file ai.c.

◆ aiL_getenemy_heuristic()

static int aiL_getenemy_heuristic ( lua_State *  L)
static

Gets the nearest enemy within specified heuristic.

Lua function parameter: number mass goal mass map (0-1) Lua function parameter: number dps goal DPS map (0-1) Lua function parameter: number hp goal HP map (0-1) Lua function parameter: number range weighting for range (typically > 1) Lua return parameter: Pilot the best fitting target

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

Lua function: getenemy_heuristic

Definition at line 3016 of file ai.c.

◆ aiL_getenemy_size()

static int aiL_getenemy_size ( lua_State *  L)
static

Gets the nearest enemy within specified size bounds.

Lua function parameter: number lb Lower size bound Lua function parameter: number ub upper size bound Lua return parameter: Pilot

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

Lua function: getenemy_size

Definition at line 2982 of file ai.c.

◆ aiL_getflybydistance()

static 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 1445 of file ai.c.

◆ aiL_getGatherable()

static 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 2788 of file ai.c.

◆ aiL_getlandspob()

static 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 2232 of file ai.c.

◆ aiL_getnearestpilot()

static 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 1357 of file ai.c.

◆ aiL_getnearestspob()

static 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 2134 of file ai.c.

◆ aiL_getrndpilot()

static 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 1333 of file ai.c.

◆ aiL_getrndspob()

static 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 2206 of file ai.c.

◆ aiL_getspobfrompos()

static 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 2169 of file ai.c.

◆ aiL_getweapammo()

static 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 function parameter:[opt=-1] number level Level of weapon set to get range of. 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 3089 of file ai.c.

◆ aiL_getweaprange()

static int aiL_getweaprange ( lua_State *  L)
static

Gets the range of a weapon.

Lua function parameter:[opt] number id Optional parameter indicating id of weapon set to get range of, defaults to selected one. Lua function parameter:[opt=-1] number level Level of weapon set to get range of. 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 3057 of file ai.c.

◆ aiL_getweapspeed()

static 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 function parameter:[opt=-1] number level Level of weapon set to get range of. 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 3073 of file ai.c.

◆ aiL_hasafterburner()

static 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 2928 of file ai.c.

◆ aiL_hascannons()

static 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 2892 of file ai.c.

◆ aiL_hasfighterbays()

static 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 2916 of file ai.c.

◆ aiL_haslockon()

static 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 1627 of file ai.c.

◆ aiL_hasprojectile()

static 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 1640 of file ai.c.

◆ aiL_hasturrets()

static 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 2904 of file ai.c.

◆ aiL_hostile()

static 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 3039 of file ai.c.

◆ aiL_hyperspace()

static 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 2384 of file ai.c.

◆ aiL_idir()

static 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 2035 of file ai.c.

◆ aiL_iface()

static 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 1905 of file ai.c.

◆ aiL_instantJump()

static 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 1544 of file ai.c.

◆ aiL_isally()

static 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 1605 of file ai.c.

◆ aiL_isbribed()

static 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 1531 of file ai.c.

◆ aiL_isenemy()

static 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 1583 of file ai.c.

◆ aiL_ismaxvel()

static 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 1556 of file ai.c.

◆ aiL_isstopped()

static 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 1570 of file ai.c.

◆ aiL_land()

static 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 2293 of file ai.c.

◆ aiL_messages()

static 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 3304 of file ai.c.

◆ aiL_minbrakedist()

static 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 return parameter: number Minimum braking distance.

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

Lua function: minbrakedist

Definition at line 1485 of file ai.c.

◆ aiL_nearhyptarget()

static 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 2451 of file ai.c.

◆ aiL_pilot()

static 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 1321 of file ai.c.

◆ aiL_popsubtask()

static 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 1259 of file ai.c.

◆ aiL_poptask()

static 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 1195 of file ai.c.

◆ aiL_pushsubtask()

static 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 1248 of file ai.c.

◆ aiL_pushtask()

static 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 1185 of file ai.c.

◆ aiL_refuel()

static 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 3179 of file ai.c.

◆ aiL_reldps()

static 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 3140 of file ai.c.

◆ aiL_relhp()

static 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 3154 of file ai.c.

◆ aiL_relsize()

static 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 3126 of file ai.c.

◆ aiL_relvel()

static 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 2566 of file ai.c.

◆ aiL_rndhyptarget()

static 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 2495 of file ai.c.

◆ aiL_scandone()

static 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 1653 of file ai.c.

◆ aiL_set_shoot_indicator()

static 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 3221 of file ai.c.

◆ aiL_setasterotarget()

static 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 2766 of file ai.c.

◆ aiL_sethyptarget()

static 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 2415 of file ai.c.

◆ aiL_settarget()

static 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 2752 of file ai.c.

◆ aiL_settimer()

static 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 3192 of file ai.c.

◆ aiL_shoot()

static int aiL_shoot ( lua_State *  L)
static

Makes the pilot shoot.

Lua function parameter:[opt=false] boolean secondary Fire secondary weapons instead of primary.

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

Lua function: shoot

Definition at line 2940 of file ai.c.

◆ aiL_shoot_indicator()

static 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 3233 of file ai.c.

◆ aiL_stealth()

static 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 3319 of file ai.c.

◆ aiL_stop()

static 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 2701 of file ai.c.

◆ aiL_subtaskdata()

static 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 1305 of file ai.c.

◆ aiL_subtaskname()

static 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 1288 of file ai.c.

◆ aiL_taskdata()

static 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 1230 of file ai.c.

◆ aiL_taskname()

static 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 1213 of file ai.c.

◆ aiL_timeup()

static 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 3208 of file ai.c.

◆ aiL_turn()

static 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 1678 of file ai.c.

◆ aiL_weapSet()

static 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 2841 of file ai.c.