Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
teleport.qc File Reference
#include "teleport.qh"
Include dependency graph for teleport.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 spawnfunc (target_teleporter)
 spawnfunc (trigger_teleport)
void target_teleport_use (entity this, entity actor, entity trigger)
void target_teleporter_checktarget (entity this)
bool Teleport_Active (entity this, entity player)
void Teleport_Touch (entity this, entity toucher)
void trigger_teleport_link (entity this)
float trigger_teleport_send (entity this, entity to, float sf)
void trigger_teleport_use (entity this, entity actor, entity trigger)

Function Documentation

◆ spawnfunc() [1/2]

spawnfunc ( target_teleporter )

Definition at line 187 of file teleport.qc.

188{
190}
const int INITPRIO_FINDTARGET
Definition constants.qh:96
void target_teleporter_checktarget(entity this)
Definition teleport.qc:142
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2230

References InitializeEntity(), INITPRIO_FINDTARGET, and target_teleporter_checktarget().

◆ spawnfunc() [2/2]

spawnfunc ( trigger_teleport )

Definition at line 119 of file teleport.qc.

120{
121 this.angles = '0 0 0';
122
123 this.active = ACTIVE_ACTIVE;
126
127 if(this.noise != "")
128 FOREACH_WORD(this.noise, true, precache_sound(it));
129
130 // this must be called to spawn the teleport waypoints for bots
132
133 if (!this.target || this.target == "")
134 {
135 objerror (this, "Teleporter with no target");
136 return;
137 }
138
139 IL_PUSH(g_teleporters, this);
140}
#define use
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
ent angles
Definition ent_cs.qc:121
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define FOREACH_WORD(words, cond, body)
Definition iter.qh:33
#define EXACTTRIGGER_INIT
Definition common.qh:116
string precache_sound(string sample)
#define objerror
Definition pre.qh:8
string noise
Definition subs.qh:83
void teleport_findtarget(entity this)
void trigger_teleport_use(entity this, entity actor, entity trigger)
Definition teleport.qc:5
IntrusiveList g_teleporters
string target
Definition triggers.qh:55

References active, ACTIVE_ACTIVE, angles, EXACTTRIGGER_INIT, FOREACH_WORD, g_teleporters, IL_PUSH(), InitializeEntity(), INITPRIO_FINDTARGET, noise, objerror, precache_sound(), target, teleport_findtarget(), trigger_teleport_use(), and use.

◆ target_teleport_use()

void target_teleport_use ( entity this,
entity actor,
entity trigger )

Definition at line 75 of file teleport.qc.

76{
77 entity player = actor;
78
79 if(!Teleport_Active(this, player))
80 return;
81
82 if(IS_PLAYER(player))
84
85 entity e = Simple_TeleportPlayer(this, player);
86
87 string s = this.target; this.target = string_null;
88 SUB_UseTargets(this, player, player); // TODO: should we be using toucher for trigger too?
89 if (!this.target)
90 {
91 this.target = s;
92 }
93
94 if(e != this) // only activate the target teleporter if target is different
95 SUB_UseTargets(e, player, player);
96}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define IS_PLAYER(s)
Definition player.qh:242
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition triggers.qc:344
string string_null
Definition nil.qh:9
void RemoveGrapplingHooks(entity pl)
Definition hook.qc:30
bool Teleport_Active(entity this, entity player)
Definition teleport.qc:15
entity Simple_TeleportPlayer(entity teleporter, entity player)

References entity(), IS_PLAYER, RemoveGrapplingHooks(), Simple_TeleportPlayer(), string_null, SUB_UseTargets(), target, and Teleport_Active().

Referenced by target_teleporter_checktarget().

◆ target_teleporter_checktarget()

void target_teleporter_checktarget ( entity this)

Definition at line 142 of file teleport.qc.

143{
144 // target_teleporter is used in many strange ways
145 // we must attempt to figure out which way it is being used for in this instance
146
147 if(!this.target || this.target == "")
148 {
149 // this target_teleporter has no target
150 // so it must be either a destination for a teleporter or a teleporter itself
151 bool is_teleporter_target = false;
152 // NOTE: target2, target3, target4 unsupported, this may not be necessary as DeFrag maps have no such targets
154 {
155 if(it.classname == "trigger_teleport" || it.classname == "target_teleporter")
156 {
157 is_teleporter_target = true;
158 break; // no need to keep looping once a valid target is found
159 }
160 });
161
162 if(is_teleporter_target)
163 {
164 // there were teleporters found targeting this, so it must be a destination!
165 spawnfunc_info_teleport_destination(this);
166 return;
167 }
168
169 // set this entity up to be a teleporter, since it can be activated as one
170 this.enemy = this;
171 this.mangle = this.angles;
172 this.angles = '0 0 0';
173 }
174
175 // seeing as this entity isn't targeted by a teleporter, it must be a teleporter itself
176
177 this.active = ACTIVE_ACTIVE;
179
180 if(this.noise && this.noise != "")
181 FOREACH_WORD(this.noise, true, precache_sound(it));
182
183 if(this.target && this.target != "") // no need to find a target on this entity, as it does not have one and .enemy is already set as required
185}
#define FOREACH_ENTITY_STRING(fld, match, body)
Definition iter.qh:184
vector mangle
Definition subs.qh:51
entity enemy
Definition sv_ctf.qh:153
void target_teleport_use(entity this, entity actor, entity trigger)
Definition teleport.qc:75
string targetname
Definition triggers.qh:56

