User Tools

Site Tools


modding:xml:weapon_devices

This is an old revision of the document!


Overview

Weapons are item types that fire projectiles. The <Weapon> element defines both the way in which projectiles are fired (e.g., the rate of fire, the power consumed, etc.) and the nature of the projectiles themselves (e.g., the speed of the projectile, the damage caused, etc.)

Some weapons fire a single type of projectile; in that case, the definition of the weapon and the projectile are both included in the <Weapon> element. See: Example 1.

Other times, the weapon fires more than one type of projectile. In that case, the definition of the projectiles are in the <Missiles> sub-element. See: Example 2.

Here is a comprehensive thread that describes how weapons are defined: Weapons Overview (basic++)

Basic Parameters

These are the attributes for a weapon that define how the projectiles are fired.

fireRate= The number of game seconds that elapse between shots. By default, a game second is two ticks, so this is twice the number of ticks between shots.

powerUse= The amount of power consumed each tick while the weapon is firing. Power is expressed in tenths of megawatts, so a value of 10 equals 1 MW.

idlePowerUse= The amount of power consumed each tick while the weapon is not firing. Optional. Defaults to 10% of powerUse. (New in 1.06)

recoil= If non-zero, this accelerates the ship opposite to the direction of fire. The acceleration is proportional to the square of the value (e.g., a value of 2 has a recoil four times stronger than a value of 1).

failureChance= The % chance that the weapon will fail when it fires.

charges= If true, the weapon uses up a charge when it is fired. The weapon will not fire if it has no charges left.

Launchers

A weapon with more than one <Missile> sub-element is automatically considered a launcher. Launchers take up a different slot and are fired with a different trigger. Moreover, the player may select which missile to fire with the launcher. [In contrast, non-launchers can only fire a single type of projectile.]

launcher= If set to true, this parameter specifies that the weapon should be treated as a launcher regardless of the number of <Missile> sub-elements. With this settings, even ammo-less weapons can be treated as launchers.

reportAmmo= For purposes of statistics, when a launcher is fired, the engine collects statistics about the number of times the launcher fired and the number of each type of missile fired. Since non-launchers can only fire one type of projectile, we don't keep track of both. If you want to override this behavior for non-launchers, then set reportAmmo=“true”.

Fire Direction

By default a weapon fires forward at 0 degrees. You may change the direction of fire with the following attributes:

omnidirectional= If true, the weapon is mounted on a turret that can fire in any direction. On a player ship the weapon will fire at the currently selected target (friendly or enemy) or, if no target is selected, at the nearest enemy ship.

minFireArc= A non-zero value indicates that the weapon swivels to aim at targets. This is the minimum angle of the swivel. Within the fire arc defined by minFireArc and maxFireArc, the weapon will fire as an omnidirectional weapons, i.e., aiming at the currently selected target or the nearest enemy ship.

maxFireArc= The maximum angle of the swivel.

If minFireArc and maxFireArc are equal but non-zero then the weapon fires in the specified direction. For example, minFireArc=“180” and maxFireArc=“180” means that the weapon always fires to the rear of the ship.

NOTE: A weapon's fire direction interacts with the fire direction specified in the device slot (the <Devices> section of the <ShipClass>). In effect there are three classes of fire direction:

  • omnidirectional: The weapon can fire in any direction without restriction.
  • swivel: The weapon can fire across a specific fire arc of less then 360 degrees.
  • fixed: The weapon fires at a fixed angle (no necessarily 0 degrees).

Since both the weapon and the device slot can specify a fire direction, there are nine possible results:

                                      DEVICE SLOT
                    omni                swivel              fixed
WEAPON -------------------------------------------------------------------------
omni   |            omni                 omni                omni
       |
       |
swivel |            omni              device slot          swivel in
       |                                swivel          fixed direction
       |
fixed  |            omni              device slot      fixed in weapon+device
       |                                swivel             direction
       |

For example, a swivel device slot always overrides any swivelling in the weapon; but a fixed device slot combines with the fire direction of the weapon.

Linked Fire Controls

