naev 0.12.6
explosion.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include "naev.h"
12
13#include "explosion.h"
14
15#include "log.h"
16#include "pilot.h"
17#include "rng.h"
18#include "spfx.h"
19#include "weapon.h"
20
21static int exp_s = -1;
22static int exp_m = -1;
23static int exp_l = -1;
24static int exp_200 = -1;
25static int exp_300 = -1;
26static int exp_400 = -1;
27static int exp_500 = -1;
28static int exp_600 = -1;
29
42void expl_explode( double x, double y, double vx, double vy, double radius,
43 const Damage *dmg, const Pilot *parent, int mode )
44{
45 int layer;
46 int efx;
47
48 /* Standard stuff - lazy allocation. */
49 if ( exp_s == -1 ) {
50 /* TODO This is all horrible and I wish we could either parametrize it or
51 * get rid of the hardcoding. */
52 exp_s = spfx_get( "ExpS" );
53 exp_m = spfx_get( "ExpM" );
54 exp_l = spfx_get( "ExpL" );
55 exp_200 = spfx_get( "Exp200" );
56 exp_300 = spfx_get( "Exp300" );
57 exp_400 = spfx_get( "Exp400" );
58 exp_500 = spfx_get( "Exp500" );
59 exp_600 = spfx_get( "Exp600" );
60 }
61 layer = SPFX_LAYER_FRONT;
62
63 if ( radius < 40. / 2. )
64 efx = exp_s;
65 else if ( radius < 70. / 2. )
66 efx = exp_m;
67 else if ( radius < 100. / 2. )
68 efx = exp_l;
69 else if ( radius < 200. / 2. )
70 efx = exp_200;
71 else if ( radius < 300. / 2. )
72 efx = exp_300;
73 else if ( radius < 400. / 2. )
74 efx = exp_400;
75 else if ( radius < 500. / 2. )
76 efx = exp_500;
77 // else if (radius < 600./2.)
78 else
79 efx = exp_600;
80
81 /* Final explosion. */
82 spfx_add( efx, x, y, vx, vy, layer );
83
84 /* Run the damage. */
85 if ( dmg != NULL )
86 expl_explodeDamage( x, y, radius, dmg, parent, mode );
87}
88
99void expl_explodeDamage( double x, double y, double radius, const Damage *dmg,
100 const Pilot *parent, int mode )
101{
102 /* Explosion affects ships. */
103 if ( mode & EXPL_MODE_SHIP )
104 pilot_explode( x, y, radius, dmg, parent );
105
106#if 0
107 /* Explosion affects missiles and bolts. */
108 if ((mode & EXPL_MODE_MISSILE) || (mode & EXPL_MODE_BOLT))
109 weapon_explode( x, y, radius, dmg->type, dmg->damage, parent, mode );
110#endif
111}
static int exp_200
Definition explosion.c:24
static int exp_m
Definition explosion.c:22
static int exp_l
Definition explosion.c:23
void expl_explode(double x, double y, double vx, double vy, double radius, const Damage *dmg, const Pilot *parent, int mode)
Does explosion in a radius (damage and graphics).
Definition explosion.c:42
static int exp_500
Definition explosion.c:27
static int exp_300
Definition explosion.c:25
static int exp_600
Definition explosion.c:28
static int exp_s
Definition explosion.c:21
void expl_explodeDamage(double x, double y, double radius, const Damage *dmg, const Pilot *parent, int mode)
Does explosion damage in a radius.
Definition explosion.c:99
static int exp_400
Definition explosion.c:26
Header file with generic functions and naev-specifics.
void pilot_explode(double x, double y, double radius, const Damage *dmg, const Pilot *parent)
Makes the pilot explosion.
Definition pilot.c:1767
int spfx_get(const char *name)
Gets the id of an spfx based on name.
Definition spfx.c:355
void spfx_add(int effect, const double px, const double py, const double vx, const double vy, int layer)
Creates a new special effect.
Definition spfx.c:504
Core damage that an outfit does.
Definition outfit.h:168
int type
Definition outfit.h:169
double damage
Definition outfit.h:173
The representation of an in-game pilot.
Definition pilot.h:263