From 34817d9776b13879cd4201f36d06e6b45e012c36 Mon Sep 17 00:00:00 2001
From: SSNTails <spaddlewit@gmail.com>
Date: Sun, 18 Feb 2024 22:38:34 -0500
Subject: [PATCH] Rollout rock handling with gravity boots

---
 src/p_map.c  |  2 +-
 src/p_mobj.c |  8 ++++++++
 src/p_user.c | 14 ++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/p_map.c b/src/p_map.c
index 7887c117de..b84fc7e279 100644
--- a/src/p_map.c
+++ b/src/p_map.c
@@ -1043,7 +1043,7 @@ static unsigned PIT_DoCheckThing(mobj_t *thing)
 		if ((thing->flags & MF_PUSHABLE) // not carrying a player
 			&& (tmthing->player->powers[pw_carry] == CR_NONE) // player is not already riding something
 			&& !(tmthing->player->powers[pw_ignorelatch] & (1<<15))
-			&& ((tmthing->eflags & MFE_VERTICALFLIP) == (thing->eflags & MFE_VERTICALFLIP))
+			&& ((tmthing->eflags & MFE_VERTICALFLIP) == (thing->eflags & MFE_VERTICALFLIP) || tmthing->player->powers[pw_gravityboots])
 			&& (P_MobjFlip(tmthing)*tmthing->momz <= 0)
 			&& ((!(tmthing->eflags & MFE_VERTICALFLIP) && abs(thing->z + thing->height - tmthing->z) < (thing->height>>2))
 				|| (tmthing->eflags & MFE_VERTICALFLIP && abs(tmthing->z + tmthing->height - thing->z) < (thing->height>>2))))
diff --git a/src/p_mobj.c b/src/p_mobj.c
index 1dd766fc38..eac8dc3d7b 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -1525,6 +1525,14 @@ fixed_t P_GetMobjGravity(mobj_t *mo)
 				case MT_WATERDROP:
 				case MT_CYBRAKDEMON:
 					gravityadd >>= 1;
+				case MT_ROLLOUTROCK:
+					// If a player has gravity boots and its riding a rollout rock, the rock should copy the player's gravity
+					if (mo->tracer && mo->tracer->player && mo->tracer->player->powers[pw_gravityboots])
+					{
+						gravityadd = -gravityadd;
+						mo->eflags ^= MFE_VERTICALFLIP;
+					}
+					break;
 				default:
 					break;
 			}
diff --git a/src/p_user.c b/src/p_user.c
index 25a60cf34b..9de234273f 100644
--- a/src/p_user.c
+++ b/src/p_user.c
@@ -1082,6 +1082,13 @@ void P_ResetPlayer(player_t *player)
 		if (player->mo->tracer && !P_MobjWasRemoved(player->mo->tracer))
 		{
 			player->mo->tracer->flags |= MF_PUSHABLE;
+
+			// goose the mom a little bit to trigger gravity to process for a tic
+			if (player->mo->eflags & MFE_VERTICALFLIP)
+				player->mo->tracer->momz -= 1;
+			else
+				player->mo->tracer->momz += 1;
+
 			P_SetTarget(&player->mo->tracer->tracer, NULL);
 		}
 		P_SetTarget(&player->mo->tracer, NULL);
@@ -4560,6 +4567,13 @@ void P_DoJump(player_t *player, boolean soundandstate, boolean allowflip)
 					player->mo->momz += player->mo->tracer->momz;
 				if (!P_IsObjectOnGround(player->mo->tracer))
 					P_SetObjectMomZ(player->mo->tracer, -9*FRACUNIT, true);
+
+				// goose the mom a little bit to trigger gravity to process for a tic
+				if (player->mo->eflags & MFE_VERTICALFLIP)
+					player->mo->tracer->momz -= 1;
+				else
+					player->mo->tracer->momz += 1;
+
 				player->mo->tracer->flags |= MF_PUSHABLE;
 				P_SetTarget(&player->mo->tracer->tracer, NULL);
 			}
-- 
GitLab