Title: A strange bit of combat physics Post by: Shiver on October 22, 2008, 01:22:51 am Take a look at lines 70-77 of ship.c in UQM 0.6.2:
Code: else if (TravelAngle == CurrentAngle && (StarShipPtr->cur_status_flags & (SHIP_AT_MAX_SPEED | SHIP_BEYOND_MAX_SPEED)) && !(StarShipPtr->cur_status_flags & SHIP_IN_GRAVITY_WELL)) { // already maxed-out acceleration return (StarShipPtr->cur_status_flags & (SHIP_AT_MAX_SPEED | SHIP_BEYOND_MAX_SPEED)); } I've been playing melee competitively for a long time and I wasn't even aware the game did this until I started poking around with the game's ship code myself. It's rare for a ship to perform a gravity whip without being nudged by the gravity well upon exiting it or for a ship to not turn at all before attempting to slow down. When this code does kick in, it will prevent a ship from slowing itself back down to default speed and screw over the unsuspecting player. Not knowing about this code until yesterday, I get the feeling I have had ships destroyed by it without understanding what went wrong. Fossil was the one that pointed me to this code in the first place. He also gave me this fix: Code: else if (TravelAngle == CurrentAngle && (StarShipPtr->cur_status_flags & (SHIP_AT_MAX_SPEED | SHIP_BEYOND_MAX_SPEED)) && !(StarShipPtr->cur_status_flags & SHIP_IN_GRAVITY_WELL)) { // already maxed-out acceleration SIZE delta_x, delta_y; SIZE cur_delta_x, cur_delta_y; DWORD current_speed; thrust_increment = WORLD_TO_VELOCITY (thrust_increment); GetCurrentVelocityComponents (VelocityPtr, &cur_delta_x, &cur_delta_y); current_speed = VelocitySquared (cur_delta_x, cur_delta_y); delta_x = cur_delta_x - COSINE (CurrentAngle, thrust_increment); delta_y = cur_delta_y - SINE (CurrentAngle, thrust_increment); SetVelocityComponents (VelocityPtr, delta_x, delta_y); return (StarShipPtr->cur_status_flags & (SHIP_BEYOND_MAX_SPEED)); } Although the offending code is not a bug and usually does not have much effect on gameplay, I propose this fix be implemented into UQM's next release to make combat physics more consistent. Title: Re: A strange bit of combat physics Post by: Elvish Pillager on October 22, 2008, 03:20:41 am I agree that this should be implemented. As Shiver says, the effect a rare exception case with no apparent reason behind it.
- Technical details: As far as I can tell, the current code for the different-angle case (lines 117-133) would result in deceleration at half the normal rate of acceleration when facing in the same direction as the velocity vector. This proposed change appears to decelerate at the full normal rate of acceleration. Also, this proposal is an ugly duplicate implementation. The existing code seems like it would work fine for the identical-angle case. So I'd do the following: - eliminate the whole "else if()" starting at line 70; - change line 105 to add a reversal of the conditions, as follows: Code: else if (TravelAngle == CurrentAngle && (!(StarShipPtr->cur_status_flags & (SHIP_AT_MAX_SPEED | SHIP_BEYOND_MAX_SPEED)) || (StarShipPtr->cur_status_flags & SHIP_IN_GRAVITY_WELL))) Title: Re: A strange bit of combat physics Post by: fossil on October 23, 2008, 12:00:36 am The last proposal looks about right, except you should not test for SHIP_IN_GRAVITY_WELL. That is handled by an else if just above. And this should still invoke when SHIP_AT_MAX_SPEED, so
Code: else if (TravelAngle == CurrentAngle && !(StarShipPtr->cur_status_flags & SHIP_BEYOND_MAX_SPEED)) However, this change has a better chance of getting attention and not getting lost if you submit it as an enhancement type bug in Bugzilla (http://bugs.uqm.stack.nl/). Provide as much reasoning behind the change as you can. Title: Re: A strange bit of combat physics Post by: Shiver on October 23, 2008, 12:36:27 am The last proposal looks about right, except you should not test for SHIP_IN_GRAVITY_WELL. That is handled by an else if just above. And this should still invoke when SHIP_AT_MAX_SPEED, so Code: else if (TravelAngle == CurrentAngle && !(StarShipPtr->cur_status_flags & SHIP_BEYOND_MAX_SPEED)) This did not work when I tried it. The Thraddash would not brake at all while traveling above max speed in a straight line. Holding off on using Bugzilla for the moment. Title: Re: A strange bit of combat physics Post by: fossil on October 23, 2008, 02:34:50 am This did not work when I tried it. Did you remove the else if at line 70 as Elvish specified?Do not hold off on Bugzilla just because all the details have not been worked out. Such details are better dealt with in Bugzilla anyway. Otherwise, it's your choice, of course. Title: Re: A strange bit of combat physics Post by: Shiver on October 23, 2008, 03:03:43 am Did you remove the else if at line 70 as Elvish specified? Do not hold off on Bugzilla just because all the details have not been worked out. Such details are better dealt with in Bugzilla anyway. Otherwise, it's your choice, of course. Oh, his replacement code worked. But if the details don't need to be set in stone, I suppose I can get on that now. Title: Re: A strange bit of combat physics Post by: fossil on October 23, 2008, 04:52:01 pm Please direct further technical details and proposed patches to Bug #1043 (https://bugs.uqm.stack.nl/show_bug.cgi?id=1043)
|