Recently, I've been studying the game code for combat calculations - so far, I've looked at chance to hit, critical effects, and damage calculation. I've started looking into burst-fire weapons, both to get an idea of how to fix the "burst attack bug" (e.g. the high chance of low-percentage shots hitting nearby targets), and to find places where adding scripting hooks could be useful for modding. The good news is, I know how to fix the burst attack bug; however, it's not a simple fix, and I'm worried that the changes I make could have implications for gameplay balance.
I wanted to poll some of the players here, on how you envision use of burst attack weapons vs. other attack types, so that the changes I make don't negatively affect gameplay. I've included details on the current behavior of burst attack below, but it's a big wall of text, so I want to get my questions out first so that I don't scare anyone away.
1. Which of the following factors do you consider as the key advantage for burst attacks, and to what degree for each?
* Damage amplification on one target, by scoring more hits
* Higher chance of doing at least some damage to the target, through firing more shots
* Damage amplification by attacking multiple targets that are grouped together
2. To what extent do you agree/disagree with the following in regards to burst weapons?
(Notes in parenthesis describe current game behaviors.)
* A target should never have a higher chance of being hit by a stray bullet fired at someone else, than they would have had if they were the intended target. (The burst bug violates this.)
* Every bullet fired should at least have a chance of hitting some target, as long as any possible target has a greater than 0 chance of being hit. (Some combinations of number of targets, and chance to hit, cause some fired rounds to never be checked, resulting in guaranteed misses.)
* It should be possible, even if somewhat unlikely statistically, or requiring point-blank range, to have a single target in the firing cone, and have that target be hit by every round fired. (Currently a single target can only be hit by at most 70% of the rounds fired in a burst.)
* If the designated target has a 95% chance to hit, then on average, 95% of the fired rounds eligible to hit that target should hit. (The game caps burst hit chance at 70%, even if the cursor displays 95% chance. Worse, having above 70% chance can actually reduce damage done to secondary targets, with no benefit to hitting the main target.)
* If multiple targets are in the firing arc, it should be possible in some circumstances for a fired round to hit more than one target. (Currently, each round is assigned to only a single target, with the total fired being divided among targets according to hit chance.)
* Targets nearer in line to the intended target should have higher chance of being hit than those at the edge of the firing cone. (Angle difference from target doesn't appear to have much, if any, effect.)
* Targets directly in front of the intended target should have higher chance to be hit than the intended target or those behind the intended target. (Currently, the only factor that comes into play is higher chance to hit due to shorter distance from the attacker. And there are scenarios where the target immediately beyond the intended target has a greater chance of being hit than those in front.)
3. How balanced are the benefits vs. drawbacks of burst weapons?
Burst attacks have a lot of disadvantages:
* One extra AP to fire
* No ability for aimed shots, leading to lower critical chance
* Usually shorter maximum range
* Extra ammo usage, plus needing to reload more often
* Lower ammo efficiency due to the reduced damage per shot
* Higher susceptibility to damage threshold, because it is applied to each shot individually
* Possibility of friendly fire
These drawbacks are balanced by the three benefits listed above in question 1, but not to the degree that may be expected due to the quirks in implementation described in question 2.
* Should only the burst bug be fixed, and the quirks of lower hit chance and uncounted shots be left as-is?
* If the quirks are fixed, allowing chance to hit above 70%, allowing more than 70% of fired rounds to hit a single target, and ensuring that every round has at least some chance to hit, will burst attacks be overpowered, balanced, or underpowered?
* If still underpowered, would having fired rounds possibly hit multiple targets help to balance? (Shotguns and explosives have this advantage already - full damage can be applied to every target in range.)
4. How should friendly fire be balanced?
Right now, there doesn't appear to be meaningful differentiation between friendly and enemy targets when considering secondary hits. So any friendly in the firing arc will a) have the same chance of being hit as an enemy would, and b) will reduce damage done to enemies even if they aren't hit. Should attackers have reduced chance to hit friendly targets, or should the player have the burden of keeping friendlies entirely out of the way? Should targets at the very edge of the firing cone have very low chance of friendly fire? Should difficulty level, or attacker's weapon skill, affect this? (For that matter, would a new perk which prevents friendly fire on burst attacks be overpowered?)
Any other comments or ideas are greatly appreciated. Everyone has different play styles, so I don't want to leave anything out.
Details of the game mechanics for burst attacks are included below.
---
The game has two routines for calculating chance to hit:
* The primary routine is used for nearly all calculations - melee, H2H, single-round guns, shotguns (single and combat), and throwing weapons. It is also used for calculating chance to hit the designated target for burst guns, and for showing the % chance to hit on the cursor. This routine caps chance to hit to the range [0, 95].
* The secondary routine is used only for burst gun attacks, and determines chance to hit targets other than the designated target within the cone of fire. This routine caps chance to hit to the range [0, 40].
For burst attacks, the game performs the following steps:
* Calculate the sum of the chance to hit for all targets in the cone of fire. This is used to determine "share" of the burst rounds for each target - the intended principle is that each round can only hit a single target, and easier-to-hit targets would have a greater share of rounds striking that target. If the sum is less than 100, set it to 100.
* Loop through all targets, in order from closest to the attacker to farthest from the attacker, and perform the following:
* Determine chance-to-hit again for the current target. Use the primary calculation for the designated target, and the secondary calculation for any others, with one exception - if the designated target is dead, then use the primary calculation for any remaining targets. Cap this chance to hit in the range [0, 70].
* Multiply the number of rounds fired by the chance to hit, and divide by the sum chance-to-hit calculated in the very first step. This determines how many rounds will be aimed at this target. If fewer rounds are available to be assigned (e.g. they have already been checked against other targets), then only those rounds remaining are used.
* For each round, roll a random number [0, 99]. If this number is less or equal to the chance to hit, then add one round to the hit count.
* Apply damage from all rounds to the target. I haven't checked on the critical hit for burst weapons yet, but I believe it does a single critical hit check, and uses the result of that check for all rounds.
Overall, I've found a few bugs, and unintuitive (and possibly unintended) behaviors for burst attacks:
* The secondary chance-to-hit calculation seems to apply factors in a confusing way. It's not clear whether secondary hits are considered "desirable" for the attacker. For example, positive factors like weapon skill and short distance to target increase the chance to hit, but so do negative factors like injuries to the attacker. And at least one positive factor (easy skill level) reduces the secondary chance-to-hit for players against enemies, but leaves unchanged secondary chance-to-hit for squadmates.
* In the secondary calculation, decently high weapon skill (80-100% or more) completely outweighs all other factors, to the point that the 40% cap is always reached. This is the main cause for the "burst attack bug", where low-percentage shots against one target have a high chance of hitting others standing nearby. As an example, consider a Browning M2 burst of 15 rounds, against a target with chance of 20%, but two other targets in line of fire with secondary chance of 40% each (chance-to-hit sum of 100). Three rounds (15 * 20/100) will be fired at the designated target, with a roughly 50/50 chance to be hit at least once. For the other two targets, 6 rounds (15 * 40/100) are fired at them, which at 40% each gives a ~95% chance of at least one hit, and an expected average of 2.4 hits per burst per secondary target.
* Burst hit chances above 70% are not useful, since the algorithm caps at 70% when determining both share of rounds on the target and chance of hit for each target. Worse, the sum in the first step actually uses the 95% value, which will break the share calculation, often causing some fired rounds to never be checked at all.
* When firing at one isolated target, it is not possible for more than 70% of the burst rounds to hit that target. The only way to get maximum damage potential for the burst is to have at least two targets, with the primary having 70% hit chance or less (otherwise part of his share is wasted).
I wanted to poll some of the players here, on how you envision use of burst attack weapons vs. other attack types, so that the changes I make don't negatively affect gameplay. I've included details on the current behavior of burst attack below, but it's a big wall of text, so I want to get my questions out first so that I don't scare anyone away.

1. Which of the following factors do you consider as the key advantage for burst attacks, and to what degree for each?
* Damage amplification on one target, by scoring more hits
* Higher chance of doing at least some damage to the target, through firing more shots
* Damage amplification by attacking multiple targets that are grouped together
2. To what extent do you agree/disagree with the following in regards to burst weapons?
(Notes in parenthesis describe current game behaviors.)
* A target should never have a higher chance of being hit by a stray bullet fired at someone else, than they would have had if they were the intended target. (The burst bug violates this.)
* Every bullet fired should at least have a chance of hitting some target, as long as any possible target has a greater than 0 chance of being hit. (Some combinations of number of targets, and chance to hit, cause some fired rounds to never be checked, resulting in guaranteed misses.)
* It should be possible, even if somewhat unlikely statistically, or requiring point-blank range, to have a single target in the firing cone, and have that target be hit by every round fired. (Currently a single target can only be hit by at most 70% of the rounds fired in a burst.)
* If the designated target has a 95% chance to hit, then on average, 95% of the fired rounds eligible to hit that target should hit. (The game caps burst hit chance at 70%, even if the cursor displays 95% chance. Worse, having above 70% chance can actually reduce damage done to secondary targets, with no benefit to hitting the main target.)
* If multiple targets are in the firing arc, it should be possible in some circumstances for a fired round to hit more than one target. (Currently, each round is assigned to only a single target, with the total fired being divided among targets according to hit chance.)
* Targets nearer in line to the intended target should have higher chance of being hit than those at the edge of the firing cone. (Angle difference from target doesn't appear to have much, if any, effect.)
* Targets directly in front of the intended target should have higher chance to be hit than the intended target or those behind the intended target. (Currently, the only factor that comes into play is higher chance to hit due to shorter distance from the attacker. And there are scenarios where the target immediately beyond the intended target has a greater chance of being hit than those in front.)
3. How balanced are the benefits vs. drawbacks of burst weapons?
Burst attacks have a lot of disadvantages:
* One extra AP to fire
* No ability for aimed shots, leading to lower critical chance
* Usually shorter maximum range
* Extra ammo usage, plus needing to reload more often
* Lower ammo efficiency due to the reduced damage per shot
* Higher susceptibility to damage threshold, because it is applied to each shot individually
* Possibility of friendly fire
These drawbacks are balanced by the three benefits listed above in question 1, but not to the degree that may be expected due to the quirks in implementation described in question 2.
* Should only the burst bug be fixed, and the quirks of lower hit chance and uncounted shots be left as-is?
* If the quirks are fixed, allowing chance to hit above 70%, allowing more than 70% of fired rounds to hit a single target, and ensuring that every round has at least some chance to hit, will burst attacks be overpowered, balanced, or underpowered?
* If still underpowered, would having fired rounds possibly hit multiple targets help to balance? (Shotguns and explosives have this advantage already - full damage can be applied to every target in range.)
4. How should friendly fire be balanced?
Right now, there doesn't appear to be meaningful differentiation between friendly and enemy targets when considering secondary hits. So any friendly in the firing arc will a) have the same chance of being hit as an enemy would, and b) will reduce damage done to enemies even if they aren't hit. Should attackers have reduced chance to hit friendly targets, or should the player have the burden of keeping friendlies entirely out of the way? Should targets at the very edge of the firing cone have very low chance of friendly fire? Should difficulty level, or attacker's weapon skill, affect this? (For that matter, would a new perk which prevents friendly fire on burst attacks be overpowered?)
Any other comments or ideas are greatly appreciated. Everyone has different play styles, so I don't want to leave anything out.
Details of the game mechanics for burst attacks are included below.
---
The game has two routines for calculating chance to hit:
* The primary routine is used for nearly all calculations - melee, H2H, single-round guns, shotguns (single and combat), and throwing weapons. It is also used for calculating chance to hit the designated target for burst guns, and for showing the % chance to hit on the cursor. This routine caps chance to hit to the range [0, 95].
* The secondary routine is used only for burst gun attacks, and determines chance to hit targets other than the designated target within the cone of fire. This routine caps chance to hit to the range [0, 40].
For burst attacks, the game performs the following steps:
* Calculate the sum of the chance to hit for all targets in the cone of fire. This is used to determine "share" of the burst rounds for each target - the intended principle is that each round can only hit a single target, and easier-to-hit targets would have a greater share of rounds striking that target. If the sum is less than 100, set it to 100.
* Loop through all targets, in order from closest to the attacker to farthest from the attacker, and perform the following:
* Determine chance-to-hit again for the current target. Use the primary calculation for the designated target, and the secondary calculation for any others, with one exception - if the designated target is dead, then use the primary calculation for any remaining targets. Cap this chance to hit in the range [0, 70].
* Multiply the number of rounds fired by the chance to hit, and divide by the sum chance-to-hit calculated in the very first step. This determines how many rounds will be aimed at this target. If fewer rounds are available to be assigned (e.g. they have already been checked against other targets), then only those rounds remaining are used.
* For each round, roll a random number [0, 99]. If this number is less or equal to the chance to hit, then add one round to the hit count.
* Apply damage from all rounds to the target. I haven't checked on the critical hit for burst weapons yet, but I believe it does a single critical hit check, and uses the result of that check for all rounds.
Overall, I've found a few bugs, and unintuitive (and possibly unintended) behaviors for burst attacks:
* The secondary chance-to-hit calculation seems to apply factors in a confusing way. It's not clear whether secondary hits are considered "desirable" for the attacker. For example, positive factors like weapon skill and short distance to target increase the chance to hit, but so do negative factors like injuries to the attacker. And at least one positive factor (easy skill level) reduces the secondary chance-to-hit for players against enemies, but leaves unchanged secondary chance-to-hit for squadmates.
* In the secondary calculation, decently high weapon skill (80-100% or more) completely outweighs all other factors, to the point that the 40% cap is always reached. This is the main cause for the "burst attack bug", where low-percentage shots against one target have a high chance of hitting others standing nearby. As an example, consider a Browning M2 burst of 15 rounds, against a target with chance of 20%, but two other targets in line of fire with secondary chance of 40% each (chance-to-hit sum of 100). Three rounds (15 * 20/100) will be fired at the designated target, with a roughly 50/50 chance to be hit at least once. For the other two targets, 6 rounds (15 * 40/100) are fired at them, which at 40% each gives a ~95% chance of at least one hit, and an expected average of 2.4 hits per burst per secondary target.
* Burst hit chances above 70% are not useful, since the algorithm caps at 70% when determining both share of rounds on the target and chance of hit for each target. Worse, the sum in the first step actually uses the 95% value, which will break the share calculation, often causing some fired rounds to never be checked at all.
* When firing at one isolated target, it is not possible for more than 70% of the burst rounds to hit that target. The only way to get maximum damage potential for the burst is to have at least two targets, with the primary having 70% hit chance or less (otherwise part of his share is wasted).
Last edited: