17#include "nlua_pilot.h"
38 unsigned int id,
int persist )
41 if ( p->escorts == NULL )
72 array_erase( &p->escorts, &p->escorts[i], &p->escorts[i + 1] );
84 for (
int i = 0; i <
array_size( p->escorts ); i++ ) {
85 if ( p->escorts[i].id ==
id ) {
106 const vec2 *vel,
double dir, EscortType_t type,
107 int add,
int dockslot )
117 pilot_clearFlagsRaw( f );
119 if ( p->faction == FACTION_PLAYER ) {
120 pilot_setFlagRaw( f, PILOT_PERSIST );
121 pilot_setFlagRaw( f, PILOT_NOCLEAR );
123 if ( type == ESCORT_TYPE_BAY )
124 pilot_setFlagRaw( f, PILOT_CARRIED );
132 if ( pe->
parent == PLAYER_ID )
133 pilot_setFlag( pe, PILOT_INVINC_PLAYER );
136 if ( pilot_isFlag( p, PILOT_HOSTILE ) )
137 pilot_setFlag( pe, PILOT_HOSTILE );
138 if ( pilot_isFlag( p, PILOT_FRIENDLY ) )
139 pilot_setFlag( pe, PILOT_FRIENDLY );
142 if ( pilot_isFlagRaw( f, PILOT_CARRIED ) ) {
144 if ( p->stats.fbay_damage != 1. ) {
156 if ( p->stats.fbay_health != 1. ) {
165 if ( p->stats.fbay_movement != 1. ) {
201 const vec2 *vel,
double dir, EscortType_t type,
202 int add,
int dockslot )
212 if ( pe->
parent == PLAYER_ID )
213 pilot_setFlag( pe, PILOT_INVINC_PLAYER );
223 if ( p->faction == FACTION_PLAYER ) {
224 pilot_setFlag( pe, PILOT_PERSIST );
225 pilot_setFlag( pe, PILOT_NOCLEAR );
227 if ( pilot_isFlag( p, PILOT_HOSTILE ) )
228 pilot_setFlag( pe, PILOT_HOSTILE );
229 if ( pilot_isFlag( p, PILOT_FRIENDLY ) )
230 pilot_setFlag( pe, PILOT_FRIENDLY );
247 for (
int j =
array_size( p->escorts ) - 1; j >= 0; j-- ) {
252 if ( e->
type != ESCORT_TYPE_BAY )
260 if ( ( slot >= 0 ) && ( slot != pe->
dockslot ) )
264 memcpy( &pe->
solid.
pos, &p->solid.pos,
sizeof(
vec2 ) );
265 memcpy( &pe->
solid.
vel, &p->solid.vel,
sizeof(
vec2 ) );
266 if ( pilot_dock( pe, p ) )
267 WARN( _(
"Pilot '%s' has escort '%s' docking error!" ), p->name,
319 if ( parent->
target != parent->
id ) {
324 if ( ( ret == 0 ) && ( parent ==
player.p ) ) {
329 pltname = _(
"Unknown" );
331 if ( pilot_isFlag( t, PILOT_DISABLED ) )
347 if ( ( ret == 0 ) && ( parent ==
player.p ) )
360 if ( ( ret == 0 ) && ( parent ==
player.p ) )
373 if ( ( ret == 0 ) && ( parent ==
player.p ) )
386 const char *title, *caption;
392 const char *opts[] = { _(
"Hold Formation" ), _(
"Return To Ship" ),
393 _(
"Clear Orders" ), _(
"Cancel" ) };
400 title = _(
"Escort Orders" );
401 caption = _(
"Select the order to give to this escort." );
404 for (
int i = 0; i < nopts; i++ )
408 if ( choice != NULL ) {
409 if ( strcmp( choice, opts[0] ) == 0 ) {
412 }
else if ( strcmp( choice, opts[1] ) == 0 ) {
415 }
else if ( strcmp( choice, opts[2] ) == 0 ) {
442 if ( ( ret == 0 ) && ( parent ==
player.p ) )
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_erase(ptr_array, first, last)
Erases elements in interval [first, last).
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
#define array_grow(ptr_array)
Increases the number of elements by one and returns the last element.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
char * dialogue_runChoice(void)
Run the dialog and return the clicked string.
void dialogue_addChoice(const char *caption, const char *msg, const char *opt)
Add a choice to the dialog.
void dialogue_makeChoice(const char *caption, const char *msg, int opts)
Create the choice dialog. Need to add choices with below method.
void escort_rmList(Pilot *p, unsigned int id)
Remove from escorts list.
int escorts_hold(const Pilot *parent)
Have a pilot order its escorts to hold position.
static int escort_command(const Pilot *parent, const char *cmd, unsigned int index)
Runs an escort command on all of a pilot's escorts.
void escort_freeList(Pilot *p)
Remove all escorts from a pilot.
int escort_clearDeployed(Pilot *p, int slot)
Clears deployed escorts of a pilot.
unsigned int escort_create(Pilot *p, const Ship *ship, const vec2 *pos, const vec2 *vel, double dir, EscortType_t type, int add, int dockslot)
Creates an escort.
unsigned int escort_createRef(Pilot *p, Pilot *pe, const vec2 *pos, const vec2 *vel, double dir, EscortType_t type, int add, int dockslot)
Creates an escort from a reference.
int escort_addList(Pilot *p, const Ship *ship, EscortType_t type, unsigned int id, int persist)
Adds an escort to the escort list of a pilot.
int escorts_return(const Pilot *parent)
Have a pilot order its escorts to dock.
void escort_rmListIndex(Pilot *p, int i)
Remove from escorts list.
int escort_playerCommand(const Pilot *e)
Open a dialog for the player to issue a command to an escort.
int escorts_attack(Pilot *parent)
Have a pilot order its escorts to attack its target.
int escorts_jump(const Pilot *parent, const JumpPoint *jp)
Have a pilot order its escorts to jump.
int escorts_clear(const Pilot *parent)
Have a pilot order its escorts to clear orders.
void player_message(const char *fmt,...)
Adds a mesg to the queue to be displayed on screen.
LuaJump * lua_pushjump(lua_State *L, LuaJump jump)
Pushes a jump on the stack.
LuaPilot * lua_pushpilot(lua_State *L, LuaPilot pilot)
Pushes a pilot on the stack.
unsigned int pilot_addStack(Pilot *p)
Adds a pilot to the stack.
Pilot * pilot_getTarget(Pilot *p)
Gets the target of a pilot using a fancy caching system.
void pilot_msg(const Pilot *p, const Pilot *receiver, const char *type, unsigned int idx)
Sends a message.
void pilot_reset(Pilot *pilot)
Resets a pilot.
Pilot * pilot_get(unsigned int id)
Pulls a pilot out of the pilot_stack based on ID.
Pilot * pilot_create(const Ship *ship, const char *name, int faction, const char *ai, const double dir, const vec2 *pos, const vec2 *vel, const PilotFlags flags, unsigned int dockpilot, int dockslot)
Creates a new pilot.
int pilot_inRangePilot(const Pilot *p, const Pilot *target, double *dist2)
Check to see if a pilot is in sensor range of another.
void pilot_calcStats(Pilot *pilot)
Recalculates the pilot's stats based on his outfits.
void pilot_weaponAuto(Pilot *p)
Tries to automatically set and create the pilot's weapon set.
double ss_statsGetRaw(const ShipStats *s, ShipStatsType type)
Gets a ship stat value by name.
The representation of an in-game pilot.
ShipStatList * intrinsic_stats