Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
cl_survival.qc File Reference
Include dependency graph for cl_survival.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void HUD_Mod_Survival (vector pos, vector mySize, bool should_draw)
 MUTATOR_HOOKFUNCTION (cl_surv, DrawScoreboard)
 MUTATOR_HOOKFUNCTION (cl_surv, DrawScoreboard_Force)
 MUTATOR_HOOKFUNCTION (cl_surv, ForcePlayercolors_Skip, CBC_ORDER_LAST)
 NET_HANDLE (ENT_CLIENT_SURVIVALSTATUSES, bool isnew)
 REGISTER_MUTATOR (cl_surv, true)

Function Documentation

◆ HUD_Mod_Survival()

void HUD_Mod_Survival ( vector pos,
vector mySize,
bool should_draw )

Definition at line 47 of file cl_survival.qc.

48{
49 if (!should_draw)
50 return;
51
52 mod_active = 1; // survival should always show the mod HUD
53
54 int mystatus = playerslots[player_localnum].survival_status;
55 string player_text = "";
56 vector player_color = '1 1 1';
57 //string player_icon = "";
58
59 if(STAT(GAMESTARTTIME) > time || STAT(ROUNDSTARTTIME) > time || entcs_IsSpectating(player_localnum))
60 return;
61
62 if(mystatus == SURV_STATUS_HUNTER)
63 {
64 player_text = _("Hunter");
65 player_color = '1 0 0';
66 //player_icon = "player_red";
67 }
68 else if(mystatus == SURV_STATUS_PREY)
69 {
70 player_text = _("Survivor");
71 player_color = '0 1 0';
72 //player_icon = "player_neutral";
73 }
74
75 drawstring_aspect(pos, player_text, vec2(mySize.x, mySize.y), player_color, panel_fg_alpha, DRAWFLAG_NORMAL);
76}
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag)
Definition draw.qc:109
entity playerslots[255]
Definition main.qh:84
const float DRAWFLAG_NORMAL
float player_localnum
float time
#define entcs_IsSpectating(i)
Definition ent_cs.qh:76
float panel_fg_alpha
Definition hud.qh:169
#define STAT(...)
Definition stats.qh:82
bool mod_active
Definition modicons.qh:7
vector
Definition self.qh:92
const int SURV_STATUS_HUNTER
Definition survival.qh:38
const int SURV_STATUS_PREY
Definition survival.qh:37
#define vec2(...)
Definition vector.qh:90

References DRAWFLAG_NORMAL, drawstring_aspect(), entcs_IsSpectating, mod_active, panel_fg_alpha, player_localnum, playerslots, STAT, SURV_STATUS_HUNTER, SURV_STATUS_PREY, time, vec2, and vector.

Referenced by Survival::void().

◆ MUTATOR_HOOKFUNCTION() [1/3]

MUTATOR_HOOKFUNCTION ( cl_surv ,
DrawScoreboard  )

Definition at line 94 of file cl_survival.qc.

95{
96 if(!ISGAMETYPE(SURVIVAL))
97 return false;
98
99 // initialize colors of new players
100 for(entity pl = players.sort_next; pl; pl = pl.sort_next)
101 if(pl.gotscores && pl.colormap == 0)
102 pl.colormap = 1024 + SURV_COLOR_PREY;
103 return false;
104}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity players
Definition main.qh:57
#define ISGAMETYPE(NAME)
Definition main.qh:46
const int SURV_COLOR_PREY
Definition survival.qh:41

References entity(), ISGAMETYPE, players, and SURV_COLOR_PREY.

◆ MUTATOR_HOOKFUNCTION() [2/3]

MUTATOR_HOOKFUNCTION ( cl_surv ,
DrawScoreboard_Force  )

Definition at line 106 of file cl_survival.qc.

107{
108 // show the scoreboard when the round ends, so players can see who the hunter was
109 return STAT(GAME_STOPPED);
110}

References STAT.

◆ MUTATOR_HOOKFUNCTION() [3/3]

MUTATOR_HOOKFUNCTION ( cl_surv ,
ForcePlayercolors_Skip ,
CBC_ORDER_LAST  )

Definition at line 80 of file cl_survival.qc.

81{
82 if(!ISGAMETYPE(SURVIVAL))
83 return false;
84
85 entity player = M_ARGV(0, entity);
86 entity e = playerslots[player.entnum - 1];
87 if (e && e.colormap)
88 player.colormap = e.colormap;
89 else
90 player.colormap = 1024 + SURV_COLOR_PREY;
91 return true;
92}
#define M_ARGV(x, type)
Definition events.qh:17

References CBC_ORDER_LAST, entity(), ISGAMETYPE, M_ARGV, playerslots, and SURV_COLOR_PREY.

◆ NET_HANDLE()

NET_HANDLE ( ENT_CLIENT_SURVIVALSTATUSES ,
bool isnew )

Definition at line 6 of file cl_survival.qc.

7{
8 make_pure(this);
9 int sf = ReadByte();
10 if (sf & BIT(0)) // make all players survivors
11 {
12 for (int j = 0; j < maxclients; ++j)
13 if (playerslots[j])
14 playerslots[j].survival_status = SURV_STATUS_PREY;
15 }
16 if (sf & BIT(1)) // receive hunter statuses
17 {
18 for (int i = 1; i <= maxclients; i += 8)
19 {
20 int f = ReadByte();
21 for (int b = 0; b < 8; ++b)
22 {
23 if (!(f & BIT(b))) continue;
24 int j = i - 1 + b;
25 if (playerslots[j])
26 playerslots[j].survival_status = SURV_STATUS_HUNTER;
27 }
28 }
29 }
30
31 // color all players
32 for (int i = 1; i <= maxclients; ++i)
33 {
34 entity e = playerslots[i - 1];
35 if (!e) continue;
36
37 int plcolor = SURV_COLOR_PREY; // default color
38 if(e.survival_status == SURV_STATUS_HUNTER) // if client knows this hunter
39 plcolor = SURV_COLOR_HUNTER;
40
41 e.colormap = 1024 + plcolor; // override scoreboard and player model colors
42 }
43
44 return true;
45}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
float maxclients
int ReadByte()
#define make_pure(e)
direct use is
Definition oo.qh:13
const int SURV_COLOR_HUNTER
Definition survival.qh:42

References BIT, entity(), make_pure, maxclients, playerslots, ReadByte(), SURV_COLOR_HUNTER, SURV_COLOR_PREY, SURV_STATUS_HUNTER, and SURV_STATUS_PREY.

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( cl_surv ,
true  )