UFO-Scripts/weapon *.ufo

From UFO:AI

Contents

Item types

  • Weapon
  1. rifle
  2. pistol
  3. biggun
  4. rpg
  5. grenade
  6. melee
  • Ammo
  1. ammo

Skills

There are several skills, most of them having an impact on weapon use, either accuracy or melee.

Damage types

There are several types of damage, some removing health points, some inducing effects.

Variables

name V_TRANSLATION_STRING
this is the translated name of the weapon - but in the script file this have to be in english
model V_STRING
model of the weapon relative to base/models (see Directory tree)
weapon V_BOOL
it this a weapon or not? e.g. ammo is no weapon
type V_STRING
see item types above; they affect animation of using the weapon
animationindex V_INT
This is the animation index for the character with the weapon (see character animation). This is useful because a pistol will not be carried like a rpg. This affects walking and standing with a weapon.
Don't confuse this with buytype (the category you can buy it in). See below.
holdtwohanded V_BOOL
does this weapon always take to hands to hold? If true then the other hand is unusuable while this weapon is equiped.
firetwohanded V_BOOL
does this weapon take two hands to fire? If true and something in the other hand then firing is disabled.
shape V_SHAPE_SMALL
the shape in equipment menu, that is how much space do we need to place this weapon (this value defines a rectangle given by the upper left corner and dimensions)
center V_VECTOR
move in a three directions to display the item in menu
scale V_FLOAT
scale up or down for displaying in menu
thrown V_BOOL
is this weapon throwable? e.g. grenades
ammo V_INT
max ammo loaded for this weapon
reload V_INT
TUs for reloading
price V_INT
the price you have to pay when you buy it.
buytype V_STRING
Defines in which category you will find this weapon:
  • buytype weap_pri - All 'Primary' weapons and their ammo for soldiers.
  • buytype weap_sec - All 'Secondary' weapons and their ammo for soldiers.
  • buytype misc - Misc soldier equipment.
  • buytype armour - Armour
  • buytype multi_ammo - Only used for items (mostly ammo) that have to appear in the primary and the secondary list. (It's a workaround, but no problems have been spotted - yet.)

Some variable types for ammo

damage V_POS
Example: damage "xx y"
The first number (xx) is the average damage, the second (y) is the maximum random value than can be added/subtracted from the damage.
spldmg V_POS
Example: spldmg "xx y"
The first number (xx) is the average splash damage, the second (y) is the maximum random value than can be added/subtracted from the damage.
dmgtype V_STRING FIXME Is this still all up to date?
Takes a value such as
  • normal
  • blast
  • fire
  • plasma
  • laser
  • particlebeam
  • stun
This is important as different types of armour are better against certain types of insult. Also some damage types such as stun have special meaning (i.e. they effect more than just armour&health points)
weapon_mod V_STRING
Example: weapon_mod xxxxx
List that contains all firemodes that are displayed/used when the ammo loaded in weapon xxxxx (equals an item definition of xxxxx).
It also tells the game that this item can be used in weapon xxxxx
The weapon entry must come before the ammo entry in the ufo file.

Some variable types for firedef

Firedefs are enclosed in a weapon_mod definition (see above).

Several of these variables are used in the hit calculation. The attempted line of fire is modified using pseudo random numbers. The pitch (up/down) and yaw (left/right) angle has a gaussian distributed variable added.

angle = gauss × {WEAPON_BALANCE × spread × {SKILL_BALANCE_MINIMUM + SKILL_BALANCE × {accuracy skill + weapon skill)/200}} × crouch

spread V_POS
Example: spread "pp yy"
width of gaussian applied to attempted line of fire, in degrees (TODO: check it really is degrees). First element affects pitch, second element affects yaw. Lower values mean greater precision.
crouch V_FLOAT
multiplicative modifier for firing when crouching. Lower values mean greater precision. Crouching does not tend to help much with pistols, but improves sniping prospects quite a bit.
dmgweight V_STRING FIXME Still needs to be documented. This has been added recently for better integration of the barious armour-types. AFAIK see also armour.ufo
range V_FLOAT
In units of map squares (fields). One square is 4 feet, approximately 1.3 metres.
time V_INT
The time units (TU) it takes to use this firemode.
shots V_INT
The number of shots fired. The particle cannon takes 1 unit of ammo for 5 shots when the "rapid shots" firemode is used.
ammo V_INT
The ammo used. The particle cannon takes 4 units of ammo for a single shot charged blast.
delaybetweenshots V_INT
The delay that the weapon needs to play sounds and particles
The higher the value, the less the delay (1000/delay)
throughwall V_INT
This parameter defines the ability to shoot through a wall with this firedefinition. The amount of throughwall will be the walls the firedef will be able to penetrate. The damage will be decreased with every wall of course.

Example

item sniper
{
	name		"_Sniper Rifle"
	model		weapons/sniper/sniper
	weapon		true
	type		rifle
	animationindex	1
	holdtwohanded	false
	firetwohanded 	true
	shape		"0 0 5 2"
	center		"9 0 3"
	scale		1.05
	ammo		5
	reload		10
	price		5920
	size		30
	buytype	weap_pri
}

item sniper_ammo
{
	name		"_Sniper Rifle Magazine"
	model		weapons/sniper/sniper_clip
	type		ammo
	animationindex	0
	shape		"0 0 1 2"
	center		"0 0 0"
	scale		1.15
	price		190
	size		5
	buytype	weap_pri
	dmgtype normal

	weapon_mod sniper
	{
		firedef
		{
			name	"_Snap Shot"
			skill	sniper
			projtl	bullet
			impact	bulletImpact
			hitbody null
			firesnd	weapons/sniperrifle
			speed	0
			spread	"1.5 1.5"
			crouch	0.3
			range	250
			shots	1
			ammo	1
			time	12
			damage	"105 0"
			dmgweight normal_heavy
			reaction	true
		}
		firedef
		{
			name	"_Aimed Shot"
			skill	sniper
			projtl	bullet
			impact	bulletImpact
			hitbody null
			firesnd	weapons/sniperrifle
			speed	0
			spread	"0.9 0.9"
			crouch	0.3
			range	250
			shots	1
			ammo	1
			time	18
			damage	"105 0"
			dmgweight normal_heavy
		}
		firedef
		{
			name	"_Headshot"
			skill	sniper
			projtl	bullet
			impact	bulletImpact
			hitbody null
			firesnd	weapons/sniperrifle
			speed	0
			spread	"0.9 0.9"
			crouch	0.3
			range	250
			shots	1
			ammo	1
			time	24
			damage	"150 0"
			dmgweight normal_heavy
		}
	}
}

Links

project-navigation