From f5947c48bfb925221717a49adbc56c9c97a01e71 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Wed, 3 May 2023 22:41:34 +0000 Subject: [PATCH] q3df teleporter flags --- qcsrc/common/mapobjects/teleporters.qc | 8 +++++--- qcsrc/common/mapobjects/trigger/teleport.qc | 4 ++++ qcsrc/common/mapobjects/trigger/teleport.qh | 10 ++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/qcsrc/common/mapobjects/teleporters.qc b/qcsrc/common/mapobjects/teleporters.qc index c8f9ad245..b9698446c 100644 --- a/qcsrc/common/mapobjects/teleporters.qc +++ b/qcsrc/common/mapobjects/teleporters.qc @@ -223,9 +223,11 @@ entity Simple_TeleportPlayer(entity teleporter, entity player) if(vdist(player.velocity, >, e.speed)) player.velocity = normalize(player.velocity) * max(0, e.speed); - if(STAT(TELEPORT_MAXSPEED, player)) - if(vdist(player.velocity, >, STAT(TELEPORT_MAXSPEED, player))) - player.velocity = normalize(player.velocity) * max(0, STAT(TELEPORT_MAXSPEED, player)); + if(!(teleporter.classname == "trigger_teleport" && teleporter.spawnflags & TELEPORT_KEEP_SPEED) && + !(teleporter.classname == "target_teleporter" && teleporter.spawnflags & TARGET_TELEPORTER_KEEP_SPEED)) + if(STAT(TELEPORT_MAXSPEED, player)) + if(vdist(player.velocity, >, STAT(TELEPORT_MAXSPEED, player))) + player.velocity = normalize(player.velocity) * max(0, STAT(TELEPORT_MAXSPEED, player)); locout = e.origin + '0 0 1' * (1 - player.mins.z - 24); diff --git a/qcsrc/common/mapobjects/trigger/teleport.qc b/qcsrc/common/mapobjects/trigger/teleport.qc index ae82a82c1..0ac4559cc 100644 --- a/qcsrc/common/mapobjects/trigger/teleport.qc +++ b/qcsrc/common/mapobjects/trigger/teleport.qc @@ -39,6 +39,10 @@ bool Teleport_Active(entity this, entity player) if(((this.spawnflags & INVERT_TEAMS) == 0) == (DIFF_TEAM(this, player))) return false; + // no need to call IS_OBSERVER(), observers never call use/touch functions which means this is never an observer + if(this.classname == "trigger_teleport" && this.spawnflags & TELEPORT_OBSERVERS_ONLY) + return false; + return true; } diff --git a/qcsrc/common/mapobjects/trigger/teleport.qh b/qcsrc/common/mapobjects/trigger/teleport.qh index 6f70f09be..de707eba0 100644 --- a/qcsrc/common/mapobjects/trigger/teleport.qh +++ b/qcsrc/common/mapobjects/trigger/teleport.qh @@ -1 +1,11 @@ #pragma once + + +// q3df compat spawnflags, they may also be useful in xonotic + +// trigger_teleport +#define TELEPORT_OBSERVERS_ONLY BIT(0) // named SPECTATOR in q3df, exists in q3 but is only documented in q3df +#define TELEPORT_KEEP_SPEED BIT(1) + +// target_teleporter +#define TARGET_TELEPORTER_KEEP_SPEED BIT(0) -- 2.39.2