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