About
Requirements
Screen shots
Movies
User Manual
Downloads
Updates
Buy
Scenery
Vehicles
Add-On Library
Tools
Creating scenery
Creating vehicles
User survey
Forum
Links


Creating Weapons for Vehicle Simulator

Weapons in Vehicle Simulator have the following types:

  • Machine guns
  • Rockets
  • Missiles
  • Bombs
  • Torpedoes

You can add as many as 12 weapons per vehicle, these weapons are defined in a file called stores.cfg inside the vehicle directory, a typical stores file looks like this sample.

5 [weapons_num]
Cannon [weapon_name]
2.0 [weapon_x]
0.35 [weapon_y]
1.5 [weapon_z]
Cannon [weapon_name]
-2.0 [weapon_x]
0.35 [weapon_y]
1.5 [weapon_z]
Small_Bomb [weapon_name]
0.0 [weapon_x]
-0.78 [weapon_y]
0.2 [weapon_z]
Small_Missile [weapon_name]
3.0 [weapon_x]
0.25 [weapon_y]
0.0 [weapon_z]
Small_Missile [weapon_name]
-3.0 [weapon_x]
0.25 [weapon_y]
0.0 [weapon_z]

This file has a fixed format, its first line specifies the number of weapons to use, the other lines specify the name of weapon and its position in x,y,z.

Each weapon has its own directory inside the weapons directory of the program, inside this directory are the weapon configuration file and related textures and mesh files.

The weapon configuration file

Inside each weapon directory there is a configuration file called weapon.cfg, this file contains the parameters for defining the type of weapon and its behavior, these are the types of parameters and their decryptions.

[explodes_in_water] - weapon is active in water or not (1 or 0)
[fixed_rotation] - the base of the weapon rotates or not (1 or 0)
[fixed_elevation] - the base of the weapon can tilt or not (1 or 0)
[weapon_guided] - the weapon is guided or not ( 1 or 0 )

[mass] - mass of projectile (kg)
[cross_section] - cross section of projectile (m^2)
[cd0] - drag coefficient of projectile

[thrust] - thrust of rocket (Newton)
[burn_time] - burn time of rocket (sec)
[time_max] - self destruct time of projectile
[launch_vel] - launch velocity of projectile (m/sec)

[launch_x] - x position of projectile relative to turret (m)
[launch_y] - y position of projectile relative to turret (m)
[launch_z] - z position of projectile relative to turret (m)

[turret_x] - x position of turret relative to barrel (m)
[turret_y] - y position of turret relative to barrel (m)
[turret_z] - z position of turret relative to barrel (m)

[barrel_x] - x position of barrel relative to base (m)
[barrel_y] - y position of barrel relative to base (m)
[barrel_z] - z position of barrel relative to base (m)

[beta_base] - yaw angle of base if fixed ( radian )
[gama_base] - pitch angle of base if fixed ( radian )

[beta_base_min] - min yaw angle of base if fixed ( radian )
[gama_base_min] - min pitch angle of base if fixed ( radian )

[beta_base_max] - max yaw angle of base if fixed ( radian )
[gama_base_max] - max pitch angle of base if fixed ( radian )

[scale] - scale factor of the weapon

[salvo_rate] - rounds per second (for machine guns)
[salvo_size] - size of shell in meters (for machine guns )
[max_rounds] - maximum number of rounds weapon can fire
[weapon_group] - all weapons with same group number fires together.
[damage] - damage points added to object hit by this weapon.

[reflect] - reflection strength (0 to 1)
[bump] - bump strength (0 to 1)
[bump_name] - bump texture name
[kill_radius] - killing radius of all targets around shell.

Weapons do not require all of these parameters to be specified, for each type of weapon there is a minimal set of parameters that can be used to specify the weapon configuration, when some parameters are not specified default values are used.

0.05	[burn_time]
3.0	[time_max]
500.0	[launch_vel]
10.0	[salvo_rate]
0.5	[salvo_size]

// Simple machine gun configuration file

The file above shows a simple machine gun with barrel, turret and shell at origin.

0	[explodes_in_water]
1	[fixed_rotation]
1	[fixed_elevation]
1	[weapon_guided]
10	[mass]
0.01	[cross_section]
0.1	[cd0]
1000.0	[thrust]
15.0	[burn_time]
15.0	[time_max]
15.0	[launch_vel]
0.0	[launch_x]
0.0	[launch_y]
0.0	[launch_z]
0.0	[beta_base]
0.0	[gama_base]

// simple torpedo configuration file

The file above shows a simple torpedo launched at a fixed orientation.

250	[mass]
0.1	[cross_section]
1.0	[cd0]
0.5	[scale]
0.1	[reflect]
0.1	[bump]

// Simple bomb configuration file

The file above shows a simple un powered un guided bomb launched at a fixed orientation.

 

Weapon graphics:

Each weapon has optionally some graphic files inside its directory, these include the following:

  • The base mesh file base.x
  • The turret mesh file turret.x
  • The barrel mesh file barrel.x
  • The shell mesh file shell.x
  • The machine gun texture flame.dds

These files are loaded according to the following structure:

 

The shell is attached to the barrel and fired from it, the barrel can swing in elevation only, and is attached to the turret, the turret swings in yaw only and is attached to the base.

All of the components can be used to compose a great variety of weapon types, for example to specify a barrel which swings in pitch and elevation simply ignore the turret.

For machine guns the actual shells are not using the shell.x mesh file, instead they use the flame.jpg file and the salvo_size parameter to draw glowing points similar to a line of tracers.

For machine guns there are also splash.jpg and blast.jpg for showing explosion and splash effects when hitting ground or water.

Weapon sound files:

Each weapon has optionally some sound files inside its directory, these include the following:

  • The firing sound fire.wav - heard when a rocket is shot.
  • The flight sound flight.wav - heard during the flight of the weapon.
  • The explosion sound explode.wav - heard when the shell explodes.
  • The release sound check.wav - heard when a bomb is released.

 Sound files should be mono sounds, 22 kHz, 16 bit sounds, other formats can be loaded as well.

 Using Limited Ammo:

Weapons can have limited or unlimited shells that can be fired, when "Limited "Ammo" option is enabled for the vehicle options, the weapons have a limited number of shells which is 500 for cannons and 1 for other types by default, this number can be specified for each weapon in the [max_rounds] parameter.

When limited ammo is used, the weight and innertia of each shell fired is subtracted from the weight and innertia of the vehicle.

 



Copyright Ilan Papini 1999 - 2008
All Right Reserved