]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add option to disable freecam in Clan Arena
authorz411 <z411@omaera.org>
Tue, 11 Oct 2022 06:48:12 +0000 (03:48 -0300)
committerz411 <z411@omaera.org>
Tue, 11 Oct 2022 06:48:12 +0000 (03:48 -0300)
gamemodes-server.cfg
qcsrc/client/hud/panel/infomessages.qc
qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc
qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qh
qcsrc/server/client.qc
qcsrc/server/world.qc
qcsrc/server/world.qh

index a57c8f135c70aa561cf68ee2a0e52bb02aa80947..89d3ab957a9f6775445a80ef4f0712f2462b812f 100644 (file)
@@ -222,7 +222,7 @@ set g_assault 0 "Assault: attack the enemy base as fast as you can, then defend
 set g_ca 0 "Clan Arena: Played in rounds, once you're dead you're out! The team with survivors wins the round"
 set g_ca_point_limit -1 "Clan Arena point limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
 set g_ca_point_leadlimit -1 "Clan Arena point lead limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
-set g_ca_spectate_enemies 0 "allow eliminated players to spectate enemy players during Clan Arena games"
+set g_ca_spectate_enemies 0 "allow eliminated players to spectate enemy players during Clan Arena games. -1 blocks freeroam camera"
 set g_ca_warmup 10 "time players get to run around before the round starts"
 set g_ca_damage2score 100  "every this amount of damage done give players 1 point"
 set g_ca_round_timelimit 180 "round time limit in seconds"
index 0f0325eeba18bfd3b1a429422c7cbd41071120e2..438fb4de6ba3d47f39717c8130fe507c98d98ff3 100644 (file)
@@ -109,8 +109,10 @@ void HUD_InfoMessages()
                                        case 1:
                                                if(spectatee_status == -1)
                                                        s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey(_("next weapon"), "weapnext"), getcommandkey(_("previous weapon"), "weapprev"));
-                                               else
+                                               else if(!observe_blocked)
                                                        s = sprintf(_("^1Press ^3%s^1 to observe, ^3%s^1 to change camera mode"), getcommandkey(_("secondary fire"), "+fire2"), getcommandkey(_("drop weapon"), "dropweapon"));
+                                               else
+                                                       s = sprintf(_("^1Press ^3%s^1 to change camera mode"), getcommandkey(_("drop weapon"), "dropweapon"));
                                                break;
                                        case 2:
                                                s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey(_("server info"), "+show_info"));
index ff51fb54c5d3d2208c792280356e410ef4806776..1d9d07801a45d121696367fc9b78bdc348c726c0 100644 (file)
@@ -653,6 +653,7 @@ NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
                newspectatee_status = 0;
 
        spectatorbutton_zoom = (f & BIT(2));
+       observe_blocked = (f & BIT(3));
 
        if(f & BIT(4))
        {
index 1f1c29002dfcc3df1b4224c8566e350a007a8c60..00dd149638de748bb50cf927b89ec9e20a2c5f92 100644 (file)
@@ -97,6 +97,7 @@ vector view_origin, view_forward, view_right, view_up;
 
 bool button_zoom;
 bool spectatorbutton_zoom;
+bool observe_blocked;
 bool button_attack2;
 
 float current_viewzoom;
index 7803108c6c00010cb896fce7fde81da0fbfebc00..383a281d545c18fb761a6b0bf447b2b5abe56670 100644 (file)
@@ -1,7 +1,6 @@
 #include "sv_clanarena.qh"
 
 float autocvar_g_ca_damage2score = 100;
-bool autocvar_g_ca_spectate_enemies;
 
 float autocvar_g_ca_start_health = 200;
 float autocvar_g_ca_start_armor = 200;
@@ -287,6 +286,8 @@ MUTATOR_HOOKFUNCTION(ca, MakePlayerObserver)
                player.frags = FRAGS_PLAYER_OUT_OF_GAME;
        if (!warmup_stage)
                eliminatedPlayers.SendFlags |= 1;
+       if (autocvar_g_ca_spectate_enemies == -1)
+               player.would_spectate = true; // force to spectate only
        if (!INGAME(player))
                return false;  // allow team reset
        return true;  // prevent team reset
@@ -425,7 +426,7 @@ MUTATOR_HOOKFUNCTION(ca, SpectateSet)
        entity client = M_ARGV(0, entity);
        entity targ = M_ARGV(1, entity);
 
-       if (!autocvar_g_ca_spectate_enemies && INGAME(client))
+       if (autocvar_g_ca_spectate_enemies != 0 && INGAME(client))
        if (DIFF_TEAM(targ, client))
                return true;
 }