By default a weapon only fires when it is the selected weapon and when the player presses the appropriate fire key ([Ctrl] for weapons, [Shift] for launchers).

linkedFire= The linkedFire attribute removes the weapon from the selection rotation (i.e., the weapon can never be selected). Instead, the weapon will fire whenever the selected weapon fires. A launcher with the linkedFire attribute will fire whenever the launcher fires; a weapon will fire whenever the selected weapon fires.

The linkedFire attribute can have one of the following values:

  • always : With this value, the linked-fire weapon will always fire, regardless of the position or existance of a target.
  • whenInFireArc : With this value, the linked-fire weapon will fire only if the selected target or an enemy ship is within its fire arc.

In general, forward-facing weapons should use the always value while others should use the whenInFireArc value.

Configurations

A weapon can fire multiple projectiles at the same time. There are two ways to specify this.

configuration= This attribute specifies a standard configuration. The following values are valid:

  • alternating
  • dual
  • spread2
  • spread3
  • spread5
  • wall

<Configuration>

A better way to specify how projectiles are fired is to use the <Configuration> sub-element.

For example:

   <Configuration aimTolerance="5" alternating="true">
      <Shot posAngle="90" posRadius="12" angle="3d5-9"/>
      <Shot posAngle="270" posRadius="12" angle="3d5-9"/>
   </Configuration>

You can place aimTolerance=“how much angle you want the weapon to deviate from a straight line” within <Configuration>. In addition, alternating=true can be placed within <Configuration> to make the weapon fire each shot sequentially. The advantage of using alternating=true in <Configuration> as opposed to specifying configuration=“alternating” under <Weapon> is that the former allows a weapon to fire more than two shots in sequence; the sequence is determined by the order in which each <Shot> is placed inside <Configuration>. In the above example, <Shot posAngle=“90” posRadius=“12” angle=“3d5-9”/> will always be fired first, followed by <Shot posAngle=“270” posRadius=“12” angle=“3d5-9”/>.

<Weapon
            type=            "missile"
            
            damage=            "kinetic:0"
            repeating=          "150000"
            fireRate=         "30"
            hitPoints=         "25"
            interaction=      "5"
            hitEffect=         "&efShieldHit1;"
            missileSpeed=      "17"
            accelerationFactor=   "75"
            lifetime=         "10d5-7"
            powerUse=         "100"
            deviceSlots=      "0"
            noFriendlyFire=      "true"
            >            
         <Configuration aimTolerance="5">
            <Shot posAngle="180" posRadius="20" angle="0-180"/>   
            <Shot posAngle="180" posRadius="20" angle="360-181"/>
            <Shot posAngle="180" posRadius="20" angle="0-180"/>   
            <Shot posAngle="180" posRadius="20" angle="360-181"/>
            <Shot posAngle="180" posRadius="20" angle="0-180"/>   
            <Shot posAngle="180" posRadius="20" angle="360-181"/>
         </Configuration>
         <Effect>
            <Image imageID="&rsParticles;" imageX="0" imageY="0" imageWidth="16" imageHeight="16" imageFrameCount="4" imageTicksPerFrame="1" randomStartFrame="true"/>
         </Effect>
      </Weapon>
<shot>

means one shot. In this example, 6 shots are fired at the same time each time the weapon is fired.

posAngle="180"

posAngle is the angle you want it to fire from. 0 is facing upwards (as in the nose of the Sapphire at the 1st facing.)

posRadius="20"

means how far you want the shot to appear from the angle [in pixels] , which means that the shot shows up 20 pixels from center, towards the nose of the craft.

angle="0-180"

means how much you want the shot to deviate (as in it can fire from angle x to y) from the initial firing. Since some of it is 0-180, and others are 360-181, that means all of the shots cover the full 360 degrees. This is different from posAngle and posRadius because posAngle and posRadius determine where the shot comes out, angle determines where the shot goes. Angles 0 and 360 is the same from what I've seen, and 90 is to the left of the playership. If you want a smaller angle, use something like 355-10 to have a narrow cone in front of your ship.

