| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#include "cg_local.h" |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
static void CG_MachineGunEjectBrass( centity_t *cent ) { |
| 32 |
localEntity_t *le; |
| 33 |
refEntity_t *re; |
| 34 |
vec3_t velocity, xvelocity; |
| 35 |
vec3_t offset, xoffset; |
| 36 |
float waterScale = 1.0f; |
| 37 |
vec3_t v[3]; |
| 38 |
|
| 39 |
if ( cg_brassTime.integer <= 0 ) { |
| 40 |
return; |
| 41 |
} |
| 42 |
|
| 43 |
le = CG_AllocLocalEntity(); |
| 44 |
re = &le->refEntity; |
| 45 |
|
| 46 |
velocity[0] = 0; |
| 47 |
velocity[1] = -50 + 40 * crandom(); |
| 48 |
velocity[2] = 100 + 50 * crandom(); |
| 49 |
|
| 50 |
le->leType = LE_FRAGMENT; |
| 51 |
le->startTime = cg.time; |
| 52 |
le->endTime = le->startTime + cg_brassTime.integer + ( cg_brassTime.integer / 4 ) * random(); |
| 53 |
|
| 54 |
le->pos.trType = TR_GRAVITY; |
| 55 |
le->pos.trTime = cg.time - (rand()&15); |
| 56 |
|
| 57 |
AnglesToAxis( cent->lerpAngles, v ); |
| 58 |
|
| 59 |
offset[0] = 8; |
| 60 |
offset[1] = -4; |
| 61 |
offset[2] = 24; |
| 62 |
|
| 63 |
xoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0]; |
| 64 |
xoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1]; |
| 65 |
xoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2]; |
| 66 |
VectorAdd( cent->lerpOrigin, xoffset, re->origin ); |
| 67 |
|
| 68 |
VectorCopy( re->origin, le->pos.trBase ); |
| 69 |
|
| 70 |
if ( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) { |
| 71 |
waterScale = 0.10f; |
| 72 |
} |
| 73 |
|
| 74 |
xvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0]; |
| 75 |
xvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1]; |
| 76 |
xvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2]; |
| 77 |
VectorScale( xvelocity, waterScale, le->pos.trDelta ); |
| 78 |
|
| 79 |
AxisCopy( axisDefault, re->axis ); |
| 80 |
re->hModel = cgs.media.machinegunBrassModel; |
| 81 |
|
| 82 |
le->bounceFactor = 0.4 * waterScale; |
| 83 |
|
| 84 |
le->angles.trType = TR_LINEAR; |
| 85 |
le->angles.trTime = cg.time; |
| 86 |
le->angles.trBase[0] = rand()&31; |
| 87 |
le->angles.trBase[1] = rand()&31; |
| 88 |
le->angles.trBase[2] = rand()&31; |
| 89 |
le->angles.trDelta[0] = 2; |
| 90 |
le->angles.trDelta[1] = 1; |
| 91 |
le->angles.trDelta[2] = 0; |
| 92 |
|
| 93 |
le->leFlags = LEF_TUMBLE; |
| 94 |
le->leBounceSoundType = LEBS_BRASS; |
| 95 |
le->leMarkType = LEMT_NONE; |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
static void CG_ShotgunEjectBrass( centity_t *cent ) { |
| 104 |
localEntity_t *le; |
| 105 |
refEntity_t *re; |
| 106 |
vec3_t velocity, xvelocity; |
| 107 |
vec3_t offset, xoffset; |
| 108 |
vec3_t v[3]; |
| 109 |
int i; |
| 110 |
|
| 111 |
if ( cg_brassTime.integer <= 0 ) { |
| 112 |
return; |
| 113 |
} |
| 114 |
|
| 115 |
for ( i = 0; i < 2; i++ ) { |
| 116 |
float waterScale = 1.0f; |
| 117 |
|
| 118 |
le = CG_AllocLocalEntity(); |
| 119 |
re = &le->refEntity; |
| 120 |
|
| 121 |
velocity[0] = 60 + 60 * crandom(); |
| 122 |
if ( i == 0 ) { |
| 123 |
velocity[1] = 40 + 10 * crandom(); |
| 124 |
} else { |
| 125 |
velocity[1] = -40 + 10 * crandom(); |
| 126 |
} |
| 127 |
velocity[2] = 100 + 50 * crandom(); |
| 128 |
|
| 129 |
le->leType = LE_FRAGMENT; |
| 130 |
le->startTime = cg.time; |
| 131 |
le->endTime = le->startTime + cg_brassTime.integer*3 + cg_brassTime.integer * random(); |
| 132 |
|
| 133 |
le->pos.trType = TR_GRAVITY; |
| 134 |
le->pos.trTime = cg.time; |
| 135 |
|
| 136 |
AnglesToAxis( cent->lerpAngles, v ); |
| 137 |
|
| 138 |
offset[0] = 8; |
| 139 |
offset[1] = 0; |
| 140 |
offset[2] = 24; |
| 141 |
|
| 142 |
xoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0]; |
| 143 |
xoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1]; |
| 144 |
xoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2]; |
| 145 |
VectorAdd( cent->lerpOrigin, xoffset, re->origin ); |
| 146 |
VectorCopy( re->origin, le->pos.trBase ); |
| 147 |
if ( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) { |
| 148 |
waterScale = 0.10f; |
| 149 |
} |
| 150 |
|
| 151 |
xvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0]; |
| 152 |
xvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1]; |
| 153 |
xvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2]; |
| 154 |
VectorScale( xvelocity, waterScale, le->pos.trDelta ); |
| 155 |
|
| 156 |
AxisCopy( axisDefault, re->axis ); |
| 157 |
re->hModel = cgs.media.shotgunBrassModel; |
| 158 |
le->bounceFactor = 0.3f; |
| 159 |
|
| 160 |
le->angles.trType = TR_LINEAR; |
| 161 |
le->angles.trTime = cg.time; |
| 162 |
le->angles.trBase[0] = rand()&31; |
| 163 |
le->angles.trBase[1] = rand()&31; |
| 164 |
le->angles.trBase[2] = rand()&31; |
| 165 |
le->angles.trDelta[0] = 1; |
| 166 |
le->angles.trDelta[1] = 0.5; |
| 167 |
le->angles.trDelta[2] = 0; |
| 168 |
|
| 169 |
le->leFlags = LEF_TUMBLE; |
| 170 |
le->leBounceSoundType = LEBS_BRASS; |
| 171 |
le->leMarkType = LEMT_NONE; |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
|
| 176 |
#ifdef MISSIONPACK |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
static void CG_NailgunEjectBrass( centity_t *cent ) { |
| 183 |
localEntity_t *smoke; |
| 184 |
vec3_t origin; |
| 185 |
vec3_t v[3]; |
| 186 |
vec3_t offset; |
| 187 |
vec3_t xoffset; |
| 188 |
vec3_t up; |
| 189 |
|
| 190 |
AnglesToAxis( cent->lerpAngles, v ); |
| 191 |
|
| 192 |
offset[0] = 0; |
| 193 |
offset[1] = -12; |
| 194 |
offset[2] = 24; |
| 195 |
|
| 196 |
xoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0]; |
| 197 |
xoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1]; |
| 198 |
xoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2]; |
| 199 |
VectorAdd( cent->lerpOrigin, xoffset, origin ); |
| 200 |
|
| 201 |
VectorSet( up, 0, 0, 64 ); |
| 202 |
|
| 203 |
smoke = CG_SmokePuff( origin, up, 32, 1, 1, 1, 0.33f, 700, cg.time, 0, 0, cgs.media.smokePuffShader ); |
| 204 |
|
| 205 |
smoke->leType = LE_SCALE_FADE; |
| 206 |
} |
| 207 |
#endif |
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
void CG_RailTrail (clientInfo_t *ci, vec3_t start, vec3_t end) { |
| 216 |
vec3_t axis[36], move, move2, vec, temp; |
| 217 |
float len; |
| 218 |
int i, j, skip; |
| 219 |
|
| 220 |
localEntity_t *le; |
| 221 |
refEntity_t *re; |
| 222 |
|
| 223 |
#define RADIUS 4 |
| 224 |
#define ROTATION 1 |
| 225 |
#define SPACING 5 |
| 226 |
|
| 227 |
start[2] -= 4; |
| 228 |
|
| 229 |
le = CG_AllocLocalEntity(); |
| 230 |
re = &le->refEntity; |
| 231 |
|
| 232 |
le->leType = LE_FADE_RGB; |
| 233 |
le->startTime = cg.time; |
| 234 |
le->endTime = cg.time + cg_railTrailTime.value; |
| 235 |
le->lifeRate = 1.0 / (le->endTime - le->startTime); |
| 236 |
|
| 237 |
re->shaderTime = cg.time / 1000.0f; |
| 238 |
re->reType = RT_RAIL_CORE; |
| 239 |
re->customShader = cgs.media.railCoreShader; |
| 240 |
|
| 241 |
VectorCopy(start, re->origin); |
| 242 |
VectorCopy(end, re->oldorigin); |
| 243 |
|
| 244 |
re->shaderRGBA[0] = ci->color1[0] * 255; |
| 245 |
re->shaderRGBA[1] = ci->color1[1] * 255; |
| 246 |
re->shaderRGBA[2] = ci->color1[2] * 255; |
| 247 |
re->shaderRGBA[3] = 255; |
| 248 |
|
| 249 |
le->color[0] = ci->color1[0] * 0.75; |
| 250 |
le->color[1] = ci->color1[1] * 0.75; |
| 251 |
le->color[2] = ci->color1[2] * 0.75; |
| 252 |
le->color[3] = 1.0f; |
| 253 |
|
| 254 |
AxisClear( re->axis ); |
| 255 |
|
| 256 |
if (cg_oldRail.integer) |
| 257 |
{ |
| 258 |
|
| 259 |
re->origin[2] -= 8; |
| 260 |
re->oldorigin[2] -= 8; |
| 261 |
return; |
| 262 |
} |
| 263 |
|
| 264 |
VectorCopy (start, move); |
| 265 |
VectorSubtract (end, start, vec); |
| 266 |
len = VectorNormalize (vec); |
| 267 |
PerpendicularVector(temp, vec); |
| 268 |
for (i = 0 ; i < 36; i++) |
| 269 |
{ |
| 270 |
RotatePointAroundVector(axis[i], vec, temp, i * 10); |
| 271 |
} |
| 272 |
|
| 273 |
VectorMA(move, 20, vec, move); |
| 274 |
VectorScale (vec, SPACING, vec); |
| 275 |
|
| 276 |
skip = -1; |
| 277 |
|
| 278 |
j = 18; |
| 279 |
for (i = 0; i < len; i += SPACING) |
| 280 |
{ |
| 281 |
if (i != skip) |
| 282 |
{ |
| 283 |
skip = i + SPACING; |
| 284 |
le = CG_AllocLocalEntity(); |
| 285 |
re = &le->refEntity; |
| 286 |
le->leFlags = LEF_PUFF_DONT_SCALE; |
| 287 |
le->leType = LE_MOVE_SCALE_FADE; |
| 288 |
le->startTime = cg.time; |
| 289 |
le->endTime = cg.time + (i>>1) + 600; |
| 290 |
le->lifeRate = 1.0 / (le->endTime - le->startTime); |
| 291 |
|
| 292 |
re->shaderTime = cg.time / 1000.0f; |
| 293 |
re->reType = RT_SPRITE; |
| 294 |
re->radius = 1.1f; |
| 295 |
re->customShader = cgs.media.railRingsShader; |
| 296 |
|
| 297 |
re->shaderRGBA[0] = ci->color2[0] * 255; |
| 298 |
re->shaderRGBA[1] = ci->color2[1] * 255; |
| 299 |
re->shaderRGBA[2] = ci->color2[2] * 255; |
| 300 |
re->shaderRGBA[3] = 255; |
| 301 |
|
| 302 |
le->color[0] = ci->color2[0] * 0.75; |
| 303 |
le->color[1] = ci->color2[1] * 0.75; |
| 304 |
le->color[2] = ci->color2[2] * 0.75; |
| 305 |
le->color[3] = 1.0f; |
| 306 |
|
| 307 |
le->pos.trType = TR_LINEAR; |
| 308 |
le->pos.trTime = cg.time; |
| 309 |
|
| 310 |
VectorCopy( move, move2); |
| 311 |
VectorMA(move2, RADIUS , axis[j], move2); |
| 312 |
VectorCopy(move2, le->pos.trBase); |
| 313 |
|
| 314 |
le->pos.trDelta[0] = axis[j][0]*6; |
| 315 |
le->pos.trDelta[1] = axis[j][1]*6; |
| 316 |
le->pos.trDelta[2] = axis[j][2]*6; |
| 317 |
} |
| 318 |
|
| 319 |
VectorAdd (move, vec, move); |
| 320 |
|
| 321 |
j = (j + ROTATION) % 36; |
| 322 |
} |
| 323 |
} |
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
static void CG_RocketTrail( centity_t *ent, const weaponInfo_t *wi ) { |
| 331 |
int step; |
| 332 |
vec3_t origin, lastPos; |
| 333 |
int t; |
| 334 |
int startTime, contents; |
| 335 |
int lastContents; |
| 336 |
entityState_t *es; |
| 337 |
vec3_t up; |
| 338 |
localEntity_t *smoke; |
| 339 |
|
| 340 |
if ( cg_noProjectileTrail.integer ) { |
| 341 |
return; |
| 342 |
} |
| 343 |
|
| 344 |
up[0] = 0; |
| 345 |
up[1] = 0; |
| 346 |
up[2] = 0; |
| 347 |
|
| 348 |
step = 50; |
| 349 |
|
| 350 |
es = &ent->currentState; |
| 351 |
startTime = ent->trailTime; |
| 352 |
t = step * ( (startTime + step) / step ); |
| 353 |
|
| 354 |
BG_EvaluateTrajectory( &es->pos, cg.time, origin ); |
| 355 |
contents = CG_PointContents( origin, -1 ); |
| 356 |
|
| 357 |
|
| 358 |
if ( es->pos.trType == TR_STATIONARY ) { |
| 359 |
ent->trailTime = cg.time; |
| 360 |
return; |
| 361 |
} |
| 362 |
|
| 363 |
BG_EvaluateTrajectory( &es->pos, ent->trailTime, lastPos ); |
| 364 |
lastContents = CG_PointContents( lastPos, -1 ); |
| 365 |
|
| 366 |
ent->trailTime = cg.time; |
| 367 |
|
| 368 |
if ( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) { |
| 369 |
if ( contents & lastContents & CONTENTS_WATER ) { |
| 370 |
CG_BubbleTrail( lastPos, origin, 8 ); |
| 371 |
} |
| 372 |
return; |
| 373 |
} |
| 374 |
|
| 375 |
for ( ; t <= ent->trailTime ; t += step ) { |
| 376 |
BG_EvaluateTrajectory( &es->pos, t, lastPos ); |
| 377 |
|
| 378 |
smoke = CG_SmokePuff( lastPos, up, |
| 379 |
wi->trailRadius, |
| 380 |
1, 1, 1, 0.33f, |
| 381 |
wi->wiTrailTime, |
| 382 |
t, |
| 383 |
0, |
| 384 |
0, |
| 385 |
cgs.media.smokePuffShader ); |
| 386 |
|
| 387 |
smoke->leType = LE_SCALE_FADE; |
| 388 |
} |
| 389 |
|
| 390 |
} |
| 391 |
|
| 392 |
#ifdef MISSIONPACK |
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
static void CG_NailTrail( centity_t *ent, const weaponInfo_t *wi ) { |
| 399 |
int step; |
| 400 |
vec3_t origin, lastPos; |
| 401 |
int t; |
| 402 |
int startTime, contents; |
| 403 |
int lastContents; |
| 404 |
entityState_t *es; |
| 405 |
vec3_t up; |
| 406 |
localEntity_t *smoke; |
| 407 |
|
| 408 |
if ( cg_noProjectileTrail.integer ) { |
| 409 |
return; |
| 410 |
} |
| 411 |
|
| 412 |
up[0] = 0; |
| 413 |
up[1] = 0; |
| 414 |
up[2] = 0; |
| 415 |
|
| 416 |
step = 50; |
| 417 |
|
| 418 |
es = &ent->currentState; |
| 419 |
startTime = ent->trailTime; |
| 420 |
t = step * ( (startTime + step) / step ); |
| 421 |
|
| 422 |
BG_EvaluateTrajectory( &es->pos, cg.time, origin ); |
| 423 |
contents = CG_PointContents( origin, -1 ); |
| 424 |
|
| 425 |
|
| 426 |
if ( es->pos.trType == TR_STATIONARY ) { |
| 427 |
ent->trailTime = cg.time; |
| 428 |
return; |
| 429 |
} |
| 430 |
|
| 431 |
BG_EvaluateTrajectory( &es->pos, ent->trailTime, lastPos ); |
| 432 |
lastContents = CG_PointContents( lastPos, -1 ); |
| 433 |
|
| 434 |
ent->trailTime = cg.time; |
| 435 |
|
| 436 |
if ( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) { |
| 437 |
if ( contents & lastContents & CONTENTS_WATER ) { |
| 438 |
CG_BubbleTrail( lastPos, origin, 8 ); |
| 439 |
} |
| 440 |
return; |
| 441 |
} |
| 442 |
|
| 443 |
for ( ; t <= ent->trailTime ; t += step ) { |
| 444 |
BG_EvaluateTrajectory( &es->pos, t, lastPos ); |
| 445 |
|
| 446 |
smoke = CG_SmokePuff( lastPos, up, |
| 447 |
wi->trailRadius, |
| 448 |
1, 1, 1, 0.33f, |
| 449 |
wi->wiTrailTime, |
| 450 |
t, |
| 451 |
0, |
| 452 |
0, |
| 453 |
cgs.media.nailPuffShader ); |
| 454 |
|
| 455 |
smoke->leType = LE_SCALE_FADE; |
| 456 |
} |
| 457 |
|
| 458 |
} |
| 459 |
#endif |
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
static void CG_PlasmaTrail( centity_t *cent, const weaponInfo_t *wi ) { |
| 467 |
localEntity_t *le; |
| 468 |
refEntity_t *re; |
| 469 |
entityState_t *es; |
| 470 |
vec3_t velocity, xvelocity, origin; |
| 471 |
vec3_t offset, xoffset; |
| 472 |
vec3_t v[3]; |
| 473 |
|
| 474 |
float waterScale = 1.0f; |
| 475 |
|
| 476 |
if ( cg_noProjectileTrail.integer || cg_oldPlasma.integer ) { |
| 477 |
return; |
| 478 |
} |
| 479 |
|
| 480 |
es = ¢->currentState; |
| 481 |
|
| 482 |
BG_EvaluateTrajectory( &es->pos, cg.time, origin ); |
| 483 |
|
| 484 |
le = CG_AllocLocalEntity(); |
| 485 |
re = &le->refEntity; |
| 486 |
|
| 487 |
velocity[0] = 60 - 120 * crandom(); |
| 488 |
velocity[1] = 40 - 80 * crandom(); |
| 489 |
velocity[2] = 100 - 200 * crandom(); |
| 490 |
|
| 491 |
le->leType = LE_MOVE_SCALE_FADE; |
| 492 |
le->leFlags = LEF_TUMBLE; |
| 493 |
le->leBounceSoundType = LEBS_NONE; |
| 494 |
le->leMarkType = LEMT_NONE; |
| 495 |
|
| 496 |
le->startTime = cg.time; |
| 497 |
le->endTime = le->startTime + 600; |
| 498 |
|
| 499 |
le->pos.trType = TR_GRAVITY; |
| 500 |
le->pos.trTime = cg.time; |
| 501 |
|
| 502 |
AnglesToAxis( cent->lerpAngles, v ); |
| 503 |
|
| 504 |
offset[0] = 2; |
| 505 |
offset[1] = 2; |
| 506 |
offset[2] = 2; |
| 507 |
|
| 508 |
xoffset[0] = offset[0] * v[0][0] + offset[1] * v[1][0] + offset[2] * v[2][0]; |
| 509 |
xoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1]; |
| 510 |
xoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2]; |
| 511 |
|
| 512 |
VectorAdd( origin, xoffset, re->origin ); |
| 513 |
VectorCopy( re->origin, le->pos.trBase ); |
| 514 |
|
| 515 |
if ( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) { |
| 516 |
waterScale = 0.10f; |
| 517 |
} |
| 518 |
|
| 519 |
xvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0]; |
| 520 |
xvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1]; |
| 521 |
xvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2]; |
| 522 |
VectorScale( xvelocity, waterScale, le->pos.trDelta ); |
| 523 |
|
| 524 |
AxisCopy( axisDefault, re->axis ); |
| 525 |
re->shaderTime = cg.time / 1000.0f; |
| 526 |
re->reType = RT_SPRITE; |
| 527 |
re->radius = 0.25f; |
| 528 |
re->customShader = cgs.media.railRingsShader; |
| 529 |
le->bounceFactor = 0.3f; |
| 530 |
|
| 531 |
re->shaderRGBA[0] = wi->flashDlightColor[0] * 63; |
| 532 |
re->shaderRGBA[1] = wi->flashDlightColor[1] * 63; |
| 533 |
re->shaderRGBA[2] = wi->flashDlightColor[2] * 63; |
| 534 |
re->shaderRGBA[3] = 63; |
| 535 |
|
| 536 |
le->color[0] = wi->flashDlightColor[0] * 0.2; |
| 537 |
le->color[1] = wi->flashDlightColor[1] * 0.2; |
| 538 |
le->color[2] = wi->flashDlightColor[2] * 0.2; |
| 539 |
le->color[3] = 0.25f; |
| 540 |
|
| 541 |
le->angles.trType = TR_LINEAR; |
| 542 |
le->angles.trTime = cg.time; |
| 543 |
le->angles.trBase[0] = rand()&31; |
| 544 |
le->angles.trBase[1] = rand()&31; |
| 545 |
le->angles.trBase[2] = rand()&31; |
| 546 |
le->angles.trDelta[0] = 1; |
| 547 |
le->angles.trDelta[1] = 0.5; |
| 548 |
le->angles.trDelta[2] = 0; |
| 549 |
|
| 550 |
} |
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
void CG_GrappleTrail( centity_t *ent, const weaponInfo_t *wi ) { |
| 557 |
vec3_t origin; |
| 558 |
entityState_t *es; |
| 559 |
vec3_t forward, up; |
| 560 |
refEntity_t beam; |
| 561 |
|
| 562 |
es = &ent->currentState; |
| 563 |
|
| 564 |
BG_EvaluateTrajectory( &es->pos, cg.time, origin ); |
| 565 |
ent->trailTime = cg.time; |
| 566 |
|
| 567 |
memset( &beam, 0, sizeof( beam ) ); |
| 568 |
|
| 569 |
VectorCopy ( cg_entities[ ent->currentState.otherEntityNum ].lerpOrigin, beam.origin ); |
| 570 |
beam.origin[2] += 26; |
| 571 |
AngleVectors( cg_entities[ ent->currentState.otherEntityNum ].lerpAngles, forward, NULL, up ); |
| 572 |
VectorMA( beam.origin, -6, up, beam.origin ); |
| 573 |
VectorCopy( origin, beam.oldorigin ); |
| 574 |
|
| 575 |
if (Distance( beam.origin, beam.oldorigin ) < 64 ) |
| 576 |
return; |
| 577 |
|
| 578 |
beam.reType = RT_LIGHTNING; |
| 579 |
beam.customShader = cgs.media.lightningShader; |
| 580 |
|
| 581 |
AxisClear( beam.axis ); |
| 582 |
beam.shaderRGBA[0] = 0xff; |
| 583 |
beam.shaderRGBA[1] = 0xff; |
| 584 |
beam.shaderRGBA[2] = 0xff; |
| 585 |
beam.shaderRGBA[3] = 0xff; |
| 586 |
trap_R_AddRefEntityToScene( &beam ); |
| 587 |
} |
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
static void CG_GrenadeTrail( centity_t *ent, const weaponInfo_t *wi ) { |
| 595 |
CG_RocketTrail( ent, wi ); |
| 596 |
} |
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
void CG_RegisterWeapon( int weaponNum ) { |
| 607 |
weaponInfo_t *weaponInfo; |
| 608 |
gitem_t *item, *ammo; |
| 609 |
char path[MAX_QPATH]; |
| 610 |
vec3_t mins, maxs; |
| 611 |
int i; |
| 612 |
|
| 613 |
weaponInfo = &cg_weapons[weaponNum]; |
| 614 |
|
| 615 |
if ( weaponNum == 0 ) { |
| 616 |
return; |
| 617 |
} |
| 618 |
|
| 619 |
if ( weaponInfo->registered ) { |
| 620 |
return; |
| 621 |
} |
| 622 |
|
| 623 |
memset( weaponInfo, 0, sizeof( *weaponInfo ) ); |
| 624 |
weaponInfo->registered = qtrue; |
| 625 |
|
| 626 |
for ( item = bg_itemlist + 1 ; item->classname ; item++ ) { |
| 627 |
if ( item->giType == IT_WEAPON && item->giTag == weaponNum ) { |
| 628 |
weaponInfo->item = item; |
| 629 |
break; |
| 630 |
} |
| 631 |
} |
| 632 |
if ( !item->classname ) { |
| 633 |
CG_Error( "Couldn't find weapon %i", weaponNum ); |
| 634 |
} |
| 635 |
CG_RegisterItemVisuals( item - bg_itemlist ); |
| 636 |
|
| 637 |
|
| 638 |
weaponInfo->weaponModel = trap_R_RegisterModel( item->world_model[0] ); |
| 639 |
|
| 640 |
|
| 641 |
trap_R_ModelBounds( weaponInfo->weaponModel, mins, maxs ); |
| 642 |
for ( i = 0 ; i < 3 ; i++ ) { |
| 643 |
weaponInfo->weaponMidpoint[i] = mins[i] + 0.5 * ( maxs[i] - mins[i] ); |
| 644 |
} |
| 645 |
|
| 646 |
weaponInfo->weaponIcon = trap_R_RegisterShader( item->icon ); |
| 647 |
weaponInfo->ammoIcon = trap_R_RegisterShader( item->icon ); |
| 648 |
|
| 649 |
for ( ammo = bg_itemlist + 1 ; ammo->classname ; ammo++ ) { |
| 650 |
if ( ammo->giType == IT_AMMO && ammo->giTag == weaponNum ) { |
| 651 |
break; |
| 652 |
} |
| 653 |
} |
| 654 |
if ( ammo->classname && ammo->world_model[0] ) { |
| 655 |
weaponInfo->ammoModel = trap_R_RegisterModel( ammo->world_model[0] ); |
| 656 |
} |
| 657 |
|
| 658 |
COM_StripExtension( item->world_model[0], path, sizeof(path) ); |
| 659 |
Q_strcat( path, sizeof(path), "_flash.md3" ); |
| 660 |
weaponInfo->flashModel = trap_R_RegisterModel( path ); |
| 661 |
|
| 662 |
COM_StripExtension( item->world_model[0], path, sizeof(path) ); |
| 663 |
Q_strcat( path, sizeof(path), "_barrel.md3" ); |
| 664 |
weaponInfo->barrelModel = trap_R_RegisterModel( path ); |
| 665 |
|
| 666 |
COM_StripExtension( item->world_model[0], path, sizeof(path) ); |
| 667 |
Q_strcat( path, sizeof(path), "_hand.md3" ); |
| 668 |
weaponInfo->handsModel = trap_R_RegisterModel( path ); |
| 669 |
|
| 670 |
if ( !weaponInfo->handsModel ) { |
| 671 |
weaponInfo->handsModel = trap_R_RegisterModel( "models/weapons2/shotgun/shotgun_hand.md3" ); |
| 672 |
} |
| 673 |
|
| 674 |
switch ( weaponNum ) { |
| 675 |
case WP_GAUNTLET: |
| 676 |
MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f ); |
| 677 |
weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/melee/fstrun.wav", qfalse ); |
| 678 |
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse ); |
| 679 |
break; |
| 680 |
|
| 681 |
case WP_LIGHTNING: |
| 682 |
MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f ); |
| 683 |
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/melee/fsthum.wav", qfalse ); |
| 684 |
weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/lightning/lg_hum.wav", qfalse ); |
| 685 |
|
| 686 |
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/lightning/lg_fire.wav", qfalse ); |
| 687 |
cgs.media.lightningShader = trap_R_RegisterShader( "lightningBoltNew"); |
| 688 |
cgs.media.lightningExplosionModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" ); |
| 689 |
cgs.media.sfx_lghit1 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit.wav", qfalse ); |
| 690 |
cgs.media.sfx_lghit2 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit2.wav", qfalse ); |
| 691 |
cgs.media.sfx_lghit3 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit3.wav", qfalse ); |
| 692 |
|
| 693 |
break; |
| 694 |
|
| 695 |
case WP_GRAPPLING_HOOK: |
| 696 |
MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f ); |
| 697 |
weaponInfo->missileModel = trap_R_RegisterModel( "models/ammo/rocket/rocket.md3" ); |
| 698 |
weaponInfo->missileTrailFunc = CG_GrappleTrail; |
| 699 |
weaponInfo->missileDlight = 200; |
| 700 |
MAKERGB( weaponInfo->missileDlightColor, 1, 0.75f, 0 ); |
| 701 |
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/melee/fsthum.wav", qfalse ); |
| 702 |
weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/melee/fstrun.wav", qfalse ); |
| 703 |
cgs.media.lightningShader = trap_R_RegisterShader( "lightningBoltNew"); |
| 704 |
break; |
| 705 |
|
| 706 |
#ifdef MISSIONPACK |
| 707 |
case WP_CHAINGUN: |
| 708 |
weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/vulcan/wvulfire.wav", qfalse ); |
| 709 |
MAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 ); |
| 710 |
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/vulcan/vulcanf1b.wav", qfalse ); |
| 711 |
weaponInfo->flashSound[1] = trap_S_RegisterSound( "sound/weapons/vulcan/vulcanf2b.wav", qfalse ); |
| 712 |
weaponInfo->flashSound[2] = trap_S_RegisterSound( "sound/weapons/vulcan/vulcanf3b.wav", qfalse ); |
| 713 |
weaponInfo->flashSound[3] = trap_S_RegisterSound( "sound/weapons/vulcan/vulcanf4b.wav", qfalse ); |
| 714 |
weaponInfo->ejectBrassFunc = CG_MachineGunEjectBrass; |
| 715 |
cgs.media.bulletExplosionShader = trap_R_RegisterShader( "bulletExplosion" ); |
| 716 |
break; |
| 717 |
#endif |
| 718 |
|
| 719 |
case WP_MACHINEGUN: |
| 720 |
MAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 ); |
| 721 |
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf1b.wav", qfalse ); |
| 722 |
weaponInfo->flashSound[1] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf2b.wav", qfalse ); |
| 723 |
weaponInfo->flashSound[2] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf3b.wav", qfalse ); |
| 724 |
weaponInfo->flashSound[3] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf4b.wav", qfalse ); |
| 725 |
weaponInfo->ejectBrassFunc = CG_MachineGunEjectBrass; |
| 726 |
cgs.media.bulletExplosionShader = trap_R_RegisterShader( "bulletExplosion" ); |
| 727 |
break; |
| 728 |
|
| 729 |
case WP_SHOTGUN: |
| 730 |
MAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 ); |
| 731 |
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/shotgun/sshotf1b.wav", qfalse ); |
| 732 |
weaponInfo->ejectBrassFunc = CG_ShotgunEjectBrass; |
| 733 |
break; |
| 734 |
|
| 735 |
case WP_ROCKET_LAUNCHER: |
| 736 |
weaponInfo->missileModel = trap_R_RegisterModel( "models/ammo/rocket/rocket.md3" ); |
| 737 |
weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/rocket/rockfly.wav", qfalse ); |
| 738 |
weaponInfo->missileTrailFunc = CG_RocketTrail; |
| 739 |
weaponInfo->missileDlight = 200; |
| 740 |
weaponInfo->wiTrailTime = 2000; |
| 741 |
weaponInfo->trailRadius = 64; |
| 742 |
|
| 743 |
MAKERGB( weaponInfo->missileDlightColor, 1, 0.75f, 0 ); |
| 744 |
MAKERGB( weaponInfo->flashDlightColor, 1, 0.75f, 0 ); |
| 745 |
|
| 746 |
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/rocket/rocklf1a.wav", qfalse ); |
| 747 |
cgs.media.rocketExplosionShader = trap_R_RegisterShader( "rocketExplosion" ); |
| 748 |
break; |
| 749 |
|
| 750 |
#ifdef MISSIONPACK |
| 751 |
case WP_PROX_LAUNCHER: |
| 752 |
weaponInfo->missileModel = trap_R_RegisterModel( "models/weaphits/proxmine.md3" ); |
| 753 |
weaponInfo->missileTrailFunc = CG_GrenadeTrail; |
| 754 |
weaponInfo->wiTrailTime = 700; |
| 755 |
weaponInfo->trailRadius = 32; |
| 756 |
MAKERGB( weaponInfo->flashDlightColor, 1, 0.70f, 0 ); |
| 757 |
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/proxmine/wstbfire.wav", qfalse ); |
| 758 |
cgs.media.grenadeExplosionShader = trap_R_RegisterShader( "grenadeExplosion" ); |
| 759 |
break; |
| 760 |
#endif |
| 761 |
|
| 762 |
case WP_GRENADE_LAUNCHER: |
| 763 |
weaponInfo->missileModel = trap_R_RegisterModel( "models/ammo/grenade1.md3" ); |
| 764 |
weaponInfo->missileTrailFunc = CG_GrenadeTrail; |
| 765 |
weaponInfo->wiTrailTime = 700; |
| 766 |
weaponInfo->trailRadius = 32; |
| 767 |
MAKERGB( weaponInfo->flashDlightColor, 1, 0.70f, 0 ); |
| 768 |
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/grenade/grenlf1a.wav", qfalse ); |
| 769 |
cgs.media.grenadeExplosionShader = trap_R_RegisterShader( "grenadeExplosion" ); |
| 770 |
break; |
| 771 |
|
| 772 |
#ifdef MISSIONPACK |
| 773 |
case WP_NAILGUN: |
| 774 |
weaponInfo->ejectBrassFunc = CG_NailgunEjectBrass; |
| 775 |
weaponInfo->missileTrailFunc = CG_NailTrail; |
| 776 |
|
| 777 |
weaponInfo->trailRadius = 16; |
| 778 |
weaponInfo->wiTrailTime = 250; |
| 779 |
weaponInfo->missileModel = trap_R_RegisterModel( "models/weaphits/nail.md3" ); |
| 780 |
MAKERGB( weaponInfo->flashDlightColor, 1, 0.75f, 0 ); |
| 781 |
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/nailgun/wnalfire.wav", qfalse ); |
| 782 |
break; |
| 783 |
#endif |
| 784 |
|
| 785 |
case WP_PLASMAGUN: |
| 786 |
|
| 787 |
weaponInfo->missileTrailFunc = CG_PlasmaTrail; |
| 788 |
weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/plasma/lasfly.wav", qfalse ); |
| 789 |
MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f ); |
| 790 |
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/plasma/hyprbf1a.wav", qfalse ); |
| 791 |
cgs.media.plasmaExplosionShader = trap_R_RegisterShader( "plasmaExplosion" ); |
| 792 |
cgs.media.railRingsShader = trap_R_RegisterShader( "railDisc" ); |
| 793 |
break; |
| 794 |
|
| 795 |
case WP_RAILGUN: |
| 796 |
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/railgun/rg_hum.wav", qfalse ); |
| 797 |
MAKERGB( weaponInfo->flashDlightColor, 1, 0.5f, 0 ); |
| 798 |
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/railgun/railgf1a.wav", qfalse ); |
| 799 |
cgs.media.railExplosionShader = trap_R_RegisterShader( "railExplosion" ); |
| 800 |
cgs.media.railRingsShader = trap_R_RegisterShader( "railDisc" ); |
| 801 |
cgs.media.railCoreShader = trap_R_RegisterShader( "railCore" ); |
| 802 |
break; |
| 803 |
|
| 804 |
case WP_BFG: |
| 805 |
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/bfg/bfg_hum.wav", qfalse ); |
| 806 |
MAKERGB( weaponInfo->flashDlightColor, 1, 0.7f, 1 ); |
| 807 |
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/bfg/bfg_fire.wav", qfalse ); |
| 808 |
cgs.media.bfgExplosionShader = trap_R_RegisterShader( "bfgExplosion" ); |
| 809 |
weaponInfo->missileModel = trap_R_RegisterModel( "models/weaphits/bfg.md3" ); |
| 810 |
weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/rocket/rockfly.wav", qfalse ); |
| 811 |
break; |
| 812 |
|
| 813 |
default: |
| 814 |
MAKERGB( weaponInfo->flashDlightColor, 1, 1, 1 ); |
| 815 |
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/rocket/rocklf1a.wav", qfalse ); |
| 816 |
break; |
| 817 |
} |
| 818 |
} |
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
void CG_RegisterItemVisuals( int itemNum ) { |
| 828 |
itemInfo_t *itemInfo; |
| 829 |
gitem_t *item; |
| 830 |
|
| 831 |
if ( itemNum < 0 || itemNum >= bg_numItems ) { |
| 832 |
CG_Error( "CG_RegisterItemVisuals: itemNum %d out of range [0-%d]", itemNum, bg_numItems-1 ); |
| 833 |
} |
| 834 |
|
| 835 |
itemInfo = &cg_items[ itemNum ]; |
| 836 |
if ( itemInfo->registered ) { |
| 837 |
return; |
| 838 |
} |
| 839 |
|
| 840 |
item = &bg_itemlist[ itemNum ]; |
| 841 |
|
| 842 |
memset( itemInfo, 0, sizeof( *itemInfo ) ); |
| 843 |
itemInfo->registered = qtrue; |
| 844 |
|
| 845 |
itemInfo->models[0] = trap_R_RegisterModel( item->world_model[0] ); |
| 846 |
|
| 847 |
itemInfo->icon = trap_R_RegisterShader( item->icon ); |
| 848 |
|
| 849 |
if ( item->giType == IT_WEAPON ) { |
| 850 |
CG_RegisterWeapon( item->giTag ); |
| 851 |
} |
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
if ( item->giType == IT_POWERUP || item->giType == IT_HEALTH || |
| 857 |
item->giType == IT_ARMOR || item->giType == IT_HOLDABLE ) { |
| 858 |
if ( item->world_model[1] ) { |
| 859 |
itemInfo->models[1] = trap_R_RegisterModel( item->world_model[1] ); |
| 860 |
} |
| 861 |
} |
| 862 |
} |
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
static int CG_MapTorsoToWeaponFrame( clientInfo_t *ci, int frame ) { |
| 880 |
|
| 881 |
|
| 882 |
if ( frame >= ci->animations[TORSO_DROP].firstFrame |
| 883 |
&& frame < ci->animations[TORSO_DROP].firstFrame + 9 ) { |
| 884 |
return frame - ci->animations[TORSO_DROP].firstFrame + 6; |
| 885 |
} |
| 886 |
|
| 887 |
|
| 888 |
if ( frame >= ci->animations[TORSO_ATTACK].firstFrame |
| 889 |
&& frame < ci->animations[TORSO_ATTACK].firstFrame + 6 ) { |
| 890 |
return 1 + frame - ci->animations[TORSO_ATTACK].firstFrame; |
| 891 |
} |
| 892 |
|
| 893 |
|
| 894 |
if ( frame >= ci->animations[TORSO_ATTACK2].firstFrame |
| 895 |
&& frame < ci->animations[TORSO_ATTACK2].firstFrame + 6 ) { |
| 896 |
return 1 + frame - ci->animations[TORSO_ATTACK2].firstFrame; |
| 897 |
} |
| 898 |
|
| 899 |
return 0; |
| 900 |
} |
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
static void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles ) { |
| 909 |
float scale; |
| 910 |
int delta; |
| 911 |
float fracsin; |
| 912 |
|
| 913 |
VectorCopy( cg.refdef.vieworg, origin ); |
| 914 |
VectorCopy( cg.refdefViewAngles, angles ); |
| 915 |
|
| 916 |
|
| 917 |
if ( cg.bobcycle & 1 ) { |
| 918 |
scale = -cg.xyspeed; |
| 919 |
} else { |
| 920 |
scale = cg.xyspeed; |
| 921 |
} |
| 922 |
|
| 923 |
|
| 924 |
angles[ROLL] += scale * cg.bobfracsin * 0.005; |
| 925 |
angles[YAW] += scale * cg.bobfracsin * 0.01; |
| 926 |
angles[PITCH] += cg.xyspeed * cg.bobfracsin * 0.005; |
| 927 |
|
| 928 |
|
| 929 |
delta = cg.time - cg.landTime; |
| 930 |
if ( delta < LAND_DEFLECT_TIME ) { |
| 931 |
origin[2] += cg.landChange*0.25 * delta / LAND_DEFLECT_TIME; |
| 932 |
} else if ( delta < LAND_DEFLECT_TIME + LAND_RETURN_TIME ) { |
| 933 |
origin[2] += cg.landChange*0.25 * |
| 934 |
(LAND_DEFLECT_TIME + LAND_RETURN_TIME - delta) / LAND_RETURN_TIME; |
| 935 |
} |
| 936 |
|
| 937 |
#if 0 |
| 938 |
|
| 939 |
delta = cg.time - cg.stepTime; |
| 940 |
if ( delta < STEP_TIME/2 ) { |
| 941 |
origin[2] -= cg.stepChange*0.25 * delta / (STEP_TIME/2); |
| 942 |
} else if ( delta < STEP_TIME ) { |
| 943 |
origin[2] -= cg.stepChange*0.25 * (STEP_TIME - delta) / (STEP_TIME/2); |
| 944 |
} |
| 945 |
#endif |
| 946 |
|
| 947 |
|
| 948 |
scale = cg.xyspeed + 40; |
| 949 |
fracsin = sin( cg.time * 0.001 ); |
| 950 |
angles[ROLL] += scale * fracsin * 0.01; |
| 951 |
angles[YAW] += scale * fracsin * 0.01; |
| 952 |
angles[PITCH] += scale * fracsin * 0.01; |
| 953 |
} |
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
static void CG_LightningBolt( centity_t *cent, vec3_t origin ) { |
| 968 |
trace_t trace; |
| 969 |
refEntity_t beam; |
| 970 |
vec3_t forward; |
| 971 |
vec3_t muzzlePoint, endPoint; |
| 972 |
int anim; |
| 973 |
|
| 974 |
if (cent->currentState.weapon != WP_LIGHTNING) { |
| 975 |
return; |
| 976 |
} |
| 977 |
|
| 978 |
memset( &beam, 0, sizeof( beam ) ); |
| 979 |
|
| 980 |
|
| 981 |
if ((cent->currentState.number == cg.predictedPlayerState.clientNum) && (cg_trueLightning.value != 0)) { |
| 982 |
vec3_t angle; |
| 983 |
int i; |
| 984 |
|
| 985 |
for (i = 0; i < 3; i++) { |
| 986 |
float a = cent->lerpAngles[i] - cg.refdefViewAngles[i]; |
| 987 |
if (a > 180) { |
| 988 |
a -= 360; |
| 989 |
} |
| 990 |
if (a < -180) { |
| 991 |
a += 360; |
| 992 |
} |
| 993 |
|
| 994 |
angle[i] = cg.refdefViewAngles[i] + a * (1.0 - cg_trueLightning.value); |
| 995 |
if (angle[i] < 0) { |
| 996 |
angle[i] += 360; |
| 997 |
} |
| 998 |
if (angle[i] > 360) { |
| 999 |
angle[i] -= 360; |
| 1000 |
} |
| 1001 |
} |
| 1002 |
|
| 1003 |
AngleVectors(angle, forward, NULL, NULL ); |
| 1004 |
VectorCopy(cent->lerpOrigin, muzzlePoint ); |
| 1005 |
|
| 1006 |
} else { |
| 1007 |
|
| 1008 |
AngleVectors( cent->lerpAngles, forward, NULL, NULL ); |
| 1009 |
VectorCopy(cent->lerpOrigin, muzzlePoint ); |
| 1010 |
} |
| 1011 |
|
| 1012 |
anim = cent->currentState.legsAnim & ~ANIM_TOGGLEBIT; |
| 1013 |
if ( anim == LEGS_WALKCR || anim == LEGS_IDLECR ) { |
| 1014 |
muzzlePoint[2] += CROUCH_VIEWHEIGHT; |
| 1015 |
} else { |
| 1016 |
muzzlePoint[2] += DEFAULT_VIEWHEIGHT; |
| 1017 |
} |
| 1018 |
|
| 1019 |
VectorMA( muzzlePoint, 14, forward, muzzlePoint ); |
| 1020 |
|
| 1021 |
|
| 1022 |
VectorMA( muzzlePoint, LIGHTNING_RANGE, forward, endPoint ); |
| 1023 |
|
| 1024 |
|
| 1025 |
CG_Trace( &trace, muzzlePoint, vec3_origin, vec3_origin, endPoint, |
| 1026 |
cent->currentState.number, MASK_SHOT ); |
| 1027 |
|
| 1028 |
|
| 1029 |
VectorCopy( trace.endpos, beam.oldorigin ); |
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
VectorCopy( origin, beam.origin ); |
| 1034 |
|
| 1035 |
beam.reType = RT_LIGHTNING; |
| 1036 |
beam.customShader = cgs.media.lightningShader; |
| 1037 |
trap_R_AddRefEntityToScene( &beam ); |
| 1038 |
|
| 1039 |
|
| 1040 |
if ( trace.fraction < 1.0 ) { |
| 1041 |
vec3_t angles; |
| 1042 |
vec3_t dir; |
| 1043 |
|
| 1044 |
VectorSubtract( beam.oldorigin, beam.origin, dir ); |
| 1045 |
VectorNormalize( dir ); |
| 1046 |
|
| 1047 |
memset( &beam, 0, sizeof( beam ) ); |
| 1048 |
beam.hModel = cgs.media.lightningExplosionModel; |
| 1049 |
|
| 1050 |
VectorMA( trace.endpos, -16, dir, beam.origin ); |
| 1051 |
|
| 1052 |
|
| 1053 |
angles[0] = rand() % 360; |
| 1054 |
angles[1] = rand() % 360; |
| 1055 |
angles[2] = rand() % 360; |
| 1056 |
AnglesToAxis( angles, beam.axis ); |
| 1057 |
trap_R_AddRefEntityToScene( &beam ); |
| 1058 |
} |
| 1059 |
} |
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
|
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
#define SPIN_SPEED 0.9 |
| 1131 |
#define COAST_TIME 1000 |
| 1132 |
static float CG_MachinegunSpinAngle( centity_t *cent ) { |
| 1133 |
int delta; |
| 1134 |
float angle; |
| 1135 |
float speed; |
| 1136 |
|
| 1137 |
delta = cg.time - cent->pe.barrelTime; |
| 1138 |
if ( cent->pe.barrelSpinning ) { |
| 1139 |
angle = cent->pe.barrelAngle + delta * SPIN_SPEED; |
| 1140 |
} else { |
| 1141 |
if ( delta > COAST_TIME ) { |
| 1142 |
delta = COAST_TIME; |
| 1143 |
} |
| 1144 |
|
| 1145 |
speed = 0.5 * ( SPIN_SPEED + (float)( COAST_TIME - delta ) / COAST_TIME ); |
| 1146 |
angle = cent->pe.barrelAngle + delta * speed; |
| 1147 |
} |
| 1148 |
|
| 1149 |
if ( cent->pe.barrelSpinning == !(cent->currentState.eFlags & EF_FIRING) ) { |
| 1150 |
cent->pe.barrelTime = cg.time; |
| 1151 |
cent->pe.barrelAngle = AngleMod( angle ); |
| 1152 |
cent->pe.barrelSpinning = !!(cent->currentState.eFlags & EF_FIRING); |
| 1153 |
#ifdef MISSIONPACK |
| 1154 |
if ( cent->currentState.weapon == WP_CHAINGUN && !cent->pe.barrelSpinning ) { |
| 1155 |
trap_S_StartSound( NULL, cent->currentState.number, CHAN_WEAPON, trap_S_RegisterSound( "sound/weapons/vulcan/wvulwind.wav", qfalse ) ); |
| 1156 |
} |
| 1157 |
#endif |
| 1158 |
} |
| 1159 |
|
| 1160 |
return angle; |
| 1161 |
} |
| 1162 |
|
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
static void CG_AddWeaponWithPowerups( refEntity_t *gun, int powerups ) { |
| 1170 |
|
| 1171 |
if ( powerups & ( 1 << PW_INVIS ) ) { |
| 1172 |
gun->customShader = cgs.media.invisShader; |
| 1173 |
trap_R_AddRefEntityToScene( gun ); |
| 1174 |
} else { |
| 1175 |
trap_R_AddRefEntityToScene( gun ); |
| 1176 |
|
| 1177 |
if ( powerups & ( 1 << PW_BATTLESUIT ) ) { |
| 1178 |
gun->customShader = cgs.media.battleWeaponShader; |
| 1179 |
trap_R_AddRefEntityToScene( gun ); |
| 1180 |
} |
| 1181 |
if ( powerups & ( 1 << PW_QUAD ) ) { |
| 1182 |
gun->customShader = cgs.media.quadWeaponShader; |
| 1183 |
trap_R_AddRefEntityToScene( gun ); |
| 1184 |
} |
| 1185 |
} |
| 1186 |
} |
| 1187 |
|
| 1188 |
|
| 1189 |
|
| 1190 |
|
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent, int team ) { |
| 1199 |
refEntity_t gun; |
| 1200 |
refEntity_t barrel; |
| 1201 |
refEntity_t flash; |
| 1202 |
vec3_t angles; |
| 1203 |
weapon_t weaponNum; |
| 1204 |
weaponInfo_t *weapon; |
| 1205 |
centity_t *nonPredictedCent; |
| 1206 |
orientation_t lerped; |
| 1207 |
|
| 1208 |
weaponNum = cent->currentState.weapon; |
| 1209 |
|
| 1210 |
CG_RegisterWeapon( weaponNum ); |
| 1211 |
weapon = &cg_weapons[weaponNum]; |
| 1212 |
|
| 1213 |
|
| 1214 |
memset( &gun, 0, sizeof( gun ) ); |
| 1215 |
VectorCopy( parent->lightingOrigin, gun.lightingOrigin ); |
| 1216 |
gun.shadowPlane = parent->shadowPlane; |
| 1217 |
gun.renderfx = parent->renderfx; |
| 1218 |
|
| 1219 |
|
| 1220 |
if( weaponNum == WP_RAILGUN ) { |
| 1221 |
clientInfo_t *ci = &cgs.clientinfo[cent->currentState.clientNum]; |
| 1222 |
if( cent->pe.railFireTime + 1500 > cg.time ) { |
| 1223 |
int scale = 255 * ( cg.time - cent->pe.railFireTime ) / 1500; |
| 1224 |
gun.shaderRGBA[0] = ( ci->c1RGBA[0] * scale ) >> 8; |
| 1225 |
gun.shaderRGBA[1] = ( ci->c1RGBA[1] * scale ) >> 8; |
| 1226 |
gun.shaderRGBA[2] = ( ci->c1RGBA[2] * scale ) >> 8; |
| 1227 |
gun.shaderRGBA[3] = 255; |
| 1228 |
} |
| 1229 |
else { |
| 1230 |
Byte4Copy( ci->c1RGBA, gun.shaderRGBA ); |
| 1231 |
} |
| 1232 |
} |
| 1233 |
|
| 1234 |
gun.hModel = weapon->weaponModel; |
| 1235 |
if (!gun.hModel) { |
| 1236 |
return; |
| 1237 |
} |
| 1238 |
|
| 1239 |
if ( !ps ) { |
| 1240 |
|
| 1241 |
cent->pe.lightningFiring = qfalse; |
| 1242 |
if ( ( cent->currentState.eFlags & EF_FIRING ) && weapon->firingSound ) { |
| 1243 |
|
| 1244 |
trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->firingSound ); |
| 1245 |
cent->pe.lightningFiring = qtrue; |
| 1246 |
} else if ( weapon->readySound ) { |
| 1247 |
trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->readySound ); |
| 1248 |
} |
| 1249 |
} |
| 1250 |
|
| 1251 |
trap_R_LerpTag(&lerped, parent->hModel, parent->oldframe, parent->frame, |
| 1252 |
1.0 - parent->backlerp, "tag_weapon"); |
| 1253 |
VectorCopy(parent->origin, gun.origin); |
| 1254 |
|
| 1255 |
VectorMA(gun.origin, lerped.origin[0], parent->axis[0], gun.origin); |
| 1256 |
|
| 1257 |
|
| 1258 |
if(ps && cg_drawGun.integer == 2) |
| 1259 |
VectorMA(gun.origin, -lerped.origin[1], parent->axis[1], gun.origin); |
| 1260 |
else if(!ps || cg_drawGun.integer != 3) |
| 1261 |
VectorMA(gun.origin, lerped.origin[1], parent->axis[1], gun.origin); |
| 1262 |
|
| 1263 |
VectorMA(gun.origin, lerped.origin[2], parent->axis[2], gun.origin); |
| 1264 |
|
| 1265 |
MatrixMultiply(lerped.axis, ((refEntity_t *)parent)->axis, gun.axis); |
| 1266 |
gun.backlerp = parent->backlerp; |
| 1267 |
|
| 1268 |
CG_AddWeaponWithPowerups( &gun, cent->currentState.powerups ); |
| 1269 |
|
| 1270 |
|
| 1271 |
if ( weapon->barrelModel ) { |
| 1272 |
memset( &barrel, 0, sizeof( barrel ) ); |
| 1273 |
VectorCopy( parent->lightingOrigin, barrel.lightingOrigin ); |
| 1274 |
barrel.shadowPlane = parent->shadowPlane; |
| 1275 |
barrel.renderfx = parent->renderfx; |
| 1276 |
|
| 1277 |
barrel.hModel = weapon->barrelModel; |
| 1278 |
angles[YAW] = 0; |
| 1279 |
angles[PITCH] = 0; |
| 1280 |
angles[ROLL] = CG_MachinegunSpinAngle( cent ); |
| 1281 |
AnglesToAxis( angles, barrel.axis ); |
| 1282 |
|
| 1283 |
CG_PositionRotatedEntityOnTag( &barrel, &gun, weapon->weaponModel, "tag_barrel" ); |
| 1284 |
|
| 1285 |
CG_AddWeaponWithPowerups( &barrel, cent->currentState.powerups ); |
| 1286 |
} |
| 1287 |
|
| 1288 |
|
| 1289 |
nonPredictedCent = &cg_entities[cent->currentState.number]; |
| 1290 |
|
| 1291 |
|
| 1292 |
|
| 1293 |
|
| 1294 |
if( ( nonPredictedCent - cg_entities ) != cent->currentState.clientNum ) { |
| 1295 |
nonPredictedCent = cent; |
| 1296 |
} |
| 1297 |
|
| 1298 |
|
| 1299 |
if ( ( weaponNum == WP_LIGHTNING || weaponNum == WP_GAUNTLET || weaponNum == WP_GRAPPLING_HOOK ) |
| 1300 |
&& ( nonPredictedCent->currentState.eFlags & EF_FIRING ) ) |
| 1301 |
{ |
| 1302 |
|
| 1303 |
} else { |
| 1304 |
|
| 1305 |
if ( cg.time - cent->muzzleFlashTime > MUZZLE_FLASH_TIME ) { |
| 1306 |
return; |
| 1307 |
} |
| 1308 |
} |
| 1309 |
|
| 1310 |
memset( &flash, 0, sizeof( flash ) ); |
| 1311 |
VectorCopy( parent->lightingOrigin, flash.lightingOrigin ); |
| 1312 |
flash.shadowPlane = parent->shadowPlane; |
| 1313 |
flash.renderfx = parent->renderfx; |
| 1314 |
|
| 1315 |
flash.hModel = weapon->flashModel; |
| 1316 |
if (!flash.hModel) { |
| 1317 |
return; |
| 1318 |
} |
| 1319 |
angles[YAW] = 0; |
| 1320 |
angles[PITCH] = 0; |
| 1321 |
angles[ROLL] = crandom() * 10; |
| 1322 |
AnglesToAxis( angles, flash.axis ); |
| 1323 |
|
| 1324 |
|
| 1325 |
if ( weaponNum == WP_RAILGUN ) { |
| 1326 |
clientInfo_t *ci; |
| 1327 |
|
| 1328 |
ci = &cgs.clientinfo[ cent->currentState.clientNum ]; |
| 1329 |
flash.shaderRGBA[0] = 255 * ci->color1[0]; |
| 1330 |
flash.shaderRGBA[1] = 255 * ci->color1[1]; |
| 1331 |
flash.shaderRGBA[2] = 255 * ci->color1[2]; |
| 1332 |
} |
| 1333 |
|
| 1334 |
CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->weaponModel, "tag_flash"); |
| 1335 |
trap_R_AddRefEntityToScene( &flash ); |
| 1336 |
|
| 1337 |
if ( ps || cg.renderingThirdPerson || |
| 1338 |
cent->currentState.number != cg.predictedPlayerState.clientNum ) { |
| 1339 |
|
| 1340 |
CG_LightningBolt( nonPredictedCent, flash.origin ); |
| 1341 |
|
| 1342 |
if ( weapon->flashDlightColor[0] || weapon->flashDlightColor[1] || weapon->flashDlightColor[2] ) { |
| 1343 |
trap_R_AddLightToScene( flash.origin, 300 + (rand()&31), weapon->flashDlightColor[0], |
| 1344 |
weapon->flashDlightColor[1], weapon->flashDlightColor[2] ); |
| 1345 |
} |
| 1346 |
} |
| 1347 |
} |
| 1348 |
|
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
|
| 1354 |
|
| 1355 |
|
| 1356 |
void CG_AddViewWeapon( playerState_t *ps ) { |
| 1357 |
refEntity_t hand; |
| 1358 |
centity_t *cent; |
| 1359 |
clientInfo_t *ci; |
| 1360 |
float fovOffset; |
| 1361 |
vec3_t angles; |
| 1362 |
weaponInfo_t *weapon; |
| 1363 |
|
| 1364 |
if ( ps->persistant[PERS_TEAM] == TEAM_SPECTATOR ) { |
| 1365 |
return; |
| 1366 |
} |
| 1367 |
|
| 1368 |
if ( ps->pm_type == PM_INTERMISSION ) { |
| 1369 |
return; |
| 1370 |
} |
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
if ( cg.renderingThirdPerson ) { |
| 1375 |
return; |
| 1376 |
} |
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
if ( !cg_drawGun.integer ) { |
| 1381 |
vec3_t origin; |
| 1382 |
|
| 1383 |
if ( cg.predictedPlayerState.eFlags & EF_FIRING ) { |
| 1384 |
|
| 1385 |
VectorCopy( cg.refdef.vieworg, origin ); |
| 1386 |
VectorMA( origin, -8, cg.refdef.viewaxis[2], origin ); |
| 1387 |
CG_LightningBolt( &cg_entities[ps->clientNum], origin ); |
| 1388 |
} |
| 1389 |
return; |
| 1390 |
} |
| 1391 |
|
| 1392 |
|
| 1393 |
if ( cg.testGun ) { |
| 1394 |
return; |
| 1395 |
} |
| 1396 |
|
| 1397 |
|
| 1398 |
if ( cg_fov.integer > 90 ) { |
| 1399 |
fovOffset = -0.2 * ( cg_fov.integer - 90 ); |
| 1400 |
} else { |
| 1401 |
fovOffset = 0; |
| 1402 |
} |
| 1403 |
|
| 1404 |
cent = &cg.predictedPlayerEntity; |
| 1405 |
CG_RegisterWeapon( ps->weapon ); |
| 1406 |
weapon = &cg_weapons[ ps->weapon ]; |
| 1407 |
|
| 1408 |
memset (&hand, 0, sizeof(hand)); |
| 1409 |
|
| 1410 |
|
| 1411 |
CG_CalculateWeaponPosition( hand.origin, angles ); |
| 1412 |
|
| 1413 |
VectorMA( hand.origin, cg_gun_x.value, cg.refdef.viewaxis[0], hand.origin ); |
| 1414 |
VectorMA( hand.origin, cg_gun_y.value, cg.refdef.viewaxis[1], hand.origin ); |
| 1415 |
VectorMA( hand.origin, (cg_gun_z.value+fovOffset), cg.refdef.viewaxis[2], hand.origin ); |
| 1416 |
|
| 1417 |
AnglesToAxis( angles, hand.axis ); |
| 1418 |
|
| 1419 |
|
| 1420 |
if ( cg_gun_frame.integer ) { |
| 1421 |
|
| 1422 |
hand.frame = hand.oldframe = cg_gun_frame.integer; |
| 1423 |
hand.backlerp = 0; |
| 1424 |
} else { |
| 1425 |
|
| 1426 |
ci = &cgs.clientinfo[ cent->currentState.clientNum ]; |
| 1427 |
hand.frame = CG_MapTorsoToWeaponFrame( ci, cent->pe.torso.frame ); |
| 1428 |
hand.oldframe = CG_MapTorsoToWeaponFrame( ci, cent->pe.torso.oldFrame ); |
| 1429 |
hand.backlerp = cent->pe.torso.backlerp; |
| 1430 |
} |
| 1431 |
|
| 1432 |
hand.hModel = weapon->handsModel; |
| 1433 |
hand.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON | RF_MINLIGHT; |
| 1434 |
|
| 1435 |
|
| 1436 |
CG_AddPlayerWeapon( &hand, ps, &cg.predictedPlayerEntity, ps->persistant[PERS_TEAM] ); |
| 1437 |
} |
| 1438 |
|
| 1439 |
|
| 1440 |
|
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
|
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
void CG_DrawWeaponSelect( void ) { |
| 1453 |
int i; |
| 1454 |
int bits; |
| 1455 |
int count; |
| 1456 |
int x, y, w; |
| 1457 |
char *name; |
| 1458 |
float *color; |
| 1459 |
|
| 1460 |
|
| 1461 |
if ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) { |
| 1462 |
return; |
| 1463 |
} |
| 1464 |
|
| 1465 |
color = CG_FadeColor( cg.weaponSelectTime, WEAPON_SELECT_TIME ); |
| 1466 |
if ( !color ) { |
| 1467 |
return; |
| 1468 |
} |
| 1469 |
trap_R_SetColor( color ); |
| 1470 |
|
| 1471 |
|
| 1472 |
cg.itemPickupTime = 0; |
| 1473 |
|
| 1474 |
|
| 1475 |
bits = cg.snap->ps.stats[ STAT_WEAPONS ]; |
| 1476 |
count = 0; |
| 1477 |
for ( i = 1 ; i < MAX_WEAPONS ; i++ ) { |
| 1478 |
if ( bits & ( 1 << i ) ) { |
| 1479 |
count++; |
| 1480 |
} |
| 1481 |
} |
| 1482 |
|
| 1483 |
x = 320 - count * 20; |
| 1484 |
y = 380; |
| 1485 |
|
| 1486 |
for ( i = 1 ; i < MAX_WEAPONS ; i++ ) { |
| 1487 |
if ( !( bits & ( 1 << i ) ) ) { |
| 1488 |
continue; |
| 1489 |
} |
| 1490 |
|
| 1491 |
CG_RegisterWeapon( i ); |
| 1492 |
|
| 1493 |
|
| 1494 |
CG_DrawPic( x, y, 32, 32, cg_weapons[i].weaponIcon ); |
| 1495 |
|
| 1496 |
|
| 1497 |
if ( i == cg.weaponSelect ) { |
| 1498 |
CG_DrawPic( x-4, y-4, 40, 40, cgs.media.selectShader ); |
| 1499 |
} |
| 1500 |
|
| 1501 |
|
| 1502 |
if ( !cg.snap->ps.ammo[ i ] ) { |
| 1503 |
CG_DrawPic( x, y, 32, 32, cgs.media.noammoShader ); |
| 1504 |
} |
| 1505 |
|
| 1506 |
x += 40; |
| 1507 |
} |
| 1508 |
|
| 1509 |
|
| 1510 |
if ( cg_weapons[ cg.weaponSelect ].item ) { |
| 1511 |
name = cg_weapons[ cg.weaponSelect ].item->pickup_name; |
| 1512 |
if ( name ) { |
| 1513 |
w = CG_DrawStrlen( name ) * BIGCHAR_WIDTH; |
| 1514 |
x = ( SCREEN_WIDTH - w ) / 2; |
| 1515 |
CG_DrawBigStringColor(x, y - 22, name, color); |
| 1516 |
} |
| 1517 |
} |
| 1518 |
|
| 1519 |
trap_R_SetColor( NULL ); |
| 1520 |
} |
| 1521 |
|
| 1522 |
|
| 1523 |
|
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
|
| 1528 |
static qboolean CG_WeaponSelectable( int i ) { |
| 1529 |
if ( !cg.snap->ps.ammo[i] ) { |
| 1530 |
return qfalse; |
| 1531 |
} |
| 1532 |
if ( ! (cg.snap->ps.stats[ STAT_WEAPONS ] & ( 1 << i ) ) ) { |
| 1533 |
return qfalse; |
| 1534 |
} |
| 1535 |
|
| 1536 |
return qtrue; |
| 1537 |
} |
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
void CG_NextWeapon_f( void ) { |
| 1545 |
int i; |
| 1546 |
int original; |
| 1547 |
|
| 1548 |
if ( !cg.snap ) { |
| 1549 |
return; |
| 1550 |
} |
| 1551 |
if ( cg.snap->ps.pm_flags & PMF_FOLLOW ) { |
| 1552 |
return; |
| 1553 |
} |
| 1554 |
|
| 1555 |
cg.weaponSelectTime = cg.time; |
| 1556 |
original = cg.weaponSelect; |
| 1557 |
|
| 1558 |
for ( i = 0 ; i < MAX_WEAPONS ; i++ ) { |
| 1559 |
cg.weaponSelect++; |
| 1560 |
if ( cg.weaponSelect == MAX_WEAPONS ) { |
| 1561 |
cg.weaponSelect = 0; |
| 1562 |
} |
| 1563 |
if ( cg.weaponSelect == WP_GAUNTLET ) { |
| 1564 |
continue; |
| 1565 |
} |
| 1566 |
if ( CG_WeaponSelectable( cg.weaponSelect ) ) { |
| 1567 |
break; |
| 1568 |
} |
| 1569 |
} |
| 1570 |
if ( i == MAX_WEAPONS ) { |
| 1571 |
cg.weaponSelect = original; |
| 1572 |
} |
| 1573 |
} |
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
|
| 1578 |
|
| 1579 |
|
| 1580 |
void CG_PrevWeapon_f( void ) { |
| 1581 |
int i; |
| 1582 |
int original; |
| 1583 |
|
| 1584 |
if ( !cg.snap ) { |
| 1585 |
return; |
| 1586 |
} |
| 1587 |
if ( cg.snap->ps.pm_flags & PMF_FOLLOW ) { |
| 1588 |
return; |
| 1589 |
} |
| 1590 |
|
| 1591 |
cg.weaponSelectTime = cg.time; |
| 1592 |
original = cg.weaponSelect; |
| 1593 |
|
| 1594 |
for ( i = 0 ; i < MAX_WEAPONS ; i++ ) { |
| 1595 |
cg.weaponSelect--; |
| 1596 |
if ( cg.weaponSelect == -1 ) { |
| 1597 |
cg.weaponSelect = MAX_WEAPONS - 1; |
| 1598 |
} |
| 1599 |
if ( cg.weaponSelect == WP_GAUNTLET ) { |
| 1600 |
continue; |
| 1601 |
} |
| 1602 |
if ( CG_WeaponSelectable( cg.weaponSelect ) ) { |
| 1603 |
break; |
| 1604 |
} |
| 1605 |
} |
| 1606 |
if ( i == MAX_WEAPONS ) { |
| 1607 |
cg.weaponSelect = original; |
| 1608 |
} |
| 1609 |
} |
| 1610 |
|
| 1611 |
|
| 1612 |
|
| 1613 |
|
| 1614 |
|
| 1615 |
|
| 1616 |
void CG_Weapon_f( void ) { |
| 1617 |
int num; |
| 1618 |
|
| 1619 |
if ( !cg.snap ) { |
| 1620 |
return; |
| 1621 |
} |
| 1622 |
if ( cg.snap->ps.pm_flags & PMF_FOLLOW ) { |
| 1623 |
return; |
| 1624 |
} |
| 1625 |
|
| 1626 |
num = atoi( CG_Argv( 1 ) ); |
| 1627 |
|
| 1628 |
if ( num < 1 || num > MAX_WEAPONS-1 ) { |
| 1629 |
return; |
| 1630 |
} |
| 1631 |
|
| 1632 |
cg.weaponSelectTime = cg.time; |
| 1633 |
|
| 1634 |
if ( ! ( cg.snap->ps.stats[STAT_WEAPONS] & ( 1 << num ) ) ) { |
| 1635 |
return; |
| 1636 |
} |
| 1637 |
|
| 1638 |
cg.weaponSelect = num; |
| 1639 |
} |
| 1640 |
|
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
void CG_OutOfAmmoChange( void ) { |
| 1649 |
int i; |
| 1650 |
|
| 1651 |
cg.weaponSelectTime = cg.time; |
| 1652 |
|
| 1653 |
for ( i = MAX_WEAPONS-1 ; i > 0 ; i-- ) { |
| 1654 |
if ( CG_WeaponSelectable( i ) ) { |
| 1655 |
cg.weaponSelect = i; |
| 1656 |
break; |
| 1657 |
} |
| 1658 |
} |
| 1659 |
} |
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
|
| 1670 |
|
| 1671 |
|
| 1672 |
|
| 1673 |
|
| 1674 |
|
| 1675 |
|
| 1676 |
|
| 1677 |
|
| 1678 |
void CG_FireWeapon( centity_t *cent ) { |
| 1679 |
entityState_t *ent; |
| 1680 |
int c; |
| 1681 |
weaponInfo_t *weap; |
| 1682 |
|
| 1683 |
ent = ¢->currentState; |
| 1684 |
if ( ent->weapon == WP_NONE ) { |
| 1685 |
return; |
| 1686 |
} |
| 1687 |
if ( ent->weapon >= WP_NUM_WEAPONS ) { |
| 1688 |
CG_Error( "CG_FireWeapon: ent->weapon >= WP_NUM_WEAPONS" ); |
| 1689 |
return; |
| 1690 |
} |
| 1691 |
weap = &cg_weapons[ ent->weapon ]; |
| 1692 |
|
| 1693 |
|
| 1694 |
|
| 1695 |
cent->muzzleFlashTime = cg.time; |
| 1696 |
|
| 1697 |
|
| 1698 |
if ( ent->weapon == WP_LIGHTNING ) { |
| 1699 |
if ( cent->pe.lightningFiring ) { |
| 1700 |
return; |
| 1701 |
} |
| 1702 |
} |
| 1703 |
|
| 1704 |
if( ent->weapon == WP_RAILGUN ) { |
| 1705 |
cent->pe.railFireTime = cg.time; |
| 1706 |
} |
| 1707 |
|
| 1708 |
|
| 1709 |
if ( cent->currentState.powerups & ( 1 << PW_QUAD ) ) { |
| 1710 |
trap_S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.media.quadSound ); |
| 1711 |
} |
| 1712 |
|
| 1713 |
|
| 1714 |
for ( c = 0 ; c < 4 ; c++ ) { |
| 1715 |
if ( !weap->flashSound[c] ) { |
| 1716 |
break; |
| 1717 |
} |
| 1718 |
} |
| 1719 |
if ( c > 0 ) { |
| 1720 |
c = rand() % c; |
| 1721 |
if ( weap->flashSound[c] ) |
| 1722 |
{ |
| 1723 |
trap_S_StartSound( NULL, ent->number, CHAN_WEAPON, weap->flashSound[c] ); |
| 1724 |
} |
| 1725 |
} |
| 1726 |
|
| 1727 |
|
| 1728 |
if ( weap->ejectBrassFunc && cg_brassTime.integer > 0 ) { |
| 1729 |
weap->ejectBrassFunc( cent ); |
| 1730 |
} |
| 1731 |
} |
| 1732 |
|
| 1733 |
|
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
void CG_MissileHitWall( int weapon, int clientNum, vec3_t origin, vec3_t dir, impactSound_t soundType ) { |
| 1742 |
qhandle_t mod; |
| 1743 |
qhandle_t mark; |
| 1744 |
qhandle_t shader; |
| 1745 |
sfxHandle_t sfx; |
| 1746 |
float radius; |
| 1747 |
float light; |
| 1748 |
vec3_t lightColor; |
| 1749 |
localEntity_t *le; |
| 1750 |
int r; |
| 1751 |
qboolean alphaFade; |
| 1752 |
qboolean isSprite; |
| 1753 |
int duration; |
| 1754 |
vec3_t sprOrg; |
| 1755 |
vec3_t sprVel; |
| 1756 |
|
| 1757 |
mod = 0; |
| 1758 |
shader = 0; |
| 1759 |
light = 0; |
| 1760 |
lightColor[0] = 1; |
| 1761 |
lightColor[1] = 1; |
| 1762 |
lightColor[2] = 0; |
| 1763 |
|
| 1764 |
|
| 1765 |
isSprite = qfalse; |
| 1766 |
duration = 600; |
| 1767 |
|
| 1768 |
switch ( weapon ) { |
| 1769 |
default: |
| 1770 |
#ifdef MISSIONPACK |
| 1771 |
case WP_NAILGUN: |
| 1772 |
if( soundType == IMPACTSOUND_FLESH ) { |
| 1773 |
sfx = cgs.media.sfx_nghitflesh; |
| 1774 |
} else if( soundType == IMPACTSOUND_METAL ) { |
| 1775 |
sfx = cgs.media.sfx_nghitmetal; |
| 1776 |
} else { |
| 1777 |
sfx = cgs.media.sfx_nghit; |
| 1778 |
} |
| 1779 |
mark = cgs.media.holeMarkShader; |
| 1780 |
radius = 12; |
| 1781 |
break; |
| 1782 |
#endif |
| 1783 |
case WP_LIGHTNING: |
| 1784 |
|
| 1785 |
r = rand() & 3; |
| 1786 |
if ( r < 2 ) { |
| 1787 |
sfx = cgs.media.sfx_lghit2; |
| 1788 |
} else if ( r == 2 ) { |
| 1789 |
sfx = cgs.media.sfx_lghit1; |
| 1790 |
} else { |
| 1791 |
sfx = cgs.media.sfx_lghit3; |
| 1792 |
} |
| 1793 |
mark = cgs.media.holeMarkShader; |
| 1794 |
radius = 12; |
| 1795 |
break; |
| 1796 |
#ifdef MISSIONPACK |
| 1797 |
case WP_PROX_LAUNCHER: |
| 1798 |
mod = cgs.media.dishFlashModel; |
| 1799 |
shader = cgs.media.grenadeExplosionShader; |
| 1800 |
sfx = cgs.media.sfx_proxexp; |
| 1801 |
mark = cgs.media.burnMarkShader; |
| 1802 |
radius = 64; |
| 1803 |
light = 300; |
| 1804 |
isSprite = qtrue; |
| 1805 |
break; |
| 1806 |
#endif |
| 1807 |
case WP_GRENADE_LAUNCHER: |
| 1808 |
mod = cgs.media.dishFlashModel; |
| 1809 |
shader = cgs.media.grenadeExplosionShader; |
| 1810 |
sfx = cgs.media.sfx_rockexp; |
| 1811 |
mark = cgs.media.burnMarkShader; |
| 1812 |
radius = 64; |
| 1813 |
light = 300; |
| 1814 |
isSprite = qtrue; |
| 1815 |
break; |
| 1816 |
case WP_ROCKET_LAUNCHER: |
| 1817 |
mod = cgs.media.dishFlashModel; |
| 1818 |
shader = cgs.media.rocketExplosionShader; |
| 1819 |
sfx = cgs.media.sfx_rockexp; |
| 1820 |
mark = cgs.media.burnMarkShader; |
| 1821 |
radius = 64; |
| 1822 |
light = 300; |
| 1823 |
isSprite = qtrue; |
| 1824 |
duration = 1000; |
| 1825 |
lightColor[0] = 1; |
| 1826 |
lightColor[1] = 0.75; |
| 1827 |
lightColor[2] = 0.0; |
| 1828 |
if (cg_oldRocket.integer == 0) { |
| 1829 |
|
| 1830 |
VectorMA( origin, 24, dir, sprOrg ); |
| 1831 |
VectorScale( dir, 64, sprVel ); |
| 1832 |
|
| 1833 |
CG_ParticleExplosion( "explode1", sprOrg, sprVel, 1400, 20, 30 ); |
| 1834 |
} |
| 1835 |
break; |
| 1836 |
case WP_RAILGUN: |
| 1837 |
mod = cgs.media.ringFlashModel; |
| 1838 |
shader = cgs.media.railExplosionShader; |
| 1839 |
|
| 1840 |
sfx = cgs.media.sfx_plasmaexp; |
| 1841 |
mark = cgs.media.energyMarkShader; |
| 1842 |
radius = 24; |
| 1843 |
break; |
| 1844 |
case WP_PLASMAGUN: |
| 1845 |
mod = cgs.media.ringFlashModel; |
| 1846 |
shader = cgs.media.plasmaExplosionShader; |
| 1847 |
sfx = cgs.media.sfx_plasmaexp; |
| 1848 |
mark = cgs.media.energyMarkShader; |
| 1849 |
radius = 16; |
| 1850 |
break; |
| 1851 |
case WP_BFG: |
| 1852 |
mod = cgs.media.dishFlashModel; |
| 1853 |
shader = cgs.media.bfgExplosionShader; |
| 1854 |
sfx = cgs.media.sfx_rockexp; |
| 1855 |
mark = cgs.media.burnMarkShader; |
| 1856 |
radius = 32; |
| 1857 |
isSprite = qtrue; |
| 1858 |
break; |
| 1859 |
case WP_SHOTGUN: |
| 1860 |
mod = cgs.media.bulletFlashModel; |
| 1861 |
shader = cgs.media.bulletExplosionShader; |
| 1862 |
mark = cgs.media.bulletMarkShader; |
| 1863 |
sfx = 0; |
| 1864 |
radius = 4; |
| 1865 |
break; |
| 1866 |
|
| 1867 |
#ifdef MISSIONPACK |
| 1868 |
case WP_CHAINGUN: |
| 1869 |
mod = cgs.media.bulletFlashModel; |
| 1870 |
if( soundType == IMPACTSOUND_FLESH ) { |
| 1871 |
sfx = cgs.media.sfx_chghitflesh; |
| 1872 |
} else if( soundType == IMPACTSOUND_METAL ) { |
| 1873 |
sfx = cgs.media.sfx_chghitmetal; |
| 1874 |
} else { |
| 1875 |
sfx = cgs.media.sfx_chghit; |
| 1876 |
} |
| 1877 |
mark = cgs.media.bulletMarkShader; |
| 1878 |
|
| 1879 |
radius = 8; |
| 1880 |
break; |
| 1881 |
#endif |
| 1882 |
|
| 1883 |
case WP_MACHINEGUN: |
| 1884 |
mod = cgs.media.bulletFlashModel; |
| 1885 |
shader = cgs.media.bulletExplosionShader; |
| 1886 |
mark = cgs.media.bulletMarkShader; |
| 1887 |
|
| 1888 |
r = rand() & 3; |
| 1889 |
if ( r == 0 ) { |
| 1890 |
sfx = cgs.media.sfx_ric1; |
| 1891 |
} else if ( r == 1 ) { |
| 1892 |
sfx = cgs.media.sfx_ric2; |
| 1893 |
} else { |
| 1894 |
sfx = cgs.media.sfx_ric3; |
| 1895 |
} |
| 1896 |
|
| 1897 |
radius = 8; |
| 1898 |
break; |
| 1899 |
} |
| 1900 |
|
| 1901 |
if ( sfx ) { |
| 1902 |
trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, sfx ); |
| 1903 |
} |
| 1904 |
|
| 1905 |
|
| 1906 |
|
| 1907 |
|
| 1908 |
if ( mod ) { |
| 1909 |
le = CG_MakeExplosion( origin, dir, |
| 1910 |
mod, shader, |
| 1911 |
duration, isSprite ); |
| 1912 |
le->light = light; |
| 1913 |
VectorCopy( lightColor, le->lightColor ); |
| 1914 |
if ( weapon == WP_RAILGUN ) { |
| 1915 |
|
| 1916 |
VectorCopy( cgs.clientinfo[clientNum].color1, le->color ); |
| 1917 |
le->refEntity.shaderRGBA[0] = le->color[0] * 0xff; |
| 1918 |
le->refEntity.shaderRGBA[1] = le->color[1] * 0xff; |
| 1919 |
le->refEntity.shaderRGBA[2] = le->color[2] * 0xff; |
| 1920 |
le->refEntity.shaderRGBA[3] = 0xff; |
| 1921 |
} |
| 1922 |
} |
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
|
| 1927 |
alphaFade = (mark == cgs.media.energyMarkShader); |
| 1928 |
if ( weapon == WP_RAILGUN ) { |
| 1929 |
float *color; |
| 1930 |
|
| 1931 |
|
| 1932 |
color = cgs.clientinfo[clientNum].color1; |
| 1933 |
CG_ImpactMark( mark, origin, dir, random()*360, color[0],color[1], color[2],1, alphaFade, radius, qfalse ); |
| 1934 |
} else { |
| 1935 |
CG_ImpactMark( mark, origin, dir, random()*360, 1,1,1,1, alphaFade, radius, qfalse ); |
| 1936 |
} |
| 1937 |
} |
| 1938 |
|
| 1939 |
|
| 1940 |
|
| 1941 |
|
| 1942 |
|
| 1943 |
|
| 1944 |
|
| 1945 |
void CG_MissileHitPlayer( int weapon, vec3_t origin, vec3_t dir, int entityNum ) { |
| 1946 |
CG_Bleed( origin, entityNum ); |
| 1947 |
|
| 1948 |
|
| 1949 |
|
| 1950 |
switch ( weapon ) { |
| 1951 |
case WP_GRENADE_LAUNCHER: |
| 1952 |
case WP_ROCKET_LAUNCHER: |
| 1953 |
#ifdef MISSIONPACK |
| 1954 |
case WP_NAILGUN: |
| 1955 |
case WP_CHAINGUN: |
| 1956 |
case WP_PROX_LAUNCHER: |
| 1957 |
#endif |
| 1958 |
CG_MissileHitWall( weapon, 0, origin, dir, IMPACTSOUND_FLESH ); |
| 1959 |
break; |
| 1960 |
default: |
| 1961 |
break; |
| 1962 |
} |
| 1963 |
} |
| 1964 |
|
| 1965 |
|
| 1966 |
|
| 1967 |
|
| 1968 |
|
| 1969 |
|
| 1970 |
|
| 1971 |
|
| 1972 |
|
| 1973 |
|
| 1974 |
|
| 1975 |
|
| 1976 |
|
| 1977 |
|
| 1978 |
|
| 1979 |
|
| 1980 |
static void CG_ShotgunPellet( vec3_t start, vec3_t end, int skipNum ) { |
| 1981 |
trace_t tr; |
| 1982 |
int sourceContentType, destContentType; |
| 1983 |
|
| 1984 |
CG_Trace( &tr, start, NULL, NULL, end, skipNum, MASK_SHOT ); |
| 1985 |
|
| 1986 |
sourceContentType = CG_PointContents( start, 0 ); |
| 1987 |
destContentType = CG_PointContents( tr.endpos, 0 ); |
| 1988 |
|
| 1989 |
|
| 1990 |
if ( sourceContentType == destContentType ) { |
| 1991 |
if ( sourceContentType & CONTENTS_WATER ) { |
| 1992 |
CG_BubbleTrail( start, tr.endpos, 32 ); |
| 1993 |
} |
| 1994 |
} else if ( sourceContentType & CONTENTS_WATER ) { |
| 1995 |
trace_t trace; |
| 1996 |
|
| 1997 |
trap_CM_BoxTrace( &trace, end, start, NULL, NULL, 0, CONTENTS_WATER ); |
| 1998 |
CG_BubbleTrail( start, trace.endpos, 32 ); |
| 1999 |
} else if ( destContentType & CONTENTS_WATER ) { |
| 2000 |
trace_t trace; |
| 2001 |
|
| 2002 |
trap_CM_BoxTrace( &trace, start, end, NULL, NULL, 0, CONTENTS_WATER ); |
| 2003 |
CG_BubbleTrail( tr.endpos, trace.endpos, 32 ); |
| 2004 |
} |
| 2005 |
|
| 2006 |
if ( tr.surfaceFlags & SURF_NOIMPACT ) { |
| 2007 |
return; |
| 2008 |
} |
| 2009 |
|
| 2010 |
if ( cg_entities[tr.entityNum].currentState.eType == ET_PLAYER ) { |
| 2011 |
CG_MissileHitPlayer( WP_SHOTGUN, tr.endpos, tr.plane.normal, tr.entityNum ); |
| 2012 |
} else { |
| 2013 |
if ( tr.surfaceFlags & SURF_NOIMPACT ) { |
| 2014 |
|
| 2015 |
return; |
| 2016 |
} |
| 2017 |
if ( tr.surfaceFlags & SURF_METALSTEPS ) { |
| 2018 |
CG_MissileHitWall( WP_SHOTGUN, 0, tr.endpos, tr.plane.normal, IMPACTSOUND_METAL ); |
| 2019 |
} else { |
| 2020 |
CG_MissileHitWall( WP_SHOTGUN, 0, tr.endpos, tr.plane.normal, IMPACTSOUND_DEFAULT ); |
| 2021 |
} |
| 2022 |
} |
| 2023 |
} |
| 2024 |
|
| 2025 |
|
| 2026 |
|
| 2027 |
|
| 2028 |
|
| 2029 |
|
| 2030 |
|
| 2031 |
|
| 2032 |
|
| 2033 |
static void CG_ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, int otherEntNum ) { |
| 2034 |
int i; |
| 2035 |
float r, u; |
| 2036 |
vec3_t end; |
| 2037 |
vec3_t forward, right, up; |
| 2038 |
|
| 2039 |
|
| 2040 |
|
| 2041 |
VectorNormalize2( origin2, forward ); |
| 2042 |
PerpendicularVector( right, forward ); |
| 2043 |
CrossProduct( forward, right, up ); |
| 2044 |
|
| 2045 |
|
| 2046 |
for ( i = 0 ; i < DEFAULT_SHOTGUN_COUNT ; i++ ) { |
| 2047 |
r = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16; |
| 2048 |
u = Q_crandom( &seed ) * DEFAULT_SHOTGUN_SPREAD * 16; |
| 2049 |
VectorMA( origin, 8192 * 16, forward, end); |
| 2050 |
VectorMA (end, r, right, end); |
| 2051 |
VectorMA (end, u, up, end); |
| 2052 |
|
| 2053 |
CG_ShotgunPellet( origin, end, otherEntNum ); |
| 2054 |
} |
| 2055 |
} |
| 2056 |
|
| 2057 |
|
| 2058 |
|
| 2059 |
|
| 2060 |
|
| 2061 |
|
| 2062 |
void CG_ShotgunFire( entityState_t *es ) { |
| 2063 |
vec3_t v; |
| 2064 |
int contents; |
| 2065 |
|
| 2066 |
VectorSubtract( es->origin2, es->pos.trBase, v ); |
| 2067 |
VectorNormalize( v ); |
| 2068 |
VectorScale( v, 32, v ); |
| 2069 |
VectorAdd( es->pos.trBase, v, v ); |
| 2070 |
if ( cgs.glconfig.hardwareType != GLHW_RAGEPRO ) { |
| 2071 |
|
| 2072 |
vec3_t up; |
| 2073 |
|
| 2074 |
contents = CG_PointContents( es->pos.trBase, 0 ); |
| 2075 |
if ( !( contents & CONTENTS_WATER ) ) { |
| 2076 |
VectorSet( up, 0, 0, 8 ); |
| 2077 |
CG_SmokePuff( v, up, 32, 1, 1, 1, 0.33f, 900, cg.time, 0, LEF_PUFF_DONT_SCALE, cgs.media.shotgunSmokePuffShader ); |
| 2078 |
} |
| 2079 |
} |
| 2080 |
CG_ShotgunPattern( es->pos.trBase, es->origin2, es->eventParm, es->otherEntityNum ); |
| 2081 |
} |
| 2082 |
|
| 2083 |
|
| 2084 |
|
| 2085 |
|
| 2086 |
|
| 2087 |
|
| 2088 |
|
| 2089 |
|
| 2090 |
|
| 2091 |
|
| 2092 |
|
| 2093 |
|
| 2094 |
|
| 2095 |
|
| 2096 |
|
| 2097 |
void CG_Tracer( vec3_t source, vec3_t dest ) { |
| 2098 |
vec3_t forward, right; |
| 2099 |
polyVert_t verts[4]; |
| 2100 |
vec3_t line; |
| 2101 |
float len, begin, end; |
| 2102 |
vec3_t start, finish; |
| 2103 |
vec3_t midpoint; |
| 2104 |
|
| 2105 |
|
| 2106 |
VectorSubtract( dest, source, forward ); |
| 2107 |
len = VectorNormalize( forward ); |
| 2108 |
|
| 2109 |
|
| 2110 |
if ( len < 100 ) { |
| 2111 |
return; |
| 2112 |
} |
| 2113 |
begin = 50 + random() * (len - 60); |
| 2114 |
end = begin + cg_tracerLength.value; |
| 2115 |
if ( end > len ) { |
| 2116 |
end = len; |
| 2117 |
} |
| 2118 |
VectorMA( source, begin, forward, start ); |
| 2119 |
VectorMA( source, end, forward, finish ); |
| 2120 |
|
| 2121 |
line[0] = DotProduct( forward, cg.refdef.viewaxis[1] ); |
| 2122 |
line[1] = DotProduct( forward, cg.refdef.viewaxis[2] ); |
| 2123 |
|
| 2124 |
VectorScale( cg.refdef.viewaxis[1], line[1], right ); |
| 2125 |
VectorMA( right, -line[0], cg.refdef.viewaxis[2], right ); |
| 2126 |
VectorNormalize( right ); |
| 2127 |
|
| 2128 |
VectorMA( finish, cg_tracerWidth.value, right, verts[0].xyz ); |
| 2129 |
verts[0].st[0] = 0; |
| 2130 |
verts[0].st[1] = 1; |
| 2131 |
verts[0].modulate[0] = 255; |
| 2132 |
verts[0].modulate[1] = 255; |
| 2133 |
verts[0].modulate[2] = 255; |
| 2134 |
verts[0].modulate[3] = 255; |
| 2135 |
|
| 2136 |
VectorMA( finish, -cg_tracerWidth.value, right, verts[1].xyz ); |
| 2137 |
verts[1].st[0] = 1; |
| 2138 |
verts[1].st[1] = 0; |
| 2139 |
verts[1].modulate[0] = 255; |
| 2140 |
verts[1].modulate[1] = 255; |
| 2141 |
verts[1].modulate[2] = 255; |
| 2142 |
verts[1].modulate[3] = 255; |
| 2143 |
|
| 2144 |
VectorMA( start, -cg_tracerWidth.value, right, verts[2].xyz ); |
| 2145 |
verts[2].st[0] = 1; |
| 2146 |
verts[2].st[1] = 1; |
| 2147 |
verts[2].modulate[0] = 255; |
| 2148 |
verts[2].modulate[1] = 255; |
| 2149 |
verts[2].modulate[2] = 255; |
| 2150 |
verts[2].modulate[3] = 255; |
| 2151 |
|
| 2152 |
VectorMA( start, cg_tracerWidth.value, right, verts[3].xyz ); |
| 2153 |
verts[3].st[0] = 0; |
| 2154 |
verts[3].st[1] = 0; |
| 2155 |
verts[3].modulate[0] = 255; |
| 2156 |
verts[3].modulate[1] = 255; |
| 2157 |
verts[3].modulate[2] = 255; |
| 2158 |
verts[3].modulate[3] = 255; |
| 2159 |
|
| 2160 |
trap_R_AddPolyToScene( cgs.media.tracerShader, 4, verts ); |
| 2161 |
|
| 2162 |
midpoint[0] = ( start[0] + finish[0] ) * 0.5; |
| 2163 |
midpoint[1] = ( start[1] + finish[1] ) * 0.5; |
| 2164 |
midpoint[2] = ( start[2] + finish[2] ) * 0.5; |
| 2165 |
|
| 2166 |
|
| 2167 |
trap_S_StartSound( midpoint, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.tracerSound ); |
| 2168 |
|
| 2169 |
} |
| 2170 |
|
| 2171 |
|
| 2172 |
|
| 2173 |
|
| 2174 |
|
| 2175 |
|
| 2176 |
|
| 2177 |
static qboolean CG_CalcMuzzlePoint( int entityNum, vec3_t muzzle ) { |
| 2178 |
vec3_t forward; |
| 2179 |
centity_t *cent; |
| 2180 |
int anim; |
| 2181 |
|
| 2182 |
if ( entityNum == cg.snap->ps.clientNum ) { |
| 2183 |
VectorCopy( cg.snap->ps.origin, muzzle ); |
| 2184 |
muzzle[2] += cg.snap->ps.viewheight; |
| 2185 |
AngleVectors( cg.snap->ps.viewangles, forward, NULL, NULL ); |
| 2186 |
VectorMA( muzzle, 14, forward, muzzle ); |
| 2187 |
return qtrue; |
| 2188 |
} |
| 2189 |
|
| 2190 |
cent = &cg_entities[entityNum]; |
| 2191 |
if ( !cent->currentValid ) { |
| 2192 |
return qfalse; |
| 2193 |
} |
| 2194 |
|
| 2195 |
VectorCopy( cent->currentState.pos.trBase, muzzle ); |
| 2196 |
|
| 2197 |
AngleVectors( cent->currentState.apos.trBase, forward, NULL, NULL ); |
| 2198 |
anim = cent->currentState.legsAnim & ~ANIM_TOGGLEBIT; |
| 2199 |
if ( anim == LEGS_WALKCR || anim == LEGS_IDLECR ) { |
| 2200 |
muzzle[2] += CROUCH_VIEWHEIGHT; |
| 2201 |
} else { |
| 2202 |
muzzle[2] += DEFAULT_VIEWHEIGHT; |
| 2203 |
} |
| 2204 |
|
| 2205 |
VectorMA( muzzle, 14, forward, muzzle ); |
| 2206 |
|
| 2207 |
return qtrue; |
| 2208 |
|
| 2209 |
} |
| 2210 |
|
| 2211 |
|
| 2212 |
|
| 2213 |
|
| 2214 |
|
| 2215 |
|
| 2216 |
|
| 2217 |
|
| 2218 |
void CG_Bullet( vec3_t end, int sourceEntityNum, vec3_t normal, qboolean flesh, int fleshEntityNum ) { |
| 2219 |
trace_t trace; |
| 2220 |
int sourceContentType, destContentType; |
| 2221 |
vec3_t start; |
| 2222 |
|
| 2223 |
|
| 2224 |
|
| 2225 |
if ( sourceEntityNum >= 0 && cg_tracerChance.value > 0 ) { |
| 2226 |
if ( CG_CalcMuzzlePoint( sourceEntityNum, start ) ) { |
| 2227 |
sourceContentType = CG_PointContents( start, 0 ); |
| 2228 |
destContentType = CG_PointContents( end, 0 ); |
| 2229 |
|
| 2230 |
|
| 2231 |
if ( ( sourceContentType == destContentType ) && ( sourceContentType & CONTENTS_WATER ) ) { |
| 2232 |
CG_BubbleTrail( start, end, 32 ); |
| 2233 |
} |
| 2234 |
|
| 2235 |
else if ( ( sourceContentType & CONTENTS_WATER ) ) { |
| 2236 |
trap_CM_BoxTrace( &trace, end, start, NULL, NULL, 0, CONTENTS_WATER ); |
| 2237 |
CG_BubbleTrail( start, trace.endpos, 32 ); |
| 2238 |
} |
| 2239 |
|
| 2240 |
else if ( ( destContentType & CONTENTS_WATER ) ) { |
| 2241 |
trap_CM_BoxTrace( &trace, start, end, NULL, NULL, 0, CONTENTS_WATER ); |
| 2242 |
CG_BubbleTrail( trace.endpos, end, 32 ); |
| 2243 |
} |
| 2244 |
|
| 2245 |
|
| 2246 |
if ( random() < cg_tracerChance.value ) { |
| 2247 |
CG_Tracer( start, end ); |
| 2248 |
} |
| 2249 |
} |
| 2250 |
} |
| 2251 |
|
| 2252 |
|
| 2253 |
if ( flesh ) { |
| 2254 |
CG_Bleed( end, fleshEntityNum ); |
| 2255 |
} else { |
| 2256 |
CG_MissileHitWall( WP_MACHINEGUN, 0, end, normal, IMPACTSOUND_DEFAULT ); |
| 2257 |
} |
| 2258 |
|
| 2259 |
} |