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