]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/vehicles/vehicles.qc
Better defaults, fix aux xhair, add aux xhair to raptor.
[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
182
183 void CSQC_RAPTOR_HUD()
184 {
185         if(autocvar_r_letterbox)
186         return;
187
188         float reload, hp, shield, energy;
189         vector picsize, hudloc, vel;
190         float movedt;
191     vector where;
192
193     if(!dropmark)
194     {
195         dropmark = spawn();
196         dropmark.owner = self;
197     }
198
199         movedt = time - dropmark.move_time;
200         dropmark.move_time = time;
201     vel = (view_origin - lastpos) * (1 / movedt);
202     lastpos  = view_origin;
203
204     // Fetch health & ammo stats
205     hp      = bound(0,getstatf(STAT_VEHICLESTAT_HEALTH), 1);
206         shield  = bound(0,getstatf(STAT_VEHICLESTAT_SHIELD), 1);
207         reload  = min(getstatf(STAT_VEHICLESTAT_RELOAD1), 1);
208         energy  = min(getstatf(STAT_VEHICLESTAT_ENERGY),  1);
209
210     // Draw the crosshairs
211     picsize = drawgetimagesize(raptor_c);
212     picsize_x *= 0.2;
213     picsize_y *= 0.2;
214     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);
215
216     hudloc_y = 4;
217     hudloc_x = 4;
218
219     picsize = drawgetimagesize(raptor_h) * 0.5;
220     drawpic(hudloc, raptor_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
221
222     picsize = drawgetimagesize(spider_a2) * 0.5;
223     drawpic(hudloc + '120 96  0', spider_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
224
225     drawstring(hudloc + '145 19  0', strcat(ftos(rint(hp * 100)), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
226     drawstring(hudloc + '175 34  0', strcat(ftos(rint(shield * 100)), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
227     drawstring(hudloc + '136 102 0', strcat(ftos(rint(energy * 100)), "%"),'15 15 0','0.5 0.5 1', 1, DRAWFLAG_NORMAL);
228
229
230     picsize = drawgetimagesize(spider_a1) * 0.85;
231     if(reload == 1)
232     {
233         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
234         drawstring(hudloc + '179 69  0', strcat(ftos(rint(reload * 100)), "%"),'14 14 0','0 1 0', 0.5, DRAWFLAG_NORMAL);
235     }
236     else
237     {
238         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
239         drawstring(hudloc + '179 69  0', strcat(ftos(rint(reload * 100)), "%"),'14 14 0','0 0 1', 1, DRAWFLAG_NORMAL);
240     }
241
242     picsize = drawgetimagesize(raptor_b) * 0.5;
243     hudloc_y = 10.5;
244     hudloc_x = 10.5;
245
246     drawpic(hudloc, raptor_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
247     drawpic(hudloc, raptor_b, picsize, '0 1 0' * hp + '1 0 0' * (1 - hp), 1, DRAWFLAG_NORMAL);
248     drawpic(hudloc, raptor_g1, picsize, '1 1 1' * energy + '1 0 0' * (1 - energy), 1, DRAWFLAG_NORMAL);
249     drawpic(hudloc, raptor_g2, picsize, '1 1 1' * reload + '1 0 0' *  (1 - reload), 1, DRAWFLAG_NORMAL);
250
251     if(reload == 1)
252     {
253         where = dropmark.origin;
254         setorigin(dropmark, view_origin);
255         dropmark.velocity = vel;
256         tracetoss(dropmark, self);
257
258         // Blend old with new predicted impact to smooth out jumpyness
259         where = project_3d_to_2d(trace_endpos * 0.5 + where * 0.5);
260
261         setorigin(dropmark, trace_endpos);
262         picsize = drawgetimagesize(raptor_d) * 0.2;
263
264         if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
265         {
266             where_x -= picsize_x * 0.5;
267             where_y -= picsize_y * 0.5;
268             where_z = 0;
269             drawpic(where, raptor_d, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
270         }
271         dropmark.cnt = time + 2;
272     }
273     else
274     {
275         if(dropmark.cnt > time)
276         {
277             where = project_3d_to_2d(dropmark.origin);
278             picsize = drawgetimagesize(raptor_d) * 0.25;
279
280             if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
281             {
282                 where_x -= picsize_x * 0.5;
283                 where_y -= picsize_y * 0.5;
284                 where_z = 0;
285                 drawpic(where, raptor_d, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
286             }
287         }
288     }
289
290         if (scoreboard_showscores)
291         {
292                 HUD_DrawScoreboard();
293                 HUD_DrawCenterPrint();
294         }
295
296 }
297
298 #define waki_h "gfx/vehicles/hud_bg.tga"
299 #define waki_b "gfx/vehicles/waki.tga"
300 #define waki_e "gfx/vehicles/waki_e.tga"
301 #define waki_g "gfx/vehicles/waki_guns.tga"
302 #define waki_r "gfx/vehicles/waki_rockets.tga"
303 #define waki_s "gfx/vehicles/shiled.tga"
304
305 #define waki_a1 "gfx/vehicles/sb_rocket.tga"
306 #define waki_a2 "gfx/vehicles/sb_cells.tga"
307
308 void CSQC_WAKIZASHI_HUD()
309 {
310         // 0--1 floats. 1 = 100%, 0.6 = 50%.
311         float health, shield, energy, rockets;
312         vector picsize, hudloc;
313
314     picsize = drawgetimagesize(SPIDER_CROSS);
315     picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
316     picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
317     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);
318
319 /*
320 const float STAT_VEHICLESTAT_HEALTH  = 60;
321 const float STAT_VEHICLESTAT_SHIELD  = 61;
322 const float STAT_VEHICLESTAT_ENERGY  = 62;
323 const float STAT_VEHICLESTAT_AMMO1   = 63;
324 const float STAT_VEHICLESTAT_RELAOD1 = 64;
325 const float STAT_VEHICLESTAT_AMMO2   = 65;
326 const float STAT_VEHICLESTAT_RELOAD2 = 66;
327 */
328     health  = min(getstatf(STAT_VEHICLESTAT_HEALTH),  1);
329         shield  = min(getstatf(STAT_VEHICLESTAT_SHIELD),  1);
330         energy  = min(getstatf(STAT_VEHICLESTAT_ENERGY),  1);
331         rockets = bound(0,getstatf(STAT_VEHICLESTAT_RELOAD1), 1);
332
333     hudloc_y =  4;
334     hudloc_x = 4;
335
336     picsize = drawgetimagesize(waki_h) * 0.5;
337     drawpic(hudloc, waki_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
338
339     picsize = drawgetimagesize(waki_a2) * 0.7;
340     drawpic(hudloc + '116 92  0', waki_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
341
342
343     drawstring(hudloc + '145 19  0', strcat(ftos(rint(health * 100)), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
344     drawstring(hudloc + '175 34  0', strcat(ftos(rint(shield * 100)), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
345
346     drawstring(hudloc + '136 102  0', strcat(ftos(rint(energy * 100)), "%"),'14 14 0','1 1 1', 1, DRAWFLAG_NORMAL);
347
348     picsize = drawgetimagesize(waki_a1) * 0.75;
349     if(rockets == 1)
350     {
351         drawpic(hudloc + '140 55  0', waki_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
352         drawpic(hudloc + '144 59  0', waki_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
353     }
354     else
355     {
356         drawpic(hudloc + '140 55  0', waki_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
357         drawpic(hudloc + '144 59  0', waki_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
358         drawstring(hudloc + '165 69 0', strcat(ftos(rint(rockets * 100)), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
359     }
360
361     picsize = drawgetimagesize(waki_b) * 0.5;
362     hudloc_y = 10.5;
363     hudloc_x = 10.5;
364
365     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
366     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0' * (1 - health), 1, DRAWFLAG_NORMAL);
367     drawpic(hudloc, waki_r, picsize, '1 1 1' * rockets + '1 0 0' * (1 - rockets), 1, DRAWFLAG_NORMAL);
368     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0' *  (1 - energy), 1, DRAWFLAG_NORMAL);
369
370
371
372         /*
373         p = '0.5 0 0' * (vid_conwidth - (rkt_size * 8));
374         p = p + '0 1 0' * vid_conheight - '0 32 0';
375
376         // Draw health bar
377         p_y += 8;
378         drawfill(p, '256 0 0' * health + '0 8 0' , '0 0.7 0', 0.75, DRAWFLAG_NORMAL);
379         p_x += 256 * health;
380         drawfill(p, '256 0 0' * (1 - health) + '0 8 0' , '0 0 0', 0.75, DRAWFLAG_NORMAL);
381
382         // Draw shiled bar
383         p_x -= 256 * health;
384         p_y += 4;
385         drawfill(p, '256 0 0' * shield + '0 4 0' , '0.25 0.25 1', 0.5, DRAWFLAG_NORMAL);
386
387         // Draw energy
388         //p_x -= 256 * health;
389         p_y -= 8;
390         drawfill(p, '256 0 0' * energy + '0 4 0' , '1 1 1', 0.75, DRAWFLAG_NORMAL);
391
392         // Draw rockets bar
393         p_y += 12;
394         drawfill(p, '256 0 0' * rockets + '0 4 0' , '1 0 0', 0.75, DRAWFLAG_NORMAL);
395         */
396
397
398
399
400         if (scoreboard_showscores)
401         {
402                 HUD_DrawScoreboard();
403                 HUD_DrawCenterPrint();
404         }
405
406 }