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