dkfans / keeperfx

Open source remake and Fan Expansion of Dungeon Keeper.
https://keeperfx.net/
GNU General Public License v2.0
720 stars 73 forks source link

Shots with speeds over 255 aim too high #3154

Open ErminioLucente opened 3 months ago

ErminioLucente commented 3 months ago

Any projectile with speeds set above 256, warps their trajectory. Any angle that is not facing perfectly cardinal and the projectile veers off course from the center. see video example, its more extreme when looking up and down...

https://github.com/dkfans/keeperfx/assets/167131626/a546856e-8e53-4eed-9e0e-22c75c874ba6

Loobinex commented 3 months ago

I looked into it a bit.

In thing_fire_shot the code is using the shot speed in this seemingly unrelated function:

        angles_to_vector(shotng->move_angle_xy, shotng->move_angle_z, speed, &cvect);
        shotng->veloc_push_add.x.val += cvect.x;
        shotng->veloc_push_add.y.val += cvect.y;
        shotng->veloc_push_add.z.val += cvect.z;

In angles_to_vector it does set vertical momentum too, which I have not bothered to figure out. It seems likely though that it assumes a max speed of 255.