]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/vehicles/vehicles.qc
62ba5304d26e59c7d06a27ae81c268d992ccc434
[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 #define SBRM_FIRST 1
15 #define SBRM_VOLLY 1
16 #define SBRM_GUIDE 2
17 #define SBRM_ARTILLERY 3
18 #define SBRM_LAST 3
19
20 #define RSM_FIRST 1
21 #define RSM_BOMB 1
22 #define RSM_FLARE 2
23 #define RSM_LAST 2
24
25 entity dropmark;
26 float autocvar_cl_vehicles_hudscale;
27 float autocvar_cl_vehicles_hudalpha;
28
29 #define raptor_ico  "gfx/vehicles/raptor.tga"
30 #define raptor_gun  "gfx/vehicles/raptor_guns.tga"
31 #define raptor_bomb "gfx/vehicles/raptor_bombs.tga"
32 #define raptor_drop "gfx/vehicles/axh-dropcross.tga"
33 string raptor_xhair;
34
35 void CSQC_WAKIZASHI_HUD();
36 void CSQC_SPIDER_HUD();
37 void CSQC_RAPTOR_HUD();
38 void CSQC_BUMBLE_HUD();
39
40 #define MAX_AXH 4
41 entity AuxiliaryXhair[MAX_AXH];
42 const var void Draw_Not();
43
44 .string axh_image;
45 .float  axh_fadetime;
46 .float  axh_drawflag;
47 .float  axh_scale;
48
49 #define spider_ico  "gfx/vehicles/sbot.tga"
50 #define spider_rkt  "gfx/vehicles/sbot_rpods.tga"
51 #define spider_mgun "gfx/vehicles/sbot_mguns.tga"
52 string spider_xhair; // = "gfx/vehicles/axh-special1.tga";
53
54 #define waki_ico "gfx/vehicles/waki.tga"
55 #define waki_eng "gfx/vehicles/waki_e.tga"
56 #define waki_gun "gfx/vehicles/waki_guns.tga"
57 #define waki_rkt "gfx/vehicles/waki_rockets.tga"
58 #define waki_xhair "gfx/vehicles/axh-special1.tga"
59
60 float alarm1time;
61 float alarm2time;
62
63 void AuxiliaryXhair_Draw2D()
64 {
65     vector loc, psize;
66
67     psize = self.axh_scale * draw_getimagesize(self.axh_image);
68     loc = project_3d_to_2d(self.origin) - 0.5 * psize;
69     if not (loc_z < 0 || loc_x < 0 || loc_y < 0 || loc_x > vid_conwidth || loc_y > vid_conheight)
70     {
71         loc_z = 0;
72         psize_z = 0;
73         drawpic(loc, self.axh_image, psize, self.colormod, self.alpha, self.axh_drawflag);
74     }
75
76     if(time - self.cnt > self.axh_fadetime)
77         self.draw2d = Draw_Not;
78 }
79
80 void Net_AuXair2(float bIsNew)
81 {
82     float axh_id;
83     entity axh;
84
85     axh_id = bound(0, ReadByte(), MAX_AXH);
86     axh = AuxiliaryXhair[axh_id];
87
88     if(axh == world || wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
89     {
90         axh               = spawn();
91                 axh.draw2d        = Draw_Not;
92                 axh.drawmask      = MASK_NORMAL;
93                 axh.axh_drawflag  = DRAWFLAG_ADDITIVE;
94                 axh.axh_fadetime  = 0.1;
95                 axh.axh_image     = "gfx/vehicles/axh-ring.tga";
96                 axh.axh_scale     = 1;
97         axh.alpha         = 1;
98                 AuxiliaryXhair[axh_id] = axh;
99     }
100
101     axh.draw2d   = AuxiliaryXhair_Draw2D;
102
103         axh.origin_x = ReadCoord();
104         axh.origin_y = ReadCoord();
105         axh.origin_z = ReadCoord();
106
107         axh.colormod_x = ReadByte() / 255;
108         axh.colormod_y = ReadByte() / 255;
109         axh.colormod_z = ReadByte() / 255;
110     axh.cnt = time;
111 }
112
113 float weapon2mode;
114 void Net_VehicleSetup()
115 {
116
117     float hud_id, i;
118     
119     hud_id = ReadByte();
120     
121     // Weapon update?
122     if(hud_id > HUD_VEHICLE_LAST)
123     {
124         weapon2mode = hud_id - HUD_VEHICLE_LAST;
125         return;
126     }
127     
128     // hud_id == 0 means we exited a vehicle, so stop alarm sound/s
129     if(hud_id == 0)
130     {
131         sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
132         sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);    
133             
134         return;
135     }
136     
137     hud_id  = bound(HUD_SPIDERBOT, hud_id, HUD_RAPTOR);
138
139     // Init auxiliary crosshairs
140     entity axh;
141     for(i = 0; i < MAX_AXH; ++i)
142     {
143         axh = AuxiliaryXhair[i];
144         if(axh != world && !wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
145             remove(axh);
146
147         axh               = spawn();
148                 axh.draw2d        = Draw_Not;
149                 axh.drawmask      = MASK_NORMAL;
150                 axh.axh_drawflag  = DRAWFLAG_NORMAL;
151                 axh.axh_fadetime  = 0.1;
152                 axh.axh_image     = "gfx/vehicles/axh-ring.tga";
153                 axh.axh_scale     = 1;
154         axh.alpha         = 1;
155                 AuxiliaryXhair[i] = axh;
156     }
157
158     switch(hud_id)
159     {
160         case HUD_SPIDERBOT:
161             // Minigun1
162             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-ring.tga";
163             AuxiliaryXhair[0].axh_scale   = 0.25;
164             // Minigun2
165             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-ring.tga";
166             AuxiliaryXhair[1].axh_scale   = 0.25;
167             // Rocket
168             AuxiliaryXhair[2].axh_image   = "gfx/vehicles/axh-special1.tga";
169             AuxiliaryXhair[2].axh_scale   = 0.5;
170             break;
171
172         case HUD_WAKIZASHI:
173             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-bracket.tga";
174             AuxiliaryXhair[0].axh_scale   = 0.25;
175             break;
176
177         case HUD_RAPTOR:
178             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-special2.tga";
179             AuxiliaryXhair[0].axh_scale   = 0.5;
180             //AuxiliaryXhair[0].alpha       = 0.5;
181
182             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-bracket.tga";
183             AuxiliaryXhair[1].axh_scale   = 0.25;
184             //AuxiliaryXhair[1].alpha       = 0.75;
185             //AuxiliaryXhair[1].axh_drawflag  = DRAWFLAG_NORMAL;
186             break;
187
188         case HUD_BUMBLEBEE:
189             // Plasma cannons
190             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-ring.tga";
191             AuxiliaryXhair[0].axh_scale   = 0.25;
192             // Raygun
193             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-special1.tga";
194             AuxiliaryXhair[1].axh_scale   = 0.25;
195             break;
196     }
197 }
198 #define HUD_GETSTATS \
199     float vh_health    = getstati(STAT_VEHICLESTAT_HEALTH);  \
200         float shield    = getstati(STAT_VEHICLESTAT_SHIELD);  \
201         float energy    = getstati(STAT_VEHICLESTAT_ENERGY);  \
202         float ammo1     = getstati(STAT_VEHICLESTAT_AMMO1);   \
203         float reload1   = getstati(STAT_VEHICLESTAT_RELOAD1); \
204         float ammo2     = getstati(STAT_VEHICLESTAT_AMMO2);   \
205         float reload2   = getstati(STAT_VEHICLESTAT_RELOAD2);
206
207 void CSQC_BUMBLE_HUD()
208 {
209 /*
210     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
211     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0'  * (1 - health), 1, DRAWFLAG_NORMAL);
212     drawpic(hudloc, waki_r, picsize, '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
213     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0'  * (1 - energy), 1, DRAWFLAG_NORMAL);
214 */
215         if(autocvar_r_letterbox)
216         return;
217
218     vector picsize, hudloc, pic2size, picloc;
219
220     // Fetch health & ammo stats
221         HUD_GETSTATS
222
223     picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
224     hudloc_y = vid_conheight - picsize_y;
225     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
226
227     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
228
229     shield  *= 0.01;
230     vh_health  *= 0.01;
231     energy  *= 0.01;
232     reload1 *= 0.01;
233
234     pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
235     picloc = picsize * 0.5 - pic2size * 0.5;
236     if(vh_health < 0.25)
237         drawpic(hudloc + picloc, waki_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
238     else
239         drawpic(hudloc + picloc, waki_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
240     drawpic(hudloc + picloc, waki_eng, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
241     drawpic(hudloc + picloc, waki_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
242     drawpic(hudloc + picloc, waki_rkt, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
243     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
244
245 // Health bar
246     picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
247     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
248     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
249     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
250     drawresetcliparea();
251 // ..  and icon
252     picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
253     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
254     if(vh_health < 0.25)
255     {
256         if(alarm1time < time)
257         {
258             alarm1time = time + 2;
259             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTN_NONE);
260         }
261         
262         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
263     }        
264     else
265     {
266         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
267         if(alarm1time)
268         {
269             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
270             alarm1time = 0;
271         }        
272     }
273         
274
275 // Shield bar
276     picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
277     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
278     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
279     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
280     drawresetcliparea();
281 // ..  and icon
282     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
283     picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
284     if(shield < 0.25)
285     {
286         if(alarm2time < time)
287         {
288             alarm2time = time + 1;
289             sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTN_NONE);
290         }
291         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
292     }
293     else
294     {
295         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
296         if(alarm2time)
297         {            
298             sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
299             alarm2time = 0;
300         }
301     }
302     
303 // Gun bar
304     picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
305     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
306     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
307     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
308     drawresetcliparea();
309 // ..  and icon
310     picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
311     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
312     if(energy < 0.2)
313         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
314     else
315         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
316
317 // Bomb bar
318     picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
319     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
320     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
321     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
322     drawresetcliparea();
323 // ..  and icon
324     pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
325     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
326     if(reload1 != 1)
327         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
328     else
329         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
330
331         if (scoreboard_showscores)
332                 HUD_DrawScoreboard();
333     else
334     {
335         picsize = draw_getimagesize(waki_xhair);
336         picsize_x *= 0.5;
337         picsize_y *= 0.5;
338
339
340         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);
341     }
342 }
343
344
345
346
347 void CSQC_SPIDER_HUD()
348 {
349         if(autocvar_r_letterbox)
350         return;
351
352     vector picsize, hudloc, pic2size, picloc;
353     float i;
354
355     // Fetch health & ammo stats
356         HUD_GETSTATS
357
358     picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
359     hudloc_y = vid_conheight - picsize_y;
360     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
361
362     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
363
364     ammo1   *= 0.01;
365     shield  *= 0.01;
366     vh_health  *= 0.01;
367     reload2 *= 0.01;
368
369     pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
370     picloc = picsize * 0.5 - pic2size * 0.5;
371     if(vh_health < 0.25)
372         drawpic(hudloc + picloc, spider_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
373     else
374         drawpic(hudloc + picloc, spider_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);    
375     drawpic(hudloc + picloc, spider_rkt, pic2size,  '1 1 1' * reload2 + '1 0 0' * (1 - reload2), 1, DRAWFLAG_NORMAL);
376     drawpic(hudloc + picloc, spider_mgun, pic2size, '1 1 1' * ammo1   + '1 0 0' * (1 - ammo1),   1, DRAWFLAG_NORMAL);
377     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
378
379 // Health bar
380     picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
381     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
382     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
383     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
384     drawresetcliparea();
385 // ..  and icon
386     picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
387     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
388     if(vh_health < 0.25)
389     {
390         if(alarm1time < time)
391         {
392             alarm1time = time + 2;
393             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTN_NONE);
394         }        
395         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
396     }        
397     else
398     {
399         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
400         if(alarm1time)
401         {
402             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
403             alarm1time = 0;
404         }        
405     }
406 // Shield bar
407     picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
408     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
409     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
410     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
411     drawresetcliparea();
412 // ..  and icon
413     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
414     picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
415     if(shield < 0.25)
416     {
417         if(alarm2time < time)
418         {
419             alarm2time = time + 1;
420             sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTN_NONE);
421         }
422         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
423     }
424     else
425     {
426         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
427         if(alarm2time)
428         {            
429             sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
430             alarm2time = 0;
431         }
432     }
433
434 // Minigun bar
435     picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
436     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
437     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * ammo1, vid_conheight);
438     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
439     drawresetcliparea();
440 // ..  and icon
441     picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
442     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
443     if(ammo1 < 0.2)
444         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
445     else
446         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
447
448 // Rocket ammo bar
449     picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
450     ammo1 = picsize_x / 8;
451     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
452     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload2, vid_conheight);
453     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
454     drawresetcliparea();
455
456 // ..  and icons
457     pic2size = 0.35 * draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
458     picloc_x -= pic2size_x;
459     picloc_y += pic2size_y * 2.25;
460     if(ammo2 == 9)
461     {
462         for(i = 1; i < 9; ++i)
463         {
464             picloc_x += ammo1;
465             drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((8 * reload2 <= i) ? '0 0 0' : '1 1 1'), 0.75, DRAWFLAG_NORMAL);
466         }
467     }
468     else
469     {
470         for(i = 1; i < 9; ++i)
471         {
472             picloc_x += ammo1;
473             drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((i >= ammo2) ? '1 1 1' : '0 0 0'), 0.75, DRAWFLAG_NORMAL);
474         }
475     }
476     pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
477     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
478     if(ammo2 == 9)
479         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
480     else
481         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
482
483         if (scoreboard_showscores)
484                 HUD_DrawScoreboard();
485     else
486     {
487         switch(weapon2mode)
488         {
489             case SBRM_VOLLY:
490                 spider_xhair = "gfx/vehicles/axh-bracket.tga";
491                 break;
492             case SBRM_GUIDE:
493                 spider_xhair = "gfx/vehicles/axh-cross.tga";
494                 break;
495             case SBRM_ARTILLERY:
496                 spider_xhair = "gfx/vehicles/axh-tag.tga";
497                 break;
498             default:
499                 spider_xhair= "gfx/vehicles/axh-tag.tga";
500         }
501
502         picsize = draw_getimagesize(spider_xhair);
503         picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
504         picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
505
506         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);
507     }
508 }
509
510 void CSQC_RAPTOR_HUD()
511 {
512         if(autocvar_r_letterbox)
513         return;
514
515     vector picsize, hudloc, pic2size, picloc;
516
517     // Fetch health & ammo stats
518         HUD_GETSTATS
519
520     picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
521     hudloc_y = vid_conheight - picsize_y;
522     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
523
524     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
525
526     ammo1   *= 0.01;
527     ammo2   *= 0.01;
528     shield  *= 0.01;
529     vh_health  *= 0.01;
530     energy  *= 0.01;
531     reload1 = reload2 * 0.01;
532     //reload2 *= 0.01;
533
534     pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
535     picloc = picsize * 0.5 - pic2size * 0.5;
536     if(vh_health < 0.25)
537         drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
538     else
539         drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
540     drawpic(hudloc + picloc, raptor_bomb, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
541     drawpic(hudloc + picloc, raptor_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
542     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
543
544 // Health bar
545     picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
546     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
547     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
548     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
549     drawresetcliparea();
550 // ..  and icon
551     picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
552     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
553     if(vh_health < 0.25)
554     {
555         if(alarm1time < time)
556         {
557             alarm1time = time + 2;
558             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTN_NONE);
559         }
560         
561         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
562     }        
563     else
564     {
565         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
566         if(alarm1time)
567         {
568             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
569             alarm1time = 0;
570         }
571     }
572
573 // Shield bar
574     picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
575     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
576     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
577     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
578     drawresetcliparea();
579 // ..  and icon
580     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
581     picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
582     if(shield < 0.25)
583     {
584         if(alarm2time < time)
585         {
586             alarm2time = time + 1;
587             sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTN_NONE);
588         }
589         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
590     }
591     else
592     {
593         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
594         if(alarm2time)
595         {            
596             sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
597             alarm2time = 0;
598         }
599     }
600     
601 // Gun bar
602     picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
603     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
604     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
605     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
606     drawresetcliparea();
607 // ..  and icon
608     picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
609     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
610     if(energy < 0.2)
611         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
612     else
613         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
614
615 // Bomb bar
616     picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
617     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
618     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
619     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
620     drawresetcliparea();
621 // ..  and icon
622     pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
623     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
624     if(reload1 != 1)
625         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
626     else
627         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
628     
629     if(weapon2mode == RSM_FLARE)
630     {
631         raptor_xhair =  "gfx/vehicles/axh-bracket.tga";
632     }
633     else
634     {
635         raptor_xhair =  "gfx/vehicles/axh-ring.tga";
636         
637         // Bombing crosshair
638         if(!dropmark)
639         {
640             dropmark = spawn();
641             dropmark.owner = self;
642             dropmark.gravity = 1;
643         }
644
645         if(reload2 == 100)
646         {
647             vector where;
648
649             setorigin(dropmark, pmove_org);
650             dropmark.velocity = pmove_vel;
651             tracetoss(dropmark, self);
652
653             where = project_3d_to_2d(trace_endpos);
654
655             setorigin(dropmark, trace_endpos);
656             picsize = draw_getimagesize(raptor_drop) * 0.2;
657
658             if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
659             {
660                 where_x -= picsize_x * 0.5;
661                 where_y -= picsize_y * 0.5;
662                 where_z = 0;
663                 drawpic(where, raptor_drop, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
664             }
665             dropmark.cnt = time + 5;
666         }
667         else
668         {
669             vector where;
670             if(dropmark.cnt > time)
671             {
672                 where = project_3d_to_2d(dropmark.origin);
673                 picsize = draw_getimagesize(raptor_drop) * 0.25;
674
675                 if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
676                 {
677                     where_x -= picsize_x * 0.5;
678                     where_y -= picsize_y * 0.5;
679                     where_z = 0;
680                     drawpic(where, raptor_drop, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
681                 }
682             }
683         }
684     }
685     
686         if (scoreboard_showscores)
687                 HUD_DrawScoreboard();
688     else
689     {
690         picsize = draw_getimagesize(raptor_xhair);
691         picsize_x *= 0.5;
692         picsize_y *= 0.5;
693
694         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);
695     }
696 }
697
698 void CSQC_WAKIZASHI_HUD()
699 {
700 /*
701     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
702     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0'  * (1 - health), 1, DRAWFLAG_NORMAL);
703     drawpic(hudloc, waki_r, picsize, '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
704     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0'  * (1 - energy), 1, DRAWFLAG_NORMAL);
705 */
706         if(autocvar_r_letterbox)
707         return;
708
709     vector picsize, hudloc, pic2size, picloc;
710
711     // Fetch health & ammo stats
712         HUD_GETSTATS
713
714     picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
715     hudloc_y = vid_conheight - picsize_y;
716     hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
717
718     drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
719
720     shield  *= 0.01;
721     vh_health  *= 0.01;
722     energy  *= 0.01;
723     reload1 *= 0.01;
724
725     pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
726     picloc = picsize * 0.5 - pic2size * 0.5;
727     if(vh_health < 0.25)
728         drawpic(hudloc + picloc, waki_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
729     else
730         drawpic(hudloc + picloc, waki_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
731     drawpic(hudloc + picloc, waki_eng, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
732     drawpic(hudloc + picloc, waki_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
733     drawpic(hudloc + picloc, waki_rkt, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
734     drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
735
736 // Health bar
737     picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
738     picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
739     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
740     drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
741     drawresetcliparea();
742 // ..  and icon
743     picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
744     picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
745     if(vh_health < 0.25)
746     {
747         if(alarm1time < time)
748         {
749             alarm1time = time + 2;
750             sound(self, CH_PAIN_SINGLE, "vehicles/alarm.wav", VOL_BASEVOICE, ATTN_NONE);
751         }
752         
753         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
754     }        
755     else
756     {
757         drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
758         if(alarm1time)
759         {
760             sound(self, CH_PAIN_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
761             alarm1time = 0;
762         }        
763     }
764         
765
766 // Shield bar
767     picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
768     picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
769     drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
770     drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
771     drawresetcliparea();
772 // ..  and icon
773     picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
774     picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
775     if(shield < 0.25)
776     {
777         if(alarm2time < time)
778         {
779             alarm2time = time + 1;
780             sound(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav", VOL_BASEVOICE, ATTN_NONE);
781         }
782         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
783     }
784     else
785     {
786         drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
787         if(alarm2time)
788         {            
789             sound(self, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_BASEVOICE, ATTN_NONE);
790             alarm2time = 0;
791         }
792     }
793     
794 // Gun bar
795     picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
796     picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
797     drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
798     drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
799     drawresetcliparea();
800 // ..  and icon
801     picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
802     picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
803     if(energy < 0.2)
804         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
805     else
806         drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
807
808 // Bomb bar
809     picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
810     picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
811     drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
812     drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
813     drawresetcliparea();
814 // ..  and icon
815     pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
816     picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
817     if(reload1 != 1)
818         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
819     else
820         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
821
822         if (scoreboard_showscores)
823                 HUD_DrawScoreboard();
824     else
825     {
826         picsize = draw_getimagesize(waki_xhair);
827         picsize_x *= 0.5;
828         picsize_y *= 0.5;
829
830
831         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);
832     }
833 }
834
835 void Vehicles_Precache()
836 {
837 // fixme: HAAAAKKKZZZ!!!!!!!!!!!! (this belongs as a setting in default.cfg)
838     if(!autocvar_cl_vehicles_hudscale )
839         autocvar_cl_vehicles_hudscale = 0.5;
840     
841     if(!autocvar_cl_vehicles_hudalpha)
842         autocvar_cl_vehicles_hudalpha = 0.75;
843
844         //precache_model("models/vehicles/wakizashi.dpm");
845
846         precache_model("models/vehicles/bomblet.md3");
847         precache_model("models/vehicles/clusterbomb.md3");
848         precache_model("models/vehicles/clusterbomb_fragment.md3");
849         precache_model("models/vehicles/rocket01.md3");
850         precache_model("models/vehicles/rocket02.md3");
851         
852         precache_sound ("vehicles/alarm.wav");
853         precache_sound ("vehicles/alarm_shield.wav");
854 }
855
856 void RaptorCBShellfragDraw()
857 {
858         
859         Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
860         if(wasfreed(self))
861                 return;     
862
863         self.move_avelocity += randomvec() * 15;
864         self.renderflags = 0;
865         if(self.cnt < time)
866         self.alpha = bound(0, self.nextthink - time, 1);
867
868         if(self.alpha < ALPHA_MIN_VISIBLE)
869         remove(self);
870 }
871
872 void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang)
873 {
874     entity sfrag;
875     
876     sfrag = spawn();
877     setmodel(sfrag, "models/vehicles/clusterbomb_fragment.md3");
878     setorigin(sfrag, _org);
879
880         sfrag.move_movetype = MOVETYPE_BOUNCE;
881         sfrag.gravity = 0.15;
882         sfrag.solid = SOLID_CORPSE;
883
884         sfrag.draw = RaptorCBShellfragDraw;
885
886         sfrag.move_origin = sfrag.origin = _org;
887         sfrag.move_velocity = _vel;
888         sfrag.move_avelocity = prandomvec() * vlen(sfrag.move_velocity);
889         sfrag.angles = self.move_angles = _ang;
890
891         sfrag.move_time = time;
892         sfrag.damageforcescale = 4;
893
894         sfrag.nextthink = time + 3;
895         sfrag.cnt = time + 2;
896         sfrag.alpha = 1;
897     sfrag.drawmask = MASK_NORMAL;
898 }