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

Go to the source code of this file.

Functions

void AuxiliaryXhair_Draw2D (entity this)
 NET_HANDLE (ENT_CLIENT_AUXILIARYXHAIR, bool isnew)
 NET_HANDLE (TE_CSQC_VEHICLESETUP, bool isnew)
void vehicle_alarm (entity e, int ch, Sound s0und)
void Vehicles_drawCrosshair (string crosshair)
void Vehicles_drawHUD (string vehicle, string vehicleWeapon1, string vehicleWeapon2, string iconAmmo1, vector colorAmmo1, string iconAmmo2, vector colorAmmo2)

Function Documentation

◆ AuxiliaryXhair_Draw2D()

void AuxiliaryXhair_Draw2D ( entity this)

Definition at line 12 of file cl_vehicles.qc.

13{
15 return;
16
17 vector pos = project_3d_to_2d(this.origin);
18
19 if (!(pos.z < 0 || pos.x < 0 || pos.y < 0 || pos.x > vid_conwidth || pos.y > vid_conheight))
20 {
21 vector size = draw_getimagesize(this.axh_image) * autocvar_cl_vehicles_crosshair_size;
22 pos.x -= 0.5 * size.x;
23 pos.y -= 0.5 * size.y;
24 pos.z = 0;
26 }
27
28 if(time - this.cnt > this.axh_fadetime)
29 this.draw2d = func_null;
30}
int axh_drawflag
string axh_image
float autocvar_cl_vehicles_crosshair_size
Definition cl_vehicles.qh:7
float axh_fadetime
#define drawpic(position, pic, size, rgb, alpha, flag)
Definition draw.qh:21
float cnt
Definition powerups.qc:24
vector colormod
Definition powerups.qc:21
float alpha
Definition items.qc:13
float autocvar_crosshair_alpha
Definition crosshair.qh:11
float time
vector size
vector origin
noref float vid_conwidth
Definition draw.qh:8
noref float vid_conheight
Definition draw.qh:9
var void func_null()
bool scoreboard_active
Definition scoreboard.qh:16
vector
Definition self.qh:92
vector project_3d_to_2d(vector vec)
Definition view.qc:373

References alpha, autocvar_cl_vehicles_crosshair_size, autocvar_crosshair_alpha, axh_drawflag, axh_fadetime, axh_image, cnt, colormod, drawpic, entity(), func_null(), origin, project_3d_to_2d(), scoreboard_active, size, time, vector, vid_conheight, and vid_conwidth.

Referenced by NET_HANDLE().

◆ NET_HANDLE() [1/2]

NET_HANDLE ( ENT_CLIENT_AUXILIARYXHAIR ,
bool isnew )

Definition at line 32 of file cl_vehicles.qc.

33{
34 int sf = ReadByte();
35
36 int axh_id = bound(0, ReadByte(), MAX_AXH);
37 entity axh = AuxiliaryXhair[axh_id];
38
39 if(axh == NULL || wasfreed(axh))
40 {
41 axh = new(auxiliary_crosshair);
42 axh.draw2d = func_null;
43 axh.drawmask = MASK_NORMAL;
44 axh.axh_drawflag = DRAWFLAG_ADDITIVE;
45 axh.axh_fadetime = 0.1;
46 axh.axh_image = vCROSS_HINT;
47 axh.alpha = 1;
48 AuxiliaryXhair[axh_id] = axh;
50 }
51
52 if(sf & 2)
53 {
54 axh.origin = ReadVector();
55 }
56
57 if(sf & 4)
58 {
59 axh.colormod_x = ReadByte() / 255;
60 axh.colormod_y = ReadByte() / 255;
61 axh.colormod_z = ReadByte() / 255;
62 }
63
64 axh.cnt = time;
65 axh.draw2d = AuxiliaryXhair_Draw2D;
66 return true;
67}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void AuxiliaryXhair_Draw2D(entity this)
const int MAX_AXH
const string vCROSS_HINT
entity AuxiliaryXhair[MAX_AXH]
IntrusiveList g_drawables_2d
Definition main.qh:92
const float DRAWFLAG_ADDITIVE
const float MASK_NORMAL
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define ReadVector()
Definition net.qh:367
int ReadByte()
float bound(float min, float value, float max)
#define NULL
Definition post.qh:14

