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