Merge branch 'master' into martin-t/limit
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / keepaway / cl_keepaway.qc
1 #include "cl_keepaway.qh"
2
3 #include <client/hud/panel/modicons.qh>
4
5 // Keepaway HUD mod icon
6 int kaball_prevstatus; // last remembered status
7 float kaball_statuschange_time; // time when the status changed
8
9 // we don't need to reset for keepaway since it immediately
10 // autocorrects prevstatus as to if the player has the ball or not
11
12 void HUD_Mod_Keepaway(vector pos, vector mySize)
13 {
14         mod_active = 1; // keepaway should always show the mod HUD
15
16         float kaball_alpha = blink(0.85, 0.15, 5);
17
18         int stat_items = STAT(ITEMS);
19         int kaball = (stat_items/IT_KEY1) & 1;
20
21         if(kaball != kaball_prevstatus)
22         {
23                 kaball_statuschange_time = time;
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 }