From: Mario Date: Mon, 6 Jan 2014 20:40:42 +0000 (+1100) Subject: Clean up invasion global functions a bit X-Git-Tag: xonotic-v0.8.0~241^2^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ed1fe44d740ada0563b17cd3c2ddb06364c1877e;p=xonotic%2Fxonotic-data.pk3dir.git Clean up invasion global functions a bit --- diff --git a/gamemodes.cfg b/gamemodes.cfg index 268be55b9..a44b83ad5 100644 --- a/gamemodes.cfg +++ b/gamemodes.cfg @@ -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" diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 499b6ff02..fc9181d56 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -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; diff --git a/qcsrc/server/mutators/gamemode_invasion.qc b/qcsrc/server/mutators/gamemode_invasion.qc index 494afc48b..5acc70388 100644 --- a/qcsrc/server/mutators/gamemode_invasion.qc +++ b/qcsrc/server/mutators/gamemode_invasion.qc @@ -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) diff --git a/qcsrc/server/mutators/gamemode_invasion.qh b/qcsrc/server/mutators/gamemode_invasion.qh index 41ccfb3c7..3438f4724 100644 --- a/qcsrc/server/mutators/gamemode_invasion.qh +++ b/qcsrc/server/mutators/gamemode_invasion.qh @@ -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; diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index ce0c10535..2a1fb2e2f 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -244,7 +244,7 @@ void InitGameplayMode() if(g_invasion) { - maxrounds = cvar("fraglimit"); + inv_maxrounds = cvar("fraglimit"); cvar_set("fraglimit", "0"); }