Additional Parameters

maxHPBonus If specified, this is the maximum HP bonus enhancement for the device. For example, a value of 100 means that the weapon cannot be enhanced beyond 100% bonus damage. The default is 150. [API Version 17]

Defining Projectiles

The following attributes may be used in the <Weapon> element to define a single projectile type or they may be used in a <Missile> sub-element.

ammoID= If specified, this is the UNID of the item type that will be used as ammo for this projectile.

type= The type of projectile defines its basic nature. The following types are supported:

  • area
  • beam
  • missile
  • particles
  • radius

damage= The damage done by the projectile. Damage is expressed as a damage descriptor string.

lifetime= The number of ticks that the projectile will live for. This is expressed as a dice range.

repeating= If specified, this is the number of extra shots that will fire.

missileSpeed= The speed of the projectile, in % of light-speed. If this attribute is not specified, then the projectile travels at light-speed. This is expressed as a dice range.

initialDelay= If non-zero, the projectile doesn't appear for this number of ticks, expressed as a dice range.

canHitSource= If true then this projectile can hit the object that fired it. By default, this is false.

noFriendlyFire= If true then the projectile never hits any friendly objects.

autoAcquireTarget= If true then the projectile will automatically acquire an enemy target when fired.

stealth= The stealth value of the projectile.

passthrough= If specified, this is the chance that the projectile will continue in its path even after it hits and damages an object. NOTE: For area weapons the default is 80; for all others the default is 0.

sound= The sound effect UNID to be played when the projectile is fired.

Be careful when using type=“whatever”. Some weapons, like beam, do not accept tags like <effect>.

type=area

type=beam

Certain weapontypes only take certain effects: “beam” is known to take these configurations:

“starblaster”→ Used on the katana. can specify colors using hexadecimal.

                                beamType=			"starblaster"
				primaryColor=		"0x00, 0x80, 0xff"
				secondaryColor=		"0x80, 0xc0, 0xff"

“lightning”→ Used on the Ares lightning turret. Can specify colors using hexadecimal as well as intensity

                                beamType=			"lightning"
				primaryColor=		"0xf0, 0xff, 0xa0"
				secondaryColor=		"0xa9, 0xff, 0x00"
				intensity=			"5"

“blaster”→ used on the bolide

                                beamType=			"blaster"

“heavyblaser”→ used on the TeV9

                                beamType=			"heavyblaster"
				primaryColor=		"0x33, 0xff, 0x33"
				secondaryColor=		"0x00, 0x99, 0x00"
				intensity=			"5"

“laser”→ used on the mining laser

                                beamType=			"laser"
				primaryColor=		"0xf1, 0x5f, 0x2a"
				secondaryColor=		"0xff, 0x00, 0x00"
				sound=				"&snLaserCannon;"

“greenparticle”→ cool looking one. Used on the lancer cannon

                                beamType=			"greenparticle"

“blueparticle”→ not used in Vanilla, is the same as greenparticle, only blue.

				beamType=			"blueparticle"

NOTE: intensity is a parameter used by SOME beam type weapon projectiles. Valid beams include heavy blaster & lightning. Note that intensity of less than 4 will not work on beams due to a strange bug that causes them to disappear at 0, 90 180 and 270 degrees. Intensity will basically increase the size of the projectile.

type=missile

type=particles

type=radius

<Effect>

The <Effect> sub-element defines how to paint the projectile. If the element is omitted, the projectile will be invisible. See the page on Effects for a full description.

<HitEffect>

This optional sub-element defines how to paint the explosion that results when the projectile hits a target. If the element is omitted, a default hit effect is used. See the page on Effects for a full description.

<FireEffect>

This optional sub-element defines how to paint the muzzle-flash effect when a weapon fires. If the element is omitted, no fire effect is painted. See the page on Effects for a full description.

Vapor Trail

vaporTrailLength= integer, probably pixels, default is 64

vaporTrailWidth= integer, probably pixels

vaporTrailWidthInc= integer, has something to do with how trapezoidal the trail is probably, default is 25

