]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up invasion global functions a bit
authorMario <mario.mario@y7mail.com>
Mon, 6 Jan 2014 20:40:42 +0000 (07:40 +1100)
committerMario <mario.mario@y7mail.com>
Mon, 6 Jan 2014 20:40:42 +0000 (07:40 +1100)
gamemodes.cfg
qcsrc/server/autocvars.qh
qcsrc/server/mutators/gamemode_invasion.qc
qcsrc/server/mutators/gamemode_invasion.qh
qcsrc/server/teamplay.qc

index 268be55b9a596829fc764426d532dcd2d763f884..a44b83ad5e79d7b25fd846a147a5b40ecef6fe43 100644 (file)
@@ -418,3 +418,4 @@ set g_invasion_round_timelimit 120 "maximum time to kill all monsters"
 set g_invasion_warmup 10 "time between waves to prepare for battle"
 set g_invasion_monster_count 10 "number of monsters on first wave (increments)"
 set g_invasion_zombies_only 0 "only spawn zombies"
+set g_invasion_spawn_delay 2 "spawn more monsters after this delay"
index 499b6ff0251d7924981a0afb87c4eef065c4a393..fc9181d56c473061faf366bf2b1c697f3bd969de 100644 (file)
@@ -1245,6 +1245,7 @@ float autocvar_g_invasion_round_timelimit;
 float autocvar_g_invasion_warmup;
 float autocvar_g_invasion_monster_count;
 float autocvar_g_invasion_zombies_only;
+float autocvar_g_invasion_spawn_delay;
 #define autocvar_g_bloodloss cvar("g_bloodloss")
 float autocvar_g_random_gravity_negative_chance;
 float autocvar_g_random_gravity_min;
index 494afc48baa77bee80e882afa66d74ac7f68f9f3..5acc70388804c45c22d8002d695bb8453d05cd7f 100644 (file)
@@ -53,8 +53,8 @@ void invasion_SpawnChosenMonster(float mon)
 
        monster = spawnmonster("", mon, spawn_point, spawn_point, spawn_point.origin, FALSE, 2);
 
-       if(roundcnt >= maxrounds)
-               monster.spawnflags |= MONSTERFLAG_MINIBOSS;
+       if(inv_roundcnt >= inv_maxrounds)
+               monster.spawnflags |= MONSTERFLAG_MINIBOSS; // last round spawns minibosses
 }
 
 void invasion_SpawnMonsters(float supermonster_count)
@@ -72,7 +72,7 @@ float Invasion_CheckWinner()
                FOR_EACH_MONSTER(head)
                        monster_remove(head);
 
-               if(roundcnt >= maxrounds)
+               if(inv_roundcnt >= inv_maxrounds)
                {
                        NextLevel();
                        return 1;
@@ -84,42 +84,30 @@ float Invasion_CheckWinner()
                return 1;
        }
 
