File: WeaponDef.h

package info (click to toggle)
spring 104.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 47,512 kB
  • sloc: cpp: 391,093; ansic: 79,943; python: 12,356; java: 12,201; awk: 5,889; sh: 1,826; xml: 655; makefile: 486; perl: 405; php: 211; objc: 194; sed: 2
file content (429 lines) | stat: -rw-r--r-- 11,601 bytes parent folder | download | duplicates (6)
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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#ifndef _WEAPON_DEF_H
#define _WEAPON_DEF_H

#include <map>

#include "DamageArray.h"

#include "System/creg/creg_cond.h"
#include "System/float3.h"


namespace springLegacyAI {

struct WeaponDef
{
private:
	CR_DECLARE_STRUCT(WeaponDef)

public:
	WeaponDef()
		: range(0.0f)
		, heightmod(0.0f)
		, accuracy(0.0f)
		, sprayAngle(0.0f)
		, movingAccuracy(0.0f)
		, ownerExpAccWeight(0.0f)
		, targetMoveError(0.0f)
		, leadLimit(0.0f)
		, leadBonus(0.0f)
		, predictBoost(0.0f)
		, areaOfEffect(0.0f)
		, noSelfDamage(false)
		, fireStarter(0.0f)
		, edgeEffectiveness(0.0f)
		, size(0.0f)
		, sizeGrowth(0.0f)
		, collisionSize(0.0f)
		, salvosize(0)
		, salvodelay(0.0f)
		, reload(0.0f)
		, beamtime(0.0f)
		, beamburst(false)
		, waterBounce(false)
		, groundBounce(false)
		, bounceRebound(0.0f)
		, bounceSlip(0.0f)
		, numBounce(0)
		, maxAngle(0.0f)
		, uptime(0.0f)
		, flighttime(0)
		, metalcost(0.0f)
		, energycost(0.0f)
		, projectilespershot(0)
		, id(0)
		, tdfId(0)
		, turret(false)
		, onlyForward(false)
		, fixedLauncher(false)
		, waterweapon(false)
		, fireSubmersed(false)
		, submissile(false)
		, tracks(false)
		, dropped(false)
		, paralyzer(false)
		, impactOnly(false)
		, noAutoTarget(false)
		, manualfire(false)
		, interceptor(0)
		, targetable(0)
		, stockpile(false)
		, coverageRange(0.0f)
		, stockpileTime(0.0f)
		, intensity(0.0f)
		, thickness(0.0f)
		, laserflaresize(0.0f)
		, corethickness(0.0f)
		, duration(0.0f)
		, lodDistance(0)
		, falloffRate(0.0f)
		, graphicsType(0)
		, soundTrigger(false)
		, selfExplode(false)
		, gravityAffected(false)
		, highTrajectory(0)
		, myGravity(0.0f)
		, noExplode(false)
		, startvelocity(0.0f)
		, weaponacceleration(0.0f)
		, turnrate(0.0f)
		, maxvelocity(0.0f)
		, projectilespeed(0.0f)
		, explosionSpeed(0.0f)
		, onlyTargetCategory(0)
		, wobble(0.0f)
		, dance(0.0f)
		, trajectoryHeight(0.0f)
		, largeBeamLaser(false)
		, isShield(false)
		, shieldRepulser(false)
		, smartShield(false)
		, exteriorShield(false)
		, visibleShield(false)
		, visibleShieldRepulse(false)
		, visibleShieldHitFrames(0)
		, shieldEnergyUse(0.0f)
		, shieldRadius(0.0f)
		, shieldForce(0.0f)
		, shieldMaxSpeed(0.0f)
		, shieldPower(0.0f)
		, shieldPowerRegen(0.0f)
		, shieldPowerRegenEnergy(0.0f)
		, shieldStartingPower(0.0f)
		, shieldRechargeDelay(0.0f)
		, shieldGoodColor(ZeroVector)
		, shieldBadColor(ZeroVector)
		, shieldAlpha(0.0f)
		, shieldInterceptType(0)
		, interceptedByShieldType(0)
		, avoidFriendly(false)
		, avoidFeature(false)
		, avoidNeutral(false)
		, targetBorder(0.0f)
		, cylinderTargetting(0.0f)
		, minIntensity(0.0f)
		, heightBoostFactor(0.0f)
		, proximityPriority(0.0f)
		, collisionFlags(0)
		, sweepFire(false)
		, canAttackGround(false)
		, cameraShake(0.0f)
		, dynDamageExp(0.0f)
		, dynDamageMin(0.0f)
		, dynDamageRange(0.0f)
		, dynDamageInverted(false)
	{}

