naev 0.11.5
explosion.c
Go to the documentation of this file.
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
10#include "naev.h"
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;
42void expl_explode( double x, double y, double vx, double vy,
43 double radius, const Damage *dmg,
44 const Pilot *parent, int mode )
45{
46 int layer;
47 int efx;
48
49 /* Standard stuff - lazy allocation. */
50 if (exp_s == -1) {
51 /* TODO This is all horrible and I wish we could either parametrize it or
52 * get rid of the hardcoding. */
53 exp_s = spfx_get("ExpS");
54 exp_m = spfx_get("ExpM");
55 exp_l = spfx_get("ExpL");
56 exp_200 = spfx_get("Exp200");
57 exp_300 = spfx_get("Exp300");
58 exp_400 = spfx_get("Exp400");
59 exp_500 = spfx_get("Exp500");
60 exp_600 = spfx_get("Exp600");
61 }
62 layer = SPFX_LAYER_FRONT;
63
64 if (radius < 40./2.)
65 efx = exp_s;
66 else if (radius < 70./2.)
67 efx = exp_m;
68 else if (radius < 100./2.)
69 efx = exp_l;
70 else if (radius < 200./2.)
71 efx = exp_200;
72 else if (radius < 300./2.)
73 efx = exp_300;
74 else if (radius < 400./2.)
75 efx = exp_400;
76 else if (radius < 500./2.)
77 efx = exp_500;
78 //else if (radius < 600./2.)
79 else
80 efx = exp_600;
81
82 /* Final explosion. */
83 spfx_add( efx, x, y, vx, vy, layer );
84
85 /* Run the damage. */
86 if (dmg != NULL)
87 expl_explodeDamage( x, y, radius, dmg, parent, mode );
88}
89
100void expl_explodeDamage( double x, double y, double radius,
101 const Damage *dmg, const Pilot *parent, int mode )
102{
103 /* Explosion affects ships. */
104 if (mode & EXPL_MODE_SHIP)
105 pilot_explode( x, y, radius, dmg, parent );
106
107#if 0
108 /* Explosion affects missiles and bolts. */
109 if ((mode & EXPL_MODE_MISSILE) || (mode & EXPL_MODE_BOLT))
110 weapon_explode( x, y, radius, dmg->type, dmg->damage, parent, mode );
111#endif
112}
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:100
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:1683
int spfx_get(const char *name)
Gets the id of an spfx based on name.
Definition spfx.c:342
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:475
Core damage that an outfit does.
Definition outfit.h:138
int type
Definition outfit.h:139
double damage
Definition outfit.h:141
The representation of an in-game pilot.
Definition pilot.h:217