Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
cl_tka.qc
Go to the documentation of this file.
1#include "cl_tka.qh"
2
3#include <client/draw.qh>
5
6// Keepaway HUD mod icon
7int tkaball_prevstatus; // last remembered status
8float tkaball_statuschange_time; // time when the status changed
9
10// we don't need to reset for team keepaway since it immediately
11// autocorrects prevstatus as to if the player has the ball or not
12
14{
15 mod_active = 1; // team keepaway should always show the mod HUD
16
17 float tkaball_alpha = blink(0.85, 0.15, 5);
18
19 int stat_items = STAT(TKA_BALLSTATUS);
20 int tkaball = (stat_items & TKA_BALL_CARRYING);
21
22 if(tkaball != tkaball_prevstatus)
23 {
25 tkaball_prevstatus = tkaball;
26 }
27
28 vector tkaball_pos, tkaball_size;
29
30 if(mySize.x > mySize.y) {
31 tkaball_pos = pos + eX * 0.25 * mySize.x;
32 tkaball_size = vec2(0.5 * mySize.x, mySize.y);
33 } else {
34 tkaball_pos = pos + eY * 0.25 * mySize.y;
35 tkaball_size = vec2(mySize.x, 0.5 * mySize.y);
36 }
37
38 float tkaball_statuschange_elapsedtime = time - tkaball_statuschange_time;
39 float f = bound(0, tkaball_statuschange_elapsedtime*2, 1);
40
41 if(tkaball_prevstatus && f < 1)
42 drawpic_aspect_skin_expanding(tkaball_pos, "keepawayball_carrying", tkaball_size, '1 1 1', panel_fg_alpha * tkaball_alpha, DRAWFLAG_NORMAL, f);
43
44 if(stat_items & TKA_BALL_CARRYING) // TODO: unique team based icon while carrying
45 drawpic_aspect_skin(pos, "keepawayball_carrying", vec2(mySize.x, mySize.y), '1 1 1', panel_fg_alpha * tkaball_alpha * f, DRAWFLAG_NORMAL);
46 else if(stat_items & TKA_BALL_TAKEN_RED)
47 drawpic_aspect_skin(pos, "tka_taken_red", vec2(mySize.x, mySize.y), '1 1 1', panel_fg_alpha * tkaball_alpha * f, DRAWFLAG_NORMAL);
48 else if(stat_items & TKA_BALL_TAKEN_BLUE)
49 drawpic_aspect_skin(pos, "tka_taken_blue", vec2(mySize.x, mySize.y), '1 1 1', panel_fg_alpha * tkaball_alpha * f, DRAWFLAG_NORMAL);
50 else if(stat_items & TKA_BALL_TAKEN_YELLOW)
51 drawpic_aspect_skin(pos, "tka_taken_yellow", vec2(mySize.x, mySize.y), '1 1 1', panel_fg_alpha * tkaball_alpha * f, DRAWFLAG_NORMAL);
52 else if(stat_items & TKA_BALL_TAKEN_PINK)
53 drawpic_aspect_skin(pos, "tka_taken_pink", vec2(mySize.x, mySize.y), '1 1 1', panel_fg_alpha * tkaball_alpha * f, DRAWFLAG_NORMAL);
54}
void HUD_Mod_TeamKeepaway(vector pos, vector mySize)
Definition cl_tka.qc:13
float tkaball_statuschange_time
Definition cl_tka.qc:8
int tkaball_prevstatus
Definition cl_tka.qc:7
void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
Definition draw.qc:61
#define drawpic_aspect_skin(pos, pic, sz, color, theAlpha, drawflag)
Definition draw.qh:78
ERASEABLE float blink(float base, float range, float freq)
Definition util.qc:2178
const float DRAWFLAG_NORMAL
float time
float panel_fg_alpha
Definition hud.qh:169
#define STAT(...)
Definition stats.qh:82
float bound(float min, float value, float max)
bool mod_active
Definition modicons.qh:7
vector
Definition self.qh:92
const int TKA_BALL_CARRYING
Definition tka.qh:66
const int TKA_BALL_TAKEN_YELLOW
Definition tka.qh:64
const int TKA_BALL_TAKEN_RED
Definition tka.qh:62
const int TKA_BALL_TAKEN_PINK
Definition tka.qh:65
const int TKA_BALL_TAKEN_BLUE
Definition tka.qh:63
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44
#define vec2(...)
Definition vector.qh:90