From 452c82cbe2154eabe6b7d9519c603480f5013913 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 17 Dec 2015 10:34:38 -0600 Subject: [PATCH] - Added TF_SENSITIVEZ to A_Teleport. Fail teleportation instead of adjusting the actor to fit if they cannot. - When checking whether to use spot z or floorz, use spot floorz instead of ref for consistency. --- src/thingdef/thingdef_codeptr.cpp | 19 +++++++++++++++---- wadsrc/static/actors/constants.txt | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 89299e0fad..af40ed342f 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -4261,6 +4261,7 @@ enum T_Flags TF_USEACTORFOG = 0x00000100, // Use the actor's TeleFogSourceType and TeleFogDestType fogs. TF_NOJUMP = 0x00000200, // Don't jump after teleporting. TF_OVERRIDE = 0x00000400, // Ignore NOTELEPORT. + TF_SENSITIVEZ = 0x00000800, // Fail if the actor wouldn't fit in the position (for Z). }; DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport) @@ -4323,6 +4324,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport) return; } + // [MC] By default, the function adjusts the actor's Z if it's below the floor or above the ceiling. + // This can be an issue as actors designed to maintain specific z positions wind up teleporting + // anyway when they should not, such as a floor rising above or ceiling lowering below the position + // of the spot. + if (Flags & TF_SENSITIVEZ) + { + fixed_t posz = (Flags & TF_USESPOTZ) ? spot->z : spot->floorz; + if ((posz + ref->height > spot->ceilingz) || (posz < spot->floorz)) + { + ACTION_SET_RESULT(false); + return; + } + } fixed_t prevX = ref->x; fixed_t prevY = ref->y; fixed_t prevZ = ref->z; @@ -4378,10 +4392,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport) } - if (Flags & TF_USESPOTZ) - ref->z = spot->z; - else - ref->z = ref->floorz; + ref->z = (Flags & TF_USESPOTZ) ? spot->z : spot->floorz; if (!(Flags & TF_KEEPANGLE)) ref->angle = spot->angle; diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 956ed119f7..81a0c1b636 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -204,6 +204,7 @@ enum TF_USEACTORFOG = 0x00000100, // Use the actor's TeleFogSourceType and TeleFogDestType fogs. TF_NOJUMP = 0x00000200, // Don't jump after teleporting. TF_OVERRIDE = 0x00000400, // Ignore NOTELEPORT. + TF_SENSITIVEZ = 0x00000800, // Fail if the actor wouldn't fit in the position (for Z). TF_KEEPORIENTATION = TF_KEEPVELOCITY|TF_KEEPANGLE, TF_NOFOG = TF_NOSRCFOG|TF_NODESTFOG,