1 #include "cl_vehicles.qh"
3 void vehicle_alarm(entity e, int ch, Sound s0und)
6 if(!autocvar_cl_vehicles_alarm)
9 sound(e, ch, s0und, VOL_BASEVOICE, ATTEN_NONE);
12 void AuxiliaryXhair_Draw2D(entity this)
14 if (scoreboard_active)
17 vector pos = project_3d_to_2d(this.origin);
19 if (!(pos.z < 0 || pos.x < 0 || pos.y < 0 || pos.x > vid_conwidth || pos.y > vid_conheight))
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;
25 drawpic(pos, this.axh_image, size, this.colormod, autocvar_crosshair_alpha * this.alpha, this.axh_drawflag);
28 if(time - this.cnt > this.axh_fadetime)
29 this.draw2d = func_null;
32 NET_HANDLE(ENT_CLIENT_AUXILIARYXHAIR, bool isnew)
36 int axh_id = bound(0, ReadByte(), MAX_AXH);
37 entity axh = AuxiliaryXhair[axh_id];
39 if(axh == NULL || wasfreed(axh))
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;
48 AuxiliaryXhair[axh_id] = axh;
49 IL_PUSH(g_drawables_2d, axh);
54 axh.origin = ReadVector();
59 axh.colormod_x = ReadByte() / 255;
60 axh.colormod_y = ReadByte() / 255;
61 axh.colormod_z = ReadByte() / 255;
65 axh.draw2d = AuxiliaryXhair_Draw2D;
69 NET_HANDLE(TE_CSQC_VEHICLESETUP, bool isnew)
71 int hud_id = ReadByte();
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)
78 sound(this, CH_TRIGGER_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
79 sound(this, CH_PAIN_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
81 for(int i = 0; i < MAX_AXH; ++i)
83 entity axh = AuxiliaryXhair[i];
85 if(axh != NULL && !wasfreed(axh))
87 AuxiliaryXhair[i] = NULL;
94 // Init auxiliary crosshairs
95 for(int i = 0; i < MAX_AXH; ++i)
97 entity axh = AuxiliaryXhair[i];
99 if(axh != NULL && !wasfreed(axh)) // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
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;
109 AuxiliaryXhair[i] = axh;
110 IL_PUSH(g_drawables_2d, axh);
113 if(hud_id == HUD_BUMBLEBEE_GUN)
115 AuxiliaryXhair[0].axh_image = vCROSS_BURST; // Plasma cannons
116 AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Raygun
118 Vehicle info = REGISTRY_GET(Vehicles, hud_id);
119 info.vr_setup(info, NULL);
123 void Vehicles_drawHUD(
125 string vehicleWeapon1,
126 string vehicleWeapon2,
133 vector tmpSize = '0 0 0';
134 vector tmpPos = '0 0 0';
136 float hudAlpha = autocvar_hud_panel_fg_alpha * hud_fade_alpha;
137 float barAlpha = autocvar_hud_progressbar_alpha * hudAlpha;
138 float blinkValue = 0.55 + sin(time * 7) * 0.45;
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;
148 // HACK to deal with the inconsistent use of the vehicle stats
149 ammo1 = (ammo1) ? ammo1 : energy;
152 string frame = strcat(hud_skin_path, "/vehicle_frame");
153 if (precache_pic(frame) == "")
154 frame = "gfx/hud/default/vehicle_frame";
156 vehicleHud_Size = draw_getimagesize(frame) * autocvar_cl_vehicles_hudscale;
157 vehicleHud_Pos.x = (vid_conwidth - vehicleHud_Size.x) / 2;
158 vehicleHud_Pos.y = vid_conheight - vehicleHud_Size.y;
160 if(teamplay && autocvar_hud_panel_bg_color_team)
161 drawpic(vehicleHud_Pos, frame, vehicleHud_Size, myteamcolors * autocvar_hud_panel_bg_color_team, autocvar_hud_panel_bg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
163 drawpic(vehicleHud_Pos, frame, vehicleHud_Size, autocvar_hud_panel_bg_color, autocvar_hud_panel_bg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
165 if(!autocvar__vehicles_shownchasemessage && time < vh_notice_time)
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);
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;
181 drawpic_skin(tmpPos, vehicle, tmpSize, '1 0 0' + '0 1 1' * blinkValue, hudAlpha, DRAWFLAG_NORMAL);
183 drawpic_skin(tmpPos, vehicle, tmpSize, '1 1 1' * health + '1 0 0' * (1 - health), hudAlpha, DRAWFLAG_NORMAL);
186 drawpic_skin(tmpPos, vehicleWeapon1, tmpSize, '1 1 1' * ammo1 + '1 0 0' * (1 - ammo1), hudAlpha, DRAWFLAG_NORMAL);
188 drawpic_skin(tmpPos, vehicleWeapon2, tmpSize, '1 1 1' * ammo2 + '1 0 0' * (1 - ammo2), hudAlpha, DRAWFLAG_NORMAL);
190 drawpic_skin(tmpPos, "vehicle_shield", tmpSize, '1 1 1' * shield + '1 0 0' * (1 - shield), hudAlpha * shield, DRAWFLAG_NORMAL);
193 tmpSize.y = vehicleHud_Size.y / 2;
194 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (32/768);
195 tmpPos.y = vehicleHud_Pos.y;
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);
201 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
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);
207 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (480/768);
208 tmpPos.y = vehicleHud_Pos.y;
211 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * ammo1, tmpSize.y);
213 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * reload1, tmpSize.y);
215 drawpic_skin(tmpPos, "vehicle_bar_northeast", tmpSize, colorAmmo1, barAlpha, DRAWFLAG_NORMAL);
218 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
221 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * ammo2, tmpSize.y);
223 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * reload2, tmpSize.y);
225 drawpic_skin(tmpPos, "vehicle_bar_southeast", tmpSize, colorAmmo2, barAlpha, DRAWFLAG_NORMAL);
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);
236 if(alarm1time < time)
238 alarm1time = time + 2;
239 vehicle_alarm(NULL, CH_PAIN_SINGLE, SND_VEH_ALARM);
241 drawpic_skin(tmpPos, "vehicle_icon_health", tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
247 vehicle_alarm(NULL, CH_PAIN_SINGLE, SND_Null);
250 drawpic_skin(tmpPos, "vehicle_icon_health", tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
254 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
258 if(alarm2time < time)
260 alarm2time = time + 1;
261 vehicle_alarm(NULL, CH_TRIGGER_SINGLE, SND_VEH_ALARM_SHIELD);
263 drawpic_skin(tmpPos, "vehicle_icon_shield", tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
269 vehicle_alarm(NULL, CH_TRIGGER_SINGLE, SND_Null);
272 drawpic_skin(tmpPos, "vehicle_icon_shield", tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
276 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (624/768);
277 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y * (48/256);
282 drawpic_skin(tmpPos, iconAmmo1, tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
284 drawpic_skin(tmpPos, iconAmmo1, tmpSize, '1 1 1', hudAlpha * 0.2, DRAWFLAG_NORMAL);
288 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
293 drawpic_skin(tmpPos, iconAmmo2, tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
295 drawpic_skin(tmpPos, iconAmmo2, tmpSize, '1 1 1', hudAlpha * 0.2, DRAWFLAG_NORMAL);
299 void Vehicles_drawCrosshair(string crosshair)
301 vector tmpSize = '0 0 0';
302 vector tmpPos = '0 0 0';
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;
311 vector wcross_color = '1 1 1';
312 if(autocvar_cl_vehicles_crosshair_colorize)
313 wcross_color = crosshair_getcolor(NULL, STAT(VEHICLESTAT_HEALTH));
315 drawpic(tmpPos, crosshair, tmpSize, wcross_color, autocvar_crosshair_alpha, DRAWFLAG_NORMAL);