From 34817d9776b13879cd4201f36d06e6b45e012c36 Mon Sep 17 00:00:00 2001 From: SSNTails Date: Sun, 18 Feb 2024 22:38:34 -0500 Subject: [PATCH 1/6] 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 7887c117d..b84fc7e27 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 1dd766fc3..eac8dc3d7 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 25a60cf34..9de234273 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); } From 372cbbc544e27b3689a0df8dbeddf5539dde83c3 Mon Sep 17 00:00:00 2001 From: SSNTails Date: Mon, 19 Feb 2024 08:08:12 -0500 Subject: [PATCH 2/6] missing 'break' --- src/p_mobj.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index eac8dc3d7..cdd71ccc4 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1525,6 +1525,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo) case MT_WATERDROP: case MT_CYBRAKDEMON: gravityadd >>= 1; + break; 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]) From 34cf7c1a018cd8fbf73c0686513c9f3a89c41b8c Mon Sep 17 00:00:00 2001 From: SSNTails Date: Wed, 13 Mar 2024 18:08:07 -0400 Subject: [PATCH 3/6] I don't think flipping the flag here is even needed... --- src/p_mobj.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index cdd71ccc4..27282fe52 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1529,10 +1529,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo) 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; From a58d9036bc48736d40c69fe9401747dbf083c90d Mon Sep 17 00:00:00 2001 From: SSNTails Date: Fri, 15 Mar 2024 14:28:44 -0400 Subject: [PATCH 4/6] Restore MF2_OBJECTFLIP/MFE_VERTICALFLIP on rollout rock disconnect --- src/p_map.c | 4 ++++ src/p_user.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/p_map.c b/src/p_map.c index b84fc7e27..088d55208 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1057,6 +1057,10 @@ static unsigned PIT_DoCheckThing(mobj_t *thing) P_SetTarget(&tmthing->tracer, thing); if (!P_IsObjectOnGround(thing)) thing->momz += tmthing->momz; + + thing->extravalue1 = thing->flags2; + thing->extravalue2 = thing->eflags; + return CHECKTHING_COLLIDE; } } diff --git a/src/p_user.c b/src/p_user.c index 9de234273..417154b19 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1089,6 +1089,17 @@ void P_ResetPlayer(player_t *player) else player->mo->tracer->momz += 1; + // Restore MF2_OBJECTFLIP / MFE_VERTICALFLIP + if (player->mo->tracer->extravalue1 & MF2_OBJECTFLIP) + player->mo->tracer->flags2 |= MF2_OBJECTFLIP; + else + player->mo->tracer->flags2 &= ~MF2_OBJECTFLIP; + + if (player->mo->tracer->extravalue2 & MFE_VERTICALFLIP) + player->mo->tracer->eflags |= MFE_VERTICALFLIP; + else + player->mo->tracer->eflags &= ~MFE_VERTICALFLIP; + P_SetTarget(&player->mo->tracer->tracer, NULL); } P_SetTarget(&player->mo->tracer, NULL); @@ -4574,6 +4585,17 @@ void P_DoJump(player_t *player, boolean soundandstate, boolean allowflip) else player->mo->tracer->momz += 1; + // Restore MF2_OBJECTFLIP / MFE_VERTICALFLIP + if (player->mo->tracer->extravalue1 & MF2_OBJECTFLIP) + player->mo->tracer->flags2 |= MF2_OBJECTFLIP; + else + player->mo->tracer->flags2 &= ~MF2_OBJECTFLIP; + + if (player->mo->tracer->extravalue2 & MFE_VERTICALFLIP) + player->mo->tracer->eflags |= MFE_VERTICALFLIP; + else + player->mo->tracer->eflags &= ~MFE_VERTICALFLIP; + player->mo->tracer->flags |= MF_PUSHABLE; P_SetTarget(&player->mo->tracer->tracer, NULL); } From 2181dadb4cead6b3dbb8f63ada6446ee72202d90 Mon Sep 17 00:00:00 2001 From: SSNTails Date: Fri, 15 Mar 2024 16:39:37 -0400 Subject: [PATCH 5/6] Checking MFE_VERTICALFLIP matching is actually redundant.. --- src/p_map.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index 088d55208..57883b448 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1043,7 +1043,6 @@ 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->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)))) From b4ad0544225bef1c5b872af3e1b76991fd4d2a8b Mon Sep 17 00:00:00 2001 From: SSNTails Date: Sat, 16 Mar 2024 10:28:49 -0400 Subject: [PATCH 6/6] Zwip Zwap Zapony's suggestions --- src/p_enemy.c | 10 ++++++++-- src/p_map.c | 3 --- src/p_mobj.c | 5 ----- src/p_user.c | 26 ++------------------------ 4 files changed, 10 insertions(+), 34 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index a386d8ee9..6a52b6402 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -14799,12 +14799,18 @@ void A_RolloutRock(mobj_t *actor) if (!actor->tracer || P_MobjWasRemoved(actor->tracer) || !actor->tracer->health) actor->flags |= MF_PUSHABLE; + else if (actor->tracer->eflags & MFE_VERTICALFLIP) + { + actor->flags2 |= MF2_OBJECTFLIP; + actor->eflags |= MFE_VERTICALFLIP; + } else { - actor->flags2 = (actor->flags2 & ~MF2_OBJECTFLIP) | (actor->tracer->flags2 & MF2_OBJECTFLIP); - actor->eflags = (actor->eflags & ~MFE_VERTICALFLIP) | (actor->tracer->eflags & MFE_VERTICALFLIP); + actor->flags2 &= ~MF2_OBJECTFLIP; + actor->eflags &= ~MFE_VERTICALFLIP; } + actor->friction = FRACUNIT; // turns out riding on solids sucks, so let's just make it easier on ourselves if (actor->eflags & MFE_JUSTHITFLOOR) diff --git a/src/p_map.c b/src/p_map.c index 57883b448..aa8ef17ec 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1057,9 +1057,6 @@ static unsigned PIT_DoCheckThing(mobj_t *thing) if (!P_IsObjectOnGround(thing)) thing->momz += tmthing->momz; - thing->extravalue1 = thing->flags2; - thing->extravalue2 = thing->eflags; - return CHECKTHING_COLLIDE; } } diff --git a/src/p_mobj.c b/src/p_mobj.c index 27282fe52..4c08c81da 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1526,11 +1526,6 @@ fixed_t P_GetMobjGravity(mobj_t *mo) case MT_CYBRAKDEMON: gravityadd >>= 1; break; - 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; - break; default: break; } diff --git a/src/p_user.c b/src/p_user.c index 417154b19..707d420fc 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1084,22 +1084,11 @@ void P_ResetPlayer(player_t *player) 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) + if (player->mo->tracer->eflags & MFE_VERTICALFLIP) player->mo->tracer->momz -= 1; else player->mo->tracer->momz += 1; - // Restore MF2_OBJECTFLIP / MFE_VERTICALFLIP - if (player->mo->tracer->extravalue1 & MF2_OBJECTFLIP) - player->mo->tracer->flags2 |= MF2_OBJECTFLIP; - else - player->mo->tracer->flags2 &= ~MF2_OBJECTFLIP; - - if (player->mo->tracer->extravalue2 & MFE_VERTICALFLIP) - player->mo->tracer->eflags |= MFE_VERTICALFLIP; - else - player->mo->tracer->eflags &= ~MFE_VERTICALFLIP; - P_SetTarget(&player->mo->tracer->tracer, NULL); } P_SetTarget(&player->mo->tracer, NULL); @@ -4580,22 +4569,11 @@ void P_DoJump(player_t *player, boolean soundandstate, boolean allowflip) 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) + if (player->mo->tracer->eflags & MFE_VERTICALFLIP) player->mo->tracer->momz -= 1; else player->mo->tracer->momz += 1; - // Restore MF2_OBJECTFLIP / MFE_VERTICALFLIP - if (player->mo->tracer->extravalue1 & MF2_OBJECTFLIP) - player->mo->tracer->flags2 |= MF2_OBJECTFLIP; - else - player->mo->tracer->flags2 &= ~MF2_OBJECTFLIP; - - if (player->mo->tracer->extravalue2 & MFE_VERTICALFLIP) - player->mo->tracer->eflags |= MFE_VERTICALFLIP; - else - player->mo->tracer->eflags &= ~MFE_VERTICALFLIP; - player->mo->tracer->flags |= MF_PUSHABLE; P_SetTarget(&player->mo->tracer->tracer, NULL); }