	WeaponDef(DamageArray damages)
		: range(0.0f)
		, heightmod(0.0f)
		, accuracy(0.0f)
		, sprayAngle(0.0f)
		, movingAccuracy(0.0f)
		, ownerExpAccWeight(0.0f)
		, targetMoveError(0.0f)
		, leadLimit(0.0f)
		, leadBonus(0.0f)
		, predictBoost(0.0f)
		, damages(damages)
		, areaOfEffect(0.0f)
		, noSelfDamage(false)
		, fireStarter(0.0f)
		, edgeEffectiveness(0.0f)
		, size(0.0f)
		, sizeGrowth(0.0f)
		, collisionSize(0.0f)
		, salvosize(0)
		, salvodelay(0.0f)
		, reload(0.0f)
		, beamtime(0.0f)
		, beamburst(false)
		, waterBounce(false)
		, groundBounce(false)
		, bounceRebound(0.0f)
		, bounceSlip(0.0f)
		, numBounce(0)
		, maxAngle(0.0f)
		, uptime(0.0f)
		, flighttime(0)
		, metalcost(0.0f)
		, energycost(0.0f)
		, projectilespershot(0)
		, id(0)
		, tdfId(0)
		, turret(false)
		, onlyForward(false)
		, fixedLauncher(false)
		, waterweapon(false)
		, fireSubmersed(false)
		, submissile(false)
		, tracks(false)
		, dropped(false)
		, paralyzer(false)
		, impactOnly(false)
		, noAutoTarget(false)
		, manualfire(false)
		, interceptor(0)
		, targetable(0)
		, stockpile(false)
		, coverageRange(0.0f)
		, stockpileTime(0.0f)
		, intensity(0.0f)
		, thickness(0.0f)
		, laserflaresize(0.0f)
		, corethickness(0.0f)
		, duration(0.0f)
		, lodDistance(0)
		, falloffRate(0.0f)
		, graphicsType(0)
		, soundTrigger(false)
		, selfExplode(false)
		, gravityAffected(false)
		, highTrajectory(0)
		, myGravity(0.0f)
		, noExplode(false)
		, startvelocity(0.0f)
		, weaponacceleration(0.0f)
		, turnrate(0.0f)
		, maxvelocity(0.0f)
		, projectilespeed(0.0f)
		, explosionSpeed(0.0f)
		, onlyTargetCategory(0)
		, wobble(0.0f)
		, dance(0.0f)
		, trajectoryHeight(0.0f)
		, largeBeamLaser(false)
		, isShield(false)
		, shieldRepulser(false)
		, smartShield(false)
		, exteriorShield(false)
		, visibleShield(false)
		, visibleShieldRepulse(false)
		, visibleShieldHitFrames(0)
		, shieldEnergyUse(0.0f)
		, shieldRadius(0.0f)
		, shieldForce(0.0f)
		, shieldMaxSpeed(0.0f)
		, shieldPower(0.0f)
		, shieldPowerRegen(0.0f)
		, shieldPowerRegenEnergy(0.0f)
		, shieldStartingPower(0.0f)
		, shieldRechargeDelay(0.0f)
		, shieldGoodColor(ZeroVector)
		, shieldBadColor(ZeroVector)
		, shieldAlpha(0.0f)
		, shieldInterceptType(0)
		, interceptedByShieldType(0)
		, avoidFriendly(false)
		, avoidFeature(false)
		, avoidNeutral(false)
		, targetBorder(0.0f)
		, cylinderTargetting(0.0f)
		, minIntensity(0.0f)
		, heightBoostFactor(0.0f)
		, proximityPriority(0.0f)
		, collisionFlags(0)
		, sweepFire(false)
		, canAttackGround(false)
		, cameraShake(0.0f)
		, dynDamageExp(0.0f)
		, dynDamageMin(0.0f)
		, dynDamageRange(0.0f)
		, dynDamageInverted(false)
	{}

	~WeaponDef() {}

	std::string name;
	std::string type;
	std::string description;
	std::string filename;
	std::string cegTag;        ///< tag of CEG that projectiles fired by this weapon should use

	float range;
	float heightmod;
	float accuracy;            ///< inaccuracy of whole burst
	float sprayAngle;          ///< inaccuracy of individual shots inside burst
	float movingAccuracy;      ///< inaccuracy while owner moving
	float ownerExpAccWeight;   ///< if 0, accuracy is not increased with owner experience (max. 1)
	float targetMoveError;     ///< fraction of targets move speed that is used as error offset
	float leadLimit;           ///< maximum distance the weapon will lead the target
	float leadBonus;           ///< factor for increasing the leadLimit with experience
	float predictBoost;        ///< replaces hardcoded behaviour for burnblow cannons

	DamageArray damages;
	float areaOfEffect;
	bool noSelfDamage;
	float fireStarter;
	float edgeEffectiveness;
	float size;
	float sizeGrowth;
	float collisionSize;