vaporTrailColor= presumably the same color formats as are used elsewhere

quick notes from looking at one place in the source –Weaver

Fragments

Standard Stats

Level Damage Power Cost Ammo Cost Over Under
1 4 10 350 0.6 0 0
2 5 20 800 1.2 0 -20
3 7 50 1850 3.0 0 -50
4 9 100 4000 6.0 0 -100
5 12 200 8500 12.0 5 -170
6 16 300 18500 18.0 5 -250
7 21 500 39000 30.0 5 -300
8 27 1000 78500 60.0 10 -300
9 35 2000 158000 120.0 10 -300
10 46 3000 320000 180.0 10 -300
11 60 4000 640000 240.0 25 -300
12 78 6000 1300000 360.0 25 -300
13 101 8000 2700000 480.0 25 -300
14 131 10000 5300000 600.0 100 -300
15 170 12000 10600000 720.0 100 -300
16 221 15000 21300000 900.0 100 -300
17 287 20000 42600000 1200.0 200 -300
18 373 25000 85200000 1500.0 200 -300
19 485 30000 170000000 1800.0 200 -300
20 631 35000 341000000 2100.0 200 -300
21 820 40000 682000000 2400.0 200 -300
22 1066 50000 1400000000 3000.0 200 -300
23 1386 60000 2700000000 3600.0 200 -300
24 1802 70000 5500000000 4200.0 200 -300
25 2343 80000 10900000000 4800.0 200 -300
  • The standard fire delay is 8 ticks (or 3.75 shots per second)
  • The standard range is 60 ls
  • The standard ammo mass is 10.0 kg
  • The Over and Under values are Balance Points; they are used when determining the overpoweredness or underpoweredness of a weapon. Rather than being chosen based on the level of the weapon, they are chosen based on the difference between
Damage Level
laser 1
kinetic 1
particle 4
ion 4
thermo 7
positron 7
plasma 10
antimatter 10
nano 13
graviton 16
singularity 16
darkAcid 19
darkSteel 19
darkLightning 22
darkFire 22

This table shows the standard weapon level that each damage type is associated with.

Fields

Properties

  • ammoTypes= If the weapon uses ammo, this is a list of UNIDs for every compatible ammo item type.
  • averageDamage= This is the average unadjusted damage dealt every time the weapon is fired. This assumes that all projectiles hit the same target.
  • balance= The percentage to which the weapon is overpowered relative to its level
  • balanceDamage=
  • balanceCost=
  • balanceExcludeCost=
  • damage=
  • damagePerProjectile=
  • damageWMD180=
  • damaged=
  • effectiveRange=
  • fireArc=
  • fireDelay=
  • fireRate=
  • linkedFireOptions=
  • maxDamage=
  • minDamage=
  • omnidirectional=
  • secondary=
  • stdCost=
  • tracking=

Balance

