From 7b0e98ef35ce756060dba5e23f41591a0da09fb0 Mon Sep 17 00:00:00 2001
From: RedEnchilada <redenchilada@derpymail.com>
Date: Wed, 20 May 2015 13:18:41 -0500
Subject: [PATCH] Change sliding physics and standing/rolling rules on slopes

---
 src/p_slopes.c | 25 +++++++++++++++++++++++--
 src/p_user.c   | 18 +++++++++++++++---
 2 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/src/p_slopes.c b/src/p_slopes.c
index 60bd1087b1..c5798707e0 100644
--- a/src/p_slopes.c
+++ b/src/p_slopes.c
@@ -868,11 +868,32 @@ void P_ButteredSlope(mobj_t *mo)
 	if (!mo->standingslope)
 		return;
 
-	if (abs(mo->standingslope->zdelta) < FRACUNIT/3)
-		return; // Don't apply physics to slopes that aren't steep enough
+	if (mo->player) {
+		if (abs(mo->standingslope->zdelta) < FRACUNIT/4 && !(mo->player->pflags & PF_SPINNING))
+			return; // Don't slide on non-steep slopes unless spinning
+
+		if (abs(mo->standingslope->zdelta) < FRACUNIT/2 && !(mo->player->rmomx || mo->player->rmomy))
+			return; // Allow the player to stand still on slopes below a certain steepness
+	}
 
 	thrust = FINESINE(mo->standingslope->zangle>>ANGLETOFINESHIFT) * 3 / 2 * (mo->eflags & MFE_VERTICALFLIP ? 1 : -1);
 
+	if (mo->player && (mo->player->pflags & PF_SPINNING)) {
+		fixed_t mult = 0;
+		if (mo->momx || mo->momy) {
+			angle_t angle = R_PointToAngle2(0, 0, mo->momx, mo->momy) - mo->standingslope->xydirection;
+
+			if (P_MobjFlip(mo) * mo->standingslope->zdelta < 0)
+				angle ^= ANGLE_180;
+
+			mult = FINECOSINE(angle >> ANGLETOFINESHIFT);
+		}
+
+		CONS_Printf("%d\n", mult);
+
+		thrust = FixedMul(thrust, FRACUNIT*2/3 + mult/8);
+	}
+
 	if (mo->momx || mo->momy) // Slightly increase thrust based on the object's speed
 		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
diff --git a/src/p_user.c b/src/p_user.c
index 0f2bd19b98..c0ff792cce 100644
--- a/src/p_user.c
+++ b/src/p_user.c
@@ -3758,7 +3758,11 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd)
 	if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_SLIDING) && !player->exiting
 		&& !P_PlayerInPain(player)) // subsequent revs
 	{
-		if ((cmd->buttons & BT_USE) && player->speed < FixedMul(5<<FRACBITS, player->mo->scale) && !player->mo->momz && onground && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING))
+		if ((cmd->buttons & BT_USE) && player->speed < FixedMul(5<<FRACBITS, player->mo->scale) && !player->mo->momz && onground && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING)
+#ifdef ESLOPE
+			&& (!player->mo->standingslope || abs(player->mo->standingslope->zdelta) < FRACUNIT/2)
+#endif
+			)
 		{
 			player->mo->momx = player->cmomx;
 			player->mo->momy = player->cmomy;
@@ -3787,7 +3791,11 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd)
 		// down the spin button and not spinning.
 		// AKA Just go into a spin on the ground, you idiot. ;)
 		else if ((cmd->buttons & BT_USE || ((twodlevel || (player->mo->flags2 & MF2_TWOD)) && cmd->forwardmove < -20))
-			&& !player->climbing && !player->mo->momz && onground && player->speed > FixedMul(5<<FRACBITS, player->mo->scale) && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING))
+			&& !player->climbing && !player->mo->momz && onground && (player->speed > FixedMul(5<<FRACBITS, player->mo->scale)
+#ifdef ESLOPE
+			|| (player->mo->standingslope && abs(player->mo->standingslope->zdelta) >= FRACUNIT/2)
+#endif
+			) && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING))
 		{
 			player->pflags |= PF_SPINNING;
 			P_SetPlayerMobjState(player->mo, S_PLAY_ATK1);
@@ -3799,7 +3807,11 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd)
 
 	// Rolling normally
 	if (onground && player->pflags & PF_SPINNING && !(player->pflags & PF_STARTDASH)
-		&& player->speed < FixedMul(5*FRACUNIT,player->mo->scale))
+		&& player->speed < FixedMul(5*FRACUNIT,player->mo->scale)
+#ifdef ESLOPE
+			&& (!player->mo->standingslope || abs(player->mo->standingslope->zdelta) < FRACUNIT/2)
+#endif
+			)
 	{
 		if (GETSECSPECIAL(player->mo->subsector->sector->special, 4) == 7 || (player->mo->ceilingz - player->mo->floorz < P_GetPlayerHeight(player)))
 			P_InstaThrust(player->mo, player->mo->angle, FixedMul(10*FRACUNIT, player->mo->scale));
-- 
GitLab