From: Samual Date: Sun, 14 Aug 2011 22:28:31 +0000 (-0400) Subject: Merge remote branch 'origin/master' into samual/flyingspectators X-Git-Tag: xonotic-v0.5.0~109^2~7 X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=6d6a01255c7a5c146bbeb3daae6f527dd40f98d4;hp=5eefde1548c4dfd4e8fa20145b9285cdfb970b2a Merge remote branch 'origin/master' into samual/flyingspectators Conflicts: qcsrc/server/t_teleporters.qc qcsrc/warpzonelib/server.qc --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index abd694165..5d275d3b3 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -1733,7 +1733,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 diff --git a/qcsrc/client/movetypes.qh b/qcsrc/client/movetypes.qh index 3ec9a8f1d..2a917718f 100644 --- a/qcsrc/client/movetypes.qh +++ b/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_SPECTATOR = 14; float FL_ITEM = 256; float FL_ONGROUND = 512; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index a497f8c34..cc4920ff7 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -656,13 +656,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_SPECTATOR; //(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; @@ -691,9 +691,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; @@ -2527,6 +2527,7 @@ void checkSpectatorBlock() { void ObserverThink() { + float prefered_movetype; if (self.flags & FL_JUMPRELEASED) { if (self.BUTTON_JUMP && !self.version_mismatch) { self.welcomemessage_time = 0; @@ -2538,6 +2539,10 @@ void ObserverThink() if(SpectateNext() == 1) { self.classname = "spectator"; } + } else { + prefered_movetype = (self.cvar_cl_clippedspectating ? MOVETYPE_SPECTATOR : MOVETYPE_NOCLIP); + if (self.movetype != prefered_movetype) + self.movetype = prefered_movetype; } } else { if (!(self.BUTTON_ATCK || self.BUTTON_JUMP)) { diff --git a/qcsrc/server/cl_physics.qc b/qcsrc/server/cl_physics.qc index 83c438b47..4af6dac1c 100644 --- a/qcsrc/server/cl_physics.qc +++ b/qcsrc/server/cl_physics.qc @@ -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; diff --git a/qcsrc/server/constants.qh b/qcsrc/server/constants.qh index dca76fe00..038dae466 100644 --- a/qcsrc/server/constants.qh +++ b/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_SPECTATOR = 14; float SOLID_NOT = 0; float SOLID_TRIGGER = 1; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 2e8ba3d69..4809fcde0 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -313,6 +313,9 @@ float default_weapon_alpha; .float cvar_cl_handicap; .float cvar_cl_playerdetailreduction; .float cvar_scr_centertime; +.float cvar_cl_shownames; +.float cvar_cl_clippedspectating; + .string cvar_g_xonoticversion; .string cvar_cl_weaponpriority; .string cvar_cl_weaponpriorities[10]; diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index b669b041f..9a952ab54 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -582,6 +582,7 @@ void GetCvars(float f) GetCvars_handleFloat(s, f, cvar_scr_centertime, "scr_centertime"); 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); diff --git a/qcsrc/server/t_teleporters.qc b/qcsrc/server/t_teleporters.qc index 0adbd5196..e069aec9f 100644 --- a/qcsrc/server/t_teleporters.qc +++ b/qcsrc/server/t_teleporters.qc @@ -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) diff --git a/qcsrc/warpzonelib/server.qc b/qcsrc/warpzonelib/server.qc index 4d44fe84e..fd23bb854 100644 --- a/qcsrc/warpzonelib/server.qc +++ b/qcsrc/warpzonelib/server.qc @@ -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) // 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;