	int salvosize;
	float salvodelay;
	float reload;
	float beamtime;
	bool beamburst;

	bool waterBounce;
	bool groundBounce;
	float bounceRebound;
	float bounceSlip;
	int numBounce;

	float maxAngle;

	float uptime;
	int flighttime;

	float metalcost;
	float energycost;

	int projectilespershot;

	int id;
	int tdfId;                  ///< the id= tag in the tdf

	bool turret;
	bool onlyForward;
	bool fixedLauncher;
	bool waterweapon;
	bool fireSubmersed;
	bool submissile;            ///< Lets a torpedo travel above water like it does below water
	bool tracks;
	bool dropped;
	bool paralyzer;             ///< weapon will only paralyze not do real damage
	bool impactOnly;            ///< The weapon damages by impacting, not by exploding

	bool noAutoTarget;          ///< cant target stuff (for antinuke,dgun)
	bool manualfire;            ///< use dgun button
	int interceptor;            ///< anti nuke
	int targetable;             ///< nuke (can be shot by interceptor)
	bool stockpile;
	float coverageRange;        ///< range of anti nuke

	float stockpileTime;        ///< builtime of a missile

	float intensity;
	float thickness;
	float laserflaresize;
	float corethickness;
	float duration;
	int   lodDistance;
	float falloffRate;

	int graphicsType;
	bool soundTrigger;

	bool selfExplode;
	bool gravityAffected;
	int highTrajectory;         ///< Per-weapon high traj setting, 0=low, 1=high, 2=unit
	float myGravity;
	bool noExplode;
	float startvelocity;
	float weaponacceleration;
	float turnrate;
	float maxvelocity;

	float projectilespeed;
	float explosionSpeed;

	unsigned int onlyTargetCategory;

	float wobble;             ///< how much the missile will wobble around its course
	float dance;              ///< how much the missile will dance
	float trajectoryHeight;   ///< how high trajectory missiles will try to fly in

	bool largeBeamLaser;

	bool isShield;                   // if the weapon is a shield rather than a weapon
	bool shieldRepulser;             // if the weapon should be repulsed or absorbed
	bool smartShield;                // only affect enemy projectiles
	bool exteriorShield;             // only affect stuff coming from outside shield radius
	bool visibleShield;              // if the shield should be graphically shown
	bool visibleShieldRepulse;       // if a small graphic should be shown at each repulse
	int  visibleShieldHitFrames;     // number of frames to draw the shield after it has been hit
	float shieldEnergyUse;           // energy use per shot or per second depending on projectile
	float shieldRadius;              // size of shielded area
	float shieldForce;               // shield acceleration on plasma stuff
	float shieldMaxSpeed;            // max speed shield can repulse plasma like weapons with
	float shieldPower;               // how much damage the shield can reflect (0=infinite)
	float shieldPowerRegen;          // how fast the power regenerates per second
	float shieldPowerRegenEnergy;    // how much energy is needed to regenerate power per second
	float shieldStartingPower;       // how much power the shield has when first created
	int   shieldRechargeDelay;       // number of frames to delay recharging by after each hit
	float3 shieldGoodColor;          // color when shield at full power
	float3 shieldBadColor;           // color when shield is empty
	float shieldAlpha;               // shield alpha value

	unsigned int shieldInterceptType;      // type of shield (bitfield)
	unsigned int interceptedByShieldType;  // weapon can be affected by shields where (shieldInterceptType & interceptedByShieldType) is not zero

	bool avoidFriendly;     // if true, try to avoid friendly units while aiming
	bool avoidFeature;      // if true, try to avoid features while aiming
	bool avoidNeutral;      // if true, try to avoid neutral units while aiming
	/**
	 * If nonzero, targetting units will TryTarget at the edge of collision sphere
	 * (radius*tag value, [-1;1]) instead of its centre.
	 */
	float targetBorder;
	/**
	 * If greater than 0, the range will be checked in a cylinder
	 * (height=range*cylinderTargetting) instead of a sphere.
	 */
	float cylinderTargetting;
	/**
	 * For beam-lasers only - always hit with some minimum intensity
	 * (a damage coeffcient normally dependent on distance).
	 * Do not confuse this with the intensity tag, it i completely unrelated.
	 */
	float minIntensity;
	/**
	 * Controls cannon range height boost.
	 *
	 * default: -1: automatically calculate a more or less sane value
	 */
	float heightBoostFactor;
	float proximityPriority;     // multiplier for the distance to the target for priority calculations

	unsigned int collisionFlags;

	bool sweepFire;
	bool canAttackGround;

	float cameraShake;

	float dynDamageExp;
	float dynDamageMin;
	float dynDamageRange;
	bool dynDamageInverted;

	std::map<std::string, std::string> customParams;
};

} // namespace springLegacyAI

#endif // _WEAPON_DEF_H