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