Merge branch 'special-sector-tweak' into 'master'

Fix step-up on stairs for other objects (Orbinaut VS Toxic Palace Stairs)

See merge request KartKrew/Kart!201
This commit is contained in:
Sal 2020-03-06 00:10:35 -05:00
commit b13ebd6d15
8 changed files with 114 additions and 116 deletions

View file

@ -1533,20 +1533,16 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid)
\return boolean
*/
static UINT8 K_CheckOffroadCollide(mobj_t *mo, sector_t *sec)
static UINT8 K_CheckOffroadCollide(mobj_t *mo)
{
UINT8 i;
sector_t *sec2;
I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo));
sec2 = P_ThingOnSpecial3DFloor(mo);
for (i = 2; i < 5; i++)
{
if ((sec2 && GETSECSPECIAL(sec2->special, 1) == i)
|| (P_IsObjectOnRealGround(mo, sec) && GETSECSPECIAL(sec->special, 1) == i))
if (P_MobjTouchingSectorSpecial(mo, 1, i, true))
return i-1;
}
@ -1561,25 +1557,16 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo, sector_t *sec)
*/
static void K_UpdateOffroad(player_t *player)
{
fixed_t offroad;
sector_t *nextsector = R_PointInSubsector(
player->mo->x + player->mo->momx*2, player->mo->y + player->mo->momy*2)->sector;
UINT8 offroadstrength = K_CheckOffroadCollide(player->mo, nextsector);
fixed_t offroadstrength = (K_CheckOffroadCollide(player->mo) << FRACBITS);
// If you are in offroad, a timer starts.
if (offroadstrength)
{
if (K_CheckOffroadCollide(player->mo, player->mo->subsector->sector) && player->kartstuff[k_offroad] == 0)
player->kartstuff[k_offroad] = TICRATE;
if (player->kartstuff[k_offroad] < offroadstrength)
player->kartstuff[k_offroad] += offroadstrength / TICRATE;
if (player->kartstuff[k_offroad] > 0)
{
offroad = (offroadstrength << FRACBITS) / TICRATE;
player->kartstuff[k_offroad] += offroad;
}
if (player->kartstuff[k_offroad] > (offroadstrength << FRACBITS))
player->kartstuff[k_offroad] = (offroadstrength << FRACBITS);
if (player->kartstuff[k_offroad] > offroadstrength)
player->kartstuff[k_offroad] = offroadstrength;
}
else
player->kartstuff[k_offroad] = 0;

View file

@ -1313,15 +1313,16 @@ static int lib_pExplodeMissile(lua_State *L)
return 0;
}
static int lib_pPlayerTouchingSectorSpecial(lua_State *L)
static int lib_pMobjTouchingSectorSpecial(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
INT32 section = (INT32)luaL_checkinteger(L, 2);
INT32 number = (INT32)luaL_checkinteger(L, 3);
boolean touchground = lua_optboolean(L, 4);
//HUDSAFE
if (!player)
return LUA_ErrInvalid(L, "player_t");
LUA_PushUserdata(L, P_PlayerTouchingSectorSpecial(player, section, number), META_SECTOR);
if (!mo)
return LUA_ErrInvalid(L, "mobj_t");
LUA_PushUserdata(L, P_MobjTouchingSectorSpecial(mo, section, number, touchground), META_SECTOR);
return 1;
}
@ -2736,7 +2737,7 @@ static luaL_Reg lib[] = {
{"P_SetMobjStateNF",lib_pSetMobjStateNF},
{"P_DoSuperTransformation",lib_pDoSuperTransformation},
{"P_ExplodeMissile",lib_pExplodeMissile},
{"P_PlayerTouchingSectorSpecial",lib_pPlayerTouchingSectorSpecial},
{"P_MobjTouchingSectorSpecial",lib_pMobjTouchingSectorSpecial},
{"P_FindSpecialLineFromTag",lib_pFindSpecialLineFromTag},
{"P_SwitchWeather",lib_pSwitchWeather},
{"P_LinedefExecute",lib_pLinedefExecute},

View file

@ -2276,7 +2276,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime)
continue;
if (!(players[i].mo->subsector->sector == sec
|| P_PlayerTouchingSectorSpecial(&players[i], 2, (GETSECSPECIAL(sec->special, 2))) == sec))
|| P_MobjTouchingSectorSpecial(players[i].mo, 2, (GETSECSPECIAL(sec->special, 2)), false) == sec))
continue;
if (floortouch == true && P_IsObjectOnRealGround(players[i].mo, sec))

