Editing

How to Edit Ships and Weapons for Flight Commander

by Eddie Benowitz

Editing  Weapons

Editing Missiles

To add or edit a missile, you will need to work with a line like the following:


  <missile
    name="Friend or Foe"
    mesh="friendfoe.mesh.bin"
    range="6000"
    damage="280"
    image="dumbfire2d.png"
    locktime="0"
    tracking="true"
    refire_delay="2000"
    icon="ff2d.bmp">
      <speeds
       velocity="1800"
       roll="3"
       pitch="90"
       yaw="90"
       acceleration="2500"
        />

      <armor
       front="2"
       rear="2"
       left="2"
       right="2" />
   </missile>

name:  This is the name that will appear in the cockpit

mesh:  The name of the file containing the gun's mesh.  You can use the mesh converter to import gun meshes from Prophecy.  For more information, see the readme that comes with the mesh import tool.

range:  The range is in game units, not the units you see from the cockpit.  The range of a laser is approximately 200-300, to give you a ballpark idea.

damage:  The amount of damage the gun does.

image: A 64x64 bitmap, with 24 bits/pixel, that is a 2d picture of the missile that will appear when the missile is targeted.  You can leave this as the default dumbfire2d.bmp

locktime:  The number of milliseconds it takes to obtain a lock on a target.

tracking:  Set tracking to "true" if the missile can track a target.  If the missile is a dumbfire, set tracking to "false".

refire_delay:  The minimum time to wait before firing another missile. In milliseconds.

icon: An image that appears in the cockpit when the player has selected this as the current missile.

velocity:  Velocity

velocity:  Acceleration

roll, pitch, yaw:   The ability of a missile to turn.

front, rear, left, right:  The amount of armor the missile has.

Editing Guns

To add or edit a gun, you will need to work with a like line the following:  <gun range="200" name="Mass Driver" mesh="massdriver.mesh.bin" damage="5" refire_delay="300" energy="20" sound="0">
<speeds velocity="2.0"/>
 </gun>

range:  The range is in game units, not the units you see from the cockpit.  The range of a laser is approximately 200-300, to give you a ballpark idea.

name:  This is the name that will appear in the cockpit

mesh:  The name of the file containing the gun's mesh.  You can use the mesh converter to import gun meshes from Prophecy.  For more information, see the readme that comes with the mesh import tool.

damage:  The amount of damage the gun does.

refire_delay:  The amount of time, in milliseconds, a player will have to wait before the same gun fires again.

energy:  The amount of energy that the gun uses up when it gets fired.

sound:  If you open up sounds.xml in notepad, you will see an area listing the sounds for weapons.  It looks like the following.
 
 

<weaponsounds numsounds="2"> 
<sound name="laser.wav"/> 
<sound name="particle.wav"/> 
</weaponsounds> 

You can add more weapon sounds to sounds to sounds.xml by adding another sound line, and changing numsounds above to the number of sound entries. 

To pick one of these sounds for your weapon, the sound field is a index into weaponsounds.  The index starts with 0.  So  to pick laser.wav for your weapon, do the following. 

sound="0" 

And to pick particle.wav, choose 
    sound="1" 
 

velocity:  This is not the same velocity that you are used to.  A very fast velocity might be 6, for example.

Editing Ships

The easiest way to edit a ship is to copy an existing ship file, and change the appropriate information.  We'll start by making the ship statistics for a wasp, as an example.  First, we copy over an existing ship file, and rename it wasp.ship.xml.

