forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
explosion.h
69 lines (56 loc) · 2.06 KB
/
explosion.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once
#ifndef CATA_SRC_EXPLOSION_H
#define CATA_SRC_EXPLOSION_H
#include <optional>
#include <string>
#include "projectile.h"
struct tripoint;
class JsonObject;
class nc_color;
struct explosion_data {
int damage = 0;
float radius = 0;
bool fire = false;
std::optional<projectile> fragment;
/** Returns the range at which blast damage is 0 and shrapnel is out of range. */
int safe_range() const;
explicit operator bool() const;
};
struct shockwave_data {
int radius = 0;
int force = 0;
int stun = 0;
int dam_mult = 0;
bool affects_player = false;
};
// handles explosion related functions
namespace explosion_handler
{
/**
* Legacy explosion function.
* Updated values are calculated from distance factor.
* If power > 0, blast is produced.
* If casing mass > 0, shrapnel is produced.
*/
void explosion(
const tripoint &p, Creature *source, float power, float factor = 0.8f,
bool fire = false, int legacy_casing_mass = 0, float legacy_frag_mass = 0.05
);
void explosion( const tripoint &p, const explosion_data &ex, Creature *source );
constexpr float power_to_dmg_mult = 2.0f / 15.0f;
/** Triggers a flashbang explosion at p. */
void flashbang( const tripoint &p, bool player_immune, const std::string &exp_name );
/** Triggers a resonance cascade at p. */
void resonance_cascade( const tripoint &p );
/** Triggers a scrambler blast at p. */
void scrambler_blast( const tripoint &p );
/** Triggers an EMP blast at p. */
void emp_blast( const tripoint &p );
/** Shockwave applies knockback with given parameters to all targets within radius of p. */
void shockwave( const tripoint &p, const shockwave_data &sw, const std::string &exp_name,
Creature *source );
projectile shrapnel_from_legacy( int power, float blast_radius );
float blast_radius_from_legacy( int power, float distance_factor );
} // namespace explosion_handler
explosion_data load_explosion_data( const JsonObject &jo );
#endif // CATA_SRC_EXPLOSION_H