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