]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/misc/teleport_dest.qc
Predict teleporters (yay)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / misc / teleport_dest.qc
1 REGISTER_NET_LINKED(ENT_CLIENT_TELEPORT_DEST)
2
3 #ifdef SVQC
4
5 bool teleport_dest_send(entity this, entity to, float sf)
6 {
7         WriteHeader(MSG_ENTITY, ENT_CLIENT_TELEPORT_DEST);
8
9         WriteByte(MSG_ENTITY, self.cnt);
10         WriteCoord(MSG_ENTITY, self.speed);
11         WriteString(MSG_ENTITY, self.targetname);
12         WriteCoord(MSG_ENTITY, self.origin_x);
13         WriteCoord(MSG_ENTITY, self.origin_y);
14         WriteCoord(MSG_ENTITY, self.origin_z);
15
16         WriteAngle(MSG_ENTITY, self.mangle_x);
17         WriteAngle(MSG_ENTITY, self.mangle_y);
18         WriteAngle(MSG_ENTITY, self.mangle_z);
19
20         return true;
21 }
22
23 void teleport_dest_link()
24 {SELFPARAM();
25         Net_LinkEntity(self, false, 0, teleport_dest_send);
26         //self.SendFlags |= 1; // update
27 }
28
29 spawnfunc(info_teleport_destination)
30 {
31         self.classname = "info_teleport_destination";
32
33         self.mangle = self.angles;
34         self.angles = '0 0 0';
35
36         //setorigin (self, self.origin + '0 0 27');     // To fix a mappers' habit as old as Quake
37         setorigin (self, self.origin);
38
39         IFTARGETED
40         {
41         }
42         else
43                 objerror ("^3Teleport destination without a targetname");
44
45         teleport_dest_link();
46 }
47
48 spawnfunc(misc_teleporter_dest)
49 {
50         spawnfunc_info_teleport_destination(this);
51 }
52
53 spawnfunc(target_teleporter)
54 {
55         spawnfunc_info_teleport_destination(this);
56 }
57
58 #elif defined(CSQC)
59
60 void teleport_dest_remove()
61 {SELFPARAM();
62         //if(self.classname)
63                 //strunzone(self.classname);
64         //self.classname = string_null;
65
66         if(self.targetname)
67                 strunzone(self.targetname);
68         self.targetname = string_null;
69 }
70
71 NET_HANDLE(ENT_CLIENT_TELEPORT_DEST, bool isnew)
72 {
73         self.classname = "info_teleport_destination";
74         self.cnt = ReadByte();
75         self.speed = ReadCoord();
76         self.targetname = strzone(ReadString());
77         self.origin_x = ReadCoord();
78         self.origin_y = ReadCoord();
79         self.origin_z = ReadCoord();
80
81         self.mangle_x = ReadAngle();
82         self.mangle_y = ReadAngle();
83         self.mangle_z = ReadAngle();
84
85         return = true;
86
87         setorigin(self, self.origin);
88
89         self.drawmask = MASK_NORMAL;
90         self.entremove = teleport_dest_remove;
91 }
92
93 #endif