From ad80593cb748a277766796f60a2619d161050d42 Mon Sep 17 00:00:00 2001 From: Boondorl <59555366+Boondorl@users.noreply.github.com> Date: Fri, 25 Nov 2022 10:47:40 -0500 Subject: [PATCH] Allow Getting Portal Group Offsets --- src/scripting/vmthunks.cpp | 17 +++++++++++++++++ wadsrc/static/zscript/doombase.zs | 1 + 2 files changed, 18 insertions(+) diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index a5ee95448..0b0391bd0 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -2419,6 +2419,23 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, Vec3Diff, Vec3Diff) ACTION_RETURN_VEC3(VecDiff(self, DVector3(x1, y1, z1), DVector3(x2, y2, z2))); } +DEFINE_ACTION_FUNCTION(FLevelLocals, GetDisplacement) +{ + PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); + PARAM_INT(pg1); + PARAM_INT(pg2); + + DVector2 ofs(0, 0); + if (pg1 != pg2) + { + int i = pg1 + self->Displacements.size * pg2; + if (i < self->Displacements.data.Size()) + ofs = self->Displacements.data[i].pos; + } + + ACTION_RETURN_VEC2(ofs); +} + void SphericalCoords(FLevelLocals *self, double vpX, double vpY, double vpZ, double tX, double tY, double tZ, double viewYaw, double viewPitch, int absolute, DVector3 *result) { diff --git a/wadsrc/static/zscript/doombase.zs b/wadsrc/static/zscript/doombase.zs index b7377baa3..5425c7b00 100644 --- a/wadsrc/static/zscript/doombase.zs +++ b/wadsrc/static/zscript/doombase.zs @@ -491,6 +491,7 @@ struct LevelLocals native native clearscope vector2 Vec2Offset(vector2 pos, vector2 dir, bool absolute = false) const; native clearscope vector3 Vec2OffsetZ(vector2 pos, vector2 dir, double atz, bool absolute = false) const; native clearscope vector3 Vec3Offset(vector3 pos, vector3 dir, bool absolute = false) const; + native clearscope Vector2 GetDisplacement(int pg1, int pg2) const; native String GetChecksum() const;