add function to check if mobj should sloperoll

makes things slightly cleaner and we can apply sloperoll dist to everything
should probably save some time esp with the trailing item z calc
+ P_MobjPitchAndRoll should be able to be called always since it also does stuff seperate from sloperoll
This commit is contained in:
Alug committed 2025-03-17 15:20:49 +01:00
1 parent de2a73149b
commit 2aca4dc0c7
3 files changed
+36 -39

No files matched your search

+32 -20
View File
@@ -3579,30 +3579,47 @@ static void K_QuiteSaltyHop(player_t *p)
}
}
// checks if slope rotation should be applied
boolean K_ShouldSlopeRoll(mobj_t *mobj)
{
if (!cv_sloperoll.value || (!mobj->player && cv_sloperoll.value != 2)) // not a player and sloperoll not set to "Everything"
return false;
const boolean usedistance = cv_sloperolldist.value && !splitscreen;
// always roll from any distance
if (!usedistance)
return true;
const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale;
const fixed_t m_dist = (R_QuickCamDist(mobj->x, mobj->y)*FRACUNIT);
return (m_dist <= rolldist);
}
#define SLOPEROLL_DIV 3
void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope)
{
// save one P_MobjWasRemoved check for dedis lel
if (rendermode == render_none)
return;
if (P_MobjWasRemoved(mo))
return;
I_Assert(mo->subsector != NULL);
I_Assert(mo->subsector->sector != NULL);
if (!K_ShouldSlopeRoll(mo))
{
mo->pitch_sprite = mo->roll_sprite = 0;
mo->sloperoll = mo->slopepitch = 0;
return;
}
// lifted from hw_md2
if (slope)
{
const boolean usedistance = cv_sloperolldist.value && !splitscreen;
const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale;
const fixed_t m_dist = usedistance ? (R_QuickCamDist(mo->x, mo->y)*FRACUNIT) : 0;
const boolean usepitchnroll = (!usedistance || (m_dist <= rolldist));
if (!usepitchnroll)
{
mo->pitch_sprite = mo->roll_sprite = 0;
mo->sloperoll = mo->slopepitch = 0;
return;
}
angle_t an;
const boolean flip = (mo->eflags & MFE_VERTICALFLIP);
fixed_t tempz = slope->normal.z;
@@ -4048,7 +4065,7 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map
if (mo->eflags & MFE_UNDERWATER)
mo->momz = (117 * mo->momz) / 200;
if (cv_sloperoll.value == 2 && cv_bananthrowroll.value && mapthing == MT_BANANA)
if (cv_bananthrowroll.value && (mapthing == MT_BANANA) && K_ShouldSlopeRoll(mo))
{
//mo->angle = FixedAngle(M_RandomRange(-180, 180) << FRACBITS);
if (cv_bananthrowroll.value == 1)
@@ -5130,7 +5147,7 @@ static void K_MoveHeldObjects(player_t *player)
if (R_PointToDist2(cur->x, cur->y, targx, targy) > 768*FRACUNIT)
P_MoveOrigin(cur, targx, targy, cur->z);
if (cv_sloperoll.value == 2 && P_IsObjectOnGround(cur))
if (P_IsObjectOnGround(cur) && K_ShouldSlopeRoll(cur))
{
K_CalculateBananaSlope(cur, cur->x, cur->y, cur->z,
cur->radius, cur->height, (cur->eflags & MFE_VERTICALFLIP), false);
@@ -7197,15 +7214,10 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
K_StretchPlayerGravity(player);
if (cv_sloperoll.value && !player->mo->salty_jump) // seeing a character rotate mid-hop looks really janky
if (!player->mo->salty_jump) // seeing a character rotate mid-hop looks really janky
{
K_RollMobjBySlopes(player->mo, player->mo->standingslope);
}
else
{
player->mo->sloperoll = 0;
player->mo->slopepitch = 0;
}
// Quick Turning
// You can't turn your kart when you're not moving.
+1
View File
@@ -63,6 +63,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor);
void K_StealBumper(player_t *player, player_t *victim, boolean force);
void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, angle_t rotangle, boolean spawncenter, boolean ghostit, mobj_t *source);
void K_SpawnMineExplosion(mobj_t *source, UINT8 color);
boolean K_ShouldSlopeRoll(mobj_t *mobj);
void K_RollMobjBySlopes(mobj_t *mo, pslope_t *slope);
void K_SpawnBoostTrail(player_t *player);
void K_SpawnSparkleTrail(mobj_t *mo);
+3 -19
View File
@@ -6109,20 +6109,6 @@ static void P_KoopaThinker(mobj_t *koopa)
//
void P_RollPitchMobj(mobj_t* mobj)
{
// we dont need this in dedi do we?
if (rendermode == render_none)
return;
if (P_MobjWasRemoved(mobj))
return;
if (cv_sloperoll.value != 2)
{
mobj->sloperoll = 0;
mobj->slopepitch = 0;
return;
}
K_RollMobjBySlopes(mobj, mobj->standingslope);
}
@@ -6134,9 +6120,6 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj)
angle_t camang = 0;
angle_t return_angle = 0;
if (!cv_sloperoll.value)
return 0;
if (P_MobjWasRemoved(mobj))
return 0;
@@ -6376,6 +6359,7 @@ void P_MobjThinker(mobj_t *mobj)
return;
}
// dont need to extra check with K_ShouldSlopeRoll
if (cv_sloperoll.value == 2 && mobj->state == &states[S_SHADOW])
{
mobj->slopepitch = mobj->target->slopepitch;
@@ -7171,7 +7155,7 @@ void P_MobjThinker(mobj_t *mobj)
break;
//{ SRB2kart Items - Death States
case MT_BANANA:
if (cv_sloperoll.value == 2 && cv_bananthrowroll.value)
if (cv_bananthrowroll.value && K_ShouldSlopeRoll(mobj))
{
angle_t spin = FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h);
//mobj->angle -= spin;
@@ -7930,7 +7914,7 @@ void P_MobjThinker(mobj_t *mobj)
case MT_BANANA:
case MT_EGGMANITEM:
//P_MobjCheckWaterVisual(mobj);
if (cv_sloperoll.value == 2 && cv_bananthrowroll.value && !P_IsObjectOnGround(mobj))
if (cv_bananthrowroll.value && !P_IsObjectOnGround(mobj) && K_ShouldSlopeRoll(mobj))
{
// tilt n tumble
angle_t spin = FixedMul(FixedDiv(mobj->momz, 8 * mobj->scale), ANGLE_67h);