]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote-tracking branch 'origin/samual/flyingspectators'
authormand1nga <mand1nga@xonotic.org>
Sun, 21 Aug 2011 03:10:17 +0000 (00:10 -0300)
committermand1nga <mand1nga@xonotic.org>
Sun, 21 Aug 2011 03:10:17 +0000 (00:10 -0300)
defaultXonotic.cfg
qcsrc/client/movetypes.qh
qcsrc/server/cl_client.qc
qcsrc/server/cl_physics.qc
qcsrc/server/constants.qh
qcsrc/server/defs.qh
qcsrc/server/extensions.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/t_teleporters.qc
qcsrc/warpzonelib/server.qc

index 3dc51da56553df8c0ceb4a05c886bfeec4b16ceb..29654fe5cf0767375a47f67ed06e55de0c9bc505 100644 (file)
@@ -1742,7 +1742,9 @@ alias gl_flashblend_update "_gl_flashblend_update_$r_shadow_realtime_dlight$r_sh
 
 set sv_clones 0        "number of clones a player may make (reset by the \"kill\" command)"
 
-set cl_handicap 1      "the higher, the more damage you will receive (client setting)"
+set cl_handicap 1      "the higher, the more damage you will receive (client setting) NOTE: reconnect or use sendcvar command to update the choice."
+
+seta cl_clippedspectating 1 "movement collision for spectators so that you can't pass through walls and such. (client setting) NOTE: reconnect or use sendcvar command to update the choice." 
 
 // must be at the bottom of this file:
 // alias for switching the teamselect menu
index 3ec9a8f1d35f50148833f68cc82fc234d48ef9da..c6ab6543cb347efe7825c07c18cea339d25bb03a 100644 (file)
@@ -28,6 +28,7 @@ float MOVETYPE_BOUNCE                         = 10;
 float  MOVETYPE_BOUNCEMISSILE  = 11;   // Like bounce but doesn't lose speed on bouncing
 float MOVETYPE_FOLLOW = 12;
 float MOVETYPE_FAKEPUSH = 13;
+float MOVETYPE_FLY_WORLDONLY = 33;
 
 float   FL_ITEM                 = 256;
 float  FL_ONGROUND                             = 512;
index 0cf0d9ea512224843f2de8f7625cfb64cef2c84e..34534b74cd96334b3f5c0297edc09788896f8799 100644 (file)
@@ -659,13 +659,13 @@ void PutObserverInServer (void)
        accuracy_resend(self);
 
        self.spectatortime = time;
-
+       
        self.classname = "observer";
        self.iscreature = FALSE;
        self.health = -666;
        self.takedamage = DAMAGE_NO;
        self.solid = SOLID_NOT;
-       self.movetype = MOVETYPE_NOCLIP;
+       self.movetype = MOVETYPE_FLY_WORLDONLY; //(self.cvar_cl_clippedspectating ? MOVETYPE_NOCLIP : MOVETYPE_FLY); // it's too early for this anyway, lets just set it in playerprethink
        self.flags = FL_CLIENT | FL_NOTARGET;
        self.armorvalue = 666;
        self.effects = 0;
