2022-02-08 18:42:28 +00:00
|
|
|
/*
|
|
|
|
server/rounds.qc
|
|
|
|
|
|
|
|
wave logic
|
|
|
|
|
2022-04-06 01:46:24 +00:00
|
|
|
Copyright (C) 2021-2022 NZ:P Team
|
2022-02-08 18:42:28 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
float() spawn_a_dogA;
|
2022-04-06 01:46:24 +00:00
|
|
|
void() zapper_cooldown;
|
2022-02-08 18:42:28 +00:00
|
|
|
|
2022-09-03 00:19:25 +00:00
|
|
|
void() Spawn_Enemy =
|
2022-02-08 18:42:28 +00:00
|
|
|
{
|
|
|
|
// temporarily prevent spawning
|
|
|
|
if (nuke_powerup_spawndelay > time)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (roundtype == 1)
|
|
|
|
{
|
|
|
|
if (spawn_a_zombieA())
|
|
|
|
{
|
|
|
|
Current_Zombies = Current_Zombies + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (roundtype == 2)
|
|
|
|
{
|
|
|
|
if (spawn_a_dogA())
|
|
|
|
{
|
|
|
|
Current_Zombies = Current_Zombies + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
float(float a, float b) qc_max =
|
|
|
|
{
|
|
|
|
if (a < b)
|
|
|
|
return b;
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
float() getZombieTotal = {
|
|
|
|
if (roundtype == 1) {
|
|
|
|
float count, multiplier, plrcnt;
|
|
|
|
count = 24;
|
|
|
|
plrcnt = player_count + 1;
|
|
|
|
|
|
|
|
multiplier = qc_max(rounds/5, 1);
|
|
|
|
|
|
|
|
if (rounds >= 10)
|
|
|
|
multiplier *= rounds * 0.15;
|
|
|
|
|
|
|
|
if (plrcnt == 1)
|
2022-09-03 00:19:25 +00:00
|
|
|
count += rint((0.5 * 6) * multiplier);
|
2022-02-08 18:42:28 +00:00
|
|
|
else
|
|
|
|
count += rint((plrcnt * 6) * multiplier);
|
|
|
|
|
|
|
|
if (rounds < 2)
|
|
|
|
count = floor(count * 0.25);
|
|
|
|
else if (rounds < 3)
|
|
|
|
count = floor(count * 0.30);
|
|
|
|
else if (rounds < 4)
|
|
|
|
count = floor(count * 0.50);
|
|
|
|
else if (rounds < 5)
|
|
|
|
count = floor(count * 0.70);
|
|
|
|
else if (rounds < 6)
|
|
|
|
count = floor(count * 0.90);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
} else { //dogs
|
|
|
|
// 2 waves
|
|
|
|
if (rounds <= 14)
|
|
|
|
return 6 * (player_count + 1);
|
|
|
|
|
|
|
|
return 8 * (player_count + 1);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void(string s) playSoundAtPlayers =
|
|
|
|
{
|
|
|
|
local entity p;
|
|
|
|
p = find(world,classname,"player");
|
|
|
|
while(p)
|
|
|
|
{
|
|
|
|
sound(p,CHAN_AUTO,s,1,ATTN_NONE);
|
|
|
|
p = find(p,classname,"player");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void() updateDogRound =
|
|
|
|
{
|
|
|
|
float r = random();
|
|
|
|
|
|
|
|
if (r < 0.33) {
|
|
|
|
dogRound = rounds + 5;
|
|
|
|
} else if (r < 0.66) {
|
|
|
|
dogRound = rounds + 6;
|
|
|
|
} else {
|
|
|
|
dogRound = rounds + 7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-29 00:34:30 +00:00
|
|
|
void() PlayerSpawn;
|
|
|
|
|
2022-02-08 18:42:28 +00:00
|
|
|
void() EndRound =
|
|
|
|
{
|
2022-12-29 00:32:21 +00:00
|
|
|
entity who = find(world,classname,"spectator");
|
|
|
|
while(who != world)
|
|
|
|
{
|
|
|
|
if(who.isspec)
|
|
|
|
{
|
|
|
|
self = who;
|
|
|
|
PlayerSpawn();
|
|
|
|
}
|
|
|
|
who = find(who, classname, "spectator");
|
|
|
|
}
|
|
|
|
|
2022-02-08 18:42:28 +00:00
|
|
|
rounds_change = 4;
|
|
|
|
SetUpdate(self, UT_ROUNDS_CHANGE, rounds_change, 0, 0);
|
|
|
|
if (gotdog && rounds == dogRound) {
|
|
|
|
playSoundAtPlayers("sounds/rounds/droundend.wav");
|
|
|
|
dogWave = false;
|
|
|
|
} else {
|
|
|
|
playSoundAtPlayers("sounds/rounds/eround.wav");
|
|
|
|
}
|
|
|
|
round_changetime = time + 5;
|
|
|
|
|
|
|
|
// No Perks? No Problem & Abstinence Program
|
|
|
|
if (rounds >= 10) {
|
|
|
|
entity players;
|
|
|
|
players = find(world, classname, "player");
|
2022-09-03 00:19:25 +00:00
|
|
|
|
2022-02-08 18:42:28 +00:00
|
|
|
while(players != world) {
|
|
|
|
if (players.ach_tracker_npnp == 0) {
|
|
|
|
GiveAchievement(5, players);
|
|
|
|
}
|
|
|
|
if (players.ach_tracker_abst == 0) {
|
|
|
|
GiveAchievement(8, players);
|
|
|
|
}
|
|
|
|
players.ach_tracker_npnp = 0;
|
|
|
|
players = find(players, classname, "player");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void() NewRound =
|
2022-09-03 00:19:25 +00:00
|
|
|
{
|
2022-02-08 18:42:28 +00:00
|
|
|
entity tempe;
|
|
|
|
round_changetime = 0;
|
|
|
|
spawn_time = time + 5;
|
|
|
|
sounds_playing = 0;//just in case it ever somehow glitches
|
|
|
|
if (delay_at_round > 0.08)
|
|
|
|
{
|
|
|
|
delay_at_round = delay_at_round*0.95;
|
|
|
|
if (delay_at_round < 0.08)
|
|
|
|
delay_at_round = 0.08;
|
|
|
|
}
|
|
|
|
if (rounds != 0)
|
|
|
|
{
|
|
|
|
if (gotdog && rounds == (dogRound - 1)) {
|
|
|
|
playSoundAtPlayers("sounds/rounds/droundstart.wav");
|
|
|
|
dogWave = true;
|
|
|
|
} else {
|
|
|
|
playSoundAtPlayers("sounds/rounds/nround.wav");
|
|
|
|
}
|
|
|
|
rounds_change = 6;
|
|
|
|
SetUpdate(self, UT_ROUNDS_CHANGE, rounds_change, 0, 0);
|
|
|
|
blink_return = time + 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we just had a dog round, set the next
|
|
|
|
if (gotdog && rounds == dogRound) {
|
|
|
|
updateDogRound();
|
|
|
|
}
|
|
|
|
|
|
|
|
rounds = rounds + 1;
|
|
|
|
|
|
|
|
NotifyNewRound(rounds);
|
|
|
|
tempe = find(world, classname, "player");
|
|
|
|
while (tempe)
|
|
|
|
{
|
|
|
|
if(tempe.grenades & 1)
|
|
|
|
{
|
|
|
|
tempe.primary_grenades = tempe.primary_grenades + 2;
|
|
|
|
if (tempe.primary_grenades > 4)
|
|
|
|
tempe.primary_grenades = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(tempe.grenades & 2)
|
|
|
|
{
|
|
|
|
tempe.secondary_grenades = tempe.secondary_grenades + 2;
|
|
|
|
if (tempe.secondary_grenades > 2)
|
|
|
|
tempe.secondary_grenades = 2;
|
|
|
|
}
|
|
|
|
tempe = find(tempe, classname, "player");
|
|
|
|
}
|
|
|
|
|
|
|
|
set_z_health();
|
2022-09-03 00:19:25 +00:00
|
|
|
|
2022-02-08 18:42:28 +00:00
|
|
|
maxreward = 50 * rounds;
|
|
|
|
if (maxreward > 500)
|
|
|
|
maxreward = 500;
|
|
|
|
|
|
|
|
totalreward = 0;
|
|
|
|
Current_Zombies = 0;
|
|
|
|
spawn_delay = 0;
|
|
|
|
totalpowerups = 0;
|
2022-09-03 00:19:25 +00:00
|
|
|
|
2022-02-08 18:42:28 +00:00
|
|
|
if (rounds == dogRound && gotdog) {
|
|
|
|
roundtype = 2;
|
2023-01-25 02:41:26 +00:00
|
|
|
#ifdef PC
|
2023-01-25 02:40:53 +00:00
|
|
|
|
|
|
|
localcmd("fog 0.25\n");
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
localcmd("fog 200 225 177 193 204\n");
|
|
|
|
|
|
|
|
#endif // PC
|
2022-02-08 18:42:28 +00:00
|
|
|
} else {
|
|
|
|
roundtype = 1;
|
2022-09-03 00:19:25 +00:00
|
|
|
|
2022-02-08 18:42:28 +00:00
|
|
|
if (world.fog) {
|
2023-01-17 23:47:31 +00:00
|
|
|
|
|
|
|
#ifndef PC
|
|
|
|
|
2022-02-08 18:42:28 +00:00
|
|
|
localcmd(strcat("fog ", world.fog));
|
2023-01-17 23:47:31 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2022-02-08 18:42:28 +00:00
|
|
|
localcmd(strcat("fog ", world_fog));
|
2023-01-17 23:47:31 +00:00
|
|
|
|
|
|
|
#endif // PC
|
|
|
|
|
2022-02-08 18:42:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Remaining_Zombies = Total_Zombies = getZombieTotal();
|
|
|
|
|
|
|
|
switch(rounds) {
|
|
|
|
case 5: GiveAchievement(0); break;
|
|
|
|
case 10: GiveAchievement(1); break;
|
|
|
|
case 15: GiveAchievement(2); break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set up delay for zombie spawning
|
|
|
|
local float spawndelay;
|
|
|
|
|
|
|
|
spawndelay = zombie_spawn_delay;
|
|
|
|
|
|
|
|
if (spawndelay > 0.08) {
|
|
|
|
zombie_spawn_delay *= 0.95;
|
|
|
|
} else {
|
|
|
|
zombie_spawn_delay = 0.08;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 2 seconds by default
|
|
|
|
if (rounds == 1)
|
|
|
|
zombie_spawn_delay = 2;
|
|
|
|
|
|
|
|
// Actually start the timer
|
|
|
|
zombie_spawn_timer = 2 + time;
|
|
|
|
|
|
|
|
if (rounds >= 10 && ach_tracker_spin == 0) {
|
|
|
|
GiveAchievement(10);
|
|
|
|
}
|
2022-04-06 01:46:24 +00:00
|
|
|
|
|
|
|
// Refresh Electric Traps
|
|
|
|
entity zaps = find(world, classname, "zapper_switch");
|
|
|
|
while(zaps != world) {
|
|
|
|
if (zaps.mode == 1) {
|
|
|
|
zaps.think = zapper_cooldown;
|
|
|
|
zaps.nextthink = time + 0.1;
|
|
|
|
}
|
|
|
|
zaps = find(zaps, classname, "zapper_switch");
|
|
|
|
}
|
2022-02-08 18:42:28 +00:00
|
|
|
}
|
2022-07-02 12:54:04 +00:00
|
|
|
|
2022-02-08 18:42:28 +00:00
|
|
|
void() Round_Core =
|
|
|
|
{
|
|
|
|
if (game_over)
|
|
|
|
return;
|
|
|
|
|
2022-07-02 12:54:04 +00:00
|
|
|
if (round_changetime) {
|
|
|
|
if (round_changetime <= (time + 2)) {
|
|
|
|
if (!rounds)
|
|
|
|
rounds_change = 2;
|
|
|
|
else
|
|
|
|
rounds_change = 5;
|
|
|
|
}
|
2022-02-08 18:42:28 +00:00
|
|
|
}
|
2022-07-02 12:54:04 +00:00
|
|
|
if (blink_return && blink_return < time) {
|
|
|
|
if (rounds_change == 6) {
|
|
|
|
blink_return = time + 3;
|
|
|
|
rounds_change = 7;
|
|
|
|
} else {
|
|
|
|
blink_return = 0;
|
|
|
|
rounds_change = 0;
|
|
|
|
}
|
2022-02-08 18:42:28 +00:00
|
|
|
}
|
2022-07-02 12:54:04 +00:00
|
|
|
|
|
|
|
if (round_changetime < time && round_changetime != 0) {
|
2022-02-08 18:42:28 +00:00
|
|
|
roundtype = 1;
|
|
|
|
NewRound();
|
|
|
|
return;
|
2022-07-02 12:54:04 +00:00
|
|
|
} else if (round_changetime != 0) return;
|
|
|
|
|
|
|
|
if (Total_Zombies > Current_Zombies && spawn_time < time) {
|
2022-02-08 18:42:28 +00:00
|
|
|
Spawn_Enemy();
|
|
|
|
}
|
2022-07-02 12:54:04 +00:00
|
|
|
|
|
|
|
if (Remaining_Zombies < 1 && !Delay_Time) {
|
2022-02-08 18:42:28 +00:00
|
|
|
Delay_Time = time + 2;
|
|
|
|
rounds_change = 3;
|
2022-07-02 12:54:04 +00:00
|
|
|
} else if (Delay_Time && Delay_Time < time) {
|
2022-02-08 18:42:28 +00:00
|
|
|
Delay_Time = 0;
|
|
|
|
EndRound();
|
|
|
|
}
|
2022-07-02 12:54:04 +00:00
|
|
|
|
2022-02-08 18:42:28 +00:00
|
|
|
SetUpdate(self, UT_ROUNDS_CHANGE, rounds_change, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void() InitRounds =
|
2022-09-03 00:19:25 +00:00
|
|
|
{
|
2022-02-08 18:42:28 +00:00
|
|
|
roundtype = 1;
|
|
|
|
delay_at_round = 2/0.95;
|
|
|
|
totalpowerups = 0;
|
2022-04-24 03:18:38 +00:00
|
|
|
powerup_activate = 2000;
|
|
|
|
powerup_score_threshold = ((player_count + 1) * G_STARTPOINTS) + powerup_activate;
|
2022-02-08 18:42:28 +00:00
|
|
|
spawnAllZombEnts();
|
|
|
|
round_changetime = time + 3.5;
|
|
|
|
rounds_change = 1;
|
|
|
|
roundinit = 1;
|
|
|
|
SetUpdate(self, UT_ROUNDS_CHANGE, rounds_change, 0, 0);
|
2022-07-02 12:54:04 +00:00
|
|
|
}
|