]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote branch 'origin/master' into samual/flyingspectators
authorSamual <samual@xonotic.org>
Wed, 20 Apr 2011 19:55:57 +0000 (15:55 -0400)
committerSamual <samual@xonotic.org>
Wed, 20 Apr 2011 19:55:57 +0000 (15:55 -0400)
qcsrc/server/cl_client.qc
qcsrc/server/cl_physics.qc
qcsrc/server/t_teleporters.qc
qcsrc/warpzonelib/server.qc

index a1047ea9d07595dae83fcb3fd49953b5b24062c7..625646c5966a87ad315060ff12d22f3f03dba340 100644 (file)
@@ -644,7 +644,7 @@ void PutObserverInServer (void)
        self.health = -666;
        self.takedamage = DAMAGE_NO;
        self.solid = SOLID_NOT;
-       self.movetype = MOVETYPE_NOCLIP;
+       self.movetype = MOVETYPE_FLY;
        self.flags = FL_CLIENT | FL_NOTARGET;
        self.armorvalue = 666;
        self.effects = 0;
@@ -673,9 +673,9 @@ void PutObserverInServer (void)
        self.fixangle = TRUE;
        self.crouch = FALSE;
 
-       self.view_ofs = PL_VIEW_OFS;
+       self.view_ofs = '0 0 0'; // so that you can't go inside walls with MOVETYPE_FLY, previously "PL_VIEW_OFS" - for some reason this is diff from normal players
        setorigin (self, spot.origin);
-       setsize (self, '0 0 0', '0 0 0');
+       setsize (self, '-16 -16 -24', '16 16 24'); // so that you can't go inside walls with MOVETYPE_FLY
        self.prevorigin = self.origin;
        self.items = 0;
        self.weapons = 0;
index 9662e0ae61035dbe402bfec093c71f0753a99644..f0617740e654210a45af5754dc526b5aaef48625 100644 (file)
@@ -892,6 +892,7 @@ void SV_PlayerPhysics()
        }
 
        if(self.flags & FL_ONGROUND)
+       if(self.classname == "player") // no fall sounds for observers thank you very much
        if(self.wasFlying)
        {
                self.wasFlying = 0;
index 93ced82670b1a36fb15c42a8236419621d52513a..a80323e23a49c95f2a734d8d12060e9a3f091ed0 100644 (file)
@@ -88,16 +88,19 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle
 
        makevectors (to_angles);
 
-       if(self.pushltime < time) // only show one teleport effect per teleporter per 0.2 seconds, for better fps
+       if(player.classname == "player") // don't play sounds or show particles for anything that isn't a player, maybe change later to block only observers
        {
-               if(tflags & TELEPORT_FLAG_SOUND)
-                       sound (player, CHAN_TRIGGER, "misc/teleport.wav", VOL_BASE, ATTN_NORM);
-               if(tflags & TELEPORT_FLAG_PARTICLES)
+               if(self.pushltime < time) // only show one teleport effect per teleporter per 0.2 seconds, for better fps
                {
-                       pointparticles(particleeffectnum("teleport"), player.origin, '0 0 0', 1);
-                       pointparticles(particleeffectnum("teleport"), to + v_forward * 32, '0 0 0', 1);
+                       if(tflags & TELEPORT_FLAG_SOUND)
+                               sound (player, CHAN_TRIGGER, "misc/teleport.wav", VOL_BASE, ATTN_NORM);
+                       if(tflags & TELEPORT_FLAG_PARTICLES)
+                       {
+                               pointparticles(particleeffectnum("teleport"), player.origin, '0 0 0', 1);
+                               pointparticles(particleeffectnum("teleport"), to + v_forward * 32, '0 0 0', 1);
+                       }
+                       self.pushltime = time + 0.2;
                }
-               self.pushltime = time + 0.2;
        }
 
        // Relocate the player
@@ -147,17 +150,55 @@ void TeleportPlayer(entity teleporter, entity player, vector to, vector to_angle
        }
 }
 
