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