http://ufoai.org/w/index.php?title=UFO-Scripts/weapon_*.ufo&feed=atom&action=historyUFO-Scripts/weapon *.ufo - Revision history2024-03-29T16:02:07ZRevision history for this page on the wikiMediaWiki 1.35.4http://ufoai.org/w/index.php?title=UFO-Scripts/weapon_*.ufo&diff=41459&oldid=prevDarkRain: /* Some variable types for firedef */2013-03-29T03:16:41Z<p><span dir="auto"><span class="autocomment">Some variable types for firedef</span></span></p>
<p><b>New page</b></p><div>==Item types==<br />
* Weapon<br />
# <code>rifle</code><br />
# <code>pistol</code><br />
# <code>biggun</code><br />
# <code>rpg</code><br />
# <code>grenade</code><br />
# <code>melee</code><br />
* Ammo<br />
# <code>ammo</code><br />
<br />
==Skills==<br />
<br />
There are several [[Skills|skills]], most of them having an impact on weapon use, either accuracy or melee.<br />
<br />
==Damage types==<br />
<br />
There are several [[Damage|types of damage]], some removing health points, some inducing effects.<br />
<br />
== Variables ==<br />
; name [[V_TRANSLATION_STRING]]<br />
: this is the [[translating|translated]] name of the weapon - but in the script file it has to be in english.<br />
: the preceding underscore, as in "_Assault Rifle", indicates that the text following it will be translateable via [[Translating|Gettext]].<br />
; model [[V_STRING]]<br />
: model of the weapon relative to base/models (see [[Directory tree]])<br />
; weapon [[V_BOOL]]<br />
: it this a weapon or not? e.g. ammo is no weapon.<br />
: Among other effects, when an alien is assigned one primary weapon from the equipment, this flag is used to tell weapon from ammo, even if it has the same "buytype".<br />
; type [[V_STRING]]<br />
: see item types above; they affect animation of using the weapon<br />
; animationindex [[V_INT]]<br />
: This is the animation index for the character with the weapon (see [[Modelling#Animation|character animation]]). This is useful because a pistol will not be carried like a rpg. This affects walking and standing with a weapon.<br />
: Don't confuse this with buytype (the category you can buy it in). See below.<br />
; holdtwohanded [[V_BOOL]]<br />
: does this weapon always take to hands to hold? If true then the other hand is unusuable while this weapon is equiped.<br />
; firetwohanded [[V_BOOL]]<br />
: does this weapon take two hands to fire? If true and something in the other hand then firing is disabled.<br />
; shape [[V_SHAPE_SMALL]]<br />
: 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). For non-rectangular shapes see [[UFO-Scripts/weapon_*.ufo#Non-rectangular_weapons|Non-rectangular weapon description]].<br />
; center [[V_VECTOR]]<br />
: move in three directions to display the item in menu. Middle coordinate has something to do with the z axis, probably a rotation. The first is a translation to the right, the third is a translation downwards. One unit seems to be around 5 pixels on a 1024x768 screen. Horizontal parameter moves to the left for positive values, and vertically positive values move downwards.<br />
; scale [[V_FLOAT]]<br />
: scale up or down for displaying in menu. Note that '''shape''' and '''scale''' variables do not influence the size of the weapon in the battlescape, so take care that small things do not have huge inventory icons. On the other hand, it might a good idea to keep most primary weapons the same inventory shape (even if, e.g., Rocket Launcher is very long in the battlescape) and most secondary weapons the same (smaller) inventory shape. This way they fit nicely in the backpack or holster.<br />
: It's not necessary to scale the object so that it completely fills all the "shape" inventory box, just try to make it look nice.<br />
; thrown [[V_BOOL]]<br />
: is this weapon throwable? e.g. grenades<br />
; ammo [[V_INT]]<br />
: max ammo loaded for this weapon<br />
; reload [[V_INT]]<br />
: [[TU|TUs]] for reloading<br />
; price [[V_INT]]<br />
: the price you have to pay when you buy it.<br />
; buytype [[V_STRING]]<br />
: Defines in which category you will find this weapon:<br />
:* <code>buytype weap_pri</code> - All 'Primary' weapons and their ammo for soldiers.<br />
:* <code>buytype weap_sec</code> - All 'Secondary' weapons and their ammo for soldiers.<br />
:* <code>buytype misc</code> - Misc soldier equipment.<br />
:* <code>buytype armour</code> - Armour<br />
:* <code>buytype multi_ammo</code> - 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.)<br />
; virtual [[V_BOOL]]<br />
: The item is virtual, which means it does not exist. It has a definition for game mechanics only (like weapon/ammo stats, fire definitions). Virtual items don't show up in user interfaces, are not collectible, but can be available (as ammo to reload for example) if researched.<br />
<br />
== Some variable types for ammo ==<br />
; damage [[V_POS]]<br />
: Example: <code>damage "xx y"</code><br />
: The first number (xx) is the average damage, the second (y) is the maximum random value than can be added/subtracted from the damage.<br />
; spldmg [[V_POS]]<br />
: Example: <code>spldmg "xx y"</code><br />
: 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.<br />
<br />
;dmgtype [[V_STRING]] <font color="red">'''FIXME'''</font> ''Is this still all up to date?''<br />
: Takes a value such as<br />
:* <code>normal</code><br />
:* <code>blast</code><br />
:* <code>fire</code><br />
:* <code>plasma</code><br />
:* <code>laser</code><br />
:* <code>particlebeam</code><br />
:* <code>stun</code><br />
: This is important as different types of armour are better against certain types of insult. Also some damage types such as <code>stun</code> have special meaning (i.e. they effect more than just armour&health points)<br />
<br />
; weapon_mod [[V_STRING]]<br />
: Example: <code>weapon_mod xxxxx</code><br />
: List that contains all firemodes that are displayed/used when the ammo loaded in weapon xxxxx (equals an item definition of xxxxx).<br />
: It also tells the game that this item can be used in weapon xxxxx<br />
: The weapon entry must come '''before the ammo entry''' in the ufo file.<br />
<br />
== Some variable types for firedef ==<br />
Firedefs are enclosed in a '''weapon_mod''' definition (see above).<br />
<br />
Several of these variables are used in the hit calculation. The attempted line of fire is modified using pseudo random numbers. For direct fire modes the pitch (up/down) and yaw (left/right) angle has a gaussian distributed variable added while thrown fire modes have a random distribution.<br />
<br />
<code><br />
'''accuracy = (1 - (accuracy ability / MAX_SKILL + weapon skill / MAX_SKILL) / 2) &times; wound penalty'''<br /><br />
'''direct angle = gauss &times; (spread &times; ((WEAPON_BALANCE + SKILL_BALANCE * accuracy) * injurymultiplier) &times; crouch'''<br /><br />
'''throw angle = random &times; 2.0 &times; (spread &times; (WEAPON_BALANCE + SKILL_BALANCE &times; accuracy)) &times; crouch'''<br /><br />
''('''Note:''' MAX_SKILL = 100, wound penalty = <TODO>, WEAPON_BALANCE = 0.5, SKILL_BALANCE = 1.0''<br /><br />
''if HP is less than 50% then injurymultiplier = 1.0 + INJURY_BALANCE * ((1.0 / (HP / maxHP + INJURY_THRESHOLD)) - 1) * MAX_SKILL / mind ability, otherwise injurymultiplier = 1.0; INJURY_BALANCE = 0.2, INJURY_THRESHOLD = 0.5)''<br />
</code><br />
<br />
; spread [[V_POS]]<br />
: Example: <code>spread "pp yy"</code><br />
: 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.<br />
; crouch [[V_FLOAT]]<br />
: 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.<br />
; dmgweight [[V_STRING]] <br />
: The type and weight of damage this firedef uses. This is used with unit resistance and armour protection values to modify final damage. A firedef of type fire_medium will cause extra damage on a unit that is more vulnerable to this type. See [[UFO-Scripts/armour.ufo|armour.ufo]]<br />
; time [[V_INT]]<br />
:The time units (TU) it takes to use this firemode.<br />
; shots [[V_INT]]<br />
:The number of shots fired. The particle cannon takes 1 unit of ammo for 5 shots when the "rapid shots" firemode is used.<br />
; ammo [[V_INT]]<br />
:The ammo used. The particle cannon takes 4 units of ammo for a single shot charged blast.<br />
; delaybetweenshots [[V_INT]]<br />
:The delay that the weapon needs to play sounds and particles <br />
:The higher the value, the less the delay (1000/delay)<br />
; throughwall [[V_INT]]<br />
: 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.<br />
; name [[V_TRANSLATION_STRING]]<br />
; shotorg [[V_POS]]<br />
:This can shift a muzzle vertically (first value) and horizontally (second value) for the trace that is done on the server side.<br />
; projtl [[V_STRING]]<br />
; impact [[V_STRING]]<br />
; hitbody [[V_STRING]]<br />
; firesnd [[V_STRING]]<br />
; impsnd [[V_STRING]] <br />
; bodysnd [[V_STRING]]<br />
; bncsnd [[V_STRING]] <br />
; impactattenuation [[V_FLOAT]]<br />
; fireattenuation [[V_FLOAT]]<br />
:You can define a ''impactattenuation'' and a ''fireattenuation'' value ([[V_FLOAT]] between 0.0 and 3.0 (0.0 means that there the sound is played at the given volume all over the level, 3.0 means that is the sound is only hearable when the camera is very close to the sound source.<br />
; sndonce [[V_BOOL]] <br />
; gravity [[V_BOOL]] <br />
; launched [[V_BOOL]] <br />
; rolled [[V_BOOL]] <br />
; reaction [[V_BOOL]] <br />
; delay [[V_INT]] <br />
; bounce [[V_INT]] <br />
; bncfac [[V_FLOAT]] <br />
; speed [[V_FLOAT]] <br />
; damage [[V_POS]]<br />
; spldmg [[V_POS]]<br />
; irgoggles [[V_BOOL]]<br />
:Is this an irgoogle?<br />
; rounds [[V_INT]]<br />
:How many rounds should this effect last. Used to keep incendiary grenades and smoke grenades around. Each side turn is one round, so 2 rounds would make it last when the player fired it and the aliens' turn only. Minimum is 2.<br />
<br />
==Non-rectangular weapons==<br />
<br />
Sometimes weapon might have an empty space in the rectangular shape where it would be nice to allow placement of other items. This can be done only on tile level, so the usefulness only appears for larger multiline weapons like rocket launcher or machine gun.<br />
<br />
Shape keyword defines a shape of a rectangle, so on it's own no non-rectanghular shapes are possible. On the other hand, you can specify multiple shapes, thus forming slightly more complex shapes.<br />
<br />
For example, if a shape is defined as "0 0 5 2", you would get a rectangle, positioned at relative coordinates 0 0, 5 tiles horizontally and 2 tiles vertically large. Let's say we have empty space at the upper left and lower right tile, so to make those tiles usable for other weapons we would do:<br />
shape "1 0 4 1"<br />
shape "0 1 4 1"<br />
Notice how we have stacked two rectangles. First is shifted one tile to the right (first "1"), and is only 4 units long and 1 unit high. Second is placed one row lower ("1" in the coordinate y position), and also is 4 units long and 1 unit high, thus leaving one tile at the end usable.<br />
<br />
Make sure to test such configurations, simple mistakes can lead to weird behaviour in the inventory screens.<br />
<br />
==Example==<br />
<pre><br />
item sniper<br />
{<br />
name "_Sniper Rifle"<br />
model weapons/sniper/sniper<br />
weapon true<br />
type rifle<br />
animationindex 1<br />
holdtwohanded false<br />
firetwohanded true<br />
shape "0 0 5 2"<br />
center "9 0 3"<br />
scale 1.05<br />
ammo 5<br />
reload 10<br />
price 5920<br />
size 30<br />
buytype weap_pri<br />
}<br />
<br />
item sniper_ammo<br />
{<br />
name "_Sniper Rifle Magazine"<br />
model weapons/sniper/sniper_clip<br />
type ammo<br />
animationindex 0<br />
shape "0 0 1 2"<br />
center "0 0 0"<br />
scale 1.15<br />
price 190<br />
size 5<br />
buytype weap_pri<br />
dmgtype normal<br />
<br />
weapon_mod sniper<br />
{<br />
firedef<br />
{<br />
name "_Snap Shot"<br />
skill sniper<br />
projtl bullet<br />
impact bulletImpact<br />
hitbody null<br />
firesnd weapons/sniperrifle<br />
speed 0<br />
spread "1.5 1.5"<br />
crouch 0.3<br />
range 250<br />
shots 1<br />
ammo 1<br />
time 12<br />
damage "105 0"<br />
dmgweight normal_heavy<br />
reaction true<br />
}<br />
firedef<br />
{<br />
name "_Aimed Shot"<br />
skill sniper<br />
projtl bullet<br />
impact bulletImpact<br />
hitbody null<br />
firesnd weapons/sniperrifle<br />
speed 0<br />
spread "0.9 0.9"<br />
crouch 0.3<br />
range 250<br />
shots 1<br />
ammo 1<br />
time 18<br />
damage "105 0"<br />
dmgweight normal_heavy<br />
}<br />
firedef<br />
{<br />
name "_Headshot"<br />
skill sniper<br />
projtl bullet<br />
impact bulletImpact<br />
hitbody null<br />
firesnd weapons/sniperrifle<br />
speed 0<br />
spread "0.9 0.9"<br />
crouch 0.3<br />
range 250<br />
shots 1<br />
ammo 1<br />
time 24<br />
damage "150 0"<br />
dmgweight normal_heavy<br />
}<br />
}<br />
}<br />
</pre><br />
<br />
==Links==<br />
* [[Weapon_tables]]<br />
* [[Equipment]]<br />
* [[Skills]]<br />
* [[Damage|Damage types]]<br />
* [[Equipment/Tweak weapons|tweak weapons]]<br />
<br />
[[Category:Equipment]]<br />
[[Category:Weapons]]<br />
[[Category:UFO-Scripts]]<br />
[[Category:Skills]]</div>DarkRain