Naev

Module escort

Library for dealing with escorts in missions.

Can be used either to provide the player with a few perishable escorts, or provide a set of escorts the player has to follow and guard to the destination.

Below is a simple example of a convoy that the player has to protect while it goes on to some spob. ``` -- This is an example of using the API to provide a fleet the player has to -- guard starting from the start_convoy function that sets it up -- The mission will automatically fail if all the escorts die function start_convoy () -- Initialize the library with the pilots the player has to escort escort.init( {"Koala", "Llama"}, {faction=faction.get("Independent")} ) -- Set the destination target, the escorts will try to go there automagically escort.setDest( spob.get("Darkshed"), "convoy success" ) end -- This function will be run when the player lands on the destination function convoy_success () local alive = escort.num_alive() -- Do something based on the number of escorts that are alive do_something( alive ) -- Cleans up the library escort.exit() end ```

Below is a more complex example where the player becomes the leader and the escorts follow and protect the player. ``` -- Initialize the library and give the player two escorts that will guard them / help them out function start_convoy () escort.init( {"Lancelot", "Lancelot"}, {faction=faction.get("Mercenary"), nofailifdead=true, func_pilot_death="escort_died"} ) end -- The escort died function escort_died( _p ) if escort.num_alive() <= 0 then -- All the escorts are dead end end ```

Functions

init (ships[, params]) Initializes the library by setting all the necessary hooks.
exit () Cleans up the escort framework when done, eliminating all hooks.
num_alive () Gets the number of escorts that are still alive.
pilots () Gets the list of pilots.
setDest (dest, success[, failure]) Sets the destination of the escort convoy.
setFollow () Disables the escorts destination target and makes them follow the player.
spawn (pos) Spawns the escorts at location.


Functions

init (ships[, params])
Initializes the library by setting all the necessary hooks.

Parameters:

  • ships table List of ships to add.
  • params table List of optional parameters. (optional)
exit ()
Cleans up the escort framework when done, eliminating all hooks.
num_alive ()
Gets the number of escorts that are still alive.

Returns:

    number Number of escorts still alive.
pilots ()
Gets the list of pilots.

Returns:

    table Table containing the existing pilots. The first will be the leader.
setDest (dest, success[, failure])
Sets the destination of the escort convoy.

Disables the escorts from following the player.

Parameters:

  • dest system or spob Destination of the escorts.
  • success string Name of the global function to call on success.
  • failure string Name of the global function to call on failure. Default will give a vntk message and fail the mission. (optional)
setFollow ()
Disables the escorts destination target and makes them follow the player.
spawn (pos)
Spawns the escorts at location. This can be useful at the beginning if you want them to jump in or take of while in space. It is handled automatically when the player takes off or jumps into a system.

Parameters:

  • pos Vector, Spob or System Position to spawn the fleet at. The argument is directly passed to pilot.add.

Returns:

    table Table of newly created pilots.
generated by LDoc 1.5.0 Last updated 2024-04-18 17:19:01