naev 0.11.5
npc.c File Reference

Handles NPC stuff. More...

#include "npc.h"
#include "array.h"
#include "dialogue.h"
#include "event.h"
#include "land.h"
#include "log.h"
#include "nlua_evt.h"
#include "nlua_tex.h"
#include "nstring.h"
#include "opengl.h"
#include "ndata.h"

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 31 of file npc.c.

Function Documentation

◆ npc_add()

static unsigned int npc_add ( NPC_t * npc)
static

Adds an NPC to the spaceport bar.

Definition at line 107 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()

static unsigned int npc_add_giver ( Mission * misn)
static

Adds a mission giver NPC to the mission computer.

Definition at line 135 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 169 of file npc.c.

◆ npc_approach()

int npc_approach ( int i)

Approaches the NPC.

Parameters
iIndex of the NPC to approach.

Definition at line 622 of file npc.c.

◆ npc_approach_giver()

static int npc_approach_giver ( NPC_t * npc)
static

Approaches a mission giver guy.

Returns 1 on destroyed, 0 on not destroyed.

Definition at line 591 of file npc.c.

◆ npc_arrayGet()

static NPC_t * npc_arrayGet ( unsigned int id)
static

Gets an NPC by ID.

Definition at line 223 of file npc.c.

◆ npc_clear()

void npc_clear ( void )

Cleans up the spaceport bar NPC.

Definition at line 470 of file npc.c.

◆ npc_compare()

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

NPC compare function.

Definition at line 326 of file npc.c.

◆ npc_free()

static void npc_free ( NPC_t * npc)
static

Frees a single npc.

Definition at line 439 of file npc.c.

◆ npc_generateMissions()

void npc_generateMissions ( void )

Generates the bar missions.

Definition at line 365 of file npc.c.

◆ npc_getArraySize()

int npc_getArraySize ( void )

Get the size of the npc array.

Definition at line 496 of file npc.c.

◆ npc_getBackground()

glTexture * npc_getBackground ( int i)

Get the background of an NPC.

Definition at line 516 of file npc.c.

◆ npc_getDesc()

const char * npc_getDesc ( int i)

Gets the NPC description.

Definition at line 563 of file npc.c.

◆ npc_getMisn()

static Mission * npc_getMisn ( const NPC_t * npc)
static

Gets the mission associated with an NPC.

Definition at line 89 of file npc.c.

◆ npc_getName()

const char * npc_getName ( int i)

Get the name of an NPC.

Definition at line 504 of file npc.c.

◆ npc_getTexture()

glTexture * npc_getTexture ( int i)

Get the texture of an NPC.

Definition at line 551 of file npc.c.

◆ npc_isImportant()

int npc_isImportant ( int i)

Checks to see if the NPC is important or not.

Definition at line 575 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 420 of file npc.c.

◆ npc_rm()

static int npc_rm ( NPC_t * npc)
static

Removes an npc from the spaceport bar.

Definition at line 211 of file npc.c.

◆ npc_rm_event()

int npc_rm_event ( unsigned int id,
unsigned int evt )

removes an event NPC.

Definition at line 234 of file npc.c.

◆ npc_rm_mission()

int npc_rm_mission ( unsigned int id,
unsigned int mid )

removes a mission NPC.

Definition at line 256 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 278 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 302 of file npc.c.

◆ npc_sort()

void npc_sort ( void )

Sorts the NPCs.

Definition at line 356 of file npc.c.

Variable Documentation

◆ npc_array

NPC_t* npc_array = NULL
static

Missions at the spaceport bar.

Definition at line 70 of file npc.c.

◆ npc_array_idgen

unsigned int npc_array_idgen = 0
static

ID generator.

Definition at line 69 of file npc.c.

◆ npc_missions

Mission* npc_missions = NULL
static

Definition at line 73 of file npc.c.