0
0
Fork 0
mirror of https://git.do.srb2.org/STJr/SRB2.git synced 2025-03-22 10:52:23 +00:00

Port katsy's bouncy FOF cleanup

This commit is contained in:
MascaraSnake 2021-12-03 18:48:16 +01:00
parent f26f41e03a
commit 6dc49042de
9 changed files with 39 additions and 95 deletions

View file

@ -776,7 +776,6 @@ linedeftypes
{
title = "Make FOF Bouncy";
prefix = "(76)";
flags16384text = "[14] Dampen";
}
}

View file

@ -1733,12 +1733,6 @@ udmf
{
title = "Bounce strength";
}
arg2
{
title = "Dampen?";
type = 11;
enum = "noyes";
}
}
}

View file

@ -5230,12 +5230,10 @@ struct int_const_s const INT_CONST[] = {
{"FF_BOUNCY",FF_BOUNCY}, ///< Bounces players
{"FF_SPLAT",FF_SPLAT}, ///< Use splat flat renderer (treat cyan pixels as invisible)
// FOF special flags
{"FS_PUSHABLES",FS_PUSHABLES},
{"FS_EXECUTOR",FS_EXECUTOR},
{"FS_ONLYBOTTOM",FS_ONLYBOTTOM},
{"FS_BUSTMASK",FS_BUSTMASK},
{"FS_DAMPEN",FS_DAMPEN},
// FOF bustable flags
{"FB_PUSHABLES",FB_PUSHABLES},
{"FB_EXECUTOR",FB_EXECUTOR},
{"FB_ONLYBOTTOM",FB_ONLYBOTTOM},
// Bustable FOF type
{"BT_TOUCH",BT_TOUCH},

View file

@ -196,7 +196,7 @@ enum ffloor_e {
ffloor_next,
ffloor_prev,
ffloor_alpha,
ffloor_specialflags,
ffloor_bustflags,
ffloor_busttype,
ffloor_busttag,
ffloor_sinkspeed,
@ -220,7 +220,7 @@ static const char *const ffloor_opt[] = {
"next",
"prev",
"alpha",
"specialflags",
"bustflags",
"busttype",
"busttag",
"sinkspeed",
@ -1819,8 +1819,8 @@ static int ffloor_get(lua_State *L)
case ffloor_alpha:
lua_pushinteger(L, ffloor->alpha);
return 1;
case ffloor_specialflags:
lua_pushinteger(L, ffloor->specialflags);
case ffloor_bustflags:
lua_pushinteger(L, ffloor->bustflags);
return 1;
case ffloor_busttype:
lua_pushinteger(L, ffloor->busttype);

View file

@ -1688,7 +1688,7 @@ static void P_PushableCheckBustables(mobj_t *mo)
if (!(rover->flags & FF_BUSTUP))
continue;
if (!(rover->specialflags & FS_PUSHABLES))
if (!(rover->bustflags & FB_PUSHABLES))
continue;
if (rover->master->frontsector->crumblestate != CRUMBLE_NONE)
@ -1698,7 +1698,7 @@ static void P_PushableCheckBustables(mobj_t *mo)
bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL);
// Height checks
if (rover->specialflags & FS_ONLYBOTTOM)
if (rover->bustflags & FB_ONLYBOTTOM)
{
if (mo->z + mo->momz + mo->height < bottomheight)
continue;
@ -1740,7 +1740,7 @@ static void P_PushableCheckBustables(mobj_t *mo)
EV_CrumbleChain(NULL, rover); // node->m_sector
// Run a linedef executor??
if (rover->specialflags & FS_EXECUTOR)
if (rover->bustflags & FB_EXECUTOR)
P_LinedefExecute(rover->busttag, mo, node->m_sector);
goto bustupdone;

View file

@ -3084,8 +3084,6 @@ static void P_ConvertBinaryMap(void)
case 76: //Make FOF bouncy
lines[i].args[0] = tag;
lines[i].args[1] = P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS;
if (lines[i].flags & ML_BOUNCY)
lines[i].args[2] = 1;
break;
case 100: //FOF: solid, opaque, shadowcasting
case 101: //FOF: solid, opaque, non-shadowcasting

View file

@ -6089,10 +6089,6 @@ static void P_MakeFOFBouncy(line_t *paramline, line_t *masterline)
rover->flags |= FF_BOUNCY;
rover->spawnflags |= FF_BOUNCY;
rover->bouncestrength = (paramline->args[1]<< FRACBITS)/100;
if (paramline->args[2])
rover->specialflags |= FS_DAMPEN;
else
rover->specialflags &= ~FS_DAMPEN;
CheckForBouncySector = true;
break;
}
@ -6739,7 +6735,7 @@ void P_SpawnSpecials(boolean fromnetsave)
case 254: // Bustable block
{
UINT8 busttype = BT_REGULAR;
ffloorspecialflags_e bustflags = 0;
ffloorbustflags_e bustflags = 0;
ffloorflags = FF_EXISTS|FF_BLOCKOTHERS|FF_RENDERALL|FF_BUSTUP;
@ -6762,15 +6758,15 @@ void P_SpawnSpecials(boolean fromnetsave)
//Flags
if (lines[i].args[3] & TMFB_PUSHABLES)
bustflags |= FS_PUSHABLES;
bustflags |= FB_PUSHABLES;
if (lines[i].args[3] & TMFB_EXECUTOR)
bustflags |= FS_EXECUTOR;
bustflags |= FB_EXECUTOR;
if (lines[i].args[3] & TMFB_ONLYBOTTOM)
bustflags |= FS_ONLYBOTTOM;
bustflags |= FB_ONLYBOTTOM;
if (lines[i].args[3] & TMFB_SPLAT)
ffloorflags |= FF_SPLAT;
if (busttype != BT_TOUCH || bustflags & FS_ONLYBOTTOM)
if (busttype != BT_TOUCH || bustflags & FB_ONLYBOTTOM)
ffloorflags |= FF_BLOCKPLAYER;
TAG_ITER_SECTORS(lines[i].args[0], s)
@ -6778,8 +6774,8 @@ void P_SpawnSpecials(boolean fromnetsave)
ffloor_t *fflr = P_AddFakeFloor(&sectors[s], lines[i].frontsector, lines + i, lines[i].args[1], ffloorflags, secthinkers);
if (!fflr)
continue;
fflr->bustflags = bustflags;
fflr->busttype = busttype;
fflr->specialflags = bustflags;
fflr->busttag = lines[i].args[4];
}
break;
@ -6839,12 +6835,12 @@ void P_SpawnSpecials(boolean fromnetsave)
}
if (lines[i].args[3] & TMFB_ONLYBOTTOM)
fflr->specialflags |= FS_ONLYBOTTOM;
fflr->bustflags |= FB_ONLYBOTTOM;
if (lines[i].flags & ML_EFFECT4)
fflr->specialflags |= FS_PUSHABLES;
fflr->bustflags |= FB_PUSHABLES;
if (lines[i].flags & ML_EFFECT5)
{
fflr->specialflags |= FS_EXECUTOR;
fflr->bustflags |= FB_EXECUTOR;
fflr->busttag = P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS;
}
}
@ -7176,7 +7172,7 @@ void P_SpawnSpecials(boolean fromnetsave)
case 74: // Make FOF bustable
{
UINT8 busttype = BT_REGULAR;
ffloorspecialflags_e bustflags = 0;
ffloorbustflags_e bustflags = 0;
if (!udmf)
break;
@ -7198,11 +7194,11 @@ void P_SpawnSpecials(boolean fromnetsave)
}
if (lines[i].args[2] & TMFB_PUSHABLES)
bustflags |= FS_PUSHABLES;
bustflags |= FB_PUSHABLES;
if (lines[i].args[2] & TMFB_EXECUTOR)
bustflags |= FS_EXECUTOR;
bustflags |= FB_EXECUTOR;
if (lines[i].args[2] & TMFB_ONLYBOTTOM)
bustflags |= FS_ONLYBOTTOM;
bustflags |= FB_ONLYBOTTOM;
TAG_ITER_LINES(lines[i].args[0], l)
{
@ -7220,9 +7216,8 @@ void P_SpawnSpecials(boolean fromnetsave)
rover->flags |= FF_BUSTUP;
rover->spawnflags |= FF_BUSTUP;
rover->bustflags = bustflags;
rover->busttype = busttype;
rover->specialflags &= ~FS_BUSTMASK;
rover->specialflags |= bustflags;
rover->busttag = lines[i].args[3];
CheckForBustableBlocks = true;
break;

View file

@ -2656,7 +2656,7 @@ static void P_CheckBustableBlocks(player_t *player)
}
// Height checks
if (rover->specialflags & FS_ONLYBOTTOM)
if (rover->bustflags & FB_ONLYBOTTOM)
{
if (player->mo->z + player->mo->momz + player->mo->height < bottomheight)
continue;
@ -2710,7 +2710,7 @@ static void P_CheckBustableBlocks(player_t *player)
EV_CrumbleChain(NULL, rover); // node->m_sector
// Run a linedef executor??
if (rover->specialflags & FS_EXECUTOR)
if (rover->bustflags & FB_EXECUTOR)
P_LinedefExecute(rover->busttag, player->mo, node->m_sector);
goto bustupdone;
@ -2766,10 +2766,6 @@ static void P_CheckBouncySectors(player_t *player)
{
rover->flags |= FF_BOUNCY;
rover->bouncestrength = P_AproxDistance(rover->master->dx, rover->master->dy)/100;
if (rover->master->flags & ML_BOUNCY)
rover->specialflags |= FS_DAMPEN;
else
rover->specialflags &= ~FS_DAMPEN;
}
if (!(rover->flags & FF_BOUNCY))
@ -2789,17 +2785,9 @@ static void P_CheckBouncySectors(player_t *player)
{
player->mo->momx = -FixedMul(player->mo->momx,rover->bouncestrength);
player->mo->momy = -FixedMul(player->mo->momy,rover->bouncestrength);
if (player->pflags & PF_SPINNING)
{
player->pflags &= ~PF_SPINNING;
player->pflags |= P_GetJumpFlags(player);
player->pflags |= PF_THOKKED;
}
}
else
{
fixed_t newmom;
pslope_t *slope = (abs(oldz - topheight) < abs(oldz + player->mo->height - bottomheight)) ? *rover->t_slope : *rover->b_slope;
momentum.x = player->mo->momx;
@ -2809,53 +2797,29 @@ static void P_CheckBouncySectors(player_t *player)
if (slope)
P_ReverseQuantizeMomentumToSlope(&momentum, slope);
newmom = momentum.z = -FixedMul(momentum.z,rover->bouncestrength)/2;
momentum.z = -FixedMul(momentum.z,rover->bouncestrength)/2;
if (abs(newmom) < (rover->bouncestrength*2))
if (abs(momentum.z) < (rover->bouncestrength*2))
goto bouncydone;
if (!(rover->specialflags & FS_DAMPEN))
{
if (newmom > 0)
{
if (newmom < 8*FRACUNIT)
newmom = 8*FRACUNIT;
}
else if (newmom < 0)
{
if (newmom > -8*FRACUNIT)
newmom = -8*FRACUNIT;
}
}
if (newmom > P_GetPlayerHeight(player)/2)
newmom = P_GetPlayerHeight(player)/2;
else if (newmom < -P_GetPlayerHeight(player)/2)
newmom = -P_GetPlayerHeight(player)/2;
momentum.z = newmom*2;
if (momentum.z > FixedMul(24*FRACUNIT, player->mo->scale)) //half of the default player height
momentum.z = FixedMul(24*FRACUNIT, player->mo->scale);
else if (momentum.z < -FixedMul(24*FRACUNIT, player->mo->scale))
momentum.z = -FixedMul(24*FRACUNIT, player->mo->scale);
if (slope)
P_QuantizeMomentumToSlope(&momentum, slope);
player->mo->momx = momentum.x;
player->mo->momy = momentum.y;
player->mo->momz = momentum.z/2;
player->mo->momz = momentum.z;
if (player->pflags & PF_SPINNING)
{
player->pflags &= ~PF_SPINNING;
player->pflags |= P_GetJumpFlags(player);
player->pflags |= PF_THOKKED;
}
}
if ((player->pflags & PF_SPINNING) && player->speed < FixedMul(1<<FRACBITS, player->mo->scale) && player->mo->momz)
{
player->pflags &= ~PF_SPINNING;
player->pflags |= P_GetJumpFlags(player);
}
goto bouncydone;
}
}

View file

@ -154,12 +154,10 @@ typedef enum
typedef enum
{
FS_PUSHABLES = 0x1, // FF_BUSTABLE: Bustable by pushables
FS_EXECUTOR = 0x2, // FF_BUSTABLE: Trigger linedef executor
FS_ONLYBOTTOM = 0x4, // FF_BUSTABLE: Only bustable from below
FS_BUSTMASK = 0x7,
FS_DAMPEN = 0x8, // FF_BOUNCY: Dampen bounce
} ffloorspecialflags_e;
FB_PUSHABLES = 0x1, // Bustable by pushables
FB_EXECUTOR = 0x2, // Trigger linedef executor
FB_ONLYBOTTOM = 0x4, // Only bustable from below
} ffloorbustflags_e;
typedef enum
{
@ -201,10 +199,8 @@ typedef struct ffloor_s
INT32 alpha;
tic_t norender; // for culling
// Flags that are only relevant for special ffloor types
ffloorspecialflags_e specialflags;
// Only relevant for FF_BUSTUP
ffloorbustflags_e bustflags;
UINT8 busttype;
INT16 busttag;