Difference between revisions of "HowTo:Make Weapons"

From VsWiki
Jump to: navigation, search
(digging through src/cmd/weapon_xml.cpp brought more stuff)
Line 16: Line 16:
 
* Missile
 
* Missile
  
 
+
If more than one is given as <code>property1</code> ''or'' <code>property1</code> this means, that they are both read, do the same ''and the latter synonymous property overwrites the former''(!).
 
==Weapon XML Schema==
 
==Weapon XML Schema==
 
{{fixme}} ''ADD DESCRIPTIONS TO SCHEMA''
 
{{fixme}} ''ADD DESCRIPTIONS TO SCHEMA''
Line 23: Line 23:
 
** <code>name</code>
 
** <code>name</code>
 
** <code>mountsize</code>
 
** <code>mountsize</code>
 +
** <code>Role</code> ''or'' <code>AntiRole</code> - {{fixme}} List of roles that will be considered eligible targets for this mount. <code>AntiRole</code> does the same, but is inverted.
 +
*** Currently only used in "CARGO INERT" set for normal 'Tractor' beam -- Dodo try to push people around because they have 'Heavy Tractor'.
 
* <code><'''Energy''' ... /></code>
 
* <code><'''Energy''' ... /></code>
** <code>rate</code> - Energy requirement (per second), in units of 100s of MJ
+
** <code>consumption</code> ''or'' <code>rate</code> - Energy requirement (per second), in units of 100s of MJ
 
** <code>stability</code> - Maximum continuous firing duration
 
** <code>stability</code> - Maximum continuous firing duration
 
** <code>refire</code> - Rest time, in seconds, between firing
 
** <code>refire</code> - Rest time, in seconds, between firing
 
** <code>locktime</code> - N/A for beams
 
** <code>locktime</code> - N/A for beams
 
* <code><'''Damage''' ... /></code>
 
* <code><'''Damage''' ... /></code>
** <code>rate</code> - Damage output (per second), in units of 5.4 MJ
+
** <code>damage</code> ''or'' <code>rate</code> - Damage output (per second), in units of 5.4 MJ
 
** <code>phasedamage</code> - Damage (per second) that ignores shields, in units of 5.4 MJ
 
** <code>phasedamage</code> - Damage (per second) that ignores shields, in units of 5.4 MJ
 
** <code>longrange</code> - Fraction of damage applied at max range
 
** <code>longrange</code> - Fraction of damage applied at max range
 
* <code><'''Distance''' ... /></code>
 
* <code><'''Distance''' ... /></code>
 
** <code>speed</code> - Speed at which beam travels linearly through space, in meters/second.
 
** <code>speed</code> - Speed at which beam travels linearly through space, in meters/second.
 +
