forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
field_type.h
343 lines (310 loc) · 10.4 KB
/
field_type.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
#pragma once
#ifndef CATA_SRC_FIELD_TYPE_H
#define CATA_SRC_FIELD_TYPE_H
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#include "bodypart.h"
#include "calendar.h"
#include "catacharset.h"
#include "color.h"
#include "effect.h"
#include "enums.h"
#include "mapdata.h"
#include "translations.h"
#include "type_id.h"
class JsonObject;
template <typename E> struct enum_traits;
enum phase_id : int;
enum body_part : int;
enum class description_affix : int {
DESCRIPTION_AFFIX_IN,
DESCRIPTION_AFFIX_COVERED_IN,
DESCRIPTION_AFFIX_ON,
DESCRIPTION_AFFIX_UNDER,
DESCRIPTION_AFFIX_ILLUMINTED_BY,
DESCRIPTION_AFFIX_NUM
};
namespace std
{
template <>
struct hash<description_affix> {
std::size_t operator()( const description_affix &k ) const noexcept {
return static_cast<size_t>( k );
}
};
} // namespace std
static const std::unordered_map<description_affix, std::string> description_affixes = {
{ description_affix::DESCRIPTION_AFFIX_IN, translate_marker( " in %s" ) },
{ description_affix::DESCRIPTION_AFFIX_COVERED_IN, translate_marker( " covered in %s" ) },
{ description_affix::DESCRIPTION_AFFIX_ON, translate_marker( " on %s" ) },
{ description_affix::DESCRIPTION_AFFIX_UNDER, translate_marker( " under %s" ) },
{ description_affix::DESCRIPTION_AFFIX_ILLUMINTED_BY, translate_marker( " in %s" ) },
};
template<>
struct enum_traits<description_affix> {
static constexpr description_affix last = description_affix::DESCRIPTION_AFFIX_NUM;
};
namespace fields
{
enum class stacking_type {
intensity = 0,
duration,
stacking_type_num
};
} // namespace fields
template<>
struct enum_traits<fields::stacking_type> {
static constexpr fields::stacking_type last = fields::stacking_type::stacking_type_num;
};
struct field_effect {
efftype_id id;
time_duration min_duration = 0_seconds;
time_duration max_duration = 0_seconds;
int intensity = 0;
bodypart_str_id bp = bodypart_str_id::NULL_ID();
bool is_environmental = true;
bool immune_in_vehicle = false;
bool immune_inside_vehicle = false;
bool immune_outside_vehicle = false;
int chance_in_vehicle = 0;
int chance_inside_vehicle = 0;
int chance_outside_vehicle = 0;
game_message_type env_message_type = m_neutral;
translation message;
translation message_npc;
time_duration get_duration() const {
return rng( min_duration, max_duration );
}
std::string get_message() const {
return message.translated();
}
std::string get_message_npc() const {
return message_npc.translated();
}
effect get_effect( const time_point &start_time = calendar::turn ) const {
return effect( &id.obj(), get_duration(), bp, intensity, start_time );
}
};
struct field_intensity_level {
translation name;
uint32_t symbol = PERCENT_SIGN_UNICODE;
nc_color color = c_white;
bool dangerous = false;
bool transparent = true;
int move_cost = 0;
int extra_radiation_min = 0;
int extra_radiation_max = 0;
int radiation_hurt_damage_min = 0;
int radiation_hurt_damage_max = 0;
translation radiation_hurt_message;
int intensity_upgrade_chance = 0;
time_duration intensity_upgrade_duration = 0_turns;
int monster_spawn_chance = 0;
int monster_spawn_count = 0;
int monster_spawn_radius = 0;
mongroup_id monster_spawn_group;
float light_emitted = 0.0f;
float local_light_override = -1.0f;
float translucency = 0.0f;
int convection_temperature_mod = 0;
int scent_neutralization = 0;
std::vector<field_effect> field_effects;
};
struct field_type {
public:
void load( const JsonObject &jo, const std::string &src );
void finalize();
void check() const;
public:
// Used by generic_factory
field_type_str_id id;
bool was_loaded = false;
// Used only during loading
std::string wandering_field_id = "fd_null";
public:
int legacy_enum_id = -1;
std::vector<field_intensity_level> intensity_levels;
time_duration underwater_age_speedup = 0_turns;
time_duration outdoor_age_speedup = 0_turns;
int decay_amount_factor = 0;
int percent_spread = 0;
int apply_slime_factor = 0;
int gas_absorption_factor = 0;
bool is_splattering = false;
bool dirty_transparency_cache = false;
bool has_fire = false;
bool has_acid = false;
bool has_elec = false;
bool has_fume = false;
description_affix desc_affix = description_affix::DESCRIPTION_AFFIX_NUM;
map_bash_info bash_info;
// chance, issue, duration, speech
std::tuple<int, std::string, time_duration, std::string> npc_complain_data;
std::vector<trait_id> immunity_data_traits;
std::vector<std::pair<body_part, int>> immunity_data_body_part_env_resistance;
std::set<mtype_id> immune_mtypes;
int priority = 0;
time_duration half_life = 0_turns;
phase_id phase = PNULL;
bool accelerated_decay = false;
bool display_items = true;
bool display_field = false;
field_type_id wandering_field;
std::string looks_like;
fields::stacking_type stacking_type = fields::stacking_type::intensity;
public:
const field_intensity_level &get_intensity_level( int level = 0 ) const;
std::string get_name( int level = 0 ) const {
return get_intensity_level( level ).name.translated();
}
uint32_t get_codepoint( int level = 0 ) const {
return get_intensity_level( level ).symbol;
}
std::string get_symbol( int level = 0 ) const {
return utf32_to_utf8( get_intensity_level( level ).symbol );
}
nc_color get_color( int level = 0 ) const {
return get_intensity_level( level ).color;
}
bool get_dangerous( int level = 0 ) const {
return get_intensity_level( level ).dangerous;
}
bool get_transparent( int level = 0 ) const {
return get_intensity_level( level ).transparent;
}
int get_move_cost( int level = 0 ) const {
return get_intensity_level( level ).move_cost;
}
int get_extra_radiation_min( int level = 0 ) const {
return get_intensity_level( level ).extra_radiation_min;
}
int get_extra_radiation_max( int level = 0 ) const {
return get_intensity_level( level ).extra_radiation_max;
}
int get_radiation_hurt_damage_min( int level = 0 ) const {
return get_intensity_level( level ).radiation_hurt_damage_min;
}
int get_radiation_hurt_damage_max( int level = 0 ) const {
return get_intensity_level( level ).radiation_hurt_damage_max;
}
std::string get_radiation_hurt_message( int level = 0 ) const {
return get_intensity_level( level ).radiation_hurt_message.translated();
}
int get_intensity_upgrade_chance( int level = 0 ) const {
return get_intensity_level( level ).intensity_upgrade_chance;
}
time_duration get_intensity_upgrade_duration( int level = 0 ) const {
return get_intensity_level( level ).intensity_upgrade_duration;
}
int get_monster_spawn_chance( int level = 0 ) const {
return get_intensity_level( level ).monster_spawn_chance;
}
int get_monster_spawn_count( int level = 0 ) const {
return get_intensity_level( level ).monster_spawn_count;
}
int get_monster_spawn_radius( int level = 0 ) const {
return get_intensity_level( level ).monster_spawn_radius;
}
mongroup_id get_monster_spawn_group( int level = 0 ) const {
return get_intensity_level( level ).monster_spawn_group;
}
float get_light_emitted( int level = 0 ) const {
return get_intensity_level( level ).light_emitted;
}
float get_local_light_override( int level = 0 )const {
return get_intensity_level( level ).local_light_override;
}
float get_translucency( int level = 0 ) const {
return get_intensity_level( level ).translucency;
}
int get_convection_temperature_mod( int level = 0 ) const {
return get_intensity_level( level ).convection_temperature_mod;
}
bool is_dangerous() const {
return std::any_of( intensity_levels.begin(), intensity_levels.end(),
[]( const field_intensity_level & elem ) {
return elem.dangerous;
} );
}
bool is_transparent() const {
return std::all_of( intensity_levels.begin(), intensity_levels.end(),
[]( const field_intensity_level & elem ) {
return elem.transparent;
} );
}
int get_max_intensity() const {
return intensity_levels.size();
}
static size_t count();
};
namespace field_types
{
void load( const JsonObject &jo, const std::string &src );
void finalize_all();
void check_consistency();
void reset();
const std::vector<field_type> &get_all();
void set_field_type_ids();
field_type get_field_type_by_legacy_enum( int legacy_enum_id );
} // namespace field_types
extern field_type_id fd_null,
fd_blood,
fd_bile,
fd_gibs_flesh,
fd_gibs_veggy,
fd_web,
fd_slime,
fd_acid,
fd_sap,
fd_sludge,
fd_fire,
fd_smoke,
fd_toxic_gas,
fd_tear_gas,
fd_nuke_gas,
fd_gas_vent,
fd_fire_vent,
fd_flame_burst,
fd_electricity,
fd_fatigue,
fd_push_items,
fd_shock_vent,
fd_acid_vent,
fd_plasma,
fd_laser,
fd_spotlight,
fd_dazzling,
fd_blood_veggy,
fd_blood_insect,
fd_blood_invertebrate,
fd_gibs_insect,
fd_gibs_invertebrate,
fd_cigsmoke,
fd_weedsmoke,
fd_cracksmoke,
fd_methsmoke,
fd_bees,
fd_incendiary,
fd_relax_gas,
fd_fungal_haze,
fd_cold_air1,
fd_cold_air2,
fd_cold_air3,
fd_cold_air4,
fd_hot_air1,
fd_hot_air2,
fd_hot_air3,
fd_hot_air4,
fd_fungicidal_gas,
fd_insecticidal_gas,
fd_smoke_vent,
fd_tindalos_rift
;
#endif // CATA_SRC_FIELD_TYPE_H