]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/gamemode/onslaught/sv_controlpoint.qc
0941833de8acd7430cc7fb35cef56c104bf405bf
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / onslaught / sv_controlpoint.qc
1 #include "sv_controlpoint.qh"
2
3 .bool iscaptured;
4
5 bool cpicon_send(entity this, entity to, int sf)
6 {
7         WriteHeader(MSG_ENTITY, ENT_CLIENT_CONTROLPOINT_ICON);
8         if(sf & CPSF_SETUP)
9                 sf &= ~CPSF_STATUS;
10         WriteByte(MSG_ENTITY, sf);
11         if(sf & CPSF_SETUP)
12         {
13                 WriteCoord(MSG_ENTITY, this.origin_x);
14                 WriteCoord(MSG_ENTITY, this.origin_y);
15                 WriteCoord(MSG_ENTITY, this.origin_z);
16
17                 WriteByte(MSG_ENTITY, this.health);
18                 WriteByte(MSG_ENTITY, this.max_health);
19                 WriteByte(MSG_ENTITY, this.count);
20                 WriteByte(MSG_ENTITY, this.team);
21                 WriteByte(MSG_ENTITY, this.owner.iscaptured);
22         }
23
24         if(sf & CPSF_STATUS)
25         {
26                 WriteByte(MSG_ENTITY, this.team);
27
28                 if(this.health <= 0)
29                         WriteByte(MSG_ENTITY, 0);
30                 else
31                         WriteByte(MSG_ENTITY, ceil((this.health / this.max_health) * 255));
32         }
33
34         return true;
35 }
36
37 void onslaught_controlpoint_icon_link(entity e, void(entity this) spawnproc)
38 {
39         Net_LinkEntity(e, true, 0, cpicon_send);
40         setthink(e, spawnproc);
41         e.nextthink     = time * sys_frametime;
42 }