]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/trigger/teleport.qc
Merge branch 'master' into terencehill/menu_hudskin_selector
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / teleport.qc
1 REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_TELEPORT)
2
3 #ifdef SVQC
4 void trigger_teleport_use()
5 {SELFPARAM();
6         if(teamplay)
7                 self.team = activator.team;
8 #ifdef SVQC
9         self.SendFlags |= SF_TRIGGER_UPDATE;
10 #endif
11 }
12 #endif
13
14 void Teleport_Touch ()
15 {SELFPARAM();
16         if (self.active != ACTIVE_ACTIVE)
17                 return;
18
19 #ifdef SVQC
20         if (!other.teleportable)
21                 return;
22
23         if(other.vehicle)
24         if(!other.vehicle.teleportable)
25                 return;
26
27         if(IS_TURRET(other))
28                 return;
29 #endif
30
31         if(PHYS_DEAD(other))
32                 return;
33
34         if(self.team)
35                 if(((self.spawnflags & 4) == 0) == (DIFF_TEAM(this, other)))
36                         return;
37
38         EXACTTRIGGER_TOUCH;
39
40 #ifdef SVQC
41         if(IS_PLAYER(other))
42                 RemoveGrapplingHook(other);
43 #endif
44
45         entity e;
46         e = Simple_TeleportPlayer(self, other);
47
48 #ifdef SVQC
49         activator = other;
50         string s = self.target; self.target = string_null;
51         SUB_UseTargets();
52         if (!self.target) self.target = s;
53
54         WITH(entity, self, e, SUB_UseTargets());
55 #endif
56 }
57
58 #ifdef SVQC
59 float trigger_teleport_send(entity this, entity to, float sf)
60 {
61         WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_TELEPORT);
62
63         WriteByte(MSG_ENTITY, this.team);
64         WriteInt24_t(MSG_ENTITY, this.spawnflags);
65         WriteByte(MSG_ENTITY, this.active);
66         WriteCoord(MSG_ENTITY, this.speed);
67
68         trigger_common_write(this, true);
69
70         return true;
71 }
72
73 void trigger_teleport_link(entity this)
74 {
75         trigger_link(this, trigger_teleport_send);
76 }
77
78 spawnfunc(trigger_teleport)
79 {
80         self.angles = '0 0 0';
81
82         self.active = ACTIVE_ACTIVE;
83         trigger_init(self);
84         self.use = trigger_teleport_use;
85
86         // this must be called to spawn the teleport waypoints for bots
87         InitializeEntity(self, teleport_findtarget, INITPRIO_FINDTARGET);
88
89         if (self.target == "")
90         {
91                 objerror ("Teleporter with no target");
92                 return;
93         }
94
95         self.teleport_next = teleport_first;
96         teleport_first = self;
97 }
98 #elif defined(CSQC)
99 NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew)
100 {
101         self.classname = "trigger_teleport";
102         int mytm = ReadByte(); if(mytm) { self.team = mytm - 1; }
103         self.spawnflags = ReadInt24_t();
104         self.active = ReadByte();
105         self.speed = ReadCoord();
106
107         trigger_common_read(true);
108
109         self.entremove = trigger_remove_generic;
110         self.solid = SOLID_TRIGGER;
111         //self.draw = trigger_draw_generic;
112         //self.move_touch = trigger_push_touch;
113         self.drawmask = MASK_NORMAL;
114         self.move_time = time;
115         defer(self, 0.25, teleport_findtarget);
116
117         self.teleport_next = teleport_first;
118         teleport_first = self;
119
120         return true;
121 }
122
123 #endif