Notes Balance Points
Compare this weapon's damage per 180 ticks to the standard damage per 180 ticks for its level. 100 * log₂(Damage180 / StdDamage180)
If the damage type's standard level is greater than the weapon's level, then add balance points from the Over column based on the difference Over[damageLevel - weaponLevel]
If the damage type's standard level is less than the weapon's level, then add balance points from the Under column based on the difference Under[damageLevel - weaponLevel]
If the weapon uses ammo or charges, it loses 100 balance points -100
Find the percentage difference between our ammo unit cost and the standard firing cost at our level. The standard firing cost is found by multiplying the standard unit cost with the ratio between our fire rate and the standard fire rate. Subtract 0.2 Balance Points for every percentage point that our cost is above the standard. If the cost is below standard, add instead. StdAmmoFiringCost = StdAmmoCost[Level] * FireRate / StdFireRate[Level]
-0.2 | 100 * (AmmoCost - StdAmmoFiringCost) / StdAmmoFiringCost
Find the percentage difference between our ammo unit mass and the standard firing mass at our level. The standard firing mass is found by multiplying the standard unit mass with the ratio between our fire rate and the standard fire rate. Subtract 0.25 Balance Points for every percentage point that our mass is above the standard. If the mass is below standard, add instead StdAmmoMass = 10
StdAmmoFiringMass = StdAmmoMass * FireRate / StdFireRate
-0.25 * 100 * (AmmoMass - StdAmmoFiringMass) / StdAmmoFiringMass
If the weapon can rotate, add up to 100 Balance Points 100 * √(FireArc / 360)
If the weapon has tracking or any of its fragments have tracking, then add Balance Points 100
Compare the weapon range to the standard range. For each light-second distance that the weapon's range is greater than the standard range, add 0.35 Balance Points (up to 21 max) 0.35 * (RangeLS - StdRangeLS[Level])
Compare the weapon range to the standard range. For each light-second distance that the weapon's range is less than the standard range, subtract 1.0 Balance Points 1.0 * (RangeLS - StdRangeLS[Level])
Subtract up to 25 Balance Points based on missile speed -25 * (1 - √(MissileSpeed / 100))
Add up to 5 Balance Points for not having interaction 5 * (100 - Interaction) / 100
Add up to 10 Balance Points as projectile hp approaches standard damage 10 * HitPoints / StdDamage[Level]
If this weapon is a primary, Find the difference between its power use and the adjusted standard (10% of the standard if we use ammo, 100% otherwise). Divide this difference by the unadjusted standard and multiply by 100. StdPowerAdjusted = 0.1 * StdPower[Level]
StdPowerAdjusted = Power[Level]
100 * (Power - StdPowerAdjusted) / StdPower[Level]
If this weapon is a primary, compare its value to the standard value at its level. For each percentage point difference from standard, subtract 0.5 Balance Points if our value is greater. Otherwise, add. -0.5 * 100 * (Value - StdValue[Level]) / StdValue[Level]
If the weapon is slotless, add 20 Balance Points 20
If the weapon takes one slot, then no Balance Points 0
If the weapon takes more than one slot, subtract 40 Balance Points for each additional slot -40 * (Slots - 1)
If the weapon has linked-fire, add 25 Balanced Points 25
Subtract 2.5 points for each point of recoil 2.5 * Recoil
Subtract 40 Balance Points if external -40
Add 30 Balance Points if this weapon has radiation 30
Add 3 Balance Points for each percent chance of device disruption (up to 50%) 3 * DeviceDisruptChance
Add 3 Balance Points for each percent chance of device damage (up to 50%) 3 * DeviceDamageChance
Add 100 Balance Points if this weapon has disintegration 100
Add 12 Balance Points for each point of Shatter 12 * Shatter
Add 0.25 Balance Points for each percent chance of shield penetration 0.25 * ShieldPenetrateChance
Shield Buster 10 * (3 + Shield - Level)
Armor Penetrate 20 * (3 + Armor - Level)
Add 0.1 for every percentage point chance of mining MiningChance[Mining] = 2 * Mining² + 2
0.1 * MiningChance[Mining]
Add 0.5 Balance Points for each percentage point of adjustment for non-standard WMD damage 0.5 * WMDAdj[WMD]

Source

Variants

Events

Weapon items support the following events (which can be added in the <Events> element for an <ItemType>).

<OnDamageArmor>

This event is called when a projectile from this weapon hits the armor of a ship. If the event returns an integer, the value is interpreted as the amount of damage to do to armor (before adjustments for damage type). If the event returns Nil, the original damage amount is unchanged.

  • gSource is the object that was hit by the projectile.
  • aArmorSeg is the armor segment on the object that was hit.
  • aAttacker is the object that fired the projectile.
  • aCause is the projectile object.
  • aDamageHP is the adjusted damage (in hit points) that reached the armor.
  • aDamageType is the type of damage.
  • aHitDir is the absolute direction that the projectile came from.
  • aHitPos is the vector position where the shot hit.
  • aOrderGiver is the object that ordered the attacker.
  • aWeaponType is the UNID of the weapon (for missile weapons, this is the UNID of the missile).

<OnDamageOverlay>

