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