Apologies - it's taken me way too long to get to this. Hopefully this info is still useful.
My current main questions are about attacks. For example, when doing a single shot attack (straight spread arc) what happens when the target roll misses, how big is the "cone" and how is an alternate target selected. I have adapted the logic from f2 and seems to work decently but would love to have it closer to the real thing.
This one is odd - I've been trying to recreate this effect (straight shot hitting an unintended target), and have not been able to do so. Nor do I see code in the main path for straight attacks to consider alternate targets. Do you have a save or specific setup I can try to confirm this effect? That way I'd be able to walk the code in the debugger and see how the alternate target is selected.
Next one is the burst attack, again adapted from f2, I currently have it spreading the bullets on 3 lanes (left, center, right), but all these three lanes intersect so that they all contain the actual target. The center lane bullets are first rolled for the mian target and what misses are rolled for other potential targets in the lane. Left and right start rolling from the closest to the furthest and may at some point get a chance to roll on the actual target. There are some to hit penalties for non-actual target rolls. Again seems to work decently but I have heard that the burst calculation in FoT is very different (and buggy) would love to learn more about it.
This one I know more about. See
this thread for more details, but the high-level behavior is:
* Determine chance to hit for all targets in the area (approx. +/- 22 degrees from intended target, if memory is correct). This is where part of the "bug" comes in - the chance to hit for "alternate" targets (e.g. all but the selected) uses a different chance to hit that is way too high at long distance.
* Determine the "share" of shots assigned to each target, based on chance to hit of each. That is, each shot can only hit one target, depending on which "share" it is included in. The intended target is capped at 70% of total shots, and each alternate target is capped at 40%. (Side effect of this - if shooting burst at only one target, then 30% of shots are automatically wasted due to the 70% share cap.)
* For each target, determine how many shots within its share actually hit, then do damage/critical calculations. Critical hit is only checked once per target for the full burst, not per shot.
The various fixes change things:
* The "old" burst bug fix mostly nulls out alternate target hits by substantially reducing the calculated alternate chance to hit.
* FTSE uses only the regular chance to hit code, but applies a linear reduction in that chance starting from 5 degrees off the line to the intended target, eventually reducing to zero at around 22 degrees off the intended line. This gives a better result than either other method, but still isn't perfect (e.g. the 70% cap is still in effect).
Your method sounds pretty good - if you get good results with it, I'd recommend sticking with it instead of trying to use one of the above.
The cone spread arc is a mistery to me, used by shotguns from what I could tell. I haven't implemented this yet. I'm currently thinking about spreading your initial rounds into multiple sub rounds (pellets) and use the same burst logic. Again would love to know how it actually works in game.
Cone is used for shotguns. Basic working is:
* The same 22 degree cone is used as in Burst case to determine eligible targets.
* Each target is hit by all shots - no share calculation as in the Burst case.
* The regular chance to hit calculation is used for all targets - no alternate chance, no reduction in chance at the edges of the cone.
* Damage is given a multiplier. At point blank range, damage is 2.5x stated. Multiplier linearly decreases based on range, down to 0.5x at the weapon's listed maximum range.
The spray and radial I could not really find used anywhere but it would be interesting to have some insights on them.
Spray I've not looked into. There is a code section specifically for it, but I haven't walked that code yet to see what it actually does.
Radial is used by the electrical attack from the Pacification Bot. It attacks in a full circle at its stated range, and does damage based on how far each target is (full damage at zero range, reduced at farther range - similar to explosives).
And the none spread arc is strange as it is used for things like the rocket launcher, I would have expected that to be straight. It is also used for the flamer which is again weird, don't exactly know how that is actually calculated behind the scenes. I remember in f2 it was something like a burst attack spread but it would try to attack each target exactly one time.
None and Straight appear to use the same code. There is alternate code specifically for projectile attacks (based on the "uses projectile" flag), but this mainly only involves setting the impact point for a "missed" projectile.
I have also implemented free fire (ctrl + click on ground). For fire arms it's relatively straight forward, I just use the single shot or burst functions with a non target tile as the target and then the lanes do their thing. I'm more curios about projectile weapons in this case like grenades, rocket launcher, spear etc - what is the spread calculation, how much more left does it go if your roll misses, how much further etc. - I have some rough implmementation that also takes into account how bad your roll was compared to the chance to hit.
I haven't checked this yet. Aiming at a location uses a fully different set of code in most cases. So I don't know exactly how it handles a "miss" in such cases, or even what chance to hit means for something without AC.
Edit: Corrected the Cone spread description - multiplier at max range is 0.5x, not 0.