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