| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
#include "cg_local.h" |
| 28 |
|
| 29 |
#define MAX_LOCAL_ENTITIES 512 |
| 30 |
localEntity_t cg_localEntities[MAX_LOCAL_ENTITIES]; |
| 31 |
localEntity_t cg_activeLocalEntities; |
| 32 |
localEntity_t *cg_freeLocalEntities; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
void CG_InitLocalEntities( void ) { |
| 42 |
int i; |
| 43 |
|
| 44 |
memset( cg_localEntities, 0, sizeof( cg_localEntities ) ); |
| 45 |
cg_activeLocalEntities.next = &cg_activeLocalEntities; |
| 46 |
cg_activeLocalEntities.prev = &cg_activeLocalEntities; |
| 47 |
cg_freeLocalEntities = cg_localEntities; |
| 48 |
for ( i = 0 ; i < MAX_LOCAL_ENTITIES - 1 ; i++ ) { |
| 49 |
cg_localEntities[i].next = &cg_localEntities[i+1]; |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
void CG_FreeLocalEntity( localEntity_t *le ) { |
| 60 |
if ( !le->prev ) { |
| 61 |
CG_Error( "CG_FreeLocalEntity: not active" ); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
le->prev->next = le->next; |
| 66 |
le->next->prev = le->prev; |
| 67 |
|
| 68 |
|
| 69 |
le->next = cg_freeLocalEntities; |
| 70 |
cg_freeLocalEntities = le; |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
localEntity_t *CG_AllocLocalEntity( void ) { |
| 81 |
localEntity_t *le; |
| 82 |
|
| 83 |
if ( !cg_freeLocalEntities ) { |
| 84 |
|
| 85 |
|
| 86 |
CG_FreeLocalEntity( cg_activeLocalEntities.prev ); |
| 87 |
} |
| 88 |
|
| 89 |
le = cg_freeLocalEntities; |
| 90 |
cg_freeLocalEntities = cg_freeLocalEntities->next; |
| 91 |
|
| 92 |
memset( le, 0, sizeof( *le ) ); |
| 93 |
|
| 94 |
|
| 95 |
le->next = cg_activeLocalEntities.next; |
| 96 |
le->prev = &cg_activeLocalEntities; |
| 97 |
cg_activeLocalEntities.next->prev = le; |
| 98 |
cg_activeLocalEntities.next = le; |
| 99 |
return le; |
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
void CG_BloodTrail( localEntity_t *le ) { |
| 122 |
int t; |
| 123 |
int t2; |
| 124 |
int step; |
| 125 |
vec3_t newOrigin; |
| 126 |
localEntity_t *blood; |
| 127 |
|
| 128 |
step = 150; |
| 129 |
t = step * ( (cg.time - cg.frametime + step ) / step ); |
| 130 |
t2 = step * ( cg.time / step ); |
| 131 |
|
| 132 |
for ( ; t <= t2; t += step ) { |
| 133 |
BG_EvaluateTrajectory( &le->pos, t, newOrigin ); |
| 134 |
|
| 135 |
blood = CG_SmokePuff( newOrigin, vec3_origin, |
| 136 |
20, |
| 137 |
1, 1, 1, 1, |
| 138 |
2000, |
| 139 |
t, |
| 140 |
0, |
| 141 |
0, |
| 142 |
cgs.media.bloodTrailShader ); |
| 143 |
|
| 144 |
blood->leType = LE_FALL_SCALE_FADE; |
| 145 |
|
| 146 |
blood->pos.trDelta[2] = 40; |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
void CG_FragmentBounceMark( localEntity_t *le, trace_t *trace ) { |
| 157 |
int radius; |
| 158 |
|
| 159 |
if ( le->leMarkType == LEMT_BLOOD ) { |
| 160 |
|
| 161 |
radius = 16 + (rand()&31); |
| 162 |
CG_ImpactMark( cgs.media.bloodMarkShader, trace->endpos, trace->plane.normal, random()*360, |
| 163 |
1,1,1,1, qtrue, radius, qfalse ); |
| 164 |
} else if ( le->leMarkType == LEMT_BURN ) { |
| 165 |
|
| 166 |
radius = 8 + (rand()&15); |
| 167 |
CG_ImpactMark( cgs.media.burnMarkShader, trace->endpos, trace->plane.normal, random()*360, |
| 168 |
1,1,1,1, qtrue, radius, qfalse ); |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
le->leMarkType = LEMT_NONE; |
| 175 |
} |
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
void CG_FragmentBounceSound( localEntity_t *le, trace_t *trace ) { |
| 183 |
if ( le->leBounceSoundType == LEBS_BLOOD ) { |
| 184 |
|
| 185 |
if ( rand() & 1 ) { |
| 186 |
int r = rand()&3; |
| 187 |
sfxHandle_t s; |
| 188 |
|
| 189 |
if ( r == 0 ) { |
| 190 |
s = cgs.media.gibBounce1Sound; |
| 191 |
} else if ( r == 1 ) { |
| 192 |
s = cgs.media.gibBounce2Sound; |
| 193 |
} else { |
| 194 |
s = cgs.media.gibBounce3Sound; |
| 195 |
} |
| 196 |
trap_S_StartSound( trace->endpos, ENTITYNUM_WORLD, CHAN_AUTO, s ); |
| 197 |
} |
| 198 |
} else if ( le->leBounceSoundType == LEBS_BRASS ) { |
| 199 |
|
| 200 |
} |
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
le->leBounceSoundType = LEBS_NONE; |
| 205 |
} |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
void CG_ReflectVelocity( localEntity_t *le, trace_t *trace ) { |
| 214 |
vec3_t velocity; |
| 215 |
float dot; |
| 216 |
int hitTime; |
| 217 |
|
| 218 |
|
| 219 |
hitTime = cg.time - cg.frametime + cg.frametime * trace->fraction; |
| 220 |
BG_EvaluateTrajectoryDelta( &le->pos, hitTime, velocity ); |
| 221 |
dot = DotProduct( velocity, trace->plane.normal ); |
| 222 |
VectorMA( velocity, -2*dot, trace->plane.normal, le->pos.trDelta ); |
| 223 |
|
| 224 |
VectorScale( le->pos.trDelta, le->bounceFactor, le->pos.trDelta ); |
| 225 |
|
| 226 |
VectorCopy( trace->endpos, le->pos.trBase ); |
| 227 |
le->pos.trTime = cg.time; |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
if ( trace->allsolid || |
| 232 |
( trace->plane.normal[2] > 0 && |
| 233 |
( le->pos.trDelta[2] < 40 || le->pos.trDelta[2] < -cg.frametime * le->pos.trDelta[2] ) ) ) { |
| 234 |
le->pos.trType = TR_STATIONARY; |
| 235 |
} else { |
| 236 |
|
| 237 |
} |
| 238 |
} |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
void CG_AddFragment( localEntity_t *le ) { |
| 246 |
vec3_t newOrigin; |
| 247 |
trace_t trace; |
| 248 |
|
| 249 |
if ( le->pos.trType == TR_STATIONARY ) { |
| 250 |
|
| 251 |
int t; |
| 252 |
float oldZ; |
| 253 |
|
| 254 |
t = le->endTime - cg.time; |
| 255 |
if ( t < SINK_TIME ) { |
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
VectorCopy( le->refEntity.origin, le->refEntity.lightingOrigin ); |
| 260 |
le->refEntity.renderfx |= RF_LIGHTING_ORIGIN; |
| 261 |
oldZ = le->refEntity.origin[2]; |
| 262 |
le->refEntity.origin[2] -= 16 * ( 1.0 - (float)t / SINK_TIME ); |
| 263 |
trap_R_AddRefEntityToScene( &le->refEntity ); |
| 264 |
le->refEntity.origin[2] = oldZ; |
| 265 |
} else { |
| 266 |
trap_R_AddRefEntityToScene( &le->refEntity ); |
| 267 |
} |
| 268 |
|
| 269 |
return; |
| 270 |
} |
| 271 |
|
| 272 |
|
| 273 |
BG_EvaluateTrajectory( &le->pos, cg.time, newOrigin ); |
| 274 |
|
| 275 |
|
| 276 |
CG_Trace( &trace, le->refEntity.origin, NULL, NULL, newOrigin, -1, CONTENTS_SOLID ); |
| 277 |
if ( trace.fraction == 1.0 ) { |
| 278 |
|
| 279 |
VectorCopy( newOrigin, le->refEntity.origin ); |
| 280 |
|
| 281 |
if ( le->leFlags & LEF_TUMBLE ) { |
| 282 |
vec3_t angles; |
| 283 |
|
| 284 |
BG_EvaluateTrajectory( &le->angles, cg.time, angles ); |
| 285 |
AnglesToAxis( angles, le->refEntity.axis ); |
| 286 |
} |
| 287 |
|
| 288 |
trap_R_AddRefEntityToScene( &le->refEntity ); |
| 289 |
|
| 290 |
|
| 291 |
if ( le->leBounceSoundType == LEBS_BLOOD ) { |
| 292 |
CG_BloodTrail( le ); |
| 293 |
} |
| 294 |
|
| 295 |
return; |
| 296 |
} |
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
if ( CG_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) { |
| 302 |
CG_FreeLocalEntity( le ); |
| 303 |
return; |
| 304 |
} |
| 305 |
|
| 306 |
|
| 307 |
CG_FragmentBounceMark( le, &trace ); |
| 308 |
|
| 309 |
|
| 310 |
CG_FragmentBounceSound( le, &trace ); |
| 311 |
|
| 312 |
|
| 313 |
CG_ReflectVelocity( le, &trace ); |
| 314 |
|
| 315 |
trap_R_AddRefEntityToScene( &le->refEntity ); |
| 316 |
} |
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
void CG_AddFadeRGB( localEntity_t *le ) { |
| 333 |
refEntity_t *re; |
| 334 |
float c; |
| 335 |
|
| 336 |
re = &le->refEntity; |
| 337 |
|
| 338 |
c = ( le->endTime - cg.time ) * le->lifeRate; |
| 339 |
c *= 0xff; |
| 340 |
|
| 341 |
re->shaderRGBA[0] = le->color[0] * c; |
| 342 |
re->shaderRGBA[1] = le->color[1] * c; |
| 343 |
re->shaderRGBA[2] = le->color[2] * c; |
| 344 |
re->shaderRGBA[3] = le->color[3] * c; |
| 345 |
|
| 346 |
trap_R_AddRefEntityToScene( re ); |
| 347 |
} |
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
static void CG_AddMoveScaleFade( localEntity_t *le ) { |
| 355 |
refEntity_t *re; |
| 356 |
float c; |
| 357 |
vec3_t delta; |
| 358 |
float len; |
| 359 |
|
| 360 |
re = &le->refEntity; |
| 361 |
|
| 362 |
if ( le->fadeInTime > le->startTime && cg.time < le->fadeInTime ) { |
| 363 |
|
| 364 |
c = 1.0 - (float) ( le->fadeInTime - cg.time ) / ( le->fadeInTime - le->startTime ); |
| 365 |
} |
| 366 |
else { |
| 367 |
|
| 368 |
c = ( le->endTime - cg.time ) * le->lifeRate; |
| 369 |
} |
| 370 |
|
| 371 |
re->shaderRGBA[3] = 0xff * c * le->color[3]; |
| 372 |
|
| 373 |
if ( !( le->leFlags & LEF_PUFF_DONT_SCALE ) ) { |
| 374 |
re->radius = le->radius * ( 1.0 - c ) + 8; |
| 375 |
} |
| 376 |
|
| 377 |
BG_EvaluateTrajectory( &le->pos, cg.time, re->origin ); |
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
VectorSubtract( re->origin, cg.refdef.vieworg, delta ); |
| 382 |
len = VectorLength( delta ); |
| 383 |
if ( len < le->radius ) { |
| 384 |
CG_FreeLocalEntity( le ); |
| 385 |
return; |
| 386 |
} |
| 387 |
|
| 388 |
trap_R_AddRefEntityToScene( re ); |
| 389 |
} |
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
static void CG_AddScaleFade( localEntity_t *le ) { |
| 402 |
refEntity_t *re; |
| 403 |
float c; |
| 404 |
vec3_t delta; |
| 405 |
float len; |
| 406 |
|
| 407 |
re = &le->refEntity; |
| 408 |
|
| 409 |
|
| 410 |
c = ( le->endTime - cg.time ) * le->lifeRate; |
| 411 |
|
| 412 |
re->shaderRGBA[3] = 0xff * c * le->color[3]; |
| 413 |
re->radius = le->radius * ( 1.0 - c ) + 8; |
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
VectorSubtract( re->origin, cg.refdef.vieworg, delta ); |
| 418 |
len = VectorLength( delta ); |
| 419 |
if ( len < le->radius ) { |
| 420 |
CG_FreeLocalEntity( le ); |
| 421 |
return; |
| 422 |
} |
| 423 |
|
| 424 |
trap_R_AddRefEntityToScene( re ); |
| 425 |
} |
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
static void CG_AddFallScaleFade( localEntity_t *le ) { |
| 439 |
refEntity_t *re; |
| 440 |
float c; |
| 441 |
vec3_t delta; |
| 442 |
float len; |
| 443 |
|
| 444 |
re = &le->refEntity; |
| 445 |
|
| 446 |
|
| 447 |
c = ( le->endTime - cg.time ) * le->lifeRate; |
| 448 |
|
| 449 |
re->shaderRGBA[3] = 0xff * c * le->color[3]; |
| 450 |
|
| 451 |
re->origin[2] = le->pos.trBase[2] - ( 1.0 - c ) * le->pos.trDelta[2]; |
| 452 |
|
| 453 |
re->radius = le->radius * ( 1.0 - c ) + 16; |
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
VectorSubtract( re->origin, cg.refdef.vieworg, delta ); |
| 458 |
len = VectorLength( delta ); |
| 459 |
if ( len < le->radius ) { |
| 460 |
CG_FreeLocalEntity( le ); |
| 461 |
return; |
| 462 |
} |
| 463 |
|
| 464 |
trap_R_AddRefEntityToScene( re ); |
| 465 |
} |
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
static void CG_AddExplosion( localEntity_t *ex ) { |
| 475 |
refEntity_t *ent; |
| 476 |
|
| 477 |
ent = &ex->refEntity; |
| 478 |
|
| 479 |
|
| 480 |
trap_R_AddRefEntityToScene(ent); |
| 481 |
|
| 482 |
|
| 483 |
if ( ex->light ) { |
| 484 |
float light; |
| 485 |
|
| 486 |
light = (float)( cg.time - ex->startTime ) / ( ex->endTime - ex->startTime ); |
| 487 |
if ( light < 0.5 ) { |
| 488 |
light = 1.0; |
| 489 |
} else { |
| 490 |
light = 1.0 - ( light - 0.5 ) * 2; |
| 491 |
} |
| 492 |
light = ex->light * light; |
| 493 |
trap_R_AddLightToScene(ent->origin, light, ex->lightColor[0], ex->lightColor[1], ex->lightColor[2] ); |
| 494 |
} |
| 495 |
} |
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
static void CG_AddSpriteExplosion( localEntity_t *le ) { |
| 503 |
refEntity_t re; |
| 504 |
float c; |
| 505 |
|
| 506 |
re = le->refEntity; |
| 507 |
|
| 508 |
c = ( le->endTime - cg.time ) / ( float ) ( le->endTime - le->startTime ); |
| 509 |
if ( c > 1 ) { |
| 510 |
c = 1.0; |
| 511 |
} |
| 512 |
|
| 513 |
re.shaderRGBA[0] = 0xff; |
| 514 |
re.shaderRGBA[1] = 0xff; |
| 515 |
re.shaderRGBA[2] = 0xff; |
| 516 |
re.shaderRGBA[3] = 0xff * c * 0.33; |
| 517 |
|
| 518 |
re.reType = RT_SPRITE; |
| 519 |
re.radius = 42 * ( 1.0 - c ) + 30; |
| 520 |
|
| 521 |
trap_R_AddRefEntityToScene( &re ); |
| 522 |
|
| 523 |
|
| 524 |
if ( le->light ) { |
| 525 |
float light; |
| 526 |
|
| 527 |
light = (float)( cg.time - le->startTime ) / ( le->endTime - le->startTime ); |
| 528 |
if ( light < 0.5 ) { |
| 529 |
light = 1.0; |
| 530 |
} else { |
| 531 |
light = 1.0 - ( light - 0.5 ) * 2; |
| 532 |
} |
| 533 |
light = le->light * light; |
| 534 |
trap_R_AddLightToScene(re.origin, light, le->lightColor[0], le->lightColor[1], le->lightColor[2] ); |
| 535 |
} |
| 536 |
} |
| 537 |
|
| 538 |
|
| 539 |
#ifdef MISSIONPACK |
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
void CG_AddKamikaze( localEntity_t *le ) { |
| 546 |
refEntity_t *re; |
| 547 |
refEntity_t shockwave; |
| 548 |
float c; |
| 549 |
vec3_t test, axis[3]; |
| 550 |
int t; |
| 551 |
|
| 552 |
re = &le->refEntity; |
| 553 |
|
| 554 |
t = cg.time - le->startTime; |
| 555 |
VectorClear( test ); |
| 556 |
AnglesToAxis( test, axis ); |
| 557 |
|
| 558 |
if (t > KAMI_SHOCKWAVE_STARTTIME && t < KAMI_SHOCKWAVE_ENDTIME) { |
| 559 |
|
| 560 |
if (!(le->leFlags & LEF_SOUND1)) { |
| 561 |
|
| 562 |
trap_S_StartLocalSound(cgs.media.kamikazeExplodeSound, CHAN_AUTO); |
| 563 |
le->leFlags |= LEF_SOUND1; |
| 564 |
} |
| 565 |
|
| 566 |
memset(&shockwave, 0, sizeof(shockwave)); |
| 567 |
shockwave.hModel = cgs.media.kamikazeShockWave; |
| 568 |
shockwave.reType = RT_MODEL; |
| 569 |
shockwave.shaderTime = re->shaderTime; |
| 570 |
VectorCopy(re->origin, shockwave.origin); |
| 571 |
|
| 572 |
c = (float)(t - KAMI_SHOCKWAVE_STARTTIME) / (float)(KAMI_SHOCKWAVE_ENDTIME - KAMI_SHOCKWAVE_STARTTIME); |
| 573 |
VectorScale( axis[0], c * KAMI_SHOCKWAVE_MAXRADIUS / KAMI_SHOCKWAVEMODEL_RADIUS, shockwave.axis[0] ); |
| 574 |
VectorScale( axis[1], c * KAMI_SHOCKWAVE_MAXRADIUS / KAMI_SHOCKWAVEMODEL_RADIUS, shockwave.axis[1] ); |
| 575 |
VectorScale( axis[2], c * KAMI_SHOCKWAVE_MAXRADIUS / KAMI_SHOCKWAVEMODEL_RADIUS, shockwave.axis[2] ); |
| 576 |
shockwave.nonNormalizedAxes = qtrue; |
| 577 |
|
| 578 |
if (t > KAMI_SHOCKWAVEFADE_STARTTIME) { |
| 579 |
c = (float)(t - KAMI_SHOCKWAVEFADE_STARTTIME) / (float)(KAMI_SHOCKWAVE_ENDTIME - KAMI_SHOCKWAVEFADE_STARTTIME); |
| 580 |
} |
| 581 |
else { |
| 582 |
c = 0; |
| 583 |
} |
| 584 |
c *= 0xff; |
| 585 |
shockwave.shaderRGBA[0] = 0xff - c; |
| 586 |
shockwave.shaderRGBA[1] = 0xff - c; |
| 587 |
shockwave.shaderRGBA[2] = 0xff - c; |
| 588 |
shockwave.shaderRGBA[3] = 0xff - c; |
| 589 |
|
| 590 |
trap_R_AddRefEntityToScene( &shockwave ); |
| 591 |
} |
| 592 |
|
| 593 |
if (t > KAMI_EXPLODE_STARTTIME && t < KAMI_IMPLODE_ENDTIME) { |
| 594 |
|
| 595 |
c = ( le->endTime - cg.time ) * le->lifeRate; |
| 596 |
c *= 0xff; |
| 597 |
re->shaderRGBA[0] = le->color[0] * c; |
| 598 |
re->shaderRGBA[1] = le->color[1] * c; |
| 599 |
re->shaderRGBA[2] = le->color[2] * c; |
| 600 |
re->shaderRGBA[3] = le->color[3] * c; |
| 601 |
|
| 602 |
if( t < KAMI_IMPLODE_STARTTIME ) { |
| 603 |
c = (float)(t - KAMI_EXPLODE_STARTTIME) / (float)(KAMI_IMPLODE_STARTTIME - KAMI_EXPLODE_STARTTIME); |
| 604 |
} |
| 605 |
else { |
| 606 |
if (!(le->leFlags & LEF_SOUND2)) { |
| 607 |
|
| 608 |
trap_S_StartLocalSound(cgs.media.kamikazeImplodeSound, CHAN_AUTO); |
| 609 |
le->leFlags |= LEF_SOUND2; |
| 610 |
} |
| 611 |
c = (float)(KAMI_IMPLODE_ENDTIME - t) / (float) (KAMI_IMPLODE_ENDTIME - KAMI_IMPLODE_STARTTIME); |
| 612 |
} |
| 613 |
VectorScale( axis[0], c * KAMI_BOOMSPHERE_MAXRADIUS / KAMI_BOOMSPHEREMODEL_RADIUS, re->axis[0] ); |
| 614 |
VectorScale( axis[1], c * KAMI_BOOMSPHERE_MAXRADIUS / KAMI_BOOMSPHEREMODEL_RADIUS, re->axis[1] ); |
| 615 |
VectorScale( axis[2], c * KAMI_BOOMSPHERE_MAXRADIUS / KAMI_BOOMSPHEREMODEL_RADIUS, re->axis[2] ); |
| 616 |
re->nonNormalizedAxes = qtrue; |
| 617 |
|
| 618 |
trap_R_AddRefEntityToScene( re ); |
| 619 |
|
| 620 |
trap_R_AddLightToScene( re->origin, c * 1000.0, 1.0, 1.0, c ); |
| 621 |
} |
| 622 |
|
| 623 |
if (t > KAMI_SHOCKWAVE2_STARTTIME && t < KAMI_SHOCKWAVE2_ENDTIME) { |
| 624 |
|
| 625 |
if (le->angles.trBase[0] == 0 && |
| 626 |
le->angles.trBase[1] == 0 && |
| 627 |
le->angles.trBase[2] == 0) { |
| 628 |
le->angles.trBase[0] = random() * 360; |
| 629 |
le->angles.trBase[1] = random() * 360; |
| 630 |
le->angles.trBase[2] = random() * 360; |
| 631 |
} |
| 632 |
memset(&shockwave, 0, sizeof(shockwave)); |
| 633 |
shockwave.hModel = cgs.media.kamikazeShockWave; |
| 634 |
shockwave.reType = RT_MODEL; |
| 635 |
shockwave.shaderTime = re->shaderTime; |
| 636 |
VectorCopy(re->origin, shockwave.origin); |
| 637 |
|
| 638 |
test[0] = le->angles.trBase[0]; |
| 639 |
test[1] = le->angles.trBase[1]; |
| 640 |
test[2] = le->angles.trBase[2]; |
| 641 |
AnglesToAxis( test, axis ); |
| 642 |
|
| 643 |
c = (float)(t - KAMI_SHOCKWAVE2_STARTTIME) / (float)(KAMI_SHOCKWAVE2_ENDTIME - KAMI_SHOCKWAVE2_STARTTIME); |
| 644 |
VectorScale( axis[0], c * KAMI_SHOCKWAVE2_MAXRADIUS / KAMI_SHOCKWAVEMODEL_RADIUS, shockwave.axis[0] ); |
| 645 |
VectorScale( axis[1], c * KAMI_SHOCKWAVE2_MAXRADIUS / KAMI_SHOCKWAVEMODEL_RADIUS, shockwave.axis[1] ); |
| 646 |
VectorScale( axis[2], c * KAMI_SHOCKWAVE2_MAXRADIUS / KAMI_SHOCKWAVEMODEL_RADIUS, shockwave.axis[2] ); |
| 647 |
shockwave.nonNormalizedAxes = qtrue; |
| 648 |
|
| 649 |
if (t > KAMI_SHOCKWAVE2FADE_STARTTIME) { |
| 650 |
c = (float)(t - KAMI_SHOCKWAVE2FADE_STARTTIME) / (float)(KAMI_SHOCKWAVE2_ENDTIME - KAMI_SHOCKWAVE2FADE_STARTTIME); |
| 651 |
} |
| 652 |
else { |
| 653 |
c = 0; |
| 654 |
} |
| 655 |
c *= 0xff; |
| 656 |
shockwave.shaderRGBA[0] = 0xff - c; |
| 657 |
shockwave.shaderRGBA[1] = 0xff - c; |
| 658 |
shockwave.shaderRGBA[2] = 0xff - c; |
| 659 |
shockwave.shaderRGBA[3] = 0xff - c; |
| 660 |
|
| 661 |
trap_R_AddRefEntityToScene( &shockwave ); |
| 662 |
} |
| 663 |
} |
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
void CG_AddInvulnerabilityImpact( localEntity_t *le ) { |
| 671 |
trap_R_AddRefEntityToScene( &le->refEntity ); |
| 672 |
} |
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
void CG_AddInvulnerabilityJuiced( localEntity_t *le ) { |
| 680 |
int t; |
| 681 |
|
| 682 |
t = cg.time - le->startTime; |
| 683 |
if ( t > 3000 ) { |
| 684 |
le->refEntity.axis[0][0] = (float) 1.0 + 0.3 * (t - 3000) / 2000; |
| 685 |
le->refEntity.axis[1][1] = (float) 1.0 + 0.3 * (t - 3000) / 2000; |
| 686 |
le->refEntity.axis[2][2] = (float) 0.7 + 0.3 * (2000 - (t - 3000)) / 2000; |
| 687 |
} |
| 688 |
if ( t > 5000 ) { |
| 689 |
le->endTime = 0; |
| 690 |
CG_GibPlayer( le->refEntity.origin ); |
| 691 |
} |
| 692 |
else { |
| 693 |
trap_R_AddRefEntityToScene( &le->refEntity ); |
| 694 |
} |
| 695 |
} |
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
void CG_AddRefEntity( localEntity_t *le ) { |
| 703 |
if (le->endTime < cg.time) { |
| 704 |
CG_FreeLocalEntity( le ); |
| 705 |
return; |
| 706 |
} |
| 707 |
trap_R_AddRefEntityToScene( &le->refEntity ); |
| 708 |
} |
| 709 |
|
| 710 |
#endif |
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
#define NUMBER_SIZE 8 |
| 717 |
|
| 718 |
void CG_AddScorePlum( localEntity_t *le ) { |
| 719 |
refEntity_t *re; |
| 720 |
vec3_t origin, delta, dir, vec, up = {0, 0, 1}; |
| 721 |
float c, len; |
| 722 |
int i, score, digits[10], numdigits, negative; |
| 723 |
|
| 724 |
re = &le->refEntity; |
| 725 |
|
| 726 |
c = ( le->endTime - cg.time ) * le->lifeRate; |
| 727 |
|
| 728 |
score = le->radius; |
| 729 |
if (score < 0) { |
| 730 |
re->shaderRGBA[0] = 0xff; |
| 731 |
re->shaderRGBA[1] = 0x11; |
| 732 |
re->shaderRGBA[2] = 0x11; |
| 733 |
} |
| 734 |
else { |
| 735 |
re->shaderRGBA[0] = 0xff; |
| 736 |
re->shaderRGBA[1] = 0xff; |
| 737 |
re->shaderRGBA[2] = 0xff; |
| 738 |
if (score >= 50) { |
| 739 |
re->shaderRGBA[1] = 0; |
| 740 |
} else if (score >= 20) { |
| 741 |
re->shaderRGBA[0] = re->shaderRGBA[1] = 0; |
| 742 |
} else if (score >= 10) { |
| 743 |
re->shaderRGBA[2] = 0; |
| 744 |
} else if (score >= 2) { |
| 745 |
re->shaderRGBA[0] = re->shaderRGBA[2] = 0; |
| 746 |
} |
| 747 |
|
| 748 |
} |
| 749 |
if (c < 0.25) |
| 750 |
re->shaderRGBA[3] = 0xff * 4 * c; |
| 751 |
else |
| 752 |
re->shaderRGBA[3] = 0xff; |
| 753 |
|
| 754 |
re->radius = NUMBER_SIZE / 2; |
| 755 |
|
| 756 |
VectorCopy(le->pos.trBase, origin); |
| 757 |
origin[2] += 110 - c * 100; |
| 758 |
|
| 759 |
VectorSubtract(cg.refdef.vieworg, origin, dir); |
| 760 |
CrossProduct(dir, up, vec); |
| 761 |
VectorNormalize(vec); |
| 762 |
|
| 763 |
VectorMA(origin, -10 + 20 * sin(c * 2 * M_PI), vec, origin); |
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
VectorSubtract( origin, cg.refdef.vieworg, delta ); |
| 768 |
len = VectorLength( delta ); |
| 769 |
if ( len < 20 ) { |
| 770 |
CG_FreeLocalEntity( le ); |
| 771 |
return; |
| 772 |
} |
| 773 |
|
| 774 |
negative = qfalse; |
| 775 |
if (score < 0) { |
| 776 |
negative = qtrue; |
| 777 |
score = -score; |
| 778 |
} |
| 779 |
|
| 780 |
for (numdigits = 0; !(numdigits && !score); numdigits++) { |
| 781 |
digits[numdigits] = score % 10; |
| 782 |
score = score / 10; |
| 783 |
} |
| 784 |
|
| 785 |
if (negative) { |
| 786 |
digits[numdigits] = 10; |
| 787 |
numdigits++; |
| 788 |
} |
| 789 |
|
| 790 |
for (i = 0; i < numdigits; i++) { |
| 791 |
VectorMA(origin, (float) (((float) numdigits / 2) - i) * NUMBER_SIZE, vec, re->origin); |
| 792 |
re->customShader = cgs.media.numberShaders[digits[numdigits-1-i]]; |
| 793 |
trap_R_AddRefEntityToScene( re ); |
| 794 |
} |
| 795 |
} |
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
void CG_AddLocalEntities( void ) { |
| 809 |
localEntity_t *le, *next; |
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
le = cg_activeLocalEntities.prev; |
| 814 |
for ( ; le != &cg_activeLocalEntities ; le = next ) { |
| 815 |
|
| 816 |
|
| 817 |
next = le->prev; |
| 818 |
|
| 819 |
if ( cg.time >= le->endTime ) { |
| 820 |
CG_FreeLocalEntity( le ); |
| 821 |
continue; |
| 822 |
} |
| 823 |
switch ( le->leType ) { |
| 824 |
default: |
| 825 |
CG_Error( "Bad leType: %i", le->leType ); |
| 826 |
break; |
| 827 |
|
| 828 |
case LE_MARK: |
| 829 |
break; |
| 830 |
|
| 831 |
case LE_SPRITE_EXPLOSION: |
| 832 |
CG_AddSpriteExplosion( le ); |
| 833 |
break; |
| 834 |
|
| 835 |
case LE_EXPLOSION: |
| 836 |
CG_AddExplosion( le ); |
| 837 |
break; |
| 838 |
|
| 839 |
case LE_FRAGMENT: |
| 840 |
CG_AddFragment( le ); |
| 841 |
break; |
| 842 |
|
| 843 |
case LE_MOVE_SCALE_FADE: |
| 844 |
CG_AddMoveScaleFade( le ); |
| 845 |
break; |
| 846 |
|
| 847 |
case LE_FADE_RGB: |
| 848 |
CG_AddFadeRGB( le ); |
| 849 |
break; |
| 850 |
|
| 851 |
case LE_FALL_SCALE_FADE: |
| 852 |
CG_AddFallScaleFade( le ); |
| 853 |
break; |
| 854 |
|
| 855 |
case LE_SCALE_FADE: |
| 856 |
CG_AddScaleFade( le ); |
| 857 |
break; |
| 858 |
|
| 859 |
case LE_SCOREPLUM: |
| 860 |
CG_AddScorePlum( le ); |
| 861 |
break; |
| 862 |
|
| 863 |
#ifdef MISSIONPACK |
| 864 |
case LE_KAMIKAZE: |
| 865 |
CG_AddKamikaze( le ); |
| 866 |
break; |
| 867 |
case LE_INVULIMPACT: |
| 868 |
CG_AddInvulnerabilityImpact( le ); |
| 869 |
break; |
| 870 |
case LE_INVULJUICED: |
| 871 |
CG_AddInvulnerabilityJuiced( le ); |
| 872 |
break; |
| 873 |
case LE_SHOWREFENTITY: |
| 874 |
CG_AddRefEntity( le ); |
| 875 |
break; |
| 876 |
#endif |
| 877 |
} |
| 878 |
} |
| 879 |
} |
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
|