]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
Merge branch 'master' into Lyberta/TeamplayFixes_
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / onslaught / onslaught.qc
1 #include "onslaught.qh"
2
3 #ifdef GAMEQC
4 REGISTER_NET_LINKED(ENT_ONSCAMERA)
5 #endif
6
7 #ifdef CSQC
8
9 entity generator_camera;
10 NET_HANDLE(ENT_ONSCAMERA, bool isnew)
11 {
12         this.origin_x = ReadCoord();
13         this.origin_y = ReadCoord();
14         this.origin_z = ReadCoord();
15         setorigin(this, this.origin);
16
17         this.angles_x = ReadAngle();
18         this.angles_y = ReadAngle();
19         this.angles_z = ReadAngle();
20
21         this.drawmask  = MASK_NORMAL;
22         setmodel(this, MDL_Null); // give it a size for clientcamera
23         setsize(this, '-1 -1 -1', '1 1 1');
24
25         generator_camera = this;
26         return true;
27 }
28
29 REGISTER_MUTATOR(cl_ons, true);
30
31 float ons_roundlost;
32 vector generator_origin;
33 vector autocvar_cl_eventchase_generator_viewoffset = '0 0 80';
34 float autocvar_cl_eventchase_generator_distance = 400;
35 MUTATOR_HOOKFUNCTION(cl_ons, WantEventchase)
36 {
37         ons_roundlost = STAT(ROUNDLOST);
38         entity gen = NULL;
39         if(ons_roundlost)
40         {
41                 IL_EACH(g_onsgenerators, it.health <= 0,
42                 {
43                         gen = it;
44                         break;
45                 });
46                 if(!gen)
47                         ons_roundlost = false; // don't enforce the 3rd person camera if there is no dead generator to show
48         }
49
50         if(ons_roundlost)
51         {
52                 generator_origin = gen.origin;
53                 return true;
54         }
55         return false;
56 }
57
58 MUTATOR_HOOKFUNCTION(cl_ons, CustomizeEventchase)
59 {
60         if(ons_roundlost)
61         {
62                 M_ARGV(0, vector) = generator_camera.origin;
63                 M_ARGV(1, vector) = autocvar_cl_eventchase_generator_viewoffset;
64                 M_ARGV(0, float) = autocvar_cl_eventchase_generator_distance;
65                 return true;
66         }
67         return false;
68 }
69
70 #endif