@@ -434,7 +435,7 @@ MUTATOR_HOOKFUNCTION(ca, SpectateNext)
 {
        entity client = M_ARGV(0, entity);
 
-       if (!autocvar_g_ca_spectate_enemies && INGAME(client)
+       if (autocvar_g_ca_spectate_enemies != 0 && INGAME(client)
                && Team_GetNumberOfAlivePlayers(Entity_GetTeam(client)))
        {
                entity targ = M_ARGV(1, entity);
@@ -449,7 +450,7 @@ MUTATOR_HOOKFUNCTION(ca, SpectatePrev)
        entity targ = M_ARGV(1, entity);
        entity first = M_ARGV(2, entity);
 
-       if (!autocvar_g_ca_spectate_enemies && INGAME(client)
+       if (autocvar_g_ca_spectate_enemies != 0 && INGAME(client)
                && Team_GetNumberOfAlivePlayers(Entity_GetTeam(client)))
        {
                do { targ = targ.chain; }
index c7e147a21a95d6d4c7c54f321b605600aa693034..c6a4ebe997572ff460a88f54cd159a6780c52a81 100644 (file)
@@ -5,6 +5,7 @@
 #include <server/round_handler.qh>
 #include <server/command/sv_cmd.qh>
 
+int autocvar_g_ca_spectate_enemies;
 int autocvar_g_ca_point_limit;
 int autocvar_g_ca_point_leadlimit;
 float autocvar_g_ca_round_timelimit;
index eb2ba1dcf7234831965879998894cedc3b0d13d6..ba3428c5c50ddf7842d072b65016fe0ba3b0c80a 100644 (file)
@@ -7,6 +7,7 @@
 #include <common/ent_cs.qh>
 #include <common/gamemodes/_mod.qh>
 #include <common/gamemodes/gamemode/nexball/sv_nexball.qh>
+#include <common/gamemodes/gamemode/clanarena/sv_clanarena.qh>
 #include <common/items/_mod.qh>
 #include <common/items/inventory.qh>
 #include <common/mapobjects/func/conveyor.qh>
@@ -138,6 +139,7 @@ bool ClientData_Send(entity this, entity to, int sf)
        if (CS(e).race_completed)       sf |= BIT(0); // forced scoreboard
        if (CS(to).spectatee_status)    sf |= BIT(1); // spectator ent number follows
        if (CS(e).zoomstate)            sf |= BIT(2); // zoomed
+       if (observe_blocked)            sf |= BIT(3); // observing blocked
        if (autocvar_sv_showspectators == 1 || (autocvar_sv_showspectators && IS_SPEC(to)))
                                        sf |= BIT(4); // show spectators
 
@@ -2253,10 +2255,12 @@ void ObserverOrSpectatorThink(entity this)
                                }
                                CS(this).impulse = 0;
                        } else if(PHYS_INPUT_BUTTON_ATCK2(this)) {
-                               this.would_spectate = false;
-                               this.flags &= ~FL_JUMPRELEASED;
-                               TRANSMUTE(Observer, this);
-                               PutClientInServer(this);
+                               if(!observe_blocked) {
+                                       this.would_spectate = false;
+                                       this.flags &= ~FL_JUMPRELEASED;
+                                       TRANSMUTE(Observer, this);
+                                       PutClientInServer(this);
+                               }
                        } else if(!SpectateUpdate(this) && !SpectateNext(this)) {
                                PutObserverInServer(this, false, true);
                                this.would_spectate = true;
index 7f651fa7748291ff5e7090192793cf39c206afa9..119341cd270a83d080d5f5fb83e017fd4794bc03 100644 (file)
@@ -706,6 +706,9 @@ void InitGameplayMode()
        cache_mutatormsg = strzone("");
        cache_lastmutatormsg = strzone("");
 
+       if (g_ca && autocvar_g_ca_spectate_enemies == -1)
+               observe_blocked = true;
+
        InitializeEntity(NULL, GameplayMode_DelayedInit, INITPRIO_GAMETYPE_FALLBACK);
 }
 
index d82469c11ef1ca7573752897113a614c673e01f3..fe43e3881e2c0176e27bfec5e72412f114aa8253 100644 (file)
@@ -159,3 +159,5 @@ void droptofloor(entity this);
 
 IntrusiveList g_moveables;
 STATIC_INIT(g_moveables) { g_moveables = IL_NEW(); }
+
+bool observe_blocked = false;