Skip to content

Commit

Permalink
Fix MBF21 ripper weapons causing too much damage
Browse files Browse the repository at this point in the history
From Woof
  • Loading branch information
bradharding committed Nov 6, 2024
1 parent 2b4f725 commit 1aa8202
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/p_enemy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ static bool P_HealCorpse(mobj_t *actor, int radius, statenum_t healstate, sfxnum
for (int bx = xl; bx <= xh; bx++)
for (int by = yl; by <= yh; by++)
// Call PIT_VileCheck() to check whether object is a corpse that can be raised.
if (!P_BlockThingsIterator(bx, by, &PIT_VileCheck))
if (!P_BlockThingsIterator(bx, by, &PIT_VileCheck, true))
{
// got one!
mobj_t *prevtarget = actor->target;
Expand Down
2 changes: 1 addition & 1 deletion src/p_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ extern fixed_t lowfloor;
void P_LineOpening(const line_t *line);

bool P_BlockLinesIterator(const int x, const int y, bool func(line_t *));
bool P_BlockThingsIterator(const int x, const int y, bool func(mobj_t *));
bool P_BlockThingsIterator(const int x, const int y, bool func(mobj_t *), bool blockmapfix);

#define PT_ADDLINES 1
#define PT_ADDTHINGS 2
Expand Down
9 changes: 5 additions & 4 deletions src/p_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ bool P_TeleportMove(mobj_t *thing, const fixed_t x, const fixed_t y, const fixed

for (int bx = xl; bx <= xh; bx++)
for (int by = yl; by <= yh; by++)
if (!P_BlockThingsIterator(bx, by, &PIT_StompThing))
if (!P_BlockThingsIterator(bx, by, &PIT_StompThing, true))
return false;

// the move is ok,
Expand Down Expand Up @@ -847,7 +847,8 @@ bool P_CheckPosition(mobj_t *thing, const fixed_t x, const fixed_t y)

for (int bx = xl; bx <= xh; bx++)
for (int by = yl; by <= yh; by++)
if (!P_BlockThingsIterator(bx, by, &PIT_CheckThing))
if (!P_BlockThingsIterator(bx, by, &PIT_CheckThing,
!(tmthing->mbf21flags & MF_MBF21_RIP)))
return false;

// check lines
Expand Down Expand Up @@ -979,7 +980,7 @@ mobj_t *P_CheckOnMobj(mobj_t *thing)

for (int bx = xl; bx <= xh; bx++)
for (int by = yl; by <= yh; by++)
if (!P_BlockThingsIterator(bx, by, &PIT_CheckOnMobjZ))
if (!P_BlockThingsIterator(bx, by, &PIT_CheckOnMobjZ, true))
{
*tmthing = oldmo;
return onmobj;
Expand Down Expand Up @@ -2121,7 +2122,7 @@ void P_RadiusAttack(mobj_t *spot, mobj_t *source, const int damage, const int di

for (int y = yl; y <= yh; y++)
for (int x = xl; x <= xh; x++)
P_BlockThingsIterator(x, y, &PIT_RadiusAttack);
P_BlockThingsIterator(x, y, &PIT_RadiusAttack, false);
}

//
Expand Down
95 changes: 47 additions & 48 deletions src/p_maputl.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ bool P_BlockLinesIterator(const int x, const int y, bool func(line_t *))
//
// P_BlockThingsIterator
//
bool P_BlockThingsIterator(const int x, const int y, bool func(mobj_t *))
bool P_BlockThingsIterator(const int x, const int y, bool func(mobj_t *), bool blockmapfix)
{
if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight)
return true;
Expand All @@ -373,66 +373,65 @@ bool P_BlockThingsIterator(const int x, const int y, bool func(mobj_t *))
if (!func(mobj))
return false;

if (func == &PIT_RadiusAttack)
return true;

// Blockmap bug fix by Terry Hearst

// (-1, -1)
if (x > 0 && y > 0)
for (mobj_t *mobj = blocklinks[(y - 1) * bmapwidth + x - 1]; mobj; mobj = mobj->bnext)
if (x == (mobj->x + mobj->radius - bmaporgx) >> MAPBLOCKSHIFT
&& y == (mobj->y + mobj->radius - bmaporgy) >> MAPBLOCKSHIFT
&& !func(mobj))
if (blockmapfix)
{
// (-1, -1)
if (x > 0 && y > 0)
for (mobj_t *mobj = blocklinks[(y - 1) * bmapwidth + x - 1]; mobj; mobj = mobj->bnext)
if (x == (mobj->x + mobj->radius - bmaporgx) >> MAPBLOCKSHIFT
&& y == (mobj->y + mobj->radius - bmaporgy) >> MAPBLOCKSHIFT
&& !func(mobj))
return false;

// (0, -1)
if (y > 0)
for (mobj_t *mobj = blocklinks[(y - 1) * bmapwidth + x]; mobj; mobj = mobj->bnext)
if (y == (mobj->y + mobj->radius - bmaporgy) >> MAPBLOCKSHIFT && !func(mobj))
// (0, -1)
if (y > 0)
for (mobj_t *mobj = blocklinks[(y - 1) * bmapwidth + x]; mobj; mobj = mobj->bnext)
if (y == (mobj->y + mobj->radius - bmaporgy) >> MAPBLOCKSHIFT && !func(mobj))
return false;

// (1, -1)
if (x < bmapwidth - 1 && y > 0)
for (mobj_t *mobj = blocklinks[(y - 1) * bmapwidth + x + 1]; mobj; mobj = mobj->bnext)
if (x == (mobj->x - mobj->radius - bmaporgx) >> MAPBLOCKSHIFT
&& y == (mobj->y + mobj->radius - bmaporgy) >> MAPBLOCKSHIFT
&& !func(mobj))
// (1, -1)
if (x < bmapwidth - 1 && y > 0)
for (mobj_t *mobj = blocklinks[(y - 1) * bmapwidth + x + 1]; mobj; mobj = mobj->bnext)
if (x == (mobj->x - mobj->radius - bmaporgx) >> MAPBLOCKSHIFT
&& y == (mobj->y + mobj->radius - bmaporgy) >> MAPBLOCKSHIFT
&& !func(mobj))
return false;

// (1, 0)
if (x < bmapwidth - 1)
for (mobj_t *mobj = blocklinks[y * bmapwidth + x + 1]; mobj; mobj = mobj->bnext)
if (x == (mobj->x - mobj->radius - bmaporgx) >> MAPBLOCKSHIFT && !func(mobj))
// (1, 0)
if (x < bmapwidth - 1)
for (mobj_t *mobj = blocklinks[y * bmapwidth + x + 1]; mobj; mobj = mobj->bnext)
if (x == (mobj->x - mobj->radius - bmaporgx) >> MAPBLOCKSHIFT && !func(mobj))
return false;

// (1, 1)
if (x < bmapwidth - 1 && y < bmapheight - 1)
for (mobj_t *mobj = blocklinks[(y + 1) * bmapwidth + x + 1]; mobj; mobj = mobj->bnext)
if (x == (mobj->x - mobj->radius - bmaporgx) >> MAPBLOCKSHIFT
&& y == (mobj->y - mobj->radius - bmaporgy) >> MAPBLOCKSHIFT
&& !func(mobj))
// (1, 1)
if (x < bmapwidth - 1 && y < bmapheight - 1)
for (mobj_t *mobj = blocklinks[(y + 1) * bmapwidth + x + 1]; mobj; mobj = mobj->bnext)
if (x == (mobj->x - mobj->radius - bmaporgx) >> MAPBLOCKSHIFT
&& y == (mobj->y - mobj->radius - bmaporgy) >> MAPBLOCKSHIFT
&& !func(mobj))
return false;

// (0, 1)
if (y < bmapheight - 1)
for (mobj_t *mobj = blocklinks[(y + 1) * bmapwidth + x]; mobj; mobj = mobj->bnext)
if (y == (mobj->y - mobj->radius - bmaporgy) >> MAPBLOCKSHIFT && !func(mobj))
// (0, 1)
if (y < bmapheight - 1)
for (mobj_t *mobj = blocklinks[(y + 1) * bmapwidth + x]; mobj; mobj = mobj->bnext)
if (y == (mobj->y - mobj->radius - bmaporgy) >> MAPBLOCKSHIFT && !func(mobj))
return false;

// (-1, 1)
if (x > 0 && y < bmapheight - 1)
for (mobj_t *mobj = blocklinks[(y + 1) * bmapwidth + x - 1]; mobj; mobj = mobj->bnext)
if (x == (mobj->x + mobj->radius - bmaporgx) >> MAPBLOCKSHIFT
&& y == (mobj->y - mobj->radius - bmaporgy) >> MAPBLOCKSHIFT
&& !func(mobj))
// (-1, 1)
if (x > 0 && y < bmapheight - 1)
for (mobj_t *mobj = blocklinks[(y + 1) * bmapwidth + x - 1]; mobj; mobj = mobj->bnext)
if (x == (mobj->x + mobj->radius - bmaporgx) >> MAPBLOCKSHIFT
&& y == (mobj->y - mobj->radius - bmaporgy) >> MAPBLOCKSHIFT
&& !func(mobj))
return false;

// (-1, 0)
if (x > 0)
for (mobj_t *mobj = blocklinks[y * bmapwidth + x - 1]; mobj; mobj = mobj->bnext)
if (x == (mobj->x + mobj->radius - bmaporgx) >> MAPBLOCKSHIFT && !func(mobj))
// (-1, 0)
if (x > 0)
for (mobj_t *mobj = blocklinks[y * bmapwidth + x - 1]; mobj; mobj = mobj->bnext)
if (x == (mobj->x + mobj->radius - bmaporgx) >> MAPBLOCKSHIFT && !func(mobj))
return false;
}

return true;
}
Expand Down Expand Up @@ -732,7 +731,7 @@ bool P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const int fl
return false; // early out

if (flags & PT_ADDTHINGS)
if (!P_BlockThingsIterator(mapx, mapy, &PIT_AddThingIntercepts))
if (!P_BlockThingsIterator(mapx, mapy, &PIT_AddThingIntercepts, true))
return false; // early out

if (mapx == xt2 && mapy == yt2)
Expand Down Expand Up @@ -772,8 +771,8 @@ bool P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const int fl

if (flags & PT_ADDTHINGS)
{
P_BlockThingsIterator(mapx + mapxstep, mapy, &PIT_AddThingIntercepts);
P_BlockThingsIterator(mapx, mapy + mapystep, &PIT_AddThingIntercepts);
P_BlockThingsIterator(mapx + mapxstep, mapy, &PIT_AddThingIntercepts, true);
P_BlockThingsIterator(mapx, mapy + mapystep, &PIT_AddThingIntercepts, true);
}

xintercept += xstep;
Expand Down
2 changes: 1 addition & 1 deletion src/p_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -3326,7 +3326,7 @@ void T_Pusher(pusher_t *pusher)

for (int bx = xl; bx <= xh; bx++)
for (int by = yl; by <= yh; by++)
P_BlockThingsIterator(bx, by, &PIT_PushThing);
P_BlockThingsIterator(bx, by, &PIT_PushThing, true);

return;
}
Expand Down

0 comments on commit 1aa8202

Please sign in to comment.