41 unsigned int id,
int persist )
44 if (p->escorts == NULL)
47 escort->
ship = strdup(ship);
63 free(p->escorts[i].ship);
77 free(p->escorts[i].ship);
78 array_erase( &p->escorts, &p->escorts[i], &p->escorts[i+1] );
91 if (p->escorts[i].id ==
id) {
112 const vec2 *pos,
const vec2 *vel,
double dir,
113 EscortType_t type,
int add,
int dockslot )
126 pilot_clearFlagsRaw( f );
127 pilot_setFlagRaw( f, PILOT_NOJUMP );
128 if (p->faction == FACTION_PLAYER) {
129 pilot_setFlagRaw( f, PILOT_PERSIST );
130 pilot_setFlagRaw( f, PILOT_NOCLEAR );
132 if (type == ESCORT_TYPE_BAY)
133 pilot_setFlagRaw( f, PILOT_CARRIED );
136 e =
pilot_create( s, NULL, p->faction,
"escort", dir, pos, vel, f, parent, dockslot );
141 if (pe->
parent == PLAYER_ID)
142 pilot_setFlag( pe, PILOT_INVINC_PLAYER );
145 if (pilot_isFlag(p, PILOT_HOSTILE))
146 pilot_setFlag( pe, PILOT_HOSTILE );
147 if (pilot_isFlag(p, PILOT_FRIENDLY))
148 pilot_setFlag( pe, PILOT_FRIENDLY );
151 if (pilot_isFlagRaw( f, PILOT_CARRIED )) {
188 const vec2 *pos,
const vec2 *vel,
double dir,
189 EscortType_t type,
int add,
int dockslot )
198 if (pe->
parent == PLAYER_ID)
199 pilot_setFlag( pe, PILOT_INVINC_PLAYER );
209 if (p->faction == FACTION_PLAYER) {
210 pilot_setFlag( pe, PILOT_PERSIST );
211 pilot_setFlag( pe, PILOT_NOCLEAR );
213 if (pilot_isFlag(p, PILOT_HOSTILE))
214 pilot_setFlag( pe, PILOT_HOSTILE );
215 if (pilot_isFlag(p, PILOT_FRIENDLY))
216 pilot_setFlag( pe, PILOT_FRIENDLY );
233 for (
int j=
array_size(p->escorts)-1; j>=0; j--) {
238 if (e->
type != ESCORT_TYPE_BAY)
245 memcpy( &pe->
solid->
pos, &p->solid->pos,
sizeof(
vec2) );
246 memcpy( &pe->
solid->
vel, &p->solid->vel,
sizeof(
vec2) );
248 WARN(_(
"Pilot '%s' has escort '%s' docking error!"), p->name, pe->
name);
303 if ((ret == 0) && (parent ==
player.
p)) {
304 if (pilot_isFlag(t, PILOT_DISABLED))
320 if ((ret == 0) && (parent ==
player.
p))
333 if ((ret == 0) && (parent ==
player.
p))
346 if ((ret == 0) && (parent ==
player.
p))
359 const char *title, *caption;
365 const char *opts[] = {
377 title = _(
"Escort Orders");
378 caption = _(
"Select the order to give to this escort.");
381 for (
int i=0; i<nopts; i++)
385 if (choice != NULL) {
386 if (strcmp(choice, opts[0]) == 0) {
390 else if (strcmp(choice, opts[1]) == 0) {
394 else if (strcmp(choice, opts[2]) == 0) {
421 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.
static int escort_command(Pilot *parent, const char *cmd, unsigned int index)
Runs an escort command on all of a pilot's escorts.
void escort_rmList(Pilot *p, unsigned int id)
Remove from escorts list.
void escort_freeList(Pilot *p)
Remove all escorts from a pilot.
unsigned int escort_create(Pilot *p, const char *ship, const vec2 *pos, const vec2 *vel, double dir, EscortType_t type, int add, int dockslot)
Creates an escort.
int escorts_jump(Pilot *parent, JumpPoint *jp)
Have a pilot order its escorts to jump.
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.
void escort_rmListIndex(Pilot *p, int i)
Remove from escorts list.
int escort_playerCommand(Pilot *e)
Open a dialog for the player to issue a command to an escort.
int escort_addList(Pilot *p, const char *ship, EscortType_t type, unsigned int id, int persist)
Adds an escort to the escort list of a pilot.
int escort_clearDeployed(Pilot *p)
Clears deployed escorts of a pilot.
int escorts_return(Pilot *parent)
Have a pilot order its escorts to dock.
int escorts_attack(Pilot *parent)
Have a pilot order its escorts to attack its target.
int escorts_hold(Pilot *parent)
Have a pilot order its escorts to hold position.
int escorts_clear(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.
Header file with generic functions and naev-specifics.
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_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.
unsigned int pilot_addStack(Pilot *p)
Adds a pilot to the stack.
void pilot_msg(Pilot *p, Pilot *receiver, const char *type, unsigned int idx)
Sends a message.
Pilot * pilot_getTarget(Pilot *p)
Gets the target of a pilot using a fancy caching system.
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.
void pilot_calcStats(Pilot *pilot)
Recalculates the pilot's stats based on his outfits.
int pilot_dock(Pilot *p, Pilot *target)
Docks the pilot on its target pilot.
const Ship * ship_get(const char *name)
Gets a ship based on its name.
The representation of an in-game pilot.
ShipStats intrinsic_stats