]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_domination.qc
Fix Large Armor and Mega Health detection in Quake / Quake 3 maps. Fixes issues in...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_domination.qc
index 73148840a9f315fb96412be07232208a55c36ecf..c365eddd300a9cb4a32fddc34c9760d8abe50e23 100644 (file)
@@ -1,3 +1,8 @@
+#include "gamemode_domination.qh"
+#include "../_all.qh"
+
+#include "gamemode.qh"
+
 void dom_EventLog(string mode, float team_before, entity actor) // use an alias for easy changing and quick editing later
 {
        if(autocvar_sv_eventlog)
@@ -396,12 +401,21 @@ void havocbot_role_dom()
        }
 }
 
+MUTATOR_HOOKFUNCTION(dom_GetTeamCount)
+{
+       ret_float = domination_teams;
+       return 0;
+}
+
 MUTATOR_HOOKFUNCTION(dom_ResetMap)
 {
+       total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
        FOR_EACH_PLAYER(self)
        {
                PutClientInServer();
                self.player_blocked = 1;
+               if(IS_REAL_CLIENT(self))
+                       set_dom_state(self);
        }
        return 1;
 }
@@ -413,19 +427,19 @@ MUTATOR_HOOKFUNCTION(dom_PlayerSpawn)
                self.player_blocked = 1;
        else
                self.player_blocked = 0;
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(dom_ClientConnect)
 {
        set_dom_state(self);
-       return FALSE;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(dom_BotRoles)
 {
        self.havocbot_role = havocbot_role_dom;
-       return TRUE;
+       return true;
 }
 
 /*QUAKED spawnfunc_dom_controlpoint (0 .5 .8) (-16 -16 -24) (16 16 32)
@@ -500,11 +514,11 @@ void spawnfunc_dom_team()
 }
 
 // scoreboard setup
-void ScoreRules_dom()
+void ScoreRules_dom(float teams)
 {
        if(domination_roundbased)
        {
-               ScoreRules_basics(domination_teams, SFL_SORT_PRIO_PRIMARY, 0, TRUE);
+               ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, 0, true);
                ScoreInfo_SetLabel_TeamScore  (ST_DOM_CAPS, "caps", SFL_SORT_PRIO_PRIMARY);
                ScoreInfo_SetLabel_PlayerScore(SP_DOM_TAKES, "takes", 0);
                ScoreRules_basics_end();
@@ -517,8 +531,7 @@ void ScoreRules_dom()
                        sp_domticks = SFL_SORT_PRIO_PRIMARY;
                else
                        sp_score = SFL_SORT_PRIO_PRIMARY;
-               CheckAllowedTeams(world);
-               ScoreRules_basics(domination_teams, sp_score, sp_score, TRUE);
+               ScoreRules_basics(teams, sp_score, sp_score, true);
                ScoreInfo_SetLabel_TeamScore  (ST_DOM_TICKS,    "ticks",     sp_domticks);
                ScoreInfo_SetLabel_PlayerScore(SP_DOM_TICKS,    "ticks",     sp_domticks);
                ScoreInfo_SetLabel_PlayerScore(SP_DOM_TAKES,    "takes",     0);
@@ -568,13 +581,13 @@ void dom_spawnpoint(vector org)
 }
 
 // spawn some default teams if the map is not set up for domination
-void dom_spawnteams()
+void dom_spawnteams(float teams)
 {
        dom_spawnteam("Red", NUM_TEAM_1-1, "models/domination/dom_red.md3", 0, "domination/claim.wav", "", "Red team has captured a control point");
        dom_spawnteam("Blue", NUM_TEAM_2-1, "models/domination/dom_blue.md3", 0, "domination/claim.wav", "", "Blue team has captured a control point");
-       if(domination_teams >= 3)
+       if(teams >= 3)
                dom_spawnteam("Yellow", NUM_TEAM_3-1, "models/domination/dom_yellow.md3", 0, "domination/claim.wav", "", "Yellow team has captured a control point");
-       if(domination_teams >= 4)
+       if(teams >= 4)
                dom_spawnteam("Pink", NUM_TEAM_4-1, "models/domination/dom_pink.md3", 0, "domination/claim.wav", "", "Pink team has captured a control point");
        dom_spawnteam("", 0, "models/domination/dom_unclaimed.md3", 0, "", "", "");
 }
@@ -585,12 +598,22 @@ void dom_DelayedInit() // Do this check with a delay so we can wait for teams to
        if(find(world, classname, "dom_team") == world || autocvar_g_domination_teams_override >= 2)
        {
                print("No ""dom_team"" entities found on this map, creating them anyway.\n");
-               dom_spawnteams();
+               domination_teams = bound(2, ((autocvar_g_domination_teams_override < 2) ? autocvar_g_domination_default_teams : autocvar_g_domination_teams_override), 4);
+               dom_spawnteams(domination_teams);
        }
 
+       CheckAllowedTeams(world);
+       domination_teams = ((c4>=0) ? 4 : (c3>=0) ? 3 : 2);
+
+       addstat(STAT_DOM_TOTAL_PPS, AS_FLOAT, dom_total_pps);
+       addstat(STAT_DOM_PPS_RED, AS_FLOAT, dom_pps_red);
+       addstat(STAT_DOM_PPS_BLUE, AS_FLOAT, dom_pps_blue);
+       if(domination_teams >= 3) addstat(STAT_DOM_PPS_YELLOW, AS_FLOAT, dom_pps_yellow);
+       if(domination_teams >= 4) addstat(STAT_DOM_PPS_PINK, AS_FLOAT, dom_pps_pink);
+
        domination_roundbased = autocvar_g_domination_roundbased;
 
-       ScoreRules_dom();
+       ScoreRules_dom(domination_teams);
 
        if(domination_roundbased)
        {
@@ -608,25 +631,17 @@ void dom_Initialize()
        precache_model("models/domination/dom_unclaimed.md3");
        precache_sound("domination/claim.wav");
 
-       domination_teams = ((autocvar_g_domination_teams_override < 2) ? autocvar_g_domination_default_teams : autocvar_g_domination_teams_override);
-       domination_teams = ((c4>=0) ? 4 : (c3>=0) ? 3 : 2);
-
-       addstat(STAT_DOM_TOTAL_PPS, AS_FLOAT, dom_total_pps);
-       addstat(STAT_DOM_PPS_RED, AS_FLOAT, dom_pps_red);
-       addstat(STAT_DOM_PPS_BLUE, AS_FLOAT, dom_pps_blue);
-       if(domination_teams >= 3) addstat(STAT_DOM_PPS_YELLOW, AS_FLOAT, dom_pps_yellow);
-       if(domination_teams >= 4) addstat(STAT_DOM_PPS_PINK, AS_FLOAT, dom_pps_pink);
-
        InitializeEntity(world, dom_DelayedInit, INITPRIO_GAMETYPE);
 }
 
 
 MUTATOR_DEFINITION(gamemode_domination)
 {
+       MUTATOR_HOOK(GetTeamCount, dom_GetTeamCount, CBC_ORDER_ANY);
        MUTATOR_HOOK(reset_map_players, dom_ResetMap, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerSpawn, dom_PlayerSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(ClientConnect, dom_ClientConnect, CBC_ORDER_ANY);
-       MUTATOR_HOOK(HavocBot_ChooseRule, dom_BotRoles, CBC_ORDER_ANY);
+       MUTATOR_HOOK(HavocBot_ChooseRole, dom_BotRoles, CBC_ORDER_ANY);
 
        MUTATOR_ONADD
        {
@@ -637,7 +652,8 @@ MUTATOR_DEFINITION(gamemode_domination)
 
        MUTATOR_ONREMOVE
        {
-               error("This is a game type and it cannot be removed at runtime.");
+               print("This is a game type and it cannot be removed at runtime.");
+               return -1;
        }
 
        return 0;