mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 12:31:54 +00:00
Modify distx/disty to ensure it never goes too low
This commit is contained in:
parent
5e2d3035e0
commit
e3d40a3878
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;
|
mobj_t *fx;
|
||||||
fixed_t momdifx, momdify;
|
fixed_t momdifx, momdify;
|
||||||
fixed_t distx, disty;
|
fixed_t distx, disty;
|
||||||
//fixed_t nobumpx = 0, nobumpy = 0;
|
|
||||||
fixed_t dot, p;
|
fixed_t dot, p;
|
||||||
fixed_t mass1, mass2;
|
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);
|
momdify = FixedMul((25*mapheaderinfo[gamemap-1]->mobj_scale), normalisedy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (mass1 == 0 && mass2 > 0)
|
// Adds the OTHER player's momentum, so that it reduces the chance of you being "inside" the other object
|
||||||
{
|
|
||||||
nobumpx = mobj2->momx;
|
|
||||||
nobumpy = mobj2->momy;
|
|
||||||
}
|
|
||||||
else if (mass2 == 0 && mass1 > 0)
|
|
||||||
{
|
|
||||||
nobumpx = mobj1->momx;
|
|
||||||
nobumpy = mobj1->momy;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
distx = (mobj1->x + mobj2->momx) - (mobj2->x + mobj1->momx);
|
distx = (mobj1->x + mobj2->momx) - (mobj2->x + mobj1->momx);
|
||||||
disty = (mobj1->y + mobj2->momy) - (mobj2->y + mobj1->momy);
|
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 (distx == 0 && disty == 0)
|
||||||
{
|
{
|
||||||
// if there's no distance between the 2, they're directly on top of each other, don't run this
|
// if there's no distance between the 2, they're directly on top of each other, don't run this
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue