Xonotic
teleporters.qh File Reference
#include "defs.qh"
+ Include dependency graph for teleporters.qh:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TELEPORT_FLAGS_PORTAL   (TELEPORT_FLAG_SOUND | TELEPORT_FLAG_PARTICLES | TELEPORT_FLAG_TDEATH | TELEPORT_FLAG_FORCE_TDEATH)
 
#define TELEPORT_FLAGS_TELEPORTER   (TELEPORT_FLAG_SOUND | TELEPORT_FLAG_PARTICLES | TELEPORT_FLAG_TDEATH)
 
#define TELEPORT_FLAGS_WARPZONE   0
 

Functions

entity Simple_TeleportPlayer (entity teleporter, entity player)
 
 STATIC_INIT (g_teleporters)
 
entity Teleport_Find (vector mi, vector ma)
 
void teleport_findtarget (entity this)
 
void Teleport_Touch (entity this, entity toucher)
 
void TeleportPlayer (entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags)
 
void WarpZone_PostTeleportPlayer_Callback (entity pl)
 

Variables

IntrusiveList g_teleporters
 
entity pusher
 
const int TELEPORT_FLAG_FORCE_TDEATH = BIT(3)
 
const int TELEPORT_FLAG_PARTICLES = BIT(1)
 
const int TELEPORT_FLAG_SOUND = BIT(0)
 
const int TELEPORT_FLAG_TDEATH = BIT(2)
 
const int TELEPORT_NORMAL = 1
 
const int TELEPORT_SIMPLE = 2
 
float teleportable
 

Macro Definition Documentation

◆ TELEPORT_FLAGS_PORTAL

Definition at line 21 of file teleporters.qh.

Referenced by Portal_TeleportPlayer().

◆ TELEPORT_FLAGS_TELEPORTER

#define TELEPORT_FLAGS_TELEPORTER   (TELEPORT_FLAG_SOUND | TELEPORT_FLAG_PARTICLES | TELEPORT_FLAG_TDEATH)

Definition at line 22 of file teleporters.qh.

Referenced by Simple_TeleportPlayer().

◆ TELEPORT_FLAGS_WARPZONE

#define TELEPORT_FLAGS_WARPZONE   0

Definition at line 20 of file teleporters.qh.

Function Documentation

◆ Simple_TeleportPlayer()

entity Simple_TeleportPlayer ( entity  teleporter,
entity  player 
)

Definition at line 180 of file teleporters.qc.

References entity(), FOREACH_ENTITY_STRING, LOG_INFO, makevectors, max(), normalize(), NULL, RandomSelection_AddEnt, RandomSelection_chosen_ent, RandomSelection_Init(), sprint(), targetname, TELEPORT_FLAGS_TELEPORTER, TeleportPlayer(), v_forward, vdist, vector(), and vlen().

Referenced by CheatCommand(), Teleport_Touch(), and WarpZone_Projectile_Touch().

181 {
182  vector locout;
183  entity e = NULL;
184 
185  // Find the output teleporter
186  if(teleporter.enemy)
187  {
188  e = teleporter.enemy;
189  }
190  else
191  {
192  // sorry CSQC, random stuff ain't gonna happen
193 #ifdef SVQC
195  FOREACH_ENTITY_STRING(targetname, teleporter.target,
196  {
197  bool p = true;
198  if(STAT(TELEPORT_TELEFRAG_AVOID, player))
199  {
200  #ifdef SVQC
201  locout = it.origin + '0 0 1' * (1 - player.mins.z - 24);
202  #elif defined(CSQC)
203  locout = it.origin + '0 0 1' * (1 - player.mins.z - 24);
204  #endif
205  if(check_tdeath(player, locout, '0 0 0', '0 0 0'))
206  p = false;
207  }
208  RandomSelection_AddEnt(it, (it.cnt ? it.cnt : 1), p);
209  });
211 #endif
212  }
213 
214 #ifdef SVQC
215  if(!e) { sprint(player, "Teleport destination vanished. Sorry... please complain to the mapper.\n"); }
216 #elif defined(CSQC)
217  if(!e) { LOG_INFO("Teleport destination could not be found from CSQC."); }
218 #endif
219 
220  makevectors(e.mangle);
221 
222  if(e.speed)
223  if(vdist(player.velocity, >, e.speed))
224  player.velocity = normalize(player.velocity) * max(0, e.speed);
225 
226  if(STAT(TELEPORT_MAXSPEED, player))
227  if(vdist(player.velocity, >, STAT(TELEPORT_MAXSPEED, player)))
228  player.velocity = normalize(player.velocity) * max(0, STAT(TELEPORT_MAXSPEED, player));
229 
230  locout = e.origin + '0 0 1' * (1 - player.mins.z - 24);
231 
232  TeleportPlayer(teleporter, player, locout, e.mangle, v_forward * vlen(player.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
233 
234  return e;
235 }
ERASEABLE void RandomSelection_Init()
Definition: random.qc:4
entity() spawn
#define FOREACH_ENTITY_STRING(fld, match, body)
Definition: iter.qh:184
#define RandomSelection_AddEnt(e, weight, priority)
Definition: random.qh:14
entity RandomSelection_chosen_ent
Definition: random.qh:5
#define NULL
Definition: post.qh:17
#define TELEPORT_FLAGS_TELEPORTER
Definition: teleporters.qh:22
#define LOG_INFO(...)
Definition: log.qh:70
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
Definition: vector.qh:8
string targetname
Definition: progsdefs.qc:194
void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags)
Definition: teleporters.qc:67
#define makevectors
Definition: post.qh:21
vector v_forward
Definition: csprogsdefs.qc:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ STATIC_INIT()

STATIC_INIT ( g_teleporters  )

Definition at line 11 of file teleporters.qh.

References IL_NEW.

11 { g_teleporters = IL_NEW(); }
IntrusiveList g_teleporters
Definition: teleporters.qh:10
#define IL_NEW()

◆ Teleport_Find()

entity Teleport_Find ( vector  mi,
vector  ma 
)

Definition at line 285 of file teleporters.qc.

References g_teleporters, IL_EACH, NULL, and WarpZoneLib_BoxTouchesBrush().

Referenced by WarpZone_Projectile_Touch().

286 {
288  {
289  return it;
290  });
291  return NULL;
292 }
#define IL_EACH(this, cond, body)
IntrusiveList g_teleporters
Definition: teleporters.qh:10
float WarpZoneLib_BoxTouchesBrush(vector mi, vector ma, entity e, entity ig)
Definition: common.qc:138
#define NULL
Definition: post.qh:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ teleport_findtarget()

void teleport_findtarget ( entity  this)

Definition at line 237 of file teleporters.qc.

References DPCONTENTS_BODY, DPCONTENTS_BOTCLIP, DPCONTENTS_PLAYERCLIP, DPCONTENTS_SOLID, enemy, entity(), find(), LOG_INFO, MOVETYPE_NONE, NULL, objerror(), solid, SOLID_TRIGGER, spawn(), target, targetname, Teleport_Touch(), and waypoint_spawnforteleporter().

Referenced by CheatCommand(), and Teleport_Touch().

238 {
239  bool istrigger = (this.solid == SOLID_TRIGGER);
240 
241  int n = 0;
242  for(entity e = NULL; (e = find(e, targetname, this.target)); )
243  {
244  ++n;
245 #ifdef SVQC
246  if(e.move_movetype == MOVETYPE_NONE)
247  {
248  entity tracetest_ent = spawn();
249  setsize(tracetest_ent, PL_MIN_CONST, PL_MAX_CONST);
250  tracetest_ent.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
251  waypoint_spawnforteleporter(this, e.origin, 0, tracetest_ent);
252  delete(tracetest_ent);
253  }
254  if(e.classname != "info_teleport_destination")
255  LOG_INFO("^3MAPPER ERROR: teleporter does target an invalid teleport destination entity. Angles will not work.");
256 #endif
257  }
258 
259  if(n == 0)
260  {
261  // no dest!
262  objerror (this, "Teleporter with nonexistent target");
263  return;
264  }
265  else if(n == 1)
266  {
267  // exactly one dest - bots love that
268  this.enemy = find(NULL, targetname, this.target);
269  }
270  else
271  {
272  // have to use random selection every single time
273  this.enemy = NULL;
274  }
275 
276  // now enable touch
277  if(istrigger)
278  settouch(this, Teleport_Touch);
279 #ifdef SVQC
280  if(istrigger)
281  trigger_teleport_link(this);
282 #endif
283 }
float MOVETYPE_NONE
Definition: progsdefs.qc:246
entity() spawn
float DPCONTENTS_BOTCLIP
float DPCONTENTS_PLAYERCLIP
entity enemy
Definition: sv_ctf.qh:143
#define NULL
Definition: post.qh:17
#define LOG_INFO(...)
Definition: log.qh:70
float DPCONTENTS_SOLID
void waypoint_spawnforteleporter(entity e, vector destination, float timetaken, entity tracetest_ent)
Definition: waypoints.qc:2069
float DPCONTENTS_BODY
const float SOLID_TRIGGER
Definition: csprogsdefs.qc:245
string targetname
Definition: progsdefs.qc:194
string target
Definition: progsdefs.qc:193
void Teleport_Touch(entity this, entity toucher)
Definition: teleport.qc:45
float solid
Definition: csprogsdefs.qc:99
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Teleport_Touch()

void Teleport_Touch ( entity  this,
entity  toucher 
)

Definition at line 45 of file teleport.qc.

References active, ACTIVE_ACTIVE, angles, classname, enemy, entity(), EXACTTRIGGER_INIT, EXACTTRIGGER_TOUCH, FOREACH_ENTITY_STRING, FOREACH_WORD, g_teleporters, IL_PUSH(), InitializeEntity(), IS_PLAYER, mangle, move_time, NET_HANDLE, noise, objerror(), precache_sound(), RemoveGrapplingHooks(), Simple_TeleportPlayer(), solid, SOLID_TRIGGER, spawnflags, spawnfunc(), speed, string_null, SUB_UseTargets(), target, targetname, team, Teleport_Active(), teleport_findtarget(), time, to, use, WriteByte(), and WriteCoord().

Referenced by teleport_findtarget().

46 {
47  entity player = toucher;
48 
49  if(!Teleport_Active(this, player))
50  return;
51 
52  EXACTTRIGGER_TOUCH(this, player);
53 
54 #ifdef SVQC
55  if(IS_PLAYER(player))
56  RemoveGrapplingHooks(player);
57 #endif
58 
59  entity e;
60  e = Simple_TeleportPlayer(this, player);
61 
62 #ifdef SVQC
63  string s = this.target; this.target = string_null;
64  SUB_UseTargets(this, player, player); // TODO: should we be using toucher for trigger too?
65  if (!this.target) this.target = s;
66 
67  SUB_UseTargets(e, player, player);
68 #endif
69 }
string string_null
Definition: nil.qh:9
#define EXACTTRIGGER_TOUCH(e, t)
Definition: common.qh:116
entity() spawn
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition: triggers.qc:366
entity Simple_TeleportPlayer(entity teleporter, entity player)
Definition: teleporters.qc:180
void RemoveGrapplingHooks(entity pl)
Definition: hook.qc:78
bool Teleport_Active(entity this, entity player)
Definition: teleport.qc:15
string target
Definition: progsdefs.qc:193
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TeleportPlayer()

void TeleportPlayer ( entity  teleporter,
entity  player,
vector  to,
vector  to_angles,
vector  to_velocity,
vector  telefragmin,
vector  telefragmax,
float  tflags 
)

Definition at line 67 of file teleporters.qc.

References _sound, ATTEN_NORM, autocvar_g_maxpushtime, BITXOR_ASSIGN, bot_aim_reset(), CH_TRIGGER, csqcplayer, EF_TELEPORT_BIT, entity(), FOREACH_WORD, g_cts, g_race, IFLAG_ANGLES, IFLAG_TELEPORTED, IFLAG_V_ANGLE, IS_BOT_CLIENT, IS_DEAD, IS_PLAYER, makevectors, PHYS_INPUT_BUTTON_CHAT, RandomSelection_chosen_string, RandomSelection_Init(), Reset_ArcBeam(), round_handler_IsActive, round_handler_IsRoundStarted, setorigin(), SND, TELEPORT_FLAG_FORCE_TDEATH, TELEPORT_FLAG_PARTICLES, TELEPORT_FLAG_SOUND, TELEPORT_FLAG_TDEATH, TELEPORT_NORMAL, time, to, UNSET_ONGROUND, UpdateCSQCProjectileAfterTeleport(), UpdateItemAfterTeleport(), v_forward, vector(), VF_ANGLES, VF_CL_VIEWANGLES, and VOL_BASE.

Referenced by Portal_TeleportPlayer(), and Simple_TeleportPlayer().

68 {
69  entity telefragger;
70  vector from;
71 
72  if(teleporter.owner)
73  telefragger = teleporter.owner;
74  else
75  telefragger = player;
76 
77  makevectors (to_angles);
78 
79 #ifdef SVQC
80  if(player.teleportable == TELEPORT_NORMAL) // don't play sounds or show particles for anything that isn't a player, maybe change later to block only observers
81  {
82  if(teleporter.pushltime < time) // only show one teleport effect per teleporter per 0.2 seconds, for better fps
83  {
84  if(tflags & TELEPORT_FLAG_SOUND)
85  {
86  string thesound = SND(TELEPORT);
87  if(teleporter.noise != "")
88  {
90  FOREACH_WORD(teleporter.noise, true,
91  {
92  RandomSelection_AddString(it, 1, 1);
93  });
95  }
96  _sound (player, CH_TRIGGER, thesound, VOL_BASE, ATTEN_NORM);
97  }
98  if(tflags & TELEPORT_FLAG_PARTICLES)
99  {
100  Send_Effect(EFFECT_TELEPORT, player.origin, '0 0 0', 1);
101  Send_Effect(EFFECT_TELEPORT, to + v_forward * 32, '0 0 0', 1);
102  }
103  teleporter.pushltime = time + 0.2;
104  }
105  }
106 #endif
107 
108  // Relocate the player
109  // assuming to allows PL_MIN to PL_MAX box and some more
110 #ifdef SVQC
111  from = player.origin;
112  setorigin(player, to);
113  player.oldorigin = to; // don't undo the teleport by unsticking
114  player.angles = to_angles;
115  if (IS_BOT_CLIENT(player))
116  {
117  player.v_angle = player.angles;
118  bot_aim_reset(player);
119  }
120  player.fixangle = true;
121  player.velocity = to_velocity;
122  BITXOR_ASSIGN(player.effects, EF_TELEPORT_BIT);
123 
124  makevectors(player.angles);
125  Reset_ArcBeam(player, v_forward);
127  UpdateItemAfterTeleport(player);
128 #elif defined(CSQC)
129  from = player.origin;
130  setorigin(player, to);
131  player.angles = to_angles;
132  player.velocity = to_velocity;
133  UNSET_ONGROUND(player);
134  player.iflags |= IFLAG_TELEPORTED | IFLAG_V_ANGLE | IFLAG_ANGLES;
135  player.csqcmodel_teleported = 1;
136  player.v_angle = to_angles;
137 
138  if(player == csqcplayer) // not for anything but the main player
139  {
140  setproperty(VF_ANGLES, player.angles);
141  setproperty(VF_CL_VIEWANGLES, player.angles);
142  }
143 #endif
144 
145 #ifdef SVQC
146  if(IS_PLAYER(player))
147  {
148  if((tflags & TELEPORT_FLAG_TDEATH) && player.takedamage && !IS_DEAD(player)
149  && !g_race && !g_cts && (autocvar_g_telefrags || (tflags & TELEPORT_FLAG_FORCE_TDEATH))
151  {
152  tdeath(player, teleporter, telefragger, telefragmin, telefragmax);
153  }
154 
155  // player no longer is on ground
156  UNSET_ONGROUND(player);
157 
158  // reset tracking of oldvelocity for impact damage (sudden velocity changes)
159  player.oldvelocity = player.velocity;
160 
161  // reset tracking of who pushed you into a hazard (for kill credit)
162  if(teleporter.owner)
163  {
164  player.pusher = teleporter.owner;
165  player.pushltime = time + autocvar_g_maxpushtime;
166  player.istypefrag = PHYS_INPUT_BUTTON_CHAT(player);
167  }
168  else
169  {
170  player.pushltime = 0;
171  player.istypefrag = 0;
172  }
173 
174  player.lastteleporttime = time;
175  player.lastteleport_origin = from;
176  }
177 #endif
178 }
#define round_handler_IsActive()
#define PHYS_INPUT_BUTTON_CHAT(s)
Definition: player.qh:155
const int TELEPORT_FLAG_TDEATH
Definition: teleporters.qh:17
string RandomSelection_chosen_string
Definition: random.qh:7
#define SND(id)
Definition: all.qh:35
const float VF_CL_VIEWANGLES
Definition: csprogsdefs.qc:194
const int TELEPORT_NORMAL
Definition: teleporters.qh:26
void bot_aim_reset(entity this)
Definition: aim.qc:170
ERASEABLE void RandomSelection_Init()
Definition: random.qc:4
entity() spawn
entity to
Definition: self.qh:96
#define round_handler_IsRoundStarted()
const int IFLAG_V_ANGLE
Definition: interpolate.qh:34
#define UNSET_ONGROUND(s)
Definition: movetypes.qh:18
float autocvar_g_maxpushtime
Definition: damage.qh:17
#define FOREACH_WORD(words, cond, body)
Definition: iter.qh:33
const int EF_TELEPORT_BIT
void Reset_ArcBeam()
#define g_cts
Definition: cts.qh:36
#define g_race
Definition: race.qh:46
const int CH_TRIGGER
Definition: sound.qh:12
const float VOL_BASE
Definition: sound.qh:36
void UpdateItemAfterTeleport(entity this)
Definition: items.qc:92
#define IS_DEAD(s)
Definition: utils.qh:26
const float ATTEN_NORM
Definition: sound.qh:30
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const int IFLAG_TELEPORTED
Definition: interpolate.qh:32
const float VF_ANGLES
Definition: csprogsdefs.qc:186
#define _sound(e, c, s, v, a)
Definition: sound.qh:50
const int TELEPORT_FLAG_SOUND
Definition: teleporters.qh:15
#define IS_BOT_CLIENT(v)
want: (IS_CLIENT(v) && !IS_REAL_CLIENT(v))
Definition: utils.qh:15
setorigin(ent, v)
void UpdateCSQCProjectileAfterTeleport(entity e)
entity csqcplayer
Definition: cl_player.qh:26
#define BITXOR_ASSIGN(a, b)
Definition: common.qh:107
const int TELEPORT_FLAG_PARTICLES
Definition: teleporters.qh:16
const int TELEPORT_FLAG_FORCE_TDEATH
Definition: teleporters.qh:18
float time
Definition: csprogsdefs.qc:16
#define makevectors
Definition: post.qh:21
const int IFLAG_ANGLES
Definition: interpolate.qh:28
#define IS_PLAYER(v)
Definition: utils.qh:9
vector v_forward
Definition: csprogsdefs.qc:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WarpZone_PostTeleportPlayer_Callback()

void WarpZone_PostTeleportPlayer_Callback ( entity  pl)

Definition at line 294 of file teleporters.qc.

References anticheat_fixangle(), BIT, IS_PLAYER, LOG_INFO, makevectors, NULL, Reset_ArcBeam(), UpdateCSQCProjectileAfterTeleport(), UpdateItemAfterTeleport(), and v_forward.

Referenced by WarpZone_TeleportPlayer().

295 {
296 #ifdef SVQC
297  makevectors(pl.angles);
301  if (IS_PLAYER(pl)) anticheat_fixangle(pl);
302 #endif
303  // "disown" projectiles after teleport
304  if(pl.owner)
305  if(pl.owner == pl.realowner)
306  {
307  #ifdef SVQC
308  if(!(pl.flags & FL_PROJECTILE))
309  #elif defined(CSQC)
310  if(!(pl.flags & BIT(15))) // FL_PROJECTILE
311  #endif
312  LOG_INFO("A non-projectile got through a warpzone and its owner cleared. It's a ", pl.classname, ".");
313  pl.owner = NULL;
314  }
315  if(IS_PLAYER(pl))
316  {
317  // reset tracking of oldvelocity for impact damage (sudden velocity changes)
318  #ifdef SVQC
319  pl.oldvelocity = pl.velocity;
320  #endif
321  }
322 }
void Reset_ArcBeam()
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition: bits.qh:8
void anticheat_fixangle(entity this)
Definition: anticheat.qc:229
#define NULL
Definition: post.qh:17
#define LOG_INFO(...)
Definition: log.qh:70
void UpdateItemAfterTeleport(entity this)
Definition: items.qc:92
void UpdateCSQCProjectileAfterTeleport(entity e)
#define makevectors
Definition: post.qh:21
#define IS_PLAYER(v)
Definition: utils.qh:9
vector v_forward
Definition: csprogsdefs.qc:31
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ g_teleporters

IntrusiveList g_teleporters

Definition at line 10 of file teleporters.qh.

Referenced by havocbot_moveto(), Teleport_Find(), and Teleport_Touch().

◆ pusher

entity pusher

Definition at line 13 of file teleporters.qh.

Referenced by football_touch(), InitBall(), PlayerDamage(), and UpdatePlayerSounds().

◆ TELEPORT_FLAG_FORCE_TDEATH

const int TELEPORT_FLAG_FORCE_TDEATH = BIT(3)

Definition at line 18 of file teleporters.qh.

Referenced by TeleportPlayer().

◆ TELEPORT_FLAG_PARTICLES

const int TELEPORT_FLAG_PARTICLES = BIT(1)

Definition at line 16 of file teleporters.qh.

Referenced by TeleportPlayer().

◆ TELEPORT_FLAG_SOUND

const int TELEPORT_FLAG_SOUND = BIT(0)

Definition at line 15 of file teleporters.qh.

Referenced by TeleportPlayer().

◆ TELEPORT_FLAG_TDEATH

const int TELEPORT_FLAG_TDEATH = BIT(2)

Definition at line 17 of file teleporters.qh.

Referenced by TeleportPlayer().

◆ TELEPORT_NORMAL

const int TELEPORT_NORMAL = 1

Definition at line 26 of file teleporters.qh.

Referenced by ctf_FlagSetup(), PutPlayerInServer(), TeleportPlayer(), and vehicles_exit().

◆ TELEPORT_SIMPLE

const int TELEPORT_SIMPLE = 2

Definition at line 27 of file teleporters.qh.

Referenced by PlayerDamage(), and PutObserverInServer().

◆ teleportable