1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
2 
3 #ifndef _WEAPON_DEF_H
4 #define _WEAPON_DEF_H
5 
6 #include <map>
7 
8 #include "DamageArray.h"
9 
10 #include "System/creg/creg_cond.h"
11 #include "System/float3.h"
12 
13 
14 namespace springLegacyAI {
15 
16 struct WeaponDef
17 {
18 private:
CR_DECLARE_STRUCTWeaponDef19 	CR_DECLARE_STRUCT(WeaponDef)
20 
21 public:
22 	WeaponDef()
23 		: range(0.0f)
24 		, heightmod(0.0f)
25 		, accuracy(0.0f)
26 		, sprayAngle(0.0f)
27 		, movingAccuracy(0.0f)
28 		, ownerExpAccWeight(0.0f)
29 		, targetMoveError(0.0f)
30 		, leadLimit(0.0f)
31 		, leadBonus(0.0f)
32 		, predictBoost(0.0f)
33 		, areaOfEffect(0.0f)
34 		, noSelfDamage(false)
35 		, fireStarter(0.0f)
36 		, edgeEffectiveness(0.0f)
37 		, size(0.0f)
38 		, sizeGrowth(0.0f)
39 		, collisionSize(0.0f)
40 		, salvosize(0)
41 		, salvodelay(0.0f)
42 		, reload(0.0f)
43 		, beamtime(0.0f)
44 		, beamburst(false)
45 		, waterBounce(false)
46 		, groundBounce(false)
47 		, bounceRebound(0.0f)
48 		, bounceSlip(0.0f)
49 		, numBounce(0)
50 		, maxAngle(0.0f)
51 		, uptime(0.0f)
52 		, flighttime(0)
53 		, metalcost(0.0f)
54 		, energycost(0.0f)
55 		, projectilespershot(0)
56 		, id(0)
57 		, tdfId(0)
58 		, turret(false)
59 		, onlyForward(false)
60 		, fixedLauncher(false)
61 		, waterweapon(false)
62 		, fireSubmersed(false)
63 		, submissile(false)
64 		, tracks(false)
65 		, dropped(false)
66 		, paralyzer(false)
67 		, impactOnly(false)
68 		, noAutoTarget(false)
69 		, manualfire(false)
70 		, interceptor(0)
71 		, targetable(0)
72 		, stockpile(false)
73 		, coverageRange(0.0f)
74 		, stockpileTime(0.0f)
75 		, intensity(0.0f)
76 		, thickness(0.0f)
77 		, laserflaresize(0.0f)
78 		, corethickness(0.0f)
79 		, duration(0.0f)
80 		, lodDistance(0)
81 		, falloffRate(0.0f)
82 		, graphicsType(0)
83 		, soundTrigger(false)
84 		, selfExplode(false)
85 		, gravityAffected(false)
86 		, highTrajectory(0)
87 		, myGravity(0.0f)
88 		, noExplode(false)
89 		, startvelocity(0.0f)
90 		, weaponacceleration(0.0f)
91 		, turnrate(0.0f)
92 		, maxvelocity(0.0f)
93 		, projectilespeed(0.0f)
94 		, explosionSpeed(0.0f)
95 		, onlyTargetCategory(0)
96 		, wobble(0.0f)
97 		, dance(0.0f)
98 		, trajectoryHeight(0.0f)
99 		, largeBeamLaser(false)
100 		, isShield(false)
101 		, shieldRepulser(false)
102 		, smartShield(false)
103 		, exteriorShield(false)
104 		, visibleShield(false)
105 		, visibleShieldRepulse(false)
106 		, visibleShieldHitFrames(0)
107 		, shieldEnergyUse(0.0f)
108 		, shieldRadius(0.0f)
109 		, shieldForce(0.0f)
110 		, shieldMaxSpeed(0.0f)
111 		, shieldPower(0.0f)
112 		, shieldPowerRegen(0.0f)
113 		, shieldPowerRegenEnergy(0.0f)
114 		, shieldStartingPower(0.0f)
115 		, shieldRechargeDelay(0.0f)
116 		, shieldGoodColor(ZeroVector)
117 		, shieldBadColor(ZeroVector)
118 		, shieldAlpha(0.0f)
119 		, shieldInterceptType(0)
120 		, interceptedByShieldType(0)
121 		, avoidFriendly(false)
122 		, avoidFeature(false)
123 		, avoidNeutral(false)
124 		, targetBorder(0.0f)
125 		, cylinderTargetting(0.0f)
126 		, minIntensity(0.0f)
127 		, heightBoostFactor(0.0f)
128 		, proximityPriority(0.0f)
129 		, collisionFlags(0)
130 		, sweepFire(false)
131 		, canAttackGround(false)
132 		, cameraShake(0.0f)
133 		, dynDamageExp(0.0f)
134 		, dynDamageMin(0.0f)
135 		, dynDamageRange(0.0f)
136 		, dynDamageInverted(false)
137 	{}
138 
WeaponDefWeaponDef139 	WeaponDef(DamageArray damages)
140 		: range(0.0f)
141 		, heightmod(0.0f)
142 		, accuracy(0.0f)
143 		, sprayAngle(0.0f)
144 		, movingAccuracy(0.0f)
145 		, ownerExpAccWeight(0.0f)
146 		, targetMoveError(0.0f)
147 		, leadLimit(0.0f)
148 		, leadBonus(0.0f)
149 		, predictBoost(0.0f)
150 		, damages(damages)
151 		, areaOfEffect(0.0f)
152 		, noSelfDamage(false)
153 		, fireStarter(0.0f)
154 		, edgeEffectiveness(0.0f)
155 		, size(0.0f)
156 		, sizeGrowth(0.0f)
157 		, collisionSize(0.0f)
158 		, salvosize(0)
159 		, salvodelay(0.0f)
160 		, reload(0.0f)
161 		, beamtime(0.0f)
162 		, beamburst(false)
163 		, waterBounce(false)
164 		, groundBounce(false)
165 		, bounceRebound(0.0f)
166 		, bounceSlip(0.0f)
167 		, numBounce(0)
168 		, maxAngle(0.0f)
169 		, uptime(0.0f)
170 		, flighttime(0)
171 		, metalcost(0.0f)
172 		, energycost(0.0f)
173 		, projectilespershot(0)
174 		, id(0)
175 		, tdfId(0)
176 		, turret(false)
177 		, onlyForward(false)
178 		, fixedLauncher(false)
179 		, waterweapon(false)
180 		, fireSubmersed(false)
181 		, submissile(false)
182 		, tracks(false)
183 		, dropped(false)
184 		, paralyzer(false)
185 		, impactOnly(false)
186 		, noAutoTarget(false)
187 		, manualfire(false)
188 		, interceptor(0)
189 		, targetable(0)
190 		, stockpile(false)
191 		, coverageRange(0.0f)
192 		, stockpileTime(0.0f)
193 		, intensity(0.0f)
194 		, thickness(0.0f)
195 		, laserflaresize(0.0f)
196 		, corethickness(0.0f)
197 		, duration(0.0f)
198 		, lodDistance(0)
199 		, falloffRate(0.0f)
200 		, graphicsType(0)
201 		, soundTrigger(false)
202 		, selfExplode(false)
203 		, gravityAffected(false)
204 		, highTrajectory(0)
205 		, myGravity(0.0f)
206 		, noExplode(false)
207 		, startvelocity(0.0f)
208 		, weaponacceleration(0.0f)
209 		, turnrate(0.0f)
210 		, maxvelocity(0.0f)
211 		, projectilespeed(0.0f)
212 		, explosionSpeed(0.0f)
213 		, onlyTargetCategory(0)
214 		, wobble(0.0f)
215 		, dance(0.0f)
216 		, trajectoryHeight(0.0f)
217 		, largeBeamLaser(false)
218 		, isShield(false)
219 		, shieldRepulser(false)
220 		, smartShield(false)
221 		, exteriorShield(false)
222 		, visibleShield(false)
223 		, visibleShieldRepulse(false)
224 		, visibleShieldHitFrames(0)
225 		, shieldEnergyUse(0.0f)
226 		, shieldRadius(0.0f)
227 		, shieldForce(0.0f)
228 		, shieldMaxSpeed(0.0f)
229 		, shieldPower(0.0f)
230 		, shieldPowerRegen(0.0f)
231 		, shieldPowerRegenEnergy(0.0f)
232 		, shieldStartingPower(0.0f)
233 		, shieldRechargeDelay(0.0f)
234 		, shieldGoodColor(ZeroVector)
235 		, shieldBadColor(ZeroVector)
236 		, shieldAlpha(0.0f)
237 		, shieldInterceptType(0)
238 		, interceptedByShieldType(0)
239 		, avoidFriendly(false)
240 		, avoidFeature(false)
241 		, avoidNeutral(false)
242 		, targetBorder(0.0f)
243 		, cylinderTargetting(0.0f)
244 		, minIntensity(0.0f)
245 		, heightBoostFactor(0.0f)
246 		, proximityPriority(0.0f)
247 		, collisionFlags(0)
248 		, sweepFire(false)
249 		, canAttackGround(false)
250 		, cameraShake(0.0f)
251 		, dynDamageExp(0.0f)
252 		, dynDamageMin(0.0f)
253 		, dynDamageRange(0.0f)
254 		, dynDamageInverted(false)
255 	{}
256 
~WeaponDefWeaponDef257 	~WeaponDef() {}
258 
259 	std::string name;
260 	std::string type;
261 	std::string description;
262 	std::string filename;
263 	std::string cegTag;        ///< tag of CEG that projectiles fired by this weapon should use
264 
265 	float range;
266 	float heightmod;
267 	float accuracy;            ///< inaccuracy of whole burst
268 	float sprayAngle;          ///< inaccuracy of individual shots inside burst
269 	float movingAccuracy;      ///< inaccuracy while owner moving
270 	float ownerExpAccWeight;   ///< if 0, accuracy is not increased with owner experience (max. 1)
271 	float targetMoveError;     ///< fraction of targets move speed that is used as error offset
272 	float leadLimit;           ///< maximum distance the weapon will lead the target
273 	float leadBonus;           ///< factor for increasing the leadLimit with experience
274 	float predictBoost;        ///< replaces hardcoded behaviour for burnblow cannons
275 
276 	DamageArray damages;
277 	float areaOfEffect;
278 	bool noSelfDamage;
279 	float fireStarter;
280 	float edgeEffectiveness;
281 	float size;
282 	float sizeGrowth;
283 	float collisionSize;
284 
285 	int salvosize;
286 	float salvodelay;
287 	float reload;
288 	float beamtime;
289 	bool beamburst;
290 
291 	bool waterBounce;
292 	bool groundBounce;
293 	float bounceRebound;
294 	float bounceSlip;
295 	int numBounce;
296 
297 	float maxAngle;
298 
299 	float uptime;
300 	int flighttime;
301 
302 	float metalcost;
303 	float energycost;
304 
305 	int projectilespershot;
306 
307 	int id;
308 	int tdfId;                  ///< the id= tag in the tdf
309 
310 	bool turret;
311 	bool onlyForward;
312 	bool fixedLauncher;
313 	bool waterweapon;
314 	bool fireSubmersed;
315 	bool submissile;            ///< Lets a torpedo travel above water like it does below water
316 	bool tracks;
317 	bool dropped;
318 	bool paralyzer;             ///< weapon will only paralyze not do real damage
319 	bool impactOnly;            ///< The weapon damages by impacting, not by exploding
320 
321 	bool noAutoTarget;          ///< cant target stuff (for antinuke,dgun)
322 	bool manualfire;            ///< use dgun button
323 	int interceptor;            ///< anti nuke
324 	int targetable;             ///< nuke (can be shot by interceptor)
325 	bool stockpile;
326 	float coverageRange;        ///< range of anti nuke
327 
328 	float stockpileTime;        ///< builtime of a missile
329 
330 	float intensity;
331 	float thickness;
332 	float laserflaresize;
333 	float corethickness;
334 	float duration;
335 	int   lodDistance;
336 	float falloffRate;
337 
338 	int graphicsType;
339 	bool soundTrigger;
340 
341 	bool selfExplode;
342 	bool gravityAffected;
343 	int highTrajectory;         ///< Per-weapon high traj setting, 0=low, 1=high, 2=unit
344 	float myGravity;
345 	bool noExplode;
346 	float startvelocity;
347 	float weaponacceleration;
348 	float turnrate;
349 	float maxvelocity;
350 
351 	float projectilespeed;
352 	float explosionSpeed;
353 
354 	unsigned int onlyTargetCategory;
355 
356 	float wobble;             ///< how much the missile will wobble around its course
357 	float dance;              ///< how much the missile will dance
358 	float trajectoryHeight;   ///< how high trajectory missiles will try to fly in
359 
360 	bool largeBeamLaser;
361 
362 	bool isShield;                   // if the weapon is a shield rather than a weapon
363 	bool shieldRepulser;             // if the weapon should be repulsed or absorbed
364 	bool smartShield;                // only affect enemy projectiles
365 	bool exteriorShield;             // only affect stuff coming from outside shield radius
366 	bool visibleShield;              // if the shield should be graphically shown
367 	bool visibleShieldRepulse;       // if a small graphic should be shown at each repulse
368 	int  visibleShieldHitFrames;     // number of frames to draw the shield after it has been hit
369 	float shieldEnergyUse;           // energy use per shot or per second depending on projectile
370 	float shieldRadius;              // size of shielded area
371 	float shieldForce;               // shield acceleration on plasma stuff
372 	float shieldMaxSpeed;            // max speed shield can repulse plasma like weapons with
373 	float shieldPower;               // how much damage the shield can reflect (0=infinite)
374 	float shieldPowerRegen;          // how fast the power regenerates per second
375 	float shieldPowerRegenEnergy;    // how much energy is needed to regenerate power per second
376 	float shieldStartingPower;       // how much power the shield has when first created
377 	int   shieldRechargeDelay;       // number of frames to delay recharging by after each hit
378 	float3 shieldGoodColor;          // color when shield at full power
379 	float3 shieldBadColor;           // color when shield is empty
380 	float shieldAlpha;               // shield alpha value
381 
382 	unsigned int shieldInterceptType;      // type of shield (bitfield)
383 	unsigned int interceptedByShieldType;  // weapon can be affected by shields where (shieldInterceptType & interceptedByShieldType) is not zero
384 
385 	bool avoidFriendly;     // if true, try to avoid friendly units while aiming
386 	bool avoidFeature;      // if true, try to avoid features while aiming
387 	bool avoidNeutral;      // if true, try to avoid neutral units while aiming
388 	/**
389 	 * If nonzero, targetting units will TryTarget at the edge of collision sphere
390 	 * (radius*tag value, [-1;1]) instead of its centre.
391 	 */
392 	float targetBorder;
393 	/**
394 	 * If greater than 0, the range will be checked in a cylinder
395 	 * (height=range*cylinderTargetting) instead of a sphere.
396 	 */
397 	float cylinderTargetting;
398 	/**
399 	 * For beam-lasers only - always hit with some minimum intensity
400 	 * (a damage coeffcient normally dependent on distance).
401 	 * Do not confuse this with the intensity tag, it i completely unrelated.
402 	 */
403 	float minIntensity;
404 	/**
405 	 * Controls cannon range height boost.
406 	 *
407 	 * default: -1: automatically calculate a more or less sane value
408 	 */
409 	float heightBoostFactor;
410 	float proximityPriority;     // multiplier for the distance to the target for priority calculations
411 
412 	unsigned int collisionFlags;
413 
414 	bool sweepFire;
415 	bool canAttackGround;
416 
417 	float cameraShake;
418 
419 	float dynDamageExp;
420 	float dynDamageMin;
421 	float dynDamageRange;
422 	bool dynDamageInverted;
423 
424 	std::map<std::string, std::string> customParams;
425 };
426 
427 } // namespace springLegacyAI
428 
429 #endif // _WEAPON_DEF_H
430