Xonotic
sv_controlpoint.qc
Go to the documentation of this file.
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, GetResource(this, RES_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(GetResource(this, RES_HEALTH) <= 0)
27  WriteByte(MSG_ENTITY, 0);
28  else
29  WriteByte(MSG_ENTITY, ceil((GetResource(this, RES_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 }
void onslaught_controlpoint_icon_link(entity e, void(entity this) spawnproc)
int team
Definition: main.qh:157
const int CPSF_STATUS
entity() spawn
entity to
Definition: self.qh:96
bool iscaptured
origin
Definition: ent_cs.qc:114
entity owner
Definition: main.qh:73
RES_HEALTH
Definition: ent_cs.qc:126
float sys_frametime
Definition: common.qh:57
float max_health
const int CPSF_SETUP
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float count
Definition: powerups.qc:22
bool cpicon_send(entity this, entity to, int sf)
#define setthink(e, f)
float time
Definition: csprogsdefs.qc:16