]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_lms.qc
Bot AI: reduce powerup rating value
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_lms.qc
index 354c1e15f4637d221058b1fbb6891998e1b0dcda..a57b2ae2d07ab150bfd494492935da44e421e221 100644 (file)
@@ -1,6 +1,6 @@
 #include "gamemode_lms.qh"
 
-#include <common/mutators/mutator/instagib/items.qc>
+#include <common/mutators/mutator/instagib/items.qh>
 #include <server/campaign.qh>
 #include <server/command/_mod.qh>
 
@@ -35,25 +35,29 @@ void ClearWinners();
 // limit.
 int WinningCondition_LMS()
 {
-       entity head, head2;
-       bool have_player = false;
-       bool have_players = false;
-
-       int l = LMS_NewPlayerLives();
-
-       head = find(NULL, classname, STR_PLAYER);
-       if(head)
-               have_player = true;
-       head2 = find(head, classname, STR_PLAYER);
-       if(head2)
-               have_players = true;
+       entity first_player = NULL;
+       int total_players = 0;
+       FOREACH_CLIENT(IS_PLAYER(it), {
+               if (!total_players)
+                       first_player = it;
+               ++total_players;
+       });
 
-       if(have_player)
+       if (total_players)
        {
-               // we have at least one player
-               if(have_players)
+               if (total_players > 1)
                {
                        // two or more active players - continue with the game
+
+                       if (autocvar_g_campaign)
+                       {
+                               FOREACH_CLIENT(IS_REAL_CLIENT(it), {
+                                       float pl_lives = GameRules_scoring_add(it, LMS_LIVES, 0);
+                                       if (!pl_lives)
+                                               return WINNING_YES; // human player lost, game over
+                                       break;
+                               });
+                       }
                }
                else
                {
@@ -62,7 +66,7 @@ int WinningCondition_LMS()
                        ClearWinners();
                        SetWinners(winning, 0); // NOTE: exactly one player is still "player", so this works out
 
-                       if(l)
+                       if (LMS_NewPlayerLives())
                        {
                                // game still running (that is, nobody got removed from the game by a frag yet)? then continue
                                return WINNING_NO;
@@ -71,7 +75,7 @@ int WinningCondition_LMS()
                        {
                                // a winner!
                                // and assign him his first place
-                               GameRules_scoring_add(head, LMS_RANK, 1);
+                               GameRules_scoring_add(first_player, LMS_RANK, 1);
                                if(warmup_stage)
                                        return WINNING_NO;
                                else
@@ -82,7 +86,7 @@ int WinningCondition_LMS()
        else
        {
                // nobody is playing at all...
-               if(l)
+               if (LMS_NewPlayerLives())
                {
                        // wait for players...
                }
@@ -313,14 +317,14 @@ MUTATOR_HOOKFUNCTION(lms, ForbidPlayerScore_Clear)
        return true;
 }
 
-MUTATOR_HOOKFUNCTION(lms, FilterItem)
+MUTATOR_HOOKFUNCTION(lms, FilterItemDefinition)
 {
-       entity item = M_ARGV(0, entity);
+       entity definition = M_ARGV(0, entity);
 
-       if(autocvar_g_lms_extra_lives)
-       if(item.itemdef == ITEM_ExtraLife)
+       if (autocvar_g_lms_extra_lives && definition == ITEM_ExtraLife)
+       {
                return false;
-
+       }
        return true;
 }
 
@@ -419,19 +423,7 @@ MUTATOR_HOOKFUNCTION(lms, AddPlayerScore)
                return true; // allow writing to this field in intermission as it is needed for newly joining players
 }
 
-// scoreboard stuff
-void lms_ScoreRules()
-{
-    GameRules_score_enabled(false);
-       GameRules_scoring(0, 0, 0, {
-        field(SP_LMS_LIVES, "lives", SFL_SORT_PRIO_SECONDARY);
-        field(SP_LMS_RANK, "rank", SFL_LOWER_IS_BETTER | SFL_RANK | SFL_SORT_PRIO_PRIMARY | SFL_ALLOW_HIDE);
-       });
-}
-
 void lms_Initialize()
 {
        lms_lowest_lives = 9999;
-
-       lms_ScoreRules();
 }