Debian Codegraph @

code/cgame/cg_effects.c

raw
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22 //
23 // cg_effects.c -- these functions generate localentities, usually as a result
24 // of event processing
25
26 #include "cg_local.h"
27
28
29 /*
30 ==================
31 CG_BubbleTrail
32
33 Bullets shot underwater
34 ==================
35 */
36 void CG_BubbleTrail( vec3_t start, vec3_t end, float spacing ) {
37 vec3_t move;
38 vec3_t vec;
39 float len;
40 int i;
41
42 if ( cg_noProjectileTrail.integer ) {
43 return;
44 }
45
46 VectorCopy (start, move);
47 VectorSubtract (end, start, vec);
48 len = VectorNormalize (vec);
49
50 // advance a random amount first
51 i = rand() % (int)spacing;
52 VectorMA( move, i, vec, move );
53
54 VectorScale (vec, spacing, vec);
55
56 for ( ; i < len; i += spacing ) {
57 localEntity_t *le;
58 refEntity_t *re;
59
60 le = CG_AllocLocalEntity();
61 le->leFlags = LEF_PUFF_DONT_SCALE;
62 le->leType = LE_MOVE_SCALE_FADE;
63 le->startTime = cg.time;
64 le->endTime = cg.time + 1000 + random() * 250;
65 le->lifeRate = 1.0 / ( le->endTime - le->startTime );
66
67 re = &le->refEntity;
68 re->shaderTime = cg.time / 1000.0f;
69
70 re->reType = RT_SPRITE;
71 re->rotation = 0;
72 re->radius = 3;
73 re->customShader = cgs.media.waterBubbleShader;
74 re->shaderRGBA[0] = 0xff;
75 re->shaderRGBA[1] = 0xff;
76 re->shaderRGBA[2] = 0xff;
77 re->shaderRGBA[3] = 0xff;
78
79 le->color[3] = 1.0;
80
81 le->pos.trType = TR_LINEAR;
82 le->pos.trTime = cg.time;
83 VectorCopy( move, le->pos.trBase );
84 le->pos.trDelta[0] = crandom()*5;
85 le->pos.trDelta[1] = crandom()*5;
86 le->pos.trDelta[2] = crandom()*5 + 6;
87
88 VectorAdd (move, vec, move);
89 }
90 }
91
92 /*
93 =====================
94 CG_SmokePuff
95
96 Adds a smoke puff or blood trail localEntity.
97 =====================
98 */
99 localEntity_t *CG_SmokePuff( const vec3_t p, const vec3_t vel,
100 float radius,
101 float r, float g, float b, float a,
102 float duration,
103 int startTime,
104 int fadeInTime,
105 int leFlags,
106 qhandle_t hShader ) {
107 static int seed = 0x92;
108 localEntity_t *le;
109 refEntity_t *re;
110 // int fadeInTime = startTime + duration / 2;
111
112 le = CG_AllocLocalEntity();
113 le->leFlags = leFlags;
114 le->radius = radius;
115
116 re = &le->refEntity;
117 re->rotation = Q_random( &seed ) * 360;
118 re->radius = radius;
119 re->shaderTime = startTime / 1000.0f;
120
121 le->leType = LE_MOVE_SCALE_FADE;
122 le->startTime = startTime;
123 le->fadeInTime = fadeInTime;
124 le->endTime = startTime + duration;
125 if ( fadeInTime > startTime ) {
126 le->lifeRate = 1.0 / ( le->endTime - le->fadeInTime );
127 }
128 else {
129 le->lifeRate = 1.0 / ( le->endTime - le->startTime );
130 }
131 le->color[0] = r;
132 le->color[1] = g;
133 le->color[2] = b;
134 le->color[3] = a;
135
136
137 le->pos.trType = TR_LINEAR_STOP;
138 le->pos.trTime = startTime;
139 VectorCopy( vel, le->pos.trDelta );
140 VectorCopy( p, le->pos.trBase );
141
142 VectorCopy( p, re->origin );
143 re->customShader = hShader;
144
145 // rage pro can't alpha fade, so use a different shader
146 if ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) {
147 re->customShader = cgs.media.smokePuffRageProShader;
148 re->shaderRGBA[0] = 0xff;
149 re->shaderRGBA[1] = 0xff;
150 re->shaderRGBA[2] = 0xff;
151 re->shaderRGBA[3] = 0xff;
152 } else {
153 re->shaderRGBA[0] = le->color[0] * 0xff;
154 re->shaderRGBA[1] = le->color[1] * 0xff;
155 re->shaderRGBA[2] = le->color[2] * 0xff;
156 re->shaderRGBA[3] = 0xff;
157 }
158
159 re->reType = RT_SPRITE;
160 re->radius = le->radius;
161
162 return le;
163 }
164
165 // LEILEI same as above, but slows down.......
166 localEntity_t *CG_SlowPuff( const vec3_t p, const vec3_t vel,
167 float radius,
168 float r, float g, float b, float a,
169 float duration,
170 int startTime,
171 int fadeInTime,
172 int leFlags,
173 qhandle_t hShader ) {
174 static int seed = 0x92;
175 localEntity_t *le;
176 refEntity_t *re;
177
178 le = CG_AllocLocalEntity();
179 le->leFlags = leFlags;
180 le->radius = radius;
181
182 re = &le->refEntity;
183 re->rotation = Q_random( &seed ) * 360;
184 re->radius = radius;
185 re->shaderTime = startTime / 1000.0f;
186
187 le->leType = LE_MOVE_SCALE_FADE;
188 le->startTime = startTime;
189 le->fadeInTime = fadeInTime;
190 le->endTime = startTime + duration;
191 if ( fadeInTime > startTime ) {
192 le->lifeRate = 1.0 / ( le->endTime - le->fadeInTime );
193 }
194 else {
195 le->lifeRate = 1.0 / ( le->endTime - le->startTime );
196 }
197 le->color[0] = r;
198 le->color[1] = g;
199 le->color[2] = b;
200 le->color[3] = a;
201
202
203 le->pos.trType = TR_LINEAR;
204 le->pos.trTime = startTime;
205 VectorCopy( vel, le->pos.trDelta );
206 VectorCopy( p, le->pos.trBase );
207
208 VectorCopy( p, re->origin );
209 re->customShader = hShader;
210
211 // rage pro can't alpha fade, so use a different shader
212 if ( cgs.glconfig.hardwareType == GLHW_RAGEPRO ) {
213 re->customShader = cgs.media.smokePuffRageProShader;
214 re->shaderRGBA[0] = 0xff;
215 re->shaderRGBA[1] = 0xff;
216 re->shaderRGBA[2] = 0xff;
217 re->shaderRGBA[3] = 0xff;
218 } else {
219 re->shaderRGBA[0] = le->color[0] * 0xff;
220 re->shaderRGBA[1] = le->color[1] * 0xff;
221 re->shaderRGBA[2] = le->color[2] * 0xff;
222 re->shaderRGBA[3] = 0xff;
223 }
224
225 re->reType = RT_SPRITE;
226 re->radius = le->radius;
227
228 return le;
229 }
230
231 /*
232 ==================
233 CG_SpawnEffect
234
235 Player teleporting in or out
236 ==================
237 */
238 void CG_SpawnEffect( vec3_t org ) {
239 localEntity_t *le;
240 refEntity_t *re;
241
242 le = CG_AllocLocalEntity();
243 le->leFlags = 0;
244 le->leType = LE_FADE_RGB;
245 le->startTime = cg.time;
246 le->endTime = cg.time + 500;
247 le->lifeRate = 1.0 / ( le->endTime - le->startTime );
248
249 le->color[0] = le->color[1] = le->color[2] = le->color[3] = 1.0;
250
251 re = &le->refEntity;
252
253 re->reType = RT_MODEL;
254 re->shaderTime = cg.time / 1000.0f;
255
256 #ifndef MISSIONPACK
257 re->customShader = cgs.media.teleportEffectShader;
258 #endif
259 re->hModel = cgs.media.teleportEffectModel;
260 AxisClear( re->axis );
261
262 VectorCopy( org, re->origin );
263 #ifdef MISSIONPACK
264 re->origin[2] += 16;
265 #else
266 re->origin[2] -= 24;
267 #endif
268 }
269
270 /*
271 ===============
272 CG_LightningBoltBeam
273 ===============
274 */
275 void CG_LightningBoltBeam( vec3_t start, vec3_t end ) {
276 localEntity_t *le;
277 refEntity_t *beam;
278
279 le = CG_AllocLocalEntity();
280 le->leFlags = 0;
281 le->leType = LE_SHOWREFENTITY;
282 le->startTime = cg.time;
283 le->endTime = cg.time + 50;
284
285 beam = &le->refEntity;
286
287 VectorCopy( start, beam->origin );
288 // this is the end point
289 VectorCopy( end, beam->oldorigin );
290
291 beam->reType = RT_LIGHTNING;
292 beam->customShader = cgs.media.lightningShader;
293 }
294
295 /*
296 ==================
297 CG_KamikazeEffect
298 ==================
299 */
300 void CG_KamikazeEffect( vec3_t org ) {
301 localEntity_t *le;
302 refEntity_t *re;
303
304 le = CG_AllocLocalEntity();
305 le->leFlags = 0;
306 le->leType = LE_KAMIKAZE;
307 le->startTime = cg.time;
308 le->endTime = cg.time + 3000;//2250;
309 le->lifeRate = 1.0 / ( le->endTime - le->startTime );
310
311 le->color[0] = le->color[1] = le->color[2] = le->color[3] = 1.0;
312
313 VectorClear(le->angles.trBase);
314
315 re = &le->refEntity;
316
317 re->reType = RT_MODEL;
318 re->shaderTime = cg.time / 1000.0f;
319
320 re->hModel = cgs.media.kamikazeEffectModel;
321
322 VectorCopy( org, re->origin );
323
324 }
325
326 /*
327 ==================
328 CG_ObeliskExplode
329 ==================
330 */
331 void CG_ObeliskExplode( vec3_t org, int entityNum ) {
332 localEntity_t *le;
333 vec3_t origin;
334
335 // create an explosion
336 VectorCopy( org, origin );
337 origin[2] += 64;
338 le = CG_MakeExplosion( origin, vec3_origin,
339 cgs.media.dishFlashModel,
340 cgs.media.rocketExplosionShader,
341 600, qtrue );
342 le->light = 300;
343 le->lightColor[0] = 1;
344 le->lightColor[1] = 0.75;
345 le->lightColor[2] = 0.0;
346 }
347
348 /*
349 ==================
350 CG_ObeliskPain
351 ==================
352 */
353 void CG_ObeliskPain( vec3_t org ) {
354 float r;
355 sfxHandle_t sfx;
356
357 // hit sound
358 r = rand() & 3;
359 if ( r < 2 ) {
360 sfx = cgs.media.obeliskHitSound1;
361 } else if ( r == 2 ) {
362 sfx = cgs.media.obeliskHitSound2;
363 } else {
364 sfx = cgs.media.obeliskHitSound3;
365 }
366 trap_S_StartSound ( org, ENTITYNUM_NONE, CHAN_BODY, sfx );
367 }
368
369
370 /*
371 ==================
372 CG_InvulnerabilityImpact
373 ==================
374 */
375 void CG_InvulnerabilityImpact( vec3_t org, vec3_t angles ) {
376 localEntity_t *le;
377 refEntity_t *re;
378 int r;
379 sfxHandle_t sfx;
380
381 le = CG_AllocLocalEntity();
382 le->leFlags = 0;
383 le->leType = LE_INVULIMPACT;
384 le->startTime = cg.time;
385 le->endTime = cg.time + 1000;
386 le->lifeRate = 1.0 / ( le->endTime - le->startTime );
387
388 le->color[0] = le->color[1] = le->color[2] = le->color[3] = 1.0;
389
390 re = &le->refEntity;
391
392 re->reType = RT_MODEL;
393 re->shaderTime = cg.time / 1000.0f;
394
395 re->hModel = cgs.media.invulnerabilityImpactModel;
396
397 VectorCopy( org, re->origin );
398 AnglesToAxis( angles, re->axis );
399
400 r = rand() & 3;
401 if ( r < 2 ) {
402 sfx = cgs.media.invulnerabilityImpactSound1;
403 } else if ( r == 2 ) {
404 sfx = cgs.media.invulnerabilityImpactSound2;
405 } else {
406 sfx = cgs.media.invulnerabilityImpactSound3;
407 }
408 trap_S_StartSound (org, ENTITYNUM_NONE, CHAN_BODY, sfx );
409 }
410
411 /*
412 ==================
413 CG_InvulnerabilityJuiced
414 ==================
415 */
416 void CG_InvulnerabilityJuiced( vec3_t org ) {
417 localEntity_t *le;
418 refEntity_t *re;
419 vec3_t angles;
420
421 le = CG_AllocLocalEntity();
422 le->leFlags = 0;
423 le->leType = LE_INVULJUICED;
424 le->startTime = cg.time;
425 le->endTime = cg.time + 10000;
426 le->lifeRate = 1.0 / ( le->endTime - le->startTime );
427
428 le->color[0] = le->color[1] = le->color[2] = le->color[3] = 1.0;
429
430 re = &le->refEntity;
431
432 re->reType = RT_MODEL;
433 re->shaderTime = cg.time / 1000.0f;
434
435 re->hModel = cgs.media.invulnerabilityJuicedModel;
436
437 VectorCopy( org, re->origin );
438 VectorClear(angles);
439 AnglesToAxis( angles, re->axis );
440
441 trap_S_StartSound (org, ENTITYNUM_NONE, CHAN_BODY, cgs.media.invulnerabilityJuicedSound );
442 }
443
444 /*
445 ==================
446 CG_ScorePlum
447 ==================
448 */
449 void CG_ScorePlum( int client, vec3_t org, int score ) {
450 localEntity_t *le;
451 refEntity_t *re;
452 vec3_t angles;
453 static vec3_t lastPos;
454
455 // only visualize for the client that scored
456 if (client != cg.predictedPlayerState.clientNum || cg_scorePlum.integer == 0) {
457 return;
458 }
459
460 le = CG_AllocLocalEntity();
461 le->leFlags = 0;
462 le->leType = LE_SCOREPLUM;
463 le->startTime = cg.time;
464 le->endTime = cg.time + 4000;
465 le->lifeRate = 1.0 / ( le->endTime - le->startTime );
466
467
468 le->color[0] = le->color[1] = le->color[2] = le->color[3] = 1.0;
469 le->radius = score;
470
471 VectorCopy( org, le->pos.trBase );
472 if (org[2] >= lastPos[2] - 20 && org[2] <= lastPos[2] + 20) {
473 le->pos.trBase[2] -= 20;
474 }
475
476 //CG_Printf( "Plum origin %i %i %i -- %i\n", (int)org[0], (int)org[1], (int)org[2], (int)Distance(org, lastPos));
477 VectorCopy(org, lastPos);
478
479
480 re = &le->refEntity;
481
482 re->reType = RT_SPRITE;
483 re->radius = 16;
484
485 VectorClear(angles);
486 AnglesToAxis( angles, re->axis );
487 }
488
489
490 /*
491 ====================
492 CG_MakeExplosion
493 ====================
494 */
495 localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir,
496 qhandle_t hModel, qhandle_t shader,
497 int msec, qboolean isSprite ) {
498 float ang;
499 localEntity_t *ex;
500 int offset;
501 vec3_t tmpVec, newOrigin;
502
503 if ( msec <= 0 ) {
504 CG_Error( "CG_MakeExplosion: msec = %i", msec );
505 }
506
507 // skew the time a bit so they aren't all in sync
508 offset = rand() & 63;
509
510 ex = CG_AllocLocalEntity();
511 if ( isSprite ) {
512 ex->leType = LE_SPRITE_EXPLOSION;
513
514 // randomly rotate sprite orientation
515 ex->refEntity.rotation = rand() % 360;
516 VectorScale( dir, 16, tmpVec );
517 VectorAdd( tmpVec, origin, newOrigin );
518 } else {
519 ex->leType = LE_EXPLOSION;
520 VectorCopy( origin, newOrigin );
521
522 // set axis with random rotate
523 if ( !dir ) {
524 AxisClear( ex->refEntity.axis );
525 } else {
526 ang = rand() % 360;
527 VectorCopy( dir, ex->refEntity.axis[0] );
528 RotateAroundDirection( ex->refEntity.axis, ang );
529 }
530 }
531
532 ex->startTime = cg.time - offset;
533 ex->endTime = ex->startTime + msec;
534
535 // bias the time so all shader effects start correctly
536 ex->refEntity.shaderTime = ex->startTime / 1000.0f;
537
538 ex->refEntity.hModel = hModel;
539 ex->refEntity.customShader = shader;
540
541 // set origin
542 VectorCopy( newOrigin, ex->refEntity.origin );
543 VectorCopy( newOrigin, ex->refEntity.oldorigin );
544
545 ex->color[0] = ex->color[1] = ex->color[2] = 1.0;
546
547 return ex;
548 }
549
550
551 /*
552 =================
553 CG_Bleed
554
555 This is the spurt of blood when a character gets hit
556 =================
557 */
558 void CG_Bleed( vec3_t origin, int entityNum ) {
559 localEntity_t *ex;
560
561 if ( !cg_blood.integer ) {
562 return;
563 }
564
565 ex = CG_AllocLocalEntity();
566 ex->leType = LE_EXPLOSION;
567
568 ex->startTime = cg.time;
569 ex->endTime = ex->startTime + 500;
570
571 VectorCopy ( origin, ex->refEntity.origin);
572 ex->refEntity.reType = RT_SPRITE;
573 ex->refEntity.rotation = rand() % 360;
574 ex->refEntity.radius = 24;
575
576 ex->refEntity.customShader = cgs.media.bloodExplosionShader;
577
578 // don't show player's own blood in view
579 if ( entityNum == cg.snap->ps.clientNum ) {
580 ex->refEntity.renderfx |= RF_THIRD_PERSON;
581 }
582 }
583
584
585
586 /*
587 ==================
588 CG_SpurtBlood (LEILEI)
589 ==================
590 */
591 void CG_SpurtBlood( vec3_t origin, vec3_t velocity, int hard ) {
592 localEntity_t *blood;
593 // if ( !cg_blood.integer ) { return; }
594
595
596 velocity[0] = velocity[0] * hard * crandom()*460;
597 velocity[1] = velocity[1] * hard * crandom()*460;
598 velocity[2] = velocity[2] * hard * crandom()*566 + 65;
599 blood = CG_SmokePuff( origin, velocity,
600 21, // radius
601 1, 1, 1, 1, // color
602 2450, // trailTime
603 cg.time, // startTime
604 0, // fadeInTime
605 0, // flags
606 cgs.media.lbldShader1 );
607 // use the optimized version
608 blood->leType = LE_FALL_SCALE_FADE;
609 blood->leType = LE_GORE;
610 blood->pos.trType = TR_GRAVITY;
611 VectorCopy( velocity, blood->pos.trDelta );
612 blood->pos.trDelta[2] = 55;
613 if (crandom() < 0.5){
614 blood->leMarkType = LEMT_BURN;
615 blood->leBounceSoundType = LEBS_BLOOD;
616 }
617 // VectorCopy( velocity, blood->pos.trDelta );
618
619 }
620 /*
621 ==================
622 CG_LaunchGib
623 ==================
624 */
625 void CG_LaunchGib( vec3_t origin, vec3_t velocity, qhandle_t hModel ) {
626 localEntity_t *le;
627 refEntity_t *re;
628
629 le = CG_AllocLocalEntity();
630 re = &le->refEntity;
631
632 le->leType = LE_FRAGMENT;
633 le->startTime = cg.time;
634 le->endTime = le->startTime + 5000 + random() * 3000;
635
636 VectorCopy( origin, re->origin );
637 AxisCopy( axisDefault, re->axis );
638 re->hModel = hModel;
639
640 le->pos.trType = TR_GRAVITY;
641 VectorCopy( origin, le->pos.trBase );
642 VectorCopy( velocity, le->pos.trDelta );
643 le->pos.trTime = cg.time;
644
645 le->bounceFactor = 0.6f;
646
647 le->leBounceSoundType = LEBS_BLOOD;
648 le->leMarkType = LEMT_BLOOD;
649 if ( cg_leiSuperGoreyAwesome.integer ) {
650 CG_SpurtBlood( origin, velocity, 7); // LEILEI toss some extra juice
651 CG_SpurtBlood( origin, velocity, 22);
652 CG_SpurtBlood( origin, velocity, 11);
653 }
654
655 }
656
657
658
659
660
661 /*
662 ===================
663 CG_GibPlayer
664
665 Generated a bunch of gibs launching out from the bodies location
666 ===================
667 */
668 #define GIB_VELOCITY 250
669 #define GIB_JUMP 250
670 void CG_GibPlayer( vec3_t playerOrigin ) {
671 vec3_t origin, velocity;
672
673 if ( !cg_blood.integer ) {
674 return;
675 }
676
677 VectorCopy( playerOrigin, origin );
678 velocity[0] = crandom()*GIB_VELOCITY;
679 velocity[1] = crandom()*GIB_VELOCITY;
680 velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;
681 if ( rand() & 1 ) {
682 CG_LaunchGib( origin, velocity, cgs.media.gibSkull );
683 } else {
684 CG_LaunchGib( origin, velocity, cgs.media.gibBrain );
685 }
686
687 // allow gibs to be turned off for speed
688 if ( !cg_gibs.integer ) {
689 return;
690 }
691
692 VectorCopy( playerOrigin, origin );
693 velocity[0] = crandom()*GIB_VELOCITY;
694 velocity[1] = crandom()*GIB_VELOCITY;
695 velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;
696 CG_LaunchGib( origin, velocity, cgs.media.gibAbdomen );
697
698 VectorCopy( playerOrigin, origin );
699 velocity[0] = crandom()*GIB_VELOCITY;
700 velocity[1] = crandom()*GIB_VELOCITY;
701 velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;
702 CG_LaunchGib( origin, velocity, cgs.media.gibArm );
703
704 VectorCopy( playerOrigin, origin );
705 velocity[0] = crandom()*GIB_VELOCITY;
706 velocity[1] = crandom()*GIB_VELOCITY;
707 velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;
708 CG_LaunchGib( origin, velocity, cgs.media.gibChest );
709
710 VectorCopy( playerOrigin, origin );
711 velocity[0] = crandom()*GIB_VELOCITY;
712 velocity[1] = crandom()*GIB_VELOCITY;
713 velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;
714 CG_LaunchGib( origin, velocity, cgs.media.gibFist );
715
716 VectorCopy( playerOrigin, origin );
717 velocity[0] = crandom()*GIB_VELOCITY;
718 velocity[1] = crandom()*GIB_VELOCITY;
719 velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;
720 CG_LaunchGib( origin, velocity, cgs.media.gibFoot );
721
722 VectorCopy( playerOrigin, origin );
723 velocity[0] = crandom()*GIB_VELOCITY;
724 velocity[1] = crandom()*GIB_VELOCITY;
725 velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;
726 CG_LaunchGib( origin, velocity, cgs.media.gibForearm );
727
728 VectorCopy( playerOrigin, origin );
729 velocity[0] = crandom()*GIB_VELOCITY;
730 velocity[1] = crandom()*GIB_VELOCITY;
731 velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;
732 CG_LaunchGib( origin, velocity, cgs.media.gibIntestine );
733
734 VectorCopy( playerOrigin, origin );
735 velocity[0] = crandom()*GIB_VELOCITY;
736 velocity[1] = crandom()*GIB_VELOCITY;
737 velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;
738 CG_LaunchGib( origin, velocity, cgs.media.gibLeg );
739
740 VectorCopy( playerOrigin, origin );
741 velocity[0] = crandom()*GIB_VELOCITY;
742 velocity[1] = crandom()*GIB_VELOCITY;
743 velocity[2] = GIB_JUMP + crandom()*GIB_VELOCITY;
744 CG_LaunchGib( origin, velocity, cgs.media.gibLeg );
745 }
746
747 /*
748 ==================
749 CG_LaunchGib
750 ==================
751 */
752 void CG_LaunchExplode( vec3_t origin, vec3_t velocity, qhandle_t hModel ) {
753 localEntity_t *le;
754 refEntity_t *re;
755
756 le = CG_AllocLocalEntity();
757 re = &le->refEntity;
758
759 le->leType = LE_FRAGMENT;
760 le->startTime = cg.time;
761 le->endTime = le->startTime + 10000 + random() * 6000;
762
763 VectorCopy( origin, re->origin );
764 AxisCopy( axisDefault, re->axis );
765 re->hModel = hModel;
766
767 le->pos.trType = TR_GRAVITY;
768 VectorCopy( origin, le->pos.trBase );
769 VectorCopy( velocity, le->pos.trDelta );
770 le->pos.trTime = cg.time;
771
772 le->bounceFactor = 0.1f;
773
774 le->leBounceSoundType = LEBS_BRASS;
775 le->leMarkType = LEMT_NONE;
776 }
777
778 #define EXP_VELOCITY 100
779 #define EXP_JUMP 150
780 /*
781 ===================
782 CG_GibPlayer
783
784 Generated a bunch of gibs launching out from the bodies location
785 ===================
786 */
787 void CG_BigExplosion( vec3_t playerOrigin ) {
788 vec3_t origin, velocity;
789
790 if ( !cg_blood.integer ) {
791 return;
792 }
793
794 VectorCopy( playerOrigin, origin );
795 velocity[0] = crandom()*EXP_VELOCITY;
796 velocity[1] = crandom()*EXP_VELOCITY;
797 velocity[2] = EXP_JUMP + crandom()*EXP_VELOCITY;
798 CG_LaunchExplode( origin, velocity, cgs.media.smoke2 );
799
800 VectorCopy( playerOrigin, origin );
801 velocity[0] = crandom()*EXP_VELOCITY;
802 velocity[1] = crandom()*EXP_VELOCITY;
803 velocity[2] = EXP_JUMP + crandom()*EXP_VELOCITY;
804 CG_LaunchExplode( origin, velocity, cgs.media.smoke2 );
805
806 VectorCopy( playerOrigin, origin );
807 velocity[0] = crandom()*EXP_VELOCITY*1.5;
808 velocity[1] = crandom()*EXP_VELOCITY*1.5;
809 velocity[2] = EXP_JUMP + crandom()*EXP_VELOCITY;
810 CG_LaunchExplode( origin, velocity, cgs.media.smoke2 );
811
812 VectorCopy( playerOrigin, origin );
813 velocity[0] = crandom()*EXP_VELOCITY*2.0;
814 velocity[1] = crandom()*EXP_VELOCITY*2.0;
815 velocity[2] = EXP_JUMP + crandom()*EXP_VELOCITY;
816 CG_LaunchExplode( origin, velocity, cgs.media.smoke2 );
817
818 VectorCopy( playerOrigin, origin );
819 velocity[0] = crandom()*EXP_VELOCITY*2.5;
820 velocity[1] = crandom()*EXP_VELOCITY*2.5;
821 velocity[2] = EXP_JUMP + crandom()*EXP_VELOCITY;
822 CG_LaunchExplode( origin, velocity, cgs.media.smoke2 );
823 }
824
825
826
827
828