![]() |
naev 0.12.5
|
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. | |
Handles how the AI interacts with the universe.
Usage is:
|
static |
|
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).
| L | Lua State |
Lua function: aim
|
static |
|
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.
| L | Lua State |
Lua function: brake
|
static |
|
static |
|
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.
| L | Lua State |
Lua function: careful_face
|
static |
|
static |
|
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).
| L | Lua State |
Lua function: dir
|
static |
|
static |
|
static |
|
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.
| L | Lua State |
Lua function: face
|
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.
| L | Lua State |
Lua function: face_accurate
|
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.
| L | Lua State |
Lua function: follow_accurate
|
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.
| L | Lua State |
Lua function: gatherablepos
|
static |
|
static |
|
static |
|
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
| L | Lua State |
Lua function: getenemy
|
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
| L | Lua State |
Lua function: flyby_dist
|
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.
| L | Lua State |
Lua function: getgatherable
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
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.
| L | Lua State |
Lua function: getweapammo
|
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.
| L | Lua State |
Lua function: getweaprange
|
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.
| L | Lua State |
Lua function: getweaprangemin
|
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.
| L | Lua State |
Lua function: getweapspeed
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
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).
| L | Lua State |
Lua function: idir
|
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).
| L | Lua State |
Lua function: iface
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
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.
| L | Lua State |
Lua function: minbrakedist
|
static |
|
static |
|
static |
|
static |
|
static |
|
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.
| L | Lua State |
Lua function: pushsubtask
|
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.
| L | Lua State |
Lua function: pushtask
|
static |
|
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.
| L | Lua State |
Lua function: reldps
|
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.
| L | Lua State |
Lua function: relhp
|
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.
| L | Lua State |
Lua function: relsize
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
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.
| L | Lua State |
Lua function: stealth
|
static |
|
static |
Gets the pilot's subtask target. Lua return parameter: The pilot's target ship identifier or nil if no target. See also: pushsubtask.
| L | Lua State |
Lua function: subtaskdata
|
static |
|
static |
|
static |
|
static |
|
static |
|
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.
| L | Lua State |
Lua function: weapset