]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/invasion/sv_invasion.qc
Merge branch 'master' into Lyberta/WaypointIcons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / invasion / sv_invasion.qc
index c9670a150c38d1dac71880355f6ce712b964b5e3..d74c2dfc2d12e474b84efd4b15bb86dcfc4d7319 100644 (file)
@@ -1,9 +1,12 @@
 #include "sv_invasion.qh"
 
+#include <common/mapobjects/triggers.qh>
 #include <common/monsters/sv_spawn.qh>
 #include <common/monsters/sv_spawner.qh>
 #include <common/monsters/sv_monsters.qh>
 
+#include <server/bot/api.qh>
+#include <server/world.qh>
 #include <server/teamplay.qh>
 
 IntrusiveList g_invasion_roundends;
@@ -207,7 +210,7 @@ void invasion_SpawnChosenMonster(Monster mon)
                setsize(e, mon.m_mins, mon.m_maxs);
 
                if(MoveToRandomMapLocation(e, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 1024, 256))
-                       monster = spawnmonster(e, tospawn, mon.monsterid, NULL, NULL, e.origin, false, false, 2);
+                       monster = spawnmonster(e, tospawn, mon, NULL, NULL, e.origin, false, false, 2);
                else
                {
                        delete(e);
@@ -215,7 +218,7 @@ void invasion_SpawnChosenMonster(Monster mon)
                }
        }
        else // if spawnmob field falls through (unset), fallback to mon (relying on spawnmonster for that behaviour)
-               monster = spawnmonster(spawn(), ((spawn_point.spawnmob && spawn_point.spawnmob != "") ? spawn_point.spawnmob : tospawn), mon.monsterid, spawn_point, spawn_point, spawn_point.origin, false, false, 2);
+               monster = spawnmonster(spawn(), ((spawn_point.spawnmob && spawn_point.spawnmob != "") ? spawn_point.spawnmob : tospawn), mon, spawn_point, spawn_point, spawn_point.origin, false, false, 2);
 
        if(!monster)
                return;
@@ -288,9 +291,9 @@ bool Invasion_CheckWinner()
 
        float total_alive_monsters = 0, supermonster_count = 0, red_alive = 0, blue_alive = 0, yellow_alive = 0, pink_alive = 0;
 
-       IL_EACH(g_monsters, GetResourceAmount(it, RESOURCE_HEALTH) > 0,
+       IL_EACH(g_monsters, GetResource(it, RES_HEALTH) > 0,
        {
-               if((get_monsterinfo(it.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
+               if(it.monsterdef.spawnflags & MON_FLAG_SUPERMONSTER)
                        ++supermonster_count;
                ++total_alive_monsters;
 
@@ -334,14 +337,20 @@ bool Invasion_CheckWinner()
        {
                if(red_alive > 0) { winner_team = NUM_TEAM_1; }
                if(blue_alive > 0)
-               if(winner_team) { winner_team = 0; }
-               else { winner_team = NUM_TEAM_2; }
+               {
+                       if(winner_team) { winner_team = 0; }
+                       else { winner_team = NUM_TEAM_2; }
+               }
                if(yellow_alive > 0)
-               if(winner_team) { winner_team = 0; }
-               else { winner_team = NUM_TEAM_3; }
+               {
+                       if(winner_team) { winner_team = 0; }
+                       else { winner_team = NUM_TEAM_3; }
+               }
                if(pink_alive > 0)
-               if(winner_team) { winner_team = 0; }
-               else { winner_team = NUM_TEAM_4; }
+               {
+                       if(winner_team) { winner_team = 0; }
+                       else { winner_team = NUM_TEAM_4; }
+               }
        }
        else
        {
@@ -429,13 +438,15 @@ MUTATOR_HOOKFUNCTION(inv, MonsterDies)
                if(teamplay) { inv_monsters_perteam[frag_target.team] -= 1; }
 
                if(IS_PLAYER(frag_attacker))
-               if(SAME_TEAM(frag_attacker, frag_target)) // in non-teamplay modes, same team = same player, so this works
-                       GameRules_scoring_add(frag_attacker, KILLS, -1);
-               else
                {
-                       GameRules_scoring_add(frag_attacker, KILLS, +1);
-                       if(teamplay)
-                               TeamScore_AddToTeam(frag_attacker.team, ST_INV_KILLS, +1);
+                       if(SAME_TEAM(frag_attacker, frag_target)) // in non-teamplay modes, same team = same player, so this works
+                               GameRules_scoring_add(frag_attacker, KILLS, -1);
+                       else
+                       {
+                               GameRules_scoring_add(frag_attacker, KILLS, +1);
+                               if(teamplay)
+                                       TeamScore_AddToTeam(frag_attacker.team, ST_INV_KILLS, +1);
+                       }
                }
        }
 }
@@ -459,7 +470,7 @@ MUTATOR_HOOKFUNCTION(inv, MonsterSpawn)
 
        mon.monster_skill = inv_monsterskill;
 
-       if((get_monsterinfo(mon.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
+       if(mon.monsterdef.spawnflags & MON_FLAG_SUPERMONSTER)
                Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_INVASION_SUPERMONSTER, mon.monster_name);
 }