]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
Merge branch 'martin-t/unused_fields' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / onslaught / onslaught.qc
1 #include "onslaught.qh"
2
3 #ifdef CSQC
4
5 REGISTER_MUTATOR(cl_ons, true);
6
7 float ons_roundlost;
8 vector generator_origin;
9 vector autocvar_cl_eventchase_generator_viewoffset = '0 0 80';
10 float autocvar_cl_eventchase_generator_distance = 400;
11 MUTATOR_HOOKFUNCTION(cl_ons, WantEventchase)
12 {
13         ons_roundlost = STAT(ROUNDLOST);
14         entity gen = NULL;
15         if(ons_roundlost)
16         {
17                 IL_EACH(g_onsgenerators, it.health <= 0,
18                 {
19                         gen = it;
20                         break;
21                 });
22                 if(!gen)
23                         ons_roundlost = false; // don't enforce the 3rd person camera if there is no dead generator to show
24         }
25
26         if(ons_roundlost)
27         {
28                 generator_origin = gen.origin;
29                 return true;
30         }
31         return false;
32 }
33
34 MUTATOR_HOOKFUNCTION(cl_ons, CustomizeEventchase)
35 {
36         if(ons_roundlost)
37         {
38                 M_ARGV(0, vector) = generator_origin;
39                 M_ARGV(1, vector) = autocvar_cl_eventchase_generator_viewoffset;
40                 M_ARGV(0, float) = autocvar_cl_eventchase_generator_distance;
41                 return true;
42         }
43         return false;
44 }
45
46 #endif