]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/vehicles/vehicles.qc
Use pmove_vel & _org fro raptor bombing crosshair insted of buggy hakk, should be...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / vehicles / vehicles.qc
1 #define spider_rocket_icon "gfx/vehicles/rocket_ico.tga"
2 #define spider_rocket_targ "gfx/vehicles/target.tga"
3 //#define SPIDER_CROSS "textures/spiderbot/cross.tga"
4 #define SPIDER_CROSS "gfx/vehicles/sbot-xhair.tga"
5 #define SPIDER_CROSS2 "gfx/vehicles/sbot-xhair2.tga"
6
7 #define axh1 "gfx/vehicles/sbot-xhair2.tga"
8 #define axh2 "gfx/vehicles/sbot-xhair2.tga"
9 #define axh3 "gfx/vehicles/sbot-xhair2.tga"
10
11 #define spider_h "gfx/vehicles/hud_bg.tga"
12 #define spider_b "gfx/vehicles/sbot.tga"
13 #define spider_r "gfx/vehicles/sbot_rpods.tga"
14 #define spider_g "gfx/vehicles/sbot_mguns.tga"
15 #define spider_s "gfx/vehicles/shiled.tga"
16 #define spider_a1 "gfx/vehicles/sb_rocket.tga"
17 #define spider_a2 "gfx/vehicles/sb_bullets.tga"
18
19 #define raptor_h  "gfx/vehicles/hud_bg.tga"
20 #define raptor_s  "gfx/vehicles/shiled.tga"
21
22 #define raptor_b  "gfx/vehicles/raptor.tga"
23 #define raptor_g1 "gfx/vehicles/raptor_guns.tga"
24 #define raptor_g2 "gfx/vehicles/raptor_bombs.tga"
25 #define raptor_d  "gfx/vehicles/dropcross.tga"
26 #define raptor_c  "gfx/vehicles/raptor_cross.tga"
27
28 entity dropmark;
29
30 void CSQC_WAKIZASHI_HUD();
31 void CSQC_SPIDER_HUD();
32 void CSQC_RAPTOR_HUD();
33
34 #define MAX_AXH 4
35 entity AuxiliaryXhair[MAX_AXH];
36 const var void Draw_Not();
37
38 .string axh_image;
39 .float  axh_fadetime;
40 .float  axh_drawflag;
41 .float  axh_scale;
42
43 void AuxiliaryXhair_Draw2D()
44 {
45     vector loc, psize;
46
47     psize = self.axh_scale * drawgetimagesize(self.axh_image);
48     loc = project_3d_to_2d(self.origin) - 0.5 * psize;
49     if not (loc_z < 0 || loc_x < 0 || loc_y < 0 || loc_x > vid_conwidth || loc_y > vid_conheight)
50     {
51         loc_z = 0;
52         psize_z = 0;
53         drawpic(loc, self.axh_image, psize, self.colormod, self.alpha, self.axh_drawflag);
54     }
55
56     if(time - self.cnt > self.axh_fadetime)
57         self.draw2d = Draw_Not;
58 }
59
60
61 void Net_AuXair()
62 {
63     float axh_id;
64     entity axh;
65
66     axh_id = bound(0, ReadByte(), MAX_AXH);
67     axh = AuxiliaryXhair[axh_id];
68
69     if(axh == world || wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
70     {
71         axh               = spawn();
72                 axh.draw2d        = Draw_Not;
73                 axh.drawmask      = MASK_NORMAL;
74                 axh.axh_drawflag  = DRAWFLAG_ADDITIVE;
75                 axh.axh_fadetime  = 0.1;
76                 axh.axh_image     = "gfx/vehicles/axh-ring.tga";
77                 axh.axh_scale     = 1;
78         axh.alpha         = 1;
79                 AuxiliaryXhair[axh_id] = axh;
80     }
81
82     axh.draw2d   = AuxiliaryXhair_Draw2D;
83
84         axh.origin_x = ReadCoord();
85         axh.origin_y = ReadCoord();
86         axh.origin_z = ReadCoord();
87
88         axh.colormod_x = ReadByte() / 255;
89         axh.colormod_y = ReadByte() / 255;
90         axh.colormod_z = ReadByte() / 255;
91     axh.cnt = time;
92 }
93 void Net_AuXair2(float blah)
94 {
95     Net_AuXair();
96 }
97 void Net_VehicleSetup()
98 {
99
100     float hud_id, i;
101     hud_id = bound(HUD_SPIDERBOT, ReadByte(), HUD_RAPTOR);
102
103     // Init auxiliary crosshairs
104 //#if 1
105     entity axh;
106     for(i = 0; i < MAX_AXH; ++i)
107     {
108         axh = AuxiliaryXhair[i];
109         if(axh != world && !wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
110             remove(axh);
111
112         axh               = spawn();
113                 axh.draw2d        = Draw_Not;
114                 axh.drawmask      = MASK_NORMAL;
115                 axh.axh_drawflag  = DRAWFLAG_ADDITIVE;
116                 axh.axh_fadetime  = 0.1;
117                 axh.axh_image     = "gfx/vehicles/axh-ring.tga";
118                 axh.axh_scale     = 1;
119         axh.alpha         = 1;
120                 AuxiliaryXhair[i] = axh;
121     }
122 /*
123 #else
124     for(i = 0; i < MAX_AXH; ++i)
125     {
126         if(AuxiliaryXhair[i] != world && !wasfreed(AuxiliaryXhair[i]))
127             remove(AuxiliaryXhair[i]);
128
129         AuxiliaryXhair[i]               = spawn();
130                 AuxiliaryXhair[i].draw2d        = Draw_Not;
131                 AuxiliaryXhair[i].drawmask      = MASK_NORMAL;
132                 AuxiliaryXhair[i].axh_drawflag  = DRAWFLAG_ADDITIVE;
133                 AuxiliaryXhair[i].axh_fadetime  = 0.1;
134                 AuxiliaryXhair[i].axh_image     = "gfx/vehicles/axh-ring.tga";
135                 AuxiliaryXhair[i].axh_scale     = 1;
136                 AuxiliaryXhair[i].alpha         = 1;
137     }
138 #endif
139 */
140     switch(hud_id)
141     {
142         case HUD_SPIDERBOT:
143             // Minigun1
144             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-ring.tga";
145             AuxiliaryXhair[0].axh_scale   = 0.25;
146             // Minigun2
147             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-ring.tga";
148             AuxiliaryXhair[1].axh_scale   = 0.25;
149             // Rocket
150             AuxiliaryXhair[2].axh_image   = "gfx/vehicles/axh-special1.tga";
151             AuxiliaryXhair[2].axh_scale   = 0.5;
152             break;
153         case HUD_WAKIZASHI:
154             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-bracket.tga";
155             AuxiliaryXhair[0].axh_scale   = 0.5;
156             break;
157         case HUD_RAPTOR:
158             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-cross.tga";
159             AuxiliaryXhair[0].axh_scale   = 0.5;
160             AuxiliaryXhair[1].alpha       = 0.25;
161             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-ring.tga";
162             AuxiliaryXhair[1].axh_scale   = 0.5;
163             AuxiliaryXhair[1].alpha       = 0.5;
164             break;
165     }
166 }
167
168 void Vehicles_Precache()
169 {
170         //precache_model("models/ax_shell.mdl");
171         //precache_sound("weapons/brass1.wav");
172 }
173
174
175 void CSQC_SPIDER_HUD()
176 {
177         float rockets, reload, heat, hp, shield;
178         vector picsize, hudloc;
179
180     // Fetch health & ammo stats
181     hp      = bound(0,getstatf(STAT_VEHICLESTAT_HEALTH), 1);
182         shield  = bound(0,getstatf(STAT_VEHICLESTAT_SHIELD), 1);
183         heat    = min(getstatf(STAT_VEHICLESTAT_RELOAD1), 2);
184         rockets =     getstati(STAT_VEHICLESTAT_AMMO2);
185         reload  = min(getstatf(STAT_VEHICLESTAT_RELOAD2), 1);
186
187
188     hudloc_y = 4;
189     hudloc_x = 4;
190     drawfill('130 28 0', ('115 0 0' * hp) + '0 10 0', hp * '0 1 0' + (1 - hp) * '1 0 0', 0.5, DRAWFLAG_NORMAL);
191     picsize = drawgetimagesize(spider_h) * 0.5;
192     drawpic(hudloc, spider_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
193
194     picsize = drawgetimagesize(spider_a2) * 0.5;
195     drawpic(hudloc + '120 96  0', spider_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
196
197     drawstring(hudloc + '145 19  0', strcat(ftos(rint(hp * 100)), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
198     drawstring(hudloc + '175 34  0', strcat(ftos(rint(shield * 100)), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
199     drawstring(hudloc + '136 102  0', strcat(ftos(100 - rint(heat * 100)), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
200
201     picsize = drawgetimagesize(spider_a1) * 0.85;
202     if(rockets == 9)
203     {
204         drawpic(hudloc + '132 54  0', spider_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
205         drawstring(hudloc + '179 69 0', strcat(ftos(rint(reload * 100)), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
206     }
207     else
208     {
209         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
210         drawstring(hudloc + '179 69  0', strcat(ftos(9 - rockets), "/8"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
211     }
212
213     picsize = drawgetimagesize(spider_b) * 0.5;
214     hudloc_y = 10.5;
215     hudloc_x = 10.5;
216
217     drawpic(hudloc, spider_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
218     drawpic(hudloc, spider_b, picsize, '0 1 0' * hp + '1 0 0' * (1 - hp), 1, DRAWFLAG_NORMAL);
219     drawpic(hudloc, spider_r, picsize, '1 1 1' * reload + '1 0 0' * (1 - reload), 1, DRAWFLAG_NORMAL);
220     drawpic(hudloc, spider_g, picsize, '1 1 1' * (1 - heat) + '1 0 0' *  heat, 1, DRAWFLAG_NORMAL);
221
222
223         if (scoreboard_showscores)
224         {
225                 HUD_DrawScoreboard();
226                 HUD_DrawCenterPrint();
227     }
228     else
229     {
230         picsize = drawgetimagesize(SPIDER_CROSS);
231         picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
232         picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
233
234         drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), SPIDER_CROSS, picsize, '1 1 1', autocvar_cl_vehicle_spiderbot_cross_alpha, DRAWFLAG_ADDITIVE);
235     }
236 }
237
238
239 void CSQC_RAPTOR_HUD()
240 {
241         if(autocvar_r_letterbox)
242         return;
243
244         float reload, hp, shield, energy;
245         vector picsize, hudloc, vel;
246         float movedt;
247     vector where;
248
249
250     if(!dropmark)
251     {
252         dropmark = spawn();
253         dropmark.owner = self;
254     }
255
256     // Fetch health & ammo stats
257     hp      = bound(0,getstatf(STAT_VEHICLESTAT_HEALTH), 1);
258         shield  = bound(0,getstatf(STAT_VEHICLESTAT_SHIELD), 1);
259         reload  = min(getstatf(STAT_VEHICLESTAT_RELOAD1), 1);
260         energy  = min(getstatf(STAT_VEHICLESTAT_ENERGY),  1);
261
262     // Draw the crosshairs
263     picsize = drawgetimagesize("gfx/vehicles/axh-cross.tga");
264     picsize_x *= 0.75;
265     picsize_y *= 0.75;
266     drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), "gfx/vehicles/axh-cross.tga", picsize, '1 0 0' + '0 1 1' * energy, 0.5, DRAWFLAG_ADDITIVE);
267
268     hudloc_y = 4;
269     hudloc_x = 4;
270
271     picsize = drawgetimagesize(raptor_h) * 0.5;
272     drawpic(hudloc, raptor_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
273
274     picsize = drawgetimagesize(spider_a2) * 0.5;
275     drawpic(hudloc + '120 96  0', spider_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
276
277     drawstring(hudloc + '145 19  0', strcat(ftos(rint(hp * 100)), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
278     drawstring(hudloc + '175 34  0', strcat(ftos(rint(shield * 100)), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
279     drawstring(hudloc + '136 102 0', strcat(ftos(rint(energy * 100)), "%"),'15 15 0','0.5 0.5 1', 1, DRAWFLAG_NORMAL);
280
281
282     picsize = drawgetimagesize(spider_a1) * 0.85;
283     if(reload == 1)
284     {
285         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
286         drawstring(hudloc + '179 69  0', strcat(ftos(rint(reload * 100)), "%"),'14 14 0','0 1 0', 0.5, DRAWFLAG_NORMAL);
287     }
288     else
289     {
290         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
291         drawstring(hudloc + '179 69  0', strcat(ftos(rint(reload * 100)), "%"),'14 14 0','0 0 1', 1, DRAWFLAG_NORMAL);
292     }
293
294     picsize = drawgetimagesize(raptor_b) * 0.5;
295     hudloc_y = 10.5;
296     hudloc_x = 10.5;
297
298     drawpic(hudloc, raptor_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
299     drawpic(hudloc, raptor_b, picsize, '0 1 0' * hp + '1 0 0' * (1 - hp), 1, DRAWFLAG_NORMAL);
300     drawpic(hudloc, raptor_g1, picsize, '1 1 1' * energy + '1 0 0' * (1 - energy), 1, DRAWFLAG_NORMAL);
301     drawpic(hudloc, raptor_g2, picsize, '1 1 1' * reload + '1 0 0' *  (1 - reload), 1, DRAWFLAG_NORMAL);
302
303     if(reload == 1)
304     {
305         where = dropmark.origin;
306         setorigin(dropmark, pmove_org);
307         dropmark.velocity = pmove_vel;
308         tracetoss(dropmark, self);
309
310         where = project_3d_to_2d(trace_endpos);
311
312         setorigin(dropmark, trace_endpos);
313         picsize = drawgetimagesize(raptor_d) * 0.2;
314
315         if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
316         {
317             where_x -= picsize_x * 0.5;
318             where_y -= picsize_y * 0.5;
319             where_z = 0;
320             drawpic(where, raptor_d, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
321         }
322         dropmark.cnt = time + 5;
323     }
324     else
325     {
326         if(dropmark.cnt > time)
327         {
328             where = project_3d_to_2d(dropmark.origin);
329             picsize = drawgetimagesize(raptor_d) * 0.25;
330
331             if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
332             {
333                 where_x -= picsize_x * 0.5;
334                 where_y -= picsize_y * 0.5;
335                 where_z = 0;
336                 drawpic(where, raptor_d, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
337             }
338         }
339     }
340
341         if (scoreboard_showscores)
342         {
343                 HUD_DrawScoreboard();
344                 HUD_DrawCenterPrint();
345         }
346
347 }
348
349 #define waki_h "gfx/vehicles/hud_bg.tga"
350 #define waki_b "gfx/vehicles/waki.tga"
351 #define waki_e "gfx/vehicles/waki_e.tga"
352 #define waki_g "gfx/vehicles/waki_guns.tga"
353 #define waki_r "gfx/vehicles/waki_rockets.tga"
354 #define waki_s "gfx/vehicles/shiled.tga"
355
356 #define waki_a1 "gfx/vehicles/sb_rocket.tga"
357 #define waki_a2 "gfx/vehicles/sb_cells.tga"
358
359 void CSQC_WAKIZASHI_HUD()
360 {
361         // 0--1 floats. 1 = 100%, 0.6 = 50%.
362         float health, shield, energy, rockets;
363         vector picsize, hudloc;
364
365     picsize = drawgetimagesize(SPIDER_CROSS);
366     picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
367     picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
368     drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), SPIDER_CROSS, picsize, '1 1 1', autocvar_cl_vehicle_spiderbot_cross_alpha, DRAWFLAG_NORMAL);
369
370 /*
371 const float STAT_VEHICLESTAT_HEALTH  = 60;
372 const float STAT_VEHICLESTAT_SHIELD  = 61;
373 const float STAT_VEHICLESTAT_ENERGY  = 62;
374 const float STAT_VEHICLESTAT_AMMO1   = 63;
375 const float STAT_VEHICLESTAT_RELAOD1 = 64;
376 const float STAT_VEHICLESTAT_AMMO2   = 65;
377 const float STAT_VEHICLESTAT_RELOAD2 = 66;
378 */
379     health  = min(getstatf(STAT_VEHICLESTAT_HEALTH),  1);
380         shield  = min(getstatf(STAT_VEHICLESTAT_SHIELD),  1);
381         energy  = min(getstatf(STAT_VEHICLESTAT_ENERGY),  1);
382         rockets = bound(0,getstatf(STAT_VEHICLESTAT_RELOAD1), 1);
383
384     hudloc_y =  4;
385     hudloc_x = 4;
386
387     picsize = drawgetimagesize(waki_h) * 0.5;
388     drawpic(hudloc, waki_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
389
390     picsize = drawgetimagesize(waki_a2) * 0.7;
391     drawpic(hudloc + '116 92  0', waki_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
392
393
394     drawstring(hudloc + '145 19  0', strcat(ftos(rint(health * 100)), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
395     drawstring(hudloc + '175 34  0', strcat(ftos(rint(shield * 100)), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
396
397     drawstring(hudloc + '136 102  0', strcat(ftos(rint(energy * 100)), "%"),'14 14 0','1 1 1', 1, DRAWFLAG_NORMAL);
398
399     picsize = drawgetimagesize(waki_a1) * 0.75;
400     if(rockets == 1)
401     {
402         drawpic(hudloc + '140 55  0', waki_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
403         drawpic(hudloc + '144 59  0', waki_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
404     }
405     else
406     {
407         drawpic(hudloc + '140 55  0', waki_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
408         drawpic(hudloc + '144 59  0', waki_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
409         drawstring(hudloc + '165 69 0', strcat(ftos(rint(rockets * 100)), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
410     }
411
412     picsize = drawgetimagesize(waki_b) * 0.5;
413     hudloc_y = 10.5;
414     hudloc_x = 10.5;
415
416     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
417     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0' * (1 - health), 1, DRAWFLAG_NORMAL);
418     drawpic(hudloc, waki_r, picsize, '1 1 1' * rockets + '1 0 0' * (1 - rockets), 1, DRAWFLAG_NORMAL);
419     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0' *  (1 - energy), 1, DRAWFLAG_NORMAL);
420
421
422
423         /*
424         p = '0.5 0 0' * (vid_conwidth - (rkt_size * 8));
425         p = p + '0 1 0' * vid_conheight - '0 32 0';
426
427         // Draw health bar
428         p_y += 8;
429         drawfill(p, '256 0 0' * health + '0 8 0' , '0 0.7 0', 0.75, DRAWFLAG_NORMAL);
430         p_x += 256 * health;
431         drawfill(p, '256 0 0' * (1 - health) + '0 8 0' , '0 0 0', 0.75, DRAWFLAG_NORMAL);
432
433         // Draw shiled bar
434         p_x -= 256 * health;
435         p_y += 4;
436         drawfill(p, '256 0 0' * shield + '0 4 0' , '0.25 0.25 1', 0.5, DRAWFLAG_NORMAL);
437
438         // Draw energy
439         //p_x -= 256 * health;
440         p_y -= 8;
441         drawfill(p, '256 0 0' * energy + '0 4 0' , '1 1 1', 0.75, DRAWFLAG_NORMAL);
442
443         // Draw rockets bar
444         p_y += 12;
445         drawfill(p, '256 0 0' * rockets + '0 4 0' , '1 0 0', 0.75, DRAWFLAG_NORMAL);
446         */
447
448
449
450
451         if (scoreboard_showscores)
452         {
453                 HUD_DrawScoreboard();
454                 HUD_DrawCenterPrint();
455         }
456
457 }