]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/vehicles/vehicles.qc
Sync with master
[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.25;
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[0].alpha       = 0.25;
161
162             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-bracket.tga";
163             AuxiliaryXhair[1].axh_scale   = 0.25;
164             AuxiliaryXhair[1].alpha       = 0.75;
165             AuxiliaryXhair[1].axh_drawflag  = DRAWFLAG_NORMAL;
166
167             break;
168     }
169 }
170
171 void Vehicles_Precache()
172 {
173         //precache_model("models/ax_shell.mdl");
174         //precache_sound("weapons/brass1.wav");
175 }
176
177
178 void CSQC_SPIDER_HUD()
179 {
180         float rockets, reload, heat, hp, shield;
181         vector picsize, hudloc;
182
183     // Fetch health & ammo stats
184     hp      = bound(0,getstatf(STAT_VEHICLESTAT_HEALTH), 1);
185         shield  = bound(0,getstatf(STAT_VEHICLESTAT_SHIELD), 1);
186         heat    = min(getstatf(STAT_VEHICLESTAT_RELOAD1), 2);
187         rockets =     getstati(STAT_VEHICLESTAT_AMMO2);
188         reload  = min(getstatf(STAT_VEHICLESTAT_RELOAD2), 1);
189
190
191     hudloc_y = 4;
192     hudloc_x = 4;
193     drawfill('130 28 0', ('115 0 0' * hp) + '0 10 0', hp * '0 1 0' + (1 - hp) * '1 0 0', 0.5, DRAWFLAG_NORMAL);
194     picsize = drawgetimagesize(spider_h) * 0.5;
195     drawpic(hudloc, spider_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
196
197     picsize = drawgetimagesize(spider_a2) * 0.5;
198     drawpic(hudloc + '120 96  0', spider_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
199
200     drawstring(hudloc + '145 19  0', strcat(ftos(rint(hp * 100)), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
201     drawstring(hudloc + '175 34  0', strcat(ftos(rint(shield * 100)), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
202     drawstring(hudloc + '136 102  0', strcat(ftos(100 - rint(heat * 100)), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
203
204     picsize = drawgetimagesize(spider_a1) * 0.85;
205     if(rockets == 9)
206     {
207         drawpic(hudloc + '132 54  0', spider_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
208         drawstring(hudloc + '179 69 0', strcat(ftos(rint(reload * 100)), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
209     }
210     else
211     {
212         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
213         drawstring(hudloc + '179 69  0', strcat(ftos(9 - rockets), "/8"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
214     }
215
216     picsize = drawgetimagesize(spider_b) * 0.5;
217     hudloc_y = 10.5;
218     hudloc_x = 10.5;
219
220     drawpic(hudloc, spider_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
221     drawpic(hudloc, spider_b, picsize, '0 1 0' * hp + '1 0 0' * (1 - hp), 1, DRAWFLAG_NORMAL);
222     drawpic(hudloc, spider_r, picsize, '1 1 1' * reload + '1 0 0' * (1 - reload), 1, DRAWFLAG_NORMAL);
223     drawpic(hudloc, spider_g, picsize, '1 1 1' * (1 - heat) + '1 0 0' *  heat, 1, DRAWFLAG_NORMAL);
224
225
226         if (scoreboard_showscores)
227         {
228                 HUD_DrawScoreboard();
229                 HUD_DrawCenterPrint();
230     }
231     else
232     {
233         picsize = drawgetimagesize(SPIDER_CROSS);
234         picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
235         picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
236
237         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);
238     }
239 }
240
241
242 void CSQC_RAPTOR_HUD()
243 {
244         if(autocvar_r_letterbox)
245         return;
246
247         float reload, hp, shield, energy;
248         vector picsize, hudloc, vel;
249         float movedt;
250     vector where;
251
252     // Fetch health & ammo stats
253     hp      = bound(0,getstatf(STAT_VEHICLESTAT_HEALTH), 1);
254         shield  = bound(0,getstatf(STAT_VEHICLESTAT_SHIELD), 1);
255         reload  = min(getstatf(STAT_VEHICLESTAT_RELOAD1), 1);
256         energy  = min(getstatf(STAT_VEHICLESTAT_ENERGY),  1);
257
258     // Draw the crosshairs
259     picsize = drawgetimagesize("gfx/vehicles/axh-cross.tga");
260     picsize_x *= 0.75;
261     picsize_y *= 0.75;
262     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);
263
264     hudloc_y = 4;
265     hudloc_x = 4;
266
267     picsize = drawgetimagesize(raptor_h) * 0.5;
268     drawpic(hudloc, raptor_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
269
270     picsize = drawgetimagesize(spider_a2) * 0.5;
271     drawpic(hudloc + '120 96  0', spider_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
272
273     drawstring(hudloc + '145 19  0', strcat(ftos(rint(hp * 100)), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
274     drawstring(hudloc + '175 34  0', strcat(ftos(rint(shield * 100)), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
275     drawstring(hudloc + '136 102 0', strcat(ftos(rint(energy * 100)), "%"),'15 15 0','0.5 0.5 1', 1, DRAWFLAG_NORMAL);
276
277
278     picsize = drawgetimagesize(spider_a1) * 0.85;
279     if(reload == 1)
280     {
281         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
282         drawstring(hudloc + '179 69  0', strcat(ftos(rint(reload * 100)), "%"),'14 14 0','0 1 0', 0.5, DRAWFLAG_NORMAL);
283     }
284     else
285     {
286         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
287         drawstring(hudloc + '179 69  0', strcat(ftos(rint(reload * 100)), "%"),'14 14 0','0 0 1', 1, DRAWFLAG_NORMAL);
288     }
289
290     picsize = drawgetimagesize(raptor_b) * 0.5;
291     hudloc_y = 10.5;
292     hudloc_x = 10.5;
293
294     drawpic(hudloc, raptor_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
295     drawpic(hudloc, raptor_b, picsize, '0 1 0' * hp + '1 0 0' * (1 - hp), 1, DRAWFLAG_NORMAL);
296     drawpic(hudloc, raptor_g1, picsize, '1 1 1' * energy + '1 0 0' * (1 - energy), 1, DRAWFLAG_NORMAL);
297     drawpic(hudloc, raptor_g2, picsize, '1 1 1' * reload + '1 0 0' *  (1 - reload), 1, DRAWFLAG_NORMAL);
298
299     if(!dropmark)
300     {
301         dropmark = spawn();
302         dropmark.owner = self;
303         dropmark.gravity = 1;
304     }
305
306     if(reload == 1)
307     {
308         where = dropmark.origin;
309         setorigin(dropmark, pmove_org);
310         dropmark.velocity = pmove_vel;
311         tracetoss(dropmark, self);
312
313         where = project_3d_to_2d(trace_endpos);
314
315         setorigin(dropmark, trace_endpos);
316         picsize = drawgetimagesize(raptor_d) * 0.2;
317
318         if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
319         {
320             where_x -= picsize_x * 0.5;
321             where_y -= picsize_y * 0.5;
322             where_z = 0;
323             drawpic(where, raptor_d, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
324         }
325         dropmark.cnt = time + 5;
326     }
327     else
328     {
329         if(dropmark.cnt > time)
330         {
331             where = project_3d_to_2d(dropmark.origin);
332             picsize = drawgetimagesize(raptor_d) * 0.25;
333
334             if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
335             {
336                 where_x -= picsize_x * 0.5;
337                 where_y -= picsize_y * 0.5;
338                 where_z = 0;
339                 drawpic(where, raptor_d, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
340             }
341         }
342     }
343
344         if (scoreboard_showscores)
345         {
346                 HUD_DrawScoreboard();
347                 HUD_DrawCenterPrint();
348         }
349
350 }
351
352 #define waki_h "gfx/vehicles/hud_bg.tga"
353 #define waki_b "gfx/vehicles/waki.tga"
354 #define waki_e "gfx/vehicles/waki_e.tga"
355 #define waki_g "gfx/vehicles/waki_guns.tga"
356 #define waki_r "gfx/vehicles/waki_rockets.tga"
357 #define waki_s "gfx/vehicles/shiled.tga"
358
359 #define waki_a1 "gfx/vehicles/sb_rocket.tga"
360 #define waki_a2 "gfx/vehicles/sb_cells.tga"
361
362 void CSQC_WAKIZASHI_HUD()
363 {
364         // 0--1 floats. 1 = 100%, 0.6 = 50%.
365         float health, shield, energy, rockets;
366         vector picsize, hudloc;
367
368     picsize = drawgetimagesize(SPIDER_CROSS);
369     picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
370     picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
371     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);
372
373     health  = min(getstatf(STAT_VEHICLESTAT_HEALTH),  1);
374         shield  = min(getstatf(STAT_VEHICLESTAT_SHIELD),  1);
375         energy  = min(getstatf(STAT_VEHICLESTAT_ENERGY),  1);
376         rockets = bound(0,getstatf(STAT_VEHICLESTAT_RELOAD1), 1);
377
378     hudloc_y =  4;
379     hudloc_x = 4;
380
381     picsize = drawgetimagesize(waki_h) * 0.5;
382     drawpic(hudloc, waki_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
383
384     picsize = drawgetimagesize(waki_a2) * 0.7;
385     drawpic(hudloc + '116 92  0', waki_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
386
387
388     drawstring(hudloc + '145 19  0', strcat(ftos(rint(health * 100)), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
389     drawstring(hudloc + '175 34  0', strcat(ftos(rint(shield * 100)), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
390
391     drawstring(hudloc + '136 102  0', strcat(ftos(rint(energy * 100)), "%"),'14 14 0','1 1 1', 1, DRAWFLAG_NORMAL);
392
393     picsize = drawgetimagesize(waki_a1) * 0.75;
394     if(rockets == 1)
395     {
396         drawpic(hudloc + '140 55  0', waki_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
397         drawpic(hudloc + '144 59  0', waki_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
398     }
399     else
400     {
401         drawpic(hudloc + '140 55  0', waki_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
402         drawpic(hudloc + '144 59  0', waki_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
403         drawstring(hudloc + '165 69 0', strcat(ftos(rint(rockets * 100)), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
404     }
405
406     picsize = drawgetimagesize(waki_b) * 0.5;
407     hudloc_y = 10.5;
408     hudloc_x = 10.5;
409
410     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
411     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0' * (1 - health), 1, DRAWFLAG_NORMAL);
412     drawpic(hudloc, waki_r, picsize, '1 1 1' * rockets + '1 0 0' * (1 - rockets), 1, DRAWFLAG_NORMAL);
413     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0' *  (1 - energy), 1, DRAWFLAG_NORMAL);
414
415         if (scoreboard_showscores)
416         {
417                 HUD_DrawScoreboard();
418                 HUD_DrawCenterPrint();
419         }
420
421 }