//------------------------------------------------------------------------------ // Purpose: //------------------------------------------------------------------------------ void CAmbientGeneric::Activate( void ) { BaseClass::Activate(); // Initialize sound source. If no source was given, or source can't be found // then this is the source if (m_hSoundSource == NULL) { if (m_sSourceEntName != NULL_STRING) { m_hSoundSource = gEntList.FindEntityByName( NULL, m_sSourceEntName ); if ( m_hSoundSource != NULL ) { m_nSoundSourceEntIndex = m_hSoundSource->entindex(); } } if (m_hSoundSource == NULL) { m_hSoundSource = this; m_nSoundSourceEntIndex = entindex(); } else { if ( !FBitSet( m_spawnflags, SF_AMBIENT_SOUND_EVERYWHERE ) ) { AddEFlags( EFL_FORCE_CHECK_TRANSMIT ); } } } // If active start the sound if ( m_fActive ) { int flags = SND_SPAWNING; // If we are loading a saved game, we can't write into the init/signon buffer here, so just issue // as a regular sound message... if ( gpGlobals->eLoadType == MapLoad_Transition || gpGlobals->eLoadType == MapLoad_LoadGame || g_pGameRules->InRoundRestart() ) { flags = SND_NOFLAGS; } // Tracker 76119: 8/12/07 ywb: // Make sure pitch and volume are set up to the correct value (especially after restoring a .sav file) flags |= ( SND_CHANGE_PITCH | SND_CHANGE_VOL ); // Don't bother sending over to client if volume is zero, though if ( m_dpv.vol > 0 ) { SendSound( (SoundFlags_t)flags ); } SetNextThink( gpGlobals->curtime + 0.1f ); } }
void PySendEvent( IRecipientFilter &filter, EHANDLE ent, int event, int data) { if( g_debug_pyevent.GetBool() ) { DevMsg("Sending Python event to entity #%d with event %d and data %d\n", ent ? ent->entindex() : -1, event, data); } g_TEPyEvent.m_hEnt = ent; g_TEPyEvent.m_iEvent = event; g_TEPyEvent.m_nData = data; g_TEPyEvent.Create( filter, 0 ); }
//------------------------------------------------------------------------------ // Purpose: //------------------------------------------------------------------------------ void CAmbientGeneric::Activate( void ) { BaseClass::Activate(); // Initialize sound source. If no source was given, or source can't be found // then this is the source if (m_hSoundSource == NULL) { if (m_sSourceEntName != NULL_STRING) { m_hSoundSource = gEntList.FindEntityByName( NULL, m_sSourceEntName ); if ( m_hSoundSource != NULL ) { m_nSoundSourceEntIndex = m_hSoundSource->entindex(); } } if (m_hSoundSource == NULL) { m_hSoundSource = this; m_nSoundSourceEntIndex = entindex(); } else { if ( !FBitSet( m_spawnflags, SF_AMBIENT_SOUND_EVERYWHERE ) ) { AddEFlags( EFL_FORCE_CHECK_TRANSMIT ); } } } // If active start the sound if ( m_fActive ) { SoundFlags_t flags = SND_SPAWNING; // If we are loading a saved game, we can't write into the init/signon buffer here, so just issue // as a regular sound message... if ( gpGlobals->eLoadType == MapLoad_Transition || gpGlobals->eLoadType == MapLoad_LoadGame || g_pGameRules->InRoundRestart() ) { flags = SND_NOFLAGS; } SendSound( flags ); SetNextThink( gpGlobals->curtime + 0.1f ); } }
//------------------------------------------------------------------------------ // Purpose: //------------------------------------------------------------------------------ void CAmbientGeneric::Activate( void ) { BaseClass::Activate(); // Initialize sound source. If no source was given, or source can't be found // then this is the source if (m_hSoundSource == NULL) { if (m_sSourceEntName != NULL_STRING) { m_hSoundSource = gEntList.FindEntityByName( NULL, m_sSourceEntName ); if ( m_hSoundSource != NULL ) { m_nSoundSourceEntIndex = m_hSoundSource->entindex(); } } if (m_hSoundSource == NULL) { m_hSoundSource = this; m_nSoundSourceEntIndex = entindex(); } else { if ( !FBitSet( m_spawnflags, SF_AMBIENT_SOUND_EVERYWHERE ) ) { AddEFlags( EFL_FORCE_CHECK_TRANSMIT ); } } } #ifdef PORTAL // This is the only way we can silence the radio sound from the first room without touching them map -- jdw if ( PortalGameRules() && PortalGameRules()->ShouldRemoveRadio() ) { if ( V_strcmp( STRING( gpGlobals->mapname ), "testchmb_a_00" ) == 0 || V_strcmp( STRING( gpGlobals->mapname ), "testchmb_a_11" ) == 0 || V_strcmp( STRING( gpGlobals->mapname ), "testchmb_a_14" ) == 0 ) { if ( V_strcmp( STRING( GetEntityName() ), "radio_sound" ) == 0 ) { UTIL_Remove( this ); return; } } } #endif // PORTAL // If active start the sound if ( m_fActive ) { int flags = SND_SPAWNING; // If we are loading a saved game, we can't write into the init/signon buffer here, so just issue // as a regular sound message... if ( gpGlobals->eLoadType == MapLoad_Transition || gpGlobals->eLoadType == MapLoad_LoadGame || g_pGameRules->InRoundRestart() ) { flags = SND_NOFLAGS; } // Tracker 76119: 8/12/07 ywb: // Make sure pitch and volume are set up to the correct value (especially after restoring a .sav file) flags |= ( SND_CHANGE_PITCH | SND_CHANGE_VOL ); // Don't bother sending over to client if volume is zero, though if ( m_dpv.vol > 0 ) { SendSound( (SoundFlags_t)flags ); } SetNextThink( gpGlobals->curtime + 0.1f ); } }
void C_SDKRagdoll::ClientThink( void ) { SetNextClientThink( CLIENT_THINK_ALWAYS ); if ( m_bFadingOut == true ) { int iAlpha = GetRenderColor().a; int iFadeSpeed = 600.0f; iAlpha = max( iAlpha - ( iFadeSpeed * gpGlobals->frametime ), 0 ); SetRenderMode( kRenderTransAlpha ); SetRenderColorA( iAlpha ); if ( iAlpha == 0 ) { Release(); } return; } for( int iClient = 1; iClient <= gpGlobals->maxClients; ++iClient ) { C_SDKPlayer *pEnt = static_cast< C_SDKPlayer *> ( UTIL_PlayerByIndex( iClient ) ); if(!pEnt || !pEnt->IsPlayer()) continue; if ( m_hPlayer == NULL ) continue; if ( pEnt->entindex() == m_hPlayer->entindex() ) continue; if ( pEnt->GetHealth() <= 0 ) continue; #if defined ( SDK_USE_PRONE ) if ( pEnt->m_Shared.IsProne() == false ) continue; #endif Vector vTargetOrigin = pEnt->GetAbsOrigin(); Vector vMyOrigin = GetAbsOrigin(); Vector vDir = vTargetOrigin - vMyOrigin; if ( vDir.Length() > cl_ragdoll_pronecheck_distance.GetInt() ) continue; SetNextClientThink( CLIENT_THINK_ALWAYS ); m_bFadingOut = true; return; } //Tony; this is kind of silly, because.. whats the point of fading out? // if the player is looking at us, delay the fade if ( IsRagdollVisible() ) { StartFadeOut( 5.0 ); return; } if ( m_fDeathTime > gpGlobals->curtime ) return; Release(); // Die }
//----------------------------------------------------------------------------- // Returns the ent index //----------------------------------------------------------------------------- inline int CSoundPatch::EntIndex() const { Assert( !m_hEnt.IsValid() || m_hEnt.Get() ); return m_hEnt.Get() ? m_hEnt->entindex() : -1; }