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, string s0und)
23 if(!autocvar_cl_vehicles_alarm)
26 _sound(e, ch, s0und, VOL_BASEVOICE, ATTEN_NONE);
29 void AuxiliaryXhair_Draw2D(entity this)
31 if (scoreboard_active)
34 vector size = draw_getimagesize(self.axh_image) * autocvar_cl_vehicles_crosshair_size;
35 vector pos = project_3d_to_2d(self.move_origin) - 0.5 * size;
37 if (!(pos.z < 0 || pos.x < 0 || pos.y < 0 || pos.x > vid_conwidth || pos.y > vid_conheight))
41 drawpic(pos, self.axh_image, size, self.colormod, autocvar_crosshair_alpha * self.alpha, self.axh_drawflag);
44 if(time - self.cnt > self.axh_fadetime)
45 self.draw2d = func_null;
48 NET_HANDLE(ENT_CLIENT_AUXILIARYXHAIR, bool isnew)
50 int axh_id = bound(0, ReadByte(), MAX_AXH);
51 entity axh = AuxiliaryXhair[axh_id];
53 if(axh == world || wasfreed(axh)) // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
56 axh.draw2d = func_null;
57 axh.drawmask = MASK_NORMAL;
58 axh.axh_drawflag = DRAWFLAG_ADDITIVE;
59 axh.axh_fadetime = 0.1;
60 axh.axh_image = vCROSS_HINT;
62 AuxiliaryXhair[axh_id] = axh;
65 axh.move_origin_x = ReadCoord();
66 axh.move_origin_y = ReadCoord();
67 axh.move_origin_z = ReadCoord();
68 axh.colormod_x = ReadByte() / 255;
69 axh.colormod_y = ReadByte() / 255;
70 axh.colormod_z = ReadByte() / 255;
72 axh.draw2d = AuxiliaryXhair_Draw2D;
76 NET_HANDLE(TE_CSQC_VEHICLESETUP, bool isnew)
78 int hud_id = ReadByte();
81 // hud_id == 0 means we exited a vehicle, so stop alarm sound/s
84 sound(self, CH_TRIGGER_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
85 sound(self, CH_PAIN_SINGLE, SND_Null, VOL_BASEVOICE, ATTEN_NONE);
89 // Init auxiliary crosshairs
90 for(int i = 0; i < MAX_AXH; ++i)
92 entity axh = AuxiliaryXhair[i];
94 if(axh != world && !wasfreed(axh)) // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
98 axh.draw2d = func_null;
99 axh.drawmask = MASK_NORMAL;
100 axh.axh_drawflag = DRAWFLAG_NORMAL;
101 axh.axh_fadetime = 0.1;
102 axh.axh_image = vCROSS_HINT;
104 AuxiliaryXhair[i] = axh;
107 if(hud_id == HUD_BUMBLEBEE_GUN)
109 AuxiliaryXhair[0].axh_image = vCROSS_BURST; // Plasma cannons
110 AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Raygun
112 Vehicle info = get_vehicleinfo(hud_id);
117 void Vehicles_drawHUD(
119 string vehicleWeapon1,
120 string vehicleWeapon2,
128 vector tmpSize = '0 0 0';
129 vector tmpPos = '0 0 0';
131 float hudAlpha = autocvar_hud_panel_fg_alpha * hud_fade_alpha;
132 float barAlpha = autocvar_hud_progressbar_alpha * hudAlpha;
133 float blinkValue = 0.55 + sin(time * 7) * 0.45;
135 float health = getstati(STAT_VEHICLESTAT_HEALTH) * 0.01;
136 float shield = getstati(STAT_VEHICLESTAT_SHIELD) * 0.01;
137 float energy = getstati(STAT_VEHICLESTAT_ENERGY) * 0.01;
138 float ammo1 = getstati(STAT_VEHICLESTAT_AMMO1) * 0.01;
139 float reload1 = getstati(STAT_VEHICLESTAT_RELOAD1) * 0.01;
140 float ammo2 = getstati(STAT_VEHICLESTAT_AMMO2) * 0.01;
141 float reload2 = getstati(STAT_VEHICLESTAT_RELOAD2) * 0.01;
143 // HACK to deal with the inconsistent use of the vehicle stats
144 ammo1 = (ammo1) ? ammo1 : energy;
147 string frame = strcat(hud_skin_path, "/vehicle_frame");
148 if (precache_pic(frame) == "")
149 frame = "gfx/hud/default/vehicle_frame";
151 vehicleHud_Size = draw_getimagesize(frame) * autocvar_cl_vehicles_hudscale;
152 vehicleHud_Pos.x = (vid_conwidth - vehicleHud_Size.x) / 2;
153 vehicleHud_Pos.y = vid_conheight - vehicleHud_Size.y;
155 if(teamplay && autocvar_hud_panel_bg_color_team)
156 drawpic(vehicleHud_Pos, frame, vehicleHud_Size, myteamcolors * autocvar_hud_panel_bg_color_team, autocvar_hud_panel_bg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
158 drawpic(vehicleHud_Pos, frame, vehicleHud_Size, autocvar_hud_panel_bg_color, autocvar_hud_panel_bg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
160 if(!autocvar__vehicles_shownchasemessage && time < vh_notice_time)
162 float tmpblinkValue = 0.55 + sin(time * 3) * 0.45;
163 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (96/256) - tmpSize.x;
164 tmpPos.y = vehicleHud_Pos.y;
165 tmpSize = '1 1 1' * hud_fontsize;
166 drawstring(tmpPos, sprintf(_("Press %s"), getcommandkey("dropweapon", "dropweapon")), tmpSize, '1 0 0' + '0 1 1' * tmpblinkValue, hudAlpha, DRAWFLAG_NORMAL);
170 tmpSize.x = vehicleHud_Size.x / 3;
171 tmpSize.y = vehicleHud_Size.y;
172 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x / 3;
173 tmpPos.y = vehicleHud_Pos.y;
176 drawpic_skin(tmpPos, vehicle, tmpSize, '1 0 0' + '0 1 1' * blinkValue, hudAlpha, DRAWFLAG_NORMAL);
178 drawpic_skin(tmpPos, vehicle, tmpSize, '1 1 1' * health + '1 0 0' * (1 - health), hudAlpha, DRAWFLAG_NORMAL);
181 drawpic_skin(tmpPos, vehicleWeapon1, tmpSize, '1 1 1' * ammo1 + '1 0 0' * (1 - ammo1), hudAlpha, DRAWFLAG_NORMAL);
183 drawpic_skin(tmpPos, vehicleWeapon2, tmpSize, '1 1 1' * ammo2 + '1 0 0' * (1 - ammo2), hudAlpha, DRAWFLAG_NORMAL);
185 drawpic_skin(tmpPos, "vehicle_shield", tmpSize, '1 1 1' * shield + '1 0 0' * (1 - shield), hudAlpha * shield, DRAWFLAG_NORMAL);
188 tmpSize.y = vehicleHud_Size.y / 2;
189 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (32/768);
190 tmpPos.y = vehicleHud_Pos.y;
192 drawsetcliparea(tmpPos.x + (tmpSize.x * (1 - health)), tmpPos.y, tmpSize.x, tmpSize.y);
193 drawpic_skin(tmpPos, "vehicle_bar_northwest", tmpSize, autocvar_hud_progressbar_health_color, barAlpha, DRAWFLAG_NORMAL);
196 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
198 drawsetcliparea(tmpPos.x + (tmpSize.x * (1 - shield)), tmpPos.y, tmpSize.x, tmpSize.y);
199 drawpic_skin(tmpPos, "vehicle_bar_southwest", tmpSize, autocvar_hud_progressbar_armor_color, barAlpha, DRAWFLAG_NORMAL);
202 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (480/768);
203 tmpPos.y = vehicleHud_Pos.y;
206 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * ammo1, tmpSize.y);
208 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * reload1, tmpSize.y);
210 drawpic_skin(tmpPos, "vehicle_bar_northeast", tmpSize, colorAmmo1, barAlpha, DRAWFLAG_NORMAL);
213 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
216 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * ammo2, tmpSize.y);
218 drawsetcliparea(tmpPos.x, tmpPos.y, tmpSize.x * reload2, tmpSize.y);
220 drawpic_skin(tmpPos, "vehicle_bar_southeast", tmpSize, colorAmmo2, barAlpha, DRAWFLAG_NORMAL);
224 tmpSize.x = vehicleHud_Size.x * (80/768);
225 tmpSize.y = vehicleHud_Size.y * (80/256);
226 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (64/768);
227 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y * (48/256);
231 if(alarm1time < time)
233 alarm1time = time + 2;
234 vehicle_alarm(self, CH_PAIN_SINGLE, SND(VEH_ALARM));
236 drawpic_skin(tmpPos, "vehicle_icon_health", tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
242 vehicle_alarm(self, CH_PAIN_SINGLE, SND(Null));
245 drawpic_skin(tmpPos, "vehicle_icon_health", tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
249 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
253 if(alarm2time < time)
255 alarm2time = time + 1;
256 vehicle_alarm(self, CH_TRIGGER_SINGLE, SND(VEH_ALARM_SHIELD));
258 drawpic_skin(tmpPos, "vehicle_icon_shield", tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
264 vehicle_alarm(self, CH_TRIGGER_SINGLE, SND(Null));
267 drawpic_skin(tmpPos, "vehicle_icon_shield", tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
271 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (624/768);
272 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y * (48/256);
277 drawpic_skin(tmpPos, iconAmmo1, tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
279 drawpic_skin(tmpPos, iconAmmo1, tmpSize, '1 1 1', hudAlpha * 0.2, DRAWFLAG_NORMAL);
283 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y / 2;
288 drawpic_skin(tmpPos, iconAmmo2, tmpSize, '1 1 1', hudAlpha, DRAWFLAG_NORMAL);
290 drawpic_skin(tmpPos, iconAmmo2, tmpSize, '1 1 1', hudAlpha * 0.2, DRAWFLAG_NORMAL);
294 void Vehicles_drawCrosshair(string crosshair)
297 vector tmpSize = '0 0 0';
298 vector tmpPos = '0 0 0';
303 tmpSize = draw_getimagesize(crosshair) * autocvar_cl_vehicles_crosshair_size;
304 tmpPos.x = (vid_conwidth - tmpSize.x) / 2;
305 tmpPos.y = (vid_conheight - tmpSize.y) / 2;
307 drawpic(tmpPos, crosshair, tmpSize, '1 1 1', autocvar_crosshair_alpha, DRAWFLAG_NORMAL);