]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/vehicles/vehicles.qc
Make colormap & fullbright work (uses g_fullbrightplayers), fix raptor shirt/pants...
[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     // Fetch health & ammo stats
250     hp      = bound(0,getstatf(STAT_VEHICLESTAT_HEALTH), 1);
251         shield  = bound(0,getstatf(STAT_VEHICLESTAT_SHIELD), 1);
252         reload  = min(getstatf(STAT_VEHICLESTAT_RELOAD1), 1);
253         energy  = min(getstatf(STAT_VEHICLESTAT_ENERGY),  1);
254
255     // Draw the crosshairs
256     picsize = drawgetimagesize("gfx/vehicles/axh-cross.tga");
257     picsize_x *= 0.75;
258     picsize_y *= 0.75;
259     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);
260
261     hudloc_y = 4;
262     hudloc_x = 4;
263
264     picsize = drawgetimagesize(raptor_h) * 0.5;
265     drawpic(hudloc, raptor_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
266
267     picsize = drawgetimagesize(spider_a2) * 0.5;
268     drawpic(hudloc + '120 96  0', spider_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
269
270     drawstring(hudloc + '145 19  0', strcat(ftos(rint(hp * 100)), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
271     drawstring(hudloc + '175 34  0', strcat(ftos(rint(shield * 100)), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
272     drawstring(hudloc + '136 102 0', strcat(ftos(rint(energy * 100)), "%"),'15 15 0','0.5 0.5 1', 1, DRAWFLAG_NORMAL);
273
274
275     picsize = drawgetimagesize(spider_a1) * 0.85;
276     if(reload == 1)
277     {
278         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
279         drawstring(hudloc + '179 69  0', strcat(ftos(rint(reload * 100)), "%"),'14 14 0','0 1 0', 0.5, DRAWFLAG_NORMAL);
280     }
281     else
282     {
283         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
284         drawstring(hudloc + '179 69  0', strcat(ftos(rint(reload * 100)), "%"),'14 14 0','0 0 1', 1, DRAWFLAG_NORMAL);
285     }
286
287     picsize = drawgetimagesize(raptor_b) * 0.5;
288     hudloc_y = 10.5;
289     hudloc_x = 10.5;
290
291     drawpic(hudloc, raptor_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
292     drawpic(hudloc, raptor_b, picsize, '0 1 0' * hp + '1 0 0' * (1 - hp), 1, DRAWFLAG_NORMAL);
293     drawpic(hudloc, raptor_g1, picsize, '1 1 1' * energy + '1 0 0' * (1 - energy), 1, DRAWFLAG_NORMAL);
294     drawpic(hudloc, raptor_g2, picsize, '1 1 1' * reload + '1 0 0' *  (1 - reload), 1, DRAWFLAG_NORMAL);
295
296     if(!dropmark)
297     {
298         dropmark = spawn();
299         dropmark.owner = self;
300     }
301
302     if(reload == 1)
303     {
304         where = dropmark.origin;
305         setorigin(dropmark, pmove_org);
306         dropmark.velocity = pmove_vel;
307         tracetoss(dropmark, self);
308
309         where = project_3d_to_2d(trace_endpos);
310
311         setorigin(dropmark, trace_endpos);
312         picsize = drawgetimagesize(raptor_d) * 0.2;
313
314         if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
315         {
316             where_x -= picsize_x * 0.5;
317             where_y -= picsize_y * 0.5;
318             where_z = 0;
319             drawpic(where, raptor_d, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
320         }
321         dropmark.cnt = time + 5;
322     }
323     else
324     {
325         if(dropmark.cnt > time)
326         {
327             where = project_3d_to_2d(dropmark.origin);
328             picsize = drawgetimagesize(raptor_d) * 0.25;
329
330             if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
331             {
332                 where_x -= picsize_x * 0.5;
333                 where_y -= picsize_y * 0.5;
334                 where_z = 0;
335                 drawpic(where, raptor_d, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
336             }
337         }
338     }
339
340         if (scoreboard_showscores)
341         {
342                 HUD_DrawScoreboard();
343                 HUD_DrawCenterPrint();
344         }
345
346 }
347
348 #define waki_h "gfx/vehicles/hud_bg.tga"
349 #define waki_b "gfx/vehicles/waki.tga"
350 #define waki_e "gfx/vehicles/waki_e.tga"
351 #define waki_g "gfx/vehicles/waki_guns.tga"
352 #define waki_r "gfx/vehicles/waki_rockets.tga"
353 #define waki_s "gfx/vehicles/shiled.tga"
354
355 #define waki_a1 "gfx/vehicles/sb_rocket.tga"
356 #define waki_a2 "gfx/vehicles/sb_cells.tga"
357
358 void CSQC_WAKIZASHI_HUD()
359 {
360         // 0--1 floats. 1 = 100%, 0.6 = 50%.
361         float health, shield, energy, rockets;
362         vector picsize, hudloc;
363
364     picsize = drawgetimagesize(SPIDER_CROSS);
365     picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
366     picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
367     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);
368
369     health  = min(getstatf(STAT_VEHICLESTAT_HEALTH),  1);
370         shield  = min(getstatf(STAT_VEHICLESTAT_SHIELD),  1);
371         energy  = min(getstatf(STAT_VEHICLESTAT_ENERGY),  1);
372         rockets = bound(0,getstatf(STAT_VEHICLESTAT_RELOAD1), 1);
373
374     hudloc_y =  4;
375     hudloc_x = 4;
376
377     picsize = drawgetimagesize(waki_h) * 0.5;
378     drawpic(hudloc, waki_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
379
380     picsize = drawgetimagesize(waki_a2) * 0.7;
381     drawpic(hudloc + '116 92  0', waki_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
382
383
384     drawstring(hudloc + '145 19  0', strcat(ftos(rint(health * 100)), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
385     drawstring(hudloc + '175 34  0', strcat(ftos(rint(shield * 100)), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
386
387     drawstring(hudloc + '136 102  0', strcat(ftos(rint(energy * 100)), "%"),'14 14 0','1 1 1', 1, DRAWFLAG_NORMAL);
388
389     picsize = drawgetimagesize(waki_a1) * 0.75;
390     if(rockets == 1)
391     {
392         drawpic(hudloc + '140 55  0', waki_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
393         drawpic(hudloc + '144 59  0', waki_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
394     }
395     else
396     {
397         drawpic(hudloc + '140 55  0', waki_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
398         drawpic(hudloc + '144 59  0', waki_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
399         drawstring(hudloc + '165 69 0', strcat(ftos(rint(rockets * 100)), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
400     }
401
402     picsize = drawgetimagesize(waki_b) * 0.5;
403     hudloc_y = 10.5;
404     hudloc_x = 10.5;
405
406     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
407     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0' * (1 - health), 1, DRAWFLAG_NORMAL);
408     drawpic(hudloc, waki_r, picsize, '1 1 1' * rockets + '1 0 0' * (1 - rockets), 1, DRAWFLAG_NORMAL);
409     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0' *  (1 - energy), 1, DRAWFLAG_NORMAL);
410
411         if (scoreboard_showscores)
412         {
413                 HUD_DrawScoreboard();
414                 HUD_DrawCenterPrint();
415         }
416
417 }