References AuxiliaryXhair, AuxiliaryXhair_Draw2D(), bound(), DRAWFLAG_ADDITIVE, entity(), func_null(), g_drawables_2d, IL_PUSH(), MASK_NORMAL, MAX_AXH, NULL, ReadByte(), ReadVector, time, and vCROSS_HINT.

◆ NET_HANDLE() [2/2]

NET_HANDLE ( TE_CSQC_VEHICLESETUP ,
bool isnew )

Definition at line 69 of file cl_vehicles.qc.

70{
71 int hud_id = ReadByte();
72 return = true;
73
74 // hud_id == 0 means we exited a vehicle, so stop alarm sound/s
75 // note: HUD_NORMAL is set to 0 currently too, but we'll check both just in case
76 if(hud_id == 0 || hud_id == HUD_NORMAL)
77 {
80
81 for(int i = 0; i < MAX_AXH; ++i)
82 {
83 entity axh = AuxiliaryXhair[i];
84
85 if(axh != NULL && !wasfreed(axh))
86 {
88 delete(axh);
89 }
90 }
91 return;
92 }
93
94 // Init auxiliary crosshairs
95 for(int i = 0; i < MAX_AXH; ++i)
96 {
97 entity axh = AuxiliaryXhair[i];
98
99 if(axh != NULL && !wasfreed(axh)) // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
100 delete(axh);
101
102 axh = new(AuxiliaryXhair);
103 axh.draw2d = func_null;
104 axh.drawmask = MASK_NORMAL;
105 axh.axh_drawflag = DRAWFLAG_NORMAL;
106 axh.axh_fadetime = 0.1;
107 axh.axh_image = vCROSS_HINT;
108 axh.alpha = 1;
109 AuxiliaryXhair[i] = axh;
111 }
112
113 if(hud_id == HUD_BUMBLEBEE_GUN)
114 {
115 AuxiliaryXhair[0].axh_image = vCROSS_BURST; // Plasma cannons
116 AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Raygun
117 } else {
118 Vehicle info = REGISTRY_GET(Vehicles, hud_id);
119 info.vr_setup(info, NULL);
120 }
121}
const string vCROSS_BURST
virtual void vr_setup()
(BOTH) setup vehicle data
Definition vehicle.qh:60
const int HUD_BUMBLEBEE_GUN
Definition constants.qh:48
const int HUD_NORMAL
Definition constants.qh:47
const float DRAWFLAG_NORMAL
#define REGISTRY_GET(id, i)
Definition registry.qh:43
const float VOL_BASEVOICE
Definition sound.qh:37
const int CH_TRIGGER_SINGLE
Definition sound.qh:13
const int CH_PAIN_SINGLE
Definition sound.qh:19
const float ATTEN_NONE
Definition sound.qh:27
#define sound(e, c, s, v, a)
Definition sound.qh:52

References ATTEN_NONE, AuxiliaryXhair, CH_PAIN_SINGLE, CH_TRIGGER_SINGLE, DRAWFLAG_NORMAL, entity(), func_null(), g_drawables_2d, HUD_BUMBLEBEE_GUN, HUD_NORMAL, IL_PUSH(), MASK_NORMAL, MAX_AXH, NULL, ReadByte(), REGISTRY_GET, sound, vCROSS_BURST, vCROSS_HINT, VOL_BASEVOICE, and Vehicle::vr_setup().

◆ vehicle_alarm()

void vehicle_alarm ( entity e,
int ch,
Sound s0und )

Definition at line 3 of file cl_vehicles.qc.

