Aiming path calculation is open source as a part of
FPC Valkyrie. Paths are calculated using the TVisionPath class. Shotgun area-of-effect is calculated using the same algorithm, though multiple rays are cast. I believe there are two minor tweaks that can be made to this class to slightly improve the consistency and usefulness of aiming paths.
Tweak 1:First, consider a combat shotgun blast. If there are no obstructions, a combat shotgun blast pointed directly right will look like this:
.................
..........******.
....************.
@***************.
....************.
..........******.
.................
This is perfectly fine, but it is not typically observed. Consider now a combat shotgun blast into relatively far-away wall:
...............#.
..........*****#.
....***********#.
@**************#.
.**************#.
.........******#.
...............#.
Now the area of effect has increased, and it is now asymmetrical. This picture may be more familiar to players, as most Doom RL levels don't have very large open spaces.
The asymmetry turns out to be relatively easy to fix. Consider lines 388-396 of vvision.pas (from valkyrie version 0.4.5): two checks are made to determine whether shx (or shy) should be positive or negative. In the case of firing into a wall (as above), both checks will succeed. Thus, preference will be given to the second check creating the above asymmetry. To resolve this, I propose that if both checks are successful, then shx (or shy) should be set to zero. As a result, TVisionRay should be completely symmetrical.
In the above comparison, my proposed fix would result in the second shotgun blast being the same as the first shotgun blast, which, although smaller, would be more consistent. This tweak should also reduce the weirdness of the bullet paths that arise when trying to target through walls.
Tweak 2:Consider a second example: trying to shoot through two doorways (as in Phobos Base Entry). The following path is calculated by the game:
...#######...
...#..****@..
...***.../...
..X#.....#...
...#######...
This path aims immediately into a wall.
Now, consider the loop in TVisionRay that calculates shx (or shy) (vvision.pas lines 382-397). The loop goes through the entire path, and recalculates shx or shy for each relevant cell. As a result, shx (or shy) is based on the final obstruction.
Recall the example: the game plotted a path through the final obstruction (the second doorway), but ignored the first obstruction (the first doorway). Observe the case if the second obstruction were removed:
...#######...
.........#@..
.......***...
..X****..#...
...#######...
Here, we see that the game is perfectly capable of plotting a path through the first doorway; it simply prefers to plot a path through the second doorway.
I propose that the aiming code should prefer to avoid the first obstacle rather than the last. Generally, neither path will be particularly desirable, but the path avoiding the first obstacle will be slightly more useful, especially when it arises without the player's knowledge as part of tracing out a shotgun blast.
To implement the proposed behavior, the game should break out of the loop immediately after setting shx (or shy) to a non-zero value (respecting the first tweak if it is implemented).