mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-03-26 21:01:19 +00:00
Modify distx/disty to ensure it never goes too low
This commit is contained in:
parent
9cd47643df
commit
89887ccf0d
1 changed files with 19 additions and 12 deletions
31
src/k_kart.c
31
src/k_kart.c
|
@ -1052,7 +1052,6 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid)
|
|||
mobj_t *fx;
|
||||
fixed_t momdifx, momdify;
|
||||
fixed_t distx, disty;
|
||||
//fixed_t nobumpx = 0, nobumpy = 0;
|
||||
fixed_t dot, p;
|
||||
fixed_t mass1, mass2;
|
||||
|
||||
|
@ -1101,20 +1100,28 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid)
|
|||
momdify = FixedMul((25*mapheaderinfo[gamemap-1]->mobj_scale), normalisedy);
|
||||
}
|
||||
|
||||
/*if (mass1 == 0 && mass2 > 0)
|
||||
{
|
||||
nobumpx = mobj2->momx;
|
||||
nobumpy = mobj2->momy;
|
||||
}
|
||||
else if (mass2 == 0 && mass1 > 0)
|
||||
{
|
||||
nobumpx = mobj1->momx;
|
||||
nobumpy = mobj1->momy;
|
||||
}*/
|
||||
|
||||
// Adds the OTHER player's momentum, so that it reduces the chance of you being "inside" the other object
|
||||
distx = (mobj1->x + mobj2->momx) - (mobj2->x + mobj1->momx);
|
||||
disty = (mobj1->y + mobj2->momy) - (mobj2->y + mobj1->momy);
|
||||
|
||||
{ // Don't allow dist to get WAY too low, that it pushes you stupidly huge amounts, or backwards...
|
||||
fixed_t dist = P_AproxDistance(distx, disty);
|
||||
fixed_t nx = FixedDiv(distx, dist);
|
||||
fixed_t ny = FixedDiv(disty, dist);
|
||||
|
||||
if (P_AproxDistance(distx, disty) < 3*mobj1->radius/4)
|
||||
{
|
||||
distx = FixedMul(mobj1->radius/2, nx);
|
||||
disty = FixedMul(mobj1->radius/2, ny);
|
||||
}
|
||||
|
||||
if (P_AproxDistance(distx, disty) < 3*mobj2->radius/4)
|
||||
{
|
||||
distx = FixedMul(mobj2->radius/2, nx);
|
||||
disty = FixedMul(mobj2->radius/2, ny);
|
||||
}
|
||||
}
|
||||
|
||||
if (distx == 0 && disty == 0)
|
||||
{
|
||||
// if there's no distance between the 2, they're directly on top of each other, don't run this
|
||||
|
|
Loading…
Reference in a new issue