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 & 4) == 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?
86 if (!this.target) this.target = s;
88 SUB_UseTargets(e, player, player);
93 float trigger_teleport_send(entity this, entity to, float sf)
95 WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_TELEPORT);
97 WriteByte(MSG_ENTITY, this.team);
98 WriteInt24_t(MSG_ENTITY, this.spawnflags);
99 WriteByte(MSG_ENTITY, this.active);
100 WriteCoord(MSG_ENTITY, this.speed);
102 trigger_common_write(this, true);
107 void trigger_teleport_link(entity this)
109 //trigger_link(this, trigger_teleport_send);
112 spawnfunc(trigger_teleport)
114 this.angles = '0 0 0';
116 this.active = ACTIVE_ACTIVE;
117 //trigger_init(this); // only for predicted triggers?
119 this.use = trigger_teleport_use;
122 FOREACH_WORD(this.noise, true, precache_sound(it));
124 // this must be called to spawn the teleport waypoints for bots
125 InitializeEntity(this, teleport_findtarget, INITPRIO_FINDTARGET);
127 if (this.target == "")
129 objerror (this, "Teleporter with no target");
133 IL_PUSH(g_teleporters, this);
136 spawnfunc(target_teleporter)
138 if(this.target == "")
140 // actually a destination!
141 spawnfunc_info_teleport_destination(this);
145 this.active = ACTIVE_ACTIVE;
147 this.use = target_teleport_use;
150 FOREACH_WORD(this.noise, true, precache_sound(it));
152 InitializeEntity(this, teleport_findtarget, INITPRIO_FINDTARGET);
155 NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew)
157 this.classname = "trigger_teleport";
159 IL_PUSH(g_teleporters, this);
160 int mytm = ReadByte(); if(mytm) { this.team = mytm - 1; }
161 this.spawnflags = ReadInt24_t();
162 this.active = ReadByte();
163 this.speed = ReadCoord();
165 trigger_common_read(this, true);
167 this.entremove = trigger_remove_generic;
168 this.solid = SOLID_TRIGGER;
169 //settouch(this, trigger_push_touch);
170 this.move_time = time;
171 defer(this, 0.25, teleport_findtarget);