<?xml version="1.0" encoding="UTF-8" ?>
<shipfile name="wasp" image="wasp2d.png" mass="18000" hitpoints="200">
   <meshfile name="wasp.mesh.bin" />

   <cockpit mesh="co_wasp.mesh.bin">
      <point x="0" y="0" z="0" />
   </cockpit>

   <mounts number="9" decoys="36">
      <mount>
         <point x="-2" y="0" z="2" />

         <weapon number="1" />
      </mount>

      <mount>
         <point x="2" y="0" z="2" />

         <weapon number="1" />
      </mount>

      <mount>
         <point x="-2" y="0" z="2" />

         <weapon number="5" />
      </mount>

      <mount>
         <point x="2" y="0" z="2" />

         <weapon number="5" />
      </mount>

      <mount>
         <point x="-2" y="0" z="2" />

         <weapon number="16" />
      </mount>

      <mount>
         <point x="2" y="0" z="2" />

         <weapon number="16" />
      </mount>

      <mount number_of_shots="4">
         <point x="4.05002" y="0" z="2" />

         <weapon number="25" />
      </mount>

      <mount number_of_shots="6">
         <point x="-4.05828" y="0" z="2" />

         <weapon number="12" />
      </mount>

      <mount number_of_shots="2">
         <point x="4.05002" y="0" z="2" />

         <weapon number="11" />
      </mount>
   </mounts>

   <thrusters number="2">
      <thruster radius="0.35">
         <point x="-2.2" y="-0.12" z="-2.23" />
      </thruster>

      <thruster radius="0.35">
         <point x="2.2" y="-0.12" z="-2.23" />
      </thruster>
   </thrusters>

   <shields front="260" left="230" right="230" rear="200" regeneration_rate="22" />

   <armor front="260" left="240" right="240" rear="220" />

   <speeds roll="120" pitch="70" yaw="80" angular_acceleration="190" velocity="480" acceleration="590" />

   <afterburner velocity="1400" acceleration="1600" fuel="360" />

   <energy total="600" recharge_rate="60" />
</shipfile>
 At this point, you should have already created a mesh.  For information on how to import meshes from Prophecy, please see the readme in the mesh converter.  After the mesh conversion process, we have obtained wasp.mesh.bin.  You will also need the original mesh file from prophecy, for example wasp.iff.

To try out a newly converted mesh, you only need to change 3 fields, at minimum

<shipfile name="Wasp" image="wasp2d.bmp" mass="100">
  <meshfile name="wasp.mesh.bin"/>

shipfile name: The name that will appear when you target this ship.

image:  A 64x64 24-bit bmp file, which has a two dimensional picture of the ship.  It can be created in mspaint, for example.  This is optional, since you can use an existing image from another ship.  However, taking the time to create a 2d image enhances the game.

meshfile name: The name of the newly converted mesh.  Make sure to use the .mesh.bin extension.

mass: The mass of the ship.  This affects the collision response.

Simple Ship Statistics

The easier statistics to enter are located at the bottom of the file.  An example is shown below.

   <shields front="260" left="230" right="230" rear="200" regeneration_rate="22" />

   <armor front="260" left="240" right="240" rear="220" />

   <speeds roll="120" pitch="70" yaw="80" angular_acceleration="190" velocity="480" acceleration="590" />

   <afterburner velocity="1400" acceleration="1600" fuel="360" />

   <energy total="600" recharge_rate="60" />
shields (right, rear, left, front):  The amount of shields the ship has for each area.

shields (regeneration_rate):  The amount of shields that are regenerated in each game turn.

armor (right, rear, left, front): The amount of armor the ship has for each area.

speeds (yaw, roll, pitch, angular acceleration): These influence the ability of the ship to turn on each axis.  

speeds  (velocity, acceleration):  How fast the ship can move forward.  

energy total:  The total amount of energy available for firing guns.

energy recharge_rate: The amount of energy that is recharged per game turn.

Mounts,  Thrusters, and the Cockpit

Each ship can have multiple mounts and thrusters, and one cockpit.  A mount is a place from which a weapon fires.  Each mount specifies a weapon, a location on the ship, and optionally the number of rounds of ammunition.  A thruster is the location on the ship where the engine flames can be seen.  Each thruster has a radius, which chooses how wide to make the thruster.  The cockpit is the location on the ship where the cockpit is located.

All three of these editable sections use 3d coordinates. 
 
Now that we have the 3d coordinates, we can start adding them to the ship.  First, we can change the cockpit location.
 
 
    <cockpit mesh="co_wasp.mesh.bin">
      <point x="0" y="0" z="0" />
   </cockpit>

Also, using the mesh field within the cockpit tag, you can select the 3d cockpit struts mesh to use.