4{
5 TC(Sound, s0und);
7 return;
8
9 sound(e, ch, s0und, VOL_BASEVOICE, ATTEN_NONE);
10}
bool autocvar_cl_vehicles_alarm
Definition cl_vehicles.qh:3
#define TC(T, sym)
Definition _all.inc:82

References ATTEN_NONE, autocvar_cl_vehicles_alarm, entity(), sound, TC, and VOL_BASEVOICE.

Referenced by Vehicles_drawHUD().

◆ Vehicles_drawCrosshair()

void Vehicles_drawCrosshair ( string crosshair)

Definition at line 299 of file cl_vehicles.qc.

300{
301 vector tmpSize = '0 0 0';
302 vector tmpPos = '0 0 0';
303
304 // Crosshair
305 if(crosshair)
306 {
307 tmpSize = draw_getimagesize(crosshair) * autocvar_cl_vehicles_crosshair_size;
308 tmpPos.x = (vid_conwidth - tmpSize.x) / 2;
309 tmpPos.y = (vid_conheight - tmpSize.y) / 2;
310
311 vector wcross_color = '1 1 1';
313 wcross_color = crosshair_getcolor(NULL, STAT(VEHICLESTAT_HEALTH));
314
315 drawpic(tmpPos, crosshair, tmpSize, wcross_color, autocvar_crosshair_alpha, DRAWFLAG_NORMAL);
316 }
317}
bool autocvar_cl_vehicles_crosshair_colorize
Definition cl_vehicles.qh:8
vector crosshair_getcolor(entity this, float health_stat)
Definition crosshair.qc:165
#define STAT(...)
Definition stats.qh:82

References autocvar_cl_vehicles_crosshair_colorize, autocvar_cl_vehicles_crosshair_size, autocvar_crosshair_alpha, crosshair_getcolor(), DRAWFLAG_NORMAL, drawpic, NULL, STAT, vector, vid_conheight, and vid_conwidth.

◆ Vehicles_drawHUD()

void Vehicles_drawHUD ( string vehicle,
string vehicleWeapon1,
string vehicleWeapon2,
string iconAmmo1,
vector colorAmmo1,
string iconAmmo2,
vector colorAmmo2 )

Definition at line 123 of file cl_vehicles.qc.

