-
Notifications
You must be signed in to change notification settings - Fork 0
/
shipstats.h
246 lines (206 loc) · 8.76 KB
/
shipstats.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
/*
* See Licensing and Copyright notice in naev.h
*/
#ifndef SHIPSTATS_H
# define SHIPSTATS_H
#include "nxml.h"
/**
* @brief Lists all the possible types.
*
* Syntax:
* SS_TYPE_#1_#2
*
* #1 is D for double, A for absolute double, I for integer or B for boolean.
* #2 is the name.
*/
typedef enum ShipStatsType_ {
SS_TYPE_NIL, /**< Invalid type. */
/*
* D: Double type data. Should be continuous.
*/
/* General. */
SS_TYPE_D_SPEED_MOD, /**< Speed multiplier. */
SS_TYPE_D_TURN_MOD, /**< Turn multiplier. */
SS_TYPE_D_THRUST_MOD, /**< Acceleration multiplier. */
SS_TYPE_D_CARGO_MOD, /**< Cargo space multiplier. */
SS_TYPE_D_ARMOUR_MOD, /**< Armour multiplier. */
SS_TYPE_D_ARMOUR_REGEN_MOD, /**< Armour regeneration multiplier. */
SS_TYPE_D_SHIELD_MOD, /**< Shield multiplier. */
SS_TYPE_D_SHIELD_REGEN_MOD, /**< Shield regeneration multiplier. */
SS_TYPE_D_ENERGY_MOD, /**< Energy multiplier. */
SS_TYPE_D_ENERGY_REGEN_MOD, /**< Energy regeneration multiplier. */
SS_TYPE_D_CPU_MOD, /**< CPU multiplier. */
/* Freighter-type. */
SS_TYPE_D_JUMP_DELAY, /**< Modulates the time that passes during a hyperspace jump. */
SS_TYPE_D_CARGO_INERTIA, /**< Modifies the effect of cargo_mass. */
/* Stealth. */
SS_TYPE_D_EW_HIDE, /**< Electronic warfare hide modifier. */
SS_TYPE_D_EW_DETECT, /**< Electronic warfare detection modifier. */
SS_TYPE_D_EW_JUMPDETECT, /**< Electronic warfare jump point detection modifier. */
/* Launchers. */
SS_TYPE_D_LAUNCH_RATE, /**< Launch rate for missiles. */ /* TODO */
SS_TYPE_D_LAUNCH_RANGE, /**< Launch range for missiles. */ /* TODO */
SS_TYPE_D_AMMO_CAPACITY, /**< Capacity of launchers. */ /* TODO */
SS_TYPE_D_LAUNCH_LOCKON, /**< Lockon speed of launchers. */ /* TODO */
/* Forward mounts. */
SS_TYPE_D_FORWARD_HEAT, /**< Heat generation for cannons. */
SS_TYPE_D_FORWARD_DAMAGE, /**< Damage done by cannons. */
SS_TYPE_D_FORWARD_FIRERATE, /**< Firerate of cannons. */
SS_TYPE_D_FORWARD_ENERGY, /**< Energy usage of cannons. */
/* Turrets. */
SS_TYPE_D_TURRET_HEAT, /**< Heat generation for turrets. */
SS_TYPE_D_TURRET_DAMAGE, /**< Damage done by turrets. */
SS_TYPE_D_TURRET_TRACKING, /**< Tracking of turrets. */
SS_TYPE_D_TURRET_FIRERATE, /**< Firerate of turrets. */
SS_TYPE_D_TURRET_ENERGY, /**< Energy usage of turrets. */
/* Nebula. */
SS_TYPE_D_NEBULA_ABSORB_SHIELD, /**< Shield nebula resistance. */
SS_TYPE_D_NEBULA_ABSORB_ARMOUR, /**< Armour nebula resistance. */
/* Misc. */
SS_TYPE_D_HEAT_DISSIPATION, /**< Ship heat dissipation. */
SS_TYPE_D_STRESS_DISSIPATION, /**< Ship stress dissipation. */
SS_TYPE_D_CREW, /**< Ship crew. */
SS_TYPE_D_MASS, /**< Ship mass. */
SS_TYPE_D_ENGINE_LIMIT_REL, /**< Modifier for the ship's engine limit. */
/*
* A: Absolute double type data. Should be continuous.
*/
SS_TYPE_A_ENERGY_FLAT, /**< Flat energy modifier (not multiplied). */
SS_TYPE_A_ENERGY_REGEN_FLAT, /**< Flat energy regeneration modifier (not multiplied). */
SS_TYPE_A_CPU_MAX, /**< Maximum CPU modifier. */
SS_TYPE_A_ENGINE_LIMIT, /**< Engine's mass limit. */
/*
* I: Integer type data. Should be continuous.
*/
SS_TYPE_I_HIDDEN_JUMP_DETECT, /**< Hidden jump detection. */
/*
* B: Boolean type data. Should be continuous.
*/
SS_TYPE_B_INSTANT_JUMP, /**< Do not require brake or chargeup to jump. */
SS_TYPE_B_REVERSE_THRUST, /**< Ship slows down rather than turning on reverse. */
SS_TYPE_SENTINEL /**< Sentinel for end of types. */
} ShipStatsType;
/**
* @brief Represents relative ship statistics as a linked list.
*
* Doubles:
* These values are relative so something like -0.15 would be -15%.
*
* Absolute and Integers:
* These values are just absolute values.
*
* Booleans:
* Can only be 1.
*/
typedef struct ShipStatList_ {
struct ShipStatList_ *next; /**< Next pointer. */
int target; /**< Whether or not it affects the target. */
ShipStatsType type; /**< Type of stat. */
union {
double d; /**< Floating point data. */
int i; /**< Integer data. */
} d; /**< Stat data. */
} ShipStatList;
/**
* @brief Represents ship statistics, properties ship can use.
*
* Doubles:
* These are normalized and centered around 1 so they are in the [0:2]
* range, with 1. being default. This value then modulates the stat's base
* value.
* Example:
* 0.7 would lower by 30% the base value.
* 1.2 would increase by 20% the base value.
*
* Absolute and Integers:
* Absolute values in whatever units it's meant to use.
*
* Booleans:
* 1 or 0 values wher 1 indicates property is set.
*/
typedef struct ShipStats_ {
#if 0
/* Corvette type. */
double afterburner_energy; /**< Energy used by afterburner. */
/* Carrier type. */
double fighterbay_cpu; /**< CPU usage by fighter bays. */
double fighterbay_rate; /**< Launch rate of fighter bay. */
#endif
/* General */
double speed_mod; /**< Speed multiplier. */
double turn_mod; /**< Turn multiplier. */
double thrust_mod; /**< Thrust multiplier. */
double cargo_mod; /**< Cargo space multiplier. */
double armour_mod; /**< Armour multiplier. */
double armour_regen_mod; /**< Armour regeneration multiplier. */
double shield_mod; /**< Shield multiplier. */
double shield_regen_mod; /**< Shield regeneration multiplier. */
double energy_mod; /**< Energy multiplier. */
double energy_regen_mod; /**< Energy regeneration multiplier. */
double energy_flat; /**< Energy modifier (flat). */
double energy_usage; /**< Energy usage (flat). */
double cpu_mod; /**< CPU multiplier. */
double cpu_max; /**< CPU modifier. */
/* Freighter-type. */
double jump_delay; /**< Modulates the time that passes during a hyperspace jump. */
double cargo_inertia; /**< Lowers the effect of cargo mass. */
/* Stealth. */
double ew_hide; /**< Electronic warfare hide modifier. */
double ew_detect; /**< Electronic warfare detection modifier. */
double ew_jump_detect; /**< Electronic warfare jump point detection modifier. */
/* Military type. */
double heat_dissipation; /**< Global ship dissipation. */
double stress_dissipation; /**< Global stress dissipation. */
double crew_mod; /**< Relative crew modification. */
double mass_mod; /**< Relative mass modification. */
/* Launchers. */
double launch_rate; /**< Fire rate of launchers. */
double launch_range; /**< Range of launchers. */
double ammo_capacity; /**< Capacity of launchers. */
double launch_lockon; /**< Lock on speed of launchers. */
/* Fighter/Corvette type. */
double fwd_heat; /**< Heat of forward mounts. */
double fwd_damage; /**< Damage of forward mounts. */
double fwd_firerate; /**< Rate of fire of forward mounts. */
double fwd_energy; /**< Consumption rate of forward mounts. */
/* Destroyer/Cruiser type. */
double tur_heat; /**< Heat of turrets. */
double tur_damage; /**< Damage of turrets. */
double tur_tracking; /**< Tracking of turrets. */
double tur_firerate; /**< Rate of fire of turrets. */
double tur_energy; /**< Consumption rate of turrets. */
/* Engine limits. */
double engine_limit_rel; /**< Engine limit modifier. */
double engine_limit; /**< Engine limit. */
/* Misc. */
double nebu_absorb_shield; /**< Shield nebula resistance. */
double nebu_absorb_armour; /**< Armour nebula resistance. */
int misc_instant_jump; /**< Do not require brake or chargeup to jump. */
int misc_reverse_thrust; /**< Slows down the ship instead of turning it around. */
int misc_hidden_jump_detect; /**< Degree of hidden jump detection. */
} ShipStats;
/*
* Safety.
*/
int ss_check (void);
/*
* Loading.
*/
ShipStatList* ss_listFromXML( xmlNodePtr node );
void ss_free( ShipStatList *ll );
/*
* Manipulation
*/
int ss_statsInit( ShipStats *stats );
int ss_statsModSingle( ShipStats *stats, const ShipStatList* list, const ShipStats *amount );
int ss_statsModFromList( ShipStats *stats, const ShipStatList* list, const ShipStats *amount );
/*
* Lookup.
*/
const char* ss_nameFromType( ShipStatsType type );
size_t ss_offsetFromType( ShipStatsType type );
ShipStatsType ss_typeFromName( const char *name );
int ss_statsListDesc( const ShipStatList *ll, char *buf, int len, int newline );
int ss_statsDesc( const ShipStats *s, char *buf, int len, int newline );
int ss_csv( const ShipStats *s, char *buf, int len );
#endif /* SHIPSTATS_H */