26typedef enum NPCtype_ {
36typedef struct NPCevtData_ {
43typedef struct NPCmisnData_ {
68static Mission *npc_missions = NULL;
92 for (
int i = 0; i <
array_size( npc_missions ); i++ )
93 if ( npc_missions[i].
id == npc->
u.
m.
id )
94 return &npc_missions[i];
135 if ( misn->
npc == NULL ) {
136 WARN( _(
"Mission '%s' trying to create NPC with no name!" ),
141 WARN( _(
"Mission '%s' trying to create NPC with no portrait!" ),
146 WARN( _(
"Mission '%s' trying to create NPC with no description!" ),
153 npc.
name = strdup( misn->
npc );
159 npc.
u.
m.
func = strdup(
"accept" );
168 const char *name,
int priority,
176 npc.
name = strdup( name );
180 npc.
desc = strdup( desc );
182 npc.
u.
m.
func = strdup( func );
191 const char *name,
int priority,
glTexture *portrait,
192 const char *desc,
glTexture *background )
198 npc.
name = strdup( name );
202 npc.
desc = strdup( desc );
204 npc.
u.
e.
func = strdup( func );
247 if ( npc->
u.
e.
id != evt )
269 if ( mid != npc->
u.
m.
id )
286 if ( npc->
u.
e.
id !=
id )
310 if ( npc->
u.
m.
id != mid )
329 const NPC_t *npc1, *npc2;
332 npc1 = (
NPC_t *)arg1;
333 npc2 = (
NPC_t *)arg2;
342 ret = strcmp( npc1->
name, npc2->
name );
347 if ( npc1->
id > npc2->
id )
349 else if ( npc1->
id < npc2->
id )
370 NTracingZone( _ctx, 1 );
372 if ( npc_missions == NULL )
382 for (
int i = 0; i <
array_size( missions ); i++ ) {
405 WARN( _(
"Mission '%s' was created at the spaceport bar but didn't "
417 NTracingZoneEnd( _ctx );
429 if ( npc_missions == NULL )
458 switch ( npc->
type ) {
469 WARN( _(
"Freeing NPC of invalid type." ) );
486 for (
int i = 0; i <
array_size( npc_missions ); i++ ) {
535 if (
land_spob->lua_barbg != LUA_NOREF ) {
538 if ( nlua_pcall(
land_spob->lua_env, 0, 1 ) ) {
539 WARN( _(
"Spob '%s' failed to run '%s':\n%s" ),
land_spob->name,
540 "barbg", lua_tostring(
naevL, -1 ) );
547 WARN( _(
"Spob '%s''s '%s' did not return a texture!" ),
553 gl_newImage( GFX_PATH
"portraits/background.png", 0 );
610 if ( misn == NULL ) {
612 _(
"Unable to find mission '%d' in npc_missions for giver npc '%s'!" ),
618 if ( ( ret == 3 ) || ( ret == 2 ) ||
648 switch ( npc->
type ) {
654 if ( misn == NULL ) {
655 WARN( _(
"Unable to find mission '%d' in npc_missions for mission npc "
660 misn_runStart( misn, npc->
u.
m.
func );
661 lua_pushnumber(
naevL, npc->
id );
662 misn_runFunc( misn, npc->
u.
m.
func, 1 );
667 lua_pushnumber(
naevL, npc->
id );
672 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
void mission_cleanup(Mission *misn)
Cleans up a mission.
Mission * missions_genList(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 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.
union NPC_t::@063306063055044074131140344114342035143052350025 u
Minimum needed NPC data for event.
Minimum needed NPC data for mission.
Abstraction for rendering sprite sheets.