]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/vehicles/vehicles.qc
Merge remote-tracking branch 'origin/master' into samual/spawn_weapons
[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-locked
207             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-bracket.tga";
208             AuxiliaryXhair[0].axh_scale   = 0.5;
209             
210             // Gunner1
211             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-target.tga";
212             AuxiliaryXhair[1].axh_scale   = 0.75;
213             
214             // Gunner2
215             AuxiliaryXhair[2].axh_image   = "gfx/vehicles/axh-target.tga";
216             AuxiliaryXhair[2].axh_scale   = 0.75;
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         if (scoreboard_showscores)
365                 HUD_DrawScoreboard();
366     else
367     {
368         picsize = draw_getimagesize(waki_xhair);
369         picsize_x *= 0.5;
370         picsize_y *= 0.5;
371         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);
372     }
373     
374 }
375
376 void CSQC_BUMBLE_GUN_HUD()
377 {
378
379         if(autocvar_r_letterbox)
380         return;
381
382     vector picsize, hudloc, pic2size, picloc;
383
384     // Fetch health & ammo stats
385         HUD_GETSTATS
386
387     picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
388     hudloc_y = vid_conheight - picsize_y;
389     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
390
391     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
392
393     shield  *= 0.01;
394     vh_health  *= 0.01;
395     energy  *= 0.01;
396     reload1 *= 0.01;
397
398     pic2size = draw_getimagesize(bumb_gun_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
399     picloc = picsize * 0.5 - pic2size * 0.5;
400     
401     if(vh_health < 0.25)
402         drawpic(hudloc + picloc, bumb_gun_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
403     else
404         drawpic(hudloc + picloc, bumb_gun_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
405     
406     drawpic(hudloc + picloc, bumb_gun_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
407     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
408
409 // Health bar
410     picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
411     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
412     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
413     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
414     drawresetcliparea();
415 // ..  and icon
416     picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
417     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
418     if(vh_health < 0.25)
419     {
420         if(alarm1time < time)
421         {
422             alarm1time = time + 2;
423             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTN_NONE);
424         }
425         
426         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
427     }        
428     else
429     {
430         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
431         if(alarm1time)
432         {
433             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
434             alarm1time = 0;
435         }        
436     }
437
438 // Shield bar
439     picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
440     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
441     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
442     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
443     drawresetcliparea();
444 // ..  and icon
445     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
446     picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
447     if(shield < 0.25)
448     {
449         if(alarm2time < time)
450         {
451             alarm2time = time + 1;
452             sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTN_NONE);
453         }
454         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
455     }
456     else
457     {
458         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
459         if(alarm2time)
460         {            
461             sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
462             alarm2time = 0;
463         }
464     }
465     
466 // Gun bar
467     picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
468     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
469     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
470     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
471     drawresetcliparea();
472     
473 // ..  and icon
474     picsize = 1.5 * draw_getimagesize(hud_energy) * autocvar_cl_vehicles_hudscale;
475     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
476     if(energy < 0.2)
477         drawpic(hudloc + picloc, hud_energy, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
478     else
479         drawpic(hudloc + picloc, hud_energy, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
480
481         if (scoreboard_showscores)
482                 HUD_DrawScoreboard();
483     /*
484     else
485     {
486         picsize = draw_getimagesize(waki_xhair);
487         picsize_x *= 0.5;
488         picsize_y *= 0.5;
489
490
491         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);
492     }
493     */
494 }
495
496
497
498 void CSQC_SPIDER_HUD()
499 {
500         if(autocvar_r_letterbox)
501         return;
502
503     vector picsize, hudloc, pic2size, picloc;
504     float i;
505
506     // Fetch health & ammo stats
507         HUD_GETSTATS
508
509     picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
510     hudloc_y = vid_conheight - picsize_y;
511     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
512
513     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
514
515     ammo1   *= 0.01;
516     shield  *= 0.01;
517     vh_health  *= 0.01;
518     reload2 *= 0.01;
519
520     pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
521     picloc = picsize * 0.5 - pic2size * 0.5;
522     if(vh_health < 0.25)
523         drawpic(hudloc + picloc, spider_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
524     else
525         drawpic(hudloc + picloc, spider_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);    
526     drawpic(hudloc + picloc, spider_rkt, pic2size,  '1 1 1' * reload2 + '1 0 0' * (1 - reload2), 1, DRAWFLAG_NORMAL);
527     drawpic(hudloc + picloc, spider_mgun, pic2size, '1 1 1' * ammo1   + '1 0 0' * (1 - ammo1),   1, DRAWFLAG_NORMAL);
528     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
529
530 // Health bar
531     picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
532     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
533     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
534     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
535     drawresetcliparea();
536 // ..  and icon
537     picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
538     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
539     if(vh_health < 0.25)
540     {
541         if(alarm1time < time)
542         {
543             alarm1time = time + 2;
544             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTN_NONE);
545         }        
546         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
547     }        
548     else
549     {
550         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
551         if(alarm1time)
552         {
553             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
554             alarm1time = 0;
555         }        
556     }
557 // Shield bar
558     picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
559     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
560     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
561     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
562     drawresetcliparea();
563 // ..  and icon
564     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
565     picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
566     if(shield < 0.25)
567     {
568         if(alarm2time < time)
569         {
570             alarm2time = time + 1;
571             sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTN_NONE);
572         }
573         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
574     }
575     else
576     {
577         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
578         if(alarm2time)
579         {            
580             sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
581             alarm2time = 0;
582         }
583     }
584
585 // Minigun bar
586     picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
587     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
588     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * ammo1, vid_conheight);
589     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
590     drawresetcliparea();
591 // ..  and icon
592     picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
593     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
594     if(ammo1 < 0.2)
595         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
596     else
597         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
598
599 // Rocket ammo bar
600     picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
601     ammo1 = picsize_x / 8;
602     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
603     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload2, vid_conheight);
604     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
605     drawresetcliparea();
606
607 // ..  and icons
608     pic2size = 0.35 * draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
609     picloc_x -= pic2size_x;
610     picloc_y += pic2size_y * 2.25;
611     if(ammo2 == 9)
612     {
613         for(i = 1; i < 9; ++i)
614         {
615             picloc_x += ammo1;
616             drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((8 * reload2 <= i) ? '0 0 0' : '1 1 1'), 0.75, DRAWFLAG_NORMAL);
617         }
618     }
619     else
620     {
621         for(i = 1; i < 9; ++i)
622         {
623             picloc_x += ammo1;
624             drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((i >= ammo2) ? '1 1 1' : '0 0 0'), 0.75, DRAWFLAG_NORMAL);
625         }
626     }
627     pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
628     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
629     if(ammo2 == 9)
630         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
631     else
632         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
633
634         if (scoreboard_showscores)
635                 HUD_DrawScoreboard();
636     else
637     {
638         switch(weapon2mode)
639         {
640             case SBRM_VOLLY:
641                 spider_xhair = "gfx/vehicles/axh-bracket.tga";
642                 break;
643             case SBRM_GUIDE:
644                 spider_xhair = "gfx/vehicles/axh-cross.tga";
645                 break;
646             case SBRM_ARTILLERY:
647                 spider_xhair = "gfx/vehicles/axh-tag.tga";
648                 break;
649             default:
650                 spider_xhair= "gfx/vehicles/axh-tag.tga";
651         }
652
653         picsize = draw_getimagesize(spider_xhair);
654         picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
655         picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
656
657         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);
658     }
659 }
660
661 void CSQC_RAPTOR_HUD()
662 {
663         if(autocvar_r_letterbox)
664         return;
665
666     vector picsize, hudloc, pic2size, picloc;
667
668     // Fetch health & ammo stats
669         HUD_GETSTATS
670
671     picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
672     hudloc_y = vid_conheight - picsize_y;
673     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
674
675     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
676
677     ammo1   *= 0.01;
678     ammo2   *= 0.01;
679     shield  *= 0.01;
680     vh_health  *= 0.01;
681     energy  *= 0.01;
682     reload1 = reload2 * 0.01;
683     //reload2 *= 0.01;
684
685     pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
686     picloc = picsize * 0.5 - pic2size * 0.5;
687     if(vh_health < 0.25)
688         drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
689     else
690         drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
691     drawpic(hudloc + picloc, raptor_bomb, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
692     drawpic(hudloc + picloc, raptor_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
693     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
694
695 // Health bar
696     picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
697     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
698     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
699     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
700     drawresetcliparea();
701 // ..  and icon
702     picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
703     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
704     if(vh_health < 0.25)
705     {
706         if(alarm1time < time)
707         {
708             alarm1time = time + 2;
709             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTN_NONE);
710         }
711         
712         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
713     }        
714     else
715     {
716         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
717         if(alarm1time)
718         {
719             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
720             alarm1time = 0;
721         }
722     }
723
724 // Shield bar
725     picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
726     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
727     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
728     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
729     drawresetcliparea();
730 // ..  and icon
731     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
732     picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
733     if(shield < 0.25)
734     {
735         if(alarm2time < time)
736         {
737             alarm2time = time + 1;
738             sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTN_NONE);
739         }
740         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
741     }
742     else
743     {
744         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
745         if(alarm2time)
746         {            
747             sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
748             alarm2time = 0;
749         }
750     }
751     
752 // Gun bar
753     picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
754     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
755     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
756     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
757     drawresetcliparea();
758 // ..  and icon
759     picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
760     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
761     if(energy < 0.2)
762         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
763     else
764         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
765
766 // Bomb bar
767     picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
768     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
769     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
770     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
771     drawresetcliparea();
772 // ..  and icon
773     pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
774     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
775     if(reload1 != 1)
776         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
777     else
778         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
779     
780     if(weapon2mode == RSM_FLARE)
781     {
782         raptor_xhair =  "gfx/vehicles/axh-bracket.tga";
783     }
784     else
785     {
786         raptor_xhair =  "gfx/vehicles/axh-ring.tga";
787         
788         // Bombing crosshair
789         if(!dropmark)
790         {
791             dropmark = spawn();
792             dropmark.owner = self;
793             dropmark.gravity = 1;
794         }
795
796         if(reload2 == 100)
797         {
798             vector where;
799
800             setorigin(dropmark, pmove_org);
801             dropmark.velocity = pmove_vel;
802             tracetoss(dropmark, self);
803
804             where = project_3d_to_2d(trace_endpos);
805
806             setorigin(dropmark, trace_endpos);
807             picsize = draw_getimagesize(raptor_drop) * 0.2;
808
809             if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
810             {
811                 where_x -= picsize_x * 0.5;
812                 where_y -= picsize_y * 0.5;
813                 where_z = 0;
814                 drawpic(where, raptor_drop, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
815             }
816             dropmark.cnt = time + 5;
817         }
818         else
819         {
820             vector where;
821             if(dropmark.cnt > time)
822             {
823                 where = project_3d_to_2d(dropmark.origin);
824                 picsize = draw_getimagesize(raptor_drop) * 0.25;
825
826                 if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
827                 {
828                     where_x -= picsize_x * 0.5;
829                     where_y -= picsize_y * 0.5;
830                     where_z = 0;
831                     drawpic(where, raptor_drop, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
832                 }
833             }
834         }
835     }
836     
837         if (scoreboard_showscores)
838                 HUD_DrawScoreboard();
839     else
840     {
841         picsize = draw_getimagesize(raptor_xhair);
842         picsize_x *= 0.5;
843         picsize_y *= 0.5;
844
845         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);
846     }
847 }
848
849 void CSQC_WAKIZASHI_HUD()
850 {
851 /*
852     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
853     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0'  * (1 - health), 1, DRAWFLAG_NORMAL);
854     drawpic(hudloc, waki_r, picsize, '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
855     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0'  * (1 - energy), 1, DRAWFLAG_NORMAL);
856 */
857         if(autocvar_r_letterbox)
858         return;
859
860     vector picsize, hudloc, pic2size, picloc;
861
862     // Fetch health & ammo stats
863         HUD_GETSTATS
864
865     picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
866     hudloc_y = vid_conheight - picsize_y;
867     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
868
869     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
870
871     shield  *= 0.01;
872     vh_health  *= 0.01;
873     energy  *= 0.01;
874     reload1 *= 0.01;
875
876     pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
877     picloc = picsize * 0.5 - pic2size * 0.5;
878     if(vh_health < 0.25)
879         drawpic(hudloc + picloc, waki_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
880     else
881         drawpic(hudloc + picloc, waki_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
882     drawpic(hudloc + picloc, waki_eng, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
883     drawpic(hudloc + picloc, waki_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
884     drawpic(hudloc + picloc, waki_rkt, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
885     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
886
887 // Health bar
888     picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
889     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
890     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
891     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
892     drawresetcliparea();
893 // ..  and icon
894     picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
895     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
896     if(vh_health < 0.25)
897     {
898         if(alarm1time < time)
899         {
900             alarm1time = time + 2;
901             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTN_NONE);
902         }
903         
904         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
905     }        
906     else
907     {
908         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
909         if(alarm1time)
910         {
911             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
912             alarm1time = 0;
913         }        
914     }
915         
916
917 // Shield bar
918     picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
919     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
920     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
921     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
922     drawresetcliparea();
923 // ..  and icon
924     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
925     picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
926     if(shield < 0.25)
927     {
928         if(alarm2time < time)
929         {
930             alarm2time = time + 1;
931             sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTN_NONE);
932         }
933         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
934     }
935     else
936     {
937         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
938         if(alarm2time)
939         {            
940             sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
941             alarm2time = 0;
942         }
943     }
944     
945 // Gun bar
946     picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
947     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
948     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
949     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
950     drawresetcliparea();
951 // ..  and icon
952     picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
953     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
954     if(energy < 0.2)
955         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
956     else
957         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
958
959 // Bomb bar
960     picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
961     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
962     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
963     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
964     drawresetcliparea();
965 // ..  and icon
966     pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
967     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
968     if(reload1 != 1)
969         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
970     else
971         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
972
973         if (scoreboard_showscores)
974                 HUD_DrawScoreboard();
975     else
976     {
977         picsize = draw_getimagesize(waki_xhair);
978         picsize_x *= 0.5;
979         picsize_y *= 0.5;
980
981
982         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);
983     }
984 }
985
986 void Vehicles_Precache()
987 {
988 // fixme: HAAAAKKKZZZ!!!!!!!!!!!! (this belongs as a setting in default.cfg)
989     if(!autocvar_cl_vehicles_hudscale )
990         autocvar_cl_vehicles_hudscale = 0.5;
991     
992     if(!autocvar_cl_vehicles_hudalpha)
993         autocvar_cl_vehicles_hudalpha = 0.75;
994
995         //precache_model("models/vehicles/wakizashi.dpm");
996
997         precache_model("models/vehicles/bomblet.md3");
998         precache_model("models/vehicles/clusterbomb.md3");
999         precache_model("models/vehicles/clusterbomb_fragment.md3");
1000         precache_model("models/vehicles/rocket01.md3");
1001         precache_model("models/vehicles/rocket02.md3");
1002         
1003         precache_sound ("vehicles/alarm.wav");
1004         precache_sound ("vehicles/alarm_shield.wav");
1005 }
1006
1007 void RaptorCBShellfragDraw()
1008 {
1009         
1010         Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
1011         if(wasfreed(self))
1012                 return;     
1013
1014         self.move_avelocity += randomvec() * 15;
1015         self.renderflags = 0;
1016         if(self.cnt < time)
1017         self.alpha = bound(0, self.nextthink - time, 1);
1018
1019         if(self.alpha < ALPHA_MIN_VISIBLE)
1020         remove(self);
1021 }
1022
1023 void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang)
1024 {
1025     entity sfrag;
1026     
1027     sfrag = spawn();
1028     setmodel(sfrag, "models/vehicles/clusterbomb_fragment.md3");
1029     setorigin(sfrag, _org);
1030
1031         sfrag.move_movetype = MOVETYPE_BOUNCE;
1032         sfrag.gravity = 0.15;
1033         sfrag.solid = SOLID_CORPSE;
1034
1035         sfrag.draw = RaptorCBShellfragDraw;
1036
1037         sfrag.move_origin = sfrag.origin = _org;
1038         sfrag.move_velocity = _vel;
1039         sfrag.move_avelocity = prandomvec() * vlen(sfrag.move_velocity);
1040         sfrag.angles = self.move_angles = _ang;
1041
1042         sfrag.move_time = time;
1043         sfrag.damageforcescale = 4;
1044
1045         sfrag.nextthink = time + 3;
1046         sfrag.cnt = time + 2;
1047         sfrag.alpha = 1;
1048     sfrag.drawmask = MASK_NORMAL;
1049 }