From c52c03d5245ba090e31c0d5b7da630940647292b Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Sun, 29 Jan 2012 13:24:03 +0200 Subject: [PATCH] Port flying spectators from Xonotic. They don't go through warpzones and teleporters however --- data/defaultVT.cfg | 2 ++ data/qcsrc/client/movetypes.qh | 1 + data/qcsrc/server/cl_client.qc | 14 +++++++++----- data/qcsrc/server/cl_physics.qc | 2 +- data/qcsrc/server/constants.qh | 1 + data/qcsrc/server/defs.qh | 1 + data/qcsrc/server/miscfunctions.qc | 1 + docs/TODO.txt | 4 ++-- 8 files changed, 18 insertions(+), 8 deletions(-) diff --git a/data/defaultVT.cfg b/data/defaultVT.cfg index c431a981..aebb1200 100644 --- a/data/defaultVT.cfg +++ b/data/defaultVT.cfg @@ -1393,6 +1393,8 @@ set sv_clones 0 "number of clones a player may make (reset by the \"kill\" comma set cl_handicap 1 "the higher, the more damage you will receive (client setting)" +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 alias menu_showteamselect "menu_cmd directmenu TeamSelect" diff --git a/data/qcsrc/client/movetypes.qh b/data/qcsrc/client/movetypes.qh index 8d3e20dd..c1d8b045 100644 --- a/data/qcsrc/client/movetypes.qh +++ b/data/qcsrc/client/movetypes.qh @@ -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; diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index 039017cf..33406554 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -623,7 +623,7 @@ void PutObserverInServer (void) self.health = -666; self.takedamage = DAMAGE_NO; self.solid = SOLID_NOT; - self.movetype = MOVETYPE_NOCLIP; + self.movetype = MOVETYPE_FLY_WORLDONLY; // user preference is controlled by playerprethink self.flags = FL_CLIENT | FL_NOTARGET; self.armorvalue = 666; self.effects = 0; @@ -652,9 +652,9 @@ void PutObserverInServer (void) self.fixangle = TRUE; self.crouch = FALSE; - self.view_ofs = PL_VIEW_OFS; + self.view_ofs = '0 0 0'; // so that your view doesn't go into the ceiling with MOVETYPE_FLY_WORLDONLY, previously "PL_VIEW_OFS" setorigin (self, spot.origin); - setsize (self, '0 0 0', '0 0 0'); + setsize (self, PL_CROUCH_MIN, PL_CROUCH_MAX); // give the spectator some space between walls for MOVETYPE_FLY_WORLDONLY self.prevorigin = self.origin; self.items = 0; self.weapons = 0; @@ -2390,17 +2390,20 @@ void SetPlayerSize() void ObserverThink() { + float prefered_movetype; if (self.flags & FL_JUMPRELEASED) { if (self.BUTTON_JUMP && !self.version_mismatch) { - self.welcomemessage_time = 0; self.flags &~= FL_JUMPRELEASED; self.flags |= FL_SPAWNING; } else if(self.BUTTON_ATCK && !self.version_mismatch) { - self.welcomemessage_time = 0; self.flags &~= FL_JUMPRELEASED; 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)) { @@ -2413,6 +2416,7 @@ void ObserverThink() } } } + PrintWelcomeMessage(self); } diff --git a/data/qcsrc/server/cl_physics.qc b/data/qcsrc/server/cl_physics.qc index 492dc2a4..f887a4b2 100644 --- a/data/qcsrc/server/cl_physics.qc +++ b/data/qcsrc/server/cl_physics.qc @@ -916,7 +916,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; diff --git a/data/qcsrc/server/constants.qh b/data/qcsrc/server/constants.qh index 8bcc5c68..70b8221a 100644 --- a/data/qcsrc/server/constants.qh +++ b/data/qcsrc/server/constants.qh @@ -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; diff --git a/data/qcsrc/server/defs.qh b/data/qcsrc/server/defs.qh index 5c468503..55cdcae9 100644 --- a/data/qcsrc/server/defs.qh +++ b/data/qcsrc/server/defs.qh @@ -325,6 +325,7 @@ float default_weapon_alpha; .float() customizeentityforclient; .float cvar_cl_handicap; +.float cvar_cl_clippedspectating; .float cvar_scr_centertime; .float cvar_cl_shownames; .string cvar_g_voretournamentversion; diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index 2e278f5d..caf444e8 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -596,6 +596,7 @@ void GetCvars(float f) GetCvars_handleFloat(s, f, cvar_cl_shownames, "cl_shownames"); GetCvars_handleString(s, f, cvar_g_voretournamentversion, "g_voretournamentversion"); 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); 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); diff --git a/docs/TODO.txt b/docs/TODO.txt index 55dd2d91..eef10c55 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -56,8 +56,6 @@ - 0.7 | 0.8: Add some saliva to the regurgitate particle effects (both constant and one-time effects) -- 0.8: Can I port the flying spectators from Xonotic? - - 0.7: Enable that new engine setting, to render models in batches for higher FPS - 0.7 | 0.8: Remake helper voices @@ -121,3 +119,5 @@ - 0.7 | 0.8 BUG: Gibbed dead bodies seem to keep throwing gibs infinitely on dedicated servers. - 0.8: Chat portraits for all models. + +- 0.7: Fix flying spectators not going through teleporters and warpzones. -- 2.39.2