Xonotic
cl_controlpoint.qc File Reference
#include "cl_controlpoint.qh"
+ Include dependency graph for cl_controlpoint.qc:

Go to the source code of this file.

Functions

void cpicon_changeteam (entity this)
 
void cpicon_construct (entity this, bool isnew)
 
void cpicon_damage (entity this, float hp)
 
void cpicon_draw (entity this)
 
 NET_HANDLE (ENT_CLIENT_CONTROLPOINT_ICON, bool isnew)
 

Variables

float alpha
 
vector colormod
 
int count
 
float cp_bob_dmg_z
 
vector cp_bob_origin
 
float cp_bob_spd
 
vector cp_origin
 
vector glowmod
 
entity icon_realmodel
 
bool iscaptured
 
float max_health
 
float pain_finished
 
vector punchangle
 

Function Documentation

◆ cpicon_changeteam()

void cpicon_changeteam ( entity  this)

Definition at line 142 of file cl_controlpoint.qc.

References colormap, glowmod, team, and Team_ColorRGB().

Referenced by NET_HANDLE().

143 {
144  if(this.team)
145  {
146  this.glowmod = Team_ColorRGB(this.team - 1);
147  this.teamradar_color = Team_ColorRGB(this.team - 1);
148  this.colormap = 1024 + (this.team - 1) * 17;
149  }
150  else
151  {
152  this.colormap = 1024;
153  this.glowmod = '1 1 0';
154  this.teamradar_color = '1 1 0';
155  }
156 }
float colormap
Definition: csprogsdefs.qc:131
int team
Definition: main.qh:157
vector Team_ColorRGB(int teamid)
Definition: teams.qh:76
vector glowmod
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cpicon_construct()

void cpicon_construct ( entity  this,
bool  isnew 
)

Definition at line 107 of file cl_controlpoint.qc.

References alpha, cp_bob_origin, cp_bob_spd, cp_origin, cpicon_draw(), CPICON_MAX, CPICON_MIN, drawmask, g_drawables, icon_realmodel, IL_PUSH(), iscaptured, MASK_NORMAL, move_time, MOVETYPE_NOCLIP, netname, NULL, origin, set_movetype(), setmodel, setorigin(), solid, SOLID_BBOX, SOLID_NOT, and time.

Referenced by NET_HANDLE().

108 {
109  this.netname = "Control Point Icon";
110 
111  setmodel(this, MDL_ONS_CP);
112  setsize(this, CPICON_MIN, CPICON_MAX);
113 
114  if(this.icon_realmodel == NULL)
115  {
116  this.icon_realmodel = new(cpicon_model);
117  setmodel(this.icon_realmodel, MDL_Null);
118  setorigin(this.icon_realmodel, this.origin);
119  setsize(this.icon_realmodel, CPICON_MIN, CPICON_MAX);
121  this.icon_realmodel.solid = SOLID_NOT;
122  }
123 
124  if(this.iscaptured) { this.icon_realmodel.solid = SOLID_BBOX; }
125 
127  this.solid = SOLID_NOT;
129  this.move_time = time;
130  this.drawmask = MASK_NORMAL;
131  this.alpha = 1;
132  this.draw = cpicon_draw;
133  this.cp_origin = this.origin;
134  this.cp_bob_origin = '0 0 0.1';
135  this.cp_bob_spd = 0;
136 
137  if(isnew)
138  IL_PUSH(g_drawables, this);
139 }
const float SOLID_NOT
Definition: csprogsdefs.qc:244
float cp_bob_spd
entity icon_realmodel
string netname
Definition: powerups.qc:20
origin
Definition: ent_cs.qc:114
const vector CPICON_MIN
#define setmodel(this, m)
Definition: model.qh:26
vector cp_origin
float alpha
vector cp_bob_origin
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
bool iscaptured
#define NULL
Definition: post.qh:17
const float MASK_NORMAL
Definition: csprogsdefs.qc:164
float drawmask
Definition: csprogsdefs.qc:95
void cpicon_draw(entity this)
float MOVETYPE_NOCLIP
Definition: progsdefs.qc:254
const vector CPICON_MAX
float move_time
Definition: movetypes.qh:77
const float SOLID_BBOX
Definition: csprogsdefs.qc:246
setorigin(ent, v)
float time
Definition: csprogsdefs.qc:16
IntrusiveList g_drawables
Definition: main.qh:77
void set_movetype(entity this, int mt)
float solid
Definition: csprogsdefs.qc:99
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cpicon_damage()

