| 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_playerstate.c -- this file acts on changes in a new playerState_t |
| 24 |
// With normal play, this will be done after local prediction, but when |
| 25 |
// following another player or playing back a demo, it will be checked |
| 26 |
// when the snapshot transitions like all the other entities |
| 27 |
|
| 28 |
#include "cg_local.h" |
| 29 |
|
| 30 |
/* |
| 31 |
============== |
| 32 |
CG_CheckAmmo |
| 33 |
|
| 34 |
If the ammo has gone low enough to generate the warning, play a sound |
| 35 |
============== |
| 36 |
*/ |
| 37 |
void CG_CheckAmmo( void ) { |
| 38 |
int i; |
| 39 |
int total; |
| 40 |
int previous; |
| 41 |
int weapons; |
| 42 |
|
| 43 |
// see about how many seconds of ammo we have remaining |
| 44 |
weapons = cg.snap->ps.stats[ STAT_WEAPONS ]; |
| 45 |
total = 0; |
| 46 |
for ( i = WP_MACHINEGUN ; i < WP_NUM_WEAPONS ; i++ ) { |
| 47 |
if ( ! ( weapons & ( 1 << i ) ) || i == WP_GRAPPLING_HOOK ) { |
| 48 |
continue; |
| 49 |
} |
| 50 |
switch ( i ) { |
| 51 |
case WP_ROCKET_LAUNCHER: |
| 52 |
case WP_GRENADE_LAUNCHER: |
| 53 |
case WP_RAILGUN: |
| 54 |
case WP_SHOTGUN: |
| 55 |
//#ifdef MISSIONPACK |
| 56 |
case WP_PROX_LAUNCHER: |
| 57 |
//#endif |
| 58 |
total += cg.snap->ps.ammo[i] * 1000; |
| 59 |
break; |
| 60 |
default: |
| 61 |
total += cg.snap->ps.ammo[i] * 200; |
| 62 |
break; |
| 63 |
} |
| 64 |
if ( total >= 5000 ) { |
| 65 |
cg.lowAmmoWarning = 0; |
| 66 |
return; |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
previous = cg.lowAmmoWarning; |
| 71 |
|
| 72 |
if ( total == 0 ) { |
| 73 |
cg.lowAmmoWarning = 2; |
| 74 |
} else { |
| 75 |
cg.lowAmmoWarning = 1; |
| 76 |
} |
| 77 |
|
| 78 |
// play a sound on transitions |
| 79 |
if ( cg.lowAmmoWarning != previous ) { |
| 80 |
trap_S_StartLocalSound( cgs.media.noAmmoSound, CHAN_LOCAL_SOUND ); |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
/* |
| 85 |
============== |
| 86 |
CG_DamageFeedback |
| 87 |
============== |
| 88 |
*/ |
| 89 |
void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) { |
| 90 |
float left, front, up; |
| 91 |
float kick; |
| 92 |
int health; |
| 93 |
float scale; |
| 94 |
vec3_t dir; |
| 95 |
vec3_t angles; |
| 96 |
float dist; |
| 97 |
float yaw, pitch; |
| 98 |
|
| 99 |
// show the attacking player's head and name in corner |
| 100 |
cg.attackerTime = cg.time; |
| 101 |
|
| 102 |
// the lower on health you are, the greater the view kick will be |
| 103 |
health = cg.snap->ps.stats[STAT_HEALTH]; |
| 104 |
if ( health < 40 ) { |
| 105 |
scale = 1; |
| 106 |
} else { |
| 107 |
scale = 40.0 / health; |
| 108 |
} |
| 109 |
kick = damage * scale; |
| 110 |
|
| 111 |
if (kick < 5) |
| 112 |
kick = 5; |
| 113 |
if (kick > 10) |
| 114 |
kick = 10; |
| 115 |
|
| 116 |
// if yaw and pitch are both 255, make the damage always centered (falling, etc) |
| 117 |
if ( yawByte == 255 && pitchByte == 255 ) { |
| 118 |
cg.damageX = 0; |
| 119 |
cg.damageY = 0; |
| 120 |
cg.v_dmg_roll = 0; |
| 121 |
cg.v_dmg_pitch = -kick; |
| 122 |
} else { |
| 123 |
// positional |
| 124 |
pitch = pitchByte / 255.0 * 360; |
| 125 |
yaw = yawByte / 255.0 * 360; |
| 126 |
|
| 127 |
angles[PITCH] = pitch; |
| 128 |
angles[YAW] = yaw; |
| 129 |
angles[ROLL] = 0; |
| 130 |
|
| 131 |
AngleVectors( angles, dir, NULL, NULL ); |
| 132 |
VectorSubtract( vec3_origin, dir, dir ); |
| 133 |
|
| 134 |
front = DotProduct (dir, cg.refdef.viewaxis[0] ); |
| 135 |
left = DotProduct (dir, cg.refdef.viewaxis[1] ); |
| 136 |
up = DotProduct (dir, cg.refdef.viewaxis[2] ); |
| 137 |
|
| 138 |
dir[0] = front; |
| 139 |
dir[1] = left; |
| 140 |
dir[2] = 0; |
| 141 |
dist = VectorLength( dir ); |
| 142 |
if ( dist < 0.1 ) { |
| 143 |
dist = 0.1f; |
| 144 |
} |
| 145 |
|
| 146 |
cg.v_dmg_roll = kick * left; |
| 147 |
|
| 148 |
cg.v_dmg_pitch = -kick * front; |
| 149 |
|
| 150 |
if ( front <= 0.1 ) { |
| 151 |
front = 0.1f; |
| 152 |
} |
| 153 |
cg.damageX = -left / front; |
| 154 |
cg.damageY = up / dist; |
| 155 |
} |
| 156 |
|
| 157 |
// clamp the position |
| 158 |
if ( cg.damageX > 1.0 ) { |
| 159 |
cg.damageX = 1.0; |
| 160 |
} |
| 161 |
if ( cg.damageX < - 1.0 ) { |
| 162 |
cg.damageX = -1.0; |
| 163 |
} |
| 164 |
|
| 165 |
if ( cg.damageY > 1.0 ) { |
| 166 |
cg.damageY = 1.0; |
| 167 |
} |
| 168 |
if ( cg.damageY < - 1.0 ) { |
| 169 |
cg.damageY = -1.0; |
| 170 |
} |
| 171 |
|
| 172 |
// don't let the screen flashes vary as much |
| 173 |
if ( kick > 10 ) { |
| 174 |
kick = 10; |
| 175 |
} |
| 176 |
cg.damageValue = kick; |
| 177 |
cg.v_dmg_time = cg.time + DAMAGE_TIME; |
| 178 |
cg.damageTime = cg.snap->serverTime; |
| 179 |
} |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
/* |
| 185 |
================ |
| 186 |
CG_Respawn |
| 187 |
|
| 188 |
A respawn happened this snapshot |
| 189 |
================ |
| 190 |
*/ |
| 191 |
void CG_Respawn( void ) { |
| 192 |
// no error decay on player movement |
| 193 |
cg.thisFrameTeleport = qtrue; |
| 194 |
|
| 195 |
// display weapons available |
| 196 |
cg.weaponSelectTime = cg.time; |
| 197 |
|
| 198 |
// select the weapon the server says we are using |
| 199 |
cg.weaponSelect = cg.snap->ps.weapon; |
| 200 |
} |
| 201 |
|
| 202 |
extern char *eventnames[]; |
| 203 |
|
| 204 |
/* |
| 205 |
============== |
| 206 |
CG_CheckPlayerstateEvents |
| 207 |
============== |
| 208 |
*/ |
| 209 |
void CG_CheckPlayerstateEvents( playerState_t *ps, playerState_t *ops ) { |
| 210 |
int i; |
| 211 |
int event; |
| 212 |
centity_t *cent; |
| 213 |
|
| 214 |
if ( ps->externalEvent && ps->externalEvent != ops->externalEvent ) { |
| 215 |
cent = &cg_entities[ ps->clientNum ]; |
| 216 |
cent->currentState.event = ps->externalEvent; |
| 217 |
cent->currentState.eventParm = ps->externalEventParm; |
| 218 |
CG_EntityEvent( cent, cent->lerpOrigin ); |
| 219 |
} |
| 220 |
|
| 221 |
cent = &cg.predictedPlayerEntity; // cg_entities[ ps->clientNum ]; |
| 222 |
// go through the predictable events buffer |
| 223 |
for ( i = ps->eventSequence - MAX_PS_EVENTS ; i < ps->eventSequence ; i++ ) { |
| 224 |
// if we have a new predictable event |
| 225 |
if ( i >= ops->eventSequence |
| 226 |
// or the server told us to play another event instead of a predicted event we already issued |
| 227 |
// or something the server told us changed our prediction causing a different event |
| 228 |
|| (i > ops->eventSequence - MAX_PS_EVENTS && ps->events[i & (MAX_PS_EVENTS-1)] != ops->events[i & (MAX_PS_EVENTS-1)]) ) { |
| 229 |
|
| 230 |
event = ps->events[ i & (MAX_PS_EVENTS-1) ]; |
| 231 |
cent->currentState.event = event; |
| 232 |
cent->currentState.eventParm = ps->eventParms[ i & (MAX_PS_EVENTS-1) ]; |
| 233 |
CG_EntityEvent( cent, cent->lerpOrigin ); |
| 234 |
|
| 235 |
cg.predictableEvents[ i & (MAX_PREDICTED_EVENTS-1) ] = event; |
| 236 |
|
| 237 |
cg.eventSequence++; |
| 238 |
} |
| 239 |
} |
| 240 |
} |
| 241 |
|
| 242 |
/* |
| 243 |
================== |
| 244 |
CG_CheckChangedPredictableEvents |
| 245 |
================== |
| 246 |
*/ |
| 247 |
void CG_CheckChangedPredictableEvents( playerState_t *ps ) { |
| 248 |
int i; |
| 249 |
int event; |
| 250 |
centity_t *cent; |
| 251 |
|
| 252 |
cent = &cg.predictedPlayerEntity; |
| 253 |
for ( i = ps->eventSequence - MAX_PS_EVENTS ; i < ps->eventSequence ; i++ ) { |
| 254 |
// |
| 255 |
if (i >= cg.eventSequence) { |
| 256 |
continue; |
| 257 |
} |
| 258 |
// if this event is not further back in than the maximum predictable events we remember |
| 259 |
if (i > cg.eventSequence - MAX_PREDICTED_EVENTS) { |
| 260 |
// if the new playerstate event is different from a previously predicted one |
| 261 |
if ( ps->events[i & (MAX_PS_EVENTS-1)] != cg.predictableEvents[i & (MAX_PREDICTED_EVENTS-1) ] ) { |
| 262 |
|
| 263 |
event = ps->events[ i & (MAX_PS_EVENTS-1) ]; |
| 264 |
cent->currentState.event = event; |
| 265 |
cent->currentState.eventParm = ps->eventParms[ i & (MAX_PS_EVENTS-1) ]; |
| 266 |
CG_EntityEvent( cent, cent->lerpOrigin ); |
| 267 |
|
| 268 |
cg.predictableEvents[ i & (MAX_PREDICTED_EVENTS-1) ] = event; |
| 269 |
|
| 270 |
if ( cg_showmiss.integer ) { |
| 271 |
CG_Printf("WARNING: changed predicted event\n"); |
| 272 |
} |
| 273 |
} |
| 274 |
} |
| 275 |
} |
| 276 |
} |
| 277 |
|
| 278 |
/* |
| 279 |
================== |
| 280 |
pushReward |
| 281 |
================== |
| 282 |
*/ |
| 283 |
static void pushReward(sfxHandle_t sfx, qhandle_t shader, int rewardCount) { |
| 284 |
if (cg.rewardStack < (MAX_REWARDSTACK-1)) { |
| 285 |
cg.rewardStack++; |
| 286 |
cg.rewardSound[cg.rewardStack] = sfx; |
| 287 |
cg.rewardShader[cg.rewardStack] = shader; |
| 288 |
cg.rewardCount[cg.rewardStack] = rewardCount; |
| 289 |
} |
| 290 |
} |
| 291 |
|
| 292 |
|
| 293 |
/* |
| 294 |
================== |
| 295 |
CG_CheckLocalSounds |
| 296 |
================== |
| 297 |
*/ |
| 298 |
void CG_CheckLocalSounds( playerState_t *ps, playerState_t *ops ) { |
| 299 |
int highScore, health, armor, reward; |
| 300 |
sfxHandle_t sfx; |
| 301 |
|
| 302 |
// don't play the sounds if the player just changed teams |
| 303 |
if ( ps->persistant[PERS_TEAM] != ops->persistant[PERS_TEAM] ) { |
| 304 |
return; |
| 305 |
} |
| 306 |
|
| 307 |
// hit changes |
| 308 |
if ( ps->persistant[PERS_HITS] > ops->persistant[PERS_HITS] ) { |
| 309 |
armor = ps->persistant[PERS_ATTACKEE_ARMOR] & 0xff; |
| 310 |
health = ps->persistant[PERS_ATTACKEE_ARMOR] >> 8; |
| 311 |
#ifdef MISSIONPACK |
| 312 |
if (armor > 50 ) { |
| 313 |
trap_S_StartLocalSound( cgs.media.hitSoundHighArmor, CHAN_LOCAL_SOUND ); |
| 314 |
} else if (armor || health > 100) { |
| 315 |
trap_S_StartLocalSound( cgs.media.hitSoundLowArmor, CHAN_LOCAL_SOUND ); |
| 316 |
} else { |
| 317 |
trap_S_StartLocalSound( cgs.media.hitSound, CHAN_LOCAL_SOUND ); |
| 318 |
} |
| 319 |
#else |
| 320 |
trap_S_StartLocalSound( cgs.media.hitSound, CHAN_LOCAL_SOUND ); |
| 321 |
#endif |
| 322 |
} else if ( ps->persistant[PERS_HITS] < ops->persistant[PERS_HITS] ) { |
| 323 |
trap_S_StartLocalSound( cgs.media.hitTeamSound, CHAN_LOCAL_SOUND ); |
| 324 |
} |
| 325 |
|
| 326 |
// health changes of more than -1 should make pain sounds |
| 327 |
if ( ps->stats[STAT_HEALTH] < ops->stats[STAT_HEALTH] - 1 ) { |
| 328 |
if ( ps->stats[STAT_HEALTH] > 0 ) { |
| 329 |
CG_PainEvent( &cg.predictedPlayerEntity, ps->stats[STAT_HEALTH] ); |
| 330 |
} |
| 331 |
} |
| 332 |
|
| 333 |
|
| 334 |
// if we are going into the intermission, don't start any voices |
| 335 |
if ( cg.intermissionStarted ) { |
| 336 |
return; |
| 337 |
} |
| 338 |
|
| 339 |
// reward sounds |
| 340 |
reward = qfalse; |
| 341 |
if (ps->persistant[PERS_CAPTURES] != ops->persistant[PERS_CAPTURES]) { |
| 342 |
pushReward(cgs.media.captureAwardSound, cgs.media.medalCapture, ps->persistant[PERS_CAPTURES]); |
| 343 |
reward = qtrue; |
| 344 |
//Com_Printf("capture\n"); |
| 345 |
} |
| 346 |
if (ps->persistant[PERS_IMPRESSIVE_COUNT] != ops->persistant[PERS_IMPRESSIVE_COUNT]) { |
| 347 |
#ifdef MISSIONPACK |
| 348 |
if (ps->persistant[PERS_IMPRESSIVE_COUNT] == 1) { |
| 349 |
sfx = cgs.media.firstImpressiveSound; |
| 350 |
} else { |
| 351 |
sfx = cgs.media.impressiveSound; |
| 352 |
} |
| 353 |
#else |
| 354 |
sfx = cgs.media.impressiveSound; |
| 355 |
#endif |
| 356 |
pushReward(sfx, cgs.media.medalImpressive, ps->persistant[PERS_IMPRESSIVE_COUNT]); |
| 357 |
reward = qtrue; |
| 358 |
//Com_Printf("impressive\n"); |
| 359 |
} |
| 360 |
//KK-OAX We Just Won't Draw The Excellent Stuff if Multikills are Enabled!!! |
| 361 |
if( !cgs.altExcellent ) { |
| 362 |
if (ps->persistant[PERS_EXCELLENT_COUNT] != ops->persistant[PERS_EXCELLENT_COUNT]) { |
| 363 |
#ifdef MISSIONPACK |
| 364 |
if (ps->persistant[PERS_EXCELLENT_COUNT] == 1) { |
| 365 |
sfx = cgs.media.firstExcellentSound; |
| 366 |
} else { |
| 367 |
sfx = cgs.media.excellentSound; |
| 368 |
} |
| 369 |
#else |
| 370 |
sfx = cgs.media.excellentSound; |
| 371 |
#endif |
| 372 |
|
| 373 |
pushReward(sfx, cgs.media.medalExcellent, ps->persistant[PERS_EXCELLENT_COUNT]); |
| 374 |
reward = qtrue; |
| 375 |
//Com_Printf("excellent\n"); |
| 376 |
} |
| 377 |
} |
| 378 |
if (ps->persistant[PERS_GAUNTLET_FRAG_COUNT] != ops->persistant[PERS_GAUNTLET_FRAG_COUNT]) { |
| 379 |
#ifdef MISSIONPACK |
| 380 |
if (ops->persistant[PERS_GAUNTLET_FRAG_COUNT] == 1) { |
| 381 |
sfx = cgs.media.firstHumiliationSound; |
| 382 |
} else { |
| 383 |
sfx = cgs.media.humiliationSound; |
| 384 |
} |
| 385 |
#else |
| 386 |
sfx = cgs.media.humiliationSound; |
| 387 |
#endif |
| 388 |
pushReward(sfx, cgs.media.medalGauntlet, ps->persistant[PERS_GAUNTLET_FRAG_COUNT]); |
| 389 |
reward = qtrue; |
| 390 |
//Com_Printf("guantlet frag\n"); |
| 391 |
} |
| 392 |
if (ps->persistant[PERS_DEFEND_COUNT] != ops->persistant[PERS_DEFEND_COUNT]) { |
| 393 |
pushReward(cgs.media.defendSound, cgs.media.medalDefend, ps->persistant[PERS_DEFEND_COUNT]); |
| 394 |
reward = qtrue; |
| 395 |
//Com_Printf("defend\n"); |
| 396 |
} |
| 397 |
if (ps->persistant[PERS_ASSIST_COUNT] != ops->persistant[PERS_ASSIST_COUNT]) { |
| 398 |
pushReward(cgs.media.assistSound, cgs.media.medalAssist, ps->persistant[PERS_ASSIST_COUNT]); |
| 399 |
reward = qtrue; |
| 400 |
//Com_Printf("assist\n"); |
| 401 |
} |
| 402 |
// if any of the player event bits changed |
| 403 |
if (ps->persistant[PERS_PLAYEREVENTS] != ops->persistant[PERS_PLAYEREVENTS]) { |
| 404 |
if ((ps->persistant[PERS_PLAYEREVENTS] & PLAYEREVENT_DENIEDREWARD) != |
| 405 |
(ops->persistant[PERS_PLAYEREVENTS] & PLAYEREVENT_DENIEDREWARD)) { |
| 406 |
trap_S_StartLocalSound( cgs.media.deniedSound, CHAN_ANNOUNCER ); |
| 407 |
} |
| 408 |
else if ((ps->persistant[PERS_PLAYEREVENTS] & PLAYEREVENT_GAUNTLETREWARD) != |
| 409 |
(ops->persistant[PERS_PLAYEREVENTS] & PLAYEREVENT_GAUNTLETREWARD)) { |
| 410 |
trap_S_StartLocalSound( cgs.media.humiliationSound, CHAN_ANNOUNCER ); |
| 411 |
} |
| 412 |
else if ((ps->persistant[PERS_PLAYEREVENTS] & PLAYEREVENT_HOLYSHIT) != |
| 413 |
(ops->persistant[PERS_PLAYEREVENTS] & PLAYEREVENT_HOLYSHIT)) { |
| 414 |
trap_S_StartLocalSound( cgs.media.holyShitSound, CHAN_ANNOUNCER ); |
| 415 |
} |
| 416 |
reward = qtrue; |
| 417 |
} |
| 418 |
|
| 419 |
// check for flag pickup |
| 420 |
if ( cgs.gametype > GT_TEAM ) { |
| 421 |
if ((ps->powerups[PW_REDFLAG] != ops->powerups[PW_REDFLAG] && ps->powerups[PW_REDFLAG]) || |
| 422 |
(ps->powerups[PW_BLUEFLAG] != ops->powerups[PW_BLUEFLAG] && ps->powerups[PW_BLUEFLAG]) || |
| 423 |
(ps->powerups[PW_NEUTRALFLAG] != ops->powerups[PW_NEUTRALFLAG] && ps->powerups[PW_NEUTRALFLAG]) ) |
| 424 |
{ |
| 425 |
trap_S_StartLocalSound( cgs.media.youHaveFlagSound, CHAN_ANNOUNCER ); |
| 426 |
} |
| 427 |
} |
| 428 |
|
| 429 |
// lead changes |
| 430 |
if (!reward) { |
| 431 |
// |
| 432 |
if ( !cg.warmup ) { |
| 433 |
// never play lead changes during warmup |
| 434 |
if ( ps->persistant[PERS_RANK] != ops->persistant[PERS_RANK] ) { |
| 435 |
if ( cgs.gametype < GT_TEAM || cgs.ffa_gt==1) { |
| 436 |
if ( ps->persistant[PERS_RANK] == 0 ) { |
| 437 |
CG_AddBufferedSound(cgs.media.takenLeadSound); |
| 438 |
} else if ( ps->persistant[PERS_RANK] == RANK_TIED_FLAG ) { |
| 439 |
CG_AddBufferedSound(cgs.media.tiedLeadSound); |
| 440 |
} else if ( ( ops->persistant[PERS_RANK] & ~RANK_TIED_FLAG ) == 0 ) { |
| 441 |
CG_AddBufferedSound(cgs.media.lostLeadSound); |
| 442 |
} |
| 443 |
} |
| 444 |
} |
| 445 |
} |
| 446 |
} |
| 447 |
|
| 448 |
// timelimit warnings |
| 449 |
if ( cgs.timelimit > 0 && cgs.timelimit <= 1000 ) { |
| 450 |
int msec; |
| 451 |
|
| 452 |
msec = cg.time - cgs.levelStartTime; |
| 453 |
if ( !( cg.timelimitWarnings & 4 ) && msec > ( cgs.timelimit * 60 + 2 ) * 1000 ) { |
| 454 |
cg.timelimitWarnings |= 1 | 2 | 4; |
| 455 |
trap_S_StartLocalSound( cgs.media.suddenDeathSound, CHAN_ANNOUNCER ); |
| 456 |
} |
| 457 |
else if ( !( cg.timelimitWarnings & 2 ) && msec > (cgs.timelimit - 1) * 60 * 1000 ) { |
| 458 |
cg.timelimitWarnings |= 1 | 2; |
| 459 |
trap_S_StartLocalSound( cgs.media.oneMinuteSound, CHAN_ANNOUNCER ); |
| 460 |
} |
| 461 |
else if ( cgs.timelimit > 5 && !( cg.timelimitWarnings & 1 ) && msec > (cgs.timelimit - 5) * 60 * 1000 ) { |
| 462 |
cg.timelimitWarnings |= 1; |
| 463 |
trap_S_StartLocalSound( cgs.media.fiveMinuteSound, CHAN_ANNOUNCER ); |
| 464 |
} |
| 465 |
} |
| 466 |
|
| 467 |
// fraglimit warnings |
| 468 |
if ( cgs.fraglimit > 0 && cgs.gametype < GT_CTF) { |
| 469 |
highScore = cgs.scores1; |
| 470 |
|
| 471 |
if (cgs.gametype == GT_TEAM && cgs.scores2 > highScore) { |
| 472 |
highScore = cgs.scores2; |
| 473 |
} |
| 474 |
|
| 475 |
if ( !( cg.fraglimitWarnings & 4 ) && highScore == (cgs.fraglimit - 1) ) { |
| 476 |
cg.fraglimitWarnings |= 1 | 2 | 4; |
| 477 |
CG_AddBufferedSound(cgs.media.oneFragSound); |
| 478 |
} |
| 479 |
else if ( cgs.fraglimit > 2 && !( cg.fraglimitWarnings & 2 ) && highScore == (cgs.fraglimit - 2) ) { |
| 480 |
cg.fraglimitWarnings |= 1 | 2; |
| 481 |
CG_AddBufferedSound(cgs.media.twoFragSound); |
| 482 |
} |
| 483 |
else if ( cgs.fraglimit > 3 && !( cg.fraglimitWarnings & 1 ) && highScore == (cgs.fraglimit - 3) ) { |
| 484 |
cg.fraglimitWarnings |= 1; |
| 485 |
CG_AddBufferedSound(cgs.media.threeFragSound); |
| 486 |
} |
| 487 |
} |
| 488 |
} |
| 489 |
|
| 490 |
/* |
| 491 |
=============== |
| 492 |
CG_TransitionPlayerState |
| 493 |
|
| 494 |
=============== |
| 495 |
*/ |
| 496 |
void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops ) { |
| 497 |
// check for changing follow mode |
| 498 |
if ( ps->clientNum != ops->clientNum ) { |
| 499 |
cg.thisFrameTeleport = qtrue; |
| 500 |
// make sure we don't get any unwanted transition effects |
| 501 |
*ops = *ps; |
| 502 |
} |
| 503 |
|
| 504 |
// damage events (player is getting wounded) |
| 505 |
if ( ps->damageEvent != ops->damageEvent && ps->damageCount ) { |
| 506 |
CG_DamageFeedback( ps->damageYaw, ps->damagePitch, ps->damageCount ); |
| 507 |
} |
| 508 |
|
| 509 |
// respawning |
| 510 |
if ( ps->persistant[PERS_SPAWN_COUNT] != ops->persistant[PERS_SPAWN_COUNT] ) { |
| 511 |
CG_Respawn(); |
| 512 |
} |
| 513 |
|
| 514 |
if ( cg.mapRestart ) { |
| 515 |
CG_Respawn(); |
| 516 |
cg.mapRestart = qfalse; |
| 517 |
} |
| 518 |
|
| 519 |
if ( cg.snap->ps.pm_type != PM_INTERMISSION |
| 520 |
&& ps->persistant[PERS_TEAM] != TEAM_SPECTATOR ) { |
| 521 |
CG_CheckLocalSounds( ps, ops ); |
| 522 |
} |
| 523 |
|
| 524 |
// check for going low on ammo |
| 525 |
CG_CheckAmmo(); |
| 526 |
|
| 527 |
// run events |
| 528 |
CG_CheckPlayerstateEvents( ps, ops ); |
| 529 |
|
| 530 |
// smooth the ducking viewheight change |
| 531 |
if ( ps->viewheight != ops->viewheight ) { |
| 532 |
cg.duckChange = ps->viewheight - ops->viewheight; |
| 533 |
cg.duckTime = cg.time; |
| 534 |
} |
| 535 |
} |
| 536 |
|