forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdamage.h
124 lines (104 loc) · 3.6 KB
/
damage.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifndef DAMAGE_H
#define DAMAGE_H
#include "bodypart.h"
#include "color.h"
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
struct itype;
struct tripoint;
class item;
class monster;
enum damage_type {
DT_NULL = 0, // null damage, doesn't exist
DT_TRUE, // typeless damage, should always go through
DT_BIOLOGICAL, // internal damage, like from smoke or poison
DT_BASH, // bash damage
DT_CUT, // cut damage
DT_ACID, // corrosive damage, e.g. acid
DT_STAB, // stabbing/piercing damage
DT_HEAT, // e.g. fire, plasma
DT_COLD, // e.g. heatdrain, cryogrenades
DT_ELECTRIC, // e.g. electrical discharge
NUM_DT
};
enum blast_shape {
BS_NONE = 0, // no aoe
BS_BLAST, // generic "blast" effect, like grenades
BS_RAYS, // randomly scattered rays of damage propragating from impact point
BS_CONE, // cone-shaped effect, starting at impact and hitting enemies behind in a cone
NUM_BS
};
struct damage_unit {
damage_type type;
float amount;
int res_pen;
float res_mult;
float damage_multiplier;
damage_unit(damage_type dt, float a, int rp, float rm) :
type(dt), amount(a), res_pen(rp), res_mult(rm), damage_multiplier(1.0) { }
};
// a single atomic unit of damage from an attack. Can include multiple types
// of damage at different armor mitigation/penetration values
struct damage_instance {
std::vector<damage_unit> damage_units;
std::set<std::string> effects;
damage_instance();
static damage_instance physical(float bash, float cut, float stab, int arpen = 0);
void add_damage(damage_type dt, float a, int rp = 0, float rm = 1.0f);
damage_instance(damage_type dt, float a, int rp = 0, float rm = 1.0f);
void add_effect( std::string effect );
void mult_damage(double multiplier);
float type_damage(damage_type dt) const;
float total_damage() const;
void clear();
};
struct dealt_damage_instance {
std::vector<int> dealt_dams;
body_part bp_hit;
dealt_damage_instance();
//TODO: add check to ensure length
dealt_damage_instance(std::vector<int> &dealt);
void set_damage(damage_type dt, int amount);
int type_damage(damage_type dt) const;
int total_damage() const;
};
struct resistances {
std::vector<int> resist_vals;
resistances();
resistances(item &armor);
resistances(monster &monster);
void set_resist(damage_type dt, int amount);
int type_resist(damage_type dt) const;
float get_effective_resist(const damage_unit &du);
};
struct projectile {
damage_instance impact;
damage_instance payload;
blast_shape aoe_shape;
nc_color aoe_color;
int aoe_size;
int speed; // how hard is it to dodge? essentially rolls to-hit, bullets have arbitrarily high values but thrown objects have dodgeable values
bool drops; // does it drop ammo units?
bool wide; // a shot that "covers" the target, e.g. a shotgun blast or flamethrower napalm
// TODO: things below here are here temporarily until we finish those
// systems
std::set<std::string> proj_effects;
itype *ammo; // projectile's item that gets spawned at impact location, e.g. thrown weapons/bolts
projectile() :
aoe_shape(BS_NONE),
aoe_color(c_red),
aoe_size(0),
speed(0),
drops(false),
wide(false),
ammo(NULL)
{ }
};
void ammo_effects(int x, int y, const std::set<std::string> &effects);
void ammo_effects( const tripoint &p, const std::set<std::string> &effects );
int aoe_size( const std::set<std::string> &effects );
damage_type dt_by_name( const std::string &name );
#endif