]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/vehicles/vehicles.qc
40f63283ab2bc98869b3e591885decc764a7e56a
[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
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_NORMAL;
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-special2.tga";
129             AuxiliaryXhair[0].axh_scale   = 0.5;
130             //AuxiliaryXhair[0].alpha       = 0.5;
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 vh_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
161
162 #define spider_ico  "gfx/vehicles/sbot.tga"
163 #define spider_rkt  "gfx/vehicles/sbot_rpods.tga"
164 #define spider_mgun "gfx/vehicles/sbot_mguns.tga"
165 #define spider_xhair "gfx/vehicles/axh-special1.tga"
166 float alarm1time;
167 float alarm2time;
168
169 void CSQC_SPIDER_HUD()
170 {
171         if(autocvar_r_letterbox)
172         return;
173
174     vector picsize, hudloc, pic2size, picloc;
175     float i;
176
177     // Fetch health & ammo stats
178         HUD_GETSTATS
179
180     picsize = drawgetimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
181     hudloc_y = vid_conheight - picsize_y;
182     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
183
184     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
185
186     //drawstring(hudloc + '145 19  0', strcat(ftos(vh_health), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
187     //drawstring(hudloc + '175 34  0', strcat(ftos(shield), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
188     //drawstring(hudloc + '136 102  0', strcat(ftos(ammo1), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
189     //drawstring(hudloc + '179 69  0', strcat(ftos(9 - ammo2), " / 8"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
190
191     ammo1   *= 0.01;
192     shield  *= 0.01;
193     vh_health  *= 0.01;
194     reload2 *= 0.01;
195
196     pic2size = drawgetimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
197     picloc = picsize * 0.5 - pic2size * 0.5;
198     if(vh_health < 0.25)
199         drawpic(hudloc + picloc, spider_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
200     else
201         drawpic(hudloc + picloc, spider_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);    
202     drawpic(hudloc + picloc, spider_rkt, pic2size,  '1 1 1' * reload2 + '1 0 0' * (1 - reload2), 1, DRAWFLAG_NORMAL);
203     drawpic(hudloc + picloc, spider_mgun, pic2size, '1 1 1' * ammo1   + '1 0 0' * (1 - ammo1),   1, DRAWFLAG_NORMAL);
204     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
205
206 // Health bar
207     picsize = drawgetimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
208     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
209     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
210     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
211     drawresetcliparea();
212 // ..  and icon
213     picsize = drawgetimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
214     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
215     if(vh_health < 0.25)
216     {
217         if(alarm1time < time)
218         {
219             alarm1time = time + 2;
220             sound(world, CHAN_PAIN, "vehicles/alarm.wav", VOL_BASEVOICE, ATTN_NONE);
221         }        
222         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
223     }        
224     else
225     {
226         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
227         if(alarm1time)
228         {
229             sound(world, CHAN_PAIN, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
230             alarm1time = 0;
231         }        
232     }
233 // Shield bar
234     picsize = drawgetimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
235     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
236     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
237     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
238     drawresetcliparea();
239 // ..  and icon
240     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
241     picsize = drawgetimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
242     if(shield < 0.25)
243     {
244         if(alarm2time < time)
245         {
246             alarm2time = time + 1;
247             sound(world, CHAN_TRIGGER, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTN_NONE);
248         }
249         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
250     }
251     else
252     {
253         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
254         if(alarm2time)
255         {            
256             sound(world, CHAN_TRIGGER, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
257             alarm2time = 0;
258         }
259     }
260     
261
262 // Minigun bar
263     picsize = drawgetimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
264     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
265     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * ammo1, vid_conheight);
266     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
267     drawresetcliparea();
268 // ..  and icon
269     picsize = drawgetimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
270     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
271     if(ammo1 < 0.2)
272         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
273     else
274         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
275
276 // Rocket ammo bar
277     picsize = drawgetimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
278     ammo1 = picsize_x / 8;
279     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
280     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload2, vid_conheight);
281     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
282     drawresetcliparea();
283
284 // ..  and icons
285     pic2size = 0.35 * drawgetimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
286     picloc_x -= pic2size_x;
287     picloc_y += pic2size_y * 2.25;
288     if(ammo2 == 9)
289     {
290         for(i = 1; i < 9; ++i)
291         {
292             picloc_x += ammo1;
293             drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((8 * reload2 <= i) ? '0 0 0' : '1 1 1'), 0.75, DRAWFLAG_NORMAL);
294         }
295     }
296     else
297     {
298         for(i = 1; i < 9; ++i)
299         {
300             picloc_x += ammo1;
301             drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((i >= ammo2) ? '1 1 1' : '0 0 0'), 0.75, DRAWFLAG_NORMAL);
302         }
303     }
304     pic2size = drawgetimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
305     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
306     if(ammo2 == 9)
307         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
308     else
309         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
310
311         if (scoreboard_showscores)
312                 HUD_DrawScoreboard();
313     else
314     {
315         picsize = drawgetimagesize(spider_xhair);
316         picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
317         picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
318
319         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);
320     }
321 }
322
323 #define raptor_ico  "gfx/vehicles/raptor.tga"
324 #define raptor_gun  "gfx/vehicles/raptor_guns.tga"
325 #define raptor_bomb "gfx/vehicles/raptor_bombs.tga"
326 #define raptor_drop "gfx/vehicles/axh-dropcross.tga"
327 #define raptor_xhair "gfx/vehicles/axh-ring.tga"
328 void CSQC_RAPTOR_HUD()
329 {
330         if(autocvar_r_letterbox)
331         return;
332
333     vector picsize, hudloc, pic2size, picloc;
334
335     // Fetch health & ammo stats
336         HUD_GETSTATS
337
338     picsize = drawgetimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
339     hudloc_y = vid_conheight - picsize_y;
340     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
341
342     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
343
344     ammo1   *= 0.01;
345     ammo2   *= 0.01;
346     shield  *= 0.01;
347     vh_health  *= 0.01;
348     energy  *= 0.01;
349     reload1 = reload2 * 0.01;
350     //reload2 *= 0.01;
351
352     pic2size = drawgetimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
353     picloc = picsize * 0.5 - pic2size * 0.5;
354     if(vh_health < 0.25)
355         drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
356     else
357         drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
358     drawpic(hudloc + picloc, raptor_bomb, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
359     drawpic(hudloc + picloc, raptor_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
360     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
361
362 // Health bar
363     picsize = drawgetimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
364     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
365     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
366     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
367     drawresetcliparea();
368 // ..  and icon
369     picsize = drawgetimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
370     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
371     if(vh_health < 0.25)
372     {
373         if(alarm1time < time)
374         {
375             alarm1time = time + 2;
376             sound(self, CHAN_PAIN, "vehicles/alarm.wav", VOL_BASEVOICE, ATTN_NONE);
377         }
378         
379         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
380     }        
381     else
382     {
383         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
384         if(alarm1time)
385         {
386             sound(self, CHAN_PAIN, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
387             alarm1time = 0;
388         }
389     }
390
391 // Shield bar
392     picsize = drawgetimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
393     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
394     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
395     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
396     drawresetcliparea();
397 // ..  and icon
398     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
399     picsize = drawgetimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
400     if(shield < 0.25)
401     {
402         if(alarm2time < time)
403         {
404             alarm2time = time + 1;
405             sound(world, CHAN_TRIGGER, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTN_NONE);
406         }
407         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
408     }
409     else
410     {
411         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
412         if(alarm2time)
413         {            
414             sound(world, CHAN_TRIGGER, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
415             alarm2time = 0;
416         }
417     }
418     
419 // Gun bar
420     picsize = drawgetimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
421     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
422     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
423     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
424     drawresetcliparea();
425 // ..  and icon
426     picsize = drawgetimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
427     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
428     if(energy < 0.2)
429         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
430     else
431         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
432
433 // Bomb bar
434     picsize = drawgetimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
435     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
436     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
437     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
438     drawresetcliparea();
439 // ..  and icon
440     pic2size = drawgetimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
441     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
442     if(reload1 != 1)
443         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
444     else
445         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
446
447 // Bombing crosshair
448     if(!dropmark)
449     {
450         dropmark = spawn();
451         dropmark.owner = self;
452         dropmark.gravity = 1;
453     }
454
455     if(reload2 == 100)
456     {
457         vector where;
458
459         setorigin(dropmark, pmove_org);
460         dropmark.velocity = pmove_vel;
461         tracetoss(dropmark, self);
462
463         where = project_3d_to_2d(trace_endpos);
464
465         setorigin(dropmark, trace_endpos);
466         picsize = drawgetimagesize(raptor_drop) * 0.2;
467
468         if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
469         {
470             where_x -= picsize_x * 0.5;
471             where_y -= picsize_y * 0.5;
472             where_z = 0;
473             drawpic(where, raptor_drop, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
474         }
475         dropmark.cnt = time + 5;
476     }
477     else
478     {
479         vector where;
480         if(dropmark.cnt > time)
481         {
482             where = project_3d_to_2d(dropmark.origin);
483             picsize = drawgetimagesize(raptor_drop) * 0.25;
484
485             if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
486             {
487                 where_x -= picsize_x * 0.5;
488                 where_y -= picsize_y * 0.5;
489                 where_z = 0;
490                 drawpic(where, raptor_drop, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
491             }
492         }
493     }
494
495         if (scoreboard_showscores)
496                 HUD_DrawScoreboard();
497     else
498     {
499         picsize = drawgetimagesize(raptor_xhair);
500         picsize_x *= 0.5;
501         picsize_y *= 0.5;
502
503         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);
504     }
505 }
506
507 #define waki_ico "gfx/vehicles/waki.tga"
508 #define waki_eng "gfx/vehicles/waki_e.tga"
509 #define waki_gun "gfx/vehicles/waki_guns.tga"
510 #define waki_rkt "gfx/vehicles/waki_rockets.tga"
511 #define waki_xhair "gfx/vehicles/axh-special1.tga"
512 void CSQC_WAKIZASHI_HUD()
513 {
514 /*
515     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
516     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0'  * (1 - health), 1, DRAWFLAG_NORMAL);
517     drawpic(hudloc, waki_r, picsize, '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
518     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0'  * (1 - energy), 1, DRAWFLAG_NORMAL);
519 */
520         if(autocvar_r_letterbox)
521         return;
522
523     vector picsize, hudloc, pic2size, picloc;
524
525     // Fetch health & ammo stats
526         HUD_GETSTATS
527
528     picsize = drawgetimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
529     hudloc_y = vid_conheight - picsize_y;
530     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
531
532     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
533
534     shield  *= 0.01;
535     vh_health  *= 0.01;
536     energy  *= 0.01;
537     reload1 *= 0.01;
538
539     pic2size = drawgetimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
540     picloc = picsize * 0.5 - pic2size * 0.5;
541     if(vh_health < 0.25)
542         drawpic(hudloc + picloc, waki_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
543     else
544         drawpic(hudloc + picloc, waki_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
545     drawpic(hudloc + picloc, waki_eng, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
546     drawpic(hudloc + picloc, waki_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
547     drawpic(hudloc + picloc, waki_rkt, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
548     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
549
550 // Health bar
551     picsize = drawgetimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
552     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
553     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
554     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
555     drawresetcliparea();
556 // ..  and icon
557     picsize = drawgetimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
558     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
559     if(vh_health < 0.25)
560     {
561         if(alarm1time < time)
562         {
563             alarm1time = time + 2;
564             sound(self, CHAN_PAIN, "vehicles/alarm.wav", VOL_BASEVOICE, ATTN_NONE);
565         }
566         
567         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
568     }        
569     else
570     {
571         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
572         if(alarm1time)
573         {
574             sound(self, CHAN_PAIN, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
575             alarm1time = 0;
576         }        
577     }
578         
579
580 // Shield bar
581     picsize = drawgetimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
582     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
583     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
584     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
585     drawresetcliparea();
586 // ..  and icon
587     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
588     picsize = drawgetimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
589     if(shield < 0.25)
590     {
591         if(alarm2time < time)
592         {
593             alarm2time = time + 1;
594             sound(world, CHAN_TRIGGER, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTN_NONE);
595         }
596         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
597     }
598     else
599     {
600         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
601         if(alarm2time)
602         {            
603             sound(world, CHAN_TRIGGER, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
604             alarm2time = 0;
605         }
606     }
607     
608 // Gun bar
609     picsize = drawgetimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
610     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
611     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
612     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
613     drawresetcliparea();
614 // ..  and icon
615     picsize = drawgetimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
616     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
617     if(energy < 0.2)
618         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
619     else
620         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
621
622 // Bomb bar
623     picsize = drawgetimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
624     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
625     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
626     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
627     drawresetcliparea();
628 // ..  and icon
629     pic2size = drawgetimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
630     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
631     if(reload1 != 1)
632         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
633     else
634         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
635
636         if (scoreboard_showscores)
637                 HUD_DrawScoreboard();
638     else
639     {
640         picsize = drawgetimagesize(waki_xhair);
641         picsize_x *= 0.5;
642         picsize_y *= 0.5;
643
644
645         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);
646     }
647 }
648
649 void Vehicles_Precache()
650 {
651 // fixme: HAAAAKKKZZZ!!!!!!!!!!!! (this belongs as a setting in default.cfg)
652     autocvar_cl_vehicles_hudscale = 0.5;
653     autocvar_cl_vehicles_hudalpha = 0.75;
654
655
656         precache_model("models/vehicles/wakizashi.dpm");
657
658         precache_model("models/vehicles/bomblet.md3");
659         precache_model("models/vehicles/clusterbomb.md3");
660         precache_model("models/vehicles/clusterbomb_fragment.md3");
661         precache_model("models/vehicles/rocket01.md3");
662         precache_model("models/vehicles/rocket02.md3");
663         
664         precache_sound ("vehicles/alarm.wav");
665         precache_sound ("vehicles/alarm_shield.wav");
666 }
667
668 void RaptorCBShellfragDraw()
669 {
670         
671         Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
672         if(wasfreed(self))
673                 return;     
674
675         self.move_avelocity += randomvec() * 15;
676         self.renderflags = 0;
677         if(self.cnt < time)
678         self.alpha = bound(0, self.nextthink - time, 1);
679
680         if(self.alpha < ALPHA_MIN_VISIBLE)
681         remove(self);
682 }
683
684 void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang)
685 {
686     entity sfrag;
687     
688     sfrag = spawn();
689     setmodel(sfrag, "models/vehicles/clusterbomb_fragment.md3");
690     setorigin(sfrag, _org);
691
692         sfrag.move_movetype = MOVETYPE_BOUNCE;
693         sfrag.gravity = 0.15;
694         sfrag.solid = SOLID_CORPSE;
695
696         sfrag.draw = RaptorCBShellfragDraw;
697
698         sfrag.move_origin = sfrag.origin = _org;
699         sfrag.move_velocity = _vel;
700         sfrag.move_avelocity = prandomvec() * vlen(sfrag.move_velocity);
701         sfrag.angles = self.move_angles = _ang;
702
703         sfrag.move_time = time;
704         sfrag.damageforcescale = 4;
705
706         sfrag.nextthink = time + 3;
707         sfrag.cnt = time + 2;
708         sfrag.alpha = 1;
709     sfrag.drawmask = MASK_NORMAL;
710 }