41 unsigned int id,
int persist )
44 if (p->escorts == NULL)
75 array_erase( &p->escorts, &p->escorts[i], &p->escorts[i+1] );
88 if (p->escorts[i].id ==
id) {
109 const vec2 *pos,
const vec2 *vel,
double dir,
110 EscortType_t type,
int add,
int dockslot )
120 pilot_clearFlagsRaw( f );
122 if (p->faction == FACTION_PLAYER) {
123 pilot_setFlagRaw( f, PILOT_PERSIST );
124 pilot_setFlagRaw( f, PILOT_NOCLEAR );
126 if (type == ESCORT_TYPE_BAY)
127 pilot_setFlagRaw( f, PILOT_CARRIED );
130 pe =
pilot_create( ship, NULL, p->faction,
"escort", dir, pos, vel, f, parent, dockslot );
134 if (pe->
parent == PLAYER_ID)
135 pilot_setFlag( pe, PILOT_INVINC_PLAYER );
138 if (pilot_isFlag(p, PILOT_HOSTILE))
139 pilot_setFlag( pe, PILOT_HOSTILE );
140 if (pilot_isFlag(p, PILOT_FRIENDLY))
141 pilot_setFlag( pe, PILOT_FRIENDLY );
144 if (pilot_isFlagRaw( f, PILOT_CARRIED )) {
146 if (p->stats.fbay_damage != 1.) {
152 if (p->stats.fbay_health != 1.) {;
157 if (p->stats.fbay_movement != 1.) {;
187 const vec2 *pos,
const vec2 *vel,
double dir,
188 EscortType_t type,
int add,
int dockslot )
197 if (pe->
parent == PLAYER_ID)
198 pilot_setFlag( pe, PILOT_INVINC_PLAYER );
208 if (p->faction == FACTION_PLAYER) {
209 pilot_setFlag( pe, PILOT_PERSIST );
210 pilot_setFlag( pe, PILOT_NOCLEAR );
212 if (pilot_isFlag(p, PILOT_HOSTILE))
213 pilot_setFlag( pe, PILOT_HOSTILE );
214 if (pilot_isFlag(p, PILOT_FRIENDLY))
215 pilot_setFlag( pe, PILOT_FRIENDLY );
232 for (
int j=
array_size(p->escorts)-1; j>=0; j--) {
237 if (e->
type != ESCORT_TYPE_BAY)
246 if (pilot_dock( pe, p ))
247 WARN(_(
"Pilot '%s' has escort '%s' docking error!"), p->name, pe->
name);
302 if ((ret == 0) && (parent ==
player.
p)) {
307 pltname = _(
"Unknown");
309 if (pilot_isFlag(t, PILOT_DISABLED))
325 if ((ret == 0) && (parent ==
player.
p))
338 if ((ret == 0) && (parent ==
player.
p))
351 if ((ret == 0) && (parent ==
player.
p))
364 const char *title, *caption;
370 const char *opts[] = {
382 title = _(
"Escort Orders");
383 caption = _(
"Select the order to give to this escort.");
386 for (
int i=0; i<nopts; i++)
390 if (choice != NULL) {
391 if (strcmp(choice, opts[0]) == 0) {
395 else if (strcmp(choice, opts[1]) == 0) {
399 else if (strcmp(choice, opts[2]) == 0) {
426 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.
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 escort_clearDeployed(Pilot *p)
Clears deployed escorts of a pilot.
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.
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_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.
The representation of an in-game pilot.
ShipStatList * intrinsic_stats