Precisión

This page is going to be an in-depth, highly technical explanation of how all the different pieces of Accuracy all work together for weapons in Deep Rock Galactic. What will be described on this page explains how Accuracy works if the player is standing still. There are additional penalties to accuracy while moving, but this topic is already complex enough without having to account for them.

## Descripción

In the most abstract terms, Accuracy has two moving parts: the "crosshair" section1 that governs where pellets can be fired when the trigger gets pulled, and the "recoil" section that determines how far the crosshair gets displaced from the Original Aim Axis. At the start of the firing sequence, there is no Recoil so the center of the crosshair is perfectly aligned with the Original Aim Axis.

For the majority of hitscan weapons2, firing a shot causes the game to get the current horizontal and vertical sizes of the crosshair and use them to create a bounding ellipse (previously referred to as "crosshair"). All pellets fired per shot start with their trajectories perfectly aligned to the center of the ellipse, and then they get randomly displaced to anywhere within the bounding ellipse. The game does **not** favor putting the pellets closer to the center of the ellipse; it is a true RNG roll for each individual pellet.

If the current Total Recoil is greater than zero, then the game first displaces the center of the bounding ellipse from the Original Aim Axis before performing its random pellet distribution.

1. NOTE: what is referred to as the "crosshair" section **is not** referring to the crosshairs displayed on-screen in the player's HUD. Those are just approximations to help the player aim; they are **not** representative of internal values.

2. Autocannon, Boomstick, and Zhukovs are the three exceptions. They all use rectangular bounding regions, instead of ellipses.

### Definición de términos

* **Base Spread**: the minimum bounding region (either ellipse or rectangle) across which pellets can be randomly distributed
* **Current Spread**: this can only have a value between zero and Spread Variance, and is the current value of units that are added to Base Spread when the game fetches what the current Horizontal and Vertical Spread values are.
* **Dispersión por disparo:** cada vez que realizas un disparo, este valor se añadirá al valor de *Dispersión actual* (sin sobrepasar la *varianza de dispersión*)
* **Spread Recovery Speed**: if Current Spread is greater than zero (as in, at least one shot has been fired recently), then this is the value of how many Spread Units are subtracted per second from Current Spread until it returns to zero
* **Spread Variance**: this value governs the maximum bounding region size such that neither its vertical nor horizontal values can surpass Base Spread + Spread Variance. If a shot gets fired and the added Spread per Shot would make Current Spread exceed Spread Variance, Current Spread instead just gets set to the max value and some of the Spread per Shot is lost.
* **Spread Curve**: certain weapons have a function that converts the current Spread values from linear, intuitive functionality into non-linear outputs. It can be conceptualized as changing "Total Spread = Base Spread + Current Spread" to "Total Spread = Base Spread + SpreadCurve(Current Spread)"
* **Original Aim Axis** (OAA): before the first shot gets fired, the Original Aim Axis is the center of the player's screen (and by extension the crosshair displayed on the HUD). The OAA is the axis to which Recoil is perpetually trying to return. The OAA remains stationary relative to the player's HUD whenever Total Recoil is greater than zero such that moving the crosshair down to counteract recoil also moves OAA down, and when the Recoil is falling off the crosshair will fall back down to where the OAA has moved to.
* **Recoil per Shot**: every shot fired by hitscan weapons has an associated recoil value that displaces the center of the bounding region by a small amount and then returns back to zero over time.
* **Total Recoil**: this is a rolling sum of all Recoil per Shots as time progresses. If only one shot was fired, then Total Recoil would be identical to one Recoil per Shot. However, if shots are fired faster than the Recoil per Shot can recover, then Total Recoil will continue to rise until it reaches an equilibrium where the amount of recoil being shed by the sum of all Recoil per Shots is equal to amount of recoil being gained by the next shot. Due to this rolling sum, increasing the weapon's Rate of Fire will also increase the maximum Total Recoil value because the equilibrium won't be reached as fast.

## Dispersión

### Variables empleadas en la dispersión

All of these variables can be found in the HitscanBaseComponent object associated with each weapon.

* MaxHorizontalSpread
* MaxVerticalSpread
* SpreadPerShot
* SpreadRecoveryPerSecond
* MinSpread
* MaxSpread

### Ecuaciones de dispersión

Horizontal Base Spread = MaxHorizontalSpread

Vertical Base Spread = MaxVerticalSpread

Spread Variance = MaxSpread - MinSpread

Current Spread after firing a shot = min(Current Spread + Spread per Shot, Spread Variance)

Current Spread(t) while Current > Base = max(Base Spread, Current Spread - Spread Recovery Speed \* t)

#### Conversión de unidades de dispersión en grados

Similar to how the FoV setting in DRG can say "100 degrees" when in fact it's only 50 degrees deviation from the center, the Total Spread value is double of the useful value. That means a Base Spread of 3 would translate to 1.5 degrees, Total Spread of 12 would become 6 degrees, and so on. The halved values are far more useful for calculating the sizes of bounding regions at any given distance. As a result, in order to calculate the degrees of deviation from OAA, it's as simple as picking either Horizontal or Vertical Spread, getting the corresponding Base Spread value, add the Current Spread (MinSpread < Current Spread < MaxSpread), and then divide by 2 for ease of use in sin().

\[Degrees = \frac{Base Spread + Current Spread}{2}\]

### Ejemplo completo de dispersión

