naev 0.12.6
effect.c File Reference

Handles pilot effects. More...

#include "effect.h"
#include "array.h"
#include "conf.h"
#include "gui.h"
#include "log.h"
#include "ndata.h"
#include "nlua_pilot.h"
#include "nxml.h"
#include "rng.h"
Include dependency graph for effect.c:

Go to the source code of this file.

Macros

#define MELEMENT(o, s)

Functions

static int effect_cmp (const void *p1, const void *p2)
 Compares effects based on name.
static int effect_cmpTimer (const void *p1, const void *p2)
 Compares effects based on priority, then timer.
static int effect_parse (EffectData *efx, const char *file)
 Parsess an effect.
int effect_load (void)
 Loads all the effects.
void effect_exit (void)
 Gets rid of all the effects.
const EffectDataeffect_get (const char *name)
 Gets an effect by name.
int effect_update (Effect **efxlist, double dt)
 Updates an effect list.
int effect_add (Effect **efxlist, const EffectData *efx, double duration, double strength, unsigned int parent)
 Adds an effect to an effect list.
int effect_rm (Effect **efxlist, int idx)
 Removes an effect from an effect list by index.
int effect_rmType (Effect **efxlist, const EffectData *efx, int all)
 Removes an effect type from an effect list.
void effect_clearSpecific (Effect **efxlist, int debuffs, int buffs, int others)
 Clears specific types of effects.
void effect_clear (Effect **efxlist)
 Clears an effect list, removing all active effects.
void effect_compute (ShipStats *s, const Effect *efxlist)
 Updates shipstats from effect list.
void effect_cleanup (Effect *efxlist)
 Cleans up an effect list freeing it.

Variables

static EffectDataeffect_list = NULL

Detailed Description

Handles pilot effects.

Definition in file effect.c.

Macro Definition Documentation

◆ MELEMENT

#define MELEMENT ( o,
s )
Value:
if ( o ) \
WARN( _( "Effect '%s' missing/invalid '%s' element" ), efx->name, \
s )

Function Documentation

◆ effect_add()

int effect_add ( Effect ** efxlist,
const EffectData * efx,
double duration,
double strength,
unsigned int parent )

Adds an effect to an effect list.

Parameters
efxlistList of effects.
efxEffect to add.
durationDuration of the effect or set to negative for default.
strengthScaling strength of the effect.
parentPilot the effect is being added to.
Returns
0 on success.

Definition at line 322 of file effect.c.

◆ effect_cleanup()

void effect_cleanup ( Effect * efxlist)

Cleans up an effect list freeing it.

Parameters
efxlistList to free.

Definition at line 561 of file effect.c.

◆ effect_clear()

void effect_clear ( Effect ** efxlist)

Clears an effect list, removing all active effects.

Parameters
efxlistList of effects.

Definition at line 524 of file effect.c.

◆ effect_clearSpecific()

void effect_clearSpecific ( Effect ** efxlist,
int debuffs,
int buffs,
int others )

Clears specific types of effects.

Parameters
efxlistList of effects.
debuffsWhether or not to clear debuffs.
buffsWhether or not to clear buffs.
othersWhether or not to clear other effects.

Definition at line 485 of file effect.c.

◆ effect_cmp()

int effect_cmp ( const void * p1,
const void * p2 )
static

Compares effects based on name.

Definition at line 31 of file effect.c.

◆ effect_cmpTimer()

int effect_cmpTimer ( const void * p1,
const void * p2 )
static

Compares effects based on priority, then timer.

Definition at line 41 of file effect.c.

◆ effect_compute()

void effect_compute ( ShipStats * s,
const Effect * efxlist )

Updates shipstats from effect list.

Parameters
sStats to update.
efxlistList of effects.

Definition at line 548 of file effect.c.

◆ effect_exit()

void effect_exit ( void )

Gets rid of all the effects.

Definition at line 244 of file effect.c.

◆ effect_get()

const EffectData * effect_get ( const char * name)

Gets an effect by name.

Parameters
nameName of the base effect to get.
Returns
The base effect or NULL if not applicable.

Definition at line 265 of file effect.c.

◆ effect_load()

int effect_load ( void )

Loads all the effects.

Returns
0 on success

Definition at line 199 of file effect.c.

◆ effect_parse()

int effect_parse ( EffectData * efx,
const char * file )
static

Parsess an effect.

Definition at line 55 of file effect.c.

◆ effect_rm()

int effect_rm ( Effect ** efxlist,
int idx )

Removes an effect from an effect list by index.

Parameters
efxlistList of effects.
idxIndex to remove.
Returns
Number of instances removed.

Definition at line 420 of file effect.c.

◆ effect_rmType()

int effect_rmType ( Effect ** efxlist,
const EffectData * efx,
int all )

Removes an effect type from an effect list.

Parameters
efxlistList of effects.
efxEffect type to remove.
allWhether or not to remove all instances.
Returns
Number of instances removed.

Definition at line 452 of file effect.c.

◆ effect_update()

int effect_update ( Effect ** efxlist,
double dt )

Updates an effect list.

Parameters
efxlistThe effect list.
dtThe time update.
Returns
The number of effects that ended or changed.

Definition at line 282 of file effect.c.

Variable Documentation

◆ effect_list

EffectData* effect_list = NULL
static

Definition at line 26 of file effect.c.