# PC Rust AK recoil

This browser model targets PC Rust only. Both modes use Facepunch weapon data extracted from the installed Steam client, build **25231061**, rather than a hand-drawn sine wave. This is a reconstruction for browser practice, not a verified port of every client camera, stance, sensitivity or projectile calculation. It has not been calibrated against the November 2026 live build.

## Source assets

- Old: `assets/content/properties/recoil/ar.recoil.asset`, retained by the installed client. `useCurves = true`, 30 shots, 0.15-second kick, ADS scale 0.5. The exported pitch and yaw keys include the original tangents.
- New: `assets/content/properties/recoil/new/ak47.recoil.nopattern.asset`, linked by the old asset's `newRecoilOverride`. Pitch -2.5 to -3.5 degrees, yaw 1.5 to 2.5 degrees, 0.1-second kick, ADS scale 0.75. It also supplies the 1.25-degree aimcone growth curve and the separate probability curve.
- The generated coefficients are in `pc-ak-data.mjs`. No external recoil service is called at runtime.

[Facepunch's Combat Update, 2 June 2022](https://rust.facepunch.com/news/the-combat-update/) describes replacing fixed patterns with variable aim drift, increasing inaccuracy and weighted aimcone. The same update changed weapon sounds. The developer's description does not publish a complete numerical client implementation.

## Verification, 9 November 2026

- Every field of both AK recoil assets was re-read from the installed client (build 25231061, updated 12 September 2026). All values in `pc-ak-data.mjs` match. The export now also records `timeToTakeMax`, `useCurves`, `curvesAsScalar`, `maxRecoilRadius` and `overrideAimconeWithCurve`.
- Old: the per-shot kicks match the historical AK compensation table with correlation 1.000 horizontally and 0.9997 vertically, every interval within 0.04 degrees. Fitting each axis separately gives the same scale (0.0402 and 0.0403 degrees per count), so the shape, turns and proportions are confirmed independently. The absolute size rests on that inferred scale.
- New: `curvesAsScalar = 1` with a yaw curve that eases from 0 to 1 over `shotsUntilMax = 10` shots was not modelled before. Each random yaw kick is now scaled by that curve (pitch curve is flat), so a spray starts almost straight up and builds its drift to the right, as seen on community PC training servers. The aimcone growth curve now also runs over `shotsUntilMax` instead of a fixed 30 shots. The curve input is taken as shots already fired divided by `shotsUntilMax`; the exact client expression has not been seen.
- `maxRecoilRadius` (5 old, 20 new) was not modelled at first; see the Thompson verification below: it caps only the summed sideways kick of new recoil, so the full-magazine climb is unaffected.
- The client is IL2CPP, so the recoil code itself was not read. Live builds after 25231061 have not been checked.

## Browser behavior and limits

Old mode samples successive positions on the retained pitch/yaw curves to create a repeatable 30-shot camera path. The full-size curve agrees with an [independent historical AK compensation table](https://github.com/Bboddy/Rust-Recoil-Script/blob/b0a98dfd412b80380dd1584e1c6b672a4607e2ed/Recoil.py) to about 0.12 degrees on either axis across its 29 intervals when the rounded counts are converted at 0.0405 degrees per count. That scale is inferred from comparing the table to the asset. Using the serialized ADS scalar again cut the historical ADS path in half. The trainer uses the full curve for legacy ADS and hip fire, with a wider aimcone for hip fire. Legacy hip-fire kick strength has not been independently measured.

New mode samples the extracted pitch/yaw ranges on each shot and evaluates the extracted aimcone growth and probability curves. Camera recoil uses elapsed simulation time. Shots follow the camera direction plus a separate aimcone offset, so perfect recoil control does not remove bullet spread.

Both modes include bullet spread. The old camera path is fixed even though bullet impacts can vary. The 0.2-degree base aimcone and 2.5-degree hip addition also appear in [this weapon-data export](https://gist.github.com/AltimorTASDK/f9c59b554d9d0de438f2e000f61a53f3). Cone angles are treated as full angles, matching `AimConeUtil.GetModifiedAimConeDirection` in the locally available server reference.

In old mode crouching tightens the aimcone while preserving the AK's fixed kick, consistent with [Bushhy's 2019 AK practice walkthrough](https://www.corrosionhour.com/rust-ak-recoil-tutorial-2019/). In new mode it reduces both kick and spread. The exact spread and movement factors, the new mode's crouch multiplier, smooth kick envelope, and 0.5-second burst reset are browser approximations, as are sensitivity/FOV mapping and hitscan shots. Ballistic travel, attachments, client recoil-radius recovery and exact stance transitions are outside this model. Full live-client parity has not been measured.

Changing the recoil selector resets the session and magazine. Disabling recoil also disables spread for precision practice. The spray chart plots both axes on one scale, so its shape is the real camera path; `scripts/aim-trainer-spray.check.mjs` checks the old plot against the curve and the new plot's steps against the asset ranges.

Console recoil is measured from 60fps Rust Console footage rather than game files (console files can't be read): see `research/console-recoil.md` in the repository and `console-ak.mjs`. Old console = PC's old AK pattern at half size when aiming; new console = PC's new recoil with pitch x0.93, yaw x1.13 and a 0.54 crouch on pitch; console aim zoom is 0.60 of the FOV. The Console option stays locked unless the input is a controller (`RECOIL_PLATFORMS` and `recoilPlatformFor` in `settings.mjs`), so mouse and keyboard can only use PC recoil.

Rebuild the extracted data and old audio with `scripts/aim-trainer-pc-assets.py` (UnityPy 1.25.4 and ffmpeg required).

## Feel tuning (November 2026)

Played against the live games, the data above felt too soft, so `RECOIL_STRENGTH` in `pc-recoil.mjs` multiplies the camera kick per mode: PC old 1.3, PC new 1.15, console new 1.1, console old 2.2 up and 1.55 sideways (aimed: about 1.17 up and 0.87 sideways of the full PC curve, instead of the measured 0.53 and 0.56). Each mode has a separate pitch and yaw strength. Spread is not scaled, and the spray chart frame scales with it. The data files and checks stay on the raw values (`RAW_STRENGTH`). To try other strengths without a deploy, add `?recoil=1.2` to the page URL: it multiplies every mode for that visit only.

## MP5 (November 2026)

The MP5 runs through exactly the same code as the AK: the same old and new recoil maths, the same `RECOIL_STRENGTH` feel tuning per mode, and the same console changes measured on the AK (old console aimed at 0.53 up and 0.56 sideways of PC, new console pitch x0.93, yaw x1.13, crouch 0.54). Only the data differs. Console MP5 recoil has not been measured separately.

- Old: `assets/content/properties/recoil/mp5recoil.asset` (its `newRecoilOverride` links the new asset). Pitch -2 to -10 degrees and yaw -1.25 to 6 degrees with curves over 30 shots, 0.15-second kick, ADS scale 0.5. The fixed path climbs 10 degrees over a magazine and swings about 4.2 degrees left before coming back.
- New: `assets/content/properties/recoil/new/mp5.recoil.nopattern.asset`. Pitch 1 to 3 degrees, yaw -1 to 1 degree (so it drifts either way, unlike the AK), 0.1-second kick, ADS scale 0.5. `curvesAsScalar = 1` with a yaw curve from 1 to 2 over `shotsUntilMax = 10` shots, an aimcone curve that reaches full size after one shot (scale 1), and its own probability curve.
- Both extracted from the same installed client (build 25231061) by `scripts/aim-trainer-pc-assets.py` into `pc-mp5-data.mjs`.
- Weapon data from the [weapon-data export](https://gist.github.com/AltimorTASDK/f9c59b554d9d0de438f2e000f61a53f3) cited above: repeat delay 0.1 s (600 RPM, the AK is 0.1333 s), reload 4 s (AK 4.4 s), 30 rounds, aimcone 0.5 degrees and hip aimcone 3 degrees (AK 0.2 and 2.5). These live in `weapon.mjs`.
- The spray chart frames the old MP5 pattern tightly and centres the new one, since its drift can go either way (`spray-chart.mjs`). `scripts/aim-trainer-mp5.check.mjs` checks all of the above.

## Thompson (November 2026)

The Thompson runs through the same code and the same strength and console tuning as the AK and MP5. Only the data differs. Console Thompson recoil has not been measured separately.

- Old: `assets/content/properties/recoil/thompsonrecoil.asset` (its `newRecoilOverride` links the new asset; the extraction script now checks that link for every gun). Pitch -2 to -15 degrees and yaw -1.5 to 10 degrees with curves over 30 shots, 0.15-second kick, ADS scale 0.5. The old curves run over one magazine (see the verification below), so the fixed path climbs the whole 15 degrees over the 20 rounds and wobbles about 1 degree each way, twice.
- New: `assets/content/properties/recoil/new/thompson.recoil.nopattern.asset`. Pitch 1.5 to 2 degrees, yaw -1 to 0.25 degrees (so it mostly drifts left), 0.1-second kick, ADS scale 0.5, movement penalty 0.2. `curvesAsScalar = 1` with a flat pitch curve and a yaw curve from 1 to 2 over `shotsUntilMax = 30` shots, an aimcone curve that reaches full size after three shots (scale 1.25), and its own probability curve.
- Both extracted from the same installed client (build 25231061) by `scripts/aim-trainer-pc-assets.py` into `pc-thompson-data.mjs`.
- Weapon data from the same weapon-data export: repeat delay 0.13 s (about 462 RPM), reload 4 s, 20 rounds, aimcone 0.5 degrees and hip aimcone 1.8 degrees. These live in `weapon.mjs`.
- `scripts/aim-trainer-thompson.check.mjs` checks all of the above.

### Thompson verification (11 November 2026)

- Both Thompson assets were re-extracted from the installed client (build 25231061) and match `pc-thompson-data.mjs` exactly.
- The [historical compensation table](https://github.com/Bboddy/Rust-Recoil-Script/blob/b0a98dfd412b80380dd1584e1c6b672a4607e2ed/Recoil.py) has an old Thompson entry (19 steps for 20 rounds). Its shape matches the asset's curves exactly (correlation 1.0000 on both axes, no residual) when the curves run over the 20-round magazine, and not when they run over `shotsUntilMax = 30` (sideways correlation 0.14). Its Custom SMG entry (24 rounds, the same curves) matches the same way over 24 shots. The old pattern now runs over the magazine for every gun, which leaves the 30-round AK and MP5 unchanged.
- Those two entries were computed rather than measured: they use 0.0467 degrees per count and the opposite sideways sign. The AK and MP5 entries, measured in game, match the trainer's size (0.0402 to 0.0408) and direction, so those are kept.
- New recoil was not in that table. Its ranges and curves are the client's, run through the same maths as the AK, whose behaviour was checked against PC training servers. Its curve still runs over `shotsUntilMax`.
- **Decompiled game code** ([natti-jpb/rust-range](https://github.com/natti-jpb/rust-range), `src/core/recoil.js`, ported from the current client's `BaseProjectile` per-frame and per-shot functions) confirms: old curves run at `t = shots / magazine capacity` with no ADS, crouch or movement scaling; new kicks are `Random.Range` within the asset ranges times ADS, crouch 0.5 and movement, with `curvesAsScalar` over `shotsUntilMax`; the shot count resets after a pause of 2 x repeatDelay; and **`maxRecoilRadius` holds a spray's summed sideways kick within that many degrees**.
- `maxRecoilRadius` is now modelled for new recoil: Thompson 0.75 degrees and MP5 0.5. The Thompson and MP5 drift a little, then climb almost straight up. A console Thompson spray at a wall (11 November 2026) drifts about 7 percent of its climb to the left; the capped model gives about 5 percent, the uncapped one about 28 percent.
- Exception: the AK is not capped (`UNCAPPED` in `pc-recoil.mjs`). Its asset says 20 degrees, which would stop its drift around shot 18 and send the rest of the magazine straight up. Every measured console AK spray drifts about 45 degrees aimed (1.13 times the uncapped model, correlation 0.999), and on PC it drifts right to the end of the magazine too. So the port's reading of the cap does not hold for the AK, and the Thompson and MP5 caps rest on the single console Thompson wall spray.
- The spray now restarts after a pause longer than two shot intervals (was 0.5 seconds), as in the game.
- Console Thompson recoil has not been measured: it uses the console changes measured on the AK.
