]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/vehicles/vehicles.qc
Make raptor bomb shell fragments work again
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / vehicles / vehicles.qc
1 #define hud_bg "gfx/vehicles/frame.tga"
2 #define hud_sh "gfx/vehicles/vh-shield.tga"
3
4 #define hud_hp_bar "gfx/vehicles/bar_up_left.tga"
5 #define hud_hp_ico "gfx/vehicles/health.tga"
6 #define hud_sh_bar "gfx/vehicles/bar_dwn_left.tga"
7 #define hud_sh_ico "gfx/vehicles/shield.tga"
8
9 #define hud_ammo1_bar "gfx/vehicles/bar_up_right.tga"
10 #define hud_ammo1_ico "gfx/vehicles/bullets.tga"
11 #define hud_ammo2_bar "gfx/vehicles/bar_dwn_right.tga"
12 #define hud_ammo2_ico "gfx/vehicles/rocket.tga"
13
14 entity dropmark;
15
16 void CSQC_WAKIZASHI_HUD();
17 void CSQC_SPIDER_HUD();
18 void CSQC_RAPTOR_HUD();
19 void CSQC_BUMBLE_HUD();
20
21 #define MAX_AXH 4
22 entity AuxiliaryXhair[MAX_AXH];
23 const var void Draw_Not();
24
25 .string axh_image;
26 .float  axh_fadetime;
27 .float  axh_drawflag;
28 .float  axh_scale;
29
30 void AuxiliaryXhair_Draw2D()
31 {
32     vector loc, psize;
33
34     psize = self.axh_scale * drawgetimagesize(self.axh_image);
35     loc = project_3d_to_2d(self.origin) - 0.5 * psize;
36     if not (loc_z < 0 || loc_x < 0 || loc_y < 0 || loc_x > vid_conwidth || loc_y > vid_conheight)
37     {
38         loc_z = 0;
39         psize_z = 0;
40         drawpic(loc, self.axh_image, psize, self.colormod, self.alpha, self.axh_drawflag);
41     }
42
43     if(time - self.cnt > self.axh_fadetime)
44         self.draw2d = Draw_Not;
45 }
46
47 void Net_AuXair2(float bIsNew)
48 {
49     float axh_id;
50     entity axh;
51
52     axh_id = bound(0, ReadByte(), MAX_AXH);
53     axh = AuxiliaryXhair[axh_id];
54
55     if(axh == world || wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
56     {
57         axh               = spawn();
58                 axh.draw2d        = Draw_Not;
59                 axh.drawmask      = MASK_NORMAL;
60                 axh.axh_drawflag  = DRAWFLAG_ADDITIVE;
61                 axh.axh_fadetime  = 0.1;
62                 axh.axh_image     = "gfx/vehicles/axh-ring.tga";
63                 axh.axh_scale     = 1;
64         axh.alpha         = 1;
65                 AuxiliaryXhair[axh_id] = axh;
66     }
67
68     axh.draw2d   = AuxiliaryXhair_Draw2D;
69
70         axh.origin_x = ReadCoord();
71         axh.origin_y = ReadCoord();
72         axh.origin_z = ReadCoord();
73
74         axh.colormod_x = ReadByte() / 255;
75         axh.colormod_y = ReadByte() / 255;
76         axh.colormod_z = ReadByte() / 255;
77     axh.cnt = time;
78 }
79
80 void Net_VehicleSetup()
81 {
82
83     float hud_id, i;
84     hud_id = bound(HUD_SPIDERBOT, ReadByte(), HUD_RAPTOR);
85
86     // Init auxiliary crosshairs
87     entity axh;
88     for(i = 0; i < MAX_AXH; ++i)
89     {
90         axh = AuxiliaryXhair[i];
91         if(axh != world && !wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
92             remove(axh);
93
94         axh               = spawn();
95                 axh.draw2d        = Draw_Not;
96                 axh.drawmask      = MASK_NORMAL;
97                 axh.axh_drawflag  = DRAWFLAG_ADDITIVE;
98                 axh.axh_fadetime  = 0.1;
99                 axh.axh_image     = "gfx/vehicles/axh-ring.tga";
100                 axh.axh_scale     = 1;
101         axh.alpha         = 1;
102                 AuxiliaryXhair[i] = axh;
103     }
104
105     switch(hud_id)
106     {
107         case HUD_SPIDERBOT:
108             // Minigun1
109             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-ring.tga";
110             AuxiliaryXhair[0].axh_scale   = 0.25;
111             // Minigun2
112             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-ring.tga";
113             AuxiliaryXhair[1].axh_scale   = 0.25;
114             // Rocket
115             AuxiliaryXhair[2].axh_image   = "gfx/vehicles/axh-special1.tga";
116             AuxiliaryXhair[2].axh_scale   = 0.5;
117             break;
118
119         case HUD_WAKIZASHI:
120             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-bracket.tga";
121             AuxiliaryXhair[0].axh_scale   = 0.25;
122             break;
123
124         case HUD_RAPTOR:
125             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-cross.tga";
126             AuxiliaryXhair[0].axh_scale   = 0.5;
127             AuxiliaryXhair[0].alpha       = 0.25;
128
129             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-bracket.tga";
130             AuxiliaryXhair[1].axh_scale   = 0.25;
131             AuxiliaryXhair[1].alpha       = 0.75;
132             AuxiliaryXhair[1].axh_drawflag  = DRAWFLAG_NORMAL;
133             break;
134
135         case HUD_BUMBLEBEE:
136             // Plasma cannons
137             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-ring.tga";
138             AuxiliaryXhair[0].axh_scale   = 0.25;
139             // Raygun
140             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-special1.tga";
141             AuxiliaryXhair[1].axh_scale   = 0.25;
142             break;
143     }
144 }
145 #define HUD_GETSTATS \
146     float health    = getstati(STAT_VEHICLESTAT_HEALTH);  \
147         float shield    = getstati(STAT_VEHICLESTAT_SHIELD);  \
148         float energy    = getstati(STAT_VEHICLESTAT_ENERGY);  \
149         float ammo1     = getstati(STAT_VEHICLESTAT_AMMO1);   \
150         float reload1   = getstati(STAT_VEHICLESTAT_RELOAD1); \
151         float ammo2     = getstati(STAT_VEHICLESTAT_AMMO2);   \
152         float reload2   = getstati(STAT_VEHICLESTAT_RELOAD2);
153
154 void CSQC_BUMBLE_HUD()
155 {
156     /*
157         vector picsize, hudloc;
158
159     // Fetch health & ammo stats
160         HUD_GETSTATS
161
162     hudloc_y = 4;
163     hudloc_x = 4;
164
165     picsize = drawgetimagesize(spider_h) * 0.5;
166     drawpic(hudloc, spider_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
167
168     picsize = drawgetimagesize(spider_a2) * 0.5;
169     drawpic(hudloc + '120 96  0', spider_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
170
171     drawstring(hudloc + '145 19  0',  strcat(ftos(health), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
172     drawstring(hudloc + '175 34  0',  strcat(ftos(shield), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
173     drawstring(hudloc + '136 102  0', strcat(ftos(ammo1), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
174
175     picsize = drawgetimagesize(spider_a1) * 0.85;
176     if(ammo2 == 9)
177     {
178         drawpic(hudloc + '132 54  0', spider_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
179         drawstring(hudloc + '179 69 0', strcat(ftos(reload2), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
180     }
181     else
182     {
183         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
184         drawstring(hudloc + '179 69  0', strcat(ftos(9 - ammo2), " / 8"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
185     }
186
187     picsize = drawgetimagesize(spider_b) * 0.5;
188     hudloc_y = 10.5;
189     hudloc_x = 10.5;
190
191     ammo1  /= 100;
192     shield /= 100;
193     health /= 100;
194     reload2 /= 100;
195
196     drawpic(hudloc, spider_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
197     drawpic(hudloc, spider_b, picsize, '0 1 0' * health + '1 0 0' * (1 - health), 1, DRAWFLAG_NORMAL);
198     drawpic(hudloc, spider_r, picsize, '1 1 1' * reload2 + '1 0 0' * (1 - reload2), 1, DRAWFLAG_NORMAL);
199     drawpic(hudloc, spider_g, picsize, '1 1 1' * ammo1 + '1 0 0' *  (1 - ammo1), 1, DRAWFLAG_NORMAL);
200
201
202         if (scoreboard_showscores)
203         {
204                 HUD_DrawScoreboard();
205                 HUD_DrawCenterPrint();
206     }
207     else
208     {
209         picsize = drawgetimagesize(SPIDER_CROSS);
210         picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
211         picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
212
213         drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), SPIDER_CROSS, picsize, '1 1 1', autocvar_cl_vehicle_spiderbot_cross_alpha, DRAWFLAG_ADDITIVE);
214     */
215 }
216
217
218 #define spider_ico  "gfx/vehicles/sbot.tga"
219 #define spider_rkt  "gfx/vehicles/sbot_rpods.tga"
220 #define spider_mgun "gfx/vehicles/sbot_mguns.tga"
221 #define spider_xhair "gfx/vehicles/axh-special1.tga"
222
223 float autocvar_cl_vehicles_hudscale;
224 float autocvar_cl_vehicles_hudalpha;
225 float flashtime;
226 void CSQC_SPIDER_HUD()
227 {
228         if(autocvar_r_letterbox)
229         return;
230
231     vector picsize, hudloc, pic2size, picloc;
232     float i;
233
234     // Fetch health & ammo stats
235         HUD_GETSTATS
236
237     picsize = drawgetimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
238     hudloc_y = vid_conheight - picsize_y;
239     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
240
241     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
242
243     //drawstring(hudloc + '145 19  0', strcat(ftos(health), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
244     //drawstring(hudloc + '175 34  0', strcat(ftos(shield), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
245     //drawstring(hudloc + '136 102  0', strcat(ftos(ammo1), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
246     //drawstring(hudloc + '179 69  0', strcat(ftos(9 - ammo2), " / 8"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
247
248     ammo1   *= 0.01;
249     shield  *= 0.01;
250     health  *= 0.01;
251     reload2 *= 0.01;
252
253     pic2size = drawgetimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
254     picloc = picsize * 0.5 - pic2size * 0.5;
255     drawpic(hudloc + picloc, spider_ico, pic2size,  '1 1 1' * health  + '1 0 0' * (1 - health),  1, DRAWFLAG_NORMAL);
256     drawpic(hudloc + picloc, spider_rkt, pic2size,  '1 1 1' * reload2 + '1 0 0' * (1 - reload2), 1, DRAWFLAG_NORMAL);
257     drawpic(hudloc + picloc, spider_mgun, pic2size, '1 1 1' * ammo1   + '1 0 0' * (1 - ammo1),   1, DRAWFLAG_NORMAL);
258     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
259
260 // Health bar
261     picsize = drawgetimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
262     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
263     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - health)), 0, vid_conwidth, vid_conheight);
264     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
265     drawresetcliparea();
266 // ..  and icon
267     picsize = drawgetimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
268     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
269     if(health < 0.25)
270         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
271     else
272         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
273
274 // Shield bar
275     picsize = drawgetimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
276     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
277     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
278     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
279     drawresetcliparea();
280 // ..  and icon
281     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
282     picsize = drawgetimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
283     if(shield < 0.25)
284         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
285     else
286         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
287
288 // Minigun bar
289     picsize = drawgetimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
290     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
291     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * ammo1, vid_conheight);
292     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
293     drawresetcliparea();
294 // ..  and icon
295     picsize = drawgetimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
296     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
297     if(ammo1 < 0.2)
298         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
299     else
300         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
301
302 // Rocket ammo bar
303     picsize = drawgetimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
304     ammo1 = picsize_x / 8;
305     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
306     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload2, vid_conheight);
307     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
308     drawresetcliparea();
309
310 // ..  and icons
311     pic2size = 0.35 * drawgetimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
312     picloc_x -= pic2size_x;
313     picloc_y += pic2size_y * 2.25;
314     if(ammo2 == 9)
315     {
316         for(i = 1; i < 9; ++i)
317         {
318             picloc_x += ammo1;
319             drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((8 * reload2 <= i) ? '0 0 0' : '1 1 1'), 0.75, DRAWFLAG_NORMAL);
320         }
321     }
322     else
323     {
324         for(i = 1; i < 9; ++i)
325         {
326             picloc_x += ammo1;
327             drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((i >= ammo2) ? '1 1 1' : '0 0 0'), 0.75, DRAWFLAG_NORMAL);
328         }
329     }
330     pic2size = drawgetimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
331     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
332     if(ammo2 == 9)
333         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
334     else
335         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
336
337
338     HUD_DrawCenterPrint();
339
340         if (scoreboard_showscores)
341                 HUD_DrawScoreboard();
342     else
343     {
344         picsize = drawgetimagesize(spider_xhair);
345         picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
346         picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
347
348         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);
349     }
350 }
351
352 #define raptor_ico  "gfx/vehicles/raptor.tga"
353 #define raptor_gun  "gfx/vehicles/raptor_guns.tga"
354 #define raptor_bomb "gfx/vehicles/raptor_bombs.tga"
355 #define raptor_drop "gfx/vehicles/axh-dropcross.tga"
356 #define raptor_xhair "gfx/vehicles/axh-cross.tga"
357 void CSQC_RAPTOR_HUD()
358 {
359         if(autocvar_r_letterbox)
360         return;
361
362     vector picsize, hudloc, pic2size, picloc;
363
364     // Fetch health & ammo stats
365         HUD_GETSTATS
366
367     picsize = drawgetimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
368     hudloc_y = vid_conheight - picsize_y;
369     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
370
371     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
372
373     ammo1   *= 0.01;
374     ammo2   *= 0.01;
375     shield  *= 0.01;
376     health  *= 0.01;
377     energy  *= 0.01;
378     reload1 = reload2 * 0.01;
379     //reload2 *= 0.01;
380
381     pic2size = drawgetimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
382     picloc = picsize * 0.5 - pic2size * 0.5;
383     drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 1 1' * health  + '1 0 0' * (1 - health),  1, DRAWFLAG_NORMAL);
384     drawpic(hudloc + picloc, raptor_bomb, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
385     drawpic(hudloc + picloc, raptor_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
386     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
387
388 // Health bar
389     picsize = drawgetimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
390     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
391     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - health)), 0, vid_conwidth, vid_conheight);
392     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
393     drawresetcliparea();
394 // ..  and icon
395     picsize = drawgetimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
396     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
397     if(health < 0.25)
398         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
399     else
400         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
401
402 // Shield bar
403     picsize = drawgetimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
404     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
405     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
406     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
407     drawresetcliparea();
408 // ..  and icon
409     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
410     picsize = drawgetimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
411     if(shield < 0.25)
412         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
413     else
414         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
415
416 // Gun bar
417     picsize = drawgetimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
418     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
419     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
420     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
421     drawresetcliparea();
422 // ..  and icon
423     picsize = drawgetimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
424     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
425     if(energy < 0.2)
426         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
427     else
428         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
429
430 // Bomb bar
431     picsize = drawgetimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
432     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
433     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
434     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
435     drawresetcliparea();
436 // ..  and icon
437     pic2size = drawgetimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
438     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
439     if(reload1 != 1)
440         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
441     else
442         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
443
444 // Bombing crosshair
445     if(!dropmark)
446     {
447         dropmark = spawn();
448         dropmark.owner = self;
449         dropmark.gravity = 1;
450     }
451
452     if(reload2 == 100)
453     {
454         vector where;
455
456         setorigin(dropmark, pmove_org);
457         dropmark.velocity = pmove_vel;
458         tracetoss(dropmark, self);
459
460         where = project_3d_to_2d(trace_endpos);
461
462         setorigin(dropmark, trace_endpos);
463         picsize = drawgetimagesize(raptor_drop) * 0.2;
464
465         if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
466         {
467             where_x -= picsize_x * 0.5;
468             where_y -= picsize_y * 0.5;
469             where_z = 0;
470             drawpic(where, raptor_drop, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
471         }
472         dropmark.cnt = time + 5;
473     }
474     else
475     {
476         vector where;
477         if(dropmark.cnt > time)
478         {
479             where = project_3d_to_2d(dropmark.origin);
480             picsize = drawgetimagesize(raptor_drop) * 0.25;
481
482             if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
483             {
484                 where_x -= picsize_x * 0.5;
485                 where_y -= picsize_y * 0.5;
486                 where_z = 0;
487                 drawpic(where, raptor_drop, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
488             }
489         }
490     }
491
492     HUD_DrawCenterPrint();
493
494         if (scoreboard_showscores)
495                 HUD_DrawScoreboard();
496     else
497     {
498         picsize = drawgetimagesize(raptor_xhair);
499         picsize_x *= 0.5;
500         picsize_y *= 0.5;
501
502         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);
503     }
504 }
505
506 #define waki_ico "gfx/vehicles/waki.tga"
507 #define waki_eng "gfx/vehicles/waki_e.tga"
508 #define waki_gun "gfx/vehicles/waki_guns.tga"
509 #define waki_rkt "gfx/vehicles/waki_rockets.tga"
510 #define waki_xhair "gfx/vehicles/axh-special1.tga"
511 void CSQC_WAKIZASHI_HUD()
512 {
513 /*
514     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
515     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0'  * (1 - health), 1, DRAWFLAG_NORMAL);
516     drawpic(hudloc, waki_r, picsize, '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
517     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0'  * (1 - energy), 1, DRAWFLAG_NORMAL);
518 */
519         if(autocvar_r_letterbox)
520         return;
521
522     vector picsize, hudloc, pic2size, picloc;
523
524     // Fetch health & ammo stats
525         HUD_GETSTATS
526
527     picsize = drawgetimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
528     hudloc_y = vid_conheight - picsize_y;
529     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
530
531     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
532
533     shield  *= 0.01;
534     health  *= 0.01;
535     energy  *= 0.01;
536     reload1 *= 0.01;
537
538     pic2size = drawgetimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
539     picloc = picsize * 0.5 - pic2size * 0.5;
540     drawpic(hudloc + picloc, waki_ico, pic2size,  '1 1 1' * health  + '1 0 0' * (1 - health),  1, DRAWFLAG_NORMAL);
541     drawpic(hudloc + picloc, waki_eng, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
542     drawpic(hudloc + picloc, waki_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
543     drawpic(hudloc + picloc, waki_rkt, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
544     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
545
546 // Health bar
547     picsize = drawgetimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
548     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
549     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - health)), 0, vid_conwidth, vid_conheight);
550     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
551     drawresetcliparea();
552 // ..  and icon
553     picsize = drawgetimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
554     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
555     if(health < 0.25)
556         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
557     else
558         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
559
560 // Shield bar
561     picsize = drawgetimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
562     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
563     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
564     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
565     drawresetcliparea();
566 // ..  and icon
567     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
568     picsize = drawgetimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
569     if(shield < 0.25)
570         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
571     else
572         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
573
574 // Gun bar
575     picsize = drawgetimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
576     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
577     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
578     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
579     drawresetcliparea();
580 // ..  and icon
581     picsize = drawgetimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
582     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
583     if(energy < 0.2)
584         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
585     else
586         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
587
588 // Bomb bar
589     picsize = drawgetimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
590     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
591     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
592     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
593     drawresetcliparea();
594 // ..  and icon
595     pic2size = drawgetimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
596     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
597     if(reload1 != 1)
598         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
599     else
600         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
601
602
603     HUD_DrawCenterPrint();
604
605         if (scoreboard_showscores)
606                 HUD_DrawScoreboard();
607     else
608     {
609         picsize = drawgetimagesize(waki_xhair);
610         picsize_x *= 0.5;
611         picsize_y *= 0.5;
612
613         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);
614     }
615 }
616
617 void Vehicles_Precache()
618 {
619         precache_model("models/vehicles/wakizashi.dpm");
620
621         precache_model("models/vehicles/bomblet.md3");
622         precache_model("models/vehicles/clusterbomb.md3");
623         precache_model("models/vehicles/clusterbomb_fragment.md3");
624         precache_model("models/vehicles/rocket01.md3");
625         precache_model("models/vehicles/rocket02.md3");
626 }
627
628 void RaptorCBShellfragDraw()
629 {
630         
631         Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
632         if(wasfreed(self))
633                 return;     
634
635         self.move_avelocity += randomvec() * 15;
636         self.renderflags = 0;
637         if(self.cnt < time)
638         self.alpha = bound(0, self.nextthink - time, 1);
639
640         if(self.alpha < ALPHA_MIN_VISIBLE)
641         remove(self);
642 }
643
644 void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang)
645 {
646     entity sfrag;
647     
648     sfrag = spawn();
649     setmodel(sfrag, "models/vehicles/clusterbomb_fragment.md3");
650     setorigin(sfrag, _org);
651
652         sfrag.move_movetype = MOVETYPE_BOUNCE;
653         sfrag.gravity = 0.15;
654         sfrag.solid = SOLID_CORPSE;
655
656         sfrag.draw = RaptorCBShellfragDraw;
657
658         sfrag.move_origin = sfrag.origin = _org;
659         sfrag.move_velocity = _vel;
660         sfrag.move_avelocity = prandomvec() * vlen(sfrag.move_velocity);
661         sfrag.angles = self.move_angles = _ang;
662
663         sfrag.move_time = time;
664         sfrag.damageforcescale = 4;
665
666         sfrag.nextthink = time + 3;
667         sfrag.cnt = time + 2;
668         sfrag.alpha = 1;
669     sfrag.drawmask = MASK_NORMAL;
670 }