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