Chaosforge Forum

  • March 28, 2024, 19:15
  • Welcome, Guest
Please login or register.



Login with username, password and session length
Pages: [1]

Author Topic: [0.9.9.3] Proposed Aiming/Shotgun Tweaks  (Read 2317 times)

tehtmi

  • Programmer
  • Local Inquisitor
  • Lieutenant Colonel
  • *
  • *
  • Offline Offline
  • Posts: 458
    • View Profile
[0.9.9.3] Proposed Aiming/Shotgun Tweaks
« on: July 19, 2011, 03:49 »

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:
Code: [Select]
.................
..........******.
....************.
@***************.
....************.
..........******.
.................
This is perfectly fine, but it is not typically observed. Consider now a combat shotgun blast into relatively far-away wall:
Code: [Select]
...............#.
..........*****#.
....***********#.
@**************#.
.**************#.
.........******#.
...............#.
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:
Code: [Select]
...#######...
...#..****@..
...***.../...
..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:
Code: [Select]
...#######...
.........#@..
.......***...
..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).
Logged

thelaptop

  • Chaos Fanatic!
  • Grand Inquisitor
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 2530
    • View Profile
Re: [0.9.9.3] Proposed Aiming/Shotgun Tweaks
« Reply #1 on: July 19, 2011, 08:15 »

Deep stuff here, but the examples are not completely satisfactory, particularly for that of the shotgun blast.  Does the propose tweak #1 also provide the best corrected firing arc when the angle is oblique (e.g. 45 degrees, 30 degrees etc)?
Logged
I computed, therefore I was.

tehtmi

  • Programmer
  • Local Inquisitor
  • Lieutenant Colonel
  • *
  • *
  • Offline Offline
  • Posts: 458
    • View Profile
Re: [0.9.9.3] Proposed Aiming/Shotgun Tweaks
« Reply #2 on: July 19, 2011, 16:37 »

Here's an example of firing with an oblique angle. (The targeted square is marked with X.)
Code: [Select]
...............#
.............**#
...........****#
.........******#
.......********#
.....**********#
...************#
.**X*******....#
@*****.........#

@**............#
.**X****.......#
...**********..#
.....**********#
.......********#
.........******#
...........****#
.............**#
...............#

................
.............***
...........*****
.........*******
.......*********
.....***********
...************.
.**X*****.......
@**.............
The result of Tweak 1 would be that firing into the wall would match the firing into space in both the firing upwards and downwards cases. (Notice that they are asymmetric currently.)

For Tweak 2, I forgot to mention what the most notable difference would probably be: the ability to corner shoot with shotguns from below as well as from above. (Depending on the implementation, Tweak 1 could also ameliorate this problem.)

When testing oblique angles, I noticed another issue that should be easy to fix.

Tweak 3:

Currently, firing shotgun blasts at two different targets with the same slope can result in different affected areas.

Consider the case of firing a combat shotgun at a 45 degree angle targeting one square away vs. two squares away.
Code: [Select]
.................
...........*****.
...........*****.
..........******.
.........*******.
........********.
........******...
.......******....
......******.....
.....*****.......
.....****........
....****.........
...***...........
..***............
..**.............
.X...............
@................

.................
........*****....
.......******....
.......******....
......*******....
.....********....
.....*******.....
....******.......
...******........
...****..........
..****...........
.*X*.............
.**..............
@................
These are both symmetrical (since no walls are involved), but the fact that they are so different is strange. In particular, notice that when the adjacent square is targeted, the range of the blast is extreme.

The reason for the difference is a case of rounding too early.  In dflevel.pas lines 765-767, the value d is rounded before using it as a divisor. If the rounding is done after the division instead, then shotgun blasts with the same slope will be the same. In the given example, the result would be somewhere in between, but much closer to the case of targeting two squares away.

The increased consistency of shotgun blasts should help players predict the results of their actions.
« Last Edit: July 20, 2011, 00:03 by tehtmi »
Logged

thelaptop

  • Chaos Fanatic!
  • Grand Inquisitor
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 2530
    • View Profile
Re: [0.9.9.3] Proposed Aiming/Shotgun Tweaks
« Reply #3 on: July 19, 2011, 18:57 »

Excellent work!  I hope this makes it into 0.9.9.4 as a fix.  Strange firing mechanics has always been a major issue with DRL1.

Thanks for the good work!  =D
Logged
I computed, therefore I was.
Pages: [1]