]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/t_teleporters.qc
Merge branch 'master' into mirceakitsune/damage_effects
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / t_teleporters.qc
index a80323e23a49c95f2a734d8d12060e9a3f091ed0..5d5b0a02c49bc2014ce502800254af43cc56384c 100644 (file)
@@ -1,6 +1,6 @@
 void trigger_teleport_use()
 {
-       if(teams_matter)
+       if(teamplay)
                self.team = activator.team;
 }
 
@@ -33,7 +33,7 @@ float check_tdeath(entity player, vector org, vector telefragmin, vector telefra
        {
                TDEATHLOOP(org)
                {
-                       if not(teams_matter && autocvar_g_telefrags_teamplay && head.team == player.team)
+                       if not(teamplay && autocvar_g_telefrags_teamplay && head.team == player.team)
                                if(head.classname == "player")
                                        if(head.health >= 1)
                                                return 1;
@@ -48,7 +48,7 @@ void tdeath(entity player, entity teleporter, entity telefragger, vector telefra
        {
                if (player.classname == "player" && player.health >= 1)
                {
-                       if not(teams_matter && autocvar_g_telefrags_teamplay && head.team == player.team)
+                       if not(teamplay && autocvar_g_telefrags_teamplay && head.team == player.team)
                        {
                                if(head.classname == "player")
                                        if(head.health >= 1)
@@ -77,7 +77,6 @@ void spawn_tdeath(vector v0, entity e, vector v)
 #define TELEPORT_FLAGS_TELEPORTER (TELEPORT_FLAG_SOUND | TELEPORT_FLAG_PARTICLES | TELEPORT_FLAG_TDEATH)
 void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity, vector telefragmin, vector telefragmax, float tflags)
 {
-       entity oldself;
        entity telefragger;
        vector from;
 
@@ -93,7 +92,7 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle
                if(self.pushltime < time) // only show one teleport effect per teleporter per 0.2 seconds, for better fps
                {
                        if(tflags & TELEPORT_FLAG_SOUND)
-                               sound (player, CHAN_TRIGGER, "misc/teleport.wav", VOL_BASE, ATTN_NORM);
+                               sound (player, CH_TRIGGER, "misc/teleport.wav", VOL_BASE, ATTN_NORM);
                        if(tflags & TELEPORT_FLAG_PARTICLES)
                        {
                                pointparticles(particleeffectnum("teleport"), player.origin, '0 0 0', 1);
@@ -139,25 +138,21 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle
                }
 
                player.lastteleporttime = time;
-
-               // stop player name display
-               {
-                       oldself = self;
-                       self = player;
-                       ClearSelectedPlayer();
-                       self = oldself;
-               }
        }
 }
 
-void Simple_TeleportPlayer(entity teleporter, entity player)
+entity Simple_TeleportPlayer(entity teleporter, entity player)
 {
        vector locout;
        entity e;
        float p;
        
        // Find the output teleporter
-       if(!teleporter.enemy)
+       if(teleporter.enemy)
+       {
+               e = teleporter.enemy;
+       }
+       else
        { 
                RandomSelection_Init();
                for(e = world; (e = find(e, targetname, teleporter.target)); )
@@ -171,23 +166,25 @@ void Simple_TeleportPlayer(entity teleporter, entity player)
                        }
                        RandomSelection_Add(e, 0, string_null, (e.cnt ? e.cnt : 1), p);
                }
-               teleporter.enemy = RandomSelection_chosen_ent;
+               e = RandomSelection_chosen_ent;
        }
 
-       if(!teleporter.enemy) { sprint(player, "Teleport destination vanished. Sorry... please complain to the mapper.\n"); }
+       if(!e) { sprint(player, "Teleport destination vanished. Sorry... please complain to the mapper.\n"); }
        
-       makevectors(teleporter.enemy.mangle);
+       makevectors(e.mangle);
 
-       if(teleporter.enemy.speed)
-               if(vlen(player.velocity) > teleporter.enemy.speed)
-                       player.velocity = normalize(player.velocity) * max(0, teleporter.enemy.speed);
+       if(e.speed)
+               if(vlen(player.velocity) > e.speed)
+                       player.velocity = normalize(player.velocity) * max(0, e.speed);
                        
        if(autocvar_g_teleport_maxspeed)
                if(vlen(player.velocity) > autocvar_g_teleport_maxspeed)
                        player.velocity = normalize(player.velocity) * max(0, autocvar_g_teleport_maxspeed);
 
-       locout = teleporter.enemy.origin + '0 0 1' * (1 - player.mins_z - 24);
-       TeleportPlayer(teleporter, player, locout, teleporter.enemy.mangle, v_forward * vlen(player.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
+       locout = e.origin + '0 0 1' * (1 - player.mins_z - 24);
+       TeleportPlayer(teleporter, player, locout, e.mangle, v_forward * vlen(player.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
+
+       return e;
 }
 
 void Teleport_Touch (void)
@@ -198,9 +195,14 @@ void Teleport_Touch (void)
        if (self.active != ACTIVE_ACTIVE)
                return;
        
-       if (other.deadflag != DEAD_NO)
+       if not(other.iscreature)
+               return;
+
+       // for gameplay: vehicles can't teleport
+       if (other.vehicle_flags & VHF_ISVEHICLE)
                return;
-       if not(other.flags & FL_CLIENT) // FIXME: Make missiles firable through the teleport too
+
+       if (other.deadflag != DEAD_NO)
                return;
 
        if(self.team)
@@ -212,7 +214,8 @@ void Teleport_Touch (void)
        if(other.classname == "player")
                RemoveGrapplingHook(other);
                
-       Simple_TeleportPlayer(self, other);
+       entity e;
+       e = Simple_TeleportPlayer(self, other);
 
        activator = other;
        s = self.target; self.target = string_null;
@@ -220,7 +223,7 @@ void Teleport_Touch (void)
        if not(self.target) self.target = s;
 
        oldself = self;
-       self = self.enemy;
+       self = e;
        SUB_UseTargets();
        self = oldself;
 }
@@ -257,18 +260,15 @@ void teleport_findtarget (void)
        entity e;
        float n;
 
-       RandomSelection_Init();
        n = 0;
        for(e = world; (e = find(e, targetname, self.target)); )
        {
                ++n;
                if(e.movetype == MOVETYPE_NONE)
-                       RandomSelection_Add(e, 0, string_null, 1, 1);
+                       waypoint_spawnforteleporter(self, e.origin, 0);
                if(e.classname != "info_teleport_destination")
                        print("^3MAPPER ERROR: teleporter does target an invalid teleport destination entity. Angles will not work.\n");
        }
-       if(RandomSelection_chosen_ent)
-               waypoint_spawnforteleporter(self, RandomSelection_chosen_ent.origin, 0);
 
        if(n == 0)
        {
@@ -280,7 +280,6 @@ void teleport_findtarget (void)
        {
                // exactly one dest - bots love that
                self.enemy = find(e, targetname, self.target);
-               self.dest = self.enemy.origin;
        }
        else
        {
@@ -329,6 +328,14 @@ void spawnfunc_trigger_teleport (void)
 void WarpZone_PostTeleportPlayer_Callback(entity pl)
 {
        UpdateCSQCProjectileAfterTeleport(pl);
+       // "disown" projectiles after teleport
+       if(pl.owner)
+       if(pl.owner == pl.realowner)
+       {
+               if(!(pl.flags & FL_PROJECTILE))
+                       print("A non-projectile got through a warpzone and its owner cleared. It's a ", pl.classname, ".\n");
+               pl.owner = world;
+       }
        if(pl.classname == "player")
        {
                // reset tracking of oldvelocity for impact damage (sudden velocity changes)