mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 07:22:28 +00:00
...I made two major mistakes with P_GetMobjGravity.
*Didn't take into account object scale *Doubled force when on the ground (ignore what the comment of the line I moved says, it was relevant for slopes...) This also led to a mistake with slopes, where I was double-multiplying by the gravity constant to get half (because of a quirk of numbers...)
This commit is contained in:
parent
213a9632ca
commit
882622d2e7
2 changed files with 9 additions and 13 deletions
10
src/p_mobj.c
10
src/p_mobj.c
|
@ -1316,9 +1316,6 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
|
||||||
if (mo->eflags & MFE_UNDERWATER && !goopgravity)
|
if (mo->eflags & MFE_UNDERWATER && !goopgravity)
|
||||||
gravityadd = gravityadd/3;
|
gravityadd = gravityadd/3;
|
||||||
|
|
||||||
if (!mo->momz) // mobj at stop, no floor, so feel the push of gravity!
|
|
||||||
gravityadd <<= 1;
|
|
||||||
|
|
||||||
if (mo->player)
|
if (mo->player)
|
||||||
{
|
{
|
||||||
if (mo->player->charability == CA_FLY && (mo->player->powers[pw_tailsfly]
|
if (mo->player->charability == CA_FLY && (mo->player->powers[pw_tailsfly]
|
||||||
|
@ -1402,6 +1399,8 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
|
||||||
if (mo->player && !!(mo->eflags & MFE_VERTICALFLIP) != wasflip)
|
if (mo->player && !!(mo->eflags & MFE_VERTICALFLIP) != wasflip)
|
||||||
P_PlayerFlip(mo);
|
P_PlayerFlip(mo);
|
||||||
|
|
||||||
|
gravityadd = FixedMul(gravityadd, mo->scale);
|
||||||
|
|
||||||
return gravityadd;
|
return gravityadd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1416,8 +1415,11 @@ void P_CheckGravity(mobj_t *mo, boolean affect)
|
||||||
{
|
{
|
||||||
fixed_t gravityadd = P_GetMobjGravity(mo);
|
fixed_t gravityadd = P_GetMobjGravity(mo);
|
||||||
|
|
||||||
|
if (!mo->momz) // mobj at stop, no floor, so feel the push of gravity!
|
||||||
|
gravityadd <<= 1;
|
||||||
|
|
||||||
if (affect)
|
if (affect)
|
||||||
mo->momz += FixedMul(gravityadd, mo->scale);
|
mo->momz += gravityadd;
|
||||||
|
|
||||||
if (mo->type == MT_SKIM && mo->z + mo->momz <= mo->watertop && mo->z >= mo->watertop)
|
if (mo->type == MT_SKIM && mo->z + mo->momz <= mo->watertop && mo->z >= mo->watertop)
|
||||||
{
|
{
|
||||||
|
|
|
@ -812,7 +812,7 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope)
|
||||||
mom.y = thing->momy;
|
mom.y = thing->momy;
|
||||||
mom.z = thing->momz*2;
|
mom.z = thing->momz*2;
|
||||||
|
|
||||||
//CONS_Printf("langing on slope\n");
|
//CONS_Printf("Landing on slope\n");
|
||||||
|
|
||||||
// Reverse quantizing might could use its own function later
|
// Reverse quantizing might could use its own function later
|
||||||
slope->zangle = ANGLE_MAX-slope->zangle;
|
slope->zangle = ANGLE_MAX-slope->zangle;
|
||||||
|
@ -871,16 +871,10 @@ void P_ButteredSlope(mobj_t *mo)
|
||||||
thrust = FixedMul(thrust, FRACUNIT+P_AproxDistance(mo->momx, mo->momy)/16);
|
thrust = FixedMul(thrust, FRACUNIT+P_AproxDistance(mo->momx, mo->momy)/16);
|
||||||
// This makes it harder to zigzag up steep slopes, as well as allows greater top speed when rolling down
|
// This makes it harder to zigzag up steep slopes, as well as allows greater top speed when rolling down
|
||||||
|
|
||||||
// The strength of gravity depends on the global gravity base setting...
|
// Let's get the gravity strength for the object...
|
||||||
thrust = FixedMul(thrust, gravity);
|
|
||||||
|
|
||||||
// ...the sector-based gravity strength...
|
|
||||||
thrust = FixedMul(thrust, abs(P_GetMobjGravity(mo)));
|
thrust = FixedMul(thrust, abs(P_GetMobjGravity(mo)));
|
||||||
|
|
||||||
// ...and the scale of the object.
|
// ... and its friction against the ground for good measure.
|
||||||
thrust = FixedMul(thrust, mo->scale);
|
|
||||||
|
|
||||||
// Let's also multiply by friction for good measure.
|
|
||||||
thrust = FixedMul(thrust, mo->friction);
|
thrust = FixedMul(thrust, mo->friction);
|
||||||
|
|
||||||
P_Thrust(mo, mo->standingslope->xydirection, thrust);
|
P_Thrust(mo, mo->standingslope->xydirection, thrust);
|
||||||
|
|
Loading…
Reference in a new issue