Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
Flying things can still get stuck in each other.
  • Loading branch information
MrAlaux committed Nov 26, 2023
1 parent 44f9b72 commit 3f39013
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 40 deletions.
65 changes: 26 additions & 39 deletions src/p_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -2465,9 +2465,9 @@ void P_MapEnd(void)

// [Nugget]: [DSDA] heretic /-------------------------------------------------

mobj_t *onmobj;
static mobj_t *onmobj;

boolean PIT_CheckOnmobjZ(mobj_t *thing)
static boolean PIT_CheckOnmobjZ(mobj_t *thing)
{
fixed_t blockdist;

Expand All @@ -2489,27 +2489,22 @@ boolean PIT_CheckOnmobjZ(mobj_t *thing)
if (thing->flags & MF_SOLID)
{ onmobj = thing; }

return (!(thing->flags & MF_SOLID));
return !((thing->flags & MF_SOLID && !(thing->flags & MF_NOCLIP))
&& (tmthing->flags & MF_SOLID || demo_compatibility));
}

void P_FakeZMovement(mobj_t *mo)
static void P_FakeZMovement(mobj_t *mo)
{
int dist;
int delta;

// Adjust height
mo->z += mo->momz;
if (mo->flags & MF_FLOAT && mo->target)

// Float down towards target if too close
if (!((mo->flags ^ MF_FLOAT) & (MF_FLOAT | MF_SKULLFLY | MF_INFLOAT)) && mo->target)
{
// Float down towards target if too close
if (!(mo->flags & MF_SKULLFLY) && !(mo->flags & MF_INFLOAT))
{
dist = P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y);
delta = (mo->target->z + (mo->height >> 1)) - mo->z;
const fixed_t delta = mo->target->z + (mo->height >> 1) - mo->z;

if (delta < 0 && dist < -(delta * 3)) { mo->z -= FLOATSPEED; }
else if (delta > 0 && dist < (delta * 3)) { mo->z += FLOATSPEED; }
}
if (P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y) < abs(delta) * 3)
{ mo->z += (delta < 0) ? -FLOATSPEED : FLOATSPEED; }
}

// Clip movement
Expand Down Expand Up @@ -2553,27 +2548,20 @@ mobj_t *P_CheckOnmobj(mobj_t *thing)
{
int xl, xh, yl, yh, bx, by;
subsector_t *newsubsec;
fixed_t x;
fixed_t y;
mobj_t oldmo;
mobj_t oldmo = *thing; // Save the old mobj before the fake movement

x = thing->x;
y = thing->y;
tmx = thing->x;
tmy = thing->y;
tmthing = thing;
tmflags = thing->flags;
oldmo = *thing; // Save the old mobj before the fake zmovement
P_FakeZMovement(tmthing);

tmx = x;
tmy = y;

tmbbox[BOXTOP] = y + tmthing->radius;
tmbbox[BOXBOTTOM] = y - tmthing->radius;
tmbbox[BOXRIGHT] = x + tmthing->radius;
tmbbox[BOXLEFT] = x - tmthing->radius;
tmbbox[BOXTOP] = tmy + tmthing->radius;
tmbbox[BOXBOTTOM] = tmy - tmthing->radius;
tmbbox[BOXRIGHT] = tmx + tmthing->radius;
tmbbox[BOXLEFT] = tmx - tmthing->radius;

newsubsec = R_PointInSubsector(x, y);
ceilingline = NULL;
newsubsec = R_PointInSubsector(tmx, tmy);
floorline = blockline = ceilingline = NULL;

// The base floor / ceiling is from the subsector that contains the
// point. Any contacted lines the step closer together will adjust them
Expand All @@ -2583,19 +2571,18 @@ mobj_t *P_CheckOnmobj(mobj_t *thing)
validcount++;
numspechit = 0;

if (tmflags & MF_NOCLIP) {
*tmthing = oldmo;
return NULL;
}
if (tmflags & MF_NOCLIP) { return NULL; }

// Check things first, possibly picking things up
// the bounding box is extended by MAXRADIUS because mobj_ts are grouped
// into mapblocks based on their origin point, and can overlap into adjacent
// blocks by up to MAXRADIUS units
xl = (tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS) >> MAPBLOCKSHIFT;
xh = (tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS) >> MAPBLOCKSHIFT;
xl = (tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS) >> MAPBLOCKSHIFT;
xh = (tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS) >> MAPBLOCKSHIFT;
yl = (tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS) >> MAPBLOCKSHIFT;
yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS) >> MAPBLOCKSHIFT;
yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS) >> MAPBLOCKSHIFT;

P_FakeZMovement(tmthing);

for (bx = xl; bx <= xh; bx++)
for (by = yl; by <= yh; by++)
Expand Down
2 changes: 1 addition & 1 deletion src/p_mobj.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ void P_MobjThinker (mobj_t* mobj)

if (mobj->z != mobj->floorz || mobj->momz)
{
// [Nugget]
// [Nugget]: [DSDA]
if (casual_play && over_under && (mobj->flags & MF_SOLID))
{
mobj_t *onmo;
Expand Down

0 comments on commit 3f39013

Please sign in to comment.