*** If "<code>[[Manual:Config:Advanced:Variables#.22Physics.22_section|physics]]/ '''gun_speed_adjusted_game_speed'''</code>" variable is set to "<code>true</code>" (default <code>false</code>), speeds are moderated (below 1000 raised, otherwise reduced) and adjusted using <code>[[Manual:Config:Advanced:Variables#.22Physics.22_section|physics]]/ '''gun_speed'''</code>.
 
*** Usually rather fast. E.g. all lasers have 300000000 (light speed).
 
*** Usually rather fast. E.g. all lasers have 300000000 (light speed).
 
** <code>radialspeed</code> - Speed at which beam reaches full radius, and full damage, in meters/second
 
** <code>radialspeed</code> - Speed at which beam reaches full radius, and full damage, in meters/second
Line 39: Line 42:
 
** <code>length</code> - N/A for beams
 
** <code>length</code> - N/A for beams
 
** <code>pulsespeed</code> - Controls visual wave effect in beam.
 
** <code>pulsespeed</code> - Controls visual wave effect in beam.
*** E.g. for tractor beams it should be negative, so that the beam texture moved toward the weapon and not from it.
+
*** E.g. for tractor beams it should be negative, so that the beam texture moved toward the weapon and not from it. Ignored for non-beams.
 
** <code>range</code> - Max damaging range, in meters
 
** <code>range</code> - Max damaging range, in meters
** <code>detonationrange</code> - N/A for beams
+
*** "<code>[[Manual:Config:Advanced:Variables#.22Physics.22_section|physics]]/ '''gun_speed_adjusted_game_speed''' and <code>'''gun_speed'''</code> (see above) control ranges adjustment as well.
 +
** <code>detonationrange</code> - N/A. Ignored for beams.
 
** <code>volume</code> - ammo volume (for one shot), in meters<sup>3</sup>. If used, 1 unit of ammo is fully spent when the beam is fired, even if it's interrupted later.
 
** <code>volume</code> - ammo volume (for one shot), in meters<sup>3</sup>. If used, 1 unit of ammo is fully spent when the beam is fired, even if it's interrupted later.
*** Works only if [[Manual:Config:Advanced:Variables#.22Physics.22_section|variable "<code>'''reduce_beam_ammo'''</code>"]] is set to "<code>true</code>" (default <code>false</code>). Currently the only beam with ammo is Jackhammer.
+
*** Works only if "<code>[[Manual:Config:Advanced:Variables#.22Physics.22_section|physics]]/ '''reduce_beam_ammo'''</code>" variable is set to "<code>true</code>" (default <code>false</code>). Currently the only beam with ammo is Jackhammer.
 
* <code><'''Appearance''' ... /></code>
 
* <code><'''Appearance''' ... /></code>
 
** <code>file</code>
 
** <code>file</code>
 +
** <code>soundmp3</code>
 
** <code>soundwav</code>
 
** <code>soundwav</code>
 +
** <code>OffsetX</code> <code>OffsetY</code> <code>OffsetZ</code> - {{fixme}} offset of the muzzle from the mount's coordinates?
 
** <code>r</code> <code>g</code> <code>b</code> <code>a</code> - color components (with transparency) of the beam.
 
** <code>r</code> <code>g</code> <code>b</code> <code>a</code> - color components (with transparency) of the beam.
 
*** E.g.: Tractor and Repulsor use the same texture, but different colors.
 
*** E.g.: Tractor and Repulsor use the same texture, but different colors.
 +
** <code>TextureStretch</code> - Stretches textures along the beam.
 +
*** Currently it's used only in code for beams. So you can use the same texture for different beams with different looks or adjust for speed.
  
 
===Bolt===
 
===Bolt===

Revision as of 10:16, 14 August 2010

arrow_left.png MOD arrow_up.png HowTos Add Upgrades arrow_right.png

Adding weapons to the weapon list

Weapon descriptions are stored in the weapon_list.xml in the data directory.

Weapons are classified as FIXME DIFFERENCES BETWEEN CATEGORIES

  • Beam
  • Bolt
  • Ball
  • Missile

If more than one is given as property1 or property1 this means, that they are both read, do the same and the latter synonymous property overwrites the former(!).

Weapon XML Schema

FIXME ADD DESCRIPTIONS TO SCHEMA

Beam

<beam ... >

    • name
    • mountsize
    • Role or AntiRole - FIXME List of roles that will be considered eligible targets for this mount. AntiRole does the same, but is inverted.
      • Currently only used in "CARGO INERT" set for normal 'Tractor' beam -- Dodo try to push people around because they have 'Heavy Tractor'.
  • <Energy ... />
    • consumption or rate - Energy requirement (per second), in units of 100s of MJ
    • stability - Maximum continuous firing duration
    • refire - Rest time, in seconds, between firing
    • locktime - N/A for beams
  • <Damage ... />
    • damage or rate - Damage output (per second), in units of 5.4 MJ
    • phasedamage - Damage (per second) that ignores shields, in units of 5.4 MJ
    • longrange - Fraction of damage applied at max range
  • <Distance ... />
    • speed - Speed at which beam travels linearly through space, in meters/second.
      • If "physics/ gun_speed_adjusted_game_speed" variable is set to "true" (default false), speeds are moderated (below 1000 raised, otherwise reduced) and adjusted using physics/ gun_speed.
      • Usually rather fast. E.g. all lasers have 300000000 (light speed).
    • radialspeed - Speed at which beam reaches full radius, and full damage, in meters/second
    • radius - Beam radius, in meters
    • length - N/A for beams
    • pulsespeed - Controls visual wave effect in beam.
      • E.g. for tractor beams it should be negative, so that the beam texture moved toward the weapon and not from it. Ignored for non-beams.
    • range - Max damaging range, in meters
      • "physics/ gun_speed_adjusted_game_speed and <code>gun_speed (see above) control ranges adjustment as well.
    • detonationrange - N/A. Ignored for beams.
    • volume - ammo volume (for one shot), in meters3. If used, 1 unit of ammo is fully spent when the beam is fired, even if it's interrupted later.
      • Works only if "physics/ reduce_beam_ammo" variable is set to "true" (default false). Currently the only beam with ammo is Jackhammer.
  • <Appearance ... />
    • file
    • soundmp3
    • soundwav
    • OffsetX OffsetY OffsetZ - FIXME offset of the muzzle from the mount's coordinates?
    • r g b a - color components (with transparency) of the beam.
      • E.g.: Tractor and Repulsor use the same texture, but different colors.
    • TextureStretch - Stretches textures along the beam.
      • Currently it's used only in code for beams. So you can use the same texture for different beams with different looks or adjust for speed.

Bolt

Mostly similar to Beam, with the following difference:

<bolt ... >

  • <Energy ... />
    • rate - Energy requirement (per shot), in units of 100s of MJ
    • stability - N/A for anything except beams
    • refire - Time between shots, in seconds
  • <Damage ... />
    • rate - Damage output (per shot), in units of 5.4 MJ
    • phasedamage - Damage (per shot) that ignores shields, in units of 5.4 MJ
  • <Distance ... />
    • pulsespeed - N/A for anything but beams
    • volume - ammo volume (for one shot), in meters3

Ball

Mostly similar to Bolt, but is spherical.

<ball ... >

Missile

Mostly similar to Bolt, with the following difference:

<missile ... >

  • <Energy ... />
    • locktime - Time to lock on the target, in seconds.
      • Should work with any weapon but is used only with missiles, since it doesn't have much sense for most non-guided weapons.
  • <Damage ... />
    • rate - Damage output, in units of 5.4 MJ.
      • FIXME Uses a complicated formula; it looks like at zero distance the damage is twice this much, but don't count on this.
    • phasedamage - Damage that ignores shields, in units of 5.4 MJ.
  • <Distance ... />
    • radius - FIXME Seems to be the radius in which the damage is applied, in meters.
    • detonationrange - FIXME The maximum distance from a target at which the missile detonates, in meters.
      • Should work for any weapon except beams, but only missiles have radius damage. Negative values are used for drones.

Weapon AI's

Example 1: Beam Weapon

<Beam name="LR_PminusBeamMKIV" mountsize="capship-massive">
  <Energy rate="1500" stability="8" refire="2" /> 
  <Damage rate="15000" longrange=".8" /> 
  <Distance speed="300000" radialspeed="60" radius="60" length="8" pulsespeed="36" range="150000" /> 
  <Appearance file="weapons/heavylaserbeam.png" soundwav="beam1.wav" r=".6" g=".1" b=".8" a=".6" /> 
</Beam>

Example 2: Spinning Weapon


You can make it spin as well by making it an accessory of the missile/weapon:

  • You make it a subunit (turret) at the center, which has the word accessory in its name (e.g call it torpedo_accessory)
  • Set the max_yaw, max_pitch, and max_roll to whatever you want it to spin at.
  • Make an invisible (or e.g torpedo casing) main body.

Creating a weapon upgrade

prestidigitator documented his steps to create new weapons in a forum post. Here it is:

You will need to create an upgrade file for this weapon that appears in master_parts_list.csv as well as units.csv.

Here is what I have done:

  1. weapon_list.xml: Copied the entire <Beam name="LaserBeam' ...> node to the end of the file (just before the </WEAPONS> end tag), changed the name from "LaserBeam" to "MyLaserBeam", and modified the values to be what I wanted (I left the "mountsize" attribute as "light").
  2. master_part_list.csv: Copied the line starting with "laser_beam" to the end of the file and changed "laser_beam" to "my_laser_beam".
  3. units/units.csv: Copied the line starting with "laser_beam__upgrades" to the end of the file, changed "laser_beam__upgrades" to "my_laser_beam__upgrades", changed "./factions/upgrades/laser_beam" to "./factions/upgrades/my_laser_beam", changed the second "laser_beam" to "my_laser_beam", and finally changed the "LaserBeam" to "MyLaserBeam".
  4. units/factions/upgrades/: Copied the "laser_beam/laser_beam" file to "my_laser_beam/my_laser_beam" and changed the "weapon" attribute of the <mount> node from "LaserBeam" to "MyLaserBeam".

There's an ordering problem. I moved all the additions to immediately after those entries for the laser beam, and it worked.

So, I guess if you are trying to do this, consider my steps above to be a mini-HowTo, with the caveat that you should be careful about WHERE in the files you add things.

See also


arrow_left.png MOD arrow_up.png HowTos Add Upgrades arrow_right.png