From fe1acc7f40d036ae60efe849ed9e68bb8ab6eac3 Mon Sep 17 00:00:00 2001 From: Boondorl <59555366+Boondorl@users.noreply.github.com> Date: Thu, 19 Jan 2023 15:44:41 -0500 Subject: [PATCH] Localized fix to its own field --- src/p_setup.cpp | 2 +- src/playsim/actor.h | 1 + src/playsim/p_mobj.cpp | 9 +++------ src/scripting/vmthunks_actors.cpp | 9 ++++++--- wadsrc/static/zscript/actors/actor.zs | 3 ++- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 569f79919..a0707357e 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -285,7 +285,7 @@ void FLevelLocals::ClearLevelData(bool fullgc) auto it = GetThinkerIterator(NAME_None, STAT_TRAVELLING); for (AActor *actor = it.Next(); actor != nullptr; actor = it.Next()) { - actor->BlockingLine = nullptr; + actor->BlockingLine = actor->MovementBlockingLine = nullptr; actor->BlockingFloor = actor->BlockingCeiling = actor->Blocking3DFloor = nullptr; } } diff --git a/src/playsim/actor.h b/src/playsim/actor.h index 8c5be5256..eea647477 100644 --- a/src/playsim/actor.h +++ b/src/playsim/actor.h @@ -1223,6 +1223,7 @@ public: AActor *BlockingMobj; // Actor that blocked the last move line_t *BlockingLine; // Line that blocked the last move + line_t *MovementBlockingLine; // Line that stopped the Actor's movement in P_XYMovement sector_t *Blocking3DFloor; // 3D floor that blocked the last move (if any) sector_t *BlockingCeiling; // Sector that blocked the last move (ceiling plane slope) sector_t *BlockingFloor; // Sector that blocked the last move (floor plane slope) diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index 8ba0ef3ba..1596989d0 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -310,6 +310,7 @@ void AActor::Serialize(FSerializer &arc) A("smokecounter", smokecounter) ("blockingmobj", BlockingMobj) A("blockingline", BlockingLine) + A("movementblockingline", MovementBlockingLine) A("blocking3dfloor", Blocking3DFloor) A("blockingceiling", BlockingCeiling) A("blockingfloor", BlockingFloor) @@ -1971,7 +1972,6 @@ static double P_XYMovement (AActor *mo, DVector2 scroll) FCheckPosition tm(!!(mo->flags2 & MF2_RIP)); DAngle oldangle = mo->Angles.Yaw; - line_t* blocker = nullptr; do { if (mo->Level->i_compatflags & COMPATF_WALLRUN) pushtime++; @@ -1987,7 +1987,7 @@ static double P_XYMovement (AActor *mo, DVector2 scroll) { // blocked move AActor *BlockingMobj = mo->BlockingMobj; - line_t *BlockingLine = blocker = mo->BlockingLine; + line_t *BlockingLine = mo->MovementBlockingLine = mo->BlockingLine; // [ZZ] if (!BlockingLine && !BlockingMobj) // hit floor or ceiling while XY movement - sector actions @@ -2189,9 +2189,6 @@ static double P_XYMovement (AActor *mo, DVector2 scroll) } } while (++step <= steps); - // Correctly update whether the Actor was truly blocked by a wall or not - mo->BlockingLine = blocker; - // Friction if (player && player->mo == mo && player->cheats & CF_NOVELOCITY) @@ -4061,7 +4058,7 @@ void AActor::Tick () // Handle X and Y velocities BlockingMobj = nullptr; - BlockingLine = nullptr; + MovementBlockingLine = nullptr; sector_t* oldBlockingCeiling = BlockingCeiling; sector_t* oldBlockingFloor = BlockingFloor; Blocking3DFloor = nullptr; diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 63450efec..e3438d6f6 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -1539,20 +1539,21 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, LookForPlayers, P_LookForPlayers) ACTION_RETURN_BOOL(P_LookForPlayers(self, allaround, params)); } -static int CheckMonsterUseSpecials(AActor *self) +static int CheckMonsterUseSpecials(AActor *self, line_t *blocking) { spechit_t spec; int good = 0; if (!(self->flags6 & MF6_NOTRIGGER)) { + auto checkLine = blocking ? blocking : self->BlockingLine; while (spechit.Pop (spec)) { // [RH] let monsters push lines, as well as use them if (((self->flags4 & MF4_CANUSEWALLS) && P_ActivateLine (spec.line, self, 0, SPAC_Use)) || ((self->flags2 & MF2_PUSHWALL) && P_ActivateLine (spec.line, self, 0, SPAC_Push))) { - good |= spec.line == self->BlockingLine ? 1 : 2; + good |= spec.line == checkLine ? 1 : 2; } } } @@ -1564,8 +1565,9 @@ static int CheckMonsterUseSpecials(AActor *self) DEFINE_ACTION_FUNCTION_NATIVE(AActor, CheckMonsterUseSpecials, CheckMonsterUseSpecials) { PARAM_SELF_PROLOGUE(AActor); + PARAM_POINTER(blocking, line_t); - ACTION_RETURN_INT(CheckMonsterUseSpecials(self)); + ACTION_RETURN_INT(CheckMonsterUseSpecials(self, blocking)); } DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_Wander, A_Wander) @@ -2055,6 +2057,7 @@ DEFINE_FIELD(AActor, lastbump) DEFINE_FIELD(AActor, DesignatedTeam) DEFINE_FIELD(AActor, BlockingMobj) DEFINE_FIELD(AActor, BlockingLine) +DEFINE_FIELD(AActor, MovementBlockingLine) DEFINE_FIELD(AActor, Blocking3DFloor) DEFINE_FIELD(AActor, BlockingCeiling) DEFINE_FIELD(AActor, BlockingFloor) diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 77f59c4d5..2601b7698 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -202,6 +202,7 @@ class Actor : Thinker native native int DesignatedTeam; native Actor BlockingMobj; native Line BlockingLine; + native Line MovementBlockingLine; native Sector Blocking3DFloor; native Sector BlockingCeiling; native Sector BlockingFloor; @@ -698,7 +699,7 @@ class Actor : Thinker native native void CheckFakeFloorTriggers (double oldz, bool oldz_has_viewheight = false); native bool CheckFor3DFloorHit(double z, bool trigger); native bool CheckFor3DCeilingHit(double z, bool trigger); - native int CheckMonsterUseSpecials(); + native int CheckMonsterUseSpecials(Line blocking = null); native bool CheckMissileSpawn(double maxdist); native bool CheckPosition(Vector2 pos, bool actorsonly = false, FCheckPosition tm = null);