naev 0.12.5
npc.c File Reference

Handles NPC stuff. More...

#include "npc.h"
#include "array.h"
#include "land.h"
#include "log.h"
#include "ndata.h"
#include "nlua_evt.h"
#include "nlua_tex.h"
#include "ntracing.h"
Include dependency graph for npc.c:

Go to the source code of this file.

Data Structures

struct  NPCevtData
 Minimum needed NPC data for event. More...
struct  NPCmisnData
 Minimum needed NPC data for mission. More...
struct  NPC_t
 The bar NPC. More...

Enumerations

enum  NPCtype { NPC_TYPE_NULL , NPC_TYPE_GIVER , NPC_TYPE_MISSION , NPC_TYPE_EVENT }
 NPC types. More...

Functions

static unsigned int npc_add (NPC_t *npc)
 Adds an NPC to the spaceport bar.
static int npc_rm (NPC_t *npc)
 Removes an npc from the spaceport bar.
static NPC_tnpc_arrayGet (unsigned int id)
 Gets an NPC by ID.
static void npc_free (NPC_t *npc)
 Frees a single npc.
static Missionnpc_getMisn (const NPC_t *npc)
static unsigned int npc_add_giver (Mission *misn)
 Adds a mission giver NPC to the mission computer.
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.
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.
int npc_rm_event (unsigned int id, unsigned int evt)
 removes an event NPC.
int npc_rm_mission (unsigned int id, unsigned int mid)
 removes a mission NPC.
int npc_rm_parentEvent (unsigned int id)
 Removes all the npc belonging to an event.
int npc_rm_parentMission (unsigned int mid)
 Removes all the npc belonging to a mission.
static int npc_compare (const void *arg1, const void *arg2)
 NPC compare function.
void npc_sort (void)
 Sorts the NPCs.
void npc_generateMissions (void)
 Generates the bar missions.
void npc_patchMission (Mission *misn)
 Patches a new mission bar npc into the bar system.
void npc_clear (void)
 Cleans up the spaceport bar NPC.
int npc_getArraySize (void)
 Get the size of the npc array.
const char * npc_getName (int i)
 Get the name of an NPC.
glTexturenpc_getBackground (int i)
 Get the background of an NPC.
glTexturenpc_getTexture (int i)
 Get the texture of an NPC.
const char * npc_getDesc (int i)
 Gets the NPC description.
int npc_isImportant (int i)
 Checks to see if the NPC is important or not.
static int npc_approach_giver (NPC_t *npc)
 Approaches a mission giver guy.
int npc_approach (int i)
 Approaches the NPC.

Variables

static unsigned int npc_array_idgen = 0
static NPC_tnpc_array = NULL
static Missionnpc_missions = NULL

Detailed Description

Handles NPC stuff.

Definition in file npc.c.

Enumeration Type Documentation

◆ NPCtype

enum NPCtype

NPC types.

Enumerator
NPC_TYPE_NULL 

Inexistent NPC.

NPC_TYPE_GIVER 

Mission giver NPC.

NPC_TYPE_MISSION 

NPC generated by a mission.

NPC_TYPE_EVENT 

NPC generated by an event.

Definition at line 26 of file npc.c.

Function Documentation

◆ npc_add()

unsigned int npc_add ( NPC_t * npc)
static

Adds an NPC to the spaceport bar.

Definition at line 102 of file npc.c.

◆ npc_add_event()

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.

Definition at line 190 of file npc.c.

◆ npc_add_giver()

unsigned int npc_add_giver ( Mission * misn)
static

Adds a mission giver NPC to the mission computer.

Definition at line 130 of file npc.c.

◆ npc_add_mission()

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.

Definition at line 167 of file npc.c.

◆ npc_approach()

int npc_approach ( int i)

Approaches the NPC.

Parameters
iIndex of the NPC to approach.

Definition at line 635 of file npc.c.

◆ npc_approach_giver()

int npc_approach_giver ( NPC_t * npc)
static

Approaches a mission giver guy.

Returns 1 on destroyed, 0 on not destroyed.

Definition at line 602 of file npc.c.

◆ npc_arrayGet()

NPC_t * npc_arrayGet ( unsigned int id)
static

Gets an NPC by ID.

Definition at line 224 of file npc.c.

◆ npc_clear()

void npc_clear ( void )

Cleans up the spaceport bar NPC.

Definition at line 477 of file npc.c.

◆ npc_compare()

int npc_compare ( const void * arg1,
const void * arg2 )
static

NPC compare function.

Definition at line 327 of file npc.c.

◆ npc_free()

void npc_free ( NPC_t * npc)
static

Frees a single npc.

Definition at line 446 of file npc.c.

◆ npc_generateMissions()

void npc_generateMissions ( void )

Generates the bar missions.

Definition at line 366 of file npc.c.

◆ npc_getArraySize()

int npc_getArraySize ( void )

Get the size of the npc array.

Definition at line 504 of file npc.c.

◆ npc_getBackground()

glTexture * npc_getBackground ( int i)

Get the background of an NPC.

Definition at line 524 of file npc.c.

◆ npc_getDesc()

const char * npc_getDesc ( int i)

Gets the NPC description.

Definition at line 574 of file npc.c.

◆ npc_getMisn()

Mission * npc_getMisn ( const NPC_t * npc)
static

Gets the mission associated with an NPC.

Definition at line 84 of file npc.c.

◆ npc_getName()

const char * npc_getName ( int i)

Get the name of an NPC.

Definition at line 512 of file npc.c.

◆ npc_getTexture()

glTexture * npc_getTexture ( int i)

Get the texture of an NPC.

Definition at line 562 of file npc.c.

◆ npc_isImportant()

int npc_isImportant ( int i)

Checks to see if the NPC is important or not.

Definition at line 586 of file npc.c.

◆ npc_patchMission()

void npc_patchMission ( Mission * misn)

Patches a new mission bar npc into the bar system.

Note
Do not reuse the pointer once it's fed.
Parameters
misnMission to patch in.

Definition at line 427 of file npc.c.

◆ npc_rm()

int npc_rm ( NPC_t * npc)
static

Removes an npc from the spaceport bar.

Definition at line 212 of file npc.c.

◆ npc_rm_event()

int npc_rm_event ( unsigned int id,
unsigned int evt )

removes an event NPC.

Definition at line 235 of file npc.c.

◆ npc_rm_mission()

int npc_rm_mission ( unsigned int id,
unsigned int mid )

removes a mission NPC.

Definition at line 257 of file npc.c.

◆ npc_rm_parentEvent()

int npc_rm_parentEvent ( unsigned int id)

Removes all the npc belonging to an event.

Definition at line 279 of file npc.c.

◆ npc_rm_parentMission()

int npc_rm_parentMission ( unsigned int mid)

Removes all the npc belonging to a mission.

Definition at line 303 of file npc.c.

◆ npc_sort()

void npc_sort ( void )

Sorts the NPCs.

Definition at line 357 of file npc.c.

Variable Documentation

◆ npc_array

NPC_t* npc_array = NULL
static

Missions at the spaceport bar.

Definition at line 65 of file npc.c.

◆ npc_array_idgen

unsigned int npc_array_idgen = 0
static

ID generator.

Definition at line 64 of file npc.c.

◆ npc_missions

Mission* npc_missions = NULL
static

Definition at line 68 of file npc.c.