1 const string vCROSS_BURST = "gfx/vehicles/crosshair_burst.tga";
2 const string vCROSS_DROP = "gfx/vehicles/crosshair_drop.tga";
3 const string vCROSS_GUIDE = "gfx/vehicles/crosshair_guide.tga";
4 const string vCROSS_HEAL = "gfx/vehicles/crosshair_heal.tga";
5 const string vCROSS_HINT = "gfx/vehicles/crosshair_hint.tga";
6 const string vCROSS_LOCK = "gfx/vehicles/crosshair_lock.tga";
7 const string vCROSS_RAIN = "gfx/vehicles/crosshair_rain.tga";
11 const int MAX_AXH = 4;
12 entity AuxiliaryXhair[MAX_AXH];
21 void vehicle_alarm(entity e, int ch, Sound s0und)
24 if(!autocvar_cl_vehicles_alarm)
27 sound(e, ch, s0und, VOL_BASEVOICE, ATTEN_NONE);
30 void AuxiliaryXhair_Draw2D(entity this)
32 if (scoreboard_active)
35 vector size = draw_getimagesize(this.axh_image) * autocvar_cl_vehicles_crosshair_size;
36 vector pos = project_3d_to_2d(this.origin) - 0.5 * size;
38 if (!(pos.z < 0 || pos.x < 0 || pos.y < 0 || pos.x > vid_conwidth || pos.y > vid_conheight))
42 drawpic(pos, this.axh_image, size, this.colormod, autocvar_crosshair_alpha * this.alpha, this.axh_drawflag);
45 if(time - this.cnt > this.axh_fadetime)
46 this.draw2d = func_null;
49 NET_HANDLE(ENT_CLIENT_AUXILIARYXHAIR, bool isnew)
53 int axh_id = bound(0, ReadByte(), MAX_AXH);
54 entity axh = AuxiliaryXhair[axh_id];
56 if(axh == NULL || wasfreed(axh))
58 axh = new(auxiliary_crosshair);
59 axh.draw2d = func_null;
60 axh.drawmask = MASK_NORMAL;
61 axh.axh_drawflag = DRAWFLAG_ADDITIVE;
62 axh.axh_fadetime = 0.1;
63 axh.axh_image = vCROSS_HINT;
65 AuxiliaryXhair[axh_id] = axh;
66 IL_PUSH(g_drawables_2d, axh);
71 axh.origin_x = ReadCoord();
72 axh.origin_y = ReadCoord();
73 axh.origin_z = ReadCoord();
78 axh.colormod_x = ReadByte() / 255;
79 axh.colormod_y = ReadByte() / 255;
80 axh.colormod_z = ReadByte() / 255;
84 axh.draw2d = AuxiliaryXhair_Draw2D;
88 NET_HANDLE(TE_CSQC_VEHICLESETUP, bool isnew)
90 int hud_id = ReadByte();
93 // hud_id == 0 means we exited a vehicle, so stop alarm sound/s
94 // note: HUD_NORMAL is set to 0 currently too, but we'll check both just in case
95 if(hud_id == 0 || hud_id == HUD_NORMAL)
97 sound(this, CH_TRIGGER_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
98 sound(this, CH_PAIN_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
100 for(int i = 0; i < MAX_AXH; ++i)
102 entity axh = AuxiliaryXhair[i];
104 if(axh != NULL && !wasfreed(axh))
106 AuxiliaryXhair[i] = NULL;
113 // Init auxiliary crosshairs
114 for(int i = 0; i < MAX_AXH; ++i)
116 entity axh = AuxiliaryXhair[i];
118 if(axh != NULL && !wasfreed(axh)) // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
122 axh.draw2d = func_null;
123 axh.drawmask = MASK_NORMAL;
124 axh.axh_drawflag = DRAWFLAG_NORMAL;
125 axh.axh_fadetime = 0.1;
126 axh.axh_image = vCROSS_HINT;
128 AuxiliaryXhair[i] = axh;
129 IL_PUSH(g_drawables_2d, axh);
132 if(hud_id == HUD_BUMBLEBEE_GUN)
134 AuxiliaryXhair[0].axh_image = vCROSS_BURST; // Plasma cannons
135 AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Raygun
137 Vehicle info = Vehicles_from(hud_id);
138 info.vr_setup(info, NULL);
142 void Vehicles_drawHUD(
144 string vehicleWeapon1,
145 string vehicleWeapon2,
152 vector tmpSize = '0 0 0';
153 vector tmpPos = '0 0 0';
155 float hudAlpha = autocvar_hud_panel_fg_alpha * hud_fade_alpha;
156 float barAlpha = autocvar_hud_progressbar_alpha * hudAlpha;
157 float blinkValue = 0.55 + sin(time * 7) * 0.45;
159 float health = STAT(VEHICLESTAT_HEALTH) * 0.01;
160 float shield = STAT(VEHICLESTAT_SHIELD) * 0.01;
161 float energy = STAT(VEHICLESTAT_ENERGY) * 0.01;
162 float ammo1 = STAT(VEHICLESTAT_AMMO1) * 0.01;
163 float reload1 = STAT(VEHICLESTAT_RELOAD1) * 0.01;
164 float ammo2 = STAT(VEHICLESTAT_AMMO2) * 0.01;
165 float reload2 = STAT(VEHICLESTAT_RELOAD2) * 0.01;
167 // HACK to deal with the inconsistent use of the vehicle stats
168 ammo1 = (ammo1) ? ammo1 : energy;
171 string frame = strcat(hud_skin_path, "/vehicle_frame");
172 if (precache_pic(frame) == "")
173 frame = "gfx/hud/default/vehicle_frame";
175 vehicleHud_Size = draw_getimagesize(frame) * autocvar_cl_vehicles_hudscale;
176 vehicleHud_Pos.x = (vid_conwidth - vehicleHud_Size.x) / 2;
177 vehicleHud_Pos.y = vid_conheight - vehicleHud_Size.y;
179 if(teamplay && autocvar_hud_panel_bg_color_team)
180 drawpic(vehicleHud_Pos, frame, vehicleHud_Size, myteamcolors * autocvar_hud_panel_bg_color_team, autocvar_hud_panel_bg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
182 drawpic(vehicleHud_Pos, frame, vehicleHud_Size, autocvar_hud_panel_bg_color, autocvar_hud_panel_bg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
184 if(!autocvar__vehicles_shownchasemessage && time < vh_notice_time)
186 float tmpblinkValue = 0.55 + sin(time * 3) * 0.45;
187 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (96/256) - tmpSize.x;
188 tmpPos.y = vehicleHud_Pos.y;
189 tmpSize = '1 1 1' * hud_fontsize;
190 drawstring(tmpPos, sprintf(_("Press %s"), getcommandkey(_("drop weapon"), "dropweapon")), tmpSize, '1 0 0' + '0 1 1' * tmpblinkValue, hudAlpha, DRAWFLAG_NORMAL);
194 tmpSize.x = vehicleHud_Size.x / 3;
195 tmpSize.y = vehicleHud_Size.y;
196 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x / 3;
197 tmpPos.y = vehicleHud_Pos.y;
200 drawpic_skin(tmpPos, vehicle, tmpSize, '1 0 0' + '0 1 1' * blinkValue, hudAlpha, DRAWFLAG_NORMAL);
202 drawpic_skin(tmpPos, vehicle, tmpSize, '1 1 1' * health + '1 0 0' * (1 - health), hudAlpha, DRAWFLAG_NORMAL);
205 drawpic_skin(tmpPos, vehicleWeapon1, tmpSize, '1 1 1' * ammo1 + '1 0 0' * (1 - ammo1), hudAlpha, DRAWFLAG_NORMAL);
207 drawpic_skin(tmpPos, vehicleWeapon2, tmpSize, '1 1 1' * ammo2 + '1 0 0' * (1 - ammo2), hudAlpha, DRAWFLAG_NORMAL);
209 drawpic_skin(tmpPos, "vehicle_shield", tmpSize, '1 1 1' * shield + '1 0 0' * (1 - shield), hudAlpha * shield, DRAWFLAG_NORMAL);
212 tmpSize.y = vehicleHud_Size.y / 2;
213 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (32/768);
214 tmpPos.y = vehicleHud_Pos.y;
216 drawsetcliparea(tmpPos.x + (tmpSize.x * (1 - health)), tmpPos.y, tmpSize.x, tmpSize.y);
217 drawpic_skin(tmpPos, "vehicle_bar_northwest", tmpSize, autocvar_hud_progressbar_health_color, barAlpha, DRAWFLAG_NORMAL);
220 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
222 drawsetcliparea(tmpPos.x + (tmpSize.x * (1 - shield)), tmpPos.y, tmpSize.x, tmpSize.y);
223 drawpic_skin(tmpPos, "vehicle_bar_southwest", tmpSize, autocvar_hud_progressbar_armor_color, barAlpha, DRAWFLAG_NORMAL);
226 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (480/768);
227 tmpPos.y = vehicleHud_Pos.y;
230 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * ammo1, tmpSize.y);
232 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * reload1, tmpSize.y);
234 drawpic_skin(tmpPos, "vehicle_bar_northeast", tmpSize, colorAmmo1, barAlpha, DRAWFLAG_NORMAL);
237 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
240 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * ammo2, tmpSize.y);
242 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * reload2, tmpSize.y);
244 drawpic_skin(tmpPos, "vehicle_bar_southeast", tmpSize, colorAmmo2, barAlpha, DRAWFLAG_NORMAL);
248 tmpSize.x = vehicleHud_Size.x * (80/768);
249 tmpSize.y = vehicleHud_Size.y * (80/256);
250 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (64/768);
251 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y * (48/256);
255 if(alarm1time < time)
257 alarm1time = time + 2;
258 vehicle_alarm(NULL, CH_PAIN_SINGLE, SND_VEH_ALARM);
260 drawpic_skin(tmpPos, "vehicle_icon_health", tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
266 vehicle_alarm(NULL, CH_PAIN_SINGLE, SND_Null);
269 drawpic_skin(tmpPos, "vehicle_icon_health", tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
273 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
277 if(alarm2time < time)
279 alarm2time = time + 1;
280 vehicle_alarm(NULL, CH_TRIGGER_SINGLE, SND_VEH_ALARM_SHIELD);
282 drawpic_skin(tmpPos, "vehicle_icon_shield", tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
288 vehicle_alarm(NULL, CH_TRIGGER_SINGLE, SND_Null);
291 drawpic_skin(tmpPos, "vehicle_icon_shield", tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
295 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (624/768);
296 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y * (48/256);
301 drawpic_skin(tmpPos, iconAmmo1, tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
303 drawpic_skin(tmpPos, iconAmmo1, tmpSize, '1 1 1', hudAlpha * 0.2, DRAWFLAG_NORMAL);
307 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
312 drawpic_skin(tmpPos, iconAmmo2, tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
314 drawpic_skin(tmpPos, iconAmmo2, tmpSize, '1 1 1', hudAlpha * 0.2, DRAWFLAG_NORMAL);
318 void Vehicles_drawCrosshair(string crosshair)
320 vector tmpSize = '0 0 0';
321 vector tmpPos = '0 0 0';
326 tmpSize = draw_getimagesize(crosshair) * autocvar_cl_vehicles_crosshair_size;
327 tmpPos.x = (vid_conwidth - tmpSize.x) / 2;
328 tmpPos.y = (vid_conheight - tmpSize.y) / 2;
330 vector wcross_color = '1 1 1';
331 if(autocvar_cl_vehicles_crosshair_colorize)
332 wcross_color = crosshair_getcolor(NULL, STAT(VEHICLESTAT_HEALTH));
334 drawpic(tmpPos, crosshair, tmpSize, wcross_color, autocvar_crosshair_alpha, DRAWFLAG_NORMAL);