]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/gamemodes/gamemode/survival/cl_survival.qc
Transifex autosync
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / survival / cl_survival.qc
1 #include "cl_survival.qh"
2
3 #include <client/draw.qh>
4 #include <client/hud/panel/modicons.qh>
5
6 NET_HANDLE(ENT_CLIENT_SURVIVALSTATUSES, bool isnew)
7 {
8         make_pure(this);
9         int sf = 0;
10         serialize(byte, 0, sf);
11         if (sf & BIT(0)) // make all players survivors
12         {
13                 for (int j = 0; j < maxclients; ++j)
14                         if (playerslots[j])
15                                 playerslots[j].survival_status = SURV_STATUS_PREY;
16         }
17         if (sf & BIT(1)) // receive hunter statuses
18         {
19                 for (int i = 1; i <= maxclients; i += 8)
20                 {
21                         int f = 0;
22                         serialize(byte, 0, f);
23                         for (int b = 0; b < 8; ++b)
24                         {
25                                 if (!(f & BIT(b))) continue;
26                                 int j = i - 1 + b;
27                                 if (playerslots[j])
28                                         playerslots[j].survival_status = SURV_STATUS_HUNTER;
29                         }
30                 }
31         }
32
33         // color all players
34         for (int i = 1; i <= maxclients; ++i)
35         {
36                 entity e = playerslots[i - 1];
37                 if (!e) continue;
38
39                 int plcolor = SURV_COLOR_PREY; // default color
40                 if(e.survival_status == SURV_STATUS_HUNTER) // if client knows this hunter
41                         plcolor = SURV_COLOR_HUNTER;
42
43                 e.colormap = 1024 + plcolor; // override scoreboard and player model colors
44         }
45
46         return true;
47 }
48
49 void HUD_Mod_Survival(vector pos, vector mySize)
50 {
51         mod_active = 1; // survival should always show the mod HUD
52
53         int mystatus = playerslots[player_localnum].survival_status;
54         string player_text = "";
55         vector player_color = '1 1 1';
56         //string player_icon = "";
57
58         if(STAT(GAMESTARTTIME) > time || STAT(ROUNDSTARTTIME) > time || entcs_IsSpectating(player_localnum))
59                 return;
60
61         if(mystatus == SURV_STATUS_HUNTER)
62         {
63                 player_text = _("Hunter");
64                 player_color = '1 0 0';
65                 //player_icon = "player_red";
66         }
67         else if(mystatus == SURV_STATUS_PREY)
68         {
69                 player_text = _("Survivor");
70                 player_color = '0 1 0';
71                 //player_icon = "player_neutral";
72         }
73
74         drawstring_aspect(pos, player_text, vec2(mySize.x, mySize.y), player_color, panel_fg_alpha, DRAWFLAG_NORMAL);
75 }
76
77 REGISTER_MUTATOR(cl_surv, true);
78
79 MUTATOR_HOOKFUNCTION(cl_surv, ForcePlayercolors_Skip, CBC_ORDER_LAST)
80 {
81         if(!ISGAMETYPE(SURVIVAL))
82                 return false;
83
84         entity player = M_ARGV(0, entity);
85         entity e = playerslots[player.entnum - 1];
86         if (e && e.colormap)
87                 player.colormap = e.colormap;
88         else
89                 player.colormap = 1024 + SURV_COLOR_PREY;
90         return true;
91 }
92
93 MUTATOR_HOOKFUNCTION(cl_surv, DrawScoreboard)
94 {
95         if(!ISGAMETYPE(SURVIVAL))
96                 return false;
97
98         // initialize colors of new players
99         for(entity pl = players.sort_next; pl; pl = pl.sort_next)
100                 if(pl.gotscores && pl.colormap == 0)
101                         pl.colormap = 1024 + SURV_COLOR_PREY;
102         return false;
103 }
104
105 MUTATOR_HOOKFUNCTION(cl_surv, DrawScoreboard_Force)
106 {
107         // show the scoreboard when the round ends, so players can see who the hunter was
108         return STAT(GAME_STOPPED);
109 }