References active, ACTIVE_ACTIVE, angles, enemy, entity(), FOREACH_ENTITY_STRING, FOREACH_WORD, mangle, noise, precache_sound(), target, target_teleport_use(), targetname, teleport_findtarget(), and use.

Referenced by spawnfunc().

◆ Teleport_Active()

bool Teleport_Active ( entity this,
entity player )

Definition at line 15 of file teleport.qc.

16{
17 if (this.active != ACTIVE_ACTIVE)
18 return false;
19
20#ifdef SVQC
21 if (!player.teleportable)
22 return false;
23
24 if(player.vehicle)
25 if(!player.vehicle.teleportable)
26 return false;
27
28 if(IS_TURRET(player))
29 return false;
30#elif defined(CSQC)
31 if(!IS_PLAYER(player))
32 return false;
33#endif
34
35 if(IS_DEAD(player))
36 return false;
37
38 if(this.team)
39 if(((this.spawnflags & INVERT_TEAMS) == 0) == (DIFF_TEAM(this, player)))
40 return false;
41
42 // no need to call IS_OBSERVER(), observers never call use/touch functions which means this is never an observer
43 if(this.classname == "trigger_teleport" && (this.spawnflags & TELEPORT_OBSERVERS_ONLY))
44 return false;
45
46 return true;
47}
int team
Definition main.qh:188
int spawnflags
Definition ammo.qh:15
#define IS_DEAD(s)
Definition player.qh:244
string classname
const int INVERT_TEAMS
Definition defs.qh:10
#define DIFF_TEAM(a, b)
Definition teams.qh:242
#define TELEPORT_OBSERVERS_ONLY
Definition teleport.qh:7
#define IS_TURRET(v)
Definition utils.qh:25

References active, ACTIVE_ACTIVE, classname, DIFF_TEAM, entity(), INVERT_TEAMS, IS_DEAD, IS_PLAYER, IS_TURRET, spawnflags, team, and TELEPORT_OBSERVERS_ONLY.

Referenced by target_teleport_use(), and Teleport_Touch().

◆ Teleport_Touch()

void Teleport_Touch ( entity this,
entity toucher )

Definition at line 49 of file teleport.qc.

50{
51 entity player = toucher;
52
53 if(!Teleport_Active(this, player))
54 return;
55
56 EXACTTRIGGER_TOUCH(this, player);
57
58#ifdef SVQC
59 if(IS_PLAYER(player))
61#endif
62
63 noref entity e = Simple_TeleportPlayer(this, player);
64
65#ifdef SVQC
66 string s = this.target; this.target = string_null;
67 SUB_UseTargets(this, player, player); // TODO: should we be using toucher for trigger too?
68 if (!this.target) this.target = s;
69
70 SUB_UseTargets(e, player, player);
71#endif
72}
#define EXACTTRIGGER_TOUCH(e, t)
Definition common.qh:115
entity entity toucher
Definition self.qh:72

References entity(), EXACTTRIGGER_TOUCH, IS_PLAYER, RemoveGrapplingHooks(), Simple_TeleportPlayer(), string_null, SUB_UseTargets(), target, Teleport_Active(), and toucher.

Referenced by teleport_findtarget().

◆ trigger_teleport_link()

void trigger_teleport_link ( entity this)

Definition at line 114 of file teleport.qc.

115{
116 //trigger_link(this, trigger_teleport_send);
117}

References entity().

Referenced by teleport_findtarget().

◆ trigger_teleport_send()

float trigger_teleport_send ( entity this,
entity to,
float sf )

Definition at line 100 of file teleport.qc.

101{
102 WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_TELEPORT);
103
105 WriteInt24_t(MSG_ENTITY, this.spawnflags);
108
109 trigger_common_write(this, true);
110
111 return true;
112}
float speed
Definition dynlight.qc:9
const int MSG_ENTITY
Definition net.qh:156
#define WriteHeader(to, id)
Definition net.qh:265
void WriteCoord(float data, float dest, float desto)
void WriteByte(float data, float dest, float desto)
void trigger_common_write(entity this, bool withtarget)
Definition triggers.qc:110

References active, entity(), MSG_ENTITY, spawnflags, speed, team, trigger_common_write(), WriteByte(), WriteCoord(), and WriteHeader.

◆ trigger_teleport_use()

void trigger_teleport_use ( entity this,
entity actor,
entity trigger )

Definition at line 5 of file teleport.qc.

6{
7 if(teamplay)
8 this.team = actor.team;
9#ifdef SVQC
11#endif
12}
const int SF_TRIGGER_UPDATE
Definition defs.qh:23
int SendFlags
Definition net.qh:159
bool teamplay
Definition teams.qh:59

References entity(), SendFlags, SF_TRIGGER_UPDATE, team, and teamplay.

Referenced by spawnfunc().