]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/vehicles/vehicles.qc
f54156d475ca06d3b5290ea5d976e0724be0abe7
[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 spider_h "gfx/vehicles/hud_bg.tga"
8 #define spider_b "gfx/vehicles/sbot.tga"
9 #define spider_r "gfx/vehicles/sbot_rpods.tga"
10 #define spider_g "gfx/vehicles/sbot_mguns.tga"
11 #define spider_s "gfx/vehicles/shiled.tga"
12 #define spider_a1 "gfx/vehicles/sb_rocket.tga"
13 #define spider_a2 "gfx/vehicles/sb_bullets.tga"
14
15 #define raptor_h  "gfx/vehicles/hud_bg.tga"
16 #define raptor_s  "gfx/vehicles/shiled.tga"
17
18 #define raptor_b  "gfx/vehicles/raptor.tga"
19 #define raptor_g1 "gfx/vehicles/raptor_guns.tga"
20 #define raptor_g2 "gfx/vehicles/raptor_bombs.tga"
21 #define raptor_d  "gfx/vehicles/dropcross.tga"
22 #define raptor_c  "gfx/vehicles/raptor_cross.tga"
23
24 entity dropmark;
25 vector lastpos;
26
27
28 void CSQC_WAKIZASHI_HUD();
29 void CSQC_SPIDER_HUD();
30 void CSQC_RAPTOR_HUD();
31
32 entity AuxiliaryXhair;
33 void AuxiliaryXhair_Draw2D()
34 {
35     vector loc, psize;
36
37     psize = 0.5 * drawgetimagesize(SPIDER_CROSS2);
38     loc = project_3d_to_2d(self.origin) - 0.5 * psize;
39     loc_z = 0;
40     psize_z = 0;
41     drawpic(loc, SPIDER_CROSS2, psize, '0 1 1', 1, DRAWFLAG_ADDITIVE);
42
43     if(time - self.cnt > 0.1)
44         remove(self);
45 }
46
47 void Ent_AuxiliaryXhair(float isNew)
48 {
49         //entity AuxiliaryXhair;
50
51     if(isNew)
52     {
53         if(AuxiliaryXhair)
54             remove(AuxiliaryXhair);
55
56         AuxiliaryXhair = spawn();
57                 AuxiliaryXhair.draw2d = AuxiliaryXhair_Draw2D;
58         setmodel(AuxiliaryXhair, "null");
59                 setsize(AuxiliaryXhair, '0 0 -1', '0 0 -1');
60
61     }
62
63         AuxiliaryXhair.origin_x = ReadCoord();
64         AuxiliaryXhair.origin_y = ReadCoord();
65         AuxiliaryXhair.origin_z = ReadCoord();
66     AuxiliaryXhair.drawmask = MASK_NORMAL;
67
68     AuxiliaryXhair.cnt = time;
69     //AuxiliaryXhair.solid = SOLID_NOT;
70 }
71
72 void Vehicles_Precache()
73 {
74         //precache_model("models/ax_shell.mdl");
75         //precache_sound("weapons/brass1.wav");
76 }
77
78
79 void CSQC_SPIDER_HUD()
80 {
81         float rockets, reload, heat, hp, shield;
82         vector picsize, hudloc;
83
84     // Fetch health & ammo stats
85     hp      = bound(0,getstatf(STAT_VEHICLESTAT_HEALTH), 1);
86         shield  = bound(0,getstatf(STAT_VEHICLESTAT_SHIELD), 1);
87         heat    = min(getstatf(STAT_VEHICLESTAT_RELOAD1), 2);
88         rockets =     getstati(STAT_VEHICLESTAT_AMMO2);
89         reload  = min(getstatf(STAT_VEHICLESTAT_RELOAD2), 1);
90
91
92     hudloc_y = 4;
93     hudloc_x = 4;
94     drawfill('130 28 0', ('115 0 0' * hp) + '0 10 0', hp * '0 1 0' + (1 - hp) * '1 0 0', 0.5, DRAWFLAG_NORMAL);
95     picsize = drawgetimagesize(spider_h) * 0.5;
96     drawpic(hudloc, spider_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
97
98     picsize = drawgetimagesize(spider_a2) * 0.5;
99     drawpic(hudloc + '120 96  0', spider_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
100
101     drawstring(hudloc + '145 19  0', strcat(ftos(rint(hp * 100)), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
102     drawstring(hudloc + '175 34  0', strcat(ftos(rint(shield * 100)), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
103     drawstring(hudloc + '136 102  0', strcat(ftos(100 - rint(heat * 100)), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
104
105     picsize = drawgetimagesize(spider_a1) * 0.85;
106     if(rockets == 9)
107     {
108         drawpic(hudloc + '132 54  0', spider_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
109         drawstring(hudloc + '179 69 0', strcat(ftos(rint(reload * 100)), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
110     }
111     else
112     {
113         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
114         drawstring(hudloc + '179 69  0', strcat(ftos(9 - rockets), "/8"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
115     }
116
117     picsize = drawgetimagesize(spider_b) * 0.5;
118     hudloc_y = 10.5;
119     hudloc_x = 10.5;
120
121     drawpic(hudloc, spider_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
122     drawpic(hudloc, spider_b, picsize, '0 1 0' * hp + '1 0 0' * (1 - hp), 1, DRAWFLAG_NORMAL);
123     drawpic(hudloc, spider_r, picsize, '1 1 1' * reload + '1 0 0' * (1 - reload), 1, DRAWFLAG_NORMAL);
124     drawpic(hudloc, spider_g, picsize, '1 1 1' * (1 - heat) + '1 0 0' *  heat, 1, DRAWFLAG_NORMAL);
125
126
127         if (scoreboard_showscores)
128         {
129                 HUD_DrawScoreboard();
130                 HUD_DrawCenterPrint();
131     }
132     else
133     {
134
135         /*
136         float movedt, vel;
137         movedt = time - self.move_time;
138         self.move_time = time;
139         vel = (view_origin - lastpos) * (1 / movedt);
140         lastpos  = view_origin;
141         dprint("vel: ", ftos(vel), "  angles: ", vtos(self.angles), "\n");
142         */
143
144         /*
145         dprint("aim1: ", vtos(aim1), "  aim2: ", vtos(aim2), "\n");
146         aim2_x *= -1;
147         makevectors(aim2);
148         te_lightning1(self, view_origin, view_origin + v_forward * MAX_SHOT_DISTANCE);
149         traceline(view_origin, view_origin + v_forward * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, self);
150         aim2 = trace_endpos;
151
152
153         aim1 = aim1 + view_origin;
154
155         // Draw the crosshairs
156         aim1 = project_3d_to_2d(aim1);
157         aim2 = project_3d_to_2d(aim2);
158
159         picsize = 0.5 * drawgetimagesize(SPIDER_CROSS2);
160         aim2 = aim2 - 0.5 * picsize;
161         aim2_z = 0;
162         picsize_z = 0;
163         drawpic(aim2, SPIDER_CROSS2, picsize, '0 1 1', 1, DRAWFLAG_ADDITIVE);
164
165         picsize = 0.5 * drawgetimagesize(SPIDER_CROSS2);
166         aim1 = aim1 - 0.5 * picsize;
167         aim1_z = 0;
168         picsize_z = 0;
169         drawpic(aim1, SPIDER_CROSS2, picsize, '1 0 0', 1, DRAWFLAG_ADDITIVE);
170
171         */
172         picsize = drawgetimagesize(SPIDER_CROSS);
173         picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
174         picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
175
176         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);
177     }
178 }
179
180
181 void CSQC_RAPTOR_HUD()
182 {
183         if(autocvar_r_letterbox)
184         return;
185
186         float reload, hp, shield, energy;
187         vector picsize, hudloc, vel;
188         float movedt;
189     vector where;
190
191     if(!dropmark)
192     {
193         dropmark = spawn();
194         dropmark.owner = self;
195     }
196
197         movedt = time - dropmark.move_time;
198         if(movedt)
199         {
200         dropmark.move_time = time;
201         vel = (view_origin - lastpos) * (1 / movedt);
202         lastpos  = view_origin;
203     }
204
205     // Fetch health & ammo stats
206     hp      = bound(0,getstatf(STAT_VEHICLESTAT_HEALTH), 1);
207         shield  = bound(0,getstatf(STAT_VEHICLESTAT_SHIELD), 1);
208         reload  = min(getstatf(STAT_VEHICLESTAT_RELOAD1), 1);
209         energy  = min(getstatf(STAT_VEHICLESTAT_ENERGY),  1);
210
211     // Draw the crosshairs
212     picsize = drawgetimagesize(raptor_c);
213     picsize_x *= 0.2;
214     picsize_y *= 0.2;
215     drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), raptor_c, picsize, '1 0 0' + '0 1 1' * energy, 0.5, DRAWFLAG_ADDITIVE);
216
217     hudloc_y = 4;
218     hudloc_x = 4;
219
220     picsize = drawgetimagesize(raptor_h) * 0.5;
221     drawpic(hudloc, raptor_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
222
223     picsize = drawgetimagesize(spider_a2) * 0.5;
224     drawpic(hudloc + '120 96  0', spider_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
225
226     drawstring(hudloc + '145 19  0', strcat(ftos(rint(hp * 100)), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
227     drawstring(hudloc + '175 34  0', strcat(ftos(rint(shield * 100)), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
228     drawstring(hudloc + '136 102 0', strcat(ftos(rint(energy * 100)), "%"),'15 15 0','0.5 0.5 1', 1, DRAWFLAG_NORMAL);
229
230
231     picsize = drawgetimagesize(spider_a1) * 0.85;
232     if(reload == 1)
233     {
234         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
235         drawstring(hudloc + '179 69  0', strcat(ftos(rint(reload * 100)), "%"),'14 14 0','0 1 0', 0.5, DRAWFLAG_NORMAL);
236     }
237     else
238     {
239         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
240         drawstring(hudloc + '179 69  0', strcat(ftos(rint(reload * 100)), "%"),'14 14 0','0 0 1', 1, DRAWFLAG_NORMAL);
241     }
242
243     picsize = drawgetimagesize(raptor_b) * 0.5;
244     hudloc_y = 10.5;
245     hudloc_x = 10.5;
246
247     drawpic(hudloc, raptor_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
248     drawpic(hudloc, raptor_b, picsize, '0 1 0' * hp + '1 0 0' * (1 - hp), 1, DRAWFLAG_NORMAL);
249     drawpic(hudloc, raptor_g1, picsize, '1 1 1' * energy + '1 0 0' * (1 - energy), 1, DRAWFLAG_NORMAL);
250     drawpic(hudloc, raptor_g2, picsize, '1 1 1' * reload + '1 0 0' *  (1 - reload), 1, DRAWFLAG_NORMAL);
251
252     if(reload == 1)
253     {
254         where = dropmark.origin;
255         setorigin(dropmark, view_origin);
256         dropmark.velocity = vel;
257         tracetoss(dropmark, self);
258
259         // Blend old with new predicted impact to smooth out jumpyness
260         where = project_3d_to_2d(trace_endpos * 0.5 + where * 0.5);
261
262         setorigin(dropmark, trace_endpos);
263         picsize = drawgetimagesize(raptor_d) * 0.2;
264
265         if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
266         {
267             where_x -= picsize_x * 0.5;
268             where_y -= picsize_y * 0.5;
269             where_z = 0;
270             drawpic(where, raptor_d, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
271         }
272         dropmark.cnt = time + 5;
273     }
274     else
275     {
276         if(dropmark.cnt > time)
277         {
278             where = project_3d_to_2d(dropmark.origin);
279             picsize = drawgetimagesize(raptor_d) * 0.25;
280
281             if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
282             {
283                 where_x -= picsize_x * 0.5;
284                 where_y -= picsize_y * 0.5;
285                 where_z = 0;
286                 drawpic(where, raptor_d, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
287             }
288         }
289     }
290
291         if (scoreboard_showscores)
292         {
293                 HUD_DrawScoreboard();
294                 HUD_DrawCenterPrint();
295         }
296
297 }
298
299 #define waki_h "gfx/vehicles/hud_bg.tga"
300 #define waki_b "gfx/vehicles/waki.tga"
301 #define waki_e "gfx/vehicles/waki_e.tga"
302 #define waki_g "gfx/vehicles/waki_guns.tga"
303 #define waki_r "gfx/vehicles/waki_rockets.tga"
304 #define waki_s "gfx/vehicles/shiled.tga"
305
306 #define waki_a1 "gfx/vehicles/sb_rocket.tga"
307 #define waki_a2 "gfx/vehicles/sb_cells.tga"
308
309 void CSQC_WAKIZASHI_HUD()
310 {
311         // 0--1 floats. 1 = 100%, 0.6 = 50%.
312         float health, shield, energy, rockets;
313         vector picsize, hudloc;
314
315     picsize = drawgetimagesize(SPIDER_CROSS);
316     picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
317     picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
318     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);
319
320 /*
321 const float STAT_VEHICLESTAT_HEALTH  = 60;
322 const float STAT_VEHICLESTAT_SHIELD  = 61;
323 const float STAT_VEHICLESTAT_ENERGY  = 62;
324 const float STAT_VEHICLESTAT_AMMO1   = 63;
325 const float STAT_VEHICLESTAT_RELAOD1 = 64;
326 const float STAT_VEHICLESTAT_AMMO2   = 65;
327 const float STAT_VEHICLESTAT_RELOAD2 = 66;
328 */
329     health  = min(getstatf(STAT_VEHICLESTAT_HEALTH),  1);
330         shield  = min(getstatf(STAT_VEHICLESTAT_SHIELD),  1);
331         energy  = min(getstatf(STAT_VEHICLESTAT_ENERGY),  1);
332         rockets = bound(0,getstatf(STAT_VEHICLESTAT_RELOAD1), 1);
333
334     hudloc_y =  4;
335     hudloc_x = 4;
336
337     picsize = drawgetimagesize(waki_h) * 0.5;
338     drawpic(hudloc, waki_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
339
340     picsize = drawgetimagesize(waki_a2) * 0.7;
341     drawpic(hudloc + '116 92  0', waki_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
342
343
344     drawstring(hudloc + '145 19  0', strcat(ftos(rint(health * 100)), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
345     drawstring(hudloc + '175 34  0', strcat(ftos(rint(shield * 100)), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
346
347     drawstring(hudloc + '136 102  0', strcat(ftos(rint(energy * 100)), "%"),'14 14 0','1 1 1', 1, DRAWFLAG_NORMAL);
348
349     picsize = drawgetimagesize(waki_a1) * 0.75;
350     if(rockets == 1)
351     {
352         drawpic(hudloc + '140 55  0', waki_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
353         drawpic(hudloc + '144 59  0', waki_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
354     }
355     else
356     {
357         drawpic(hudloc + '140 55  0', waki_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
358         drawpic(hudloc + '144 59  0', waki_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
359         drawstring(hudloc + '165 69 0', strcat(ftos(rint(rockets * 100)), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
360     }
361
362     picsize = drawgetimagesize(waki_b) * 0.5;
363     hudloc_y = 10.5;
364     hudloc_x = 10.5;
365
366     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
367     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0' * (1 - health), 1, DRAWFLAG_NORMAL);
368     drawpic(hudloc, waki_r, picsize, '1 1 1' * rockets + '1 0 0' * (1 - rockets), 1, DRAWFLAG_NORMAL);
369     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0' *  (1 - energy), 1, DRAWFLAG_NORMAL);
370
371
372
373         /*
374         p = '0.5 0 0' * (vid_conwidth - (rkt_size * 8));
375         p = p + '0 1 0' * vid_conheight - '0 32 0';
376
377         // Draw health bar
378         p_y += 8;
379         drawfill(p, '256 0 0' * health + '0 8 0' , '0 0.7 0', 0.75, DRAWFLAG_NORMAL);
380         p_x += 256 * health;
381         drawfill(p, '256 0 0' * (1 - health) + '0 8 0' , '0 0 0', 0.75, DRAWFLAG_NORMAL);
382
383         // Draw shiled bar
384         p_x -= 256 * health;
385         p_y += 4;
386         drawfill(p, '256 0 0' * shield + '0 4 0' , '0.25 0.25 1', 0.5, DRAWFLAG_NORMAL);
387
388         // Draw energy
389         //p_x -= 256 * health;
390         p_y -= 8;
391         drawfill(p, '256 0 0' * energy + '0 4 0' , '1 1 1', 0.75, DRAWFLAG_NORMAL);
392
393         // Draw rockets bar
394         p_y += 12;
395         drawfill(p, '256 0 0' * rockets + '0 4 0' , '1 0 0', 0.75, DRAWFLAG_NORMAL);
396         */
397
398
399
400
401         if (scoreboard_showscores)
402         {
403                 HUD_DrawScoreboard();
404                 HUD_DrawCenterPrint();
405         }
406
407 }