Xonotic
cl_keepaway.qc
Go to the documentation of this file.
1 #include "cl_keepaway.qh"
2 
3 #include <client/draw.qh>
5 
6 // Keepaway HUD mod icon
7 int kaball_prevstatus; // last remembered status
8 float kaball_statuschange_time; // time when the status changed
9 
10 // we don't need to reset for keepaway since it immediately
11 // autocorrects prevstatus as to if the player has the ball or not
12 
13 void HUD_Mod_Keepaway(vector pos, vector mySize)
14 {
15  mod_active = 1; // keepaway should always show the mod HUD
16 
17  float kaball_alpha = blink(0.85, 0.15, 5);
18 
19  int kaball = (STAT(OBJECTIVE_STATUS) & KA_CARRYING);
20 
21  if(kaball != kaball_prevstatus)
22  {
24  kaball_prevstatus = kaball;
25  }
26 
27  vector kaball_pos, kaball_size;
28 
29  if(mySize.x > mySize.y) {
30  kaball_pos = pos + eX * 0.25 * mySize.x;
31  kaball_size = vec2(0.5 * mySize.x, mySize.y);
32  } else {
33  kaball_pos = pos + eY * 0.25 * mySize.y;
34  kaball_size = vec2(mySize.x, 0.5 * mySize.y);
35  }
36 
37  float kaball_statuschange_elapsedtime = time - kaball_statuschange_time;
38  float f = bound(0, kaball_statuschange_elapsedtime*2, 1);
39 
40  if(kaball_prevstatus && f < 1)
41  drawpic_aspect_skin_expanding(kaball_pos, "keepawayball_carrying", kaball_size, '1 1 1', panel_fg_alpha * kaball_alpha, DRAWFLAG_NORMAL, f);
42 
43  if(kaball)
44  drawpic_aspect_skin(pos, "keepawayball_carrying", vec2(mySize.x, mySize.y), '1 1 1', panel_fg_alpha * kaball_alpha * f, DRAWFLAG_NORMAL);
45 }
float panel_fg_alpha
Definition: hud.qh:166
float kaball_statuschange_time
Definition: cl_keepaway.qc:8
const vector eY
Definition: vector.qh:45
ERASEABLE float blink(float base, float range, float freq)
Definition: util.qc:2044
bool mod_active
Definition: modicons.qh:7
#define drawpic_aspect_skin(pos, pic, sz, color, theAlpha, drawflag)
Definition: draw.qh:78
void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
Definition: draw.qc:61
const float DRAWFLAG_NORMAL
Definition: csprogsdefs.qc:317
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const vector eX
Definition: vector.qh:44
#define vec2(...)
Definition: vector.qh:90
void HUD_Mod_Keepaway(vector pos, vector mySize)
Definition: cl_keepaway.qc:13
int kaball_prevstatus
Definition: cl_keepaway.qc:7
float time
Definition: csprogsdefs.qc:16