131{
132 // Initialize
133 vector tmpSize = '0 0 0';
134 vector tmpPos = '0 0 0';
135
137 float barAlpha = autocvar_hud_progressbar_alpha * hudAlpha;
138 float blinkValue = 0.55 + sin(time * 7) * 0.45;
139
140 float health = STAT(VEHICLESTAT_HEALTH) * 0.01;
141 float shield = STAT(VEHICLESTAT_SHIELD) * 0.01;
142 float energy = STAT(VEHICLESTAT_ENERGY) * 0.01;
143 float ammo1 = STAT(VEHICLESTAT_AMMO1) * 0.01;
144 float reload1 = STAT(VEHICLESTAT_RELOAD1) * 0.01;
145 float ammo2 = STAT(VEHICLESTAT_AMMO2) * 0.01;
146 float reload2 = STAT(VEHICLESTAT_RELOAD2) * 0.01;
147
148 // HACK to deal with the inconsistent use of the vehicle stats
149 ammo1 = (ammo1) ? ammo1 : energy;
150
151 // Frame
152 string frame = strcat(hud_skin_path, "/vehicle_frame");
153 if (precache_pic(frame) == "")
154 frame = "gfx/hud/default/vehicle_frame";
155
159
162 else
164
166 {
167 float tmpblinkValue = 0.55 + sin(time * 3) * 0.45;
168 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (96/256) - tmpSize.x;
169 tmpPos.y = vehicleHud_Pos.y;
170 tmpSize = '1 1 1' * hud_fontsize;
171 drawstring(tmpPos, sprintf(_("Press %s"), getcommandkey(_("drop weapon"), "dropweapon")), tmpSize, '1 0 0' + '0 1 1' * tmpblinkValue, hudAlpha, DRAWFLAG_NORMAL);
172 }
173
174 // Model
175 tmpSize.x = vehicleHud_Size.x / 3;
176 tmpSize.y = vehicleHud_Size.y;
177 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x / 3;
178 tmpPos.y = vehicleHud_Pos.y;
179
180 if(health < 0.25)
181 drawpic_skin(tmpPos, vehicle, tmpSize, '1 0 0' + '0 1 1' * blinkValue, hudAlpha, DRAWFLAG_NORMAL);
182 else
183 drawpic_skin(tmpPos, vehicle, tmpSize, '1 1 1' * health + '1 0 0' * (1 - health), hudAlpha, DRAWFLAG_NORMAL);
184
185 if(vehicleWeapon1)
186 drawpic_skin(tmpPos, vehicleWeapon1, tmpSize, '1 1 1' * ammo1 + '1 0 0' * (1 - ammo1), hudAlpha, DRAWFLAG_NORMAL);
187 if(vehicleWeapon2)
188 drawpic_skin(tmpPos, vehicleWeapon2, tmpSize, '1 1 1' * ammo2 + '1 0 0' * (1 - ammo2), hudAlpha, DRAWFLAG_NORMAL);
189
190 drawpic_skin(tmpPos, "vehicle_shield", tmpSize, '1 1 1' * shield + '1 0 0' * (1 - shield), hudAlpha * shield, DRAWFLAG_NORMAL);
191
192 // Health bar
193 tmpSize.y = vehicleHud_Size.y / 2;
194 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (32/768);
195 tmpPos.y = vehicleHud_Pos.y;
196
197 drawsetcliparea(tmpPos.x + (tmpSize.x * (1 - health)), tmpPos.y, tmpSize.x, tmpSize.y);
198 drawpic_skin(tmpPos, "vehicle_bar_northwest", tmpSize, autocvar_hud_progressbar_health_color, barAlpha, DRAWFLAG_NORMAL);
199
200 // Shield bar
201 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
202
203 drawsetcliparea(tmpPos.x + (tmpSize.x * (1 - shield)), tmpPos.y, tmpSize.x, tmpSize.y);
204 drawpic_skin(tmpPos, "vehicle_bar_southwest", tmpSize, autocvar_hud_progressbar_armor_color, barAlpha, DRAWFLAG_NORMAL);
205
206 // Ammo1 bar
207 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (480/768);
208 tmpPos.y = vehicleHud_Pos.y;
209
210 if(ammo1)
211 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * ammo1, tmpSize.y);
212 else
213 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * reload1, tmpSize.y);
214
215 drawpic_skin(tmpPos, "vehicle_bar_northeast", tmpSize, colorAmmo1, barAlpha, DRAWFLAG_NORMAL);
216
217 // Ammo2 bar
218 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
219
220 if(ammo2)
221 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * ammo2, tmpSize.y);
222 else
223 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * reload2, tmpSize.y);
224
225 drawpic_skin(tmpPos, "vehicle_bar_southeast", tmpSize, colorAmmo2, barAlpha, DRAWFLAG_NORMAL);
227
228 // Health icon
229 tmpSize.x = vehicleHud_Size.x * (80/768);
230 tmpSize.y = vehicleHud_Size.y * (80/256);
231 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (64/768);
232 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y * (48/256);
233
234 if(health < 0.25)
235 {
236 if(alarm1time < time)
237 {
238 alarm1time = time + 2;
239 vehicle_alarm(NULL, CH_PAIN_SINGLE, SND_VEH_ALARM);
240 }
241 drawpic_skin(tmpPos, "vehicle_icon_health", tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
242 }
243 else
244 {
245 if(alarm1time)
246 {
248 alarm1time = 0;
249 }
250 drawpic_skin(tmpPos, "vehicle_icon_health", tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
251 }
252
253 // Shield icon
254 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
255
256 if(shield < 0.25)
257 {
258 if(alarm2time < time)
259 {
260 alarm2time = time + 1;
261 vehicle_alarm(NULL, CH_TRIGGER_SINGLE, SND_VEH_ALARM_SHIELD);
262 }
263 drawpic_skin(tmpPos, "vehicle_icon_shield", tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
264 }
265 else
266 {
267 if(alarm2time)
268 {
270 alarm2time = 0;
271 }
272 drawpic_skin(tmpPos, "vehicle_icon_shield", tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
273 }
274
275 // Ammo1 icon
276 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (624/768);
277 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y * (48/256);
278
279 if(iconAmmo1)
280 {
281 if(ammo1)
282 drawpic_skin(tmpPos, iconAmmo1, tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
283 else
284 drawpic_skin(tmpPos, iconAmmo1, tmpSize, '1 1 1', hudAlpha * 0.2, DRAWFLAG_NORMAL);
285 }
286
287 // Ammo2 icon
288 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
289
290 if(iconAmmo2)
291 {
292 if(ammo2)
293 drawpic_skin(tmpPos, iconAmmo2, tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
294 else
295 drawpic_skin(tmpPos, iconAmmo2, tmpSize, '1 1 1', hudAlpha * 0.2, DRAWFLAG_NORMAL);
296 }
297}
float frame
primary framegroup animation (strength = 1 - lerpfrac - lerpfrac3 - lerpfrac4)
Definition anim.qh:6
void vehicle_alarm(entity e, int ch, Sound s0und)
Definition cl_vehicles.qc:3
vector vehicleHud_Pos
vector vehicleHud_Size
float alarm1time
float alarm2time
float autocvar_cl_vehicles_hudscale
Definition cl_vehicles.qh:5
bool autocvar__vehicles_shownchasemessage
Definition cl_vehicles.qh:9
#define drawsetcliparea(xposition, yposition, w, h)
Definition draw.qh:39
#define drawstring(position, text, scale, rgb, alpha, flag)
Definition draw.qh:27
#define drawpic_skin(pos, pic, sz, color, theAlpha, drawflag)
Definition draw.qh:88
vector hud_fontsize
Definition main.qh:77
#define getcommandkey(cmd_name, command)
Definition main.qh:137
vector autocvar_hud_progressbar_armor_color
vector autocvar_hud_progressbar_health_color
float vh_notice_time
Definition hud.qc:487
float autocvar_hud_progressbar_alpha
Definition hud.qh:204
float autocvar_hud_panel_bg_alpha
Definition hud.qh:197
float hud_fade_alpha
Definition hud.qh:134
vector autocvar_hud_panel_bg_color
Definition hud.qh:199
string hud_skin_path
Definition hud.qh:136
float autocvar_hud_panel_bg_color_team
Definition hud.qh:200
vector myteamcolors
Definition hud.qh:139
float autocvar_hud_panel_fg_alpha
Definition hud.qh:202
void drawresetcliparea(void)
string precache_pic(string name,...)
float sin(float f)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
float health
Legacy fields for the resources. To be removed.
Definition resources.qh:9
entity vehicle
Entity to disply the shild effect on damage.
bool teamplay
Definition teams.qh:59

References alarm1time, alarm2time, autocvar__vehicles_shownchasemessage, autocvar_cl_vehicles_hudscale, autocvar_hud_panel_bg_alpha, autocvar_hud_panel_bg_color, autocvar_hud_panel_bg_color_team, autocvar_hud_panel_fg_alpha, autocvar_hud_progressbar_alpha, autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_health_color, CH_PAIN_SINGLE, CH_TRIGGER_SINGLE, DRAWFLAG_NORMAL, drawpic, drawpic_skin, drawresetcliparea(), drawsetcliparea, drawstring, frame, getcommandkey, health, hud_fade_alpha, hud_fontsize, hud_skin_path, myteamcolors, NULL, precache_pic(), sin(), STAT, strcat(), teamplay, time, vector, vehicle, vehicle_alarm(), vehicleHud_Pos, vehicleHud_Size, vh_notice_time, vid_conheight, and vid_conwidth.

Referenced by CSQC_BUMBLE_GUN_HUD().