]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/gamemode/onslaught/sv_controlpoint.qc
d3b6d5c7f4c09f62d510db50b61c79685f1847b0
[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                 WriteVector(MSG_ENTITY, this.origin);
14
15                 WriteByte(MSG_ENTITY, this.health);
16                 WriteByte(MSG_ENTITY, this.max_health);
17                 WriteByte(MSG_ENTITY, this.count);
18                 WriteByte(MSG_ENTITY, this.team);
19                 WriteByte(MSG_ENTITY, this.owner.iscaptured);
20         }
21
22         if(sf & CPSF_STATUS)
23         {
24                 WriteByte(MSG_ENTITY, this.team);
25
26                 if(this.health <= 0)
27                         WriteByte(MSG_ENTITY, 0);
28                 else
29                         WriteByte(MSG_ENTITY, ceil((this.health / this.max_health) * 255));
30         }
31
32         return true;
33 }
34
35 void onslaught_controlpoint_icon_link(entity e, void(entity this) spawnproc)
36 {
37         Net_LinkEntity(e, true, 0, cpicon_send);
38         setthink(e, spawnproc);
39         e.nextthink     = time * sys_frametime;
40 }