]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/gamemode/survival/cl_survival.qc
Display the remaining round time in the panel next to the Survivor/Hunter text, rathe...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / survival / cl_survival.qc
1 #include "cl_survival.qh"
2
3 #include <client/hud/panel/modicons.qh>
4
5 void HUD_Mod_Survival(vector pos, vector mySize)
6 {
7         mod_active = 1; // survival should always show the mod HUD
8
9         int mystatus = entcs_receiver(player_localnum).survival_status;
10         string player_text = "";
11         vector player_color = '1 1 1';
12         //string player_icon = "";
13         if(mystatus == SV_STATUS_HUNTER)
14         {
15                 player_text = _("Hunter");
16                 player_color = '1 0 0';
17                 //player_icon = "player_red";
18         }
19         else if(mystatus == SV_STATUS_PREY)
20         {
21                 player_text = _("Survivor");
22                 player_color = '0 1 0';
23                 //player_icon = "player_neutral";
24         }
25         else
26         {
27                 // if the player has no valid status, don't draw anything
28                 return;
29         }
30
31         string time_text = string_null;
32         vector timer_color = '1 1 1';
33         if(!STAT(GAME_STOPPED) && !warmup_stage && STAT(SURVIVAL_ROUNDTIMER) > 0)
34         {
35                 float timeleft = max(0, STAT(SURVIVAL_ROUNDTIMER) - time);
36                 timeleft = ceil(timeleft);
37                 float minutesLeft = floor(timeleft / 60);
38                 time_text = seconds_tostring(timeleft);
39                 if(intermission_time || minutesLeft >= 5 || warmup_stage || STAT(SURVIVAL_ROUNDTIMER) == 0)
40                         timer_color = '1 1 1'; //white
41                 else if(minutesLeft >= 1)
42                         timer_color = '1 1 0'; //yellow
43                 else
44                         timer_color = '1 0 0'; //red
45         }
46
47         //drawpic_aspect_skin(pos, player_icon, vec2(0.5 * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
48         if(!time_text)
49                 drawstring_aspect(pos, player_text, vec2(mySize.x, mySize.y), player_color, panel_fg_alpha, DRAWFLAG_NORMAL);
50         else
51         {
52                 drawstring_aspect(pos, player_text, vec2(0.5 * mySize.x, mySize.y), player_color, panel_fg_alpha, DRAWFLAG_NORMAL);
53                 drawstring_aspect(pos + eX * (0.5 * mySize.x), time_text, vec2(0.5 * mySize.x, mySize.y), timer_color, panel_fg_alpha, DRAWFLAG_NORMAL);
54         }
55 }
56
57 REGISTER_MUTATOR(cl_sv, true);
58
59 MUTATOR_HOOKFUNCTION(cl_sv, ForcePlayercolors_Skip, CBC_ORDER_LAST)
60 {
61         if(!ISGAMETYPE(SURVIVAL))
62                 return false;
63                 
64         entity player = M_ARGV(0, entity);
65         entity e = entcs_receiver(player.entnum - 1);
66         int surv_status = ((e) ? e.survival_status : 0);
67         int mystatus = entcs_receiver(player_localnum).survival_status;
68
69         int plcolor = SV_COLOR_PREY; // default to survivor
70         if((mystatus == SV_STATUS_HUNTER || intermission || STAT(GAME_STOPPED)) && surv_status == SV_STATUS_HUNTER)
71                 plcolor = SV_COLOR_HUNTER;
72
73         player.colormap = 1024 + plcolor;
74         return true;
75 }