For the thrusters, we also need to specify how many thrusters there are, in addition to the locations.

  <thrusters number="2">
      <thruster radius="0.35">
         <point x="-2.2" y="-0.12" z="-2.23" />
      </thruster>

      <thruster radius="0.35">
         <point x="2.2" y="-0.12" z="-2.23" />
      </thruster>
   </thrusters>

If the thrusters appear too large or too small, you can change the radius.  Note that x, y, and z may appear out of order in the ship.xml file, so be sure to match x to x, y to y, and z to z.
 
For mounts, you specify the location, the weapon, and the number of shots.

  <mounts number="2">
    <mount>
      <point z="5.094" y=" -.833 " x="0"/>
      <weapon number="0"/>
    </mount>
    <mount number_of_shots="3">
      <point z="5.094" y=" -.833 " x="0"/>
      <weapon number="5"/>
    </mount>
  </mounts>

mounts number:  The number of mount entries that will follow.

weapon number:  The index into weapons.xml, specifying which weapon will be located at this mount.  The index starts at 0:  If you specify 0, you will get the first weapon in weapons.xml, and if you put in 1, you will get the second weapon in weapons.xml.

number_of_shots:  Use this to limit the number of shots. This is especially helpful for missiles.  Above, we give the player 3 missiles. 


 Editing turrets

First the xml, then I'll explain it

      <turret type="Gun Turret" mesh="midhtr.mesh.bin" damaged_mesh="" hit_points = "800" >
<turretlocation>
<point x = "-369.223" y = "-32.9294" z = "-263.404" />
<rotation matrix = "0 -1 0 1 0 0 0 0 1 " />
</turretlocation>
<barrel barrel_mesh="midtrhg.mesh.bin">
<point x = "0" y = "6" z = "0" />
<rotation matrix = "1 0 0 0 1 0 0 0 1 " />
</barrel>
<turretmounts>
<mount>
<point x = "-4.27085" y = "0" z = "12.9463" />
<weapon number = "43" />
</mount>
<mount>
<point x = "4.20305" y = "0" z = "12.9463" />
<weapon number = "43" />
</mount>
</turretmounts>
<jointconstraint>
<point x = "180" y = "180" z = "90" />
</jointconstraint>
</turret>

First, we specify the name the turret will have on screen.  We also specify the mesh for the BASE of the turret.  This is just the bottom portion of the turret.  Also we give the hit pints.

<turret type="Gun Turret" mesh="midhtr.mesh.bin" damaged_mesh="" hit_points = "800" >

A turret is like any other 3d object.  it needs to be put into the world.  Since it is put on a ship, the turret needs to be located and rotated
to the right place on the ship.  So the first thing we do is place and rotate the turret's location (with respect to the ship it is on).

         <turretlocation>
<point x = "-369.223" y = "-32.9294" z = "-263.404" />
<rotation matrix = "0 -1 0 1 0 0 0 0 1 " />
</turretlocation>
The rotation matrix describes the turret's orientation

[0 -1 0]
[1 0 0  ]
[ 0 0 1 ]

If you don't know what a rotation matrix is, learn about them in a computer graphics book.  

Now that we have the base of the turret placed on th ship, it is time to add the barrel.   As you can see below, the barrel is highlighted in blue.

turret


The barrel of the turret rotates separately from the base of the turret,
so it has to be a separate mesh.  The barrel also must have a rotation and position with respect to the base of the turret
         <barrel barrel_mesh="midtrhg.mesh.bin">
<point x = "0" y = "6" z = "0" />
<rotation matrix = "1 0 0 0 1 0 0 0 1 " />
</barrel>

Finally, we specify the weapons in the turret.  These are positioned with respect to the barrel of the turret.
            <mount>
<point x = "4.20305" y = "0" z = "12.9463" />
<weapon number = "43" />
</mount>
The weapon number can be any number in weapons.xml.

Turrets are not always allowed to turn anywhere they want.  For example, the turret in the above picture may only be able to move the barrel 90 degrees
These sorts of movement constraints are described by a joint constraint.

         <jointconstraint>
<point x = "180" y = "180" z = "90" />
</jointconstraint>

This says the turret can rotate 180 degrees around the x axis, 180 degrees around the y axis, and 90 degrees around z.