Modding weapon ranges and accuracy

From NexusWiki
Jump to: navigation, search

Editing the range and accuracy of weapons is one of the more obscure things to do, since the official modding documentation is a bit vague about that. This article is trying to explain how to modify these properties to achieve the result you're going for.

Ranges in the game

The game differentiates between five ranges, that two ships can be in:

Range ID Name Distance
1 Contact 0 meters
2 Combat 1 to 5000 meters
3 Artillery 5001 to 10000 meters
4 Bomber 10001 to 20000 meters
5 Out of (range) 20001-25000 meters (and above?)

These ranges are actually being defined by entries in the file tacticsbase.ini located in the following folder:
/universe/tactics/tacticsbase.ini/

They can be changed, though that may create problems further down the road with certain AI scripts. The syntax is as follows:

Range <id> <distance> <unknown1> <unknown2> <name>
Parameter name Function Possible value
<id> the range identifier 1-5
<distance> the maximum distance of this range any number greater than the distance of the earlier ranges
<unknown1> not currently known not currently known (- / F)
<unknown2> not currently known not currently known (F1-F5)
<name> name of the range any string, enclosed by double quotation marks (",")

Accuracy

Every weapon entry in the tacticstypes.ini has a HitChanceCat-property, which links it to a certain BASEHITCHANCE-block in the same file. These blocks determine both accuracy and maximum range of a given weapon against any given target, but we'll just look at accuracy for now:

Every row in the BASEHITCHANCE-block follows the same syntax:

<TargetType> <RangeID> <HitChance>
Parameter name Function Possible value
<TargetType> refers to the TargetType-property off SHIPCLASS-entries

more specifically: it is the TargetType of the object the weapon aims at

any TargetType-value
<RangeID the ID of the Range the targetted object is in; usually only Ranges 2 to 4 are being used here, because Range 0 wouldn't make sense and Range 5 is being used up to infinity any of the Range IDs
<HitChance> accuracy at this Range against the given TargetType, in percent, without ECM- or ECCM-systems in mind percentile value; can be greater than 100 percent to counter ECM-/ECCM-effects

So, for example, the default energy shell weapon has a HitChanceCat of 4 and we assume, it now fires at a Gorg Battleship, which is a TargetType of 5. When determining the chance to hit the target, the game will look at the BASEHITCHANCE-block with the number 4. It looks for any rows starting with the TargetType-value of 5 and since the battleship is roughly 6000 meters away, it'll use the following row for Range 3:

5 3 95

Obviously your chance to hit and therefore your accuracy at this range is 95 percent. It'll still apply ECM- and ECCM-effects to this percentage, so your actual accuracy may be lower than this value.

Having 0 accuracy

If your hitchance for a given TargetType and Range is 0, the weapon will not even fire at the target, since it is impossible to hit at this range. This actually serves to limit the maximum range of weapons, which we'll discuss next.

Range of weapons

As we've seen, a weapon having a hitchance of 0 at a certain range, will not fire at the target. This actually represents your maximum range of this weapon as well. If you want to modify your weapons to fire at greater distances, you'll be wanting to raise the hit percentages of this weapon for the larger Ranges (3 and 4 respectively). Of course this also means you're going to stick to the predefined Ranges (5000m, 10000m and 20000m per default) and you won't be able to create a weapon with a non-default firing range.

Actually this isn't quite true for all weapons. Laser-type weapons have their range also limited by their Travel-property:

Travel <type> <param> <effectID> <effectScaling>
Parameter name Function Possible value
<type> the type of the shot, that is being fired Numerical value:
  1. radius from the firing to the target (laser weapons)
  2. travelling shot (projectile shot)
  3. shot has a shipclass (missiles, fighters)
  4. shot aims a breaching point and it doesn't have a shipclass (commandos?)
<param> additional parameter, depending on the type of the shot numerical value
  • <type>=1: <param>=maximum length of the radius (firing distance of the laser)
  • <type>=2: <param>=speed of the shot
  • else <param>=0
<effectID> the effect being used for the shot effect ID from efx.ini or mod_efx.ini or a SHIPCLASS-id, if <type>=3
<effectScaling> how to scale the effect any numerical value; 1 means original size, <1 is smaller, >1 is bigger

So you can give laser weapons their maximum range using the <param>-parameter of the Travel-property. This works in combination with the hitchances, so if your accuracy against some target at a certain range is 0, the weapon will still not fire, even if your <param>-parameter is greater than this distance. However, if your <param>-parameter is smaller than the distance, where you would still have a chance to hit, then the weapon will only fire, when the target is not farther away than what was specified in your <param>-parameter.

Infinite range

Typically there is no row in any BASEHITCHANCE-block being specified for a Range of 5, so the accuracy for that range defaults to 0. If you manually add a row for a Range of 5 for a certain TargetType (or all of them) and set accuracy to some value greater than 0, then your weapon will fire at infinite range (unless being a laser weapon of course, see above). No matter, how far away your target is, you'll be able to shoot at it with the accuracy specified at that row.