]> 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 252ead261ec700a3551edf49133d7a8fae0c1a14..54777b75cb1aa57723aa5d0c4d90c6556bdcaeb7 100644 (file)
@@ -1,18 +1,18 @@
 REGISTER_NET_LINKED(ENT_CLIENT_TRIGGER_TELEPORT)
 
 #ifdef SVQC
-void trigger_teleport_use()
-{SELFPARAM();
+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 ()
-{SELFPARAM();
+void Teleport_Touch (entity this)
+{
        if (self.active != ACTIVE_ACTIVE)
                return;
 
@@ -26,9 +26,12 @@ void Teleport_Touch ()
 
        if(IS_TURRET(other))
                return;
+#elif defined(CSQC)
+       if(!IS_PLAYER(other))
+               return;
 #endif
 
-       if(PHYS_DEAD(other))
+       if(IS_DEAD(other))
                return;
 
        if(self.team)
@@ -46,131 +49,77 @@ void Teleport_Touch ()
        e = Simple_TeleportPlayer(self, other);
 
 #ifdef SVQC
-       activator = other;
        string s = self.target; self.target = string_null;
-       SUB_UseTargets();
+       SUB_UseTargets(self, other, other); // TODO: should we be using other for trigger too?
        if (!self.target) self.target = s;
 
-       WITH(entity, self, e, SUB_UseTargets());
+       SUB_UseTargets(e, other, other);
 #endif
 }
 
 #ifdef SVQC
-float trigger_teleport_send(entity to, float sf)
-{SELFPARAM();
+float trigger_teleport_send(entity this, entity to, float sf)
+{
        WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_TELEPORT);
 
-       int f = 0;
-       if(self.warpzone_isboxy)
-               BITSET_ASSIGN(f, 1);
-       if(self.origin != '0 0 0')
-               BITSET_ASSIGN(f, 4);
-       WriteByte(MSG_ENTITY, f);
-
-       if(f & 4)
-       {
-               WriteCoord(MSG_ENTITY, self.origin.x);
-               WriteCoord(MSG_ENTITY, self.origin.y);
-               WriteCoord(MSG_ENTITY, self.origin.z);
-       }
+       WriteByte(MSG_ENTITY, this.team);
+       WriteInt24_t(MSG_ENTITY, this.spawnflags);
+       WriteByte(MSG_ENTITY, this.active);
+       WriteCoord(MSG_ENTITY, this.speed);
 
-       WriteShort(MSG_ENTITY, self.modelindex);
-       WriteCoord(MSG_ENTITY, self.mins.x);
-       WriteCoord(MSG_ENTITY, self.mins.y);
-       WriteCoord(MSG_ENTITY, self.mins.z);
-       WriteCoord(MSG_ENTITY, self.maxs.x);
-       WriteCoord(MSG_ENTITY, self.maxs.y);
-       WriteCoord(MSG_ENTITY, self.maxs.z);
-       WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
-       WriteByte(MSG_ENTITY, self.team);
-       WriteInt24_t(MSG_ENTITY, self.spawnflags);
-       WriteByte(MSG_ENTITY, self.active);
-       WriteCoord(MSG_ENTITY, self.speed);
-
-       trigger_common_write(true);
+       trigger_common_write(this, true);
 
        return true;
 }
 
 void trigger_teleport_link(entity this)
 {
-       this.SendEntity = trigger_teleport_send;
-       this.SendFlags = 0xFFFFFF;
+       //trigger_link(this, trigger_teleport_send);
 }
 
 spawnfunc(trigger_teleport)
 {
-       self.angles = '0 0 0';
-
-       string m = self.model;
-       WarpZoneLib_ExactTrigger_Init();
-       if(m != "")
-       {
-               precache_model(m);
-               _setmodel(self, m); // no precision needed
-       }
-       setorigin(self, self.origin);
-       if(self.scale)
-               setsize(self, self.mins * self.scale, self.maxs * self.scale);
-       else
-               setsize(self, self.mins, self.maxs);
+       this.angles = '0 0 0';
 
-       self.active = ACTIVE_ACTIVE;
-       BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
-       self.use = trigger_teleport_use;
+       this.active = ACTIVE_ACTIVE;
+       //trigger_init(this); // only for predicted triggers?
+       EXACTTRIGGER_INIT;
+       this.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)
 {
-       int f = ReadByte();
-       self.warpzone_isboxy = (f & 1);
-       if(f & 4)
-       {
-               self.origin_x = ReadCoord();
-               self.origin_y = ReadCoord();
-               self.origin_z = ReadCoord();
-       }
-       else
-               self.origin = '0 0 0';
-
-       self.modelindex = ReadShort();
-       self.mins_x = ReadCoord();
-       self.mins_y = ReadCoord();
-       self.mins_z = ReadCoord();
-       self.maxs_x = ReadCoord();
-       self.maxs_y = ReadCoord();
-       self.maxs_z = ReadCoord();
-       self.scale = ReadByte() / 16;
-       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;
+       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;
 }