]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/vehicles/vehicles.qc
Merge remote branch 'origin/samual/waypointsprite_edgeoffset'
[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, CH_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, CH_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, CH_TRIGGER_SINGLE, "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, CH_TRIGGER_SINGLE, "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
312     HUD_DrawCenterPrint();
313
314         if (scoreboard_showscores)
315                 HUD_DrawScoreboard();
316     else
317     {
318         picsize = drawgetimagesize(spider_xhair);
319         picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
320         picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
321
322         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);
323     }
324 }
325
326 #define raptor_ico  "gfx/vehicles/raptor.tga"
327 #define raptor_gun  "gfx/vehicles/raptor_guns.tga"
328 #define raptor_bomb "gfx/vehicles/raptor_bombs.tga"
329 #define raptor_drop "gfx/vehicles/axh-dropcross.tga"
330 #define raptor_xhair "gfx/vehicles/axh-ring.tga"
331 void CSQC_RAPTOR_HUD()
332 {
333         if(autocvar_r_letterbox)
334         return;
335
336     vector picsize, hudloc, pic2size, picloc;
337
338     // Fetch health & ammo stats
339         HUD_GETSTATS
340
341     picsize = drawgetimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
342     hudloc_y = vid_conheight - picsize_y;
343     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
344
345     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
346
347     ammo1   *= 0.01;
348     ammo2   *= 0.01;
349     shield  *= 0.01;
350     vh_health  *= 0.01;
351     energy  *= 0.01;
352     reload1 = reload2 * 0.01;
353     //reload2 *= 0.01;
354
355     pic2size = drawgetimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
356     picloc = picsize * 0.5 - pic2size * 0.5;
357     if(vh_health < 0.25)
358         drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
359     else
360         drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
361     drawpic(hudloc + picloc, raptor_bomb, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
362     drawpic(hudloc + picloc, raptor_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
363     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
364
365 // Health bar
366     picsize = drawgetimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
367     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
368     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
369     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
370     drawresetcliparea();
371 // ..  and icon
372     picsize = drawgetimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
373     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
374     if(vh_health < 0.25)
375     {
376         if(alarm1time < time)
377         {
378             alarm1time = time + 2;
379             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTN_NONE);
380         }
381         
382         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
383     }        
384     else
385     {
386         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
387         if(alarm1time)
388         {
389             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
390             alarm1time = 0;
391         }
392     }
393
394 // Shield bar
395     picsize = drawgetimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
396     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
397     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
398     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
399     drawresetcliparea();
400 // ..  and icon
401     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
402     picsize = drawgetimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
403     if(shield < 0.25)
404     {
405         if(alarm2time < time)
406         {
407             alarm2time = time + 1;
408             sound(world, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTN_NONE);
409         }
410         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
411     }
412     else
413     {
414         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
415         if(alarm2time)
416         {            
417             sound(world, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
418             alarm2time = 0;
419         }
420     }
421     
422 // Gun bar
423     picsize = drawgetimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
424     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
425     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
426     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
427     drawresetcliparea();
428 // ..  and icon
429     picsize = drawgetimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
430     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
431     if(energy < 0.2)
432         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
433     else
434         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
435
436 // Bomb bar
437     picsize = drawgetimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
438     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
439     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
440     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
441     drawresetcliparea();
442 // ..  and icon
443     pic2size = drawgetimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
444     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
445     if(reload1 != 1)
446         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
447     else
448         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
449
450 // Bombing crosshair
451     if(!dropmark)
452     {
453         dropmark = spawn();
454         dropmark.owner = self;
455         dropmark.gravity = 1;
456     }
457
458     if(reload2 == 100)
459     {
460         vector where;
461
462         setorigin(dropmark, pmove_org);
463         dropmark.velocity = pmove_vel;
464         tracetoss(dropmark, self);
465
466         where = project_3d_to_2d(trace_endpos);
467
468         setorigin(dropmark, trace_endpos);
469         picsize = drawgetimagesize(raptor_drop) * 0.2;
470
471         if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
472         {
473             where_x -= picsize_x * 0.5;
474             where_y -= picsize_y * 0.5;
475             where_z = 0;
476             drawpic(where, raptor_drop, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
477         }
478         dropmark.cnt = time + 5;
479     }
480     else
481     {
482         vector where;
483         if(dropmark.cnt > time)
484         {
485             where = project_3d_to_2d(dropmark.origin);
486             picsize = drawgetimagesize(raptor_drop) * 0.25;
487
488             if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
489             {
490                 where_x -= picsize_x * 0.5;
491                 where_y -= picsize_y * 0.5;
492                 where_z = 0;
493                 drawpic(where, raptor_drop, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
494             }
495         }
496     }
497
498     HUD_DrawCenterPrint();
499
500         if (scoreboard_showscores)
501                 HUD_DrawScoreboard();
502     else
503     {
504         picsize = drawgetimagesize(raptor_xhair);
505         picsize_x *= 0.5;
506         picsize_y *= 0.5;
507
508         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);
509     }
510 }
511
512 #define waki_ico "gfx/vehicles/waki.tga"
513 #define waki_eng "gfx/vehicles/waki_e.tga"
514 #define waki_gun "gfx/vehicles/waki_guns.tga"
515 #define waki_rkt "gfx/vehicles/waki_rockets.tga"
516 #define waki_xhair "gfx/vehicles/axh-special1.tga"
517 void CSQC_WAKIZASHI_HUD()
518 {
519 /*
520     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
521     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0'  * (1 - health), 1, DRAWFLAG_NORMAL);
522     drawpic(hudloc, waki_r, picsize, '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
523     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0'  * (1 - energy), 1, DRAWFLAG_NORMAL);
524 */
525         if(autocvar_r_letterbox)
526         return;
527
528     vector picsize, hudloc, pic2size, picloc;
529
530     // Fetch health & ammo stats
531         HUD_GETSTATS
532
533     picsize = drawgetimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
534     hudloc_y = vid_conheight - picsize_y;
535     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
536
537     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
538
539     shield  *= 0.01;
540     vh_health  *= 0.01;
541     energy  *= 0.01;
542     reload1 *= 0.01;
543
544     pic2size = drawgetimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
545     picloc = picsize * 0.5 - pic2size * 0.5;
546     if(vh_health < 0.25)
547         drawpic(hudloc + picloc, waki_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
548     else
549         drawpic(hudloc + picloc, waki_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
550     drawpic(hudloc + picloc, waki_eng, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
551     drawpic(hudloc + picloc, waki_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
552     drawpic(hudloc + picloc, waki_rkt, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
553     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
554
555 // Health bar
556     picsize = drawgetimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
557     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
558     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
559     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
560     drawresetcliparea();
561 // ..  and icon
562     picsize = drawgetimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
563     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
564     if(vh_health < 0.25)
565     {
566         if(alarm1time < time)
567         {
568             alarm1time = time + 2;
569             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTN_NONE);
570         }
571         
572         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
573     }        
574     else
575     {
576         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
577         if(alarm1time)
578         {
579             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
580             alarm1time = 0;
581         }        
582     }
583         
584
585 // Shield bar
586     picsize = drawgetimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
587     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
588     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
589     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
590     drawresetcliparea();
591 // ..  and icon
592     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
593     picsize = drawgetimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
594     if(shield < 0.25)
595     {
596         if(alarm2time < time)
597         {
598             alarm2time = time + 1;
599             sound(world, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTN_NONE);
600         }
601         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
602     }
603     else
604     {
605         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
606         if(alarm2time)
607         {            
608             sound(world, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
609             alarm2time = 0;
610         }
611     }
612     
613 // Gun bar
614     picsize = drawgetimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
615     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
616     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
617     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
618     drawresetcliparea();
619 // ..  and icon
620     picsize = drawgetimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
621     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
622     if(energy < 0.2)
623         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
624     else
625         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
626
627 // Bomb bar
628     picsize = drawgetimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
629     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
630     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
631     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
632     drawresetcliparea();
633 // ..  and icon
634     pic2size = drawgetimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
635     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
636     if(reload1 != 1)
637         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
638     else
639         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
640
641
642     HUD_DrawCenterPrint();
643
644         if (scoreboard_showscores)
645                 HUD_DrawScoreboard();
646     else
647     {
648         picsize = drawgetimagesize(waki_xhair);
649         picsize_x *= 0.5;
650         picsize_y *= 0.5;
651
652
653         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);
654     }
655 }
656
657 void Vehicles_Precache()
658 {
659 // fixme: HAAAAKKKZZZ!!!!!!!!!!!! (this belongs as a setting in default.cfg)
660     autocvar_cl_vehicles_hudscale = 0.5;
661     autocvar_cl_vehicles_hudalpha = 0.75;
662
663
664         precache_model("models/vehicles/wakizashi.dpm");
665
666         precache_model("models/vehicles/bomblet.md3");
667         precache_model("models/vehicles/clusterbomb.md3");
668         precache_model("models/vehicles/clusterbomb_fragment.md3");
669         precache_model("models/vehicles/rocket01.md3");
670         precache_model("models/vehicles/rocket02.md3");
671         
672         precache_sound ("vehicles/alarm.wav");
673         precache_sound ("vehicles/alarm_shield.wav");
674 }
675
676 void RaptorCBShellfragDraw()
677 {
678         
679         Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
680         if(wasfreed(self))
681                 return;     
682
683         self.move_avelocity += randomvec() * 15;
684         self.renderflags = 0;
685         if(self.cnt < time)
686         self.alpha = bound(0, self.nextthink - time, 1);
687
688         if(self.alpha < ALPHA_MIN_VISIBLE)
689         remove(self);
690 }
691
692 void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang)
693 {
694     entity sfrag;
695     
696     sfrag = spawn();
697     setmodel(sfrag, "models/vehicles/clusterbomb_fragment.md3");
698     setorigin(sfrag, _org);
699
700         sfrag.move_movetype = MOVETYPE_BOUNCE;
701         sfrag.gravity = 0.15;
702         sfrag.solid = SOLID_CORPSE;
703
704         sfrag.draw = RaptorCBShellfragDraw;
705
706         sfrag.move_origin = sfrag.origin = _org;
707         sfrag.move_velocity = _vel;
708         sfrag.move_avelocity = prandomvec() * vlen(sfrag.move_velocity);
709         sfrag.angles = self.move_angles = _ang;
710
711         sfrag.move_time = time;
712         sfrag.damageforcescale = 4;
713
714         sfrag.nextthink = time + 3;
715         sfrag.cnt = time + 2;
716         sfrag.alpha = 1;
717     sfrag.drawmask = MASK_NORMAL;
718 }