/* * CG_FirePlayerStateEvents * This events are only received by this client, and only affect it. */ static void CG_FirePlayerStateEvents( void ) { unsigned int event, parm, i, count; vec3_t dir; if( !cg.frame.playerState.event ) return; if( cg.view.POVent != (int)cg.frame.playerState.POVnum ) return; for( count = 0; count < 2; count++ ) { // first byte is event number, second is parm event = cg.frame.playerState.event[count] & 127; parm = cg.frame.playerState.eventParm[count] & 0xFF; switch( event ) { case PSEV_HIT: if( parm > 6 ) break; if( parm < 4 ) { // hit of some caliber trap_S_StartGlobalSound( CG_MediaSfx( cgs.media.sfxWeaponHit[parm] ), CHAN_AUTO, cg_volume_hitsound->value ); CG_ScreenCrosshairDamageUpdate(); } else if( parm == 4 ) // killed an enemy { trap_S_StartGlobalSound( CG_MediaSfx( cgs.media.sfxWeaponKill ), CHAN_AUTO, cg_volume_hitsound->value ); CG_ScreenCrosshairDamageUpdate(); } else { // hit a teammate trap_S_StartGlobalSound( CG_MediaSfx( cgs.media.sfxWeaponHitTeam ), CHAN_AUTO, cg_volume_hitsound->value ); if( cg_showhelp->integer ) { if( random() <= 0.5f ) CG_CenterPrint( "Don't shoot at members of your team!" ); else CG_CenterPrint( "You are shooting at your teammates!" ); } } break; case PSEV_PICKUP: if( cg_pickup_flash->integer && !cg.view.thirdperson ) CG_StartColorBlendEffect( 1.0f, 1.0f, 1.0f, 0.25f, 150 ); // auto-switch if( cg_weaponAutoSwitch->integer && ( parm > WEAP_NONE && parm < WEAP_TOTAL ) ) { if( !cgs.demoPlaying && cg.predictedPlayerState.pmove.pm_type == PM_NORMAL && cg.predictedPlayerState.POVnum == cgs.playerNum + 1 ) { // auto-switch only works when the user didn't have the just-picked weapon if( !cg.oldFrame.playerState.inventory[parm] ) { // switch when player's only weapon is gunblade if( cg_weaponAutoSwitch->integer == 2 ) { for( i = WEAP_GUNBLADE + 1; i < WEAP_TOTAL; i++ ) { if( i == parm ) continue; if( cg.predictedPlayerState.inventory[i] ) break; } if( i == WEAP_TOTAL ) // didn't have any weapon CG_UseItem( va( "%i", parm ) ); } // switch when the new weapon improves player's selected weapon else if( cg_weaponAutoSwitch->integer == 1 ) { unsigned int best = WEAP_GUNBLADE; for( i = WEAP_GUNBLADE + 1; i < WEAP_TOTAL; i++ ) { if( i == parm ) continue; if( cg.predictedPlayerState.inventory[i] ) best = i; } if( best < parm ) CG_UseItem( va( "%i", parm ) ); } } } } break; case PSEV_DAMAGE_20: ByteToDir( parm, dir ); CG_DamageIndicatorAdd( 20, dir ); break; case PSEV_DAMAGE_40: ByteToDir( parm, dir ); CG_DamageIndicatorAdd( 40, dir ); break; case PSEV_DAMAGE_60: ByteToDir( parm, dir ); CG_DamageIndicatorAdd( 60, dir ); break; case PSEV_DAMAGE_80: ByteToDir( parm, dir ); CG_DamageIndicatorAdd( 80, dir ); break; case PSEV_INDEXEDSOUND: if( cgs.soundPrecache[parm] ) trap_S_StartGlobalSound( cgs.soundPrecache[parm], CHAN_AUTO, cg_volume_effects->value ); break; case PSEV_ANNOUNCER: CG_AddAnnouncerEvent( cgs.soundPrecache[parm], qfalse ); break; case PSEV_ANNOUNCER_QUEUED: CG_AddAnnouncerEvent( cgs.soundPrecache[parm], qtrue ); break; default: break; } } }
/* * CG_AddLocalSounds */ static void CG_AddLocalSounds( void ) { static bool postmatchsound_set = false, demostream = false, background = false; static unsigned int lastSecond = 0; // add local announces if( GS_Countdown() ) { if( GS_MatchDuration() ) { unsigned int duration, curtime, remainingSeconds; float seconds; curtime = GS_MatchPaused() ? cg.frame.serverTime : cg.time; duration = GS_MatchDuration(); if( duration + GS_MatchStartTime() < curtime ) duration = curtime - GS_MatchStartTime(); // avoid negative results seconds = (float)( GS_MatchStartTime() + duration - curtime ) * 0.001f; remainingSeconds = (unsigned int)seconds; if( remainingSeconds != lastSecond ) { if( 1 + remainingSeconds < 4 ) { struct sfx_s *sound = trap_S_RegisterSound( va( S_ANNOUNCER_COUNTDOWN_COUNT_1_to_3_SET_1_to_2, 1 + remainingSeconds, 1 ) ); CG_AddAnnouncerEvent( sound, false ); } lastSecond = remainingSeconds; } } } else lastSecond = 0; // add sounds from announcer CG_ReleaseAnnouncerEvents(); // if in postmatch, play postmatch song if( GS_MatchState() >= MATCH_STATE_POSTMATCH ) { if( !postmatchsound_set && !demostream ) { trap_S_StartBackgroundTrack( S_PLAYLIST_POSTMATCH, NULL, 3 ); // loop random track from the playlist postmatchsound_set = true; background = false; } } else { if( cgs.demoPlaying && cgs.demoAudioStream && !demostream ) { trap_S_StartBackgroundTrack( cgs.demoAudioStream, NULL, 0 ); demostream = true; } if( postmatchsound_set ) { trap_S_StopBackgroundTrack(); postmatchsound_set = false; background = false; } if( (!postmatchsound_set && !demostream) && !background ) { CG_StartBackgroundTrack(); background = true; } // notice: these 2 sound files aren't used anymore //cgs.media.sfxTimerBipBip //cgs.media.sfxTimerPloink } }