Fix bots + friction

This commit is contained in:
Sally Coolatta 2021-01-31 17:58:18 -05:00
parent bc75f935e3
commit aefff1c943

View file

@ -474,8 +474,7 @@ fixed_t K_BotTopSpeedRubberband(player_t *player)
fixed_t K_BotFrictionRubberband(player_t *player, fixed_t frict) fixed_t K_BotFrictionRubberband(player_t *player, fixed_t frict)
{ {
fixed_t rubberband = K_BotRubberband(player) - FRACUNIT; fixed_t rubberband = K_BotRubberband(player) - FRACUNIT;
fixed_t newfrict; fixed_t origFrict, newFrict;
fixed_t frictionRatio;
if (rubberband <= 0) if (rubberband <= 0)
{ {
@ -483,21 +482,31 @@ fixed_t K_BotFrictionRubberband(player_t *player, fixed_t frict)
return frict; return frict;
} }
newfrict = FixedDiv(ORIG_FRICTION, FRACUNIT + (rubberband / 2)); origFrict = FixedDiv(ORIG_FRICTION, FRACUNIT + (rubberband / 2));
if (frict != ORIG_FRICTION) if (frict == ORIG_FRICTION)
{ {
// Adjust for non-ORIG_FRICTION values newFrict = origFrict;
frictionRatio = FixedDiv(frict, ORIG_FRICTION); }
newfrict = FixedMul(newfrict, frictionRatio); else
{
// Do some mumbo jumbo to make our friction value
// relative to what it WOULD be for ORIG_FRICTION.
// (I hate multiplicative friction :/)
fixed_t offset = ORIG_FRICTION - frict;
fixed_t ratio = FixedDiv(frict, ORIG_FRICTION);
offset = FixedDiv(offset, ratio);
newFrict = frict + offset;
} }
if (newfrict < 0) if (newFrict < 0)
newfrict = 0; newFrict = 0;
if (newfrict > FRACUNIT) if (newFrict > FRACUNIT)
newfrict = FRACUNIT; newFrict = FRACUNIT;
return newfrict; return newFrict;
} }
/*-------------------------------------------------- /*--------------------------------------------------