//----------------------------------------------------------------------------- // Purpose: Update all envelopes and send appropriate data to the client // Input : time - new global clock // deltaTime - amount of time that has passed // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CSoundPatch::Update( float time, float deltaTime ) { if ( m_shutdownTime && time > m_shutdownTime ) { Shutdown(); return false; } if ( EntIndex() < 0 ) { // FIXME: The pointer to this soundpatch is probably leaked since no entity is around to clean it up (ywb) Warning( "CSoundPatch::Update: Removing CSoundPatch (%s) with NULL EHandle\n", STRING(m_iszSoundName) ); return false; } if ( m_pitch.ShouldUpdate() ) { m_pitch.Update( deltaTime ); m_flags |= SND_CHANGE_PITCH; } else { m_flags &= ~SND_CHANGE_PITCH; } if ( m_volume.ShouldUpdate() ) { m_volume.Update( deltaTime ); m_flags |= SND_CHANGE_VOL; } else { m_flags &= ~SND_CHANGE_VOL; } if ( m_flags && m_Filter.IsActive() ) { // SoundPatches take volumes between 0 & 1, and use that to multiply the sounds.txt specified volume. // Because of this, we need to always set the SND_CHANGE_VOL flag when we emit sound, or it'll use the scriptfile's instead. m_flags |= SND_CHANGE_VOL; CBaseEntity::EmitSound( m_Filter, EntIndex(), m_entityChannel, STRING(m_iszSoundName), GetVolumeForEngine(), m_soundlevel, m_flags, (int)m_pitch.Value() ); m_flags = 0; } return true; }
//----------------------------------------------------------------------------- // Purpose: resumes playing the sound on restore //----------------------------------------------------------------------------- void CSoundPatch::ResumeSound( void ) { if ( IsPlaying() && m_Filter.IsActive() ) { CBaseEntity::EmitSound( m_Filter, EntIndex(), m_entityChannel, STRING( m_iszSoundName ), GetVolumeForEngine(), m_soundlevel, SND_CHANGE_VOL | SND_CHANGE_PITCH, (int)m_pitch.Value() ); } }
//----------------------------------------------------------------------------- // Purpose: A new player's entered the game. See if we need to restart our sound. //----------------------------------------------------------------------------- void CSoundPatch::AddPlayerPost( CBasePlayer *pPlayer ) { if ( m_Filter.IsActive() && m_Filter.AddRecipient(pPlayer) ) { // Alrighty, he's new. We need to restart our sound just to him. // Create a new filter just to him. CSingleUserRecipientFilter filter( pPlayer ); CBaseEntity::EmitSound( filter, EntIndex(), m_entityChannel, STRING( m_iszSoundName ), GetVolumeForEngine(), m_soundlevel, SND_CHANGE_VOL, (int)m_pitch.Value() ); } }
//----------------------------------------------------------------------------- // Purpose: Start playing the sound - send updates to the client //----------------------------------------------------------------------------- void CSoundPatch::StartSound( void ) { // Msg( "Start sound %s\n", m_pszSoundName ); m_flags = 0; if ( m_Filter.IsActive() ) { CBaseEntity::EmitSound( m_Filter, EntIndex(), m_entityChannel, STRING( m_iszSoundName ), GetVolumeForEngine(), m_soundlevel, SND_CHANGE_VOL, (int)m_pitch.Value() ); } m_isPlaying = true; }
//----------------------------------------------------------------------------- // Purpose: Stop the sound //----------------------------------------------------------------------------- void CSoundPatch::Shutdown( void ) { // Msg( "Removing sound %s\n", m_pszSoundName ); if ( m_isPlaying ) { int entIndex = EntIndex(); Assert( entIndex >= 0 ); // BUGBUG: Don't crash in release mode if ( entIndex >= 0 ) { CBaseEntity::StopSound( entIndex, m_entityChannel, STRING( m_iszSoundName ) ); } m_isPlaying = false; } }
void ctx_t::Globals::remove_shot( IGameEvent * event ) { auto local_player = static_cast< player_t * >(g_csgo.m_entitylist()->GetClientEntity(g_csgo.m_engine()->GetLocalPlayer())); if ( !g_ctx.m_local ) return; if ( !strcmp( event->GetName( ), "player_hurt" ) ) { int attackerid = g_csgo.m_engine( )->GetPlayerForUserID( event->GetInt( "attacker" ) ), userid = g_csgo.m_engine( )->GetPlayerForUserID( event->GetInt( "userid" ) ); if (!local_player) return; if ( attackerid != local_player->EntIndex( ) ) return; if ( event->GetInt( "hitgroup" ) != 1 ) return; missed_shots[ userid ] = 0; } }