]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/gamemode/lms/cl_lms.qc
Merge branch 'terencehill/lms_updates' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / lms / cl_lms.qc
1 #include "cl_lms.qh"
2
3 #include <common/mutators/base.qh>
4
5 REGISTER_MUTATOR(cl_lms, true);
6
7 MUTATOR_HOOKFUNCTION(cl_lms, DrawInfoMessages)
8 {
9         if(!warmup_stage && ISGAMETYPE(LMS))
10         {
11                 entity sk = playerslots[player_localnum];
12                 vector pos = M_ARGV(0, vector);
13                 vector mySize = M_ARGV(1, vector);
14                 vector fontsize = '0.2 0.2 0' * mySize.y;
15                 int img_curr_group = M_ARGV(2, int);
16                 if(sk.(scores(ps_primary)) > 0)
17                 {
18                         InfoMessage(_("^1You have no more lives left"));
19                         M_ARGV(0, vector) = pos;
20                         M_ARGV(2, int) = img_curr_group;
21                         return true;
22                 }
23         }
24         return false;
25 }
26
27 void HUD_Mod_LMS_Draw(vector myPos, vector mySize)
28 {
29         int leaders_count = STAT(REDALIVE); // recycled stat
30         if(!leaders_count)
31         {
32                 mod_active = 0;
33                 return;
34         }
35
36         int rows, columns;
37         float aspect_ratio = 2;
38         rows = HUD_GetRowCount(2, mySize, aspect_ratio);
39         columns = ceil(2 / rows);
40
41         vector pos = myPos;
42         vector itemSize = vec2(mySize.x / columns, mySize.y / rows);
43
44         bool visible_leaders = STAT(OBJECTIVE_STATUS);
45
46         if (visible_leaders)
47                 drawpic_aspect_skin(pos, "flag_stalemate", vec2(0.5 * itemSize.x, itemSize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
48         drawpic_aspect_skin(pos, "player_neutral", vec2(0.5 * itemSize.x, itemSize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
49         drawstring_aspect(pos + eX * 0.5 * itemSize.x, ftos(leaders_count), vec2(0.5 * itemSize.x, itemSize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
50
51         if (rows > 1)
52                 pos.y = myPos.y + itemSize.y;
53         else
54                 pos.x = myPos.x + itemSize.x;
55
56         int lives_diff = STAT(BLUEALIVE); // recycled stat
57         vector color = '1 1 0';
58         if (lives_diff >= 4)
59                 color = '1 0 0';
60         else if (lives_diff == 3)
61                 color = '1 0.5 0';
62         float scale = 0.75;
63         drawstring_aspect(pos + itemSize * (1 - scale) * 0.5, strcat("+", ftos(lives_diff)), itemSize * scale, color, panel_fg_alpha, DRAWFLAG_NORMAL);
64 }
65
66 void HUD_Mod_LMS(vector myPos, vector mySize)
67 {
68         mod_active = 1;
69
70         HUD_Mod_LMS_Draw(myPos, mySize);
71 }