]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
Add Read/WriteAngleVector macros to simplify the networking of angles
[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 = ReadVector();
13         setorigin(this, this.origin);
14
15         this.angles = ReadAngleVector();
16
17         this.drawmask  = MASK_NORMAL;
18         setmodel(this, MDL_Null); // give it a size for clientcamera
19         setsize(this, '-1 -1 -1', '1 1 1');
20
21         generator_camera = this;
22         return true;
23 }
24
25 REGISTER_MUTATOR(cl_ons, true);
26
27 float ons_roundlost;
28 vector generator_origin;
29 vector autocvar_cl_eventchase_generator_viewoffset = '0 0 80';
30 float autocvar_cl_eventchase_generator_distance = 400;
31 MUTATOR_HOOKFUNCTION(cl_ons, WantEventchase)
32 {
33         ons_roundlost = STAT(ROUNDLOST);
34         entity gen = NULL;
35         if(ons_roundlost)
36         {
37                 IL_EACH(g_onsgenerators, GetResource(it, RES_HEALTH) <= 0,
38                 {
39                         gen = it;
40                         break;
41                 });
42                 if(!gen)
43                         ons_roundlost = false; // don't enforce the 3rd person camera if there is no dead generator to show
44         }
45
46         if(ons_roundlost)
47         {
48                 generator_origin = gen.origin;
49                 return true;
50         }
51         return false;
52 }
53
54 MUTATOR_HOOKFUNCTION(cl_ons, CustomizeEventchase)
55 {
56         if(ons_roundlost)
57         {
58                 M_ARGV(0, vector) = generator_camera.origin;
59                 M_ARGV(1, vector) = autocvar_cl_eventchase_generator_viewoffset;
60                 M_ARGV(0, float) = autocvar_cl_eventchase_generator_distance;
61                 return true;
62         }
63         return false;
64 }
65
66 #endif