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