1. El jugador dispara
2. The game fetches the current values of Horizontal Base Spread + Current Spread and Vertical Base Spread + Current Spread, and uses them to form a bounding region (either ellipse or rectangle). If the weapon has a Spread Curve, it changes the lookup to Base Spread + SpreadCurve(Current Spread)
3. All pellets to be fired for this shot have their trajectories randomly displaced within the bounding region and then their hitscan collisions get checked
4. The game tries to add the Spread per Shot to the Current Spread value. If that causes Current Spread to exceed the Spread Variance value, Current Spread gets set to Spread Variance instead.
5. If Current Spread > 0 (equivalent to Current Spread + Base Spread > Base Spread), then the game starts subtracting Spread Recovery Speed units per second from Current Spread
6. Se repiten los pasos 1-5 para cada disparo del cargador
7. After enough time has passed, Spread Recovery Speed will reduce Current Spread all the way to zero, bringing the Total Spread back down to Base Spread.

## Retroceso

DRG has modeled the recoil of their guns to use a Critically Damped Harmonic Oscillator function.

### Variables usadas en el retroceso

All of these variables can be found in the RecoilSettings property of the AmmoDrivenWeapon object associated with each weapon.

* Mass
* SpringStiffness
* RecoilPitch
* RecoilYaw
* CanRecoilDown

NOTE: CanRecoilDown is only true for Minigun, Autocannon, and Zhukovs. For all other weapons, the recoil can only go up, left, or right.

### Recoil Equations Used

#### Frecuencia natural

* Let Mass be represented by 'M'
* Let SpringStiffness be represented by 'S'

\[\omega\_{n} = \sqrt{\frac{S}{M}}\]

#### Velocidad inicial total

* Let RecoilPitch be represented by 'V'
* Let RecoilYaw be represented by 'H'

\[v\_{i} = \sqrt{V^{2} + H^{2}}\]

#### Retroceso por disparo con el tiempo

\[R(t) = e^{-\omega\_{n}\*t} \* (v\_{i} \* t)\]

NOTE: this equation returns the degrees of deviation of how far the center of the crosshair should move away from the OAA for this shot.

Example plot using Subata's default variables:

#### Time for Recoil per Shot to reach 0.1

\[End = \frac{-W\_{-1}[\frac{-\omega\_{n} \* 0.1}{v\_{i}}]}{\omega\_{n}}\]

NOTE: the \[W\_{-1}[...]\] is shorthand for the LambertW function using k=-1

### Ejemplo completo de retroceso

1. Se realiza un disparo
2. RecoilPitch is fetched and chooses between the up and down direction (if CanRecoilDown=True, else only up direction can be chosen), and RecoilYaw is fetched and chooses between either left or right direction.
3. Using RecoilPitch, Mass, and SpringStiffness a Recoil(t) function is made to track the vertical recoil of the shot that was just fired. Similarly, RecoilYaw is used in a Recoil(t) function to track the horizontal recoil.
4. The Total Vertical Recoil and Total Horizontal Recoil values start tracking their new Recoil(t) functions, respectively, and add the current degrees of deviation to their totals.
5. When Recoil(t) falls below a certain value (modeled as 0.1), the two Total Recoil trackers discard that function from their running sums.
6. The player's HUD is moved off of the OAA vertically by Total Vertical Recoil degrees and horizontally by Total Horizontal Recoil degrees. This has the added effect of moving the weapon's crosshair center off of the OAA too.
7. Repeat steps 1-6 for every shot in the magazine
8. After enough time has passed, all of the individual Recoil(t) functions will have fallen below the threshold (0.1 in this model) and both Total Recoil values will return to zero, also returning the HUD to the OAA.

## Internal values per weapon

### Table of baseline values

Disclaimer: these values were last updated using Update 31, Hotfix 5.

### Tables of mods' and overclocks' effects

Disclaimer: these values were last updated using Update 31, Hotfix 5.

#### Subata

 OC "Automatic Fire" | x2.0 MaxHorizontalSpread  x2.0 MaxVerticalSpread  x2.5 RecoilPitch  x2.5 RecoilYaw

#### Shotgun

 OC "Mini Shells" | x0.5 RecoilPitch  x0.5 RecoilYaw

#### SMG

 OC "EM Refire Booster | x1.5 MaxHorizontalSpread  x1.5 MaxVerticalSpread

#### Minigun

 OC "Bullet Hell" | x6.0 MaxHorizontalSpread  x6.0 MaxVerticalSpread

#### Autocannon

 OC "Big Bertha" | x0.7 MaxHorizontalSpread  x0.7 MaxVerticalSpread

#### Revolver

 OC "Elephant Rounds | x0.5 MaxHorizontalSpread  x0.5 MaxVerticalSpread  +5 SpreadPerShot  +4 MaxSpread  x1.5 RecoilPitch  x1.5 RecoilYaw  +3.5 Mass

#### BRT

 OC "Lead Spray" | x4.0 MaxHorizontalSpread  x4.0 MaxVerticalSpread

#### GK2

 OC "AI Stability Engine" | +9 SpreadRecoveryPerSecond  x0 RecoilPitch  x0 RecoilYaw

#### M1000

 OC "Hipster" | -0.3 SpreadPerShot  x0.85 MaxSpread  x0.5 RecoilPitch  x0.5 RecoilYaw

#### Zhukovs

 OC "Gas Recycling" | x1.5 MaxHorizontalSpread  x1.5 MaxVerticalSpread