Gun Spread Formula (New Vegas)

From GECK
Jump to: navigation, search

Spread is the value that determines by how much your shots can deviate from your intended target (the center of your cross hair). The higher your spread, the more inaccurate you are. For the sake of powergamers, modders and the good of mankind we'll explain in-depth how this mechanic works.

Spread Calculation

A lot of you probably know the Gun Spread Formula from the (original) GECK wiki. Now forget all about it, because none of the settings or formulas are used in Fallout: New Vegas. And just to point out here again, New Vegas is full of data and settings that are legacies from Oblivion and Fallout 3, so just because something exists in the data files, doesn't mean it's actually used anywhere.

Instead we are presented with the following new settings in New Vegas:


Setting Default Description
fRunningSpreadPenalty 0.2 Used when calculating RunPenalty
fStandingSpreadPenalty 0.1 Used when calculating StandingPenalty
fUnaimedSpreadPenalty 0.2 Used when calculating UnaimedPenalty
fWalkingSpreadPenalty 0.1 Used when calculating WalkingPenalty
fCrippledArm1HSpreadPenalty 0.2 Used when calculating ArmConditionPenalty
fCrippledArm2HSpreadPenalty 0.4 Used when calculating ArmConditionPenalty
fCrippledArms1HSpreadPenalty 0.4 Used when calculating ArmConditionPenalty
fCrippledArms2HSpreadPenalty 0.6 Used when calculating ArmConditionPenalty
fWobbleToSkillConversion 0.5 Used when calculating SkillBonusMultiplier
fMinGunSpreadValue 0.01 Used when calculating PlayerSpread
fWeapStrengthReqPenalty 0.025 How much each point of STR under the weapon's requirement affects spread
fWeapSkillReqPenalty 0.01 How much each point of the associated skill under the weapon's requirement affects spread


These settings all affect the player's spread. Now the total spread consists of two major factors, the player's spread (from here on referred to as PSp) and the weapon's spread (referred to as WSp). The PSp is very variable, being affected by the players weapon skill, movement, arms and much more. Here is an overview of all the factors that affect PSp:

  • Weapon Skill
  • Perk effects
  • Crouching
  • Aiming control pressed, be it Scope/Iron Sights/Weapon zoom
  • Standing/Walking/Running
  • Using a 1 or 2 handed weapon and having 1 or 2 arms crippled
  • Weapon's required strength
  • Weapon's required skill

The WSp is completely static and based on the weapon's "Min Spread" value. It is affected by:

  • Weapon Mods with Decrease Spread effects, or as a byproduct of Split Beam effects.
  • Ammo Effects that alter spread. These used to alter PSp before an official patch corrected it.

Many people probably have also noticed the "Spread" value in weapon tabs. That value does nothing at all. It didn't do anything in FO3 either, unless you re-enabled spread penalties based on weapon conditions. I'm not sure if it's possible to enable that in FNV, haven't really looked into that.

Now what the PSp does is influence your character's hand sway. The higher the PSp the more your hand will sway around, causing your shots to go off target. The sway you experience while using a weapon's scope is exactly the same as your hand sway. The WSp on the other hand simply influence at what angle your bullet will leave the gun barrel, it will not cause any sway of the scope or player's hand.

Following are the calculations that are used to determine the player's exact spread:

Function Formula
UnaimedPenalty fUnaimedSpreadPenalty * !isAiming
RunningPenalty fRunningSpreadPenalty * isRunning * isMoving
WalkingPenalty fWalkingSpreadPenalty * !isRunning * isMoving
StandingPenalty fStandingSpreadPenalty * !isSneaking
ArmConditionPenalty fCrippledArm1HSpreadPenalty * RIGHT Arm Crippled * isUsing1HWeapon
fCrippledArm2HSpreadPenalty * EITHER Arm Crippled * isUsing2HWeapon
fCrippledArms1HSpreadPenalty * BOTH Arms Crippled * isUsing1HWeapon
fCrippledArms2HSpreadPenalty * BOTH Arms Crippled * isUsing2HWeapon
SkillBonusMultiplier 1 - (fWobbleToSkillConversion * Player Skill{max 100} / 100)

