2 REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_TELEPORT)
5 void trigger_teleport_use(entity this, entity actor, entity trigger)
8 this.team = actor.team;
10 this.SendFlags |= SF_TRIGGER_UPDATE;
15 bool Teleport_Active(entity this, entity player)
17 if (this.active != ACTIVE_ACTIVE)
21 if (!player.teleportable)
25 if(!player.vehicle.teleportable)
31 if(!IS_PLAYER(player))
39 if(((this.spawnflags & INVERT_TEAMS) == 0) == (DIFF_TEAM(this, player)))
45 void Teleport_Touch(entity this, entity toucher)
47 entity player = toucher;
49 if(!Teleport_Active(this, player))
52 EXACTTRIGGER_TOUCH(this, player);
56 RemoveGrapplingHooks(player);
60 e = Simple_TeleportPlayer(this, player);
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;
67 SUB_UseTargets(e, player, player);
72 void target_teleport_use(entity this, entity actor, entity trigger)
74 entity player = actor;
76 if(!Teleport_Active(this, player))
80 RemoveGrapplingHooks(player);
82 entity e = Simple_TeleportPlayer(this, player);
84 string s = this.target; this.target = string_null;
85 SUB_UseTargets(this, player, player); // TODO: should we be using toucher for trigger too?
91 SUB_UseTargets(e, player, player);
96 float trigger_teleport_send(entity this, entity to, float sf)
98 WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_TELEPORT);
100 WriteByte(MSG_ENTITY, this.team);
101 WriteInt24_t(MSG_ENTITY, this.spawnflags);
102 WriteByte(MSG_ENTITY, this.active);
103 WriteCoord(MSG_ENTITY, this.speed);
105 trigger_common_write(this, true);
110 void trigger_teleport_link(entity this)
112 //trigger_link(this, trigger_teleport_send);
115 spawnfunc(trigger_teleport)
117 this.angles = '0 0 0';
119 this.active = ACTIVE_ACTIVE;
120 //trigger_init(this); // only for predicted triggers?
122 this.use = trigger_teleport_use;
125 FOREACH_WORD(this.noise, true, precache_sound(it));
127 // this must be called to spawn the teleport waypoints for bots
128 InitializeEntity(this, teleport_findtarget, INITPRIO_FINDTARGET);
130 if (this.target == "")
132 objerror (this, "Teleporter with no target");
136 IL_PUSH(g_teleporters, this);
139 spawnfunc(target_teleporter)
141 if(this.target == "")
143 // actually a destination!
144 spawnfunc_info_teleport_destination(this);
148 this.active = ACTIVE_ACTIVE;
150 this.use = target_teleport_use;
153 FOREACH_WORD(this.noise, true, precache_sound(it));
155 InitializeEntity(this, teleport_findtarget, INITPRIO_FINDTARGET);
158 NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew)
160 this.classname = "trigger_teleport";
162 IL_PUSH(g_teleporters, this);
163 int mytm = ReadByte();
166 this.team = mytm - 1;
168 this.spawnflags = ReadInt24_t();
169 this.active = ReadByte();
170 this.speed = ReadCoord();
172 trigger_common_read(this, true);
174 this.entremove = trigger_remove_generic;
175 this.solid = SOLID_TRIGGER;
176 //settouch(this, trigger_push_touch);
177 this.move_time = time;
178 defer(this, 0.25, teleport_findtarget);