Activate sector each time / once actions when mobj touches the ground
Before - Each time / once only activates when the mobj's sector changes - The activation may depend on the mobj touching the floor - If the mobj is in the air when the sector changes, the action will never be activated After - Each time / once actions that require floor touching also activate every time the mobj lands on the ground from the air (regardless of whether the sector changed)
This commit is contained in:
parent
4beb4e6f02
commit
67888c237d
5 changed files with 58 additions and 21 deletions
|
|
@ -100,6 +100,9 @@ camera_t *mapcampointer;
|
|||
//
|
||||
static boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z)
|
||||
{
|
||||
boolean startingonground = P_IsObjectOnGround(thing);
|
||||
sector_t *oldsector = thing->subsector->sector;
|
||||
|
||||
numspechit = 0U;
|
||||
|
||||
// the move is ok,
|
||||
|
|
@ -129,6 +132,8 @@ static boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z)
|
|||
thing->floorrover = g_tm.floorrover;
|
||||
thing->ceilingrover = g_tm.ceilingrover;
|
||||
|
||||
P_CheckSectorTransitionalEffects(thing, oldsector, startingonground);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2745,6 +2750,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff, Try
|
|||
fixed_t oldx = thing->x;
|
||||
fixed_t oldy = thing->y;
|
||||
fixed_t startingonground = P_IsObjectOnGround(thing);
|
||||
sector_t *oldsector = thing->subsector->sector;
|
||||
|
||||
// Is the move OK?
|
||||
if (increment_move(thing, x, y, allowdropoff, result) == false)
|
||||
|
|
@ -2847,6 +2853,8 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff, Try
|
|||
|
||||
P_SetThingPosition(thing);
|
||||
|
||||
P_CheckSectorTransitionalEffects(thing, oldsector, startingonground);
|
||||
|
||||
// remove any duplicates that may be in spechitint
|
||||
spechitint_removedups();
|
||||
|
||||
|
|
|
|||
|
|
@ -1236,7 +1236,6 @@ static void P_LinkToBlockMap(mobj_t *thing, mobj_t **bmap)
|
|||
void P_SetThingPosition(mobj_t *thing)
|
||||
{ // link into subsector
|
||||
subsector_t *ss;
|
||||
sector_t *prevsec = NULL;
|
||||
sector_t *oldsec = NULL;
|
||||
fixed_t tfloorz, tceilz;
|
||||
|
||||
|
|
@ -1249,11 +1248,6 @@ void P_SetThingPosition(mobj_t *thing)
|
|||
oldsec = thing->subsector->sector;
|
||||
}
|
||||
|
||||
if (thing->subsector)
|
||||
{
|
||||
prevsec = thing->subsector->sector;
|
||||
}
|
||||
|
||||
ss = thing->subsector = R_PointInSubsector(thing->x, thing->y);
|
||||
|
||||
if (!(thing->flags & MF_NOSECTOR))
|
||||
|
|
@ -1310,12 +1304,6 @@ void P_SetThingPosition(mobj_t *thing)
|
|||
else if (thing->z <= tfloorz)
|
||||
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
|
||||
}
|
||||
|
||||
if (udmf && prevsec != thing->subsector->sector)
|
||||
{
|
||||
// Check for each time / once sector special actions
|
||||
P_CheckMobjTouchingSectorActions(thing, false);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
12
src/p_mobj.c
12
src/p_mobj.c
|
|
@ -2175,10 +2175,13 @@ boolean P_ZMovement(mobj_t *mo)
|
|||
{
|
||||
fixed_t dist, delta;
|
||||
boolean onground;
|
||||
boolean wasonground;
|
||||
|
||||
I_Assert(mo != NULL);
|
||||
I_Assert(!P_MobjWasRemoved(mo));
|
||||
|
||||
wasonground = P_IsObjectOnGround(mo);
|
||||
|
||||
// Intercept the stupid 'fall through 3dfloors' bug
|
||||
if (mo->subsector->sector->ffloors)
|
||||
P_AdjustMobjFloorZ_FFloors(mo, mo->subsector->sector, 0);
|
||||
|
|
@ -2604,6 +2607,8 @@ boolean P_ZMovement(mobj_t *mo)
|
|||
}
|
||||
}
|
||||
|
||||
P_CheckSectorTransitionalEffects(mo, mo->subsector->sector, wasonground);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2697,6 +2702,7 @@ static boolean P_PlayerPolyObjectZMovement(mobj_t *mo)
|
|||
void P_PlayerZMovement(mobj_t *mo)
|
||||
{
|
||||
boolean onground;
|
||||
boolean wasonground;
|
||||
|
||||
I_Assert(mo != NULL);
|
||||
I_Assert(!P_MobjWasRemoved(mo));
|
||||
|
|
@ -2704,6 +2710,8 @@ void P_PlayerZMovement(mobj_t *mo)
|
|||
if (!mo->player)
|
||||
return;
|
||||
|
||||
wasonground = P_IsObjectOnGround(mo);
|
||||
|
||||
// Intercept the stupid 'fall through 3dfloors' bug
|
||||
if (mo->subsector->sector->ffloors)
|
||||
P_AdjustMobjFloorZ_FFloors(mo, mo->subsector->sector, 0);
|
||||
|
|
@ -2834,6 +2842,8 @@ void P_PlayerZMovement(mobj_t *mo)
|
|||
P_CheckGravity(mo, true);
|
||||
}
|
||||
}
|
||||
|
||||
P_CheckSectorTransitionalEffects(mo, mo->subsector->sector, wasonground);
|
||||
}
|
||||
|
||||
boolean P_SceneryZMovement(mobj_t *mo)
|
||||
|
|
@ -10216,7 +10226,7 @@ void P_MobjThinker(mobj_t *mobj)
|
|||
if (udmf)
|
||||
{
|
||||
// Check for continuous sector special actions
|
||||
P_CheckMobjTouchingSectorActions(mobj, true);
|
||||
P_CheckMobjTouchingSectorActions(mobj, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
44
src/p_spec.c
44
src/p_spec.c
|
|
@ -5763,7 +5763,7 @@ static boolean P_AllowSpecialCeiling(sector_t *sec, mobj_t *thing)
|
|||
return false;
|
||||
}
|
||||
|
||||
static void P_CheckMobj3DFloorAction(mobj_t *mo, sector_t *sec, boolean continuous)
|
||||
static void P_CheckMobj3DFloorAction(mobj_t *mo, sector_t *sec, boolean continuous, boolean sectorchanged)
|
||||
{
|
||||
sector_t *originalsector = mo->subsector->sector;
|
||||
ffloor_t *rover;
|
||||
|
|
@ -5822,6 +5822,10 @@ static void P_CheckMobj3DFloorAction(mobj_t *mo, sector_t *sec, boolean continuo
|
|||
continue;
|
||||
}
|
||||
}
|
||||
else if (sectorchanged == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
activator = Z_Calloc(sizeof(activator_t), PU_LEVEL, NULL);
|
||||
I_Assert(activator != NULL);
|
||||
|
|
@ -5841,7 +5845,7 @@ static void P_CheckMobj3DFloorAction(mobj_t *mo, sector_t *sec, boolean continuo
|
|||
}
|
||||
}
|
||||
|
||||
static void P_CheckMobjPolyobjAction(mobj_t *mo, boolean continuous)
|
||||
static void P_CheckMobjPolyobjAction(mobj_t *mo, boolean continuous, boolean sectorchanged)
|
||||
{
|
||||
sector_t *originalsector = mo->subsector->sector;
|
||||
polyobj_t *po;
|
||||
|
|
@ -5896,6 +5900,10 @@ static void P_CheckMobjPolyobjAction(mobj_t *mo, boolean continuous)
|
|||
continue;
|
||||
}
|
||||
}
|
||||
else if (sectorchanged == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
activator = Z_Calloc(sizeof(activator_t), PU_LEVEL, NULL);
|
||||
I_Assert(activator != NULL);
|
||||
|
|
@ -5915,7 +5923,7 @@ static void P_CheckMobjPolyobjAction(mobj_t *mo, boolean continuous)
|
|||
}
|
||||
}
|
||||
|
||||
static void P_CheckMobjSectorAction(mobj_t *mo, sector_t *sec, boolean continuous)
|
||||
static void P_CheckMobjSectorAction(mobj_t *mo, sector_t *sec, boolean continuous, boolean sectorchanged)
|
||||
{
|
||||
activator_t *activator = NULL;
|
||||
boolean result = false;
|
||||
|
|
@ -5952,6 +5960,10 @@ static void P_CheckMobjSectorAction(mobj_t *mo, sector_t *sec, boolean continuou
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if (sectorchanged == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
activator = Z_Calloc(sizeof(activator_t), PU_LEVEL, NULL);
|
||||
I_Assert(activator != NULL);
|
||||
|
|
@ -5968,7 +5980,7 @@ static void P_CheckMobjSectorAction(mobj_t *mo, sector_t *sec, boolean continuou
|
|||
}
|
||||
}
|
||||
|
||||
void P_CheckMobjTouchingSectorActions(mobj_t *mobj, boolean continuous)
|
||||
void P_CheckMobjTouchingSectorActions(mobj_t *mobj, boolean continuous, boolean sectorchanged)
|
||||
{
|
||||
sector_t *originalsector;
|
||||
|
||||
|
|
@ -5994,13 +6006,13 @@ void P_CheckMobjTouchingSectorActions(mobj_t *mobj, boolean continuous)
|
|||
}
|
||||
}
|
||||
|
||||
P_CheckMobj3DFloorAction(mobj, originalsector, continuous);
|
||||
P_CheckMobj3DFloorAction(mobj, originalsector, continuous, sectorchanged);
|
||||
if TELEPORTED(mobj) return;
|
||||
|
||||
P_CheckMobjPolyobjAction(mobj, continuous);
|
||||
P_CheckMobjPolyobjAction(mobj, continuous, sectorchanged);
|
||||
if TELEPORTED(mobj) return;
|
||||
|
||||
P_CheckMobjSectorAction(mobj, originalsector, continuous);
|
||||
P_CheckMobjSectorAction(mobj, originalsector, continuous, sectorchanged);
|
||||
}
|
||||
|
||||
#undef TELEPORTED
|
||||
|
|
@ -9493,3 +9505,21 @@ void P_StartQuake(fixed_t intensity, tic_t time)
|
|||
quake.intensity = FixedMul(intensity, mapobjectscale);
|
||||
quake.time = time;
|
||||
}
|
||||
|
||||
void P_CheckSectorTransitionalEffects(mobj_t *thing, sector_t *prevsec, boolean wasgrounded)
|
||||
{
|
||||
if (!udmf)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean sectorchanged = (prevsec != thing->subsector->sector);
|
||||
|
||||
if (!sectorchanged && wasgrounded == P_IsObjectOnGround(thing))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for each time / once sector special actions
|
||||
P_CheckMobjTouchingSectorActions(thing, false, sectorchanged);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -543,12 +543,13 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n
|
|||
sector_t *P_PlayerTouchingSectorSpecialFlag(player_t *player, sectorspecialflags_t flag);
|
||||
void P_PlayerInSpecialSector(player_t *player);
|
||||
void P_CheckMobjTrigger(mobj_t *mobj, boolean pushable);
|
||||
void P_CheckMobjTouchingSectorActions(mobj_t *mobj, boolean continuous);
|
||||
void P_CheckMobjTouchingSectorActions(mobj_t *mobj, boolean continuous, boolean sectorchanged);
|
||||
sector_t *P_FindPlayerTrigger(player_t *player, line_t *sourceline);
|
||||
boolean P_IsPlayerValid(size_t playernum);
|
||||
boolean P_CanPlayerTrigger(size_t playernum);
|
||||
void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *roversector);
|
||||
sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo);
|
||||
void P_CheckSectorTransitionalEffects(mobj_t *thing, sector_t *prevsec, boolean wasgrounded);
|
||||
|
||||
fixed_t P_FindLowestFloorSurrounding(sector_t *sec);
|
||||
fixed_t P_FindHighestFloorSurrounding(sector_t *sec);
|
||||
|
|
|
|||
Loading…
Reference in a new issue