]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/controlpoint.qc
ecf3feef06a85958a6f3f2423ff8f5564da4b630
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / controlpoint.qc
1 #ifdef CSQC
2 float controlpoint_precached;
3
4 void controlpoint_precache()
5 {
6         if(controlpoint_precached)
7                 return; // already precached
8                 
9         precache_model("models/onslaught/controlpoint_pad.md3");
10         precache_model("models/onslaught/controlpoint_pad2.md3");
11         
12         controlpoint_precached = TRUE;
13 }
14
15 void controlpoint_draw()
16 {
17 }
18
19 void controlpoint_construct()
20 {
21         self.netname = "Control Point";
22
23         setorigin(self, self.origin);
24         setmodel(self, "models/onslaught/controlpoint_pad.md3");
25         setsize(self, CONTROLPOINT_MIN, CONTROLPOINT_MAX);
26         
27         self.move_movetype      = MOVETYPE_NOCLIP;
28         self.solid                      = SOLID_BBOX;
29         self.movetype           = MOVETYPE_NOCLIP; 
30         self.move_origin        = self.origin;
31         self.move_time          = time;
32         self.drawmask           = MASK_NORMAL;  
33         self.alpha                      = 1;
34         self.draw                       = controlpoint_draw;
35         self.health                     = 255;
36 }
37
38 .vector glowmod;
39 void controlpoint_changeteam()
40 {
41         if(self.team)
42         {
43                 self.glowmod = Team_ColorRGB(self.team - 1);
44                 self.teamradar_color = Team_ColorRGB(self.team - 1);
45                 self.colormap = 1024 + (self.team - 1) * 17;
46                 setmodel(self, "models/onslaught/controlpoint_pad2.md3");
47                 setsize(self, CONTROLPOINT_MIN, CONTROLPOINT_MAX);
48         }
49         else
50         {
51                 self.colormap = 1024;
52                 self.glowmod = '1 1 0';
53                 self.teamradar_color = '1 1 0';
54                 setmodel(self, "models/onslaught/controlpoint_pad.md3");
55                 setsize(self, CONTROLPOINT_MIN, CONTROLPOINT_MAX);
56         }
57 }
58
59 void ent_controlpoint()
60 {
61         float sf;
62         sf = ReadByte();
63
64         if(sf & CPSF_SETUP)
65         {
66                 self.origin_x = ReadCoord();
67                 self.origin_y = ReadCoord();
68                 self.origin_z = ReadCoord();
69                 setorigin(self, self.origin);
70                 
71                 self.team = ReadByte();
72                 
73                 if not(self.count)
74                         self.count = 40;
75                 
76                 controlpoint_changeteam();
77                 controlpoint_precache();
78                 controlpoint_construct();
79         }
80
81         if(sf & CPSF_STATUS)
82         {
83                 float _tmp;
84                 _tmp = ReadByte();
85                 if(_tmp != self.team)
86                 {                       
87                         self.team = _tmp;
88                         controlpoint_changeteam();
89                 }
90         }
91 }
92 #endif // CSQC
93
94 #ifdef SVQC
95 float controlpoint_send(entity to, float sf)
96 {
97         WriteByte(MSG_ENTITY, ENT_CLIENT_CONTROLPOINT);    
98         WriteByte(MSG_ENTITY, sf);
99         if(sf & CPSF_SETUP)
100         {
101             WriteCoord(MSG_ENTITY, self.origin_x);
102             WriteCoord(MSG_ENTITY, self.origin_y);
103             WriteCoord(MSG_ENTITY, self.origin_z);
104                 
105                 WriteByte(MSG_ENTITY, self.team);
106     }
107     
108     if(sf & CPSF_STATUS)
109     {
110                 WriteByte(MSG_ENTITY, self.team);
111     }
112     
113         return TRUE;
114 }
115
116 void controlpoint_link()
117 {
118     Net_LinkEntity(self, TRUE, 0, controlpoint_send);
119 }
120 #endif // SVQC