]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_invasion.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_invasion.qc
index b38a4e2b6d20378afc9232dc494f0349ce86b94a..8a7a4738f347c452b9d6a6772f313a70c2898551 100644 (file)
@@ -5,18 +5,20 @@ void invasion_spawnpoint()
        self.classname = "invasion_spawnpoint";
 }
 
-float invasion_PickMonster(float have_shamblers)
+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 || (i == MONSTER_SHAMBLER && have_shamblers >= 1))
+               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);
@@ -50,11 +52,14 @@ void invasion_SpawnChosenMonster(float mon)
        }
        
        monster = spawnmonster("", mon, spawn_point, spawn_point, spawn_point.origin, FALSE, 2);
+       
+       if(roundcnt >= maxrounds)
+               monster.spawnflags |= MONSTERFLAG_MINIBOSS;
 }
 
-void invasion_SpawnMonsters(float have_shamblers)
+void invasion_SpawnMonsters(float supermonster_count)
 {
-       float chosen_monster = invasion_PickMonster(have_shamblers);
+       float chosen_monster = invasion_PickMonster(supermonster_count);
        
        invasion_SpawnChosenMonster(chosen_monster);
 }
@@ -66,11 +71,16 @@ float Invasion_CheckWinner()
        {
                FOR_EACH_MONSTER(head)
                {
-                       WaypointSprite_Kill(head.sprite);
                        if(head.weaponentity) remove(head.weaponentity);
                        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,24 +88,36 @@ float Invasion_CheckWinner()
                return 1;
        }
        
-       float total_alive_monsters = 0, shamblers = 0;
-       
-       FOR_EACH_MONSTER(head) if(head.health > 0)
+       // boss round
+       if(roundcnt >= maxrounds)
        {
-               if(head.monsterid == MONSTER_SHAMBLER)
-                       ++shamblers;
-               ++total_alive_monsters;
+               if(numspawned < 1)
+               {
+                       maxspawned = 1;
+                       invasion_SpawnMonsters(0);
+               }
        }
-
-       if((total_alive_monsters + numkilled) < maxspawned && maxcurrent < 10) // 10 at a time should be plenty
+       else
        {
-               if(time >= last_check)
+               float total_alive_monsters = 0, supermonster_count = 0;
+               
+               FOR_EACH_MONSTER(head) if(head.health > 0)
                {
-                       invasion_SpawnMonsters(shamblers);
-                       last_check = time + 2;
+                       if((get_monsterinfo(head.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
+                               ++supermonster_count;
+                       ++total_alive_monsters;
+               }
+
+               if((total_alive_monsters + numkilled) < maxspawned && maxcurrent < 10) // 10 at a time should be plenty
+               {
+                       if(time >= last_check)
+                       {
+                               invasion_SpawnMonsters(supermonster_count);
+                               last_check = time + 2;
+                       }
+                       
+                       return 0;
                }
-               
-               return 0;
        }
        
        if(numspawned < 1 || numkilled < maxspawned)
@@ -162,28 +184,36 @@ void Invasion_RoundStart()
 
 MUTATOR_HOOKFUNCTION(invasion_MonsterDies)
 {
-       numkilled += 1;
-       maxcurrent -= 1;
+       if not(self.monster_respawned)
+       {
+               numkilled += 1;
+               maxcurrent -= 1;
        
-       if(IS_PLAYER(frag_attacker))
-               PlayerScore_Add(frag_attacker, SP_KILLS, +1);
+               if(IS_PLAYER(frag_attacker))
+                       PlayerScore_Add(frag_attacker, SP_KILLS, +1);
+       }
        
        return FALSE;
 }
 
 MUTATOR_HOOKFUNCTION(invasion_MonsterSpawn)
 {
-       if(self.realowner == world)
+       if not(self.spawnflags & MONSTERFLAG_SPAWNED)
        {
-               WaypointSprite_Kill(self.sprite);
                if(self.weaponentity) remove(self.weaponentity);
                if(self.iceblock) remove(self.iceblock);
                remove(self);
                return FALSE;
        }
        
-       numspawned += 1;
-       maxcurrent += 1;
+       if(roundcnt < maxrounds && self.spawnflags & MONSTERFLAG_MINIBOSS)
+               self.spawnflags &= ~MONSTERFLAG_MINIBOSS;
+       
+       if not(self.monster_respawned)
+       {
+               numspawned += 1;
+               maxcurrent += 1;
+       }
        
        self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_BOTCLIP | DPCONTENTS_MONSTERCLIP;
        
@@ -212,9 +242,6 @@ MUTATOR_HOOKFUNCTION(invasion_PlayerDamage)
                frag_force = '0 0 0';
        }
        
-       if(frag_attacker.flags & FL_MONSTER && frag_target.flags & FL_MONSTER && frag_attacker != frag_target)
-               frag_damage = 0;
-       
        return FALSE;
 }
 
@@ -241,7 +268,8 @@ MUTATOR_HOOKFUNCTION(invasion_PlayerCommand)
 
 MUTATOR_HOOKFUNCTION(invasion_SetStartItems)
 {
-       start_armorvalue = 100;
+       start_health = 200;
+       start_armorvalue = 200;
        
        return FALSE;
 }