Kanhef said:
The function compute_attack is in charge of most of the process. Early on it makes a call to compute_spray; treating a single shot as a burst of 1 simplifies the code.
Actually, compute_spray is called if and only if weapon's animation type is 2E or 2F (burst attack and flame attack, respectively). Check for single shot/melee/etc. attacks is made elsewhere.
Kanhef said:
compute_spray calls check_ranged_miss to determine what happens to bullets that miss their target outright. check_ranged_miss includes a call to critter_is_dead, so it doesn't hit dead bodies (or at least doesn't show any messages about it).
Only 1/6 of the bullets (at least one) try to attack the primary target. I'm not absolutely sure about next part of the code, but it looks like check_ranged_miss checks only ONE of those 1/6 bullets that missed their target (I know this is weird; I suspect it's just a bug).
Kanhef said:
If you don't miss completely, compute_spray later calls shoot_along_path so bullets can hit critters in the way, no matter how skilled you are.
These are always called, except for case of critical failure (and even then, if "hit randomly" effect chose another target, they will be called, just the primary target will be changed). All the bullets are divided into three groups (left, right, central, that will contain about 1/3, 1/3, and 1/6+n bullets respectively, where n are leftover bullets from the initial 1/6 volley that attacked the primary target).
These three groups will then travel along three "parallel" tracks (but hex adjacent to the attacker is common for all of them), trying to hit targets on the way. And skill does matter - determine_to_hit is called every time the valid target is found. Basically, when the group of bullets finds the target, the bullets try to hit it one by one until one of them fails. Then they move on to the next target.
The above was confirmed in-game. I used minigun throwing 1000 bullets at a time (I set ToHit to constant 95%), about 180 hit the primary target, the rest were hit by around 20 - which is the expected value, 1/(1-0.95). When I changed ToHit to constant 100%, the primary target was hit by 334, and the two at it's sides for 333.
Kanhef said:
it looks like the armor-piercing unarmed attacks ignore the target's damage threshold (DT), whereas armor-bypassing criticals ignore damage resistance. With the critical chance bonus from these attacks, it's not hard to get both at once.
Armor-piercing unarmed attacks are equivalent to attacks with weapons with Weapon Penetrate perk. They are dividing the target's DT by 5.
Armor-bypassing criticals are dividing the target's DT by 5, dividing target's inherent DR (that gained from armour, drugs, perks/implants in case of player) by 5 and ignoring Finesse trait DR bonus. The DR from bullet's dr_mod is applied normally.
Effects of these two does not stack. Armor-bypassing critical hit won't work with EMP weapons.
In about two weeks, I'll make a nice PDF with (almost) fully described mechanics of combat in FO2. It should clarify even more issues.