Symthic Forum was shut down on January 11th, 2019. You're viewing an archive of this page from 2019-01-09 at 01:32. Thank you all for your support! Please get in touch via the Curse help desk if you need any support using this archive.

Welcome to symthic forums! We would love if you'd register!
You don't have to be expert in bit baking, everyone is more than welcome to join our community.

You are not logged in.

## Algorithms for the Shooting Mechanics in BF4

Hey! If this is your first visit on symthic.com, also check out our weapon damage charts.
Currently we have charts for Battlefield 3, Call of Duty: Black Ops 2, Medal of Honor: Warfighter and Call of Duty: Modern Warfare 3

Skynet T100

Posts: 1,614

Date of registration
: Apr 12th 2013

Platform: PC

Location: Guilin Peaks, Finland

Battlelog:

Reputation modifier: 14

Sunday, November 10th 2013, 3:59pm

### Algorithms for the Shooting Mechanics in BF4

Background and Aims
To evaluate objectively how weapons, attachments, bursting patterns, etc. possibilities compare against each other, we can use computational modeling of weapon behaviour given these parameters. Many such efforts to quantify and tabulate weapon comparisons or headshot efficiencies have been made, see:
Attachment Combinations - Numerical Benefits
A dummy's guide to calculating optimum weapon's range

Here at Symthic, we have a fairly good understanding of the mechanisms that control weapon accuracy and damage output through knowledge of the weapon stats and by understanding how recoil and spread works. This knowledge is, however, distributed to several too often forgotten threads and Symthic web pages. The great grandfather of this stuff is probably the plotic thread where much of the algorithms and programming were pioneered: Plotic - Graphical representation of weapon deadliness that for the program code was followed by Symplot - v.0.6.8

The aims of this thread are

(i) to compile and document this information and its sources,
(ii) to make the algorithms and their assumptions explicit, and
(iii) to present discussion about and critique towards the current state-of-the art methods.
(iv) The ultimate aim is to provide the basis for anyone to build an as accurate as possible model of in-game weapon behaviour with data that are continuously improving through future discoveries that refine the model.

Tl;dr, One Ring Thread to rule them all . ÂÂthem allÂ denoting gun-model threads.

I will do my best to acknowledge the persons responsible for the original observations and give links to the correct threads. If there are deficiencies or omissions in this, please make a post about it. For all information, having the correct original source is critical because only that way the quality of the information can be assessed.

Finally, as a disclaimer, what I have written here is not an established truth. It is the most accurate working hypothesis about the mechanics of BF4 that we as a community have. So, if you know better, please contribute any critique that you see relevant and constructive. This thread aims to compile the best efforts of Symthic to achieve the best models achievable Â this is possible only through iterative and continuous improvement.

Overview
In BF4, probability of hitting (weapon accuracy) is controlled by spread and recoil. The damage-output-per-second is controlled by damage/bullet, the firing rate of the gun, and the fraction of bullets that hit the target. These define a framework where we can assess the effectiveness of each weapon. The question of which gun+attachment-combo is the best, however, has to be formulated properly because the effects of many parameters cannot be included in simulations. Think about the value of having a large magazine or staying of the minimap with silencer. Someone could even make a list of such considerations to fuel further modelling work (for example, the magazine size issue could be included into a metric like ÂHow much time does it take to get five kills? (incl. reloads)Â.

For a set of gun stats, attachments, recoil compensation method, hitboxes, bursting patterns, and distance:
ÂHow much Time does it take to produce 100 damage?Â

We could call such a measure T100. It represents our ultimate estimate of the true-time-to-kill but still excludes factors like reloading.

In the two posts below, I outline the framework for modelling shooting in BF4 and the algorithms used therein. In algorithms, I use the variable names from BF4 files.

As the very core assumption, I presume ÂshootingÂ and ÂaimingÂ to go like this:

Shooting
The bullet leaves the player model ÂsoonÂ after the moment of the player giving the ÂFireÂ command (usually with LMB). The bullet is aimed at the Aimpoint of the player avatar. This aimpoint is modifiable by player mouse location all the time, by recoil after each shot, and by recoil recovery after the last bullet of the burst has been fired. This aim is modified by spread and finally the bullet trajectory is modified by gravity. The aimpoint in reality is a quaternion (a three/four dimensional complex number for representing the three angles needed to represent a point in a 3D sphere) but for all purposes needed here, it is sufficient to consider the aimpoint in the two dimensions (x,y) of the flat hit box surfaces facing the shooter.

Most of the links and math that I know of are now in place - this is the release version like it or not . Please make a post in this thread if you think I have omitted a source or ignored some aspect of the algorithms.
"Less is more? How can that be? How could less be more, that's impossible. More is more." Yngwie Malmsten
"Many bullets help." WoopsyYaya
"most rhetorically legitimate ad hominem 2015" ToTheSun!

This post has been edited 7 times, last edit by "3VerstsNorth" (May 5th 2014, 5:21pm)

Skynet T100

Posts: 1,614

Date of registration
: Apr 12th 2013

Platform: PC

Location: Guilin Peaks, Finland

Battlelog:

Reputation modifier: 14

Sunday, November 10th 2013, 4:00pm

Spread is radial noise added to the aimpoint of every shot (see What kind of noise is Spread? and Plotic - Graphical representation of weapon deadliness). This was confirmed by Demize and in game by John Stuart-Mill's analysis in this post: What kind of noise is Spread?. Mechanics of spread are summarized below.

For an aimpoint az,
az = ax + i*ay,
the bullet will go towards the location z,
z = ax + sz.

Here Spread is the current playerÂs current spread value and theta is a uniformly random angle from Âpi Â +pi. For grasping the polar notation for complex numbers, see Complex number. It is important to note that radially random spread gives much more hits close to the aimpoint than uniform spread (see first post in the ref above): within 0.5 x Spread, 50% of shots will hit whereas uniform predicts only 25% to hit and within 0.25 x spread, 25% of shots will hit whereas uniform predicts only 6.25% to hit.

Spread is dependent on the player state variables: mode {ADS, HIP}, stance {Stand,Crouch,Prone}, and motion {Base,Move}. In addition, Spread is dependent on spread accumulated from prior shots AND on spread recovered during time spent without shooting time or during the time spent after a change in the state variable(s).

In gamefiles, the minimum spread is defined in variables named by state variable names and ÂMinÂ, like ADSStandBaseMin for example. Spread increase per shot is similarly defined by ÂSpreadIncÂ, e.g., by ADSStandBaseSpreadInc. For clarity, I refer to these variables by ÂMinÂ and ÂSpreadIncÂ. Look into the spoilers for all the interesting stuff:

For each shot j from 0 to N-1,

Note that the maximum Spread achievable during ADS or HIP by accumulation is limited by ADS**Max and HIP**Max values.

Spread recovery in files is controlled by ÂSpreadDecÂ. Spread recovery has been confirmed by a reliable source to be linear. Spread recovery can be approximated with a linear dependence on time, t.

Spread recovery, albeit short in time, is essential for determining optimal bursting rates. For those tabulated, see: Mouse click rates for optimal RoF

The minimum spread variable for a moving player (**MoveMin) is apparently not used directly for giving the Min(spread) but rather used to define a 'moving penalty' so that

SpreadPenalty = (MoveMin Â BaseMin * BaseMinModifiers)

In this scenario, the 0.5 moving spread multiplier of ergo/vertical grip influences spread so that

Min = BaseMin + 0.5 * Penalty * SpeedModifier

Min = 0.5 * BaseMin + Penalty * SpeedModifier,

where Penalty would be MoveMin - 0.5 * BaseMin.

The SpeedModifier is the fraction of the player's movement speed from the normal running (not sprinting) speed. For most guns, SpeedModifier during ADS is 0.5. For bullpup weapons, it is 0.75.

Considering multiple modifiers together, Rezal argues that the order of computations is

(Rezal's notation for variables)

For sources, see this and this post by Rezal. See also this thread by WoopsyYaya where many very good questions are answered in great detail and where Woopsy has tabulated the moving spread values for all guns.
"Less is more? How can that be? How could less be more, that's impossible. More is more." Yngwie Malmsten
"Many bullets help." WoopsyYaya
"most rhetorically legitimate ad hominem 2015" ToTheSun!

This post has been edited 14 times, last edit by "3VerstsNorth" (Oct 6th 2014, 10:34pm)

Skynet T100

Posts: 1,614

Date of registration
: Apr 12th 2013

Platform: PC

Location: Guilin Peaks, Finland

Battlelog:

Reputation modifier: 14

Sunday, November 10th 2013, 4:00pm

### Recoil

Recoil is defined by its horizontal and vertical components defined in the files by RecoilLeft, RecoilRight, and RecoilUp. The vertical recoil and the mean horizontal recoil can be compensated for: 'Recoil Compensation'.

The vertical component moves for each shot the aimpoint upwards apparently without randomness and so that for the first shot, the vertical recoil is multiplied by FirstShotMultiplier.

### ÂIn pseudo-code:Â

For each shot after the first shot
if j=0
VRecoil = VerticalRecoil * FirstShotMultiplier
else
VRecoil = VerticalRecoil
ay(j+1) = ay(j) + VRecoil

The horizontal recoil is not a random number between LeftRecoil and RightRecoil. If it were, the aimpoint would exhibit a random walk during the burst (see Random walks & horizontal recoil ). Instead, LeftRecoil and RightRecoil are used in pseudo-random pre-generated patterns: Horizontal recoil analysis (recoil patterns) (see, for example, RezalÂs recordings in BF3).

To approximate the pseudo-randomness, AdmiralGiggleÂs hitrate simulator: Hitrate simulator uses the following algorithm that can be more formally thought of as a Markov-like process.

### ÂHorizontal recoil algorithm AÂ

For each shot, find a random value between -LeftRecoil and RightRecoil.
After any two consecutive positive values, the next value is randomized between ÂLeftRecoil and 0
After any two consecutive negative values, the next value is randomized between 0 and RightRecoil.

An alternative realization, used in Brute-force approach to BF4 gun balance & optimal attachments, burst sizes, and aim targets, of the same idea that would be suitable for having weapon-independent pre-generated patterns is:

### ÂHorizontal recoil algorithm BÂ

Â¬LetÂs divide the pattern into two parts so that first weapon independent series of recoil directions Booleans (False for ÂLeftÂ and True for ÂRightÂ) are generated with algorithm A:
For each shot, pick a random boolean.
After any two consecutive same values, the next value is not this value.
This series can then be realized to a weapon-specific series by randomizing a number between ÂLeftRecoil and 0 for each False and a number between 0 and RightRecoil for each True.

As far as I know, we do not have analyses that allow the falsification either of these models even though they generate different distributions of horizontal recoil. Testing this statistically from aimpoint series like this [ref] would be easy if there was a sufficient amount of data (say 20+ magdumps) from a couple of BF4 weapons.

However, Rezal has made a note that BF4 H recoil might not be generated this way while ViperFTW accurately observes that H Recoil is annoying nevertheless.

The horizontal recoil is a random number between LeftRecoil and RightRecoil (see this: Horizontal Recoil in BF4). Hence the aimpoint will exhibit a random walk during the burst (see Random walks & horizontal recoil ).

Once the vertical and horizontal recoils are found, the iterative algorithm for modifying the aimpoint az is simply

az(j+1) = [ax(j) + Hrecoil] + i*[ay(j) + Vrecoil].

### Recoil Recovery

Recoil recovery is a cubic function and was revealed by James "undeadpixel" Kono / Miffyli in this thread. The equations are:

### Source code

1

recoil* scale * time^2

Where:

### Source code

1
2
3

recoil = the recoil decrease from the files
scale = 0.1 when gun is firing (more accurately: time when you can't fire second shot due to RoF). 1.0 otherwise
time = time since last shot
"Less is more? How can that be? How could less be more, that's impossible. More is more." Yngwie Malmsten
"Many bullets help." WoopsyYaya
"most rhetorically legitimate ad hominem 2015" ToTheSun!

This post has been edited 15 times, last edit by "3VerstsNorth" (Oct 11th 2014, 2:10pm)

Skynet T100

Posts: 1,614

Date of registration
: Apr 12th 2013

Platform: PC

Location: Guilin Peaks, Finland

Battlelog:

Reputation modifier: 14

Sunday, November 10th 2013, 4:01pm

### Major unresolved issues

We need a list of stuff that remains poorly understood. Please make a post about questions that are missing from this list and also post on this thread when an item on the list has been addressed.

1. Exact (estimated as well as possible) dimensions of the different hitboxes in player avatars in the in-game stances or behind common heights of cover.

2. Moving ADS spread vs. movement speed vs. attachment effects. IÂm not sure if an agreement has been reached on the conclusiveness of the evidence at present.

3. Recoil and Spread recovery. What functions control recovery? Is recovery interrupted by shooting? Does, for example, spread recovery from HIP to ADS start before or after the ADS animation?

4. Â

"Less is more? How can that be? How could less be more, that's impossible. More is more." Yngwie Malmsten
"Many bullets help." WoopsyYaya
"most rhetorically legitimate ad hominem 2015" ToTheSun!

This post has been edited 2 times, last edit by "3VerstsNorth" (Oct 6th 2014, 10:30pm)

PvF 2017 Champion

Posts: 7,304

Date of registration
: Apr 3rd 2012

Platform: PC

Battlelog:

Reputation modifier: 19

Monday, November 11th 2013, 9:07am

### Quoted from "3VerstsNorth"

see, for example, Rezal?s recordings for BF3: imgur: the simple image sharer).

Data Browser

Passive Spotting is the future!

"Skill" may indeed be the most magical of words. Chant it well enough and any desire can be yours.

Are you a scrub?

### Quoted from "blahdy"

If it flies, it diesÂ.

Skynet T100

Posts: 1,614

Date of registration
: Apr 12th 2013

Platform: PC

Location: Guilin Peaks, Finland

Battlelog:

Reputation modifier: 14

Monday, November 11th 2013, 9:14am

### Quoted from "3VerstsNorth"

see, for example, Rezal?s recordings for BF3: imgur: the simple image sharer).

Thanks, corrected.
"Less is more? How can that be? How could less be more, that's impossible. More is more." Yngwie Malmsten
"Many bullets help." WoopsyYaya
"most rhetorically legitimate ad hominem 2015" ToTheSun!

Skynet T100

Posts: 1,614

Date of registration
: Apr 12th 2013

Platform: PC

Location: Guilin Peaks, Finland

Battlelog:

Reputation modifier: 14

Monday, November 11th 2013, 11:43am

Update: Most of the links that I know of are now in place. Please make a post in this thread if you think I have omitted a source or ignored some aspect of the algorithms.
"Less is more? How can that be? How could less be more, that's impossible. More is more." Yngwie Malmsten
"Many bullets help." WoopsyYaya
"most rhetorically legitimate ad hominem 2015" ToTheSun!

Posts: 328

Date of registration
: Jun 12th 2013

Platform: PC

Location: US

Battlelog:

Reputation modifier: 5

Monday, November 11th 2013, 2:50pm

Lennox 203 did some analysis on headshot burst distance back in bf3 that might be relevant here.
The fact that someone has an opinion, doesn't make their opinion a fact. Making just arguments first requires an acknowledgement of intellectual humility, while valid arguments require you to not commit fallacies of logic and rhetoric.

Skynet T100

Posts: 1,614

Date of registration
: Apr 12th 2013

Platform: PC

Location: Guilin Peaks, Finland

Battlelog:

Reputation modifier: 14

Tuesday, November 12th 2013, 11:23am

### Quoted from "untamedone"

Lennox 203 did some analysis on headshot burst distance back in bf3 that might be relevant here.

Good, thanks! This is now included in the first post.

"Spread accumulation" is also edited to have a note on max spread.
"Less is more? How can that be? How could less be more, that's impossible. More is more." Yngwie Malmsten
"Many bullets help." WoopsyYaya
"most rhetorically legitimate ad hominem 2015" ToTheSun!

Posts: 86

Date of registration
: Jul 18th 2013

Platform: 360

Location: New York, NY

Battlelog:

Reputation modifier: 8

Tuesday, November 12th 2013, 6:10pm

It may be a bit redundant, but 'Real' ADS strafe spread values talks about the implementation of ADS moving spread to reflect a linear relationship between min and max speed as in BF3. Obviously, this post is mostly relevant to ADS moving spread applied to BF3, but it does confirm its implementation as such in BF3 with a tweet from Demize99 (a Dice developer). It might be useful to elucidate/clarify what a weapon's 'real' ADS strafe spread value are.

Otherwise, thank you for taking the time to put this together.

1 guests