]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/trigger/teleport.qc
Merge branch 'terencehill/v_deathtilt_fix' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / teleport.qc
index 5ff5fcf3357210703844b5c90690b56d07a392be..54777b75cb1aa57723aa5d0c4d90c6556bdcaeb7 100644 (file)
@@ -1,21 +1,22 @@
+REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_TELEPORT)
+
 #ifdef SVQC
-void trigger_teleport_use()
+void trigger_teleport_use(entity this, entity actor, entity trigger)
 {
        if(teamplay)
-               self.team = activator.team;
+               this.team = actor.team;
 #ifdef SVQC
-       self.SendFlags |= SF_TRIGGER_UPDATE;
+       this.SendFlags |= SF_TRIGGER_UPDATE;
 #endif
 }
+#endif
 
-void Teleport_Touch (void)
+void Teleport_Touch (entity this)
 {
-       entity oldself;
-       string s;
-
        if (self.active != ACTIVE_ACTIVE)
                return;
 
+#ifdef SVQC
        if (!other.teleportable)
                return;
 
@@ -23,55 +24,104 @@ 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);
 
-       activator = other;
-       s = self.target; self.target = string_null;
-       SUB_UseTargets();
+#ifdef SVQC
+       string s = self.target; self.target = string_null;
+       SUB_UseTargets(self, other, other); // TODO: should we be using other for trigger too?
        if (!self.target) self.target = s;
 
-       oldself = self;
-       self = e;
-       SUB_UseTargets();
-       self = oldself;
+       SUB_UseTargets(e, other, other);
+#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);
+
+       trigger_common_write(this, true);
+
+       return true;
+}
+
+void trigger_teleport_link(entity this)
+{
+       //trigger_link(this, trigger_teleport_send);
+}
 
-       self.active = ACTIVE_ACTIVE;
+spawnfunc(trigger_teleport)
+{
+       this.angles = '0 0 0';
+
+       this.active = ACTIVE_ACTIVE;
+       //trigger_init(this); // only for predicted triggers?
+       EXACTTRIGGER_INIT;
+       this.use = trigger_teleport_use;
 
-       self.use = trigger_teleport_use;
+       if(this.noise != "")
+               FOREACH_WORD(this.noise, true, precache_sound(it));
 
        // this must be called to spawn the teleport waypoints for bots
-       InitializeEntity(self, teleport_findtarget, INITPRIO_FINDTARGET);
+       InitializeEntity(this, teleport_findtarget, INITPRIO_FINDTARGET);
 
-       if (self.target == "")
+       if (this.target == "")
        {
                objerror ("Teleporter with no target");
                return;
        }
 
-       self.teleport_next = teleport_first;
-       teleport_first = self;
+       this.teleport_next = teleport_first;
+       teleport_first = this;
 }
+#elif defined(CSQC)
+NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew)
+{
+       this.classname = "trigger_teleport";
+       int mytm = ReadByte(); if(mytm) { this.team = mytm - 1; }
+       this.spawnflags = ReadInt24_t();
+       this.active = ReadByte();
+       this.speed = ReadCoord();
+
+       trigger_common_read(this, true);
+
+       this.entremove = trigger_remove_generic;
+       this.solid = SOLID_TRIGGER;
+       //this.move_touch = trigger_push_touch;
+       this.move_time = time;
+       defer(this, 0.25, teleport_findtarget);
+
+       this.teleport_next = teleport_first;
+       teleport_first = this;
+
+       return true;
+}
+
 #endif