]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_invasion.qc
Merge branch 'terencehill/lms_itemtimes_fix' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_invasion.qc
index 26a7b91dbb8536128c57a9d5c833476a2d1f03c5..b7730592c03fb680c48cfce3ad123d54405e338c 100644 (file)
@@ -61,10 +61,10 @@ const float ST_INV_KILLS = 1;
 
 #ifdef IMPLEMENTATION
 
-#include "../../../common/monsters/spawn.qh"
-#include "../../../common/monsters/sv_monsters.qh"
+#include <common/monsters/spawn.qh>
+#include <common/monsters/sv_monsters.qh>
 
-#include "../../teamplay.qh"
+#include <server/teamplay.qh>
 
 
 float autocvar_g_invasion_round_timelimit;
@@ -192,11 +192,9 @@ void invasion_SpawnMonsters(float supermonster_count)
 
 float Invasion_CheckWinner()
 {
-       entity head;
        if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
        {
-               FOR_EACH_MONSTER(head)
-                       Monster_Remove(head);
+               FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(Monster_Remove(it)));
 
                Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_OVER);
                Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_OVER);
@@ -206,21 +204,23 @@ float Invasion_CheckWinner()
 
        float total_alive_monsters = 0, supermonster_count = 0, red_alive = 0, blue_alive = 0, yellow_alive = 0, pink_alive = 0;
 
-       FOR_EACH_MONSTER(head) if(head.health > 0)
-       {
-               if((get_monsterinfo(head.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
-                       ++supermonster_count;
-               ++total_alive_monsters;
-
-               if(teamplay)
-               switch(head.team)
+       FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(
+               if(it.health > 0)
                {
-                       case NUM_TEAM_1: ++red_alive; break;
-                       case NUM_TEAM_2: ++blue_alive; break;
-                       case NUM_TEAM_3: ++yellow_alive; break;
-                       case NUM_TEAM_4: ++pink_alive; break;
+                       if((get_monsterinfo(it.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
+                               ++supermonster_count;
+                       ++total_alive_monsters;
+
+                       if(teamplay)
+                       switch(it.team)
+                       {
+                               case NUM_TEAM_1: ++red_alive; break;
+                               case NUM_TEAM_2: ++blue_alive; break;
+                               case NUM_TEAM_3: ++yellow_alive; break;
+                               case NUM_TEAM_4: ++pink_alive; break;
+                       }
                }
-       }
+       ));
 
        if((total_alive_monsters + inv_numkilled) < inv_maxspawned && inv_maxcurrent < inv_maxspawned)
        {
@@ -262,18 +262,18 @@ float Invasion_CheckWinner()
                else { winner_team = NUM_TEAM_4; }
        }
        else
-       FOR_EACH_PLAYER(head)
        {
-               float cs = PlayerScore_Add(head, SP_KILLS, 0);
-               if(cs > winning_score)
-               {
-                       winning_score = cs;
-                       winner = head;
-               }
+               FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+                       float cs = PlayerScore_Add(it, SP_KILLS, 0);
+                       if(cs > winning_score)
+                       {
+                               winning_score = cs;
+                               winner = it;
+                       }
+               ));
        }
 
-       FOR_EACH_MONSTER(head)
-               Monster_Remove(head);
+       FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(Monster_Remove(it)));
 
        if(teamplay)
        {
@@ -294,20 +294,18 @@ float Invasion_CheckWinner()
        return 1;
 }
 
-float Invasion_CheckPlayers()
+bool Invasion_CheckPlayers()
 {
        return true;
 }
 
 void Invasion_RoundStart()
 {
-       entity e;
-       float numplayers = 0;
-       FOR_EACH_PLAYER(e)
-       {
-               e.player_blocked = 0;
+       int numplayers = 0;
+       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+               it.player_blocked = false;
                ++numplayers;
-       }
+       ));
 
        if(inv_roundcnt < inv_maxrounds)
                inv_roundcnt += 1; // a limiter to stop crazy counts
@@ -331,15 +329,15 @@ void Invasion_RoundStart()
 }
 
 MUTATOR_HOOKFUNCTION(inv, MonsterDies)
-{SELFPARAM();
-       if(!(self.spawnflags & MONSTERFLAG_RESPAWNED))
+{
+       if(!(frag_target.spawnflags & MONSTERFLAG_RESPAWNED))
        {
                inv_numkilled += 1;
                inv_maxcurrent -= 1;
-               if(teamplay) { inv_monsters_perteam[self.team] -= 1; }
+               if(teamplay) { inv_monsters_perteam[frag_target.team] -= 1; }
 
                if(IS_PLAYER(frag_attacker))
-               if(SAME_TEAM(frag_attacker, self)) // in non-teamplay modes, same team = same player, so this works
+               if(SAME_TEAM(frag_attacker, frag_target)) // in non-teamplay modes, same team = same player, so this works
                        PlayerScore_Add(frag_attacker, SP_KILLS, -1);
                else
                {