]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/vehicles/vehicles.qc
more csqc-vehicles stuff
[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 void CSQC_BUMBLE_HUD();
34
35 #define MAX_AXH 4
36 entity AuxiliaryXhair[MAX_AXH];
37 const var void Draw_Not();
38
39 .string axh_image;
40 .float  axh_fadetime;
41 .float  axh_drawflag;
42 .float  axh_scale;
43
44 void AuxiliaryXhair_Draw2D()
45 {
46     vector loc, psize;
47
48     psize = self.axh_scale * drawgetimagesize(self.axh_image);
49     loc = project_3d_to_2d(self.origin) - 0.5 * psize;
50     if not (loc_z < 0 || loc_x < 0 || loc_y < 0 || loc_x > vid_conwidth || loc_y > vid_conheight)
51     {
52         loc_z = 0;
53         psize_z = 0;
54         drawpic(loc, self.axh_image, psize, self.colormod, self.alpha, self.axh_drawflag);
55     }
56
57     if(time - self.cnt > self.axh_fadetime)
58         self.draw2d = Draw_Not;
59 }
60
61 void Net_Vehicle(float IsNew)
62 {
63     //entnum
64 }
65
66 void Net_AuXair2(float bIsNew)
67 {
68     float axh_id;
69     entity axh;
70
71     axh_id = bound(0, ReadByte(), MAX_AXH);
72     axh = AuxiliaryXhair[axh_id];
73
74     if(axh == world || wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
75     {
76         axh               = spawn();
77                 axh.draw2d        = Draw_Not;
78                 axh.drawmask      = MASK_NORMAL;
79                 axh.axh_drawflag  = DRAWFLAG_ADDITIVE;
80                 axh.axh_fadetime  = 0.1;
81                 axh.axh_image     = "gfx/vehicles/axh-ring.tga";
82                 axh.axh_scale     = 1;
83         axh.alpha         = 1;
84                 AuxiliaryXhair[axh_id] = axh;
85     }
86
87     axh.draw2d   = AuxiliaryXhair_Draw2D;
88
89         axh.origin_x = ReadCoord();
90         axh.origin_y = ReadCoord();
91         axh.origin_z = ReadCoord();
92
93         axh.colormod_x = ReadByte() / 255;
94         axh.colormod_y = ReadByte() / 255;
95         axh.colormod_z = ReadByte() / 255;
96     axh.cnt = time;
97 }
98
99 void Net_VehicleSetup()
100 {
101
102     float hud_id, i;
103     hud_id = bound(HUD_SPIDERBOT, ReadByte(), HUD_RAPTOR);
104
105     // Init auxiliary crosshairs
106     entity axh;
107     for(i = 0; i < MAX_AXH; ++i)
108     {
109         axh = AuxiliaryXhair[i];
110         if(axh != world && !wasfreed(axh))  // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?)
111             remove(axh);
112
113         axh               = spawn();
114                 axh.draw2d        = Draw_Not;
115                 axh.drawmask      = MASK_NORMAL;
116                 axh.axh_drawflag  = DRAWFLAG_ADDITIVE;
117                 axh.axh_fadetime  = 0.1;
118                 axh.axh_image     = "gfx/vehicles/axh-ring.tga";
119                 axh.axh_scale     = 1;
120         axh.alpha         = 1;
121                 AuxiliaryXhair[i] = axh;
122     }
123
124     switch(hud_id)
125     {
126         case HUD_SPIDERBOT:
127             // Minigun1
128             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-ring.tga";
129             AuxiliaryXhair[0].axh_scale   = 0.25;
130             // Minigun2
131             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-ring.tga";
132             AuxiliaryXhair[1].axh_scale   = 0.25;
133             // Rocket
134             AuxiliaryXhair[2].axh_image   = "gfx/vehicles/axh-special1.tga";
135             AuxiliaryXhair[2].axh_scale   = 0.5;
136             break;
137         case HUD_WAKIZASHI:
138             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-bracket.tga";
139             AuxiliaryXhair[0].axh_scale   = 0.25;
140             break;
141         case HUD_RAPTOR:
142             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-cross.tga";
143             AuxiliaryXhair[0].axh_scale   = 0.5;
144             AuxiliaryXhair[0].alpha       = 0.25;
145
146             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-bracket.tga";
147             AuxiliaryXhair[1].axh_scale   = 0.25;
148             AuxiliaryXhair[1].alpha       = 0.75;
149             AuxiliaryXhair[1].axh_drawflag  = DRAWFLAG_NORMAL;
150             break;
151         case HUD_BUMBLEBEE:
152             // Plasma cannons
153             AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-ring.tga";
154             AuxiliaryXhair[0].axh_scale   = 0.25;
155             // Raygun
156             AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-special1.tga";
157             AuxiliaryXhair[1].axh_scale   = 0.25;
158             break;
159     }
160 }
161 #define HUD_GETSTATS \
162     float health    = getstati(STAT_VEHICLESTAT_HEALTH); \
163         float shield    = getstati(STAT_VEHICLESTAT_SHIELD); \
164         float energy    = getstati(STAT_VEHICLESTAT_ENERGY); \
165         float ammo1     = getstati(STAT_VEHICLESTAT_AMMO1); \
166         float reload1   = getstati(STAT_VEHICLESTAT_RELOAD1); \
167         float ammo2     = getstati(STAT_VEHICLESTAT_AMMO2); \
168         float reload2   = getstati(STAT_VEHICLESTAT_RELOAD2);
169
170 void CSQC_BUMBLE_HUD()
171 {
172         vector picsize, hudloc;
173
174     // Fetch health & ammo stats
175         HUD_GETSTATS
176
177     hudloc_y = 4;
178     hudloc_x = 4;
179
180     picsize = drawgetimagesize(spider_h) * 0.5;
181     drawpic(hudloc, spider_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
182
183     picsize = drawgetimagesize(spider_a2) * 0.5;
184     drawpic(hudloc + '120 96  0', spider_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
185
186     drawstring(hudloc + '145 19  0',  strcat(ftos(health), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
187     drawstring(hudloc + '175 34  0',  strcat(ftos(shield), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
188     drawstring(hudloc + '136 102  0', strcat(ftos(ammo1), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
189
190     picsize = drawgetimagesize(spider_a1) * 0.85;
191     if(ammo2 == 9)
192     {
193         drawpic(hudloc + '132 54  0', spider_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
194         drawstring(hudloc + '179 69 0', strcat(ftos(reload2), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
195     }
196     else
197     {
198         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
199         drawstring(hudloc + '179 69  0', strcat(ftos(9 - ammo2), " / 8"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
200     }
201
202     picsize = drawgetimagesize(spider_b) * 0.5;
203     hudloc_y = 10.5;
204     hudloc_x = 10.5;
205
206     ammo1  /= 100;
207     shield /= 100;
208     health /= 100;
209     reload2 /= 100;
210
211     drawpic(hudloc, spider_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
212     drawpic(hudloc, spider_b, picsize, '0 1 0' * health + '1 0 0' * (1 - health), 1, DRAWFLAG_NORMAL);
213     drawpic(hudloc, spider_r, picsize, '1 1 1' * reload2 + '1 0 0' * (1 - reload2), 1, DRAWFLAG_NORMAL);
214     drawpic(hudloc, spider_g, picsize, '1 1 1' * ammo1 + '1 0 0' *  (1 - ammo1), 1, DRAWFLAG_NORMAL);
215
216
217         if (scoreboard_showscores)
218         {
219                 HUD_DrawScoreboard();
220                 HUD_DrawCenterPrint();
221     }
222     else
223     {
224         picsize = drawgetimagesize(SPIDER_CROSS);
225         picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
226         picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
227
228         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);
229     }
230 }
231
232
233 void CSQC_SPIDER_HUD()
234 {
235         vector picsize, hudloc;
236
237     // Fetch health & ammo stats
238         HUD_GETSTATS
239
240     hudloc_y = 4;
241     hudloc_x = 4;
242
243     picsize = drawgetimagesize(spider_h) * 0.5;
244     drawpic(hudloc, spider_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
245
246     picsize = drawgetimagesize(spider_a2) * 0.5;
247     drawpic(hudloc + '120 96  0', spider_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
248
249     drawstring(hudloc + '145 19  0', strcat(ftos(health), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
250     drawstring(hudloc + '175 34  0', strcat(ftos(shield), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
251     drawstring(hudloc + '136 102  0', strcat(ftos(ammo1), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
252
253     picsize = drawgetimagesize(spider_a1) * 0.85;
254     if(ammo2 == 9)
255     {
256         drawpic(hudloc + '132 54  0', spider_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
257         drawstring(hudloc + '179 69 0', strcat(ftos(reload2), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
258     }
259     else
260     {
261         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
262         drawstring(hudloc + '179 69  0', strcat(ftos(9 - ammo2), " / 8"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
263     }
264
265     picsize = drawgetimagesize(spider_b) * 0.5;
266     hudloc_y = 10.5;
267     hudloc_x = 10.5;
268
269     ammo1  /= 100;
270     shield /= 100;
271     health /= 100;
272     reload2 /= 100;
273
274     drawpic(hudloc, spider_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
275     drawpic(hudloc, spider_b, picsize, '0 1 0' * health + '1 0 0' * (1 - health), 1, DRAWFLAG_NORMAL);
276     drawpic(hudloc, spider_r, picsize, '1 1 1' * reload2 + '1 0 0' * (1 - reload2), 1, DRAWFLAG_NORMAL);
277     drawpic(hudloc, spider_g, picsize, '1 1 1' * ammo1 + '1 0 0' *  (1 - ammo1), 1, DRAWFLAG_NORMAL);
278
279
280         if (scoreboard_showscores)
281         {
282                 HUD_DrawScoreboard();
283                 HUD_DrawCenterPrint();
284     }
285     else
286     {
287         picsize = drawgetimagesize(SPIDER_CROSS);
288         picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
289         picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
290
291         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);
292     }
293 }
294
295
296 void CSQC_RAPTOR_HUD()
297 {
298         if(autocvar_r_letterbox)
299         return;
300
301         vector picsize, hudloc;
302     vector where;
303
304
305     // Fetch health & ammo stats
306     HUD_GETSTATS
307
308     // Draw the crosshairs
309     picsize = drawgetimagesize("gfx/vehicles/axh-cross.tga");
310     picsize_x *= 0.75;
311     picsize_y *= 0.75;
312     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);
313
314     hudloc_y = 4;
315     hudloc_x = 4;
316
317     picsize = drawgetimagesize(raptor_h) * 0.5;
318     drawpic(hudloc, raptor_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
319
320     picsize = drawgetimagesize(spider_a2) * 0.5;
321     drawpic(hudloc + '120 96  0', spider_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
322
323     drawstring(hudloc + '145 19  0', strcat(ftos(health), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
324     drawstring(hudloc + '175 34  0', strcat(ftos(shield), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
325     drawstring(hudloc + '136 102 0', strcat(ftos(energy), "%"),'15 15 0','0.5 0.5 1', 1, DRAWFLAG_NORMAL);
326
327     health /= 100;
328     shield /= 100;
329     energy /= 100;
330
331     picsize = drawgetimagesize(spider_a1) * 0.85;
332     if(reload2 == 100)
333     {
334         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
335         drawstring(hudloc + '179 69  0', strcat(ftos(reload2), "%"),'14 14 0','0 1 0', 0.5, DRAWFLAG_NORMAL);
336     }
337     else
338     {
339         drawpic(hudloc + '132 54  0', spider_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
340         drawstring(hudloc + '179 69  0', strcat(ftos(reload2), "%"),'14 14 0','0 0 1', 1, DRAWFLAG_NORMAL);
341     }
342
343     picsize = drawgetimagesize(raptor_b) * 0.5;
344     hudloc_y = 10.5;
345     hudloc_x = 10.5;
346     reload1 = reload2 / 100;
347     drawpic(hudloc, raptor_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
348     drawpic(hudloc, raptor_b, picsize, '0 1 0' * health + '1 0 0' * (1 - health), 1, DRAWFLAG_NORMAL);
349     drawpic(hudloc, raptor_g1, picsize, '1 1 1' * energy + '1 0 0' * (1 - energy), 1, DRAWFLAG_NORMAL);
350     drawpic(hudloc, raptor_g2, picsize, '1 1 1' * reload1 + '1 0 0' *  (1 - reload1), 1, DRAWFLAG_NORMAL);
351
352     if(!dropmark)
353     {
354         dropmark = spawn();
355         dropmark.owner = self;
356         dropmark.gravity = 1;
357     }
358
359     if(reload2 == 100)
360     {
361         where = dropmark.origin;
362         setorigin(dropmark, pmove_org);
363         dropmark.velocity = pmove_vel;
364         tracetoss(dropmark, self);
365
366         where = project_3d_to_2d(trace_endpos);
367
368         setorigin(dropmark, trace_endpos);
369         picsize = drawgetimagesize(raptor_d) * 0.2;
370
371         if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
372         {
373             where_x -= picsize_x * 0.5;
374             where_y -= picsize_y * 0.5;
375             where_z = 0;
376             drawpic(where, raptor_d, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
377         }
378         dropmark.cnt = time + 5;
379     }
380     else
381     {
382         if(dropmark.cnt > time)
383         {
384             where = project_3d_to_2d(dropmark.origin);
385             picsize = drawgetimagesize(raptor_d) * 0.25;
386
387             if not (where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight)
388             {
389                 where_x -= picsize_x * 0.5;
390                 where_y -= picsize_y * 0.5;
391                 where_z = 0;
392                 drawpic(where, raptor_d, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
393             }
394         }
395     }
396
397         if (scoreboard_showscores)
398         {
399                 HUD_DrawScoreboard();
400                 HUD_DrawCenterPrint();
401         }
402
403 }
404
405 #define waki_h "gfx/vehicles/hud_bg.tga"
406 #define waki_b "gfx/vehicles/waki.tga"
407 #define waki_e "gfx/vehicles/waki_e.tga"
408 #define waki_g "gfx/vehicles/waki_guns.tga"
409 #define waki_r "gfx/vehicles/waki_rockets.tga"
410 #define waki_s "gfx/vehicles/shiled.tga"
411
412 #define waki_a1 "gfx/vehicles/sb_rocket.tga"
413 #define waki_a2 "gfx/vehicles/sb_cells.tga"
414
415 void CSQC_WAKIZASHI_HUD()
416 {
417         vector picsize, hudloc;
418
419     picsize = drawgetimagesize(SPIDER_CROSS);
420     picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
421     picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
422     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);
423
424     /*
425     health  = min(getstatf(STAT_VEHICLESTAT_HEALTH),  1);
426         shield  = min(getstatf(STAT_VEHICLESTAT_SHIELD),  1);
427         energy  = min(getstatf(STAT_VEHICLESTAT_ENERGY),  1);
428         rockets = bound(0,getstatf(STAT_VEHICLESTAT_RELOAD1), 1);
429         */
430
431     HUD_GETSTATS
432
433     hudloc_y =  4;
434     hudloc_x = 4;
435
436     picsize = drawgetimagesize(waki_h) * 0.5;
437     drawpic(hudloc, waki_h, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
438
439     picsize = drawgetimagesize(waki_a2) * 0.7;
440     drawpic(hudloc + '116 92  0', waki_a2, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
441
442
443     drawstring(hudloc + '145 19  0', strcat(ftos(health), "%"),'15 15 0','0 1 0', 1, DRAWFLAG_NORMAL);
444     drawstring(hudloc + '175 34  0', strcat(ftos(shield), "%"),'15 15 0','0 0 1', 1, DRAWFLAG_NORMAL);
445     drawstring(hudloc + '136 102  0', strcat(ftos(energy), "%"),'14 14 0','1 1 1', 1, DRAWFLAG_NORMAL);
446
447     picsize = drawgetimagesize(waki_a1) * 0.75;
448     if(reload1 == 100)
449     {
450         drawpic(hudloc + '140 55  0', waki_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
451         drawpic(hudloc + '144 59  0', waki_a1, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
452     }
453     else
454     {
455         drawpic(hudloc + '140 55  0', waki_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
456         drawpic(hudloc + '144 59  0', waki_a1, picsize, '-1 -1 -1', 1, DRAWFLAG_NORMAL);
457         drawstring(hudloc + '165 69 0', strcat(ftos(reload1), "%"),'14 14 0','1 1 0', 1, DRAWFLAG_NORMAL);
458     }
459
460     picsize = drawgetimagesize(waki_b) * 0.5;
461     hudloc_y = 10.5;
462     hudloc_x = 10.5;
463
464     health /= 100;
465     energy /= 100;
466     shield /= 100;
467     reload1 /= 100;
468
469     drawpic(hudloc, waki_s, picsize, '1 1 1', shield, DRAWFLAG_NORMAL);
470     drawpic(hudloc, waki_b, picsize, '0 1 0' * health + '1 0 0'  * (1 - health), 1, DRAWFLAG_NORMAL);
471     drawpic(hudloc, waki_r, picsize, '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
472     drawpic(hudloc, waki_e, picsize, '1 1 1' * energy + '1 0 0'  * (1 - energy), 1, DRAWFLAG_NORMAL);
473
474         if (scoreboard_showscores)
475         {
476                 HUD_DrawScoreboard();
477                 HUD_DrawCenterPrint();
478         }
479
480 }
481
482 void Vehicles_Precache()
483 {
484         precache_model("models/vehicles/bomblet.md3");
485         precache_model("models/vehicles/clusterbomb.md3");
486         precache_model("models/vehicles/clusterbomb_fragment.md3");
487         precache_model("models/vehicles/rocket01.md3");
488         precache_model("models/vehicles/rocket02.md3");
489 }
490
491 void RaptorCBShellfragDraw()
492 {
493         Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
494         if(wasfreed(self))
495                 return;
496
497         self.move_avelocity += randomvec() * 15;
498         self.renderflags = 0;
499         if(self.cnt < time)
500         self.alpha = bound(0, self.nextthink - time, 1);
501
502         if(self.alpha < ALPHA_MIN_VISIBLE)
503         remove(self);
504
505 }
506
507 void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang)
508 {
509     entity sfrag;
510
511     sfrag = spawn();
512     setmodel(sfrag, "models/vehicles/clusterbomb_fragment.md3");
513     setorigin(sfrag, _org);
514
515         sfrag.move_movetype = MOVETYPE_BOUNCE;
516         sfrag.gravity = 0.15;
517         sfrag.solid = SOLID_CORPSE;
518
519         sfrag.draw = RaptorCBShellfragDraw;
520
521         sfrag.move_origin = sfrag.origin = _org;
522         sfrag.move_velocity = _vel;
523         sfrag.move_avelocity = prandomvec() * vlen(sfrag.move_velocity);
524         sfrag.angles = self.move_angles = _ang;
525
526         sfrag.move_time = time;
527         sfrag.damageforcescale = 4;
528
529         sfrag.nextthink = time + 3;
530         sfrag.cnt = time + 2;
531     sfrag.drawmask = MASK_NORMAL;
532 }