1 REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_TELEPORT)
4 void trigger_teleport_use()
7 self.team = activator.team;
9 self.SendFlags |= SF_TRIGGER_UPDATE;
14 void Teleport_Touch ()
16 if (self.active != ACTIVE_ACTIVE)
20 if (!other.teleportable)
24 if(!other.vehicle.teleportable)
35 if(((self.spawnflags & 4) == 0) == (DIFF_TEAM(this, other)))
42 RemoveGrapplingHook(other);
46 e = Simple_TeleportPlayer(self, other);
50 string s = self.target; self.target = string_null;
52 if (!self.target) self.target = s;
54 WITH(entity, self, e, SUB_UseTargets());
59 float trigger_teleport_send(entity to, float sf)
61 WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_TELEPORT);
64 if(self.warpzone_isboxy)
66 if(self.origin != '0 0 0')
68 WriteByte(MSG_ENTITY, f);
72 WriteCoord(MSG_ENTITY, self.origin.x);
73 WriteCoord(MSG_ENTITY, self.origin.y);
74 WriteCoord(MSG_ENTITY, self.origin.z);
77 WriteShort(MSG_ENTITY, self.modelindex);
78 WriteCoord(MSG_ENTITY, self.mins.x);
79 WriteCoord(MSG_ENTITY, self.mins.y);
80 WriteCoord(MSG_ENTITY, self.mins.z);
81 WriteCoord(MSG_ENTITY, self.maxs.x);
82 WriteCoord(MSG_ENTITY, self.maxs.y);
83 WriteCoord(MSG_ENTITY, self.maxs.z);
84 WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
85 WriteByte(MSG_ENTITY, self.team);
86 WriteInt24_t(MSG_ENTITY, self.spawnflags);
87 WriteByte(MSG_ENTITY, self.active);
88 WriteCoord(MSG_ENTITY, self.speed);
90 trigger_common_write(true);
95 void trigger_teleport_link(entity this)
97 this.SendEntity = trigger_teleport_send;
98 this.SendFlags = 0xFFFFFF;
101 spawnfunc(trigger_teleport)
103 self.angles = '0 0 0';
105 string m = self.model;
106 WarpZoneLib_ExactTrigger_Init();
110 _setmodel(self, m); // no precision needed
112 setorigin(self, self.origin);
114 setsize(self, self.mins * self.scale, self.maxs * self.scale);
116 setsize(self, self.mins, self.maxs);
118 self.active = ACTIVE_ACTIVE;
119 BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
120 self.use = trigger_teleport_use;
122 // this must be called to spawn the teleport waypoints for bots
123 InitializeEntity(self, teleport_findtarget, INITPRIO_FINDTARGET);
125 if (self.target == "")
127 objerror ("Teleporter with no target");
131 self.teleport_next = teleport_first;
132 teleport_first = self;
135 NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew)
138 self.warpzone_isboxy = (f & 1);
141 self.origin_x = ReadCoord();
142 self.origin_y = ReadCoord();
143 self.origin_z = ReadCoord();
146 self.origin = '0 0 0';
148 self.modelindex = ReadShort();
149 self.mins_x = ReadCoord();
150 self.mins_y = ReadCoord();
151 self.mins_z = ReadCoord();
152 self.maxs_x = ReadCoord();
153 self.maxs_y = ReadCoord();
154 self.maxs_z = ReadCoord();
155 self.scale = ReadByte() / 16;
156 self.classname = "trigger_teleport";
157 int mytm = ReadByte(); if(mytm) { self.team = mytm - 1; }
158 self.spawnflags = ReadInt24_t();
159 self.active = ReadByte();
160 self.speed = ReadCoord();
162 trigger_common_read(true);
164 self.entremove = trigger_remove_generic;
165 self.solid = SOLID_TRIGGER;
166 //self.draw = trigger_draw_generic;
167 //self.move_touch = trigger_push_touch;
168 self.drawmask = MASK_NORMAL;
169 self.move_time = time;
170 defer(self, 0.25, teleport_findtarget);
172 self.teleport_next = teleport_first;
173 teleport_first = self;