]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/clanarena/clanarena.qh
Merge branch 'Mario/weapon_alias_fix' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / clanarena / clanarena.qh
index 8a94acd18746f927cdc1db8a7ee19d2921d8f51e..3b3dace64e30be13fad4c5ded3be8ba2b5a264ad 100644 (file)
@@ -1,56 +1,49 @@
 #pragma once
 
-#ifdef SVQC
-#include <common/mutators/base.qh>
-#include <server/round_handler.qh>
-#include <server/miscfunctions.qh>
+#include <common/mapinfo.qh>
 
-int autocvar_g_ca_point_limit;
-int autocvar_g_ca_point_leadlimit;
-float autocvar_g_ca_round_timelimit;
-bool autocvar_g_ca_team_spawns;
-//int autocvar_g_ca_teams;
-int autocvar_g_ca_teams_override;
-float autocvar_g_ca_warmup;
-
-
-int ca_teams;
-bool allowed_to_spawn;
-
-const int ST_CA_ROUNDS = 1;
-
-bool CA_CheckTeams();
-bool CA_CheckWinner();
-void CA_RoundStart();
-bool ca_isEliminated(entity e);
-
-REGISTER_MUTATOR(ca, false)
-{
-    MUTATOR_STATIC();
-       MUTATOR_ONADD
-       {
-               GameRules_teams(true);
-        GameRules_spawning_teams(autocvar_g_ca_team_spawns);
-        GameRules_limit_score(autocvar_g_ca_point_limit);
-        GameRules_limit_lead(autocvar_g_ca_point_leadlimit);
-
-               ca_teams = autocvar_g_ca_teams_override;
-               if (ca_teams < 2)
-                       ca_teams = cvar("g_ca_teams"); // read the cvar directly as it gets written earlier in the same frame
-
-               ca_teams = BITS(bound(2, ca_teams, 4));
-        GameRules_scoring(ca_teams, SFL_SORT_PRIO_PRIMARY, 0, {
-            field_team(ST_CA_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY);
-        });
-
-               allowed_to_spawn = true;
-               round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart);
-               round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit);
-               EliminatedPlayers_Init(ca_isEliminated);
-       }
-       return 0;
-}
-
-// should be removed in the future, as other code should not have to care
-.float caplayer; // 0.5 if scheduled to join the next round
+#ifdef CSQC
+void HUD_Mod_CA(vector pos, vector mySize);
+void HUD_Mod_CA_Export(int fh);
+#endif
+CLASS(ClanArena, Gametype)
+    INIT(ClanArena)
+    {
+        this.gametype_init(this, _("Clan Arena"),"ca","g_ca",GAMETYPE_FLAG_TEAMPLAY | GAMETYPE_FLAG_USEPOINTS,"","timelimit=20 pointlimit=10 teams=2 leadlimit=6",_("Kill all enemy teammates to win the round"));
+    }
+    METHOD(ClanArena, m_parse_mapinfo, bool(string k, string v))
+    {
+        if (!k) {
+            cvar_set("g_ca_teams", cvar_defstring("g_ca_teams"));
+            return true;
+        }
+        switch (k) {
+            case "teams":
+                cvar_set("g_ca_teams", v);
+                return true;
+        }
+        return false;
+    }
+    METHOD(ClanArena, m_isAlwaysSupported, bool(Gametype this, int spawnpoints, float diameter))
+    {
+        if(spawnpoints >= 8 && diameter > 4096)
+            return true;
+        return false;
+    }
+    METHOD(ClanArena, m_setTeams, void(string sa))
+    {
+        cvar_set("g_ca_teams", sa);
+    }
+    METHOD(ClanArena, m_configuremenu, void(Gametype this, entity menu, void(entity me, string pLabel, float pMin, float pMax, float pStep, string pCvar, string tCvar, string pTooltip) returns))
+    {
+        TC(Gametype, this);
+        returns(menu, _("Frag limit:"),      5,  100,  5, "fraglimit_override",        "g_ca_teams_override",          _("The amount of frags needed before the match will end"));
+    }
+#ifdef CSQC
+    ATTRIB(ClanArena, m_modicons, void(vector pos, vector mySize), HUD_Mod_CA);
+    ATTRIB(ClanArena, m_modicons_export, void(int fh), HUD_Mod_CA_Export);
 #endif
+    ATTRIB(ClanArena, m_legacydefaults, string, "10 20 0");
+ENDCLASS(ClanArena)
+REGISTER_GAMETYPE(CA, NEW(ClanArena));
+#define g_ca IS_GAMETYPE(CA)