]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/vehicles/vehicles.qc
db1df041deb72508d134d4f9570745aac5b860a0
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / vehicles / vehicles.qc
1 #include "vehicles.qh"
2
3 #include "../autocvars.qh"
4 #include "../defs.qh"
5 #include "../main.qh"
6 #include "../miscfunctions.qh"
7 #include "../movetypes.qh"
8 #include "../movetypes.qh"
9 #include "../prandom.qh"
10 #include "../scoreboard.qh"
11 #include "../t_items.qh"
12
13 #include "../../common/buffs.qh"
14 #include "../../common/constants.qh"
15 #include "../../common/stats.qh"
16 #include "../../common/util.qh"
17
18 #include "../../csqcmodellib/cl_model.qh"
19
20 #include "../../dpdefs/csprogsdefs.qh"
21
22 .float cnt;
23
24 const string hud_bg = "gfx/vehicles/frame.tga";
25 const string hud_sh = "gfx/vehicles/vh-shield.tga";
26
27 const string hud_hp_bar = "gfx/vehicles/bar_up_left.tga";
28 const string hud_hp_ico = "gfx/vehicles/health.tga";
29 const string hud_sh_bar = "gfx/vehicles/bar_dwn_left.tga";
30 const string hud_sh_ico = "gfx/vehicles/shield.tga";
31
32 const string hud_ammo1_bar = "gfx/vehicles/bar_up_right.tga";
33 const string hud_ammo1_ico = "gfx/vehicles/bullets.tga";
34 const string hud_ammo2_bar = "gfx/vehicles/bar_dwn_right.tga";
35 const string hud_ammo2_ico = "gfx/vehicles/rocket.tga";
36 const string hud_energy = "gfx/vehicles/energy.tga";
37
38 const int SBRM_FIRST = 1;
39 const int SBRM_VOLLY = 1;
40 const int SBRM_GUIDE = 2;
41 const int SBRM_ARTILLERY = 3;
42 const int SBRM_LAST = 3;
43
44 const int RSM_FIRST = 1;
45 const int RSM_BOMB = 1;
46 const int RSM_FLARE = 2;
47 const int RSM_LAST = 2;
48
49 entity dropmark;
50 float autocvar_cl_vehicles_hudscale = 0.5;
51 float autocvar_cl_vehicles_hudalpha = 0.75;
52
53 const string raptor_ico =  "gfx/vehicles/raptor.tga";
54 const string raptor_gun =  "gfx/vehicles/raptor_guns.tga";
55 const string raptor_bomb = "gfx/vehicles/raptor_bombs.tga";
56 const string raptor_drop = "gfx/vehicles/axh-dropcross.tga";
57 string raptor_xhair;
58
59
60
61 const int MAX_AXH = 4;
62 entity AuxiliaryXhair[MAX_AXH];
63
64 entityclass(AuxiliaryXhair)
65 class(AuxiliaryXhair) .string axh_image;
66 class(AuxiliaryXhair) .float  axh_fadetime;
67 class(AuxiliaryXhair) .float  axh_drawflag;
68 class(AuxiliaryXhair) .float  axh_scale;
69
70 const string bumb_ico =  "gfx/vehicles/bumb.tga";
71 const string bumb_lgun =  "gfx/vehicles/bumb_lgun.tga";
72 const string bumb_rgun =  "gfx/vehicles/bumb_rgun.tga";
73
74 const string bumb_gun_ico =  "gfx/vehicles/bumb_side.tga";
75 const string bumb_gun_gun =  "gfx/vehicles/bumb_side_gun.tga";
76
77 const string spider_ico =  "gfx/vehicles/sbot.tga";
78 const string spider_rkt =  "gfx/vehicles/sbot_rpods.tga";
79 const string spider_mgun = "gfx/vehicles/sbot_mguns.tga";
80 string spider_xhair; // = "gfx/vehicles/axh-special1.tga";
81
82 const string waki_ico = "gfx/vehicles/waki.tga";
83 const string waki_eng = "gfx/vehicles/waki_e.tga";
84 const string waki_gun = "gfx/vehicles/waki_guns.tga";
85 const string waki_rkt = "gfx/vehicles/waki_rockets.tga";
86 const string waki_xhair = "gfx/vehicles/axh-special1.tga";
87
88 float alarm1time;
89 float alarm2time;
90 int weapon2mode;
91
92 void AuxiliaryXhair_Draw2D()
93 {
94     vector loc, psize;
95
96     psize = self.axh_scale * draw_getimagesize(self.axh_image);
97     loc = project_3d_to_2d(self.move_origin) - 0.5 * psize;
98     if (!(loc.z < 0 || loc.x < 0 || loc.y < 0 || loc.x > vid_conwidth || loc.y > vid_conheight))
99     {
100         loc.z = 0;
101         psize.z = 0;
102         drawpic(loc, self.axh_image, psize, self.colormod, self.alpha, self.axh_drawflag);
103     }
104
105     if(time - self.cnt > self.axh_fadetime)
106         self.draw2d = func_null;
107 }
108
109 void Net_AuXair2(bool bIsNew)
110 {
111     int axh_id  = bound(0, ReadByte(), MAX_AXH);
112     entity axh          = AuxiliaryXhair[axh_id];
113
114     if(axh == world || wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
115     {
116         axh                                     = spawn();
117                 axh.draw2d                      = func_null;
118                 axh.drawmask            = MASK_NORMAL;
119                 axh.axh_drawflag        = DRAWFLAG_ADDITIVE;
120                 axh.axh_fadetime        = 0.1;
121                 axh.axh_image           = "gfx/vehicles/axh-ring.tga";
122                 axh.axh_scale           = 1;
123         axh.alpha                       = 1;
124                 AuxiliaryXhair[axh_id] = axh;
125     }
126
127         axh.move_origin_x = ReadCoord();
128         axh.move_origin_y = ReadCoord();
129         axh.move_origin_z = ReadCoord();
130         axh.colormod_x = ReadByte() / 255;
131         axh.colormod_y = ReadByte() / 255;
132         axh.colormod_z = ReadByte() / 255;
133     axh.cnt                     = time;
134     axh.draw2d                  = AuxiliaryXhair_Draw2D;
135 }
136
137 void Net_VehicleSetup()
138 {
139     int hud_id = ReadByte();
140
141     // Weapon update?
142     if(hud_id > HUD_VEHICLE_LAST)
143     {
144         weapon2mode = hud_id - HUD_VEHICLE_LAST;
145         return;
146     }
147
148     // hud_id == 0 means we exited a vehicle, so stop alarm sound/s
149     if(hud_id == 0)
150     {
151         sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
152         sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
153         return;
154     }
155
156     hud_id  = bound(HUD_VEHICLE_FIRST, hud_id, HUD_VEHICLE_LAST);
157
158     // Init auxiliary crosshairs
159     int i;
160     for(i = 0; i < MAX_AXH; ++i)
161     {
162         entity axh = AuxiliaryXhair[i];
163         if(axh != world && !wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
164             remove(axh);
165
166         axh                                     = spawn();
167                 axh.draw2d                      = func_null;
168                 axh.drawmask            = MASK_NORMAL;
169                 axh.axh_drawflag        = DRAWFLAG_NORMAL;
170                 axh.axh_fadetime        = 0.1;
171                 axh.axh_image           = "gfx/vehicles/axh-ring.tga";
172                 axh.axh_scale           = 1;
173         axh.alpha                       = 1;
174                 AuxiliaryXhair[i]       = axh;
175     }
176
177     switch(hud_id)
178     {
179         case HUD_SPIDERBOT:
180             // Minigun1
181             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-ring.tga";
182             AuxiliaryXhair[0].axh_scale   = 0.25;
183             // Minigun2
184             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-ring.tga";
185             AuxiliaryXhair[1].axh_scale   = 0.25;
186             // Rocket
187             AuxiliaryXhair[2].axh_image   = "gfx/vehicles/axh-special1.tga";
188             AuxiliaryXhair[2].axh_scale   = 0.5;
189             break;
190
191         case HUD_WAKIZASHI:
192             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-bracket.tga";
193             AuxiliaryXhair[0].axh_scale   = 0.25;
194             break;
195
196         case HUD_RAPTOR:
197             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-special2.tga";
198             AuxiliaryXhair[0].axh_scale   = 0.5;
199             //AuxiliaryXhair[0].alpha       = 0.5;
200
201             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-bracket.tga";
202             AuxiliaryXhair[1].axh_scale   = 0.25;
203             //AuxiliaryXhair[1].alpha       = 0.75;
204             //AuxiliaryXhair[1].axh_drawflag  = DRAWFLAG_NORMAL;
205             break;
206
207         case HUD_BUMBLEBEE:
208             // Raygun-locked
209             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-bracket.tga";
210             AuxiliaryXhair[0].axh_scale   = 0.5;
211
212             // Gunner1
213             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-target.tga";
214             AuxiliaryXhair[1].axh_scale   = 0.75;
215
216             // Gunner2
217             AuxiliaryXhair[2].axh_image   = "gfx/vehicles/axh-target.tga";
218             AuxiliaryXhair[2].axh_scale   = 0.75;
219             break;
220         case HUD_BUMBLEBEE_GUN:
221             // Plasma cannons
222             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-bracket.tga";
223             AuxiliaryXhair[0].axh_scale   = 0.25;
224             // Raygun
225             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-bracket.tga";
226             AuxiliaryXhair[1].axh_scale   = 0.25;
227             break;
228     }
229 }
230 #define HUD_GETSTATS \
231     int vh_health       = getstati(STAT_VEHICLESTAT_HEALTH);  \
232         float shield        = getstati(STAT_VEHICLESTAT_SHIELD);  \
233         noref int energy    = getstati(STAT_VEHICLESTAT_ENERGY);  \
234         noref float ammo1   = getstati(STAT_VEHICLESTAT_AMMO1);   \
235         noref float reload1 = getstati(STAT_VEHICLESTAT_RELOAD1); \
236         noref int ammo2     = getstati(STAT_VEHICLESTAT_AMMO2);   \
237         noref int reload2   = getstati(STAT_VEHICLESTAT_RELOAD2);
238
239 void CSQC_BUMBLE_HUD()
240 {
241 /*
242     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
243     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0'  * (1 - health), 1, DRAWFLAG_NORMAL);
244     drawpic(hudloc, waki_r, picsize, '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
245     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0'  * (1 - energy), 1, DRAWFLAG_NORMAL);
246 */
247         if(autocvar_r_letterbox)
248         return;
249
250     vector picsize, hudloc = '0 0 0', pic2size, picloc;
251
252     // Fetch health & ammo stats
253         HUD_GETSTATS
254
255     picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
256     hudloc.y = vid_conheight - picsize.y;
257     hudloc.x = vid_conwidth * 0.5 - picsize.x * 0.5;
258
259     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
260
261     shield  *= 0.01;
262     vh_health  *= 0.01;
263     energy  *= 0.01;
264     reload1 *= 0.01;
265
266     pic2size = draw_getimagesize(bumb_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
267     picloc = picsize * 0.5 - pic2size * 0.5;
268
269     if(vh_health < 0.25)
270         drawpic(hudloc + picloc, bumb_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
271     else
272         drawpic(hudloc + picloc, bumb_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
273
274     drawpic(hudloc + picloc, bumb_lgun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
275     drawpic(hudloc + picloc, bumb_lgun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
276     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
277
278 // Health bar
279     picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
280     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
281     drawsetcliparea(hudloc.x + picloc.x + (picsize.x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
282     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
283     drawresetcliparea();
284 // ..  and icon
285     picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
286     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
287     if(vh_health < 0.25)
288     {
289         if(alarm1time < time)
290         {
291             alarm1time = time + 2;
292             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTEN_NONE);
293         }
294
295         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
296     }
297     else
298     {
299         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
300         if(alarm1time)
301         {
302             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
303             alarm1time = 0;
304         }
305     }
306
307 // Shield bar
308     picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
309     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
310     drawsetcliparea(hudloc.x + picloc.x + (picsize.x * (1 - shield)), 0, vid_conwidth, vid_conheight);
311     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
312     drawresetcliparea();
313 // ..  and icon
314     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
315     picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
316     if(shield < 0.25)
317     {
318         if(alarm2time < time)
319         {
320             alarm2time = time + 1;
321             sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTEN_NONE);
322         }
323         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
324     }
325     else
326     {
327         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
328         if(alarm2time)
329         {
330             sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
331             alarm2time = 0;
332         }
333     }
334
335         ammo1 *= 0.01;
336         ammo2 *= 0.01;
337
338 // Gunner1 bar
339     picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
340     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
341     drawsetcliparea(hudloc.x + picloc.x, picloc.y, picsize.x * ammo1, vid_conheight);
342     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
343     drawresetcliparea();
344
345 // Right gunner slot occupied?
346         if(!AuxiliaryXhair[1].draw2d)
347         {
348                 shield = (picsize.x * 0.5) - (0.5 * stringwidth(_("No right gunner!"), false, '1 0 0' * picsize.y + '0 1 0' * picsize.y));
349                 drawfill(hudloc + picloc - '0.2 0.2 0', picsize + '0.4 0.4 0', '0.25 0.25 0.25', 0.75, DRAWFLAG_NORMAL);
350                 drawstring(hudloc + picloc + '1 0 0' * shield, _("No right gunner!"), '1 0 0' * picsize.y + '0 1 0' * picsize.y, '1 0 0' + '0 1 1' * sin(time * 10), 1, DRAWFLAG_NORMAL);
351         }
352
353 // ..  and icon
354     picsize = 1.5 * draw_getimagesize(hud_energy) * autocvar_cl_vehicles_hudscale;
355     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
356     if(ammo1 < 0.2)
357         drawpic(hudloc + picloc, hud_energy, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
358     else
359         drawpic(hudloc + picloc, hud_energy, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
360
361 // Gunner2 bar
362     picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
363     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
364     drawsetcliparea(hudloc.x + picloc.x, picloc.y, picsize.x * ammo2, vid_conheight);
365     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
366     drawresetcliparea();
367 // Left gunner slot occupied?
368         if(!AuxiliaryXhair[2].draw2d)
369         {
370                 shield = (picsize.x * 0.5) - (0.5 * stringwidth(_("No left gunner!"), false, '1 0 0' * picsize.y + '0 1 0' * picsize.y));
371                 drawfill(hudloc + picloc - '0.2 0.2 0', picsize + '0.4 0.4 0', '0.25 0.25 0.25', 0.75, DRAWFLAG_NORMAL);
372                 drawstring(hudloc + picloc + '1 0 0' * shield, _("No left gunner!"), '1 0 0' * picsize.y + '0 1 0' * picsize.y, '1 0 0' + '0 1 1' * sin(time * 10), 1, DRAWFLAG_NORMAL);
373         }
374
375 // ..  and icon
376     picsize = 1.5 * draw_getimagesize(hud_energy) * autocvar_cl_vehicles_hudscale;
377     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
378     if(ammo2 < 0.2)
379         drawpic(hudloc + picloc, hud_energy, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
380     else
381         drawpic(hudloc + picloc, hud_energy, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
382
383         if (scoreboard_showscores)
384                 HUD_DrawScoreboard();
385     else
386     {
387         picsize = draw_getimagesize(waki_xhair);
388         picsize.x *= 0.5;
389         picsize.y *= 0.5;
390         drawpic('0.5 0 0' * (vid_conwidth - picsize.x) + '0 0.5 0' * (vid_conheight - picsize.y), waki_xhair, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
391     }
392
393 }
394
395 void CSQC_BUMBLE_GUN_HUD()
396 {
397
398         if(autocvar_r_letterbox)
399         return;
400
401     vector picsize, hudloc = '0 0 0', pic2size, picloc;
402
403     // Fetch health & ammo stats
404         HUD_GETSTATS
405
406     picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
407     hudloc.y = vid_conheight - picsize.y;
408     hudloc.x = vid_conwidth * 0.5 - picsize.x * 0.5;
409
410     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
411
412     shield  *= 0.01;
413     vh_health  *= 0.01;
414     energy  *= 0.01;
415     reload1 *= 0.01;
416
417     pic2size = draw_getimagesize(bumb_gun_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
418     picloc = picsize * 0.5 - pic2size * 0.5;
419
420     if(vh_health < 0.25)
421         drawpic(hudloc + picloc, bumb_gun_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
422     else
423         drawpic(hudloc + picloc, bumb_gun_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
424
425     drawpic(hudloc + picloc, bumb_gun_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
426     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
427
428 // Health bar
429     picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
430     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
431     drawsetcliparea(hudloc.x + picloc.x + (picsize.x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
432     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
433     drawresetcliparea();
434 // ..  and icon
435     picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
436     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
437     if(vh_health < 0.25)
438     {
439         if(alarm1time < time)
440         {
441             alarm1time = time + 2;
442             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTEN_NONE);
443         }
444
445         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
446     }
447     else
448     {
449         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
450         if(alarm1time)
451         {
452             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
453             alarm1time = 0;
454         }
455     }
456
457 // Shield bar
458     picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
459     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
460     drawsetcliparea(hudloc.x + picloc.x + (picsize.x * (1 - shield)), 0, vid_conwidth, vid_conheight);
461     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
462     drawresetcliparea();
463 // ..  and icon
464     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
465     picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
466     if(shield < 0.25)
467     {
468         if(alarm2time < time)
469         {
470             alarm2time = time + 1;
471             sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTEN_NONE);
472         }
473         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
474     }
475     else
476     {
477         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
478         if(alarm2time)
479         {
480             sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
481             alarm2time = 0;
482         }
483     }
484
485 // Gun bar
486     picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
487     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
488     drawsetcliparea(hudloc.x + picloc.x, picloc.y, picsize.x * energy, vid_conheight);
489     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
490     drawresetcliparea();
491
492 // ..  and icon
493     picsize = 1.5 * draw_getimagesize(hud_energy) * autocvar_cl_vehicles_hudscale;
494     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
495     if(energy < 0.2)
496         drawpic(hudloc + picloc, hud_energy, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
497     else
498         drawpic(hudloc + picloc, hud_energy, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
499
500         if (scoreboard_showscores)
501                 HUD_DrawScoreboard();
502     /*
503     else
504     {
505         picsize = draw_getimagesize(waki_xhair);
506         picsize_x *= 0.5;
507         picsize_y *= 0.5;
508
509
510         drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), waki_xhair, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
511     }
512     */
513 }
514
515
516
517 void CSQC_SPIDER_HUD()
518 {
519         if(autocvar_r_letterbox)
520         return;
521
522     vector picsize, hudloc = '0 0 0', pic2size, picloc;
523     int i;
524
525     // Fetch health & ammo stats
526         HUD_GETSTATS
527
528     picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
529     hudloc.y = vid_conheight - picsize.y;
530     hudloc.x = vid_conwidth * 0.5 - picsize.x * 0.5;
531
532     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
533
534     ammo1   *= 0.01;
535     shield  *= 0.01;
536     vh_health  *= 0.01;
537     reload2 *= 0.01;
538
539     pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
540     picloc = picsize * 0.5 - pic2size * 0.5;
541     if(vh_health < 0.25)
542         drawpic(hudloc + picloc, spider_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
543     else
544         drawpic(hudloc + picloc, spider_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
545     drawpic(hudloc + picloc, spider_rkt, pic2size,  '1 1 1' * reload2 + '1 0 0' * (1 - reload2), 1, DRAWFLAG_NORMAL);
546     drawpic(hudloc + picloc, spider_mgun, pic2size, '1 1 1' * ammo1   + '1 0 0' * (1 - ammo1),   1, DRAWFLAG_NORMAL);
547     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
548
549 // Health bar
550     picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
551     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
552     drawsetcliparea(hudloc.x + picloc.x + (picsize.x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
553     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
554     drawresetcliparea();
555 // ..  and icon
556     picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
557     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
558     if(vh_health < 0.25)
559     {
560         if(alarm1time < time)
561         {
562             alarm1time = time + 2;
563             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTEN_NONE);
564         }
565         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
566     }
567     else
568     {
569         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
570         if(alarm1time)
571         {
572             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
573             alarm1time = 0;
574         }
575     }
576 // Shield bar
577     picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
578     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
579     drawsetcliparea(hudloc.x + picloc.x + (picsize.x * (1 - shield)), 0, vid_conwidth, vid_conheight);
580     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
581     drawresetcliparea();
582 // ..  and icon
583     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
584     picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
585     if(shield < 0.25)
586     {
587         if(alarm2time < time)
588         {
589             alarm2time = time + 1;
590             sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTEN_NONE);
591         }
592         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
593     }
594     else
595     {
596         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
597         if(alarm2time)
598         {
599             sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
600             alarm2time = 0;
601         }
602     }
603
604 // Minigun bar
605     picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
606     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
607     drawsetcliparea(hudloc.x + picloc.x, picloc.y, picsize.x * ammo1, vid_conheight);
608     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
609     drawresetcliparea();
610 // ..  and icon
611     picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
612     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
613     if(ammo1 < 0.2)
614         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
615     else
616         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
617
618 // Rocket ammo bar
619     picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
620     ammo1 = picsize.x / 8;
621     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
622     drawsetcliparea(hudloc.x + picloc.x, hudloc.y + picloc.y, picsize.x * reload2, vid_conheight);
623     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
624     drawresetcliparea();
625
626 // ..  and icons
627     pic2size = 0.35 * draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
628     picloc.x -= pic2size.x;
629     picloc.y += pic2size.y * 2.25;
630     if(ammo2 == 9)
631     {
632         for(i = 1; i < 9; ++i)
633         {
634             picloc.x += ammo1;
635             drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((8 * reload2 <= i) ? '0 0 0' : '1 1 1'), 0.75, DRAWFLAG_NORMAL);
636         }
637     }
638     else
639     {
640         for(i = 1; i < 9; ++i)
641         {
642             picloc.x += ammo1;
643             drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((i >= ammo2) ? '1 1 1' : '0 0 0'), 0.75, DRAWFLAG_NORMAL);
644         }
645     }
646     pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
647     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
648     if(ammo2 == 9)
649         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
650     else
651         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
652
653         if (scoreboard_showscores)
654                 HUD_DrawScoreboard();
655     else
656     {
657         switch(weapon2mode)
658         {
659             case SBRM_VOLLY:
660                 spider_xhair = "gfx/vehicles/axh-bracket.tga";
661                 break;
662             case SBRM_GUIDE:
663                 spider_xhair = "gfx/vehicles/axh-cross.tga";
664                 break;
665             case SBRM_ARTILLERY:
666                 spider_xhair = "gfx/vehicles/axh-tag.tga";
667                 break;
668             default:
669                 spider_xhair= "gfx/vehicles/axh-tag.tga";
670         }
671
672         picsize = draw_getimagesize(spider_xhair);
673         picsize.x *= autocvar_cl_vehicle_spiderbot_cross_size;
674         picsize.y *= autocvar_cl_vehicle_spiderbot_cross_size;
675
676         drawpic('0.5 0 0' * (vid_conwidth - picsize.x) + '0 0.5 0' * (vid_conheight - picsize.y), spider_xhair, picsize, '1 1 1', autocvar_cl_vehicle_spiderbot_cross_alpha, DRAWFLAG_ADDITIVE);
677     }
678 }
679
680 void CSQC_RAPTOR_HUD()
681 {
682         if(autocvar_r_letterbox)
683         return;
684
685     vector picsize, hudloc = '0 0 0', pic2size, picloc;
686
687     // Fetch health & ammo stats
688         HUD_GETSTATS
689
690     picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
691     hudloc.y = vid_conheight - picsize.y;
692     hudloc.x = vid_conwidth * 0.5 - picsize.x * 0.5;
693
694     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
695
696     ammo1   *= 0.01;
697     ammo2   *= 0.01;
698     shield  *= 0.01;
699     vh_health  *= 0.01;
700     energy  *= 0.01;
701     reload1 = reload2 * 0.01;
702     //reload2 *= 0.01;
703
704     pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
705     picloc = picsize * 0.5 - pic2size * 0.5;
706     if(vh_health < 0.25)
707         drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
708     else
709         drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
710     drawpic(hudloc + picloc, raptor_bomb, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
711     drawpic(hudloc + picloc, raptor_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
712     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
713
714 // Health bar
715     picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
716     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
717     drawsetcliparea(hudloc.x + picloc.x + (picsize.x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
718     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
719     drawresetcliparea();
720 // ..  and icon
721     picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
722     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
723     if(vh_health < 0.25)
724     {
725         if(alarm1time < time)
726         {
727             alarm1time = time + 2;
728             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTEN_NONE);
729         }
730
731         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
732     }
733     else
734     {
735         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
736         if(alarm1time)
737         {
738             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
739             alarm1time = 0;
740         }
741     }
742
743 // Shield bar
744     picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
745     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
746     drawsetcliparea(hudloc.x + picloc.x + (picsize.x * (1 - shield)), 0, vid_conwidth, vid_conheight);
747     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
748     drawresetcliparea();
749 // ..  and icon
750     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
751     picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
752     if(shield < 0.25)
753     {
754         if(alarm2time < time)
755         {
756             alarm2time = time + 1;
757             sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTEN_NONE);
758         }
759         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
760     }
761     else
762     {
763         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
764         if(alarm2time)
765         {
766             sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
767             alarm2time = 0;
768         }
769     }
770
771 // Gun bar
772     picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
773     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
774     drawsetcliparea(hudloc.x + picloc.x, picloc.y, picsize.x * energy, vid_conheight);
775     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
776     drawresetcliparea();
777 // ..  and icon
778     picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
779     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
780     if(energy < 0.2)
781         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
782     else
783         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
784
785 // Bomb bar
786     picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
787     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
788     drawsetcliparea(hudloc.x + picloc.x, hudloc.y + picloc.y, picsize.x * reload1, vid_conheight);
789     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
790     drawresetcliparea();
791 // ..  and icon
792     pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
793     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
794     if(reload1 != 1)
795         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
796     else
797         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
798
799     if(weapon2mode == RSM_FLARE)
800     {
801         raptor_xhair =  "gfx/vehicles/axh-bracket.tga";
802     }
803     else
804     {
805         raptor_xhair =  "gfx/vehicles/axh-ring.tga";
806
807         // Bombing crosshair
808         if(!dropmark)
809         {
810             dropmark = spawn();
811             dropmark.owner = self;
812             dropmark.gravity = 1;
813         }
814
815         if(reload2 == 100)
816         {
817             vector where;
818
819             setorigin(dropmark, pmove_org);
820             dropmark.velocity = pmove_vel;
821             tracetoss(dropmark, self);
822
823             where = project_3d_to_2d(trace_endpos);
824
825             setorigin(dropmark, trace_endpos);
826             picsize = draw_getimagesize(raptor_drop) * 0.2;
827
828             if (!(where.z < 0 || where.x < 0 || where.y < 0 || where.x > vid_conwidth || where.y > vid_conheight))
829             {
830                 where.x -= picsize.x * 0.5;
831                 where.y -= picsize.y * 0.5;
832                 where.z = 0;
833                 drawpic(where, raptor_drop, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
834             }
835             dropmark.cnt = time + 5;
836         }
837         else
838         {
839             vector where;
840             if(dropmark.cnt > time)
841             {
842                 where = project_3d_to_2d(dropmark.origin);
843                 picsize = draw_getimagesize(raptor_drop) * 0.25;
844
845                 if (!(where.z < 0 || where.x < 0 || where.y < 0 || where.x > vid_conwidth || where.y > vid_conheight))
846                 {
847                     where.x -= picsize.x * 0.5;
848                     where.y -= picsize.y * 0.5;
849                     where.z = 0;
850                     drawpic(where, raptor_drop, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
851                 }
852             }
853         }
854     }
855
856         if (scoreboard_showscores)
857                 HUD_DrawScoreboard();
858     else
859     {
860         picsize = draw_getimagesize(raptor_xhair);
861         picsize.x *= 0.5;
862         picsize.y *= 0.5;
863
864         drawpic('0.5 0 0' * (vid_conwidth - picsize.x) + '0 0.5 0' * (vid_conheight - picsize.y), raptor_xhair, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
865     }
866 }
867
868 void CSQC_WAKIZASHI_HUD()
869 {
870 /*
871     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
872     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0'  * (1 - health), 1, DRAWFLAG_NORMAL);
873     drawpic(hudloc, waki_r, picsize, '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
874     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0'  * (1 - energy), 1, DRAWFLAG_NORMAL);
875 */
876         if(autocvar_r_letterbox)
877         return;
878
879     vector picsize, hudloc = '0 0 0', pic2size, picloc;
880
881     // Fetch health & ammo stats
882         HUD_GETSTATS
883
884     picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
885     hudloc.y = vid_conheight - picsize.y;
886     hudloc.x = vid_conwidth * 0.5 - picsize.x * 0.5;
887
888     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
889
890     shield  *= 0.01;
891     vh_health  *= 0.01;
892     energy  *= 0.01;
893     reload1 *= 0.01;
894
895     pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
896     picloc = picsize * 0.5 - pic2size * 0.5;
897     if(vh_health < 0.25)
898         drawpic(hudloc + picloc, waki_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
899     else
900         drawpic(hudloc + picloc, waki_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
901     drawpic(hudloc + picloc, waki_eng, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
902     drawpic(hudloc + picloc, waki_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
903     drawpic(hudloc + picloc, waki_rkt, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
904     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
905
906 // Health bar
907     picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
908     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
909     drawsetcliparea(hudloc.x + picloc.x + (picsize.x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
910     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
911     drawresetcliparea();
912 // ..  and icon
913     picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
914     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
915     if(vh_health < 0.25)
916     {
917         if(alarm1time < time)
918         {
919             alarm1time = time + 2;
920             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTEN_NONE);
921         }
922
923         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
924     }
925     else
926     {
927         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
928         if(alarm1time)
929         {
930             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
931             alarm1time = 0;
932         }
933     }
934
935
936 // Shield bar
937     picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
938     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
939     drawsetcliparea(hudloc.x + picloc.x + (picsize.x * (1 - shield)), 0, vid_conwidth, vid_conheight);
940     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
941     drawresetcliparea();
942 // ..  and icon
943     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
944     picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
945     if(shield < 0.25)
946     {
947         if(alarm2time < time)
948         {
949             alarm2time = time + 1;
950             sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTEN_NONE);
951         }
952         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
953     }
954     else
955     {
956         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
957         if(alarm2time)
958         {
959             sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTEN_NONE);
960             alarm2time = 0;
961         }
962     }
963
964 // Gun bar
965     picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
966     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
967     drawsetcliparea(hudloc.x + picloc.x, picloc.y, picsize.x * energy, vid_conheight);
968     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
969     drawresetcliparea();
970 // ..  and icon
971     picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
972     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
973     if(energy < 0.2)
974         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
975     else
976         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
977
978 // Bomb bar
979     picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
980     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
981     drawsetcliparea(hudloc.x + picloc.x, hudloc.y + picloc.y, picsize.x * reload1, vid_conheight);
982     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
983     drawresetcliparea();
984 // ..  and icon
985     pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
986     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
987     if(reload1 != 1)
988         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
989     else
990         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
991
992         if (scoreboard_showscores)
993                 HUD_DrawScoreboard();
994     else
995     {
996         picsize = draw_getimagesize(waki_xhair);
997         picsize.x *= 0.5;
998         picsize.y *= 0.5;
999
1000
1001         drawpic('0.5 0 0' * (vid_conwidth - picsize.x) + '0 0.5 0' * (vid_conheight - picsize.y), waki_xhair, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1002     }
1003 }
1004
1005 void Vehicles_Precache()
1006 {
1007         precache_model("models/vehicles/bomblet.md3");
1008         precache_model("models/vehicles/clusterbomb.md3");
1009         precache_model("models/vehicles/clusterbomb_fragment.md3");
1010         precache_model("models/vehicles/rocket01.md3");
1011         precache_model("models/vehicles/rocket02.md3");
1012
1013         precache_sound ("vehicles/alarm.wav");
1014         precache_sound ("vehicles/alarm_shield.wav");
1015 }
1016
1017 void RaptorCBShellfragDraw()
1018 {
1019         if(wasfreed(self))
1020                 return;
1021
1022         Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
1023         self.move_avelocity += randomvec() * 15;
1024         self.renderflags = 0;
1025
1026         if(self.cnt < time)
1027                 self.alpha = bound(0, self.nextthink - time, 1);
1028
1029         if(self.alpha < ALPHA_MIN_VISIBLE)
1030         remove(self);
1031 }
1032
1033 void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang)
1034 {
1035     entity sfrag;
1036
1037     sfrag = spawn();
1038     setmodel(sfrag, "models/vehicles/clusterbomb_fragment.md3");
1039     setorigin(sfrag, _org);
1040
1041         sfrag.move_movetype = MOVETYPE_BOUNCE;
1042         sfrag.gravity = 0.15;
1043         sfrag.solid = SOLID_CORPSE;
1044
1045         sfrag.draw = RaptorCBShellfragDraw;
1046
1047         sfrag.move_origin = sfrag.origin = _org;
1048         sfrag.move_velocity = _vel;
1049         sfrag.move_avelocity = prandomvec() * vlen(sfrag.move_velocity);
1050         sfrag.angles = self.move_angles = _ang;
1051
1052         sfrag.move_time = time;
1053         sfrag.damageforcescale = 4;
1054
1055         sfrag.nextthink = time + 3;
1056         sfrag.cnt = time + 2;
1057         sfrag.alpha = 1;
1058     sfrag.drawmask = MASK_NORMAL;
1059 }