@@ -694,9 +694,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;
@@ -2503,6 +2503,7 @@ void checkSpectatorBlock() {
 
 void ObserverThink()
 {
+       float prefered_movetype;
        if (self.flags & FL_JUMPRELEASED) {
                if (self.BUTTON_JUMP && !self.version_mismatch) {
                        self.flags &~= FL_JUMPRELEASED;
@@ -2512,6 +2513,10 @@ void ObserverThink()
                        if(SpectateNext() == 1) {
                                self.classname = "spectator";
                        }
+               } else {
+                       prefered_movetype = ((!self.BUTTON_USE ? self.cvar_cl_clippedspectating : !self.cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP);
+                       if (self.movetype != prefered_movetype)
+                               self.movetype = prefered_movetype;
                }
        } else {
                if (!(self.BUTTON_ATCK || self.BUTTON_JUMP)) {
index 83c438b47600f7b07bd8fbf3fe54e99f2c992d15..1012734302a67f372e1979a78e2bdacbc7498526 100644 (file)
@@ -904,6 +904,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;
@@ -962,7 +963,7 @@ void SV_PlayerPhysics()
        {
                RaceCarPhysics();
        }
-       else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY)
+       else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY || self.movetype == MOVETYPE_FLY_WORLDONLY)
        {
                // noclipping or flying
                self.flags &~= FL_ONGROUND;
index dca76fe003ca685ebee8e32bfdee56c0228e63fe..5e18a5cc60c55bb4936887ab9fab6f8b80153105 100644 (file)
@@ -33,6 +33,7 @@ float MOVETYPE_FLYMISSILE                     = 9;
 float  MOVETYPE_BOUNCE                         = 10;
 float  MOVETYPE_BOUNCEMISSILE  = 11;   // Like bounce but doesn't lose speed on bouncing
 //float        MOVETYPE_FOLLOW                         = 12;   // 'Attaches' the entity to its aim_ent
+//float MOVETYPE_FLY_WORLDONLY = 33;
 
 float  SOLID_NOT                               = 0;
 float  SOLID_TRIGGER                           = 1;
index 9e6a73b5e3642fe9e9ae952a9b6a318120e32ad7..6ef2bfcd0cc925397616ff34b8f8dc528896d1bd 100644 (file)
@@ -309,6 +309,8 @@ float default_weapon_alpha;
 .float() customizeentityforclient;
 .float cvar_cl_handicap;
 .float cvar_cl_playerdetailreduction;
+.float cvar_cl_clippedspectating;
+
 .string cvar_g_xonoticversion;
 .string cvar_cl_weaponpriority;
 .string cvar_cl_weaponpriorities[10];
index 1aba127a584f1b7a4c46b17dda93a060bdf48e31..8422cf5df8d7b73294b0b18cf6061e4f7730ee41 100644 (file)
@@ -520,6 +520,14 @@ void(entity e, entity tagentity, string tagname) setattachment = #443; // attach
 //description:
 //MOVETYPE_BOUNCE but without gravity, and with full reflection (no speed loss like grenades have), in other words - bouncing laser bolts.
 
+//DP_MOVETYPEFLYWORLDONLY
+//idea: Samual
+//darkplaces implementation: Samual
+//movetype definitions:
+float MOVETYPE_FLY_WORLDONLY = 33;
+//description:
+//like MOVETYPE_FLY, but does all traces with MOVE_WORLDONLY, and is ignored by MOVETYPE_PUSH. Should only be combined with SOLID_NOT and SOLID_TRIGGER.
+
 //DP_NULL_MODEL
 //idea: Chris
 //darkplaces implementation: divVerent
index 09e2dfb05d4b60e64154b00498cc919b3369fc50..7a0257a068b33058814025f3419787e2e7d0c8fb 100644 (file)
@@ -586,6 +586,7 @@ void GetCvars(float f)
        GetCvars_handleFloat(s, f, cvar_cl_playerdetailreduction, "cl_playerdetailreduction");
        GetCvars_handleString(s, f, cvar_g_xonoticversion, "g_xonoticversion");
        GetCvars_handleFloat(s, f, cvar_cl_handicap, "cl_handicap");
+       GetCvars_handleFloat(s, f, cvar_cl_clippedspectating, "cl_clippedspectating");
        GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriority, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);
        GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriorities[0], "cl_weaponpriority0", W_FixWeaponOrder_AllowIncomplete);
        GetCvars_handleString_Fixup(s, f, cvar_cl_weaponpriorities[1], "cl_weaponpriority1", W_FixWeaponOrder_AllowIncomplete);
index 0adbd5196af1731fecf51774167e77816d161c1b..e069aec9f3d7e18c1d2f9af5cfecc21aa745cd80 100644 (file)
@@ -87,16 +87,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, CH_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, CH_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
@@ -138,17 +141,56 @@ 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 not(other.iscreature)
+       if (other.deadflag != DEAD_NO)
                return;
 
        // for gameplay: vehicles can't teleport
@@ -164,49 +206,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;
@@ -214,7 +217,7 @@ void Teleport_Touch (void)
        if not(self.target) self.target = s;
 
        oldself = self;
-       self = e;
+       self = self.enemy;
        SUB_UseTargets();
        self = oldself;
 }
@@ -282,6 +285,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';
@@ -300,6 +314,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 4d44fe84e73327d4ff9a7762dcf35daa56ae72ad..29a378dc6c27892ce17635dfd1711c260f689f1e 100644 (file)
@@ -773,41 +773,47 @@ void WarpZone_StartFrame()
                WarpZone_PostInitialize_Callback();
        }
 
-       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 || e.movetype == MOVETYPE_FLY_WORLDONLY) // 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;
-                               if(WarpZone_PlaneDist(self, e.origin + e.view_ofs) <= 0)
-                                       WarpZone_Teleport(self, e, -1, 0); // 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())
+                                       if(WarpZone_PlaneDist(self, e.origin + e.view_ofs) <= 0)
+                                               WarpZone_Teleport(self, e, -1, 0); } // 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;