31typedef enum NPCtype_ {
41typedef struct NPCevtData_ {
48typedef struct NPCmisnData_ {
73static Mission *npc_missions = NULL;
98 if (npc_missions[i].
id == npc->
u.
m.
id)
99 return &npc_missions[i];
140 if (misn->
npc == NULL) {
141 WARN(_(
"Mission '%s' trying to create NPC with no name!"), misn->
data->
name);
145 WARN(_(
"Mission '%s' trying to create NPC with no portrait!"), misn->
data->
name);
149 WARN(_(
"Mission '%s' trying to create NPC with no description!"), misn->
data->
name);
161 npc.
u.
m.
func = strdup(
"accept");
176 npc.
name = strdup( name );
180 npc.
desc = strdup( desc );
182 npc.
u.
m.
func = strdup( func );
190unsigned int npc_add_event(
unsigned int evt,
const char *func,
const char *name,
197 npc.
name = strdup( name );
201 npc.
desc = strdup( desc );
203 npc.
u.
e.
func = strdup( func );
246 if (npc->
u.
e.
id != evt)
268 if (mid != npc->
u.
m.
id)
285 if (npc->
u.
e.
id !=
id )
309 if (npc->
u.
m.
id != mid )
328 const NPC_t *npc1, *npc2;
341 ret = strcmp( npc1->
name, npc2->
name );
346 if (npc1->
id > npc2->
id)
348 else if (npc1->
id < npc2->
id)
370 if (npc_missions == NULL)
381 for (
int i=0; i<nmissions; i++) {
402 WARN(_(
"Mission '%s' was created at the spaceport bar but didn't create any NPC!"), m->
data->
name);
422 if (npc_missions==NULL)
462 WARN(_(
"Freeing NPC of invalid type."));
479 for (
int i=0; i<
array_size( npc_missions ); i++) {
531 WARN(_(
"Spob '%s' failed to run '%s':\n%s"),
land_spob->
name,
"barbg", lua_tostring(naevL,-1));
538 WARN(_(
"Spob '%s''s '%s' did not return a texture!"),
land_spob->
name,
"barbg");
600 WARN(_(
"Unable to find mission '%d' in npc_missions for giver npc '%s'!"), npc->
u.
m.
id, npc->
name);
605 if ((ret==3) || (ret==2) || (ret==-1)) {
642 WARN(_(
"Unable to find mission '%d' in npc_missions for mission npc '%s'!"), npc->
u.
m.
id, npc->
name);
645 misn_runStart( misn, npc->
u.
m.
func );
646 lua_pushnumber( naevL, npc->
id );
647 misn_runFunc( misn, npc->
u.
m.
func, 1 );
652 lua_pushnumber( naevL, npc->
id );
657 WARN(_(
"Unknown NPC type!"));
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_push_back(ptr_array, element)
Adds a new element at the end of the array.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
void bar_regen(void)
Regenerates the bar list.
int mission_accept(Mission *mission)
Small wrapper for misn_run.
Mission ** player_missions
Mission * missions_genList(int *n, int faction, const Spob *pnt, const StarSystem *sys, MissionAvailability loc)
Generates a mission list. This runs create() so won't work with all missions.
void mission_cleanup(Mission *misn)
Cleans up a mission.
Header file with generic functions and naev-specifics.
void event_runStart(unsigned int eventid, const char *func)
Starts running a function, allows programmer to set up arguments.
int event_runFunc(unsigned int eventid, const char *func, int nargs)
Runs a function previously set up with event_runStart.
glTexture * lua_totex(lua_State *L, int ind)
Lua bindings to interact with OpenGL textures.
int lua_istex(lua_State *L, int ind)
Checks to see if ind is a texture.
const char * npc_getDesc(int i)
Gets the NPC description.
static int npc_rm(NPC_t *npc)
Removes an npc from the spaceport bar.
void npc_patchMission(Mission *misn)
Patches a new mission bar npc into the bar system.
void npc_generateMissions(void)
Generates the bar missions.
glTexture * npc_getTexture(int i)
Get the texture of an NPC.
static void npc_free(NPC_t *npc)
Frees a single npc.
static unsigned int npc_add(NPC_t *npc)
Adds an NPC to the spaceport bar.
int npc_approach(int i)
Approaches the NPC.
int npc_rm_parentMission(unsigned int mid)
Removes all the npc belonging to a mission.
void npc_clear(void)
Cleans up the spaceport bar NPC.
unsigned int npc_add_event(unsigned int evt, const char *func, const char *name, int priority, glTexture *portrait, const char *desc, glTexture *background)
Adds a event NPC to the mission computer.
static unsigned int npc_add_giver(Mission *misn)
Adds a mission giver NPC to the mission computer.
int npc_getArraySize(void)
Get the size of the npc array.
int npc_rm_parentEvent(unsigned int id)
Removes all the npc belonging to an event.
glTexture * npc_getBackground(int i)
Get the background of an NPC.
static unsigned int npc_array_idgen
unsigned int npc_add_mission(unsigned int mid, const char *func, const char *name, int priority, glTexture *portrait, const char *desc, glTexture *background)
Adds a mission NPC to the mission computer.
int npc_isImportant(int i)
Checks to see if the NPC is important or not.
int npc_rm_mission(unsigned int id, unsigned int mid)
removes a mission NPC.
static int npc_compare(const void *arg1, const void *arg2)
NPC compare function.
int npc_rm_event(unsigned int id, unsigned int evt)
removes an event NPC.
const char * npc_getName(int i)
Get the name of an NPC.
static int npc_approach_giver(NPC_t *npc)
Approaches a mission giver guy.
static Mission * npc_getMisn(const NPC_t *npc)
static NPC_t * npc_arrayGet(unsigned int id)
Gets an NPC by ID.
void npc_sort(void)
Sorts the NPCs.
glTexture * gl_dupTexture(const glTexture *texture)
Duplicates a texture.
glTexture * gl_newImage(const char *path, const unsigned int flags)
Loads an image as a texture.
void gl_freeTexture(glTexture *texture)
Frees a texture.
void spob_luaInitMem(const Spob *spob)
Initializes the memory fo a spob.
Represents an active mission.
Minimum needed NPC data for event.
Minimum needed NPC data for mission.
Abstraction for rendering sprite sheets.