CDarrow / DXX-Retro

A source port of Descent 1 and 2, focused on quality competitive play. Uncompromising commitment to original gameplay (except where the original sucked). Based on the Rebirth project.
Other
49 stars 15 forks source link

(D2) Bomblet acceleration varies with the frame rate #78

Open ryusei117 opened 7 years ago

ryusei117 commented 7 years ago

Tested versions with this bug: D2X Retro 1.3a D2X Retro 1.4.X3

Tested versions without this bug: D1X Retro 1.3 D1X Retro 1.4.X3 D1X-Rebirth and D2X-Rebirth 0.58.1

Bomblets from Smart Missiles, Smart Mines, and Earthshaker Missiles accelerate less quickly as the frame rate increases. At 30 FPS, they seem to accelerate about as quickly as in the original D2 engine, but at 200 FPS, they're quite sluggish. I'm kinda surprised it took me this long to notice!

Here are some demos comparing the original engine and D2X Retro 1.4.X3 at 30 FPS and 200 FPS:

bomblets_d2x_retro.zip

ghost commented 7 years ago

It took me way longer than it should to find this issue and I'd like to post my changes to save you some time. :) https://github.com/dxx-rebirth/dxx-rebirth/commit/89a2df0e1884d48293dc288360800a7f61520d08

ryusei117 commented 7 years ago

While investigating this issue, zico and vLKp found several interesting bugs related to the homing code as well. I recommend looking at the DXX-Rebirth issue report; it should be helpful in addressing the bomblet issue. :-)

roncli commented 7 years ago

I looked into this, and I have questions for @zicodxx. This addresses dxx-rebirth/dxx-rebirth@89a2df0, and then I'll look into dxx-rebirth/dxx-rebirth@407805b if necessary. :)

ghost commented 7 years ago

a) the incorrect change in object_is_trackable that I reverted in https://github.com/dxx-rebirth/dxx-rebirth/commit/89a2df0 happened a long time ago and it's possible that Retro was forked after that. I can honestly not recall anymore why I made this change however but for the sake of restoring the original behavior of the tracking and the acceleration of the homing projectiles connected to that, this was essential.

b) 'homerFrameCount' and 'tick_count' between Retro and Rebirth are negligible. They represent 'FrameCount' of the original engine. But while the original engine actually counted every frame, this made the tracking become more drastig, the higher the FPS. Both 'homerFrameCount' and 'tick_count' increment in 33.3 ms intervals - i.e. 'as if the game ran at 30 FPS' to keep the tracking constant. The reason D2 only checks every 8 frames (i.e. every 8 ticks in Rebirth/Retro) is because D1 and D2 behave vastly different when it comes to the velocity computation of a tracking projectile. See: https://github.com/dxx-rebirth/dxx-rebirth/commit/dad3e953e9731a8d87f128f651751e996dddb45a#diff-9ec4bf9e21dc950adcea244c1053830aR1624 That is also why the trackable dot definitions are so different between both games.

c) The change in 'homing_missile_turn_towards_velocity' is - of all changes - the most insignificant as it just rotates the missile model. Since the homing projectiles do in fact only turn based on ticks - and not in every frame, rotating them should happen in the same scale as they turn. Otherwise, for sharp turns, it may look as if the missile suddenly starts to strafe, instead of pointing its nose in the direction it flies.

d) https://github.com/dxx-rebirth/dxx-rebirth/commit/407805b addresses the trackable dots I mentioned in the last line of 'b'. Since the developers of the game realized that missiles do not track constant on all FrameRates, they tried to compensate this by giving the homing projectiles a more narrow field of view the higher the FPS rates are. My commit restores this behavior so it gives the missiles the proper tracking cone depending on what FPS behavior are specified for the individual game. I once made those all constants but the problem was that I used the WRONG constant for the 30 FPS base in D2. With this fix get_scaled_min_trackable_dot will query the original constants given in the game's original release based on which FPS base value we wish to make them behave to. It's important to note that those trackable dot values also differ between D1 and D2 due to the different behavior of the missiles as detailed in 'b'.

I hope this helps. I realize this is very convoluted. Which is why it took me so long to find all these problems and properly address them.

EDIT: And yes, quite a few of these issues already were present in Rebirth way before Retro was forked. Either because I was tinkering on them without knowing exactly what I was doing or others were tinkering with them before Rebirth was even a thing. With the current code base Rebirth should perfectly emulate the unique homing behaviors of the original games as if they ran on 30 FPS. So all changes that have added between the original source release (i.e. from the original D1X to Rebirth) are reverted and made tick based.