void cpicon_damage ( entity  this,
float  hp 
)

Definition at line 85 of file cl_controlpoint.qc.

References colormod, cp_bob_dmg_z, CPICON_MAX, CPICON_MIN, iscaptured, max_health, pain_finished, punchangle, random(), randomvec(), setmodel, and time.

Referenced by NET_HANDLE().

86 {
87  if(!this.iscaptured) { return; }
88 
89  if(hp < this.max_health * 0.25)
90  setmodel(this, MDL_ONS_CP3);
91  else if(hp < this.max_health * 0.50)
92  setmodel(this, MDL_ONS_CP2);
93  else if(hp < this.max_health * 0.75)
94  setmodel(this, MDL_ONS_CP1);
95  else if(hp <= this.max_health || hp >= this.max_health)
96  setmodel(this, MDL_ONS_CP);
97 
98  this.punchangle = (2 * randomvec() - '1 1 1') * 45;
99 
100  this.cp_bob_dmg_z = (2 * random() - 1) * 15;
101  this.pain_finished = time + 1;
102  this.colormod = '2 2 2';
103 
104  setsize(this, CPICON_MIN, CPICON_MAX);
105 }
vector punchangle
const vector CPICON_MIN
#define setmodel(this, m)
Definition: model.qh:26
bool iscaptured
vector colormod
float max_health
float cp_bob_dmg_z
const vector CPICON_MAX
float pain_finished
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cpicon_draw()

void cpicon_draw ( entity  this)

Definition at line 21 of file cl_controlpoint.qc.

References alpha, bound(), colormod, cos(), cp_bob_dmg_z, cp_bob_origin, cp_bob_spd, cp_origin, eZ, frametime, GetResource(), iscaptured, max_health, move_time, pain_finished, PI, RES_HEALTH, setorigin(), and time.

Referenced by cpicon_construct().

22 {
23  if(time < this.move_time) { return; }
24 
25  if(this.cp_bob_dmg_z > 0)
26  this.cp_bob_dmg_z = this.cp_bob_dmg_z - 3 * frametime;
27  else
28  this.cp_bob_dmg_z = 0;
29  this.cp_bob_origin_z = 4 * PI * (1 - cos(this.cp_bob_spd));
30  this.cp_bob_spd = this.cp_bob_spd + 1.875 * frametime;
31  this.colormod = '1 1 1' * (2 - bound(0, (this.pain_finished - time) / 10, 1));
32 
33  if(!this.iscaptured) this.alpha = GetResource(this, RES_HEALTH) / this.max_health;
34 
35  if(this.iscaptured)
36  {
37  if (this.punchangle_x > 0)
38  {
39  this.punchangle_x = this.punchangle_x - 60 * frametime;
40  if (this.punchangle_x < 0)
41  this.punchangle_x = 0;
42  }
43  else if (this.punchangle_x < 0)
44  {
45  this.punchangle_x = this.punchangle_x + 60 * frametime;
46  if (this.punchangle_x > 0)
47  this.punchangle_x = 0;
48  }
49 
50  if (this.punchangle_y > 0)
51  {
52  this.punchangle_y = this.punchangle_y - 60 * frametime;
53  if (this.punchangle_y < 0)
54  this.punchangle_y = 0;
55  }
56  else if (this.punchangle_y < 0)
57  {
58  this.punchangle_y = this.punchangle_y + 60 * frametime;
59  if (this.punchangle_y > 0)
60  this.punchangle_y = 0;
61  }
62 
63  if (this.punchangle_z > 0)
64  {
65  this.punchangle_z = this.punchangle_z - 60 * frametime;
66  if (this.punchangle_z < 0)
67  this.punchangle_z = 0;
68  }
69  else if (this.punchangle_z < 0)
70  {
71  this.punchangle_z = this.punchangle_z + 60 * frametime;
72  if (this.punchangle_z > 0)
73  this.punchangle_z = 0;
74  }
75 
76  this.angles_x = this.punchangle_x;
77  this.angles_y = this.punchangle_y + this.angles_y;
78  this.angles_z = this.punchangle_z;
79  this.angles_y = this.angles_y + 45 * frametime;
80  }
81 
82  setorigin(this, this.cp_origin + this.cp_bob_origin + eZ * this.cp_bob_dmg_z);
83 }
float PI
Definition: csprogsdefs.qc:963
float cp_bob_spd
RES_HEALTH
Definition: ent_cs.qc:126
vector cp_origin
float alpha
vector cp_bob_origin
bool iscaptured
vector colormod
float frametime
Definition: csprogsdefs.qc:17
float max_health
float cp_bob_dmg_z
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float pain_finished
float move_time
Definition: movetypes.qh:77
const vector eZ
Definition: vector.qh:46
setorigin(ent, v)
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ NET_HANDLE()

