1 // Zombie Apocalypse mutator - small side project
2 // Spawns a defined number of zombies at the start of a match
4 float za_numspawns, totalzombies, roundcnt, numzoms;
5 entity PickZombieSpawn()
9 RandomSelection_Init();
13 for(sp = world; (sp = find(sp, classname, "info_player_team1")); )
15 RandomSelection_Add(sp, 0, string_null, 1, 1);
20 for(sp = world; (sp = find(sp, classname, "info_player_deathmatch")); )
22 RandomSelection_Add(sp, 0, string_null, 1, 1);
26 return RandomSelection_chosen_ent;
29 void zombie_spawn_somewhere ()
31 if(gameover) { return; }
35 if(MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 1024, 256))
37 mon = spawnmonster("zombie", self, self, self.origin, TRUE, 2);
38 tracebox(mon.origin, mon.mins, mon.maxs, mon.origin, MOVE_NOMONSTERS, mon);
39 mon.spawnflags |= MONSTERFLAG_NORESPAWN;
43 sp = PickZombieSpawn();
45 setorigin(mon, sp.origin);
51 zombie_spawn_somewhere();
60 Send_CSQC_Centerprint_Generic(head, CPID_MINSTA_FINDAMMO, "All the zombies have been exterminated! Prepare for round 2!", 0, 0);
65 numzoms = autocvar_g_za_monster_count * roundcnt;
67 monsters_total = numzoms;
68 totalzombies = numzoms;
70 self.think = spawn_zombies;
71 self.nextthink = time + 10;
76 self.nextthink = time + 1;
80 self.think = za_roundwon;
81 self.nextthink = time;
85 if(gameover || numzoms <= 0)
90 print("Them zombies be spawnin'!\n");
95 e.think = zombie_spawn_somewhere;
108 numzoms = autocvar_g_za_monster_count * roundcnt;
110 monsters_total = numzoms;
111 totalzombies = numzoms;
114 e.think = spawn_zombies;
115 e.nextthink = time + 3;
118 MUTATOR_HOOKFUNCTION(za_ZombieDies)
120 if(frag_attacker.classname == "player")
121 PlayerScore_Add(frag_attacker, SP_SCORE, 1);
124 monsters_killed += 1;
128 MUTATOR_HOOKFUNCTION(za_BuildMutatorsString)
130 ret_string = strcat(ret_string, ":Zombies");
134 MUTATOR_HOOKFUNCTION(za_BuildMutatorsPrettyString)
136 ret_string = strcat(ret_string, ", Zombies");
140 MUTATOR_DEFINITION(mutator_zombie_apocalypse)
142 MUTATOR_HOOK(MonsterDies, za_ZombieDies, CBC_ORDER_ANY);
143 MUTATOR_HOOK(BuildMutatorsString, za_BuildMutatorsString, CBC_ORDER_ANY);
144 MUTATOR_HOOK(BuildMutatorsPrettyString, za_BuildMutatorsPrettyString, CBC_ORDER_ANY);