]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/mutators/mutator_zombie_apocalypse.qc
Some more fixes to fish suffocating
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator_zombie_apocalypse.qc
1 // Zombie Apocalypse mutator - small side project
2 // Spawns a defined number of zombies at the start of a match
3
4 float za_numspawns;
5 entity PickZombieSpawn()
6 {
7         entity sp;
8         
9         RandomSelection_Init();
10         
11         if(teamplay)
12         {
13                 for(sp = world; (sp = find(sp, classname, "info_player_team1")); )
14                 {
15                         RandomSelection_Add(sp, 0, string_null, 1, 1);
16                 }
17         }
18         else
19         {
20                 for(sp = world; (sp = find(sp, classname, "info_player_deathmatch")); )
21                 {
22                         RandomSelection_Add(sp, 0, string_null, 1, 1);
23                 }
24         }
25         
26         return RandomSelection_chosen_ent;
27 }
28
29 void zombie_spawn_somewhere ()
30 {
31         if(gameover) { return; }
32     
33     entity mon, sp;
34         
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))
36         {
37                 mon = spawnmonster("zombie", self, self, self.origin, TRUE, 2);
38                 tracebox(mon.origin, mon.mins, mon.maxs, mon.origin, MOVE_NOMONSTERS, mon);
39
40                 if(trace_startsolid)
41                 {
42                         sp = PickZombieSpawn();
43                         if(sp)
44                                 setorigin(mon, sp.origin);
45                 }
46                         
47         za_numspawns += 1;
48         }
49         else
50                 zombie_spawn_somewhere();
51 }
52
53 void spawn_zombies ()
54 {      
55     float numzoms;
56     entity e;
57     
58     print("Them zombies be spawnin'!\n");
59
60         numzoms = autocvar_g_za_monster_count;
61
62         while(numzoms > 0)
63         {
64         e = spawn();
65                 e.think = zombie_spawn_somewhere;
66         e.nextthink = time;
67
68                 numzoms -= 1;
69         }
70         
71         if(self)
72         remove(self);
73 }
74
75 void za_init ()
76 {
77     entity e;
78     
79     e = spawn();
80         e.think = spawn_zombies;
81         e.nextthink = time + 3;
82 }
83
84 MUTATOR_HOOKFUNCTION(Zombies_BuildMutatorsString)
85 {
86         ret_string = strcat(ret_string, ":Zombies");
87         return 0;
88 }
89
90 MUTATOR_HOOKFUNCTION(Zombies_BuildMutatorsPrettyString)
91 {
92         ret_string = strcat(ret_string, ", Zombies");
93         return 0;
94 }
95
96 MUTATOR_DEFINITION(mutator_zombie_apocalypse)
97 {
98         MUTATOR_HOOK(BuildMutatorsString, Zombies_BuildMutatorsString, CBC_ORDER_ANY);
99         MUTATOR_HOOK(BuildMutatorsPrettyString, Zombies_BuildMutatorsPrettyString, CBC_ORDER_ANY);
100     
101     MUTATOR_ONADD
102     {
103         za_init();
104     }
105
106         return 0;
107 }