Gamedev:WeaponDefs: Difference between revisions
→shield: interceptType |
m Updated targetmoveerror description with https://springrts.com/phpbb/viewtopic.php?t=2234 |
||
| (130 intermediate revisions by 16 users not shown) | |||
| Line 1: | Line 1: | ||
[[Gamedev:Main|Development]] < [[Gamedev:Main]] < {{FULLPAGENAME}} | |||
==Location== | ==Location== | ||
WeaponDef files are .lua files stored in the <code>Weapons/</code> directory of a Spring Game. Alternatively they can be integrated into [[ | WeaponDef files are .lua files stored in the <code>Weapons/</code> directory of a Spring Game. Alternatively they can be integrated into [[Gamedev:UnitDefs|UnitDefs]]. | ||
==Purpose== | ==Purpose== | ||
WeaponDef files have one purpose; to define the properties of weapons. They are the main description file for what attributes your weapon should have and how it should behave. | WeaponDef files have one purpose; to define the properties of weapons. They are the main description file for what attributes your weapon should have and how it should behave. Since version 100.0, Spring will record a warning whenever it finds an unknown tag. | ||
==Source== | ==Source== | ||
The engine source code which loads the tags from these files is viewable here:{{sourcelink|file=rts/Sim/Weapons/ | The engine source code which loads the tags from these files is viewable here: | ||
* {{sourcelink|file=rts/Sim/Weapons/WeaponDef.cpp}} | |||
==Data Types== | ==Data Types== | ||
{{DataTypes}} | |||
==Details== | ==Details== | ||
| Line 23: | Line 22: | ||
It is usual to name the returned WeaponDef table the internal <code>weaponName</code> desired for the weapon. | It is usual to name the returned WeaponDef table the internal <code>weaponName</code> desired for the weapon. | ||
=== | ===Common=== | ||
The following tags | The following tags are common to all or at least a majority of '''WeaponTypes''', depending on the tag. | ||
====General==== | ====General==== | ||
| Line 43: | Line 42: | ||
* [[#MissileLauncher|MissileLauncher]] | * [[#MissileLauncher|MissileLauncher]] | ||
* [[#Rifle|Rifle]] | * [[#Rifle|Rifle]] | ||
* [[#Shield|Shield]] | * [[#Shield (WeaponType)|Shield]] | ||
* [[#StarburstLauncher|StarburstLauncher]] | * [[#StarburstLauncher|StarburstLauncher]] | ||
* [[#TorpedoLauncher|TorpedoLauncher]] | * [[#TorpedoLauncher|TorpedoLauncher]] | ||
| Line 69: | Line 68: | ||
|type = bool | |type = bool | ||
|default = false | |default = false | ||
|description = Does the weapon only deal damage through direct hits and not 'splash' damage through | |description = Does the weapon only deal damage through direct hits and not 'splash' damage through {{taglink|areaOfEffect}}?}} | ||
{{tag | {{tag | ||
| Line 75: | Line 74: | ||
|type = bool | |type = bool | ||
|default = false | |default = false | ||
|description = Does the weapon explode on impact with a target or continue through? Note that these weapons will do damage every single frame they are inside the [[ | |description = Does the weapon explode on impact with a target or continue through? Note that these weapons will do damage every single frame they are inside the [[Gamedev:CollisionVolumes|collision volume]] of an object, underground or under water, massively multiplying their damage.}} | ||
{{tag | {{tag | ||
| Line 81: | Line 80: | ||
|type = bool | |type = bool | ||
|default = false | |default = false | ||
|lua = selfExplode | |||
|description = Does the weapon explode when it reaches its maximum range or continue on its path? The name is an [[OTAism]].}} | |description = Does the weapon explode when it reaches its maximum range or continue on its path? The name is an [[OTAism]].}} | ||
| Line 87: | Line 87: | ||
|type = float | |type = float | ||
|default = 10.0 | |default = 10.0 | ||
|description = The maximum range in [[ | |description = The maximum range in [[elmo]]s that the weapon can fire at.}} | ||
{{tag | {{tag | ||
| Line 93: | Line 93: | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = The velocity in [[ | |description = The velocity in [[elmo]]s per second of the weapon projectile. Since 99.0 <code>maxVelocity</code> is a synonym.}} | ||
{{tag | {{tag | ||
| Line 105: | Line 105: | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = Metal used per shot. If the specified amount is not available, the weapon cannot be fired. Can also be used to specify how much a | |description = Metal used per shot. If the specified amount is not available, the weapon cannot be fired. Can also be used to specify how much a {{taglink|stockpile}} weapon will cost to build.}} | ||
{{tag | {{tag | ||
| Line 111: | Line 111: | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = Energy used per shot. If the specified amount is not available, the weapon cannot be fired. Can also be used to specify how much a | |description = Energy used per shot. If the specified amount is not available, the weapon cannot be fired. Can also be used to specify how much a {{taglink|stockpile}} weapon will cost to build.}} | ||
{{tag | {{tag | ||
| Line 135: | Line 135: | ||
|type = bool | |type = bool | ||
|default = false | |default = false | ||
|description = Does each round of the weapon have to be built and stockpiled by the player?}} | |description = Does each round of the weapon have to be built and stockpiled by the player? Will only correctly function for the first of each stockpiled weapons a unit has.}} | ||
{{tag | {{tag | ||
| Line 146: | Line 146: | ||
|name = interceptedByShieldType | |name = interceptedByShieldType | ||
|type = int | |type = int | ||
|default = | |default = Depends on {{taglink|weaponType}} | ||
|description = [http://en.wikipedia.org/wiki/Mask_(computing) Bitmask] representing the types of shields that can intercept this weapon. Each digit of binary that is set to one means that a shield with the corresponding digit will intercept this weapon. The defaults are as follows: | |description = [http://en.wikipedia.org/wiki/Mask_(computing) Bitmask] representing the types of shields that can intercept this weapon. Each digit of binary that is set to one means that a shield with the corresponding digit in its {{taglink|interceptType}} will intercept this weapon. A value of <code>0</code> means that no shields will intercept the weapon. The defaults are as follows: | ||
* <code>0</code> - [[#DGun]] | |||
* <code>1</code> - [[#Cannon]] and [[#EmgCannon]] | * <code>1</code> - [[#Cannon]] and [[#EmgCannon]] | ||
* <code>2</code> - [[#LaserCannon]] and [[#BeamLaser]] | * <code>2</code> - [[#LaserCannon]] and [[#BeamLaser]] | ||
| Line 160: | Line 161: | ||
====Collision & Avoidance==== | ====Collision & Avoidance==== | ||
{{tag | |||
|name = avoidGround | |||
|type = bool | |||
|default = true | |||
|description = Should the weapon avoid firing if terrain blocks the line of fire?}} | |||
{{tag | {{tag | ||
| Line 183: | Line 190: | ||
|type = bool | |type = bool | ||
|default = true | |default = true | ||
|lua = noEnemyCollide | |||
|description = Does the weapon projectile collide with enemy units or pass through?}} | |description = Does the weapon projectile collide with enemy units or pass through?}} | ||
| Line 189: | Line 197: | ||
|type = bool | |type = bool | ||
|default = true | |default = true | ||
|lua = noFriendlyCollide | |||
|description = Does the weapon projectile collide with friendly units or pass through?}} | |description = Does the weapon projectile collide with friendly units or pass through?}} | ||
{{tag | |||
|name = collideFirebase | |||
|type = bool | |||
|default = false | |||
|lua = noFirebaseCollide | |||
|description = Does the weapon projectile collide with friendly firebase units the owner is loaded onto, or pass through?}} | |||
{{tag | {{tag | ||
| Line 195: | Line 211: | ||
|type = bool | |type = bool | ||
|default = true | |default = true | ||
|lua = noFeatureCollide | |||
|description = Does the weapon projectile collide with static map features or pass through?}} | |description = Does the weapon projectile collide with static map features or pass through?}} | ||
| Line 201: | Line 218: | ||
|type = bool | |type = bool | ||
|default = true | |default = true | ||
|lua = noNeutralCollide | |||
|description = Does the weapon projectile collide with neutral units or pass through?}} | |description = Does the weapon projectile collide with neutral units or pass through?}} | ||
| Line 207: | Line 225: | ||
|type = bool | |type = bool | ||
|default = true | |default = true | ||
|lua = noGroundCollide | |||
|description = Does the weapon projectile collide with terrain or pass through?}} | |description = Does the weapon projectile collide with terrain or pass through?}} | ||
{{tag | |||
|name = collisionSize | |||
|type = float | |||
|default = 0.05 (0.5 for [[#Flame]] and [[#LaserCannon]], 10.0 for [[#Dgun]]) | |||
|description = Modifies visual size of EMG and Flame projectiles, and physical size '''only''' for hitscan interceptor weapons (e.g. antinuke lasers). [[https://github.com/spring/spring/blob/3034e5f5a8f5b9fb4624a97f7a85cb5c90457725/rts/Sim/Projectiles/WeaponProjectiles/WeaponProjectile.cpp#L250 1]][[https://github.com/spring/spring/blob/master/rts/Sim/Misc/CollisionHandler.cpp#L33 2]]}} | |||
====Targeting & Accuracy==== | ====Targeting & Accuracy==== | ||
| Line 233: | Line 258: | ||
|default = waterWeapon | |default = waterWeapon | ||
|description = Determines if the weapon can fire whilst underwater.}} | |description = Determines if the weapon can fire whilst underwater.}} | ||
{{tag | {{tag | ||
| Line 244: | Line 263: | ||
|type = float | |type = float | ||
|default = 0.0 (1.0 for [[#Melee]]) | |default = 0.0 (1.0 for [[#Melee]]) | ||
|description = Controls whether the weapon aims for the centre or the edge of its target's [[ | |description = Controls whether the weapon aims for the centre or the edge of its target's [[Gamedev:CollisionVolumes|collision volume]]. Clamped between <code>-1.0</code> - target the far border, and <code>1.0</code> - target the near border.}} | ||
{{tag | {{tag | ||
| Line 250: | Line 269: | ||
|type = float | |type = float | ||
|default = 0.0 (1.0 for [[#Melee]]) | |default = 0.0 (1.0 for [[#Melee]]) | ||
|description = Controls whether the weapon range is calculated in a sphere or a cylinder. The height of the cylinder is determined by the value of | |description = Controls whether the weapon range is calculated in a sphere or a cylinder. The height of the cylinder is determined by the value of this tag multiplied by the {{taglink|range}}. Clamped between <code>0.0</code> and <code>128.0</code>.}} | ||
{{tag | {{tag | ||
|name = tolerance | |name = tolerance | ||
|type = float | |type = float | ||
|default = 3000.0 | |default = 3000.0 (+/- ~18 degrees) | ||
|description = The amount to which the weapon's "real" aim can be off while the weapon will still be able to fire accurately at the target. For <code> | |description = The amount (in [[Gamedev:UnitsOfMeasurement#Angular|cau]]) to which the weapon's "real" aim can be off while the weapon will still be able to fire accurately at the target. For {{taglink|turret|false}} or {{taglink|fixedLauncher|true}} weapons this determines in what arc the unit will fire.}} | ||
{{tag | |||
|name = fireTolerance | |||
|type = float | |||
|default = 32768.0 (+/- 180 degrees) | |||
|special = {{new|99.0}} | |||
|description = Final check to prevent weapons from shooting sideways. If a weapon is about to fire but the difference between its old aim and requested aim is greater than this angle (in [[Gamedev:UnitsOfMeasurement#Angular|cau]]) then it will not fire.}} | |||
{{tag | |||
|name = allowNonBlockingAim | |||
|type = bool | |||
|default = false | |||
|special = {{new|99.0}} | |||
|description = When enabled it makes [[Animation-LuaCallins#Weapons|AimWeapon()]] script calls non-blocking (still the {{taglink|fireTolerance}} tag might prevent the weapon firing). This is very useful for fast units that need to re-target often.}} | |||
{{tag | |||
|name = targetMoveError | |||
|type = float | |||
|default = 0.0 | |||
|description = The degree to which a weapon's aiming will fail to keep up with its target's movement. It adds a fraction of the target's speed (per second) as a random error to the targetting. So if the target moves 50 units per second and the targetmoveerror is 0.5 a random error of 25 will be added to the target position. If set very low or not set at all, a weapon will lead its target and almost always hit.}} | |||
{{tag | |||
|name = leadLimit | |||
|type = float | |||
|default = -1.0 | |||
|description = Limits the maximum distance a unit will lead a target. The default of <code>-1</code> allows an infinite distance.}} | |||
{{tag | |||
|name = leadBonus | |||
|type = float | |||
|default = 0.0 | |||
|description = Controls how experience boosts the weapon's target leading. Is multiplied with the unit's experience and added to the {{taglink|leadLimit}}.}} | |||
{{tag | |||
|name = predictBoost | |||
|type = float | |||
|default = 0.0 (0.5 for {{taglink|burnblow|true}} weapons) | |||
|description = Controls how well the weapon predicts unit speeds. Works in a similar way to {{taglink|targetMoveError}} except that it is 1-dimensional. This tag spreads the shots in a line based on the direction of the target whereas {{taglink|targetMoveError}} spreads the shots all around based on the movement.}} | |||
{{tag | |||
|name = heightMod | |||
|type = float | |||
|default = 0.2 (0.8 for [[#Cannon]], 1.0 for [[#BeamLaser]] and [[#LightningCannon]]) | |||
|description = Changes the spherical weapon range into an ellipsoid. Values above <code>1.0</code> mean the weapon cannot target as high as it can far, values below <code>1.0</code> mean it can target higher than it can far. For example <code>0.5</code> would allow the weapon to target twice as high as far.}} | |||
{{tag | |||
|name = proximityPriority | |||
|type = float | |||
|default = 1.0 | |||
|description = Acts as a multiplier for the distance to the target in the priority calculation. Note that negative values make weapons prefer distant targets.}} | |||
{{tag | {{tag | ||
| Line 268: | Line 337: | ||
|type = float | |type = float | ||
|default = accuracy | |default = accuracy | ||
|description = A weapon's | |description = A weapon's {{taglink|accuracy}} whilst the owning unit is moving.}} | ||
{{tag | {{tag | ||
| Line 274: | Line 343: | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = How wide the the angle of a burst from a [[#Bursts|burst weapon]] can be. Very similar to | |description = How wide the the angle of a burst from a [[#Bursts|burst weapon]] can be. Very similar to {{taglink|accuracy}}, except that this tag affects each projectile in a burst, whilst the former does not.}} | ||
{{tag | {{tag | ||
|name = | |name = ownerExpAccWeight | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 (See description) | ||
|description = | |description = A multiplier to {{taglink|accuracy}} and {{taglink|sprayAngle}} that reduces inaccuracy as a units experience increases. Defaults are as follows: | ||
* <code>0.9</code> - [[#Cannon]], [[#Rifle]] | |||
* <code>0.7</code> - [[#LaserCannon]], [[#BeamLaser]], [[#StarburstLauncher]] | |||
* <code>0.5</code> - [[#MissileLauncher]], [[#LightningCannon]], [[#EmgCannon]], [[#DGun]] | |||
* <code>0.2</code> - [[#Flame]] | |||
}} | |||
{{tag | |||
|name = targetable | |||
|type = int | |||
|default = 0 | |||
|special = {{new|92.0}} Previously only for [[#StarburstLauncher]] | |||
|description = [http://en.wikipedia.org/wiki/Mask_(computing) Bitmask] representing the types of weapon that can intercept this weapon. Each digit of binary that is set to one means that a weapon with the corresponding digit in its {{taglink|interceptor}} tag will intercept this weapon. Instant-hitting weapons such as [[#BeamLaser]], [[#LightningCannon]] and [[#Rifle]] cannot be targeted. | |||
}} | |||
{{tag | {{tag | ||
|name = | |name = interceptor | ||
|type = | |type = int | ||
|default = | |default = 0 | ||
|description = | |special = {{new|92.0}} Previously only for [[#StarburstLauncher]] | ||
|description = [http://en.wikipedia.org/wiki/Mask_(computing) Bitmask] representing the types of weapons that this weapon can intercept. Each digit of binary that is set to one means that a weapon with the corresponding digit in its {{taglink|targetable}} tag will be intercepted by this weapon. | |||
}} | |||
{{tag | {{tag | ||
|name = | |name = interceptSolo | ||
|type = | |type = bool | ||
|default = | |default = true | ||
|description = | |special = {{new|92.0}} | ||
|description = If <code>true</code> no other interceptors may target the same projectile. | |||
}} | |||
{{tag | {{tag | ||
|name = | |name = coverage | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = | |special = {{new|92.0}} Previously only for [[#StarburstLauncher]] | ||
|description = The radius in [[elmo]]s within which an {{taglink|interceptor}} weapon will fire on {{taglink|targetable}} weapons. | |||
}} | |||
====Bouncing==== | ====Bouncing==== | ||
| Line 337: | Line 425: | ||
|name = areaOfEffect | |name = areaOfEffect | ||
|type = float | |type = float | ||
|default = 8.0 | |default = 8.0 * 0.5 | ||
|description = The ''diameter'' in [[ | |lua = damageAreaOfEffect | ||
|description = The ''diameter'' in [[elmo]]s in which the weapons explosion will cause damage.}} | |||
{{tag | {{tag | ||
| Line 344: | Line 433: | ||
|type = float | |type = float | ||
|default = areaOfEffect * 0.5 | |default = areaOfEffect * 0.5 | ||
|description = The ''radius'' in [[ | |description = The ''radius'' in [[elmo]]s in which the weapons explosion will cause terrain cratering. Behaviour changed slightly in 98.0 as previously craters were 1.5x {{taglink|craterAreaOfEffect}} whilst decals were 1.0x, they are now both the same size.}} | ||
{{tag | {{tag | ||
| Line 350: | Line 439: | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = Determines what percent of a weapon's maximum damage value will be applied to units within the weapon's | |description = Determines what percent of a weapon's maximum damage value will be applied to units within the weapon's {{taglink|areaOfEffect}}. Falls off from the epicentre according to the formula <code>damageApplied = damage * [(areaOfEffect - distToUnit) / (areaOfEffect - (distToUnit * edgeEffectiveness))]</code>, a graph of the function for various values is available [[Media:EdgeEffectiveness.png|here]].}} | ||
{{tag | |||
|name = explosionSpeed | |||
|type = float | |||
|default = See description | |||
|description = The speed at which the weapon's explosion propagates from the epicentre. The default is calculated by this complex formula: <code>defExpSpeed = {8.0 + [max(30.0, default_damage / 20.0) * 2.5]} / {9.0f + [sqrt(max(30.0, default_damage / 20.0f)) * 0.7]} * 0.5</code>.}} | |||
{{tag | {{tag | ||
| Line 356: | Line 451: | ||
|type = float | |type = float | ||
|default = 1.0 | |default = 1.0 | ||
|description = A multiplier to the impulse given to units within the explosion | |description = A multiplier to the impulse given to units within the explosion {{taglink|areaOfEffect}}, which is otherwise equal to the damage dealt after {{taglink|edgeEffectiveness}} is taken into account. For [[#Melee]] weapons this is instead multiplied by the owning unit's mass (See [[Gamedev:UnitDefs#Tag:mass|Gamedev:UnitDefs]]).}} | ||
{{tag | {{tag | ||
| Line 362: | Line 457: | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = A constant amount added to the weapon's impulse, regardless of distance from the epicentre or the damage potential of the explosion, prior to the application of | |description = A constant amount added to the weapon's impulse, regardless of distance from the epicentre or the damage potential of the explosion, prior to the application of {{taglink|impulseFactor}}}} | ||
{{tag | {{tag | ||
| Line 374: | Line 469: | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = A constant amount, added to the weapon's cratering depth before the application of | |description = A constant amount, added to the weapon's cratering depth before the application of {{taglink|craterMult}}.}} | ||
====Bursts==== | ====Bursts==== | ||
| Line 382: | Line 477: | ||
|type = int | |type = int | ||
|default = 1 | |default = 1 | ||
|lua = salvoSize | |||
|description = How many shots to fire per burst. | |description = How many shots to fire per burst. | ||
}} | }} | ||
| Line 389: | Line 485: | ||
|type = float | |type = float | ||
|default = 0.1 | |default = 0.1 | ||
|description = The time in seconds between shots in a burst. Note that | |lua = salvoDelay | ||
|description = The time in seconds between shots in a burst. Note that {{taglink|reloadTime}} starts to count down from the ''first'' round fired, not the last so if <code>reloadTime < burst * burstRate</code> the weapon will fire continuously. | |||
}} | }} | ||
| Line 396: | Line 493: | ||
|type = int | |type = int | ||
|default = 1 | |default = 1 | ||
|description = How many projectiles released per shot (shotgun style). e.g. a weapon with | |description = How many projectiles released per shot (shotgun style). e.g. a weapon with {{taglink|burst|5}}, {{taglink|burstRate|0.5}} and {{taglink|projectiles|2}} will shoot 5 lots of 2 for 10 projectiles total, with gaps of 0.5 seconds, before waiting for {{taglink|reloadTime}}. Best used in conjunction with {{taglink|sprayAngle}} or changing the firing piece using [[Animation-LuaCallins#Weapons|ShotX]] as otherwise they'll all be clumped in one shot. | ||
}} | }} | ||
| Line 411: | Line 508: | ||
|type = int | |type = int | ||
|default = 10 | |default = 10 | ||
|lua = damages.paralyzeDamageTime | |||
|description = Determines the maximum length of time in seconds that the target will be paralyzed. The timer is restarted every time the target is hit by the weapon. Cannot be less than <code>0</code>. | |description = Determines the maximum length of time in seconds that the target will be paralyzed. The timer is restarted every time the target is hit by the weapon. Cannot be less than <code>0</code>. | ||
}} | }} | ||
====Dynamic Damage==== | ====Dynamic Damage==== | ||
The following set of tags allow for a weapon's damage potential to vary with the distance to its target. | |||
{{tag | |||
|name = dynDamageExp | |||
|type = float | |||
|default = 0.0 | |||
|description = Exponent of the range-dependent damage formula, the default of <code>0.0</code> disables dynamic damage, <code>1.0</code> means linear scaling, <code>2.0</code> quadratic and so on. | |||
}} | |||
{{tag | |||
|name = dynDamageMin | |||
|type = float | |||
|default = 0.0 | |||
|description = The minimum floor value that range-dependent damage can drop to. | |||
}} | |||
{{tag | |||
|name = dynDamageRange | |||
|type = float | |||
|default = 0.0 | |||
|description = If set to non-zero values the weapon will use this value in the range-dependant damage formula instead of the actual {{taglink|range}}. | |||
}} | |||
{{tag | |||
|name = dynDamageInverted | |||
|type = bool | |||
|default = false | |||
|description = If <code>true</code> the damage curve is inverted i.e. the weapon does more damage at greater ranges as opposed to less. | |||
}} | |||
====Sounds==== | ====Sounds==== | ||
| Line 420: | Line 547: | ||
|name = soundTrigger | |name = soundTrigger | ||
|type = bool | |type = bool | ||
|default = false (true for Melee, Rifle and non-beamBurst BeamLaser) | |default = false (true for [[#Melee]], [[#Rifle]] and non-beamBurst [[#BeamLaser]]) | ||
|description = Does the weapon play | |description = Does the weapon play {{taglink|soundStart}} only once for each salvo (<code>true</code>) or for every round in a burst (<code>false</code>)?}} | ||
{{tag | |||
|name = soundStart | |||
|type = string | |||
|default = "" | |||
|description = The name of a '''SoundItem''' (See [[Sounds.lua]]) or filename of a sound to play when the weapon fires.}} | |||
{{tag | |||
|name = soundHitDry | |||
|type = string | |||
|default = "" | |||
|description = The name of a '''SoundItem''' (See [[Sounds.lua]]) or filename of a sound to play when the weapon collides with solid ground. Note that a [[#BeamLaser]] will play this sound every frame of its lifetime.}} | |||
{{tag | |||
|name = soundHitWet | |||
|type = string | |||
|default = "" | |||
|description = The name of a '''SoundItem''' (See [[Sounds.lua]]) or filename of a sound to play when the weapon collides with water. Note that a [[#BeamLaser]] will play this sound every frame of its lifetime.}} | |||
====Visuals==== | ====Visuals==== | ||
| Line 429: | Line 574: | ||
|type = string | |type = string | ||
|default = "" | |default = "" | ||
|description = The name, without prefixes, of a [[CEG]] to be emitted by the projectile each frame.}} | |description = The name, without prefixes, of a [[CEG]] to be emitted by the projectile each frame. | ||
}} | |||
{{tag | {{tag | ||
|name = intensity | |name = intensity | ||
|type = float | |type = float | ||
|default = 0.9 | |default = 0.9 (0.2 for [[#Cannon]]) | ||
|description = Alpha transparency for non-3D model projectiles. Lower values are more opaque, but <code>0.0</code> will cause the projectile to disappear entirely.}} | |description = Alpha transparency for non-3D model projectiles. Lower values are more opaque, but <code>0.0</code> will cause the projectile to disappear entirely. | ||
}} | |||
=== | {{tag | ||
|name = model | |||
|type = string | |||
|default = "" | |||
|description = The filename of a 3D model to use when rendering the projectile. Note that only the root piece of a projectile model is rendered. Currently only for [[#Cannon]], [[#LaserCannon]], [[#MissileLauncher]], [[#StarburstLauncher]] and [[#TorpedoLauncher]]. | |||
}} | |||
{{tag | |||
|name = explosionScar | |||
|type = bool | |||
|default = false | |||
|description = Does the weapon's explosion leave a scar decal on the ground? For all types except [[#Melee]] and [[#Rifle]]. | |||
}} | |||
{{tag | |||
|name = alwaysVisible | |||
|type = bool | |||
|default = false | |||
|description = If <code>true</code> the weapon is always rendered regardless of whether or not it is in LOS range of a player's units. | |||
}} | |||
{{tag | |||
|name = rgbColor | |||
|type = float[3] | |||
|default = {1.0, 0.0, 0.0} (See Description) | |||
|description = The primary colour for sprite rendering weapons. Additional defaults are as follows: | |||
* [[#Cannon]] - <code>{1.0, 0.5, 0.0}</code> | |||
* [[#EmgCannon]] - <code>{0.9, 0.9, 0.2}</code> | |||
}} | |||
{{tag | |||
|name = explosionGenerator | |||
|type = string | |||
|default = "" | |||
|description = The name of a [[CEG]], with <code>custom:</code> prefix, to spawn as the weapon's explosion. Does not currently work for [[#Melee]] and [[#Rifle]]. | |||
}} | |||
{{tag | |||
|name = bounceExplosionGenerator | |||
|type = string | |||
|default = "" | |||
|description = For weapons which can use {{taglink|groundBounce|true}}, the name of a [[CEG]], with <code>custom:</code> prefix, to spawn when weapon the bounces. | |||
}} | |||
{{tag | |||
|name = texture1 | |||
|type = string | |||
|default = "" | |||
|description = The projectile texture for [[#AircraftBomb]], [[#Cannon]], [[#EmgCannon]], [[#Flame]]; beam texture for [[#LaserCannon]], [[#BeamLaser]], [[#LightningCannon]]; flare texture for [[#MissileLauncher]], [[#StarburstLauncher]] and dome texture for the [[#Shield]]. | |||
}} | |||
{{tag | {{tag | ||
|name = | |name = texture2 | ||
|type = | |type = string | ||
|default = | |default = "" | ||
|description = | |description = The end-of-beam texture for [[#LaserCannon]], [[#BeamLaser]] and {{taglink|smoketrail}} texture for [[#MissileLauncher]], [[#StarburstLauncher]]. | ||
}} | }} | ||
==== | {{tag | ||
|name = texture3 | |||
|type = string | |||
|default = "" | |||
|description = Flare texture for [[#BeamLaser]], or muzzle texture if {{taglink|largeBeamLaser|true}}. Also used as the flame texture for [[#StarburstLauncher]]. | |||
}} | |||
{{tag | {{tag | ||
|name = | |name = texture4 | ||
|type = | |type = string | ||
|default = | |default = "" | ||
|description = | |description = Flare texture for [[#BeamLaser]] with {{taglink|largeBeamLaser|true}}. | ||
}} | }} | ||
===AircraftBomb=== | |||
Drops a ballistic projectile at the same movement vector as the unit itself. Intended only for aircraft. Visually drawn as a billboarded sprite as used by the [[#Cannon]], but more commonly used with a 3D model. | |||
There are no tags specific to this '''WeaponType''' | |||
====AircraftBomb Visuals==== | |||
When not using a {{taglink|model}}, the AircraftBomb is the same as [[#Cannon Visuals]]. | |||
===BeamLaser=== | ===BeamLaser=== | ||
An instant-hit weapon which spawns a beam and does a portion of its total damage each frame. Cannot be [[Animation-LuaCallouts#Effects|script emitted]] if it has a | An instant-hit weapon which spawns a beam and does a portion of its total damage each frame. Cannot be [[Animation-LuaCallouts#Effects|script emitted]] if it has a {{taglink|beamTime}} longer than one frame. Visually drawn as a [http://en.wikipedia.org/wiki/Star_Trek Star Trek] Phaser-style laser weapon. The {{taglink|largeBeamLaser}} tag allows changing the visual effect of the laser, such as using a tileable, scrolling texture without changing the behaviour. | ||
{{tag | {{tag | ||
| Line 463: | Line 672: | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = The minimum percentage the weapon's damage can fall-off to over its range. Setting to <code>1.0</code> will disable fall off entirely. Unrelated to the visual-only | |description = The minimum percentage the weapon's damage can fall-off to over its range. Setting to <code>1.0</code> will disable fall off entirely. Unrelated to the visual-only {{taglink|intensity}} tag. | ||
}} | }} | ||
| Line 470: | Line 679: | ||
|type = float | |type = float | ||
|default = 1.0 | |default = 1.0 | ||
|description = How long in seconds to fire the laser before waiting for | |lua = beamtime (all lowercase!) | ||
|description = How long in seconds to fire the laser before waiting for {{taglink|reloadTime}} to start. Damage is distributed over the duration of the {{taglink|beamTime}}, and the weapon will aim to hit the target when the beam is in the middle of its {{taglink|beamTime}} (i.e. using prediction). | |||
}} | }} | ||
| Line 477: | Line 687: | ||
|type = bool | |type = bool | ||
|default = false | |default = false | ||
|description = Makes the laser fire a burst of beams that are all aimed towards the target (instead of aimed with the piece). A | |lua = beamburst (all lowercase!) | ||
|description = Makes the laser fire a burst of beams that are all aimed towards the target (instead of aimed with the piece). A [[#BeamLaser]] can do its full damage with every shot if {{taglink|beamBurst}} is enabled. Disables {{taglink|beamTime}} in favour of the [[#Bursts|burst tags]]. | |||
}} | }} | ||
| Line 484: | Line 695: | ||
|type = bool | |type = bool | ||
|default = false | |default = false | ||
|description = Makes the laser continue firing while it aims for a new target, 'sweeping' across the terrain. | |description = Makes the laser continue firing while it aims for a new target, 'sweeping' across the terrain. Reimplemented in 95.0, still has no script interaction so use with care. Respects {{taglink|reloadTime}} constraint but not much else. | ||
}} | }} | ||
====BeamLaser Visuals==== | ====BeamLaser Visuals==== | ||
See also {{taglink|thickness}} and {{taglink|coreThickness}}. | |||
{{tag | {{tag | ||
|name = | |name = beamTTL | ||
|type = int | |||
|default = 0 | |||
|description = The time in frames for which the laser beam remains visible. | |||
}} | |||
{{tag | |||
|name = beamDecay | |||
|type = float | |type = float | ||
|default = 1.0 | |default = 1.0 | ||
|description = | |description = How fast the beam fades out. Each frame the {{taglink|intensity}} is multiplied by this value. | ||
}} | |||
{{tag | |||
|name = laserFlareSize | |||
|type = float | |||
|default = 15.0 | |||
|description = Determines the size of the firing flare. | |||
}} | |||
{{tag | |||
|name = largeBeamLaser | |||
|type = bool | |||
|default = false | |||
|description = Changes the visual effect allowing tiling and scrolling of the texture and a pulsating firing flare. | |||
}} | |||
{{tag | |||
|name = tileLength | |||
|type = float | |||
|default = 200.0 | |||
|description = Defines the length before the texture used is repeated (tiled). Only if {{taglink|largeBeamLaser|true}}. | |||
}} | |||
{{tag | |||
|name = scrollSpeed | |||
|type = float | |||
|default = 5.0 | |||
|description = Controls how fast the texture scrolls. Only if {{taglink|largeBeamLaser|true}}. | |||
}} | |||
{{tag | |||
|name = pulseSpeed | |||
|type = float | |||
|default = 1.0 | |||
|description = Controls how fast the pulsating effect at the start of the beam is. Only if {{taglink|largeBeamLaser|true}}. | |||
}} | }} | ||
===Cannon=== | ===Cannon=== | ||
The default '''WeaponType'''. Fires a ballistic projectile, for the best result (without under/overshooting) the | The default '''WeaponType'''. Fires a ballistic projectile, for the best result (without under/overshooting) the {{taglink|weaponVelocity}} should be set so as to give an elevation of 45° when firing at the maximum {{taglink|range}}. Substituting the angle into the [http://en.wikipedia.org/wiki/Trajectory#Range_and_height trajectory equation] and rearranging, we get: | ||
<code><pre>weaponVelocity = √(range * g)</pre></code> | <code><pre>weaponVelocity = √(range * g)</pre></code> | ||
where <code>g</code> is the map gravity, usually around <code>120</code> for most Spring maps (You can use the | where <code>g</code> is the map gravity, usually around <code>120</code> for most Spring maps (You can use the {{taglink|myGravity}} tag if you want to be exact). Visually drawn as a billboarded sprite or 3D model. | ||
{{tag | {{tag | ||
| Line 506: | Line 761: | ||
|default = 2 | |default = 2 | ||
|description = Can this weapon be fired in a high trajectory (>45° angle). Can be <code>0</code> - low trajectory only, <code>1</code> - high trajectory only or <code>2</code> - enables a high/low toggle button on the unit. | |description = Can this weapon be fired in a high trajectory (>45° angle). Can be <code>0</code> - low trajectory only, <code>1</code> - high trajectory only or <code>2</code> - enables a high/low toggle button on the unit. | ||
}} | |||
{{tag | |||
|name = heightBoostFactor | |||
|type = float | |||
|default = -1.0 | |||
|description = Controls the boost given to {{taglink|range}} by high terrain. Values > <code>1.0</code> result in increased range, <code>0.0</code> means the cannon has fixed range regardless of height difference to target. Any value < <code>0.0</code> (i.e. the default value) result in an automatically calculated value based on {{taglink|range}} and theoretical maximum range. | |||
}} | }} | ||
| Line 511: | Line 773: | ||
{{tag | {{tag | ||
|name = | |name = size | ||
|type = float | |type = float | ||
|default = | |default = 2.0 + min(default_damage * 0.0025, {{taglink|areaOfEffect}} * 0.1) | ||
|description = | |description = The drawing radius of the billboarded sprite. Also for [[#AircraftBomb Visuals]], [[#EmgCannon Visuals]] (default: <code>3.0</code>) and [[#Flame Visuals]]. | ||
}} | }} | ||
=== | {{tag | ||
|name = colorMap | |||
|type = string | |||
|default = "" | |||
|description = A set of RGB colours to transition between over the projectile's lifetime. Can be given as a string of RGB digits or an image filename (See [[CColorMap]]). Also for [[#Flame Visuals]]. | |||
}} | |||
{{tag | {{tag | ||
|name = | |name = sizeDecay | ||
|type = | |type = float | ||
|default = | |default = 0.0 | ||
|description = | |description = How quickly each particle of the Cannon shot decays in size. | ||
}} | }} | ||
=== | {{tag | ||
|name = alphaDecay | |||
|type = float | |||
|default = 1.0 | |||
|description = How quickly each particle of the Cannon shot fades out. | |||
}} | |||
{{tag | {{tag | ||
|name = | |name = separation | ||
|type = float | |type = float | ||
|default = | |default = 0.0 | ||
|description = | |description = The distance between each particle of the Cannon shot. | ||
}} | }} | ||
==== | {{tag | ||
|name = noGap | |||
|type = bool | |||
|default = true | |||
|description = Switch between the distance between particles being proportional to the size of the two particles (<code>true</code>) or proportional to the size of the first particle (<code>false</code>). | |||
}} | |||
{{tag | {{tag | ||
|name = | |name = stages | ||
|type = | |type = int | ||
|default = | |default = 5 | ||
|description = | |description = The number of particles in each Cannon shot. | ||
}} | }} | ||
=== | ===DGun=== | ||
Fires a line-of-sight or ballistic projectile (selected via the {{taglink|gravityAffected}} tag). Visually represented by a fireball effect that cannot be customised, however it can be replaced by a 3D model. The name and visual effect are [[OTAism]]s. | |||
{{tag | {{tag | ||
|name = | |name = gravityAffected | ||
|type = | |type = bool | ||
|default = | |default = false | ||
|description = | |description = Does the fireball projectile lose height due to map gravity? | ||
}} | }} | ||
===EmgCannon=== | |||
A line-of-sight weapon. Visually drawn as a billboarded sprite very similar to that of the [[#Cannon]], however not as customisable, or a 3D model. The name is another [[OTAism]]. | |||
There are no tags specific to this '''WeaponType'''. | |||
===Flame=== | |||
A line-of-sight weapon intended for use as a flamethrower or similar. Visually drawn as a stream of textured particles, the colour of which can be controlled very precisely using the {{taglink|colorMap}} tag (see [[CColorMap]]). | |||
====Flame Visuals==== | ====Flame Visuals==== | ||
See also {{taglink|colorMap}}. | |||
{{tag | {{tag | ||
|name = | |name = sizeGrowth | ||
|type = float | |type = float | ||
|default = | |default = 0.5 | ||
|description = | |description = How much the draw radius of the flame projectile increases each frame. | ||
}} | }} | ||
{{tag | {{tag | ||
|name = | |name = flameGFXTime | ||
|type = float | |type = float | ||
|default = 1. | |default = 1.2 | ||
|description = | |description = Makes the flamethrower projectile stay alive as a visual-only effect (i.e. does not deal any damage) after it has reached maximum {{taglink|range}}. It is a percentage multiplier, e.g. <code>1.2</code> makes the projectile stay alive until it reaches 20% beyond {{taglink|range}}. | ||
}} | }} | ||
===LaserCannon=== | |||
A particularly versatile line-of-sight weapon. Visually drawn like a [http://en.wikipedia.org/wiki/Star_Wars Star Wars] Blaster-style laser weapon, or a 3D model. | |||
====LaserCannon Visuals==== | ====LaserCannon Visuals==== | ||
| Line 581: | Line 865: | ||
|type = float | |type = float | ||
|default = 0.05 | |default = 0.05 | ||
|description = Multiplied against | |description = Multiplied against {{taglink|weaponVelocity}} to determine the visual length of the beam projectile. | ||
}} | |||
{{tag | |||
|name = hardStop | |||
|type = bool | |||
|default = false | |||
|description = Does the laser projectile stop dead or fade out? | |||
}} | }} | ||
| Line 588: | Line 879: | ||
|type = float | |type = float | ||
|default = 0.5 | |default = 0.5 | ||
|description = Rate at which the beam fades out after it goes past its maximum | |description = Rate at which the beam fades out after it goes past its maximum {{taglink|range}} if {{taglink|hardStop|false}}. A value of <code>0.0</code> is never fade out, <code>1.0</code> is finish fading out exactly at maximum {{taglink|range}}. | ||
}} | }} | ||
=== | {{tag | ||
|name = lodDistance | |||
|type = int | |||
|default = 1000 | |||
|description = Minimum camera distance at which the default LaserCannon projectile is simplified to a single rectangle. | |||
}} | |||
{{tag | {{tag | ||
|name = | |name = thickness | ||
|type = float | |type = float | ||
|default = | |default = 2.0 | ||
|description = | |description = The thickness (width) of the LaserCannon projectile. Also for [[#BeamLaser Visuals]]. | ||
}} | }} | ||
==== | {{tag | ||
|name = coreThickness | |||
|type = float | |||
|default = 2.0 | |||
|description = The thickness (width) of the LaserCannon projectile's core. Also for [[#BeamLaser Visuals]]. | |||
}} | |||
{{tag | {{tag | ||
|name = | |name = rgbColor2 | ||
|type = float | |type = float | ||
|default = 1.0 | |default = {1.0, 1.0, 1.0} | ||
|description = | |description = The colour of the LaserCannon projectile's core. Also for [[#BeamLaser Visuals]]. | ||
}} | }} | ||
===LightningCannon=== | |||
An instant-hit weapon similar to the [[#BeamLaser]], but which does all its damage at once. Visually drawn like [http://en.wikipedia.org/wiki/Star_Wars Star Wars] 'Force Lightning' or [http://en.wikipedia.org/wiki/Command_%26_Conquer:_Red_Alert CnC: Red Alert] [http://en.wikipedia.org/wiki/Tesla_coil Tesla Coil] weapons, the effect is not very customisable. | |||
There are no tags specific to this '''WeaponType'''. | |||
===Melee=== | ===Melee=== | ||
| Line 616: | Line 921: | ||
===MissileLauncher=== | ===MissileLauncher=== | ||
A versatile weapon which can optionally track targets and accelerate from a low initial velocity. It can also use | A versatile weapon which can optionally track targets and accelerate from a low initial velocity. It can also use {{taglink|trajectoryHeight}} to have the shot arc similar to a ballistic projectile. Visually represented by a 3D model, with an optional {{taglink|smokeTrail}}. | ||
{{tag | |||
|name = startVelocity | |||
|type = float | |||
|default = 0.0 | |||
|description = The initial velocity of the weapon projectile. Also for [[#StarburstLauncher]] and [[#TorpedoLauncher]]. | |||
}} | |||
{{tag | |||
|name = weaponAcceleration | |||
|type = float | |||
|default = 0.0 | |||
|description = The initial acceleration of the weapon projectile. Also for [[#StarburstLauncher]] and [[#TorpedoLauncher]]. Note that if it is <code>0.0</code> the weapon can never increase from its {{taglink|startVelocity}} and will not reach its maximum {{taglink|weaponVelocity}}. Since 99.0 <code>acceleration</code> is a synonym. | |||
}} | |||
{{tag | |||
|name = tracks | |||
|type = bool | |||
|default = false | |||
|description = Can the weapon projectile track a moving target? Also for [[#StarburstLauncher]] and [[#TorpedoLauncher]].}} | |||
{{tag | |||
|name = turnRate | |||
|type = float | |||
|default = 0.0 | |||
|description = The rate (in [[Elmo#Angular|cau]]) at which {{taglink|tracks|true}} weapons turn towards their target. This is relative to a projectile's current velocity; a weapon with a higher velocity will need a higher value in order to be able to hit targets that turn suddenly.}} | |||
{{tag | |||
|name = flightTime | |||
|type = float | |||
|default = 0.0 | |||
|description = The time in seconds before a missile projectile's fuel runs out; it ceases to obey {{taglink|tracks}}, loses velocity and falls to the ground. Also for [[#StarburstLauncher]]. Large values may cause over/undershoot problems. As of 104.0 also applies to [[#EmgCannon]]. | |||
}} | |||
{{tag | {{tag | ||
| Line 622: | Line 960: | ||
|type = bool | |type = bool | ||
|default = false | |default = false | ||
|description = Makes the projectile spawn with the orientation of the shooting piece instead of their normal orientation. Also | |description = Makes the projectile spawn with the orientation of the shooting piece instead of their normal orientation. Also for [[#StarburstLauncher]] and [[#TorpedoLauncher]]. Weapons may not correctly obey [[#Collision & Avoidance|avoidance settings]] when using this tag. | ||
}} | |||
{{tag | |||
|name = wobble | |||
|type = float | |||
|default = 0.0 | |||
|description = Adds a random vector to the direction of travel every 16 frames, multiplied by the value of the tag. The effect is reduced as the firing unit gains experience. As this missiles direction is changed, wobbling swarm of missiles will diverge. | |||
}} | }} | ||
{{tag | {{tag | ||
|name = | |name = dance | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = | |description = Adds a random vector to the position of a missile projectile every 8 frames, multiplied by the value of the tag. As the projectile is not rotated, a dancing swarm of missiles will remain relatively coherent. | ||
}} | }} | ||
{{tag | {{tag | ||
|name = | |name = trajectoryHeight | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = | |description = Determines the height of the arc the missile will reach as it moves towards its target. A value of <code>0.0</code> will result in a flat trajectory, <code>1.0</code> will launch at 45°. Can be any value >= <code>0.0</code>; extreme values may require the {{taglink|tracks}} tag to be able to hit a target. | ||
}} | }} | ||
====MissileLauncher Visuals==== | ====MissileLauncher Visuals==== | ||
A note about the missile exhaust flare: the size of the flare is determined by the model radius. The emit position of the flare is at (0,0,-radius) so the model may need careful adjustment to get the flare looking right. | |||
{{tag | {{tag | ||
|name = | |name = smokeTrail | ||
|type = | |type = bool | ||
|default = | |default = false | ||
|description = | |description = Does the missile projectile emit a smoke trail as it travels? Also for [[#StarburstLauncher]]. | ||
}} | }} | ||
| Line 654: | Line 1,000: | ||
===Shield (WeaponType)=== | ===Shield (WeaponType)=== | ||
As the name suggests, not a weapon but a defensive shield. Can absorb or | As the name suggests, not a weapon but a defensive shield. Can absorb or deflect ({{taglink|repulsor|true}}) projectiles. Individual weapons can be set to be intercepted or not by the shield using a [http://en.wikipedia.org/wiki/Mask_(computing) bitmask] (see [[Shield Interception Tag Use]]). Visually represented as a translucent sphere, with control over colour and texture; by default the shield is invisible ({{taglink|visible|false}}). | ||
{{ | |||
| | |||
| | |||
See the [[#shield]] sub-table section for other tags specific to this type. | See the [[#shield]] sub-table section for other tags specific to this type. | ||
===StarburstLauncher=== | ===StarburstLauncher=== | ||
Fires a projectile that rises vertically for | Fires a projectile that rises vertically for {{taglink|weaponTimer}} seconds, then turns towards its target. It can optionally track targets and accelerate from a low initial velocity. Before spring 92.0 was the only weapon that can be {{taglink|targetable}} and act as an {{taglink|interceptor}}. Visually represented by a 3D model, with an optional {{taglink|smokeTrail}}. | ||
{{ | |||
| | |||
}} | |||
{{tag | {{tag | ||
|name = | |name = weaponTimer | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = The | |description = The time in seconds during which the missile ascends vertically before turning towards its target. | ||
}} | }} | ||
===TorpedoLauncher=== | ===TorpedoLauncher=== | ||
Fires a projectile that will behave ballistically out of water and like a missile in water. Usually used with | Fires a projectile that will behave ballistically out of water and like a missile in water. Usually used with {{taglink|waterWeapon|true}} so they can fire underwater and target underwater units. An aircraft carrying a [[#TorpedoLauncher]] is a special case, the weapon turns into an [[#AircraftBomb]] projectile that will spawn a torpedo projectile on impact with water. Visually represented by a pointed black cuboid, usually the default object is replaced by a 3D model. | ||
{{tag | {{tag | ||
| Line 708: | Line 1,025: | ||
===NoWeapon=== | ===NoWeapon=== | ||
Not actually a '''WeaponType''', but an individual weapon requested by Spring to 'fill in the gaps' if a unit claims to have a weapon which isn't actually defined. There needs to be only one of these weapons and it is | Not actually a '''WeaponType''', but an individual weapon requested by Spring to 'fill in the gaps' if a unit claims to have a weapon which isn't actually defined. There needs to be only one of these weapons and it is created by setting {{taglink|weaponName|"NOWEAPON"}} rather than by the {{taglink|weaponType}} tag. | ||
==Sub Tables== | ==Sub Tables== | ||
===damage=== | ===damage=== | ||
The damage subtable lists how many hit points the weapon depletes against each armor class (See [[Armordefs.lua]]). It is a key-value map of armor class names and damage values. The special <code>default</code> entry is as the name suggests the default damage applied to any unit which does not belong to a listed armor class, or to shields. | |||
For example a weapon which deals 100 damage by default but only 50 to units in the 'tank' armor class: | |||
<code><pre>damage = { | |||
default = 100, | |||
tank = 50, | |||
}</pre></code> | |||
===shield=== | ===shield=== | ||
The preferred way to create a shield or | The preferred way to create a shield or repulser is to use the shield subtable rather than the old shield tags. | ||
The following tags are | The following tags are repulser specific: | ||
{{tag | {{tag | ||
|name = | |name = repulser | ||
|type = bool | |type = bool | ||
|default = false | |default = false | ||
|description = Does the shield [http://dictionary.reference.com/browse/repulse?s=t repulse] (deflect) projectiles or absorb them?}} | |description = Does the shield [http://dictionary.reference.com/browse/repulse?s=t repulse] (deflect) projectiles or absorb them? Btw its [http://springrts.com/mantis/view.php?id=4206 not repulsOr, but repulsEr]!}} | ||
{{tag | {{tag | ||
| Line 729: | Line 1,054: | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = The force applied by the | |description = The force applied by the repulser to the weapon - higher values will deflect weapons away at higher velocities.}} | ||
{{tag | {{tag | ||
| Line 735: | Line 1,060: | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = The maximum speed the | |description = The maximum speed the repulser will impart to deflected projectiles.}} | ||
{{tag | {{tag | ||
| Line 749: | Line 1,074: | ||
|type = int | |type = int | ||
|default = 0 | |default = 0 | ||
|description = [http://en.wikipedia.org/wiki/Mask_(computing) Bitmask] representing the types of weapons that this shield can intercept. Each digit of binary that is set to one means that a weapon with the corresponding digit in its | |description = [http://en.wikipedia.org/wiki/Mask_(computing) Bitmask] representing the types of weapons that this shield can intercept. Each digit of binary that is set to one means that a weapon with the corresponding digit in its {{taglink|interceptedByShieldType}} will be intercepted by this shield (See [[Shield Interception Tag Use]]).}} | ||
{{tag | |||
|name = armorType | |||
|type = string | |||
|default = "" | |||
|description = Specifies the armorclass of the shield; you can input either an [[Armordefs.lua|armorclass]] name OR a unitdef {{xtaglink|Gamedev:UnitDefs|name}} to share that unit's armorclass.}} | |||
{{tag | {{tag | ||
| Line 767: | Line 1,098: | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = The amount of the energy resource consumed by the shield to absorb or repulse weapons, continually drained by a | |description = The amount of the energy resource consumed by the shield to absorb or repulse weapons, continually drained by a repulser as long as the projectile is in range.}} | ||
{{tag | {{tag | ||
| Line 785: | Line 1,116: | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = How many hit-points the shield starts with - otherwise the shield must regenerate from <code>0</code> until it reaches maximum | |description = How many hit-points the shield starts with - otherwise the shield must regenerate from <code>0</code> until it reaches maximum {{taglink|power}}.}} | ||
{{tag | {{tag | ||
| Line 797: | Line 1,128: | ||
|type = float | |type = float | ||
|default = 0.0 | |default = 0.0 | ||
|description = How much energy resource is consumed to regenerate each | |description = How much energy resource is consumed to regenerate each hit-point.}} | ||
{{tag | {{tag | ||
| Line 821: | Line 1,152: | ||
{{tag | {{tag | ||
|name = badColor | |name = badColor | ||
|type = | |type = float[4] | ||
|default = {1.0, 0.5, 0.5} (Red) | |default = {1.0, 0.5, 0.5, 1.0} (Red) | ||
|description = The | |description = The RGBA colour the shield transitions to as its hit-points are reduced towards <code>0</code>.}} | ||
{{tag | {{tag | ||
|name = goodColor | |name = goodColor | ||
|type = | |type = float[4] | ||
|default = {0.5, 0.5, 1.0} (Blue) | |default = {0.5, 0.5, 1.0, 1.0} (Blue) | ||
|description = The | |description = The RGBA colour the shield transitions to as its hit-points are regenerated towards its maximum {{taglink|power}}.}} | ||
=== | {{tag | ||
|name = alpha | |||
|type = float | |||
|default = 0.2 | |||
|description = The alpha transparency of the shield whilst it is visible.}} | |||
===customParams=== | ===customParams=== | ||
| Line 839: | Line 1,174: | ||
==Examples== | ==Examples== | ||
[ | Some games may have most WeaponDefs integrated into their [[Gamedev:UnitDefs#Examples|UnitDefs]]. | ||
[http:// | S44 and MC:L implement an [http://en.wikipedia.org/wiki/Object-oriented_programming OOP] paradigm with [http://en.wikipedia.org/wiki/Inheritance_(computer_science) inheritance]. | ||
{{ExampleRepoLinks | |||
|path = weapons/ | |||
|entity = WeaponDefs | |||
}} | |||
[[Category: Game Dev]] | |||
[[Category: Game | |||
Latest revision as of 05:38, 25 October 2018
Development < Gamedev:Main < Gamedev:WeaponDefs
Location
WeaponDef files are .lua files stored in the Weapons/ directory of a Spring Game. Alternatively they can be integrated into UnitDefs.
Purpose
WeaponDef files have one purpose; to define the properties of weapons. They are the main description file for what attributes your weapon should have and how it should behave. Since version 100.0, Spring will record a warning whenever it finds an unknown tag.
Source
The engine source code which loads the tags from these files is viewable here:
Data Types
- int
- An integer number. eg. 5
- float
- A number with decimals. eg 1.023
- bool
- A value which can be true or false. eg true
- string
- Text, or more precisely a string of alphanumeric characters. eg "string of characters"
- rgb
- Three float components, representing red, green and blue components, ranged from 0.0 to 1.0. eg {0.0, 0.0, 0.0}
- float3
- Three float components, eg {0.0, 0.0, 0.0}
- float4
- Four float components, eg {0.0, 0.0, 0.0, 0.0}
Details
There follows a comprehensive (certain deprecated tags are not present) list of the tags available, their data type, default value and a brief description of what they do. Bear in mind that the source code linked above is the ultimate reference when dealing with these tags.
In lua tables keys (i.e. the tags) should be lower case, here they are represented in camelCase for readability. In your files you may use the lowerkeys function on your final table to ensure the keys are properly cased.
It is usual to name the returned WeaponDef table the internal weaponName desired for the weapon.
Common
The following tags are common to all or at least a majority of WeaponTypes, depending on the tag.
General
string weaponType default: "Cannon"
- Spring has 14 WeaponTypes which provide game developers with basic behaviours which they can customise to an extent with the WeaponDef tags. Some tags are specific to certain WeaponTypes and not implemented for others, this two-way table indicates which tags work for which types. The possible values are:
- AircraftBomb
- BeamLaser
- Cannon
- Dgun
- EmgCannon
- Flame
- LaserCannon
- LightningCanon
- Melee
- MissileLauncher
- Rifle
- Shield
- StarburstLauncher
- TorpedoLauncher
string name default: "Weapon"
- The descriptive name of the weapon as listed in FPS mode.
bool turret default: false
- Does the unit aim within an arc (up-to and including full 360° turret traverse) or always aim along the owner's heading?
bool noSelfDamage default: false
- Can the weapon's explosion damage the unit which fires it? Useful for preventing bombers with high-yield weapons destroying themselves.
bool impactOnly default: false
- Does the weapon only deal damage through direct hits and not 'splash' damage through areaOfEffect?
bool noExplode default: false
- Does the weapon explode on impact with a target or continue through? Note that these weapons will do damage every single frame they are inside the collision volume of an object, underground or under water, massively multiplying their damage.
bool burnblow default: false lua: selfExplode
- Does the weapon explode when it reaches its maximum range or continue on its path? The name is an OTAism.
float range default: 10.0
- The maximum range in elmos that the weapon can fire at.
float weaponVelocity default: 0.0
- The velocity in elmos per second of the weapon projectile. Since 99.0
maxVelocityis a synonym.
float reloadTime default: 1.0
- The time in seconds between shots fired.
float metalPerShot default: 0.0
- Metal used per shot. If the specified amount is not available, the weapon cannot be fired. Can also be used to specify how much a stockpile weapon will cost to build.
float energyPerShot default: 0.0
- Energy used per shot. If the specified amount is not available, the weapon cannot be fired. Can also be used to specify how much a stockpile weapon will cost to build.
float myGravity default: 0.0
- Overrides the map gravity for ballistic weapons. The default of
0.0disables the tag in favour of map gravity.
float fireStarter default: 0.0
- The percentage chance (
0.0to100.0) of the weapon setting fire to static map features on impact.
float cameraShake default: damage (0.0 for paralyzers)
- Passed to the ShockFront() callin as the first argument. Intended as a means to make the camera shake if in range of detonation.
bool stockpile default: false
- Does each round of the weapon have to be built and stockpiled by the player? Will only correctly function for the first of each stockpiled weapons a unit has.
float stockpileTime default: reloadTime
- The time in seconds taken to stockpile one round of the weapon.
int interceptedByShieldType default: Depends on weaponType
- Bitmask representing the types of shields that can intercept this weapon. Each digit of binary that is set to one means that a shield with the corresponding digit in its interceptType will intercept this weapon. A value of
0means that no shields will intercept the weapon. The defaults are as follows:
0- #DGun1- #Cannon and #EmgCannon2- #LaserCannon and #BeamLaser4- #MissileLauncher and #StarburstLauncher8- #AircraftBomb16- #Flame32- #TorpedoLauncher64- #LightningCannon128- #Rifle256- #Melee
(See Shield Interception Tag Use).
Collision & Avoidance
bool avoidGround default: true
- Should the weapon avoid firing if terrain blocks the line of fire?
bool avoidFriendly default: true
- Should the weapon avoid firing if a friendly unit is in the line of fire?
bool avoidFeature default: true
- Should the weapon avoid firing if a static map feature is in the line of fire?
bool avoidNeutral default: false
- Should the weapon avoid firing if a neutral unit is in the line of fire?
bool collideEnemy default: true lua: noEnemyCollide
- Does the weapon projectile collide with enemy units or pass through?
bool collideFriendly default: true lua: noFriendlyCollide
- Does the weapon projectile collide with friendly units or pass through?
bool collideFirebase default: false lua: noFirebaseCollide
- Does the weapon projectile collide with friendly firebase units the owner is loaded onto, or pass through?
bool collideFeature default: true lua: noFeatureCollide
- Does the weapon projectile collide with static map features or pass through?
bool collideNeutral default: true lua: noNeutralCollide
- Does the weapon projectile collide with neutral units or pass through?
bool collideGround default: true lua: noGroundCollide
- Does the weapon projectile collide with terrain or pass through?
float collisionSize default: 0.05 (0.5 for #Flame and #LaserCannon, 10.0 for #Dgun)
- Modifies visual size of EMG and Flame projectiles, and physical size only for hitscan interceptor weapons (e.g. antinuke lasers). [1][2]
Targeting & Accuracy
bool commandFire default: false
- Determines if the weapon will automatically fire on enemy units in range or only when manually ordered to attack.
bool canAttackGround default: true
- Determines if the weapon can be force-fired on ground positions or only fire on targeted units.
bool waterWeapon default: false
- Determines if the weapon can pass through water and target underwater units.
bool fireSubmersed default: waterWeapon
- Determines if the weapon can fire whilst underwater.
float targetBorder default: 0.0 (1.0 for #Melee)
- Controls whether the weapon aims for the centre or the edge of its target's collision volume. Clamped between
-1.0- target the far border, and1.0- target the near border.
float cylinderTargeting default: 0.0 (1.0 for #Melee)
- Controls whether the weapon range is calculated in a sphere or a cylinder. The height of the cylinder is determined by the value of this tag multiplied by the range. Clamped between
0.0and128.0.
float tolerance default: 3000.0 (+/- ~18 degrees)
- The amount (in cau) to which the weapon's "real" aim can be off while the weapon will still be able to fire accurately at the target. For turret = false or fixedLauncher = true weapons this determines in what arc the unit will fire.
float fireTolerance default: 32768.0 (+/- 180 degrees) New in version 99.0
- Final check to prevent weapons from shooting sideways. If a weapon is about to fire but the difference between its old aim and requested aim is greater than this angle (in cau) then it will not fire.
bool allowNonBlockingAim default: false New in version 99.0
- When enabled it makes AimWeapon() script calls non-blocking (still the fireTolerance tag might prevent the weapon firing). This is very useful for fast units that need to re-target often.
float targetMoveError default: 0.0
- The degree to which a weapon's aiming will fail to keep up with its target's movement. It adds a fraction of the target's speed (per second) as a random error to the targetting. So if the target moves 50 units per second and the targetmoveerror is 0.5 a random error of 25 will be added to the target position. If set very low or not set at all, a weapon will lead its target and almost always hit.
float leadLimit default: -1.0
- Limits the maximum distance a unit will lead a target. The default of
-1allows an infinite distance.
float leadBonus default: 0.0
- Controls how experience boosts the weapon's target leading. Is multiplied with the unit's experience and added to the leadLimit.
float predictBoost default: 0.0 (0.5 for burnblow = true weapons)
- Controls how well the weapon predicts unit speeds. Works in a similar way to targetMoveError except that it is 1-dimensional. This tag spreads the shots in a line based on the direction of the target whereas targetMoveError spreads the shots all around based on the movement.
float heightMod default: 0.2 (0.8 for #Cannon, 1.0 for #BeamLaser and #LightningCannon)
- Changes the spherical weapon range into an ellipsoid. Values above
1.0mean the weapon cannot target as high as it can far, values below1.0mean it can target higher than it can far. For example0.5would allow the weapon to target twice as high as far.
float proximityPriority default: 1.0
- Acts as a multiplier for the distance to the target in the priority calculation. Note that negative values make weapons prefer distant targets.
float accuracy default: 0.0
- How accurate the weapon is. Lower values are more accurate. Accuracy is relative to the distance to the target; for instance, if the target is very close, even a very high value will probably still hit. If a target is very far away, even a very low value will likely cause the weapon to miss.
float movingAccuracy default: accuracy
- A weapon's accuracy whilst the owning unit is moving.
float sprayAngle default: 0.0
- How wide the the angle of a burst from a burst weapon can be. Very similar to accuracy, except that this tag affects each projectile in a burst, whilst the former does not.
float ownerExpAccWeight default: 0.0 (See description)
- A multiplier to accuracy and sprayAngle that reduces inaccuracy as a units experience increases. Defaults are as follows:
0.9- #Cannon, #Rifle0.7- #LaserCannon, #BeamLaser, #StarburstLauncher0.5- #MissileLauncher, #LightningCannon, #EmgCannon, #DGun0.2- #Flame
int targetable default: 0 New in version 92.0 Previously only for #StarburstLauncher
- Bitmask representing the types of weapon that can intercept this weapon. Each digit of binary that is set to one means that a weapon with the corresponding digit in its interceptor tag will intercept this weapon. Instant-hitting weapons such as #BeamLaser, #LightningCannon and #Rifle cannot be targeted.
int interceptor default: 0 New in version 92.0 Previously only for #StarburstLauncher
- Bitmask representing the types of weapons that this weapon can intercept. Each digit of binary that is set to one means that a weapon with the corresponding digit in its targetable tag will be intercepted by this weapon.
bool interceptSolo default: true New in version 92.0
- If
trueno other interceptors may target the same projectile.
float coverage default: 0.0 New in version 92.0 Previously only for #StarburstLauncher
- The radius in elmos within which an interceptor weapon will fire on targetable weapons.
Bouncing
bool waterBounce default: false
- Does the weapon bounce on water impacts?
bool groundBounce default: false
- Does the weapon bounce on ground impacts?
float bounceSlip default: 1.0
- The decimal-percentage amount of horizontal velocity a projectile keeps when it bounces.
float bounceRebound default: 1.0
- The decimal-percentage amount of vertical velocity a projectile keeps when it bounces.
int numBounce default: -1
- The number of times the weapon will bounce on impact before exploding. The default value of
-1allows infinite bounces (at least until velocity reaches 0).
Area Of Effect, Impulse & Cratering
float areaOfEffect default: 8.0 * 0.5 lua: damageAreaOfEffect
- The diameter in elmos in which the weapons explosion will cause damage.
float craterAreaOfEffect default: areaOfEffect * 0.5
- The radius in elmos in which the weapons explosion will cause terrain cratering. Behaviour changed slightly in 98.0 as previously craters were 1.5x craterAreaOfEffect whilst decals were 1.0x, they are now both the same size.
float edgeEffectiveness default: 0.0
- Determines what percent of a weapon's maximum damage value will be applied to units within the weapon's areaOfEffect. Falls off from the epicentre according to the formula
damageApplied = damage * [(areaOfEffect - distToUnit) / (areaOfEffect - (distToUnit * edgeEffectiveness))], a graph of the function for various values is available here.
float explosionSpeed default: See description
- The speed at which the weapon's explosion propagates from the epicentre. The default is calculated by this complex formula:
defExpSpeed = {8.0 + [max(30.0, default_damage / 20.0) * 2.5]} / {9.0f + [sqrt(max(30.0, default_damage / 20.0f)) * 0.7]} * 0.5.
float impulseFactor default: 1.0
- A multiplier to the impulse given to units within the explosion areaOfEffect, which is otherwise equal to the damage dealt after edgeEffectiveness is taken into account. For #Melee weapons this is instead multiplied by the owning unit's mass (See Gamedev:UnitDefs).
float impulseBoost default: 0.0
- A constant amount added to the weapon's impulse, regardless of distance from the epicentre or the damage potential of the explosion, prior to the application of impulseFactor
float craterMult default: impulseFactor
- A multiplier to depth of terrain crater the weapon's explosion will create, which is otherwise based on the damage potential.
float craterBoost default: 0.0
- A constant amount, added to the weapon's cratering depth before the application of craterMult.
Bursts
int burst default: 1 lua: salvoSize
- How many shots to fire per burst.
float burstRate default: 0.1 lua: salvoDelay
- The time in seconds between shots in a burst. Note that reloadTime starts to count down from the first round fired, not the last so if
reloadTime < burst * burstRatethe weapon will fire continuously.
int projectiles default: 1
- How many projectiles released per shot (shotgun style). e.g. a weapon with burst = 5, burstRate = 0.5 and projectiles = 2 will shoot 5 lots of 2 for 10 projectiles total, with gaps of 0.5 seconds, before waiting for reloadTime. Best used in conjunction with sprayAngle or changing the firing piece using ShotX as otherwise they'll all be clumped in one shot.
Paralyzing
bool paralyzer default: false
- Is the weapon a paralyzer? If
truethe weapon only stuns enemy units and does not cause damage in the form of lost hit-points.
int paralyzeTime default: 10 lua: damages.paralyzeDamageTime
- Determines the maximum length of time in seconds that the target will be paralyzed. The timer is restarted every time the target is hit by the weapon. Cannot be less than
0.
Dynamic Damage
The following set of tags allow for a weapon's damage potential to vary with the distance to its target.
float dynDamageExp default: 0.0
- Exponent of the range-dependent damage formula, the default of
0.0disables dynamic damage,1.0means linear scaling,2.0quadratic and so on.
float dynDamageMin default: 0.0
- The minimum floor value that range-dependent damage can drop to.
float dynDamageRange default: 0.0
- If set to non-zero values the weapon will use this value in the range-dependant damage formula instead of the actual range.
bool dynDamageInverted default: false
- If
truethe damage curve is inverted i.e. the weapon does more damage at greater ranges as opposed to less.
Sounds
bool soundTrigger default: false (true for #Melee, #Rifle and non-beamBurst #BeamLaser)
- Does the weapon play soundStart only once for each salvo (
true) or for every round in a burst (false)?
string soundStart default: ""
- The name of a SoundItem (See Sounds.lua) or filename of a sound to play when the weapon fires.
string soundHitDry default: ""
- The name of a SoundItem (See Sounds.lua) or filename of a sound to play when the weapon collides with solid ground. Note that a #BeamLaser will play this sound every frame of its lifetime.
string soundHitWet default: ""
- The name of a SoundItem (See Sounds.lua) or filename of a sound to play when the weapon collides with water. Note that a #BeamLaser will play this sound every frame of its lifetime.
Visuals
string cegTag default: ""
- The name, without prefixes, of a CEG to be emitted by the projectile each frame.
float intensity default: 0.9 (0.2 for #Cannon)
- Alpha transparency for non-3D model projectiles. Lower values are more opaque, but
0.0will cause the projectile to disappear entirely.
string model default: ""
- The filename of a 3D model to use when rendering the projectile. Note that only the root piece of a projectile model is rendered. Currently only for #Cannon, #LaserCannon, #MissileLauncher, #StarburstLauncher and #TorpedoLauncher.
bool explosionScar default: false
- Does the weapon's explosion leave a scar decal on the ground? For all types except #Melee and #Rifle.
bool alwaysVisible default: false
- If
truethe weapon is always rendered regardless of whether or not it is in LOS range of a player's units.
float[3] rgbColor default: {1.0, 0.0, 0.0} (See Description)
- The primary colour for sprite rendering weapons. Additional defaults are as follows:
- #Cannon -
{1.0, 0.5, 0.0} - #EmgCannon -
{0.9, 0.9, 0.2}
string explosionGenerator default: ""
- The name of a CEG, with
custom:prefix, to spawn as the weapon's explosion. Does not currently work for #Melee and #Rifle.
string bounceExplosionGenerator default: ""
- For weapons which can use groundBounce = true, the name of a CEG, with
custom:prefix, to spawn when weapon the bounces.
string texture1 default: ""
- The projectile texture for #AircraftBomb, #Cannon, #EmgCannon, #Flame; beam texture for #LaserCannon, #BeamLaser, #LightningCannon; flare texture for #MissileLauncher, #StarburstLauncher and dome texture for the #Shield.
string texture2 default: ""
- The end-of-beam texture for #LaserCannon, #BeamLaser and smoketrail texture for #MissileLauncher, #StarburstLauncher.
string texture3 default: ""
- Flare texture for #BeamLaser, or muzzle texture if largeBeamLaser = true. Also used as the flame texture for #StarburstLauncher.
string texture4 default: ""
- Flare texture for #BeamLaser with largeBeamLaser = true.
AircraftBomb
Drops a ballistic projectile at the same movement vector as the unit itself. Intended only for aircraft. Visually drawn as a billboarded sprite as used by the #Cannon, but more commonly used with a 3D model.
There are no tags specific to this WeaponType
AircraftBomb Visuals
When not using a model, the AircraftBomb is the same as #Cannon Visuals.
BeamLaser
An instant-hit weapon which spawns a beam and does a portion of its total damage each frame. Cannot be script emitted if it has a beamTime longer than one frame. Visually drawn as a Star Trek Phaser-style laser weapon. The largeBeamLaser tag allows changing the visual effect of the laser, such as using a tileable, scrolling texture without changing the behaviour.
float minIntensity default: 0.0
- The minimum percentage the weapon's damage can fall-off to over its range. Setting to
1.0will disable fall off entirely. Unrelated to the visual-only intensity tag.
float beamTime default: 1.0 lua: beamtime (all lowercase!)
- How long in seconds to fire the laser before waiting for reloadTime to start. Damage is distributed over the duration of the beamTime, and the weapon will aim to hit the target when the beam is in the middle of its beamTime (i.e. using prediction).
bool beamBurst default: false lua: beamburst (all lowercase!)
- Makes the laser fire a burst of beams that are all aimed towards the target (instead of aimed with the piece). A #BeamLaser can do its full damage with every shot if beamBurst is enabled. Disables beamTime in favour of the burst tags.
bool sweepFire default: false
- Makes the laser continue firing while it aims for a new target, 'sweeping' across the terrain. Reimplemented in 95.0, still has no script interaction so use with care. Respects reloadTime constraint but not much else.
BeamLaser Visuals
See also thickness and coreThickness.
int beamTTL default: 0
- The time in frames for which the laser beam remains visible.
float beamDecay default: 1.0
- How fast the beam fades out. Each frame the intensity is multiplied by this value.
float laserFlareSize default: 15.0
- Determines the size of the firing flare.
bool largeBeamLaser default: false
- Changes the visual effect allowing tiling and scrolling of the texture and a pulsating firing flare.
float tileLength default: 200.0
- Defines the length before the texture used is repeated (tiled). Only if largeBeamLaser = true.
float scrollSpeed default: 5.0
- Controls how fast the texture scrolls. Only if largeBeamLaser = true.
float pulseSpeed default: 1.0
- Controls how fast the pulsating effect at the start of the beam is. Only if largeBeamLaser = true.
Cannon
The default WeaponType. Fires a ballistic projectile, for the best result (without under/overshooting) the weaponVelocity should be set so as to give an elevation of 45° when firing at the maximum range. Substituting the angle into the trajectory equation and rearranging, we get:
weaponVelocity = √(range * g)
where g is the map gravity, usually around 120 for most Spring maps (You can use the myGravity tag if you want to be exact). Visually drawn as a billboarded sprite or 3D model.
int highTrajectory default: 2
- Can this weapon be fired in a high trajectory (>45° angle). Can be
0- low trajectory only,1- high trajectory only or2- enables a high/low toggle button on the unit.
float heightBoostFactor default: -1.0
- Controls the boost given to range by high terrain. Values >
1.0result in increased range,0.0means the cannon has fixed range regardless of height difference to target. Any value <0.0(i.e. the default value) result in an automatically calculated value based on range and theoretical maximum range.
Cannon Visuals
float size default: 2.0 + min(default_damage * 0.0025, areaOfEffect * 0.1)
- The drawing radius of the billboarded sprite. Also for #AircraftBomb Visuals, #EmgCannon Visuals (default:
3.0) and #Flame Visuals.
string colorMap default: ""
- A set of RGB colours to transition between over the projectile's lifetime. Can be given as a string of RGB digits or an image filename (See CColorMap). Also for #Flame Visuals.
float sizeDecay default: 0.0
- How quickly each particle of the Cannon shot decays in size.
float alphaDecay default: 1.0
- How quickly each particle of the Cannon shot fades out.
float separation default: 0.0
- The distance between each particle of the Cannon shot.
bool noGap default: true
- Switch between the distance between particles being proportional to the size of the two particles (
true) or proportional to the size of the first particle (false).
int stages default: 5
- The number of particles in each Cannon shot.
DGun
Fires a line-of-sight or ballistic projectile (selected via the gravityAffected tag). Visually represented by a fireball effect that cannot be customised, however it can be replaced by a 3D model. The name and visual effect are OTAisms.
bool gravityAffected default: false
- Does the fireball projectile lose height due to map gravity?
EmgCannon
A line-of-sight weapon. Visually drawn as a billboarded sprite very similar to that of the #Cannon, however not as customisable, or a 3D model. The name is another OTAism.
There are no tags specific to this WeaponType.
Flame
A line-of-sight weapon intended for use as a flamethrower or similar. Visually drawn as a stream of textured particles, the colour of which can be controlled very precisely using the colorMap tag (see CColorMap).
Flame Visuals
See also colorMap.
float sizeGrowth default: 0.5
- How much the draw radius of the flame projectile increases each frame.
float flameGFXTime default: 1.2
- Makes the flamethrower projectile stay alive as a visual-only effect (i.e. does not deal any damage) after it has reached maximum range. It is a percentage multiplier, e.g.
1.2makes the projectile stay alive until it reaches 20% beyond range.
LaserCannon
A particularly versatile line-of-sight weapon. Visually drawn like a Star Wars Blaster-style laser weapon, or a 3D model.
LaserCannon Visuals
float duration default: 0.05
- Multiplied against weaponVelocity to determine the visual length of the beam projectile.
bool hardStop default: false
- Does the laser projectile stop dead or fade out?
float fallOffRate default: 0.5
- Rate at which the beam fades out after it goes past its maximum range if hardStop = false. A value of
0.0is never fade out,1.0is finish fading out exactly at maximum range.
int lodDistance default: 1000
- Minimum camera distance at which the default LaserCannon projectile is simplified to a single rectangle.
float thickness default: 2.0
- The thickness (width) of the LaserCannon projectile. Also for #BeamLaser Visuals.
float coreThickness default: 2.0
- The thickness (width) of the LaserCannon projectile's core. Also for #BeamLaser Visuals.
float rgbColor2 default: {1.0, 1.0, 1.0}
- The colour of the LaserCannon projectile's core. Also for #BeamLaser Visuals.
LightningCannon
An instant-hit weapon similar to the #BeamLaser, but which does all its damage at once. Visually drawn like Star Wars 'Force Lightning' or CnC: Red Alert Tesla Coil weapons, the effect is not very customisable.
There are no tags specific to this WeaponType.
Melee
A weapon that always damages the target, no ifs or buts; unsurprisingly intended for use as a close quarters 'melee' weapon. It does not fire a projectile and does not care about the line of fire.
There are no tags specific to this WeaponType.
MissileLauncher
A versatile weapon which can optionally track targets and accelerate from a low initial velocity. It can also use trajectoryHeight to have the shot arc similar to a ballistic projectile. Visually represented by a 3D model, with an optional smokeTrail.
float startVelocity default: 0.0
- The initial velocity of the weapon projectile. Also for #StarburstLauncher and #TorpedoLauncher.
float weaponAcceleration default: 0.0
- The initial acceleration of the weapon projectile. Also for #StarburstLauncher and #TorpedoLauncher. Note that if it is
0.0the weapon can never increase from its startVelocity and will not reach its maximum weaponVelocity. Since 99.0accelerationis a synonym.
bool tracks default: false
- Can the weapon projectile track a moving target? Also for #StarburstLauncher and #TorpedoLauncher.
float turnRate default: 0.0
- The rate (in cau) at which tracks = true weapons turn towards their target. This is relative to a projectile's current velocity; a weapon with a higher velocity will need a higher value in order to be able to hit targets that turn suddenly.
float flightTime default: 0.0
- The time in seconds before a missile projectile's fuel runs out; it ceases to obey tracks, loses velocity and falls to the ground. Also for #StarburstLauncher. Large values may cause over/undershoot problems. As of 104.0 also applies to #EmgCannon.
bool fixedLauncher default: false
- Makes the projectile spawn with the orientation of the shooting piece instead of their normal orientation. Also for #StarburstLauncher and #TorpedoLauncher. Weapons may not correctly obey avoidance settings when using this tag.
float wobble default: 0.0
- Adds a random vector to the direction of travel every 16 frames, multiplied by the value of the tag. The effect is reduced as the firing unit gains experience. As this missiles direction is changed, wobbling swarm of missiles will diverge.
float dance default: 0.0
- Adds a random vector to the position of a missile projectile every 8 frames, multiplied by the value of the tag. As the projectile is not rotated, a dancing swarm of missiles will remain relatively coherent.
float trajectoryHeight default: 0.0
- Determines the height of the arc the missile will reach as it moves towards its target. A value of
0.0will result in a flat trajectory,1.0will launch at 45°. Can be any value >=0.0; extreme values may require the tracks tag to be able to hit a target.
MissileLauncher Visuals
A note about the missile exhaust flare: the size of the flare is determined by the model radius. The emit position of the flare is at (0,0,-radius) so the model may need careful adjustment to get the flare looking right.
bool smokeTrail default: false
- Does the missile projectile emit a smoke trail as it travels? Also for #StarburstLauncher.
Rifle
An instant hit weapon which does all its damage at once. Visually represented by a hardcoded tracer, firing and hitting effects. Rarely used.
There are no tags specific to this WeaponType.
Shield (WeaponType)
As the name suggests, not a weapon but a defensive shield. Can absorb or deflect (repulsor = true) projectiles. Individual weapons can be set to be intercepted or not by the shield using a bitmask (see Shield Interception Tag Use). Visually represented as a translucent sphere, with control over colour and texture; by default the shield is invisible (visible = false).
See the #shield sub-table section for other tags specific to this type.
StarburstLauncher
Fires a projectile that rises vertically for weaponTimer seconds, then turns towards its target. It can optionally track targets and accelerate from a low initial velocity. Before spring 92.0 was the only weapon that can be targetable and act as an interceptor. Visually represented by a 3D model, with an optional smokeTrail.
float weaponTimer default: 0.0
- The time in seconds during which the missile ascends vertically before turning towards its target.
TorpedoLauncher
Fires a projectile that will behave ballistically out of water and like a missile in water. Usually used with waterWeapon = true so they can fire underwater and target underwater units. An aircraft carrying a #TorpedoLauncher is a special case, the weapon turns into an #AircraftBomb projectile that will spawn a torpedo projectile on impact with water. Visually represented by a pointed black cuboid, usually the default object is replaced by a 3D model.
bool subMissile default: false
- Can the torpedo leave the water and target units and positions on land?
NoWeapon
Not actually a WeaponType, but an individual weapon requested by Spring to 'fill in the gaps' if a unit claims to have a weapon which isn't actually defined. There needs to be only one of these weapons and it is created by setting weaponName = "NOWEAPON" rather than by the weaponType tag.
Sub Tables
damage
The damage subtable lists how many hit points the weapon depletes against each armor class (See Armordefs.lua). It is a key-value map of armor class names and damage values. The special default entry is as the name suggests the default damage applied to any unit which does not belong to a listed armor class, or to shields.
For example a weapon which deals 100 damage by default but only 50 to units in the 'tank' armor class:
damage = {
default = 100,
tank = 50,
}
shield
The preferred way to create a shield or repulser is to use the shield subtable rather than the old shield tags.
The following tags are repulser specific:
bool repulser default: false
- Does the shield repulse (deflect) projectiles or absorb them? Btw its not repulsOr, but repulsEr!
float force default: 0.0
- The force applied by the repulser to the weapon - higher values will deflect weapons away at higher velocities.
float maxSpeed default: 0.0
- The maximum speed the repulser will impart to deflected projectiles.
bool visibleRepulse default: false
- Is the (hard-coded) repulse effect rendered or not?
The following tags are general behaviour for all shields:
int interceptType default: 0
- Bitmask representing the types of weapons that this shield can intercept. Each digit of binary that is set to one means that a weapon with the corresponding digit in its interceptedByShieldType will be intercepted by this shield (See Shield Interception Tag Use).
string armorType default: ""
- Specifies the armorclass of the shield; you can input either an armorclass name OR a unitdef name to share that unit's armorclass.
bool smart default: false
- Determines whether or not projectiles fired by allied units can pass through the shield (
true) or are intercepted as enemy weapons are (false).
bool exterior default: false
- Determines whether or not projectiles fired within the shield's radius can pass through the shield (
true) or are intercepted (false).
float energyUse default: 0.0
- The amount of the energy resource consumed by the shield to absorb or repulse weapons, continually drained by a repulser as long as the projectile is in range.
float radius default: 0.0
- The radius of the circular area the shield covers.
float power default: 0.0
- Essentially the maximum allowed hit-points of the shield - reduced by the
damageof a weapon upon impact.
float startingPower default: 0.0
- How many hit-points the shield starts with - otherwise the shield must regenerate from
0until it reaches maximum power.
float powerRegen default: 0.0
- How many hit-points the shield regenerates each second.
float powerRegenEnergy default: 0.0
- How much energy resource is consumed to regenerate each hit-point.
float rechargeDelay default: 0.0
- The delay in seconds before a shield begins to regenerate after it is hit.
The following tags control the visual aspects of the shield:
bool visible default: false
- Is the shield visible or not?
int visibleHitFrames default: 0
- The number of frames a shield becomes visible for when hit.
float[4] badColor default: {1.0, 0.5, 0.5, 1.0} (Red)
- The RGBA colour the shield transitions to as its hit-points are reduced towards
0.
float[4] goodColor default: {0.5, 0.5, 1.0, 1.0} (Blue)
- The RGBA colour the shield transitions to as its hit-points are regenerated towards its maximum power.
float alpha default: 0.2
- The alpha transparency of the shield whilst it is visible.
customParams
The customParams subtable of a WeaponDef allows the game designer to give their weapons custom attributes, which can then be accessed via lua gadgets and widgets. It is a map (key-value pair indexed table) of strings. When accessing these attributes in lua the strings can be turned back into numbers, bools or even tables. This gives great control to game designers to essentially implement their own behaviour tags.
There are no additional tags specific to this subtable
Examples
Some games may have most WeaponDefs integrated into their UnitDefs.
S44 and MC:L implement an OOP paradigm with inheritance.
'Balanced Annihilation' WeaponDefs
'MechCommander: Legacy' WeaponDefs