]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_invasion.qc
Add a special flag for powerful monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_invasion.qc
index 03c469c64320fc1601aeaf8482c10e3e72f1fd64..90d18d4fc9df02275395e80488e6b718b4c55b66 100644 (file)
@@ -5,18 +5,20 @@ void invasion_spawnpoint()
        self.classname = "invasion_spawnpoint";
 }
 
-float invasion_PickMonster()
+float invasion_PickMonster(float supermonster_count)
 {
        if(autocvar_g_invasion_zombies_only)
-               return MONSTER_ZOMBIE;
+               return MON_ZOMBIE;
 
        float i;
+       entity mon;
        
        RandomSelection_Init();
        
-       for(i = MONSTER_FIRST + 1; i < MONSTER_LAST; ++i)
+       for(i = MON_FIRST; i <= MON_LAST; ++i)
        {
-               if(i == MONSTER_STINGRAY || i == MONSTER_WYVERN)
+               mon = get_monsterinfo(i);
+               if((mon.spawnflags & MONSTER_TYPE_FLY) || (mon.spawnflags & MONSTER_TYPE_SWIM) || (mon.spawnflags & MON_FLAG_SUPERMONSTER && supermonster_count >= 1))
                        continue; // flying/swimming monsters not yet supported
                
                RandomSelection_Add(world, i, "", 1, 1);
@@ -52,9 +54,9 @@ void invasion_SpawnChosenMonster(float mon)
        monster = spawnmonster("", mon, spawn_point, spawn_point, spawn_point.origin, FALSE, 2);
 }
 
-void invasion_SpawnMonsters()
+void invasion_SpawnMonsters(float supermonster_count)
 {
-       float chosen_monster = invasion_PickMonster();
+       float chosen_monster = invasion_PickMonster(supermonster_count);
        
        invasion_SpawnChosenMonster(chosen_monster);
 }
@@ -71,6 +73,12 @@ float Invasion_CheckWinner()
                        if(head.iceblock) remove(head.iceblock);
                        remove(head);
                }
+               
+               if(roundcnt >= maxrounds)
+               {
+                       NextLevel();
+                       return 1;
+               }
        
                Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_OVER);
                Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_OVER);
@@ -78,16 +86,20 @@ float Invasion_CheckWinner()
                return 1;
        }
        
-       float total_alive_monsters = 0;
+       float total_alive_monsters = 0, supermonster_count = 0;
        
        FOR_EACH_MONSTER(head) if(head.health > 0)
+       {
+               if((get_monsterinfo(head.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
+                       ++supermonster_count;
                ++total_alive_monsters;
+       }
 
-       if((total_alive_monsters + numkilled) < maxspawned)
+       if((total_alive_monsters + numkilled) < maxspawned && maxcurrent < 10) // 10 at a time should be plenty
        {
                if(time >= last_check)
                {
-                       invasion_SpawnMonsters();
+                       invasion_SpawnMonsters(supermonster_count);
                        last_check = time + 2;
                }
                
@@ -144,6 +156,7 @@ void Invasion_RoundStart()
                
        roundcnt += 1;
        
+       maxcurrent = 0;
        numspawned = 0;
        numkilled = 0;
                
@@ -158,6 +171,7 @@ void Invasion_RoundStart()
 MUTATOR_HOOKFUNCTION(invasion_MonsterDies)
 {
        numkilled += 1;
+       maxcurrent -= 1;
        
        if(IS_PLAYER(frag_attacker))
                PlayerScore_Add(frag_attacker, SP_KILLS, +1);
@@ -177,6 +191,7 @@ MUTATOR_HOOKFUNCTION(invasion_MonsterSpawn)
        }
        
        numspawned += 1;
+       maxcurrent += 1;
        
        self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_BOTCLIP | DPCONTENTS_MONSTERCLIP;
        
@@ -232,6 +247,13 @@ MUTATOR_HOOKFUNCTION(invasion_PlayerCommand)
        return FALSE;
 }
 
+MUTATOR_HOOKFUNCTION(invasion_SetStartItems)
+{
+       start_armorvalue = 100;
+       
+       return FALSE;
+}
+
 void invasion_ScoreRules()
 {
        ScoreRules_basics(0, 0, 0, FALSE);
@@ -265,6 +287,7 @@ MUTATOR_DEFINITION(gamemode_invasion)
        MUTATOR_HOOK(PlayerSpawn, invasion_PlayerSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerDamage_Calculate, invasion_PlayerDamage, CBC_ORDER_ANY);
        MUTATOR_HOOK(SV_ParseClientCommand, invasion_PlayerCommand, CBC_ORDER_ANY);
+       MUTATOR_HOOK(SetStartItems, invasion_SetStartItems, CBC_ORDER_ANY);
        
        MUTATOR_ONADD
        {