NET_HANDLE ( ENT_CLIENT_CONTROLPOINT_ICON  ,
bool  isnew 
)

Definition at line 158 of file cl_controlpoint.qc.

References count, cpicon_changeteam(), cpicon_construct(), cpicon_damage(), CPSF_SETUP, CPSF_STATUS, frametime, GetResource(), iscaptured, max_health, origin, RES_HEALTH, setorigin(), SetResourceExplicit(), and team.

159 {
160  return = true;
161  int sf = ReadByte();
162 
163  if(sf & CPSF_SETUP)
164  {
165  this.origin = ReadVector();
166  setorigin(this, this.origin);
167 
168  SetResourceExplicit(this, RES_HEALTH, ReadByte());
169  this.max_health = ReadByte();
170  this.count = ReadByte();
171  this.team = ReadByte();
172  this.iscaptured = ReadByte();
173 
174  if(!this.count)
175  this.count = (GetResource(this, RES_HEALTH) - this.max_health) * frametime;
176 
177  cpicon_changeteam(this);
178  cpicon_construct(this, isnew);
179  }
180 
181  if(sf & CPSF_STATUS)
182  {
183  int _tmp = ReadByte();
184  if(_tmp != this.team)
185  {
186  this.team = _tmp;
187  cpicon_changeteam(this);
188  }
189 
190  _tmp = ReadByte();
191 
192  if(_tmp != GetResource(this, RES_HEALTH))
193  cpicon_damage(this, _tmp);
194 
195  SetResourceExplicit(this, RES_HEALTH, _tmp);
196  }
197 }
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition: cl_resources.qc:15
int team
Definition: main.qh:157
void cpicon_changeteam(entity this)
void cpicon_damage(entity this, float hp)
const int CPSF_STATUS
void cpicon_construct(entity this, bool isnew)
origin
Definition: ent_cs.qc:114
RES_HEALTH
Definition: ent_cs.qc:126
bool iscaptured
float frametime
Definition: csprogsdefs.qc:17
float max_health
int count
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
setorigin(ent, v)
+ Here is the call graph for this function:

Variable Documentation

◆ alpha

float alpha

Definition at line 4 of file cl_controlpoint.qc.

Referenced by cpicon_construct(), and cpicon_draw().

◆ colormod

vector colormod

Definition at line 3 of file cl_controlpoint.qc.

Referenced by cpicon_damage(), and cpicon_draw().

◆ count

int count

Definition at line 5 of file cl_controlpoint.qc.

Referenced by NET_HANDLE().

◆ cp_bob_dmg_z

float cp_bob_dmg_z

Definition at line 13 of file cl_controlpoint.qc.

Referenced by cpicon_damage(), and cpicon_draw().

◆ cp_bob_origin

vector cp_bob_origin

Definition at line 10 of file cl_controlpoint.qc.

Referenced by cpicon_construct(), and cpicon_draw().

◆ cp_bob_spd

float cp_bob_spd

Definition at line 11 of file cl_controlpoint.qc.

Referenced by cpicon_construct(), and cpicon_draw().

◆ cp_origin

vector cp_origin

Definition at line 10 of file cl_controlpoint.qc.

Referenced by cpicon_construct(), and cpicon_draw().

◆ glowmod

vector glowmod

Definition at line 141 of file cl_controlpoint.qc.

Referenced by cpicon_changeteam().

◆ icon_realmodel

entity icon_realmodel

Definition at line 19 of file cl_controlpoint.qc.

Referenced by cpicon_construct().

◆ iscaptured

◆ max_health

◆ pain_finished

◆ punchangle