Vinifera-Developers / Vinifera

Vinifera is a C&C: Tiberian Sun engine extension implementing new logics and fixing bugs.
GNU General Public License v3.0
44 stars 10 forks source link

[Vanilla Bug] Arcing projectiles gain extra range always #90

Open Crimsonum opened 3 years ago

Crimsonum commented 3 years ago

Description:

Units with arcing projectiles (Arcing=true) have some 20–25% higher range than indicated by their weapons' Range value, on flat terrain. This potentially gives them an unfair advantage and makes comparing weapon stats more complicated. For example, although they have the same Range values, a Tick Tank is able to outrange a Titan.

In addition, this extra range is not taken into account when giving attack commands to distant targets. If the target is out of range, the unit will still move to the distance specified by Range before attacking. This supports the conclusion that this extra range is an unintentional oversight.

Steps To Reproduce:

  1. Take two units, one with an arcing weapon and another with any other kind of weapon. Make sure they have the same Range values, preferably 5 or higher.
  2. Place the units side-by-side.
  3. Make them fire at the max. distance specified by their range.
  4. Now, tell the units to fire a little further. The unit with the non-arcing weapon will close the distance, while the unit with the arcing weapon should remain still and still be able to fire at the target.

Expected Behaviour:

On flat terrain, arcing projectiles should gain no extra range compared to other projectile types. However, on high ground, it's logical for them to gain increased range.

Additional Files:

GIF 8 5 2021 22-28-44 For the purpose of this demonstration, all the units were given Range=10. As distance to the target increases beyond 10 cells, note how the tank remains still while the infantry have to reposition themselves.

Rampastring commented 1 year ago

At 0x0063D5A7 in TechnoTypeClass::In_Range is a check for Arcing=yes.

From a quick look, if the projectile has Arcing=no, the game seems to just use the Range= specified on the weapon for the "is-target-in-range" calculation. If the projectile instead has Arcing=yes, the game does some more complex 3D vector math involving the weapon range, gravity and such, giving the projectile more range. This more complex check is an addition to the code in TS that wasn't there in RA, meaning this was probably considered a feature by Westwood.

However, this extra range was only added in TechnoTypeClass::In_Range; the "pick cell to move into when approaching target that is out of range" logic doesn't seem to contain this more "advanced" range calculation and instead only uses the weapon range, regardless of the Arcing= setting of the projectile. This causes the bug where the extra range is only taken into account when you target something that's within the extended range, and ignored otherwise.

The following code disables the extra range in all cases. It should probably not be included in Vinifera by default though because this bug has an effect on vanilla gameplay, and it also disables extra range from elevation.

/**
 *  #issue-90
 *
 *  Disables the bugged bonus range for arcing projectiles.
 *
 *  Author: Rampastring
 */
DECLARE_PATCH(_TechnoTypeClass_In_Range_Disable_Arcing_Bonus_Range_Patch)
{
    JMP(0x0063D6AA);
}

/**
 *  Main function for patching the hooks.
 */
void TechnoTypeClassExtension_Hooks()
{
    Patch_Jump(0x0063D5A7, &_TechnoTypeClass_In_Range_Disable_Arcing_Bonus_Range_Patch);
}