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