From 357baeaa604573b4cf34fd50f3444c286f20fd91 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Sat, 5 Oct 2019 22:20:48 +0200 Subject: [PATCH] Added gravflip support to lavafall, Pyre Fly and Pterabyte --- src/p_enemy.c | 3 ++- src/p_mobj.c | 12 +++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 594d8f978..e6ca4f2f1 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -13820,7 +13820,8 @@ void A_FallingLavaCheck(mobj_t *actor) { actor->flags = MF_NOGRAVITY|MF_NOCLIPTHING; actor->momz = 0; - actor->z = actor->watertop; + if (actor->eflags & MFE_TOUCHWATER) + actor->z = (actor->eflags & MFE_VERTICALFLIP) ? actor->waterbottom : actor->watertop; P_SetMobjState(actor, actor->info->deathstate); } } diff --git a/src/p_mobj.c b/src/p_mobj.c index f4fe43ecf..5bf4323c3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9096,13 +9096,11 @@ void P_MobjThinker(mobj_t *mobj) if (hdist < 1000*FRACUNIT) { - fixed_t dist = P_AproxDistance(hdist, mobj->target->z - mobj->z); + //Aim for player z position. If too close to floor/ceiling, aim just above/below them. + fixed_t destz = min(max(mobj->target->z, mobj->target->floorz + 70*FRACUNIT), mobj->target->ceilingz - 80*FRACUNIT - mobj->height); + fixed_t dist = P_AproxDistance(hdist, destz - mobj->z); P_InstaThrust(mobj, R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y), 2*FRACUNIT); - //aim for player z position; if too close to floor, aim just above them - if (mobj->z - mobj->floorz >= 80*FRACUNIT) - mobj->momz = FixedMul(FixedDiv(mobj->target->z - mobj->z, dist), 2*FRACUNIT); - else - mobj->momz = FixedMul(FixedDiv((mobj->target->z + 70*FRACUNIT) - mobj->z, dist), 2*FRACUNIT); + mobj->momz = FixedMul(FixedDiv(destz - mobj->z, dist), 2*FRACUNIT); } else { @@ -9155,7 +9153,7 @@ void P_MobjThinker(mobj_t *mobj) } vdist = mobj->z - mobj->target->z - mobj->target->height; - if (vdist <= 0) + if (P_MobjFlip(mobj)*vdist <= 0) { P_SetTarget(&mobj->target, NULL); break;