-void Teleport_Touch (void)
+void Simple_TeleportPlayer(entity teleporter, entity player)
 {
-       entity oldself, e;
-       vector o;
+       vector locout;
+       entity e;
        float p;
+       
+       // Find the output teleporter
+       if(!teleporter.enemy)
+       { 
+               RandomSelection_Init();
+               for(e = world; (e = find(e, targetname, teleporter.target)); )
+               {
+                       p = 1;
+                       if(autocvar_g_telefrags_avoid)
+                       {
+                               locout = e.origin + '0 0 1' * (1 - player.mins_z - 24);
+                               if(check_tdeath(player, locout, '0 0 0', '0 0 0'))
+                                       p = 0;
+                       }
+                       RandomSelection_Add(e, 0, string_null, (e.cnt ? e.cnt : 1), p);
+               }
+               teleporter.enemy = RandomSelection_chosen_ent;
+       }
+
+       if(!teleporter.enemy) { sprint(player, "Teleport destination vanished. Sorry... please complain to the mapper.\n"); }
+       
+       makevectors(teleporter.enemy.mangle);
+
+       if(teleporter.enemy.speed)
+               if(vlen(player.velocity) > teleporter.enemy.speed)
+                       player.velocity = normalize(player.velocity) * max(0, teleporter.enemy.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);
+}
+
+void Teleport_Touch (void)
+{
+       entity oldself;
        string s;
 
        if (self.active != ACTIVE_ACTIVE)
                return;
        
-       if (other.health < 1)
+       if (other.deadflag != DEAD_NO)
                return;
        if not(other.flags & FL_CLIENT) // FIXME: Make missiles firable through the teleport too
                return;
@@ -168,49 +209,10 @@ void Teleport_Touch (void)
 
        EXACTTRIGGER_TOUCH;
 
-       makevectors(self.enemy.mangle);
-
        if(other.classname == "player")
                RemoveGrapplingHook(other);
-       
-       if(self.enemy)
-       {
-               e = self.enemy;
-       }
-       else
-       {
-               RandomSelection_Init();
-               for(e = world; (e = find(e, targetname, self.target)); )
-               {
-                       p = 1;
-                       if(autocvar_g_telefrags_avoid)
-                       {
-                               o = e.origin + '0 0 1' * (1 - other.mins_z - 24);
-                               if(check_tdeath(other, o, '0 0 0', '0 0 0'))
-                                       p = 0;
-                       }
-                       if(e.cnt)
-                               RandomSelection_Add(e, 0, string_null, e.cnt, p);
-                       else
-                               RandomSelection_Add(e, 0, string_null, 1, p);
-               }
-               e = RandomSelection_chosen_ent;
-       }
-
-       if(!e)
-       {
-               sprint(other, "Teleport destination vanished. Sorry... please complain to the mapper.\n");
-       }
-
-       if(e.speed)
-               if(vlen(other.velocity) > e.speed)
-                       other.velocity = normalize(other.velocity) * max(0, e.speed);
-       if(autocvar_g_teleport_maxspeed)
-               if(vlen(other.velocity) > autocvar_g_teleport_maxspeed)
-                       other.velocity = normalize(other.velocity) * max(0, autocvar_g_teleport_maxspeed);
-
-       o = e.origin + '0 0 1' * (1 - other.mins_z - 24);
-       TeleportPlayer(self, other, o, e.mangle, v_forward * vlen(other.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
+               
+       Simple_TeleportPlayer(self, other);
 
        activator = other;
        s = self.target; self.target = string_null;
@@ -218,7 +220,7 @@ void Teleport_Touch (void)
        if not(self.target) self.target = s;
 
        oldself = self;
-       self = e;
+       self = self.enemy;
        SUB_UseTargets();
        self = oldself;
 }
@@ -290,6 +292,17 @@ void teleport_findtarget (void)
        self.touch = Teleport_Touch;
 }
 
+entity Teleport_Find(vector mi, vector ma)
+{
+       entity e;
+       for(e = world; (e = find(e, classname, "trigger_teleport")); )
+               if(WarpZoneLib_BoxTouchesBrush(mi, ma, e, world))
+                       return e;
+       return world;
+}
+
+entity teleport_first; 
+.entity teleport_next;
 void spawnfunc_trigger_teleport (void)
 {
        self.angles = '0 0 0';
@@ -308,6 +321,9 @@ void spawnfunc_trigger_teleport (void)
                objerror ("Teleporter with no target");
                return;
        }
+       
+       self.teleport_next = teleport_first;
+       teleport_first = self;
 }
 
 void WarpZone_PostTeleportPlayer_Callback(entity pl)
index e0dfc6675342eb9282283f6f6599398896370e4a..85e17e13303befd1cb44b922a967b4a4e2cef0af 100644 (file)
@@ -605,40 +605,46 @@ void WarpZone_StartFrame()
                WarpZones_Reconnect();
        }
 
-       if(warpzone_warpzones_exist)
+       entity oldself, oldother;
+       oldself = self;
+       oldother = other;
+       for(e = world; (e = nextent(e)); )
        {
-               entity oldself, oldother;
-               oldself = self;
-               oldother = other;
-               for(e = world; (e = nextent(e)); )
+               if(warpzone_warpzones_exist) { WarpZone_StoreProjectileData(e); }
+               
+               float f = clienttype(e);
+               if(f == CLIENTTYPE_REAL)
                {
-                       WarpZone_StoreProjectileData(e);
-                       float f;
-                       f = clienttype(e);
-                       if(f == CLIENTTYPE_REAL)
+                       if(e.solid == SOLID_NOT) // not spectating?
+                       if(e.movetype == MOVETYPE_NOCLIP || e.movetype == MOVETYPE_FLY) // not spectating? (this is to catch observers)
                        {
-                               if(e.solid != SOLID_NOT) // not spectating?
-                                       continue;
-                               if(e.movetype != MOVETYPE_NOCLIP && e.movetype != MOVETYPE_FLY) // not spectating? (this is to catch observers)
-                                       continue;
-                               self = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs);
-                               if(!self)
-                                       continue;
-                               other = e;
-                               if(WarpZoneLib_ExactTrigger_Touch())
-                                       continue;
-                               WarpZone_Teleport(e); // NOT triggering targets by this!
+                               other = e; // player
+                       
+                               // warpzones
+                               if(warpzone_warpzones_exist) { 
+                               self = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs); 
+                               if(self)
+                               if(!WarpZoneLib_ExactTrigger_Touch())
+                                       WarpZone_Teleport(e); } // NOT triggering targets by this!
+                       
+                               // teleporters
+                               self = Teleport_Find(e.origin + e.mins, e.origin + e.maxs);
+                               if(self)
+                               if(!WarpZoneLib_ExactTrigger_Touch())
+                                       Simple_TeleportPlayer(self, other); // NOT triggering targets by this!
                        }
-                       if(f == CLIENTTYPE_NOTACLIENT)
-                       {
+               }
+               
+               if(f == CLIENTTYPE_NOTACLIENT)
+               {
+                       if(warpzone_warpzones_exist)
                                for(; (e = nextent(e)); )
                                        WarpZone_StoreProjectileData(e);
-                               break;
-                       }
+                       break;
                }
-               self = oldself;
-               other = oldother;
        }
+       self = oldself;
+       other = oldother;
 }
 
 .float warpzone_reconnecting;