Notes:

  • Walking and Running Penalties exclude each other.
  • As do Arm Condition Penalties.
    • "1 Handed" weapons are those that return GetWeaponAnimType == 4, on the actor, i.e. pistols. The ArmConditionPenalty to them only applies when having both arms crippled (fCrippledArms1HSpreadPenalty), or when having the right one crippled (fCrippledArm1HSpreadPenalty). The game doesn't consider the left arm to be holding them, not even when aiming in ironsights.


Then there's the weapon requirements:

if Weapon Required Strength > Player Strength
StrReqPenalty = (Weapon Required Strength - Player Strength{max 10}) * fWeapStrengthReqPenalty

The Weapon's Required Strength can be lowered by perks with the Modify Weapon Strength Req entry point. Skill requirements don't work correctly:

if Weapon Required Skill > Player Skill
SkillReqPenalty = (Weapon Required Skill - Player Skill{max 100}) * 0.1 * fWeapStrengthReqPenalty

fWeapSkillReqPenalty does not appear to have any effect in vanilla game, its use in the skill requirement formula somehow usurped by fWeapStrengthReqPenalty. This was fixed in JohnnyGuitar NVSE 3.45.

NOTE: the game's loading screens claim that requirements also affect melee weapons' attack speed, but this does not appear to be the case. Weapon requirements do not seem to affect melee weapons in any capacity. Strength requirements do affect the throwing distance of thrown weapons like spears, etc. but not grenades. See fThrowingStrengthPenalty for more info.

Perks

There are two perk entry point functions that can affect PlayerSpread:

  • The main one is Calculate Gun Spread (CGS, entry function nº 34), which a bit counter-intuitively affects PlayerSpread exclusively, not WeaponSpread at all. This entry point is applied after all other parts of the formula, and can lower PlayerSpread under the fMinGunSpreadValue setting.
  • The other one is Modify Aiming Move Speed, which alters the RunningPenalty and WalkingPenalty parts of the formula. The penalty for running or walking is divided by the value of Modify Aiming Move Speed, however it cannot divide below 1.

So, the final spread value for the player with perks ends up like:

PlayerSpread before CGS = max [fMinGunSpreadValue, SkillBonusMult * (UnaimedPenalty + {(WalkingPenalty OR RunningPenalty) / Modify Aiming Move Speed multiplier} + StandingPenalty + ArmConditionPenalty + SkillReqPenalty + StrReqPenalty)]
PlayerSpread = GetPerkModifier 34 (PlayerSpread before CGS), weapon ref

Weapon Spread is:

WeaponSpread = WeaponMinSpread - WeaponModBonus A from Decrease Spread mods

Player Final Spread is:

FinalSpread = WeaponModBonus B from Split Beam mods * (Ammo Modifier * (PlayerSpread + WeaponSpread))

If the attacker is an actor and not the player, the Final Spread is:

FinalSpread = WeaponModBonus B from Split Beam mods * ((Ammo Modifier * (PlayerSpread + WeaponSpread)) * fNPCMaxGunWobbleAngle + (Ammo Modifier * (PlayerSpread + WeaponSpread)))

And there you have your spread value. A few noteworthy things (in the vanilla game at least):

  • I wrote Player everywhere, however it should be interchangeable with Actor, both human NPCs and creatures with ranged weapons.
  • As long as you have the weapon's required strength and skill values, and no crippled arms, you will have the best possible PlayerSpread while crouching, not moving and using aiming/ironsights.
  • Trigger Discipline is only useful for Run n' Gun players, or characters that otherwise have a lot of penalties. Fast Shot is FAR more useful for careful sniper characters that usually crouch and aren't moving.
  • With the default values and no accuracy perks there is always a minimal amount of spread (fMinGunSpreadValue). It's a nice touch for immersion, since it prevents the player's weapon and scope to become completely static.

Other settings

A few settings can affect spread more indirectly:

Setting Default Description
fGunWobbleChaseDriftTime 0.75 ???
fGunWobbleMultScope 1.0 See the description in the FO3 formula. This acts like a multiplier to weapon sway while looking through a scope, but does NOT affect the real weapon sway when firing. So unless you want weird handicaps when scope aiming, it should be left as 1.
fNonAttackGunWobbleMult 0.5 This is the multiplier to weapon sway while the player is NOT attacking, i.e. pulling the trigger. This can help to make high values of PSp less jarring in terms of sway animations while just having the weapon out.
fNPCMaxGunWobbleAngle 15.0 This presumably caps the maximum amount of PSp for actors other than the player, as per the final conversion to degrees.


Spread in-game

Now the spread numbers are only arbitrary values and were fairly easy to figure out. We went one step further and calculated the actual degrees of deviation that spread causes.

These are approximations and may not be 100% correct, since we had little to work with here, however we did plenty of tests and these numbers fit into the calculations:

PSp was actually surprisingly straight forward:

1 unit of PSp = 5.955 degrees of deviation

WSp however not at all because it didn't follow a straight linear progression. Ultimately the following formula fit the debug values for different WeaponSpreads:

1 unit of WSp = ((0.0125 * WeaponSpread²) + (0.125 * WeaponSpread)) * 5.955
TotalDeviationDegree = (PlayerSpread + ((0.0125 * WeaponSpread²) + (0.125 * WeaponSpread)) ) * 5.955

What's noteworthy:

  • PSp actually causes a much bigger degree in deviation than an equal number of WSp. So 2 units of PSp is a much bigger penalty to the players accuracy than 2 units of WSp.
  • However most of the time players, especially those that use automatic weapons and shotguns, have a lot higher WSp than PSp. In those cases a weapon's Min Spread will be a way bigger factor in your overall accuracy than anything else.

Testing Methods

The PSp again was actually fairly easy to figure out, thanks to the fact that in the default settings the scope sway follows exactly the player's hand sway.

All we had to do was record all the extremes of the scope sway, then we could simply calculate the diameter of the sway circle with 3 xy coordinates via the following formula (where getAngle X is Y and getAngle Z is x):

A + B(-x1) + C(-y1) = -(x12 + y12)
A + B(-x2) + C(-y2) = -(x22 + y22)
A + B(-x3) + C(-y3) = -(x32 + y32)
xm = B/2, ym = C/2, and r2 = xm2 + ym2 - A

If you want to try this yourself you can simply write a script that records player.getAngle X and player.getAngle Z, while you are using a scope, have it record the 3 extreme points it will find during a 20 second duration) and input them into a circle calculator.

What initially threw us off was that no matter what game settings we changed, the sway wouldn't alter one bit. That was because we were using the old calculation from FO3 and eventually realized they didn't do anything at all. We then found the new spread GMSTs, and their effect was immediately apparent.

Calculating the PSp is fairly trivial since FNV uses a much much more straight forward calculation (that makes a lot more sense too) than what was used in FO3.

In the end all we had to do was input various test circles into a spreadsheet and the common multiplier of 5.955 for the spread values became very apparent.


Like mentioned, the degrees of deviation caused by Weapon Spread were far more tricky to find out, since weapon spread doesn't cause any kind of sway.

In this case what we did was build a test room with a shooting range. Our test methods were fairly...brute force. We created a circle in the center of the HUD that we could expand and contract manually. Then we fired thousands of rounds into a wall and contracted the circle to fit the shot impacts, then we would use the diameters of those circles in our weapon spread calculations. It became quickly apparent that the deviation wasn't a linear progression as it was for player spread, i.e. 4 MinSpread didn't have twice the deviation of 2 MinSpread.

In this case we simply had to rely on a lot of trial and error and approximations until we reached the above mentioned formula for WeaponSpread deviation.


And that concludes our explanation of Spread. Hope these findings will prove helpful to people out there.

Disclaimer

All of the above was originally written several years ago, and some later findings and additions have been included so that it should all be usable advice when playing and modding FNV, but overall there may still be parts of the whole formula and system left to discover and clarify.

See Also