]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/trigger/teleport.qc
Rename PHYS_DEAD to IS_DEAD and make it usable outside of player physics
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / teleport.qc
index 5ff5fcf3357210703844b5c90690b56d07a392be..c013eb867fa446e1175f383dd50dc2f159e75f86 100644 (file)
@@ -1,21 +1,22 @@
+REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_TELEPORT)
+
 #ifdef SVQC
 void trigger_teleport_use()
-{
+{SELFPARAM();
        if(teamplay)
                self.team = activator.team;
 #ifdef SVQC
        self.SendFlags |= SF_TRIGGER_UPDATE;
 #endif
 }
+#endif
 
-void Teleport_Touch (void)
-{
-       entity oldself;
-       string s;
-
+void Teleport_Touch ()
+{SELFPARAM();
        if (self.active != ACTIVE_ACTIVE)
                return;
 
+#ifdef SVQC
        if (!other.teleportable)
                return;
 
@@ -23,43 +24,66 @@ void Teleport_Touch (void)
        if(!other.vehicle.teleportable)
                return;
 
-       if(other.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
+       if(IS_TURRET(other))
                return;
+#elif defined(CSQC)
+       if(!IS_PLAYER(other))
+               return;
+#endif
 
-       if(other.deadflag != DEAD_NO)
+       if(IS_DEAD(other))
                return;
 
        if(self.team)
-               if(((self.spawnflags & 4) == 0) == (self.team != other.team))
+               if(((self.spawnflags & 4) == 0) == (DIFF_TEAM(this, other)))
                        return;
 
        EXACTTRIGGER_TOUCH;
 
+#ifdef SVQC
        if(IS_PLAYER(other))
                RemoveGrapplingHook(other);
+#endif
 
        entity e;
        e = Simple_TeleportPlayer(self, other);
 
+#ifdef SVQC
        activator = other;
-       s = self.target; self.target = string_null;
+       string s = self.target; self.target = string_null;
        SUB_UseTargets();
        if (!self.target) self.target = s;
 
-       oldself = self;
-       self = e;
-       SUB_UseTargets();
-       self = oldself;
+       WITH(entity, self, e, SUB_UseTargets());
+#endif
 }
 
-void spawnfunc_trigger_teleport()
+#ifdef SVQC
+float trigger_teleport_send(entity this, entity to, float sf)
 {
-       self.angles = '0 0 0';
+       WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_TELEPORT);
 
-       EXACTTRIGGER_INIT;
+       WriteByte(MSG_ENTITY, this.team);
+       WriteInt24_t(MSG_ENTITY, this.spawnflags);
+       WriteByte(MSG_ENTITY, this.active);
+       WriteCoord(MSG_ENTITY, this.speed);
 
-       self.active = ACTIVE_ACTIVE;
+       trigger_common_write(this, true);
 
+       return true;
+}
+
+void trigger_teleport_link(entity this)
+{
+       trigger_link(this, trigger_teleport_send);
+}
+
+spawnfunc(trigger_teleport)
+{
+       self.angles = '0 0 0';
+
+       self.active = ACTIVE_ACTIVE;
+       trigger_init(self);
        self.use = trigger_teleport_use;
 
        // this must be called to spawn the teleport waypoints for bots
@@ -74,4 +98,29 @@ void spawnfunc_trigger_teleport()
        self.teleport_next = teleport_first;
        teleport_first = self;
 }
+#elif defined(CSQC)
+NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew)
+{
+       self.classname = "trigger_teleport";
+       int mytm = ReadByte(); if(mytm) { self.team = mytm - 1; }
+       self.spawnflags = ReadInt24_t();
+       self.active = ReadByte();
+       self.speed = ReadCoord();
+
+       trigger_common_read(true);
+
+       self.entremove = trigger_remove_generic;
+       self.solid = SOLID_TRIGGER;
+       //self.draw = trigger_draw_generic;
+       //self.move_touch = trigger_push_touch;
+       self.drawmask = MASK_NORMAL;
+       self.move_time = time;
+       defer(self, 0.25, teleport_findtarget);
+
+       self.teleport_next = teleport_first;
+       teleport_first = self;
+
+       return true;
+}
+
 #endif