-       // boss round
-       if(roundcnt >= maxrounds)
+       float total_alive_monsters = 0, supermonster_count = 0;
+
+       FOR_EACH_MONSTER(head) if(head.health > 0)
        {
-               if(numspawned < 1)
-               {
-                       maxspawned = 1;
-                       invasion_SpawnMonsters(0);
-               }
+               if((get_monsterinfo(head.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
+                       ++supermonster_count;
+               ++total_alive_monsters;
        }
-       else
-       {
-               float total_alive_monsters = 0, supermonster_count = 0;
 
-               FOR_EACH_MONSTER(head) if(head.health > 0)
+       if((total_alive_monsters + inv_numkilled) < inv_maxspawned && inv_maxcurrent < 10) // 10 at a time should be plenty
+       {
+               if(time >= inv_lastcheck)
                {
-                       if((get_monsterinfo(head.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
-                               ++supermonster_count;
-                       ++total_alive_monsters;
+                       invasion_SpawnMonsters(supermonster_count);
+                       inv_lastcheck = time + autocvar_g_invasion_spawn_delay;
                }
 
-               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)
+       if(inv_numspawned < 1 || inv_numkilled < inv_maxspawned)
                return 0; // nothing has spawned yet, or there are still alive monsters
 
-       if(roundcnt >= maxrounds)
+       if(inv_roundcnt >= inv_maxrounds)
        {
                NextLevel();
                return 1;
@@ -167,26 +155,23 @@ void Invasion_RoundStart()
                ++numplayers;
        }
 
-       roundcnt += 1;
+       inv_roundcnt += 1;
 
-       invasion_monsterskill = roundcnt + (numplayers * 0.3);
+       inv_monsterskill = inv_roundcnt + (numplayers * 0.3);
 
-       maxcurrent = 0;
-       numspawned = 0;
-       numkilled = 0;
+       inv_maxcurrent = 0;
+       inv_numspawned = 0;
+       inv_numkilled = 0;
 
-       if(roundcnt > 1)
-               maxspawned = rint(autocvar_g_invasion_monster_count * (roundcnt * 0.5));
-       else
-               maxspawned = autocvar_g_invasion_monster_count;
+       inv_maxspawned = rint(min(autocvar_g_invasion_monster_count, autocvar_g_invasion_monster_count * (inv_roundcnt * 0.5)));
 }
 
 MUTATOR_HOOKFUNCTION(invasion_MonsterDies)
 {
        if(!(self.spawnflags & MONSTERFLAG_RESPAWNED))
        {
-               numkilled += 1;
-               maxcurrent -= 1;
+               inv_numkilled += 1;
+               inv_maxcurrent -= 1;
 
                if(IS_PLAYER(frag_attacker))
                        PlayerScore_Add(frag_attacker, SP_KILLS, +1);
@@ -203,16 +188,13 @@ MUTATOR_HOOKFUNCTION(invasion_MonsterSpawn)
                return FALSE;
        }
 
-       if(roundcnt < maxrounds && self.spawnflags & MONSTERFLAG_MINIBOSS)
-               self.spawnflags &= ~MONSTERFLAG_MINIBOSS;
-
        if(!(self.spawnflags & MONSTERFLAG_RESPAWNED))
        {
-               numspawned += 1;
-               maxcurrent += 1;
+               inv_numspawned += 1;
+               inv_maxcurrent += 1;
        }
 
-       self.monster_skill = invasion_monsterskill;
+       self.monster_skill = inv_monsterskill;
 
        if((get_monsterinfo(self.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
                Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_INVASION_SUPERMONSTER, M_NAME(self.monsterid));
@@ -224,8 +206,8 @@ MUTATOR_HOOKFUNCTION(invasion_MonsterSpawn)
 
 MUTATOR_HOOKFUNCTION(invasion_PlayerThink)
 {
-       monsters_total = maxspawned; // TODO: make sure numspawned never exceeds maxspawned
-       monsters_killed = numkilled;
+       monsters_total = inv_maxspawned; // TODO: make sure numspawned never exceeds maxspawned
+       monsters_killed = inv_numkilled;
 
        return FALSE;
 }
@@ -260,13 +242,13 @@ MUTATOR_HOOKFUNCTION(invasion_PlayerCommand)
 
        if(cmd_name == "debuginvasion")
        {
-               sprint(self, strcat("maxspawned = ", ftos(maxspawned), "\n"));
-               sprint(self, strcat("numspawned = ", ftos(numspawned), "\n"));
-               sprint(self, strcat("numkilled = ", ftos(numkilled), "\n"));
-               sprint(self, strcat("roundcnt = ", ftos(roundcnt), "\n"));
+               sprint(self, strcat("inv_maxspawned = ", ftos(inv_maxspawned), "\n"));
+               sprint(self, strcat("inv_numspawned = ", ftos(inv_numspawned), "\n"));
+               sprint(self, strcat("inv_numkilled = ", ftos(inv_numkilled), "\n"));
+               sprint(self, strcat("inv_roundcnt = ", ftos(inv_roundcnt), "\n"));
                sprint(self, strcat("monsters_total = ", ftos(monsters_total), "\n"));
                sprint(self, strcat("monsters_killed = ", ftos(monsters_killed), "\n"));
-               sprint(self, strcat("invasion_monsterskill = ", ftos(invasion_monsterskill), "\n"));
+               sprint(self, strcat("inv_monsterskill = ", ftos(inv_monsterskill), "\n"));
 
                return TRUE;
        }
@@ -315,7 +297,7 @@ void invasion_Initialize()
 
        allowed_to_spawn = TRUE;
 
-       roundcnt = 0;
+       inv_roundcnt = 0;
 }
 
 MUTATOR_DEFINITION(gamemode_invasion)
index 41ccfb3c74abd3407224e70fff44c4b763547725..3438f472413b73901bce8028124a07f62a399515 100644 (file)
@@ -1,9 +1,9 @@
-float numspawned;
-float maxspawned;
-float roundcnt;
-float maxrounds;
-float numkilled;
-float last_check;
-float maxcurrent;
+float inv_numspawned;
+float inv_maxspawned;
+float inv_roundcnt;
+float inv_maxrounds;
+float inv_numkilled;
+float inv_lastcheck;
+float inv_maxcurrent;
 
-float invasion_monsterskill;
+float inv_monsterskill;
index ce0c10535b083b6f79e05f1bc29105bd5322f9bc..2a1fb2e2f8475a7dc791c57c05d961e4e6dc304f 100644 (file)
@@ -244,7 +244,7 @@ void InitGameplayMode()
        
        if(g_invasion)
        {
-               maxrounds = cvar("fraglimit");
+               inv_maxrounds = cvar("fraglimit");
                cvar_set("fraglimit", "0");
        }