This event is called when a projectile from this weapon hits an overlay on a ship. If the event returns an integer, the value is interpreted as the amount of damage to pass to shields (before adjustments for damage type). If the event returns Nil, the original damage amount is unchanged.

  • gSource is the object that was hit by the projectile.
  • aAttacker is the object that fired the projectile.
  • aCause is the projectile object.
  • aDamageHP is the adjusted damage (in hit points) that reached the armor.
  • aDamageType is the type of damage.
  • aArmorSeg is the armor segment that would be hit if it penetrates overlay and shields.
  • aHitDir is the absolute direction that the projectile came from.
  • aHitPos is the vector position where the shot hit.
  • aOrderGiver is the object that ordered the attacker.
  • aOverlayID is the ID of the overlay that was hit.
  • aWeaponType is the UNID of the weapon (for missile weapons, this is the UNID of the missile).

<OnDamageShields>

This event is called when a projectile from this weapon hits the shields on a ship.

If the event returns Nil, the shields process the damage normally.

If the event returns an integer, then the shields are by-passed and the value is interpreted as the amount of damage to do to armor.

If the event returns the string “reflect”, then the projectile is reflected and neither shields nor armor take any damage.

If the event returns a list, then the list must have three elements. The first element is either the string “reflect” or Nil. The second element is the number of HP to subtract from the current shield level. The third element is the number of HP to do to armor.

  • gSource is the object that was hit by the projectile.
  • aArmorDamageHP is the number of hit points of damage that will be passed to armor after the shields absorb some.
  • aAttacker is the object that fired the projectile.
  • aCause is the projectile object.
  • aDamageHP is the amount of damage (in hit points) that reached the armor. It has not been adjusted for damage type.
  • aDamageType is the type of damage.
  • aDeviceItem is the shield item.
  • aArmorSeg is the armor segment that would be hit if it penetrates shields.
  • aHitDir is the absolute direction that the projectile came from.
  • aHitPos is the vector position where the shot hit.
  • aOrderGiver is the object that ordered the attacker.
  • aOriginalArmorDamageHP if the shot will be reflected, this is the number of hit points that would have been dealt to armor if the shot had not been reflected.
  • aOriginalShieldDamageHP if the shot will be reflected, this is the number of hit points that would have been dealt to shields if the shot had not been reflected.
  • aShieldDamageHP is the number of hit points of damage that the hit will do to shields.
  • aShieldHP is the current number of hit points on the shields.
  • aShieldReflect is the string “reflect” is the shield will reflect this projectile. Otherwise, its value is Nil.
  • aWeaponType is the UNID of the weapon (for missile weapons, this is the UNID of the missile).

<OnFireWeapon>

This event is called on weapon items when the weapon fires. For weapons with multi-projectile configurations or for repeating weapons, the event is called once per projectile. The event may use sysCreateWeaponFire to create projectiles. If the event returns Nil, then the normal projectile is created.

  • gSource is the object that fired the weapon.
  • gItem is the weapon itself (for missile weapons, this is the launcher).
  • aFireAngle is the angle that the weapon fired at.
  • aFirePos is the position where the weapon fire originates.
  • aTargetObj is the target object (if any).
  • aWeaponBonus is the %bonus confered by any enhancements.
  • aWeaponType is the UNID of the weapon (for missile weapons, this is the UNID of the missile).

<OnFragment>

This event is called on a weapon when a shot from that weapon fragments due to either proximity or reaching the end of its lifetime.

  • aNearestObj The object that triggered the fragmentation (or Nil)
  • aTargetObj The object that the attacker was targeting (or Nil if no target)
  • aHitPos The detonation position
  • aHitDir The direction that the shot was traveling
  • aWeaponType The UNID of the weapon that fired
  • aWeaponFragment An identifier for the fragmentation (in case a fragment also fragments)
  • aCause The shot object
  • aAttacker The attacker
  • aOrderGiver The object that ordered the attack (in case aAttacker is an auton)
modding/xml/weapon_devices.1485833290.txt.gz · Last modified: 2017/01/31 03:28 by 0xabcdef