| 1 |
/* |
| 2 |
=========================================================================== |
| 3 |
Copyright (C) 1999-2005 Id Software, Inc. |
| 4 |
|
| 5 |
This file is part of Quake III Arena source code. |
| 6 |
|
| 7 |
Quake III Arena source code is free software; you can redistribute it |
| 8 |
and/or modify it under the terms of the GNU General Public License as |
| 9 |
published by the Free Software Foundation; either version 2 of the License, |
| 10 |
or (at your option) any later version. |
| 11 |
|
| 12 |
Quake III Arena source code is distributed in the hope that it will be |
| 13 |
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
GNU General Public License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with Quake III Arena source code; if not, write to the Free Software |
| 19 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 |
=========================================================================== |
| 21 |
*/ |
| 22 |
// |
| 23 |
// cg_event.c -- handle entity events at snapshot or playerstate transitions |
| 24 |
|
| 25 |
#include "cg_local.h" |
| 26 |
|
| 27 |
// for the voice chats |
| 28 |
#ifdef MISSIONPACK // bk001205 |
| 29 |
#include "../../ui/menudef.h" |
| 30 |
#endif |
| 31 |
//========================================================================== |
| 32 |
|
| 33 |
/* |
| 34 |
=================== |
| 35 |
CG_PlaceString |
| 36 |
|
| 37 |
Also called by scoreboard drawing |
| 38 |
=================== |
| 39 |
*/ |
| 40 |
const char *CG_PlaceString( int rank ) { |
| 41 |
static char str[64]; |
| 42 |
char *s, *t; |
| 43 |
|
| 44 |
if ( rank & RANK_TIED_FLAG ) { |
| 45 |
rank &= ~RANK_TIED_FLAG; |
| 46 |
t = "Tied for "; |
| 47 |
} else { |
| 48 |
t = ""; |
| 49 |
} |
| 50 |
|
| 51 |
if ( rank == 1 ) { |
| 52 |
s = S_COLOR_BLUE "1st" S_COLOR_WHITE; // draw in blue |
| 53 |
} else if ( rank == 2 ) { |
| 54 |
s = S_COLOR_RED "2nd" S_COLOR_WHITE; // draw in red |
| 55 |
} else if ( rank == 3 ) { |
| 56 |
s = S_COLOR_YELLOW "3rd" S_COLOR_WHITE; // draw in yellow |
| 57 |
} else if ( rank == 11 ) { |
| 58 |
s = "11th"; |
| 59 |
} else if ( rank == 12 ) { |
| 60 |
s = "12th"; |
| 61 |
} else if ( rank == 13 ) { |
| 62 |
s = "13th"; |
| 63 |
} else if ( rank % 10 == 1 ) { |
| 64 |
s = va("%ist", rank); |
| 65 |
} else if ( rank % 10 == 2 ) { |
| 66 |
s = va("%ind", rank); |
| 67 |
} else if ( rank % 10 == 3 ) { |
| 68 |
s = va("%ird", rank); |
| 69 |
} else { |
| 70 |
s = va("%ith", rank); |
| 71 |
} |
| 72 |
|
| 73 |
Com_sprintf( str, sizeof( str ), "%s%s", t, s ); |
| 74 |
return str; |
| 75 |
} |
| 76 |
|
| 77 |
/* |
| 78 |
============= |
| 79 |
CG_Obituary |
| 80 |
============= |
| 81 |
*/ |
| 82 |
static void CG_Obituary( entityState_t *ent ) { |
| 83 |
int mod; |
| 84 |
int target, attacker; |
| 85 |
char *message; |
| 86 |
char *message2; |
| 87 |
const char *targetInfo; |
| 88 |
const char *attackerInfo; |
| 89 |
char targetName[32]; |
| 90 |
char attackerName[32]; |
| 91 |
gender_t gender; |
| 92 |
clientInfo_t *ci; |
| 93 |
|
| 94 |
target = ent->otherEntityNum; |
| 95 |
attacker = ent->otherEntityNum2; |
| 96 |
mod = ent->eventParm; |
| 97 |
|
| 98 |
if ( target < 0 || target >= MAX_CLIENTS ) { |
| 99 |
CG_Error( "CG_Obituary: target out of range" ); |
| 100 |
} |
| 101 |
ci = &cgs.clientinfo[target]; |
| 102 |
|
| 103 |
if ( attacker < 0 || attacker >= MAX_CLIENTS ) { |
| 104 |
attacker = ENTITYNUM_WORLD; |
| 105 |
attackerInfo = NULL; |
| 106 |
} else { |
| 107 |
attackerInfo = CG_ConfigString( CS_PLAYERS + attacker ); |
| 108 |
} |
| 109 |
|
| 110 |
targetInfo = CG_ConfigString( CS_PLAYERS + target ); |
| 111 |
if ( !targetInfo ) { |
| 112 |
return; |
| 113 |
} |
| 114 |
Q_strncpyz( targetName, Info_ValueForKey( targetInfo, "n" ), sizeof(targetName) - 2); |
| 115 |
strcat( targetName, S_COLOR_WHITE ); |
| 116 |
|
| 117 |
message2 = ""; |
| 118 |
|
| 119 |
// check for single client messages |
| 120 |
|
| 121 |
if(attacker != ENTITYNUM_WORLD) |
| 122 |
message = NULL; |
| 123 |
else |
| 124 |
switch( mod ) { |
| 125 |
case MOD_SUICIDE: |
| 126 |
message = "suicides"; |
| 127 |
break; |
| 128 |
case MOD_FALLING: |
| 129 |
message = "cratered"; |
| 130 |
break; |
| 131 |
case MOD_CRUSH: |
| 132 |
message = "was squished"; |
| 133 |
break; |
| 134 |
case MOD_WATER: |
| 135 |
message = "sank like a rock"; |
| 136 |
break; |
| 137 |
case MOD_SLIME: |
| 138 |
message = "melted"; |
| 139 |
break; |
| 140 |
case MOD_LAVA: |
| 141 |
message = "does a back flip into the lava"; |
| 142 |
break; |
| 143 |
case MOD_TARGET_LASER: |
| 144 |
message = "saw the light"; |
| 145 |
break; |
| 146 |
case MOD_TRIGGER_HURT: |
| 147 |
message = "was in the wrong place"; |
| 148 |
break; |
| 149 |
default: |
| 150 |
message = NULL; |
| 151 |
break; |
| 152 |
} |
| 153 |
|
| 154 |
if (attacker == target) { |
| 155 |
gender = ci->gender; |
| 156 |
switch (mod) { |
| 157 |
case MOD_KAMIKAZE: |
| 158 |
message = "goes out with a bang"; |
| 159 |
break; |
| 160 |
case MOD_GRENADE_SPLASH: |
| 161 |
if ( gender == GENDER_FEMALE ) |
| 162 |
message = "tripped on her own grenade"; |
| 163 |
else if ( gender == GENDER_NEUTER ) |
| 164 |
message = "tripped on its own grenade"; |
| 165 |
else |
| 166 |
message = "tripped on his own grenade"; |
| 167 |
break; |
| 168 |
case MOD_ROCKET_SPLASH: |
| 169 |
if ( gender == GENDER_FEMALE ) |
| 170 |
message = "blew herself up"; |
| 171 |
else if ( gender == GENDER_NEUTER ) |
| 172 |
message = "blew itself up"; |
| 173 |
else |
| 174 |
message = "blew himself up"; |
| 175 |
break; |
| 176 |
case MOD_PLASMA_SPLASH: |
| 177 |
if ( gender == GENDER_FEMALE ) |
| 178 |
message = "melted herself"; |
| 179 |
else if ( gender == GENDER_NEUTER ) |
| 180 |
message = "melted itself"; |
| 181 |
else |
| 182 |
message = "melted himself"; |
| 183 |
break; |
| 184 |
case MOD_BFG_SPLASH: |
| 185 |
message = "should have used a smaller gun"; |
| 186 |
break; |
| 187 |
case MOD_PROXIMITY_MINE: |
| 188 |
if( gender == GENDER_FEMALE ) { |
| 189 |
message = "found her prox mine"; |
| 190 |
} else if ( gender == GENDER_NEUTER ) { |
| 191 |
message = "found its prox mine"; |
| 192 |
} else { |
| 193 |
message = "found his prox mine"; |
| 194 |
} |
| 195 |
break; |
| 196 |
default: |
| 197 |
if ( gender == GENDER_FEMALE ) |
| 198 |
message = "killed herself"; |
| 199 |
else if ( gender == GENDER_NEUTER ) |
| 200 |
message = "killed itself"; |
| 201 |
else |
| 202 |
message = "killed himself"; |
| 203 |
break; |
| 204 |
} |
| 205 |
} |
| 206 |
|
| 207 |
//If a suicide happens while disconnecting then we might not have a targetName |
| 208 |
if (message && strlen(targetName)) { |
| 209 |
CG_Printf( "%s %s.\n", targetName, message); |
| 210 |
return; |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
// check for kill messages from the current clientNum |
| 215 |
if ( attacker == cg.snap->ps.clientNum ) { |
| 216 |
char *s; |
| 217 |
|
| 218 |
if ( cgs.gametype < GT_TEAM ) { |
| 219 |
s = va("You fragged %s\n%s place with %i", targetName, |
| 220 |
CG_PlaceString( cg.snap->ps.persistant[PERS_RANK] + 1 ), |
| 221 |
cg.snap->ps.persistant[PERS_SCORE] ); |
| 222 |
} else { |
| 223 |
if(ent->generic1) |
| 224 |
s = va("You fragged your ^1TEAMMATE^7 %s", targetName ); |
| 225 |
else |
| 226 |
s = va("You fragged %s", targetName ); |
| 227 |
} |
| 228 |
#ifdef MISSIONPACK |
| 229 |
if (!(cg_singlePlayerActive.integer && cg_cameraOrbit.integer)) { |
| 230 |
CG_CenterPrint( s, SCREEN_HEIGHT * 0.30, (int)(BIGCHAR_WIDTH * cg_fragmsgsize.value) ); |
| 231 |
} |
| 232 |
#else |
| 233 |
CG_CenterPrint( s, SCREEN_HEIGHT * 0.30, (int)(BIGCHAR_WIDTH * cg_fragmsgsize.value) ); |
| 234 |
#endif |
| 235 |
|
| 236 |
// print the text message as well |
| 237 |
} |
| 238 |
|
| 239 |
// check for double client messages |
| 240 |
if ( !attackerInfo ) { |
| 241 |
attacker = ENTITYNUM_WORLD; |
| 242 |
strcpy( attackerName, "noname" ); |
| 243 |
} else { |
| 244 |
Q_strncpyz( attackerName, Info_ValueForKey( attackerInfo, "n" ), sizeof(attackerName) - 2); |
| 245 |
strcat( attackerName, S_COLOR_WHITE ); |
| 246 |
// check for kill messages about the current clientNum |
| 247 |
if ( target == cg.snap->ps.clientNum ) { |
| 248 |
Q_strncpyz( cg.killerName, attackerName, sizeof( cg.killerName ) ); |
| 249 |
} |
| 250 |
} |
| 251 |
|
| 252 |
if ( attacker != ENTITYNUM_WORLD ) { |
| 253 |
|
| 254 |
if(ent->generic1) { |
| 255 |
message = "was killed by ^1TEAMMATE^7"; |
| 256 |
} |
| 257 |
else |
| 258 |
switch (mod) { |
| 259 |
case MOD_GRAPPLE: |
| 260 |
message = "was caught by"; |
| 261 |
break; |
| 262 |
case MOD_GAUNTLET: |
| 263 |
message = "was pummeled by"; |
| 264 |
break; |
| 265 |
case MOD_MACHINEGUN: |
| 266 |
message = "was machinegunned by"; |
| 267 |
break; |
| 268 |
case MOD_SHOTGUN: |
| 269 |
message = "was gunned down by"; |
| 270 |
break; |
| 271 |
case MOD_GRENADE: |
| 272 |
message = "ate"; |
| 273 |
message2 = "'s grenade"; |
| 274 |
break; |
| 275 |
case MOD_GRENADE_SPLASH: |
| 276 |
message = "was shredded by"; |
| 277 |
message2 = "'s shrapnel"; |
| 278 |
break; |
| 279 |
case MOD_ROCKET: |
| 280 |
message = "ate"; |
| 281 |
message2 = "'s rocket"; |
| 282 |
break; |
| 283 |
case MOD_ROCKET_SPLASH: |
| 284 |
message = "almost dodged"; |
| 285 |
message2 = "'s rocket"; |
| 286 |
break; |
| 287 |
case MOD_PLASMA: |
| 288 |
message = "was melted by"; |
| 289 |
message2 = "'s plasmagun"; |
| 290 |
break; |
| 291 |
case MOD_PLASMA_SPLASH: |
| 292 |
message = "was melted by"; |
| 293 |
message2 = "'s plasmagun"; |
| 294 |
break; |
| 295 |
case MOD_RAILGUN: |
| 296 |
message = "was railed by"; |
| 297 |
break; |
| 298 |
case MOD_LIGHTNING: |
| 299 |
message = "was electrocuted by"; |
| 300 |
break; |
| 301 |
case MOD_BFG: |
| 302 |
case MOD_BFG_SPLASH: |
| 303 |
message = "was blasted by"; |
| 304 |
message2 = "'s BFG"; |
| 305 |
break; |
| 306 |
case MOD_NAIL: |
| 307 |
message = "was nailed by"; |
| 308 |
break; |
| 309 |
case MOD_CHAINGUN: |
| 310 |
message = "got lead poisoning from"; |
| 311 |
message2 = "'s Chaingun"; |
| 312 |
break; |
| 313 |
case MOD_PROXIMITY_MINE: |
| 314 |
message = "was too close to"; |
| 315 |
message2 = "'s Prox Mine"; |
| 316 |
break; |
| 317 |
case MOD_KAMIKAZE: |
| 318 |
message = "falls to"; |
| 319 |
message2 = "'s Kamikaze blast"; |
| 320 |
break; |
| 321 |
case MOD_JUICED: |
| 322 |
message = "was juiced by"; |
| 323 |
break; |
| 324 |
case MOD_TELEFRAG: |
| 325 |
message = "tried to invade"; |
| 326 |
message2 = "'s personal space"; |
| 327 |
break; |
| 328 |
case MOD_LAVA: |
| 329 |
message = "was given a hot bath by"; |
| 330 |
break; |
| 331 |
case MOD_SLIME: |
| 332 |
message = "was given a acid bath by"; |
| 333 |
break; |
| 334 |
case MOD_FALLING: |
| 335 |
message = "was given a small push by"; |
| 336 |
break; |
| 337 |
case MOD_TRIGGER_HURT: |
| 338 |
message = "was helped on the way by"; |
| 339 |
break; |
| 340 |
case MOD_CRUSH: |
| 341 |
message = "was crushed in"; |
| 342 |
message2 = "'s trap"; |
| 343 |
break; |
| 344 |
default: |
| 345 |
message = "was killed by"; |
| 346 |
break; |
| 347 |
} |
| 348 |
|
| 349 |
if (message) { |
| 350 |
CG_Printf( "%s %s %s%s\n", |
| 351 |
targetName, message, attackerName, message2); |
| 352 |
return; |
| 353 |
} |
| 354 |
} |
| 355 |
|
| 356 |
// we don't know what it was |
| 357 |
CG_Printf( "%s died.\n", targetName ); |
| 358 |
} |
| 359 |
|
| 360 |
//========================================================================== |
| 361 |
|
| 362 |
/* |
| 363 |
=============== |
| 364 |
CG_UseItem |
| 365 |
=============== |
| 366 |
*/ |
| 367 |
static void CG_UseItem( centity_t *cent ) { |
| 368 |
clientInfo_t *ci; |
| 369 |
int itemNum, clientNum; |
| 370 |
gitem_t *item; |
| 371 |
entityState_t *es; |
| 372 |
|
| 373 |
es = ¢->currentState; |
| 374 |
|
| 375 |
itemNum = (es->event & ~EV_EVENT_BITS) - EV_USE_ITEM0; |
| 376 |
if ( itemNum < 0 || itemNum > HI_NUM_HOLDABLE ) { |
| 377 |
itemNum = 0; |
| 378 |
} |
| 379 |
|
| 380 |
// print a message if the local player |
| 381 |
if ( es->number == cg.snap->ps.clientNum ) { |
| 382 |
if ( !itemNum ) { |
| 383 |
CG_CenterPrint( "No item to use", SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH ); |
| 384 |
} else { |
| 385 |
item = BG_FindItemForHoldable( itemNum ); |
| 386 |
CG_CenterPrint( va("Use %s", item->pickup_name), SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH ); |
| 387 |
} |
| 388 |
} |
| 389 |
|
| 390 |
switch ( itemNum ) { |
| 391 |
default: |
| 392 |
case HI_NONE: |
| 393 |
trap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.useNothingSound ); |
| 394 |
break; |
| 395 |
|
| 396 |
case HI_TELEPORTER: |
| 397 |
break; |
| 398 |
|
| 399 |
case HI_MEDKIT: |
| 400 |
clientNum = cent->currentState.clientNum; |
| 401 |
if ( clientNum >= 0 && clientNum < MAX_CLIENTS ) { |
| 402 |
ci = &cgs.clientinfo[ clientNum ]; |
| 403 |
ci->medkitUsageTime = cg.time; |
| 404 |
} |
| 405 |
trap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.medkitSound ); |
| 406 |
break; |
| 407 |
|
| 408 |
//#ifdef MISSIONPACK |
| 409 |
case HI_KAMIKAZE: |
| 410 |
break; |
| 411 |
|
| 412 |
case HI_PORTAL: |
| 413 |
break; |
| 414 |
case HI_INVULNERABILITY: |
| 415 |
trap_S_StartSound (NULL, es->number, CHAN_BODY, cgs.media.useInvulnerabilitySound ); |
| 416 |
break; |
| 417 |
//#endif |
| 418 |
} |
| 419 |
|
| 420 |
} |
| 421 |
|
| 422 |
static qboolean CG_WeaponHigher(int currentWeapon, int newWeapon) { |
| 423 |
char *currentScore = NULL; |
| 424 |
char *newScore = NULL; |
| 425 |
char weapon[5]; |
| 426 |
Com_sprintf(weapon,5,"/%i/",currentWeapon); |
| 427 |
currentScore = strstr(cg_weaponOrder.string,weapon); |
| 428 |
Com_sprintf(weapon,5,"/%i/",newWeapon); |
| 429 |
newScore = strstr(cg_weaponOrder.string,weapon); |
| 430 |
if(!newScore || !currentScore) |
| 431 |
return qfalse; |
| 432 |
if(newScore>currentScore) |
| 433 |
return qtrue; |
| 434 |
else |
| 435 |
return qfalse; |
| 436 |
} |
| 437 |
|
| 438 |
/* |
| 439 |
================ |
| 440 |
CG_ItemPickup |
| 441 |
|
| 442 |
A new item was picked up this frame |
| 443 |
================ |
| 444 |
*/ |
| 445 |
static void CG_ItemPickup( int itemNum ) { |
| 446 |
cg.itemPickup = itemNum; |
| 447 |
cg.itemPickupTime = cg.time; |
| 448 |
cg.itemPickupBlendTime = cg.time; |
| 449 |
// see if it should be the grabbed weapon |
| 450 |
if ( bg_itemlist[itemNum].giType == IT_WEAPON ) { |
| 451 |
// select it immediately |
| 452 |
/* always*/ |
| 453 |
if ( cg_autoswitch.integer == 1 && bg_itemlist[itemNum].giTag != WP_MACHINEGUN ) { |
| 454 |
cg.weaponSelectTime = cg.time; |
| 455 |
cg.weaponSelect = bg_itemlist[itemNum].giTag; |
| 456 |
} |
| 457 |
/* if new */ |
| 458 |
if ( cg_autoswitch.integer == 2 && 0 == (cg.snap->ps.stats[ STAT_WEAPONS ] & (1 << bg_itemlist[itemNum].giTag) ) ) { |
| 459 |
cg.weaponSelectTime = cg.time; |
| 460 |
cg.weaponSelect = bg_itemlist[itemNum].giTag; |
| 461 |
} |
| 462 |
/* if better */ |
| 463 |
if ( cg_autoswitch.integer == 3 && CG_WeaponHigher(cg.weaponSelect,bg_itemlist[itemNum].giTag)) { |
| 464 |
cg.weaponSelectTime = cg.time; |
| 465 |
cg.weaponSelect = bg_itemlist[itemNum].giTag; |
| 466 |
} |
| 467 |
/* if new and better */ |
| 468 |
if ( cg_autoswitch.integer == 4 && 0 == (cg.snap->ps.stats[ STAT_WEAPONS ] & (1 << bg_itemlist[itemNum].giTag) ) |
| 469 |
&& CG_WeaponHigher(cg.weaponSelect,bg_itemlist[itemNum].giTag)) { |
| 470 |
cg.weaponSelectTime = cg.time; |
| 471 |
cg.weaponSelect = bg_itemlist[itemNum].giTag; |
| 472 |
} |
| 473 |
// |
| 474 |
} |
| 475 |
|
| 476 |
} |
| 477 |
|
| 478 |
/* |
| 479 |
================ |
| 480 |
CG_WaterLevel |
| 481 |
|
| 482 |
Returns waterlevel for entity origin |
| 483 |
================ |
| 484 |
*/ |
| 485 |
int CG_WaterLevel(centity_t *cent) { |
| 486 |
vec3_t point; |
| 487 |
int contents, sample1, sample2, anim, waterlevel; |
| 488 |
|
| 489 |
// get waterlevel, accounting for ducking |
| 490 |
waterlevel = 0; |
| 491 |
VectorCopy(cent->lerpOrigin, point); |
| 492 |
point[2] += MINS_Z + 1; |
| 493 |
anim = cent->currentState.legsAnim & ~ANIM_TOGGLEBIT; |
| 494 |
|
| 495 |
if (anim == LEGS_WALKCR || anim == LEGS_IDLECR) { |
| 496 |
point[2] += CROUCH_VIEWHEIGHT; |
| 497 |
} else { |
| 498 |
point[2] += DEFAULT_VIEWHEIGHT; |
| 499 |
} |
| 500 |
|
| 501 |
contents = CG_PointContents(point, -1); |
| 502 |
|
| 503 |
if (contents & MASK_WATER) { |
| 504 |
sample2 = point[2] - MINS_Z; |
| 505 |
sample1 = sample2 / 2; |
| 506 |
waterlevel = 1; |
| 507 |
point[2] = cent->lerpOrigin[2] + MINS_Z + sample1; |
| 508 |
contents = CG_PointContents(point, -1); |
| 509 |
|
| 510 |
if (contents & MASK_WATER) { |
| 511 |
waterlevel = 2; |
| 512 |
point[2] = cent->lerpOrigin[2] + MINS_Z + sample2; |
| 513 |
contents = CG_PointContents(point, -1); |
| 514 |
|
| 515 |
if (contents & MASK_WATER) { |
| 516 |
waterlevel = 3; |
| 517 |
} |
| 518 |
} |
| 519 |
} |
| 520 |
|
| 521 |
return waterlevel; |
| 522 |
} |
| 523 |
|
| 524 |
/* |
| 525 |
================ |
| 526 |
CG_PainEvent |
| 527 |
|
| 528 |
Also called by playerstate transition |
| 529 |
================ |
| 530 |
*/ |
| 531 |
void CG_PainEvent( centity_t *cent, int health ) { |
| 532 |
char *snd; |
| 533 |
|
| 534 |
// don't do more than two pain sounds a second |
| 535 |
if ( cg.time - cent->pe.painTime < 500 ) { |
| 536 |
return; |
| 537 |
} |
| 538 |
|
| 539 |
if ( health < 25 ) { |
| 540 |
snd = "*pain25_1.wav"; |
| 541 |
} else if ( health < 50 ) { |
| 542 |
snd = "*pain50_1.wav"; |
| 543 |
} else if ( health < 75 ) { |
| 544 |
snd = "*pain75_1.wav"; |
| 545 |
} else { |
| 546 |
snd = "*pain100_1.wav"; |
| 547 |
} |
| 548 |
// play a gurp sound instead of a normal pain sound |
| 549 |
if (CG_WaterLevel(cent) >= 1) { |
| 550 |
if (rand()&1) { |
| 551 |
trap_S_StartSound(NULL, cent->currentState.number, CHAN_VOICE, CG_CustomSound(cent->currentState.number, "sound/player/gurp1.wav")); |
| 552 |
} else { |
| 553 |
trap_S_StartSound(NULL, cent->currentState.number, CHAN_VOICE, CG_CustomSound(cent->currentState.number, "sound/player/gurp2.wav")); |
| 554 |
} |
| 555 |
} else { |
| 556 |
trap_S_StartSound(NULL, cent->currentState.number, CHAN_VOICE, CG_CustomSound(cent->currentState.number, snd)); |
| 557 |
} |
| 558 |
// save pain time for programitic twitch animation |
| 559 |
cent->pe.painTime = cg.time; |
| 560 |
cent->pe.painDirection ^= 1; |
| 561 |
} |
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
/* |
| 566 |
============== |
| 567 |
CG_EntityEvent |
| 568 |
|
| 569 |
An entity has an event value |
| 570 |
also called by CG_CheckPlayerstateEvents |
| 571 |
============== |
| 572 |
*/ |
| 573 |
#define DEBUGNAME(x) if(cg_debugEvents.integer){CG_Printf(x"\n");} |
| 574 |
void CG_EntityEvent( centity_t *cent, vec3_t position ) { |
| 575 |
entityState_t *es; |
| 576 |
int event; |
| 577 |
vec3_t dir; |
| 578 |
const char *s; |
| 579 |
int clientNum; |
| 580 |
clientInfo_t *ci; |
| 581 |
|
| 582 |
es = ¢->currentState; |
| 583 |
event = es->event & ~EV_EVENT_BITS; |
| 584 |
|
| 585 |
if ( cg_debugEvents.integer ) { |
| 586 |
CG_Printf( "ent:%3i event:%3i ", es->number, event ); |
| 587 |
} |
| 588 |
|
| 589 |
if ( !event ) { |
| 590 |
DEBUGNAME("ZEROEVENT"); |
| 591 |
return; |
| 592 |
} |
| 593 |
|
| 594 |
clientNum = es->clientNum; |
| 595 |
if ( clientNum < 0 || clientNum >= MAX_CLIENTS ) { |
| 596 |
clientNum = 0; |
| 597 |
} |
| 598 |
ci = &cgs.clientinfo[ clientNum ]; |
| 599 |
|
| 600 |
switch ( event ) { |
| 601 |
// |
| 602 |
// movement generated events |
| 603 |
// |
| 604 |
case EV_FOOTSTEP: |
| 605 |
DEBUGNAME("EV_FOOTSTEP"); |
| 606 |
if (cg_footsteps.integer) { |
| 607 |
trap_S_StartSound (NULL, es->number, CHAN_BODY, |
| 608 |
cgs.media.footsteps[ ci->footsteps ][rand()&3] ); |
| 609 |
} |
| 610 |
break; |
| 611 |
case EV_FOOTSTEP_METAL: |
| 612 |
DEBUGNAME("EV_FOOTSTEP_METAL"); |
| 613 |
if (cg_footsteps.integer) { |
| 614 |
trap_S_StartSound (NULL, es->number, CHAN_BODY, |
| 615 |
cgs.media.footsteps[ FOOTSTEP_METAL ][rand()&3] ); |
| 616 |
} |
| 617 |
break; |
| 618 |
case EV_FOOTSPLASH: |
| 619 |
DEBUGNAME("EV_FOOTSPLASH"); |
| 620 |
if (cg_footsteps.integer) { |
| 621 |
trap_S_StartSound (NULL, es->number, CHAN_BODY, |
| 622 |
cgs.media.footsteps[ FOOTSTEP_SPLASH ][rand()&3] ); |
| 623 |
} |
| 624 |
break; |
| 625 |
case EV_FOOTWADE: |
| 626 |
DEBUGNAME("EV_FOOTWADE"); |
| 627 |
if (cg_footsteps.integer) { |
| 628 |
trap_S_StartSound (NULL, es->number, CHAN_BODY, |
| 629 |
cgs.media.footsteps[ FOOTSTEP_SPLASH ][rand()&3] ); |
| 630 |
} |
| 631 |
break; |
| 632 |
case EV_SWIM: |
| 633 |
DEBUGNAME("EV_SWIM"); |
| 634 |
if (cg_footsteps.integer) { |
| 635 |
trap_S_StartSound (NULL, es->number, CHAN_BODY, |
| 636 |
cgs.media.footsteps[ FOOTSTEP_SPLASH ][rand()&3] ); |
| 637 |
} |
| 638 |
break; |
| 639 |
|
| 640 |
|
| 641 |
case EV_FALL_SHORT: |
| 642 |
DEBUGNAME("EV_FALL_SHORT"); |
| 643 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.landSound ); |
| 644 |
if ( clientNum == cg.predictedPlayerState.clientNum ) { |
| 645 |
// smooth landing z changes |
| 646 |
cg.landChange = -8; |
| 647 |
cg.landTime = cg.time; |
| 648 |
} |
| 649 |
break; |
| 650 |
case EV_FALL_MEDIUM: |
| 651 |
DEBUGNAME("EV_FALL_MEDIUM"); |
| 652 |
// use normal pain sound |
| 653 |
trap_S_StartSound( NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*pain100_1.wav" ) ); |
| 654 |
if ( clientNum == cg.predictedPlayerState.clientNum ) { |
| 655 |
// smooth landing z changes |
| 656 |
cg.landChange = -16; |
| 657 |
cg.landTime = cg.time; |
| 658 |
} |
| 659 |
break; |
| 660 |
case EV_FALL_FAR: |
| 661 |
DEBUGNAME("EV_FALL_FAR"); |
| 662 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, CG_CustomSound( es->number, "*fall1.wav" ) ); |
| 663 |
cent->pe.painTime = cg.time; // don't play a pain sound right after this |
| 664 |
if ( clientNum == cg.predictedPlayerState.clientNum ) { |
| 665 |
// smooth landing z changes |
| 666 |
cg.landChange = -24; |
| 667 |
cg.landTime = cg.time; |
| 668 |
} |
| 669 |
break; |
| 670 |
|
| 671 |
case EV_STEP_4: |
| 672 |
case EV_STEP_8: |
| 673 |
case EV_STEP_12: |
| 674 |
case EV_STEP_16: // smooth out step up transitions |
| 675 |
DEBUGNAME("EV_STEP"); |
| 676 |
{ |
| 677 |
float oldStep; |
| 678 |
int delta; |
| 679 |
int step; |
| 680 |
|
| 681 |
if ( clientNum != cg.predictedPlayerState.clientNum ) { |
| 682 |
break; |
| 683 |
} |
| 684 |
// if we are interpolating, we don't need to smooth steps |
| 685 |
if ( cg.demoPlayback || (cg.snap->ps.pm_flags & PMF_FOLLOW) || |
| 686 |
cg_nopredict.integer || cg_synchronousClients.integer ) { |
| 687 |
break; |
| 688 |
} |
| 689 |
// check for stepping up before a previous step is completed |
| 690 |
delta = cg.time - cg.stepTime; |
| 691 |
if (delta < STEP_TIME) { |
| 692 |
oldStep = cg.stepChange * (STEP_TIME - delta) / STEP_TIME; |
| 693 |
} else { |
| 694 |
oldStep = 0; |
| 695 |
} |
| 696 |
|
| 697 |
// add this amount |
| 698 |
step = 4 * (event - EV_STEP_4 + 1 ); |
| 699 |
cg.stepChange = oldStep + step; |
| 700 |
if ( cg.stepChange > MAX_STEP_CHANGE ) { |
| 701 |
cg.stepChange = MAX_STEP_CHANGE; |
| 702 |
} |
| 703 |
cg.stepTime = cg.time; |
| 704 |
break; |
| 705 |
} |
| 706 |
|
| 707 |
case EV_JUMP_PAD: |
| 708 |
DEBUGNAME("EV_JUMP_PAD"); |
| 709 |
// CG_Printf( "EV_JUMP_PAD w/effect #%i\n", es->eventParm ); |
| 710 |
{ |
| 711 |
localEntity_t *smoke; |
| 712 |
vec3_t up = {0, 0, 1}; |
| 713 |
|
| 714 |
|
| 715 |
smoke = CG_SmokePuff( cent->lerpOrigin, up, |
| 716 |
32, |
| 717 |
1, 1, 1, 0.33f, |
| 718 |
1000, |
| 719 |
cg.time, 0, |
| 720 |
LEF_PUFF_DONT_SCALE, |
| 721 |
cgs.media.smokePuffShader ); |
| 722 |
} |
| 723 |
|
| 724 |
// boing sound at origin, jump sound on player |
| 725 |
trap_S_StartSound ( cent->lerpOrigin, -1, CHAN_VOICE, cgs.media.jumpPadSound ); |
| 726 |
trap_S_StartSound (NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*jump1.wav" ) ); |
| 727 |
break; |
| 728 |
|
| 729 |
case EV_JUMP: |
| 730 |
DEBUGNAME("EV_JUMP"); |
| 731 |
trap_S_StartSound (NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*jump1.wav" ) ); |
| 732 |
break; |
| 733 |
case EV_TAUNT: |
| 734 |
DEBUGNAME("EV_TAUNT"); |
| 735 |
trap_S_StartSound (NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*taunt.wav" ) ); |
| 736 |
break; |
| 737 |
#ifdef MISSIONPACK |
| 738 |
case EV_TAUNT_YES: |
| 739 |
DEBUGNAME("EV_TAUNT_YES"); |
| 740 |
CG_VoiceChatLocal(SAY_TEAM, qfalse, es->number, COLOR_CYAN, VOICECHAT_YES); |
| 741 |
break; |
| 742 |
case EV_TAUNT_NO: |
| 743 |
DEBUGNAME("EV_TAUNT_NO"); |
| 744 |
CG_VoiceChatLocal(SAY_TEAM, qfalse, es->number, COLOR_CYAN, VOICECHAT_NO); |
| 745 |
break; |
| 746 |
case EV_TAUNT_FOLLOWME: |
| 747 |
DEBUGNAME("EV_TAUNT_FOLLOWME"); |
| 748 |
CG_VoiceChatLocal(SAY_TEAM, qfalse, es->number, COLOR_CYAN, VOICECHAT_FOLLOWME); |
| 749 |
break; |
| 750 |
case EV_TAUNT_GETFLAG: |
| 751 |
DEBUGNAME("EV_TAUNT_GETFLAG"); |
| 752 |
CG_VoiceChatLocal(SAY_TEAM, qfalse, es->number, COLOR_CYAN, VOICECHAT_ONGETFLAG); |
| 753 |
break; |
| 754 |
case EV_TAUNT_GUARDBASE: |
| 755 |
DEBUGNAME("EV_TAUNT_GUARDBASE"); |
| 756 |
CG_VoiceChatLocal(SAY_TEAM, qfalse, es->number, COLOR_CYAN, VOICECHAT_ONDEFENSE); |
| 757 |
break; |
| 758 |
case EV_TAUNT_PATROL: |
| 759 |
DEBUGNAME("EV_TAUNT_PATROL"); |
| 760 |
CG_VoiceChatLocal(SAY_TEAM, qfalse, es->number, COLOR_CYAN, VOICECHAT_ONPATROL); |
| 761 |
break; |
| 762 |
#endif |
| 763 |
case EV_WATER_TOUCH: |
| 764 |
DEBUGNAME("EV_WATER_TOUCH"); |
| 765 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.watrInSound ); |
| 766 |
break; |
| 767 |
case EV_WATER_LEAVE: |
| 768 |
DEBUGNAME("EV_WATER_LEAVE"); |
| 769 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.watrOutSound ); |
| 770 |
break; |
| 771 |
case EV_WATER_UNDER: |
| 772 |
DEBUGNAME("EV_WATER_UNDER"); |
| 773 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.watrUnSound ); |
| 774 |
break; |
| 775 |
case EV_WATER_CLEAR: |
| 776 |
DEBUGNAME("EV_WATER_CLEAR"); |
| 777 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, CG_CustomSound( es->number, "*gasp.wav" ) ); |
| 778 |
break; |
| 779 |
|
| 780 |
case EV_ITEM_PICKUP: |
| 781 |
DEBUGNAME("EV_ITEM_PICKUP"); |
| 782 |
{ |
| 783 |
gitem_t *item; |
| 784 |
int index; |
| 785 |
|
| 786 |
index = es->eventParm; // player predicted |
| 787 |
|
| 788 |
if ( index < 1 || index >= bg_numItems ) { |
| 789 |
break; |
| 790 |
} |
| 791 |
item = &bg_itemlist[ index ]; |
| 792 |
|
| 793 |
// powerups and team items will have a separate global sound, this one |
| 794 |
// will be played at prediction time |
| 795 |
if ( item->giType == IT_POWERUP || item->giType == IT_TEAM) { |
| 796 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.n_healthSound ); |
| 797 |
} else if (item->giType == IT_PERSISTANT_POWERUP) { |
| 798 |
#ifdef MISSIONPACK |
| 799 |
switch (item->giTag ) { |
| 800 |
case PW_SCOUT: |
| 801 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.scoutSound ); |
| 802 |
break; |
| 803 |
case PW_GUARD: |
| 804 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.guardSound ); |
| 805 |
break; |
| 806 |
case PW_DOUBLER: |
| 807 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.doublerSound ); |
| 808 |
break; |
| 809 |
case PW_AMMOREGEN: |
| 810 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.ammoregenSound ); |
| 811 |
break; |
| 812 |
} |
| 813 |
#endif |
| 814 |
} else { |
| 815 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, trap_S_RegisterSound( item->pickup_sound, qfalse ) ); |
| 816 |
} |
| 817 |
|
| 818 |
// show icon and name on status bar |
| 819 |
if ( es->number == cg.snap->ps.clientNum ) { |
| 820 |
CG_ItemPickup( index ); |
| 821 |
} |
| 822 |
} |
| 823 |
break; |
| 824 |
|
| 825 |
case EV_GLOBAL_ITEM_PICKUP: |
| 826 |
DEBUGNAME("EV_GLOBAL_ITEM_PICKUP"); |
| 827 |
{ |
| 828 |
gitem_t *item; |
| 829 |
int index; |
| 830 |
|
| 831 |
index = es->eventParm; // player predicted |
| 832 |
|
| 833 |
if ( index < 1 || index >= bg_numItems ) { |
| 834 |
break; |
| 835 |
} |
| 836 |
item = &bg_itemlist[ index ]; |
| 837 |
// powerup pickups are global |
| 838 |
if( item->pickup_sound ) { |
| 839 |
trap_S_StartSound (NULL, cg.snap->ps.clientNum, CHAN_AUTO, trap_S_RegisterSound( item->pickup_sound, qfalse ) ); |
| 840 |
} |
| 841 |
|
| 842 |
// show icon and name on status bar |
| 843 |
if ( es->number == cg.snap->ps.clientNum ) { |
| 844 |
CG_ItemPickup( index ); |
| 845 |
} |
| 846 |
} |
| 847 |
break; |
| 848 |
|
| 849 |
// |
| 850 |
// weapon events |
| 851 |
// |
| 852 |
case EV_NOAMMO: |
| 853 |
DEBUGNAME("EV_NOAMMO"); |
| 854 |
// trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.noAmmoSound ); |
| 855 |
if ( es->number == cg.snap->ps.clientNum ) { |
| 856 |
CG_OutOfAmmoChange(); |
| 857 |
} |
| 858 |
break; |
| 859 |
case EV_CHANGE_WEAPON: |
| 860 |
DEBUGNAME("EV_CHANGE_WEAPON"); |
| 861 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.selectSound ); |
| 862 |
break; |
| 863 |
case EV_FIRE_WEAPON: |
| 864 |
DEBUGNAME("EV_FIRE_WEAPON"); |
| 865 |
CG_FireWeapon( cent ); |
| 866 |
break; |
| 867 |
|
| 868 |
case EV_USE_ITEM0: |
| 869 |
DEBUGNAME("EV_USE_ITEM0"); |
| 870 |
CG_UseItem( cent ); |
| 871 |
break; |
| 872 |
case EV_USE_ITEM1: |
| 873 |
DEBUGNAME("EV_USE_ITEM1"); |
| 874 |
CG_UseItem( cent ); |
| 875 |
break; |
| 876 |
case EV_USE_ITEM2: |
| 877 |
DEBUGNAME("EV_USE_ITEM2"); |
| 878 |
CG_UseItem( cent ); |
| 879 |
break; |
| 880 |
case EV_USE_ITEM3: |
| 881 |
DEBUGNAME("EV_USE_ITEM3"); |
| 882 |
CG_UseItem( cent ); |
| 883 |
break; |
| 884 |
case EV_USE_ITEM4: |
| 885 |
DEBUGNAME("EV_USE_ITEM4"); |
| 886 |
CG_UseItem( cent ); |
| 887 |
break; |
| 888 |
case EV_USE_ITEM5: |
| 889 |
DEBUGNAME("EV_USE_ITEM5"); |
| 890 |
CG_UseItem( cent ); |
| 891 |
break; |
| 892 |
case EV_USE_ITEM6: |
| 893 |
DEBUGNAME("EV_USE_ITEM6"); |
| 894 |
CG_UseItem( cent ); |
| 895 |
break; |
| 896 |
case EV_USE_ITEM7: |
| 897 |
DEBUGNAME("EV_USE_ITEM7"); |
| 898 |
CG_UseItem( cent ); |
| 899 |
break; |
| 900 |
case EV_USE_ITEM8: |
| 901 |
DEBUGNAME("EV_USE_ITEM8"); |
| 902 |
CG_UseItem( cent ); |
| 903 |
break; |
| 904 |
case EV_USE_ITEM9: |
| 905 |
DEBUGNAME("EV_USE_ITEM9"); |
| 906 |
CG_UseItem( cent ); |
| 907 |
break; |
| 908 |
case EV_USE_ITEM10: |
| 909 |
DEBUGNAME("EV_USE_ITEM10"); |
| 910 |
CG_UseItem( cent ); |
| 911 |
break; |
| 912 |
case EV_USE_ITEM11: |
| 913 |
DEBUGNAME("EV_USE_ITEM11"); |
| 914 |
CG_UseItem( cent ); |
| 915 |
break; |
| 916 |
case EV_USE_ITEM12: |
| 917 |
DEBUGNAME("EV_USE_ITEM12"); |
| 918 |
CG_UseItem( cent ); |
| 919 |
break; |
| 920 |
case EV_USE_ITEM13: |
| 921 |
DEBUGNAME("EV_USE_ITEM13"); |
| 922 |
CG_UseItem( cent ); |
| 923 |
break; |
| 924 |
case EV_USE_ITEM14: |
| 925 |
DEBUGNAME("EV_USE_ITEM14"); |
| 926 |
CG_UseItem( cent ); |
| 927 |
break; |
| 928 |
|
| 929 |
//================================================================= |
| 930 |
|
| 931 |
// |
| 932 |
// other events |
| 933 |
// |
| 934 |
case EV_PLAYER_TELEPORT_IN: |
| 935 |
DEBUGNAME("EV_PLAYER_TELEPORT_IN"); |
| 936 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.teleInSound ); |
| 937 |
CG_SpawnEffect( position); |
| 938 |
break; |
| 939 |
|
| 940 |
case EV_PLAYER_TELEPORT_OUT: |
| 941 |
DEBUGNAME("EV_PLAYER_TELEPORT_OUT"); |
| 942 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.teleOutSound ); |
| 943 |
CG_SpawnEffect( position); |
| 944 |
break; |
| 945 |
|
| 946 |
case EV_ITEM_POP: |
| 947 |
DEBUGNAME("EV_ITEM_POP"); |
| 948 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.respawnSound ); |
| 949 |
break; |
| 950 |
case EV_ITEM_RESPAWN: |
| 951 |
DEBUGNAME("EV_ITEM_RESPAWN"); |
| 952 |
cent->miscTime = cg.time; // scale up from this |
| 953 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.respawnSound ); |
| 954 |
break; |
| 955 |
|
| 956 |
case EV_GRENADE_BOUNCE: |
| 957 |
DEBUGNAME("EV_GRENADE_BOUNCE"); |
| 958 |
if ( rand() & 1 ) { |
| 959 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.hgrenb1aSound ); |
| 960 |
} else { |
| 961 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.hgrenb2aSound ); |
| 962 |
} |
| 963 |
break; |
| 964 |
|
| 965 |
|
| 966 |
case EV_PROXIMITY_MINE_STICK: |
| 967 |
DEBUGNAME("EV_PROXIMITY_MINE_STICK"); |
| 968 |
if( es->eventParm & SURF_FLESH ) { |
| 969 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.wstbimplSound ); |
| 970 |
} else if( es->eventParm & SURF_METALSTEPS ) { |
| 971 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.wstbimpmSound ); |
| 972 |
} else { |
| 973 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.wstbimpdSound ); |
| 974 |
} |
| 975 |
break; |
| 976 |
|
| 977 |
case EV_PROXIMITY_MINE_TRIGGER: |
| 978 |
DEBUGNAME("EV_PROXIMITY_MINE_TRIGGER"); |
| 979 |
trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.wstbactvSound ); |
| 980 |
break; |
| 981 |
case EV_KAMIKAZE: |
| 982 |
DEBUGNAME("EV_KAMIKAZE"); |
| 983 |
CG_KamikazeEffect( cent->lerpOrigin ); |
| 984 |
break; |
| 985 |
case EV_OBELISKEXPLODE: |
| 986 |
DEBUGNAME("EV_OBELISKEXPLODE"); |
| 987 |
CG_ObeliskExplode( cent->lerpOrigin, es->eventParm ); |
| 988 |
break; |
| 989 |
case EV_OBELISKPAIN: |
| 990 |
DEBUGNAME("EV_OBELISKPAIN"); |
| 991 |
CG_ObeliskPain( cent->lerpOrigin ); |
| 992 |
break; |
| 993 |
case EV_INVUL_IMPACT: |
| 994 |
DEBUGNAME("EV_INVUL_IMPACT"); |
| 995 |
CG_InvulnerabilityImpact( cent->lerpOrigin, cent->currentState.angles ); |
| 996 |
break; |
| 997 |
case EV_JUICED: |
| 998 |
DEBUGNAME("EV_JUICED"); |
| 999 |
CG_InvulnerabilityJuiced( cent->lerpOrigin ); |
| 1000 |
break; |
| 1001 |
case EV_LIGHTNINGBOLT: |
| 1002 |
DEBUGNAME("EV_LIGHTNINGBOLT"); |
| 1003 |
CG_LightningBoltBeam(es->origin2, es->pos.trBase); |
| 1004 |
break; |
| 1005 |
case EV_SCOREPLUM: |
| 1006 |
DEBUGNAME("EV_SCOREPLUM"); |
| 1007 |
CG_ScorePlum( cent->currentState.otherEntityNum, cent->lerpOrigin, cent->currentState.time ); |
| 1008 |
break; |
| 1009 |
|
| 1010 |
// |
| 1011 |
// missile impacts |
| 1012 |
// |
| 1013 |
case EV_MISSILE_HIT: |
| 1014 |
DEBUGNAME("EV_MISSILE_HIT"); |
| 1015 |
ByteToDir( es->eventParm, dir ); |
| 1016 |
CG_MissileHitPlayer( es->weapon, position, dir, es->otherEntityNum ); |
| 1017 |
break; |
| 1018 |
|
| 1019 |
case EV_MISSILE_MISS: |
| 1020 |
DEBUGNAME("EV_MISSILE_MISS"); |
| 1021 |
ByteToDir( es->eventParm, dir ); |
| 1022 |
CG_MissileHitWall( es->weapon, 0, position, dir, IMPACTSOUND_DEFAULT ); |
| 1023 |
break; |
| 1024 |
|
| 1025 |
case EV_MISSILE_MISS_METAL: |
| 1026 |
DEBUGNAME("EV_MISSILE_MISS_METAL"); |
| 1027 |
ByteToDir( es->eventParm, dir ); |
| 1028 |
CG_MissileHitWall( es->weapon, 0, position, dir, IMPACTSOUND_METAL ); |
| 1029 |
break; |
| 1030 |
|
| 1031 |
case EV_RAILTRAIL: |
| 1032 |
DEBUGNAME("EV_RAILTRAIL"); |
| 1033 |
cent->currentState.weapon = WP_RAILGUN; |
| 1034 |
//unlagged - attack prediction #2 |
| 1035 |
// if the client is us, unlagged is on server-side, and we've got it client-side |
| 1036 |
if ( es->clientNum == cg.predictedPlayerState.clientNum && |
| 1037 |
cgs.delagHitscan && (cg_delag.integer & 1 || cg_delag.integer & 16) ) { |
| 1038 |
// do nothing, because it was already predicted |
| 1039 |
//Com_Printf("Ignoring rail trail event\n"); |
| 1040 |
} |
| 1041 |
else { |
| 1042 |
if(es->clientNum == cg.snap->ps.clientNum && !cg.renderingThirdPerson) |
| 1043 |
{ |
| 1044 |
if(cg_drawGun.integer == 2) |
| 1045 |
VectorMA(es->origin2, 8, cg.refdef.viewaxis[1], es->origin2); |
| 1046 |
else if(cg_drawGun.integer == 3) |
| 1047 |
VectorMA(es->origin2, 4, cg.refdef.viewaxis[1], es->origin2); |
| 1048 |
} |
| 1049 |
|
| 1050 |
|
| 1051 |
// draw a rail trail, because it wasn't predicted |
| 1052 |
CG_RailTrail( ci, es->origin2, es->pos.trBase ); |
| 1053 |
|
| 1054 |
// if the end was on a nomark surface, don't make an explosion |
| 1055 |
if ( es->eventParm != 255 ) { |
| 1056 |
ByteToDir( es->eventParm, dir ); |
| 1057 |
CG_MissileHitWall( es->weapon, es->clientNum, position, dir, IMPACTSOUND_DEFAULT ); |
| 1058 |
} |
| 1059 |
//Com_Printf("Non-predicted rail trail\n"); |
| 1060 |
} |
| 1061 |
//unlagged - attack prediction #2 |
| 1062 |
break; |
| 1063 |
|
| 1064 |
case EV_BULLET_HIT_WALL: |
| 1065 |
DEBUGNAME("EV_BULLET_HIT_WALL"); |
| 1066 |
//unlagged - attack prediction #2 |
| 1067 |
// if the client is us, unlagged is on server-side, and we've got it client-side |
| 1068 |
if ( es->clientNum == cg.predictedPlayerState.clientNum && |
| 1069 |
cgs.delagHitscan && (cg_delag.integer & 1 || cg_delag.integer & 2) ) { |
| 1070 |
// do nothing, because it was already predicted |
| 1071 |
//Com_Printf("Ignoring bullet event\n"); |
| 1072 |
} |
| 1073 |
else { |
| 1074 |
// do the bullet, because it wasn't predicted |
| 1075 |
ByteToDir( es->eventParm, dir ); |
| 1076 |
CG_Bullet( es->pos.trBase, es->otherEntityNum, dir, qfalse, ENTITYNUM_WORLD ); |
| 1077 |
//Com_Printf("Non-predicted bullet\n"); |
| 1078 |
} |
| 1079 |
//unlagged - attack prediction #2 |
| 1080 |
break; |
| 1081 |
|
| 1082 |
case EV_BULLET_HIT_FLESH: |
| 1083 |
DEBUGNAME("EV_BULLET_HIT_FLESH"); |
| 1084 |
//unlagged - attack prediction #2 |
| 1085 |
// if the client is us, unlagged is on server-side, and we've got it client-side |
| 1086 |
if ( es->clientNum == cg.predictedPlayerState.clientNum && |
| 1087 |
cgs.delagHitscan && (cg_delag.integer & 1 || cg_delag.integer & 2) ) { |
| 1088 |
// do nothing, because it was already predicted |
| 1089 |
//Com_Printf("Ignoring bullet event\n"); |
| 1090 |
} |
| 1091 |
else { |
| 1092 |
// do the bullet, because it wasn't predicted |
| 1093 |
CG_Bullet( es->pos.trBase, es->otherEntityNum, dir, qtrue, es->eventParm ); |
| 1094 |
//Com_Printf("Non-predicted bullet\n"); |
| 1095 |
} |
| 1096 |
//unlagged - attack prediction #2 |
| 1097 |
break; |
| 1098 |
|
| 1099 |
case EV_SHOTGUN: |
| 1100 |
DEBUGNAME("EV_SHOTGUN"); |
| 1101 |
//unlagged - attack prediction #2 |
| 1102 |
// if the client is us, unlagged is on server-side, and we've got it client-side |
| 1103 |
if ( es->otherEntityNum == cg.predictedPlayerState.clientNum && |
| 1104 |
cgs.delagHitscan && (cg_delag.integer & 1 || cg_delag.integer & 4) ) { |
| 1105 |
// do nothing, because it was already predicted |
| 1106 |
//Com_Printf("Ignoring shotgun event\n"); |
| 1107 |
} |
| 1108 |
else { |
| 1109 |
// do the shotgun pattern, because it wasn't predicted |
| 1110 |
CG_ShotgunFire( es ); |
| 1111 |
//Com_Printf("Non-predicted shotgun pattern\n"); |
| 1112 |
} |
| 1113 |
//unlagged - attack prediction #2 |
| 1114 |
break; |
| 1115 |
|
| 1116 |
case EV_GENERAL_SOUND: |
| 1117 |
DEBUGNAME("EV_GENERAL_SOUND"); |
| 1118 |
if ( cgs.gameSounds[ es->eventParm ] ) { |
| 1119 |
trap_S_StartSound (NULL, es->number, CHAN_VOICE, cgs.gameSounds[ es->eventParm ] ); |
| 1120 |
} else { |
| 1121 |
s = CG_ConfigString( CS_SOUNDS + es->eventParm ); |
| 1122 |
trap_S_StartSound (NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, s ) ); |
| 1123 |
} |
| 1124 |
break; |
| 1125 |
|
| 1126 |
case EV_GLOBAL_SOUND: // play from the player's head so it never diminishes |
| 1127 |
DEBUGNAME("EV_GLOBAL_SOUND"); |
| 1128 |
if ( cgs.gameSounds[ es->eventParm ] ) { |
| 1129 |
trap_S_StartSound (NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.gameSounds[ es->eventParm ] ); |
| 1130 |
} else { |
| 1131 |
s = CG_ConfigString( CS_SOUNDS + es->eventParm ); |
| 1132 |
trap_S_StartSound (NULL, cg.snap->ps.clientNum, CHAN_AUTO, CG_CustomSound( es->number, s ) ); |
| 1133 |
} |
| 1134 |
break; |
| 1135 |
|
| 1136 |
case EV_GLOBAL_TEAM_SOUND: // play from the player's head so it never diminishes |
| 1137 |
{ |
| 1138 |
DEBUGNAME("EV_GLOBAL_TEAM_SOUND"); |
| 1139 |
switch( es->eventParm ) { |
| 1140 |
case GTS_RED_CAPTURE: // CTF: red team captured the blue flag, 1FCTF: red team captured the neutral flag |
| 1141 |
if ( cgs.clientinfo[cg.clientNum].team == TEAM_RED ) |
| 1142 |
CG_AddBufferedSound( cgs.media.captureYourTeamSound ); |
| 1143 |
else |
| 1144 |
CG_AddBufferedSound( cgs.media.captureOpponentSound ); |
| 1145 |
break; |
| 1146 |
case GTS_BLUE_CAPTURE: // CTF: blue team captured the red flag, 1FCTF: blue team captured the neutral flag |
| 1147 |
if ( cgs.clientinfo[cg.clientNum].team == TEAM_BLUE ) |
| 1148 |
CG_AddBufferedSound( cgs.media.captureYourTeamSound ); |
| 1149 |
else |
| 1150 |
CG_AddBufferedSound( cgs.media.captureOpponentSound ); |
| 1151 |
break; |
| 1152 |
case GTS_RED_RETURN: // CTF: blue flag returned, 1FCTF: never used |
| 1153 |
if ( cgs.clientinfo[cg.clientNum].team == TEAM_RED ) |
| 1154 |
CG_AddBufferedSound( cgs.media.returnYourTeamSound ); |
| 1155 |
else |
| 1156 |
CG_AddBufferedSound( cgs.media.returnOpponentSound ); |
| 1157 |
// |
| 1158 |
CG_AddBufferedSound( cgs.media.blueFlagReturnedSound ); |
| 1159 |
break; |
| 1160 |
case GTS_BLUE_RETURN: // CTF red flag returned, 1FCTF: neutral flag returned |
| 1161 |
if ( cgs.clientinfo[cg.clientNum].team == TEAM_BLUE ) |
| 1162 |
CG_AddBufferedSound( cgs.media.returnYourTeamSound ); |
| 1163 |
else |
| 1164 |
CG_AddBufferedSound( cgs.media.returnOpponentSound ); |
| 1165 |
// |
| 1166 |
CG_AddBufferedSound( cgs.media.redFlagReturnedSound ); |
| 1167 |
break; |
| 1168 |
|
| 1169 |
case GTS_RED_TAKEN: // CTF: red team took blue flag, 1FCTF: blue team took the neutral flag |
| 1170 |
// if this player picked up the flag then a sound is played in CG_CheckLocalSounds |
| 1171 |
if (cg.snap->ps.powerups[PW_BLUEFLAG] || cg.snap->ps.powerups[PW_NEUTRALFLAG]) { |
| 1172 |
} |
| 1173 |
else { |
| 1174 |
if (cgs.clientinfo[cg.clientNum].team == TEAM_BLUE) { |
| 1175 |
//#ifdef MISSIONPACK |
| 1176 |
if (cgs.gametype == GT_1FCTF) |
| 1177 |
CG_AddBufferedSound( cgs.media.yourTeamTookTheFlagSound ); |
| 1178 |
else |
| 1179 |
//#endif |
| 1180 |
CG_AddBufferedSound( cgs.media.enemyTookYourFlagSound ); |
| 1181 |
} |
| 1182 |
else if (cgs.clientinfo[cg.clientNum].team == TEAM_RED) { |
| 1183 |
//#ifdef MISSIONPACK |
| 1184 |
if (cgs.gametype == GT_1FCTF) |
| 1185 |
CG_AddBufferedSound( cgs.media.enemyTookTheFlagSound ); |
| 1186 |
else |
| 1187 |
//#endif |
| 1188 |
CG_AddBufferedSound( cgs.media.yourTeamTookEnemyFlagSound ); |
| 1189 |
} |
| 1190 |
} |
| 1191 |
break; |
| 1192 |
case GTS_BLUE_TAKEN: // CTF: blue team took the red flag, 1FCTF red team took the neutral flag |
| 1193 |
// if this player picked up the flag then a sound is played in CG_CheckLocalSounds |
| 1194 |
if (cg.snap->ps.powerups[PW_REDFLAG] || cg.snap->ps.powerups[PW_NEUTRALFLAG]) { |
| 1195 |
} |
| 1196 |
else { |
| 1197 |
if (cgs.clientinfo[cg.clientNum].team == TEAM_RED) { |
| 1198 |
//#ifdef MISSIONPACK |
| 1199 |
if (cgs.gametype == GT_1FCTF) |
| 1200 |
CG_AddBufferedSound( cgs.media.yourTeamTookTheFlagSound ); |
| 1201 |
else |
| 1202 |
//#endif |
| 1203 |
CG_AddBufferedSound( cgs.media.enemyTookYourFlagSound ); |
| 1204 |
} |
| 1205 |
else if (cgs.clientinfo[cg.clientNum].team == TEAM_BLUE) { |
| 1206 |
//#ifdef MISSIONPACK |
| 1207 |
if (cgs.gametype == GT_1FCTF) |
| 1208 |
CG_AddBufferedSound( cgs.media.enemyTookTheFlagSound ); |
| 1209 |
else |
| 1210 |
//#endif |
| 1211 |
CG_AddBufferedSound( cgs.media.yourTeamTookEnemyFlagSound ); |
| 1212 |
} |
| 1213 |
} |
| 1214 |
break; |
| 1215 |
case GTS_REDOBELISK_ATTACKED: // Overload: red obelisk is being attacked |
| 1216 |
if (cgs.clientinfo[cg.clientNum].team == TEAM_RED) { |
| 1217 |
CG_AddBufferedSound( cgs.media.yourBaseIsUnderAttackSound ); |
| 1218 |
} |
| 1219 |
break; |
| 1220 |
case GTS_BLUEOBELISK_ATTACKED: // Overload: blue obelisk is being attacked |
| 1221 |
if (cgs.clientinfo[cg.clientNum].team == TEAM_BLUE) { |
| 1222 |
CG_AddBufferedSound( cgs.media.yourBaseIsUnderAttackSound ); |
| 1223 |
} |
| 1224 |
break; |
| 1225 |
|
| 1226 |
case GTS_REDTEAM_SCORED: |
| 1227 |
CG_AddBufferedSound(cgs.media.redScoredSound); |
| 1228 |
break; |
| 1229 |
case GTS_BLUETEAM_SCORED: |
| 1230 |
CG_AddBufferedSound(cgs.media.blueScoredSound); |
| 1231 |
break; |
| 1232 |
case GTS_REDTEAM_TOOK_LEAD: |
| 1233 |
CG_AddBufferedSound(cgs.media.redLeadsSound); |
| 1234 |
break; |
| 1235 |
case GTS_BLUETEAM_TOOK_LEAD: |
| 1236 |
CG_AddBufferedSound(cgs.media.blueLeadsSound); |
| 1237 |
break; |
| 1238 |
case GTS_TEAMS_ARE_TIED: |
| 1239 |
CG_AddBufferedSound( cgs.media.teamsTiedSound ); |
| 1240 |
break; |
| 1241 |
case GTS_KAMIKAZE: |
| 1242 |
trap_S_StartLocalSound(cgs.media.kamikazeFarSound, CHAN_ANNOUNCER); |
| 1243 |
break; |
| 1244 |
default: |
| 1245 |
break; |
| 1246 |
} |
| 1247 |
break; |
| 1248 |
} |
| 1249 |
|
| 1250 |
case EV_PAIN: |
| 1251 |
// local player sounds are triggered in CG_CheckLocalSounds, |
| 1252 |
// so ignore events on the player |
| 1253 |
DEBUGNAME("EV_PAIN"); |
| 1254 |
if ( cent->currentState.number != cg.snap->ps.clientNum ) { |
| 1255 |
CG_PainEvent( cent, es->eventParm ); |
| 1256 |
} |
| 1257 |
break; |
| 1258 |
|
| 1259 |
case EV_DEATH1: |
| 1260 |
case EV_DEATH2: |
| 1261 |
case EV_DEATH3: |
| 1262 |
DEBUGNAME("EV_DEATHx"); |
| 1263 |
|
| 1264 |
if (CG_WaterLevel(cent) >= 1) { |
| 1265 |
trap_S_StartSound(NULL, es->number, CHAN_VOICE, CG_CustomSound(es->number, "*drown.wav")); |
| 1266 |
} else { |
| 1267 |
trap_S_StartSound(NULL, es->number, CHAN_VOICE, CG_CustomSound(es->number, va("*death%i.wav", event - EV_DEATH1 + 1))); |
| 1268 |
} |
| 1269 |
|
| 1270 |
break; |
| 1271 |
|
| 1272 |
|
| 1273 |
case EV_OBITUARY: |
| 1274 |
DEBUGNAME("EV_OBITUARY"); |
| 1275 |
CG_Obituary( es ); |
| 1276 |
break; |
| 1277 |
|
| 1278 |
// |
| 1279 |
// powerup events |
| 1280 |
// |
| 1281 |
case EV_POWERUP_QUAD: |
| 1282 |
DEBUGNAME("EV_POWERUP_QUAD"); |
| 1283 |
if ( es->number == cg.snap->ps.clientNum ) { |
| 1284 |
cg.powerupActive = PW_QUAD; |
| 1285 |
cg.powerupTime = cg.time; |
| 1286 |
} |
| 1287 |
trap_S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.quadSound ); |
| 1288 |
break; |
| 1289 |
case EV_POWERUP_BATTLESUIT: |
| 1290 |
DEBUGNAME("EV_POWERUP_BATTLESUIT"); |
| 1291 |
if ( es->number == cg.snap->ps.clientNum ) { |
| 1292 |
cg.powerupActive = PW_BATTLESUIT; |
| 1293 |
cg.powerupTime = cg.time; |
| 1294 |
} |
| 1295 |
trap_S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.protectSound ); |
| 1296 |
break; |
| 1297 |
case EV_POWERUP_REGEN: |
| 1298 |
DEBUGNAME("EV_POWERUP_REGEN"); |
| 1299 |
if ( es->number == cg.snap->ps.clientNum ) { |
| 1300 |
cg.powerupActive = PW_REGEN; |
| 1301 |
cg.powerupTime = cg.time; |
| 1302 |
} |
| 1303 |
trap_S_StartSound (NULL, es->number, CHAN_ITEM, cgs.media.regenSound ); |
| 1304 |
break; |
| 1305 |
|
| 1306 |
case EV_GIB_PLAYER: |
| 1307 |
DEBUGNAME("EV_GIB_PLAYER"); |
| 1308 |
// don't play gib sound when using the kamikaze because it interferes |
| 1309 |
// with the kamikaze sound, downside is that the gib sound will also |
| 1310 |
// not be played when someone is gibbed while just carrying the kamikaze |
| 1311 |
if ( !(es->eFlags & EF_KAMIKAZE) ) { |
| 1312 |
trap_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.gibSound ); |
| 1313 |
} |
| 1314 |
CG_GibPlayer( cent->lerpOrigin ); |
| 1315 |
break; |
| 1316 |
|
| 1317 |
case EV_STOPLOOPINGSOUND: |
| 1318 |
DEBUGNAME("EV_STOPLOOPINGSOUND"); |
| 1319 |
trap_S_StopLoopingSound( es->number ); |
| 1320 |
es->loopSound = 0; |
| 1321 |
break; |
| 1322 |
|
| 1323 |
case EV_DEBUG_LINE: |
| 1324 |
DEBUGNAME("EV_DEBUG_LINE"); |
| 1325 |
CG_Beam( cent ); |
| 1326 |
break; |
| 1327 |
|
| 1328 |
default: |
| 1329 |
DEBUGNAME("UNKNOWN"); |
| 1330 |
CG_Error( "Unknown event: %i", event ); |
| 1331 |
break; |
| 1332 |
} |
| 1333 |
|
| 1334 |
} |
| 1335 |
|
| 1336 |
|
| 1337 |
/* |
| 1338 |
============== |
| 1339 |
CG_CheckEvents |
| 1340 |
|
| 1341 |
============== |
| 1342 |
*/ |
| 1343 |
void CG_CheckEvents( centity_t *cent ) { |
| 1344 |
// check for event-only entities |
| 1345 |
if ( cent->currentState.eType > ET_EVENTS ) { |
| 1346 |
if ( cent->previousEvent ) { |
| 1347 |
return; // already fired |
| 1348 |
} |
| 1349 |
// if this is a player event set the entity number of the client entity number |
| 1350 |
if ( cent->currentState.eFlags & EF_PLAYER_EVENT ) { |
| 1351 |
cent->currentState.number = cent->currentState.otherEntityNum; |
| 1352 |
} |
| 1353 |
|
| 1354 |
cent->previousEvent = 1; |
| 1355 |
|
| 1356 |
cent->currentState.event = cent->currentState.eType - ET_EVENTS; |
| 1357 |
} else { |
| 1358 |
// check for events riding with another entity |
| 1359 |
if ( cent->currentState.event == cent->previousEvent ) { |
| 1360 |
return; |
| 1361 |
} |
| 1362 |
cent->previousEvent = cent->currentState.event; |
| 1363 |
if ( ( cent->currentState.event & ~EV_EVENT_BITS ) == 0 ) { |
| 1364 |
return; |
| 1365 |
} |
| 1366 |
} |
| 1367 |
|
| 1368 |
// calculate the position at exactly the frame time |
| 1369 |
BG_EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, cent->lerpOrigin ); |
| 1370 |
CG_SetEntitySoundPosition( cent ); |
| 1371 |
|
| 1372 |
CG_EntityEvent( cent, cent->lerpOrigin ); |
| 1373 |
} |
| 1374 |
|