View file

@ -925,7 +925,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
special->fuse = 1;
special->flags2 |= MF2_JUSTATTACKED;
if (!P_PlayerTouchingSectorSpecial(player, 4, 2 + flagteam))
if (!P_MobjTouchingSectorSpecial(player->mo, 4, 2 + flagteam, false))
{
CONS_Printf(M_GetText("%s returned the %c%s%c to base.\n"), plname, flagcolor, flagtext, 0x80);

View file

@ -2790,28 +2790,15 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
const fixed_t maxstepmove = FixedMul(MAXSTEPMOVE, mapobjectscale);
fixed_t maxstep = maxstepmove;
if (thing->player)
{
if (thing->player->kartstuff[k_waterskip])
maxstep += maxstepmove; // Force some stepmove when waterskipping
if (thing->player && thing->player->kartstuff[k_waterskip])
maxstep += maxstepmove; // Add some extra stepmove when waterskipping
// If using type Section1:13, double the maxstep.
if (P_PlayerTouchingSectorSpecial(thing->player, 1, 13)
|| GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 13)
maxstep += maxstepmove;
// If using type Section1:12, no maxstep. For ledges you don't want the player to climb! (see: Egg Zeppelin & SMK port walls)
else if (P_PlayerTouchingSectorSpecial(thing->player, 1, 12)
|| GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 12)
maxstep -= maxstepmove;
// Don't 'step up' while springing,
// Only step up "if needed".
/* // SRB2kart - don't need
if (thing->state == &states[S_PLAY_SPRING]
&& P_MobjFlip(thing)*thing->momz > FixedMul(FRACUNIT, thing->scale))
maxstep = 0;
*/
}
// If using type Section1:13, double the maxstep.
if (P_MobjTouchingSectorSpecial(thing, 1, 13, false))
maxstep <<= 1;
// If using type Section1:12, no maxstep. For short walls, like Egg Zeppelin
else if (P_MobjTouchingSectorSpecial(thing, 1, 12, false))
maxstep = 0;
if (thing->type == MT_SKIM)
maxstep = 0;
@ -2834,12 +2821,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
return false; // mobj must lower itself to fit
// Ramp test
if (maxstep > 0 && !(
thing->player && (
P_PlayerTouchingSectorSpecial(thing->player, 1, 14)
|| GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 14)
)
)
if ((maxstep > 0) && !(P_MobjTouchingSectorSpecial(thing, 1, 14, false)))
{
// If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS
// step down! Formerly required a Section1:13 sector for the full MAXSTEPMOVE, but no more.

View file

@ -8355,14 +8355,8 @@ void P_MobjThinker(mobj_t *mobj)
P_Thrust(mobj, mobj->angle, thrustamount);
if (grounded)
{
sector_t *sec2 = P_ThingOnSpecial3DFloor(mobj);
if ((sec2 && GETSECSPECIAL(sec2->special, 3) == 1)
|| (P_IsObjectOnRealGround(mobj, mobj->subsector->sector)
&& GETSECSPECIAL(mobj->subsector->sector->special, 3) == 1))
K_DoPogoSpring(mobj, 0, 1);
}
if (P_MobjTouchingSectorSpecial(mobj, 3, 1, true))
K_DoPogoSpring(mobj, 0, 1);
if (mobj->threshold > 0)
mobj->threshold--;
@ -8374,7 +8368,6 @@ void P_MobjThinker(mobj_t *mobj)
}
case MT_JAWZ:
{
sector_t *sec2;
mobj_t *ghost = P_SpawnGhostMobj(mobj);
if (mobj->target && !P_MobjWasRemoved(mobj->target) && mobj->target->player)
@ -8392,10 +8385,7 @@ void P_MobjThinker(mobj_t *mobj)
K_DriftDustHandling(mobj);
sec2 = P_ThingOnSpecial3DFloor(mobj);
if ((sec2 && GETSECSPECIAL(sec2->special, 3) == 1)
|| (P_IsObjectOnRealGround(mobj, mobj->subsector->sector)
&& GETSECSPECIAL(mobj->subsector->sector->special, 3) == 1))
if (P_MobjTouchingSectorSpecial(mobj, 3, 1, true))
K_DoPogoSpring(mobj, 0, 1);
break;
@ -8447,14 +8437,8 @@ void P_MobjThinker(mobj_t *mobj)
mobj->angle = R_PointToAngle2(0, 0, mobj->momx, mobj->momy);
P_Thrust(mobj, mobj->angle, thrustamount);
if (grounded)
{
sector_t *sec2 = P_ThingOnSpecial3DFloor(mobj);
if ((sec2 && GETSECSPECIAL(sec2->special, 3) == 1)
|| (P_IsObjectOnRealGround(mobj, mobj->subsector->sector)
&& GETSECSPECIAL(mobj->subsector->sector->special, 3) == 1))
K_DoPogoSpring(mobj, 0, 1);
}
if (P_MobjTouchingSectorSpecial(mobj, 3, 1, true))
K_DoPogoSpring(mobj, 0, 1);
if (mobj->threshold > 0)
mobj->threshold--;
@ -9675,13 +9659,9 @@ void P_MobjThinker(mobj_t *mobj)
break;
case MT_BLUEFLAG:
case MT_REDFLAG:
{
sector_t *sec2;
sec2 = P_ThingOnSpecial3DFloor(mobj);
if ((sec2 && GETSECSPECIAL(sec2->special, 4) == 2) || (GETSECSPECIAL(mobj->subsector->sector->special, 4) == 2))
mobj->fuse = 1; // Return to base.
break;
}
if (P_MobjTouchingSectorSpecial(mobj, 4, 2, false))
mobj->fuse = 1; // Return to base.
break;
case MT_CANNONBALL:
#ifdef FLOORSPLATS
R_AddFloorSplat(mobj->tracer->subsector, mobj->tracer, "TARGET", mobj->tracer->x,

View file

@ -3304,7 +3304,7 @@ boolean P_IsFlagAtBase(mobjtype_t flag)
}
//
// P_PlayerTouchingSectorSpecial
// P_MobjTouchingSectorSpecial
//
// Replaces the old player->specialsector.
// This allows a player to touch more than
@ -3314,60 +3314,86 @@ boolean P_IsFlagAtBase(mobjtype_t flag)
// the particular type that it finds.
// Returns NULL if it doesn't find it.
//
sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 number)
// Sal: Couldn't see a reason for this to
// be a player_t only function.
//
sector_t *P_MobjTouchingSectorSpecial(mobj_t *mo, INT32 section, INT32 number, boolean touchground)
{
fixed_t topheight, bottomheight;
msecnode_t *node;
ffloor_t *rover;
if (!player->mo)
if (!mo)
return NULL;
// Check default case first
if (GETSECSPECIAL(player->mo->subsector->sector->special, section) == number)
return player->mo->subsector->sector;
if (GETSECSPECIAL(mo->subsector->sector->special, section) == number)
{
if (touchground)
{
topheight = P_GetSpecialTopZ(mo, mo->subsector->sector, mo->subsector->sector);
bottomheight = P_GetSpecialBottomZ(mo, mo->subsector->sector, mo->subsector->sector);
// Thing must be on top of the floor to be affected...
if (mo->subsector->sector->flags & SF_FLIPSPECIAL_FLOOR)
{
if (!(mo->eflags & MFE_VERTICALFLIP) && mo->z <= bottomheight)
return mo->subsector->sector;
}
if (mo->subsector->sector->flags & SF_FLIPSPECIAL_CEILING)
{
if ((mo->eflags & MFE_VERTICALFLIP) && mo->z + mo->height >= topheight)
return mo->subsector->sector;
}
}
else
{
return mo->subsector->sector;
}
}
// Hmm.. maybe there's a FOF that has it...
for (rover = player->mo->subsector->sector->ffloors; rover; rover = rover->next)
for (rover = mo->subsector->sector->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
if (GETSECSPECIAL(rover->master->frontsector->special, section) != number)
continue;
if (!(rover->flags & FF_EXISTS))
continue;
topheight = P_GetSpecialTopZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector);
bottomheight = P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector);
topheight = P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector);
bottomheight = P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector);
// Check the 3D floor's type...
if (rover->flags & FF_BLOCKPLAYER)
if (((rover->flags & FF_BLOCKPLAYER) && mo->player)
|| ((rover->flags & FF_BLOCKOTHERS) && !mo->player))
{
// Thing must be on top of the floor to be affected...
if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING))
{
if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != topheight)
if ((mo->eflags & MFE_VERTICALFLIP) || mo->z != topheight)
continue;
}
else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR))
{
if (!(player->mo->eflags & MFE_VERTICALFLIP)
|| player->mo->z + player->mo->height != bottomheight)
if (!(mo->eflags & MFE_VERTICALFLIP)
|| mo->z + mo->height != bottomheight)
continue;
}
else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH)
{
if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == bottomheight)
|| (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == topheight)))
if (!((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height == bottomheight)
|| (!(mo->eflags & MFE_VERTICALFLIP) && mo->z == topheight)))
continue;
}
}
else
{
// Water and DEATH FOG!!! heh
if (player->mo->z > topheight || (player->mo->z + player->mo->height) < bottomheight)
if (mo->z > topheight || (mo->z + mo->height) < bottomheight)
continue;
}
@ -3375,64 +3401,86 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n
return rover->master->frontsector;
}
for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next)
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
{
if (GETSECSPECIAL(node->m_sector->special, section) == number)
{
// This sector has the special we're looking for, but
// are we allowed to touch it?
if (node->m_sector == player->mo->subsector->sector
if (node->m_sector == mo->subsector->sector
|| (node->m_sector->flags & SF_TRIGGERSPECIAL_TOUCH))
return node->m_sector;
{
if (touchground)
{
topheight = P_GetSpecialTopZ(mo, node->m_sector, node->m_sector);
bottomheight = P_GetSpecialBottomZ(mo, node->m_sector, node->m_sector);
// Thing must be on top of the floor to be affected...
if (node->m_sector->flags & SF_FLIPSPECIAL_FLOOR)
{
if (!(mo->eflags & MFE_VERTICALFLIP) && mo->z <= bottomheight)
return node->m_sector;
}
if (node->m_sector->flags & SF_FLIPSPECIAL_CEILING)
{
if ((mo->eflags & MFE_VERTICALFLIP) && mo->z + mo->height >= topheight)
return node->m_sector;
}
}
else
{
return node->m_sector;
}
}
}
// Hmm.. maybe there's a FOF that has it...
for (rover = node->m_sector->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
if (GETSECSPECIAL(rover->master->frontsector->special, section) != number)
continue;
if (!(rover->flags & FF_EXISTS))
continue;
topheight = P_GetSpecialTopZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector);
bottomheight = P_GetSpecialBottomZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector);
topheight = P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector);
bottomheight = P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector);
// Check the 3D floor's type...
if (rover->flags & FF_BLOCKPLAYER)
if (((rover->flags & FF_BLOCKPLAYER) && mo->player)
|| ((rover->flags & FF_BLOCKOTHERS) && !mo->player))
{
// Thing must be on top of the floor to be affected...
if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING))
{
if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != topheight)
if ((mo->eflags & MFE_VERTICALFLIP) || mo->z != topheight)
continue;
}
else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)
&& !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR))
{
if (!(player->mo->eflags & MFE_VERTICALFLIP)
|| player->mo->z + player->mo->height != bottomheight)
if (!(mo->eflags & MFE_VERTICALFLIP)
|| mo->z + mo->height != bottomheight)
continue;
}
else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH)
{
if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == bottomheight)
|| (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == topheight)))
if (!((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height == bottomheight)
|| (!(mo->eflags & MFE_VERTICALFLIP) && mo->z == topheight)))
continue;
}
}
else
{
// Water and DEATH FOG!!! heh
if (player->mo->z > topheight || (player->mo->z + player->mo->height) < bottomheight)
if (mo->z > topheight || (mo->z + mo->height) < bottomheight)
continue;
}
// This FOF has the special we're looking for, but are we allowed to touch it?
if (node->m_sector == player->mo->subsector->sector
if (node->m_sector == mo->subsector->sector
|| (rover->master->frontsector->flags & SF_TRIGGERSPECIAL_TOUCH))
return rover->master->frontsector;
}

View file

@ -37,7 +37,7 @@ void P_SpawnSpecials(INT32 fromnetsave);
// every tic
void P_UpdateSpecials(void);
sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 number);
sector_t *P_MobjTouchingSectorSpecial(mobj_t *mo, INT32 section, INT32 number, boolean touchground);
void P_PlayerInSpecialSector(player_t *player);
void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *roversector);