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)
 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 )

Definition at line 49 of file cl_survival.qc.

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}
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag)
Definition draw.qc:110
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 93 of file cl_survival.qc.

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}
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 105 of file cl_survival.qc.

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

References STAT.

◆ MUTATOR_HOOKFUNCTION() [3/3]

MUTATOR_HOOKFUNCTION ( cl_surv ,
ForcePlayercolors_Skip ,
CBC_ORDER_LAST  )

Definition at line 79 of file cl_survival.qc.

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}
#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 = 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}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
float maxclients
#define serialize(T, stream,...)
Definition net.qh:243
#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, serialize, SURV_COLOR_HUNTER, SURV_COLOR_PREY, SURV_STATUS_HUNTER, and SURV_STATUS_PREY.

◆ REGISTER_MUTATOR()

REGISTER_MUTATOR ( cl_surv ,
true  )