/* * make a sound like thunder * this function is called after each time BoltSound is called */ static void BoomSound() /*********************/ { short i; short low; short high; StopSound(); SetVoiceQueueSize( 1, 600 ); SetVoiceAccent( 1, 120, 50, S_STACCATO, 0 ); for( i=0; i < 1000; i++ ) { /* * create a random low-pitched sound */ high = rand() % 200 + 1; low = rand() % high + 1; SetVoiceSound( 1, MAKELONG( low, high ), 1 ); } StartSound(); WaitSoundState( S_QUEUEEMPTY ); /* wait for the sound to finish */ StopSound(); CloseSound(); } /* BoomSound */
//------------------------------------------------------------------------------ // Purpose : Draw attack beam and do damage / decals // Input : // Output : //------------------------------------------------------------------------------ void CNPC_Stalker::KillAttackBeam(void) { if ( !m_pBeam ) return; // Kill sound StopSound(m_pBeam->entindex(), "NPC_Stalker.BurnWall" ); StopSound(m_pBeam->entindex(), "NPC_Stalker.BurnFlesh" ); UTIL_Remove( m_pLightGlow ); UTIL_Remove( m_pBeam); m_pBeam = NULL; m_bPlayingHitWall = false; m_bPlayingHitFlesh = false; SetThink(&CNPC_Stalker::CallNPCThink); if ( m_flNextNPCThink > gpGlobals->curtime ) { SetNextThink( m_flNextNPCThink ); } // Beam has to recharge m_fBeamRechargeTime = gpGlobals->curtime + STALKER_LASER_RECHARGE; ClearCondition( COND_CAN_RANGE_ATTACK1 ); RelaxAim(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponMedigun::StopHealSound( bool bStopHealingSound, bool bStopNoTargetSound ) { if ( bStopHealingSound ) { StopSound( "WeaponMedigun.Healing" ); } if ( bStopNoTargetSound ) { StopSound( "WeaponMedigun.NoTarget" ); } }
//----------------------------------------------------------------------------- // Purpose: // Input : *pOther - //----------------------------------------------------------------------------- void CRocketMissile::MissileTouch( CBaseEntity *pOther ) { Assert( pOther ); // Don't touch triggers (but DO hit weapons) if ( pOther->IsSolidFlagSet(FSOLID_TRIGGER|FSOLID_VOLUME_CONTENTS)&& pOther->GetCollisionGroup() != COLLISION_GROUP_WEAPON ) { StopSound( "Missile.Accelerate" ); StopSound( "Missile.Ignite" ); this->Remove(); return; } Explode(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CNewWallHealth::Off(void) { // Stop looping sound. if (m_iOn > 1) StopSound( "WallHealth.LoopingContinueCharge" ); if ( m_nState == 1 ) { SetCycle( 1.0f ); } m_iOn = 0; m_flJuice = m_iJuice; if ( m_iReactivate == 0 ) { if ((!m_iJuice) && g_pGameRules->FlHealthChargerRechargeTime() > 0 ) { m_iReactivate = (int)g_pGameRules->FlHealthChargerRechargeTime(); SetNextThink( gpGlobals->curtime + m_iReactivate ); SetThink(&CNewWallHealth::Recharge); } else SetThink( NULL ); } }
void SoundPlayer::UpdateCavalryRunning(bool value) { if (value) PlaySound(SoundSourceCavalryRunning, SoundBufferCavalryRunning, true); else StopSound(SoundSourceCavalryRunning); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CDODBaseRocket::Explode( void ) { // Don't explode against the skybox. Just pretend that // the missile flies off into the distance. Vector vecForward = GetAbsVelocity(); trace_t tr; UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + 60*vecForward, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); m_takedamage = DAMAGE_NO; if( tr.fraction == 1.0 || !(tr.surface.flags & SURF_SKY) ) { DoExplosion(); if ( !tr.m_pEnt->IsPlayer() ) UTIL_DecalTrace( &tr, "Scorch" ); } if( m_hRocketTrail ) { m_hRocketTrail->SetLifetime(0.1f); m_hRocketTrail = NULL; } StopSound( "Weapon_Bazooka.Shoot" ); UTIL_Remove( this ); }
//----------------------------------------------------------------------------- // Creates the explosion effect //----------------------------------------------------------------------------- void CEnvHeadcrabCanister::Detonate( ) { // Send the impact output m_OnImpacted.FireOutput( this, this, 0 ); if ( !HasSpawnFlags( SF_NO_IMPACT_SOUND ) ) { StopSound( "HeadcrabCanister.IncomingSound" ); EmitSound( "HeadcrabCanister.Explosion" ); } // If we're supposed to be removed, do that now if ( HasSpawnFlags( SF_REMOVE_ON_IMPACT ) ) { SetAbsOrigin( m_vecImpactPosition ); SetModel( ENV_HEADCRABCANISTER_BROKEN_MODEL ); SetMoveType( MOVETYPE_NONE ); IncrementInterpolationFrame(); m_bLanded = true; // Become invisible so our trail can finish up AddEffects( EF_NODRAW ); SetSolidFlags( FSOLID_NOT_SOLID ); SetThink( &CEnvHeadcrabCanister::SUB_Remove ); SetNextThink( gpGlobals->curtime + ENV_HEADCRABCANISTER_TRAIL_TIME ); return; } // Test for damaging things TestForCollisionsAgainstWorld( m_vecImpactPosition ); // Shake the screen unless flagged otherwise if ( !HasSpawnFlags( SF_NO_SHAKE ) ) { CBasePlayer *pPlayer = UTIL_GetNearestPlayer(GetAbsOrigin()); // If the player is on foot, then do a more limited shake float shakeRadius = ( pPlayer && pPlayer->IsInAVehicle() ) ? sk_env_headcrabcanister_shake_radius_vehicle.GetFloat() : sk_env_headcrabcanister_shake_radius.GetFloat(); UTIL_ScreenShake( m_vecImpactPosition, sk_env_headcrabcanister_shake_amplitude.GetFloat(), 150.0, 1.0, shakeRadius, SHAKE_START ); } // Do explosion effects if ( !HasSpawnFlags( SF_NO_IMPACT_EFFECTS ) ) { // Normal explosion ExplosionCreate( m_vecImpactPosition, GetAbsAngles(), this, 50.0f, 500.0f, SF_ENVEXPLOSION_NODLIGHTS | SF_ENVEXPLOSION_NOSPARKS | SF_ENVEXPLOSION_NODAMAGE | SF_ENVEXPLOSION_NOSOUND, 1300.0f ); // Dust explosion AR2Explosion *pExplosion = AR2Explosion::CreateAR2Explosion( m_vecImpactPosition ); if( pExplosion ) { pExplosion->SetLifetime(10); } } }
void DoFCEUExit(void) { /* Wolfenstein 3D had cute exit messages. */ char *emsg[4]={"Are you sure you want to leave? I'll become lonely!", "If you exit, I'll... EAT YOUR MOUSE.", "You can never really exit, you know.", "E-x-i-t?" }; if(exiting) /* Eh, oops. I'll need to try to fix this later. */ return; StopSound(); if(goptions & GOO_CONFIRMEXIT) if(IDYES != MessageBox(hAppWnd,emsg[rand()&3],"Exit FCE Ultra?",MB_ICONQUESTION|MB_YESNO)) return; exiting=1; if(GI) { GI=0; RedoMenuGI(GI); #ifdef FCEUDEF_DEBUGGER KillDebugger(); #endif FCEUI_CloseGame(); //GI=0; //RedoMenuGI(GI); } }
void SoundPlayer::UpdateFighting(bool value) { if (value) PlaySound(SoundSourceFighting, SoundBufferInfantryFighting, true); else StopSound(SoundSourceFighting); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- CFuncTank::~CFuncTank( void ) { if ( m_soundLoopRotate != NULL_STRING && (m_spawnflags & SF_TANK_SOUNDON) ) { StopSound( entindex(), CHAN_STATIC, STRING(m_soundLoopRotate) ); } }
void SoundPlayer::StopAll() { for (int i = 0; i < NUMBER_OF_SOUND_SOURCES; ++i) { StopSound((SoundSource)i); } }
static void MultiCB(X6502 *X) { Xsave=X; if(instep>=0) { Redrawsy(X); if(mwin) UpdateDMem(cmsi); } while(instep>=0) { if(instep>=1) { instep--; return; } StopSound(); if(!BlockingCheck()) /* Whoops, need to exit for some reason. */ { instep=-1; FCEUI_SetCPUCallback(0); return; } Sleep(50); } }
//----------------------------------------------------------------------------- // Purpose: find the anim events that may have started sounds, and stop them. //----------------------------------------------------------------------------- void C_BaseObject::StopAnimGeneratedSounds( void ) { MDLCACHE_CRITICAL_SECTION(); CStudioHdr *pStudioHdr = GetModelPtr(); if ( !pStudioHdr ) return; mstudioseqdesc_t &seqdesc = pStudioHdr->pSeqdesc( GetSequence() ); float flCurrentCycle = GetCycle(); mstudioevent_t *pevent = GetEventIndexForSequence( seqdesc ); for (int i = 0; i < (int)seqdesc.numevents; i++) { if ( pevent[i].cycle < flCurrentCycle ) { if ( pevent[i].event == CL_EVENT_SOUND || pevent[i].event == AE_CL_PLAYSOUND ) { StopSound( entindex(), pevent[i].options ); } } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_ObjectBuffStation::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged( updateType ); // Did a player connect / disconnect? for ( int i = 0; i < BUFF_STATION_MAX_PLAYERS; i++ ) { // Something's changed if ( m_hOldPlayers[i] != m_hPlayers[i] ) { // Disconnected? if ( m_hOldPlayers[i] ) { // Stop the startup, in case it's still going StopSound( m_hOldPlayers[i]->entindex(), "ObjectPortablePowerGenerator.Startup" ); // Start the shutdown sound CPASAttenuationFilter filter( m_hOldPlayers[i], "ObjectPortablePowerGenerator.Shutdown" ); EmitSound( filter, m_hOldPlayers[i]->entindex(), "ObjectPortablePowerGenerator.Shutdown" ); } if ( m_hPlayers[i] ) { // Start "buff" sound. CPASAttenuationFilter filter( m_hPlayers[i], "ObjectPortablePowerGenerator.Startup" ); EmitSound( filter, m_hPlayers[i]->entindex(), "ObjectPortablePowerGenerator.Startup" ); } } } }
//----------------------------------------------------------------------------- // Purpose: Reset the charge when we holster //----------------------------------------------------------------------------- bool CTFPipebombLauncher::Holster( CBaseCombatWeapon *pSwitchingTo ) { m_flChargeBeginTime = 0; StopSound("Weapon_StickyBombLauncher.ChargeUp"); return BaseClass::Holster( pSwitchingTo ); }
void EC_Sound::PlaySound() { triggerSound_.Set(false, AttributeChange::LocalOnly); ComponentChanged(AttributeChange::LocalOnly); Foundation::SoundServiceInterface *soundService = framework_->GetService<Foundation::SoundServiceInterface>(); if(!soundService) return; if(sound_id_) StopSound(); OgreRenderer::EC_OgrePlaceable *placeable = dynamic_cast<OgreRenderer::EC_OgrePlaceable *>(FindPlaceable().get()); if(placeable) { sound_id_ = soundService->PlaySound3D(soundId_.Get().toStdString(), Foundation::SoundServiceInterface::Triggered, false, placeable->GetPosition()); soundService->SetGain(sound_id_, soundGain_.Get()); soundService->SetLooped(sound_id_, loopSound_.Get()); soundService->SetRange(sound_id_, soundInnerRadius_.Get(), soundOuterRadius_.Get(), 2.0f); } else // If entity isn't holding placeable component treat sound as ambient sound. { sound_id_ = soundService->PlaySound(soundId_.Get().toStdString(), Foundation::SoundServiceInterface::Ambient); soundService->SetGain(sound_id_, soundGain_.Get()); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CGrenadeRocket::MissileTouch( CBaseEntity *pOther ) { Assert( pOther ); if ( !pOther->IsSolid() ) return; Vector vecAbsOrigin = GetAbsOrigin(); CPASFilter filter( vecAbsOrigin ); te->Explosion( filter, 0.0, &vecAbsOrigin, g_sModelIndexFireball, 2.0, 15, TE_EXPLFLAG_NONE, 100, m_flDamage ); StopSound( "GrenadeRocket.FlyLoop" ); // Don't apply explosive damage if it hit a shield of any kind... bool bHittingShield = false; if (pOther->GetCollisionGroup() == TFCOLLISION_GROUP_SHIELD) { bHittingShield = true; } else if ( pOther->IsPlayer() ) { CBaseTFPlayer *pPlayer = static_cast<CBaseTFPlayer*>(pOther); trace_t tr; float flDamage = m_flDamage; bHittingShield = pPlayer->IsHittingShield( GetAbsVelocity(), &flDamage ); } if (!bHittingShield) { RadiusDamage( CTakeDamageInfo( this, m_pRealOwner, m_flDamage, DMG_BLAST ), vecAbsOrigin, 100, CLASS_NONE ); } UTIL_Remove( this ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- CAPCController::~CAPCController( void ) { if ( m_soundLoopRotate != NULL_STRING ) { StopSound( entindex(), CHAN_STATIC, STRING(m_soundLoopRotate) ); } }
/* ================= hhProjectileCrawlerGrenade::Event_Collision_Bounce ================= */ void hhProjectileCrawlerGrenade::Event_Collision_Bounce( const trace_t* collision, const idVec3 &velocity ) { static const float minCollisionVelocity = 20.0f; static const float maxCollisionVelocity = 90.0f; StopSound( SND_CHANNEL_BODY, true ); // Velocity in normal direction float len = velocity * -collision->c.normal; if( collision->fraction < VECTOR_EPSILON || len < minCollisionVelocity ) { idThread::ReturnInt( 0 ); return; } StartSound( "snd_bounce", SND_CHANNEL_BODY, 0, true, NULL ); float volume = hhUtils::CalculateSoundVolume( len, minCollisionVelocity, maxCollisionVelocity ); HH_SetSoundVolume( volume, SND_CHANNEL_BODY ); BounceSplat( GetOrigin(), -collision->c.normal ); SIMDProcessor->Memcpy( &collisionInfo, collision, sizeof(trace_t) ); collisionInfo.fraction = 0.0f;//Sometimes fraction == 1.0f physicsObj.SetAngularVelocity( 0.5f*physicsObj.GetAngularVelocity() ); idThread::ReturnInt( 0 ); }
void CGERocket::Explode() { StopParticleEffects( this ); StopSound( "Weapon_RocketLauncher.Ignite" ); BaseClass::Explode(); }
/* ============ idSecurityCamera::Killed ============ */ void idSecurityCamera::Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location ) { sweeping = false; StopSound( SND_CHANNEL_ANY, false ); // RAVEN BEGIN // bdube: replaced fx call with raven call gameLocal.PlayEffect ( spawnArgs, "fx_destroyed", GetPhysics()->GetOrigin(), GetPhysics()->GetAxis() ); /* const char *fx = spawnArgs.GetString( "fx_destroyed" ); if ( fx[0] != '\0' ) { idEntityFx::StartFx( fx, NULL, NULL, this, true ); } */ // RAVEN END physicsObj.SetSelf( this ); physicsObj.SetClipModel( new idClipModel( trm ), 0.02f ); physicsObj.SetOrigin( GetPhysics()->GetOrigin() ); physicsObj.SetAxis( GetPhysics()->GetAxis() ); physicsObj.SetBouncyness( 0.2f ); physicsObj.SetFriction( 0.6f, 0.6f, 0.2f ); physicsObj.SetGravity( gameLocal.GetGravity() ); physicsObj.SetContents( CONTENTS_SOLID ); physicsObj.SetClipMask( MASK_SOLID | CONTENTS_BODY | CONTENTS_CORPSE | CONTENTS_MOVEABLECLIP ); SetPhysics( &physicsObj ); physicsObj.DropToFloor(); }
void CSoundLibrary::PlaySound(CBaseEntity* pEntity, const tstring& pszFilename, float flVolume, bool bLoop) { if (Get()->m_aiActiveSounds.find(pEntity) != Get()->m_aiActiveSounds.end()) { if (Get()->m_aiActiveSounds[pEntity].find(pszFilename) != Get()->m_aiActiveSounds[pEntity].end()) StopSound(pEntity, pszFilename); } size_t iSound = Get()->FindSound(pszFilename); if (iSound >= Get()->m_apSounds.size()) return; CSound* pSound = Get()->m_apSounds[iSound]; if (!pSound) return; if( pSound->m_pSound == NULL ) return; int iChannel = Mix_PlayChannel(-1, pSound->m_pSound, bLoop?-1:0); if (iChannel < 0) return; Get()->m_aiActiveSounds[pEntity][pszFilename].iChannel = iChannel; Get()->m_aiActiveSounds[pEntity][pszFilename].flVolume = flVolume; Mix_Volume(Get()->m_aiActiveSounds[pEntity][pszFilename].iChannel, (int)(flVolume*s_flMasterVolume*MIX_MAX_VOLUME)); }
//-------------------------------- // hhProxDoor::Lock //-------------------------------- void hhProxDoor::Lock( int f ) { doorLocked = f > 0 ? true : false; //HUMANHEAD PCF mdl 04/27/06 - Changed PROXSTATE_Inactive to PROXSTATE_GoingInactive SetDoorState( doorLocked ? PROXSTATE_GoingInactive : PROXSTATE_Active ); SetShaderParm( SHADERPARM_MODE, GetDoorShaderParm( doorLocked, false ) ); // 2=locked, 1=unlocked, 0=never locked StopSound( SND_CHANNEL_ANY ); }
LTBOOL CSteamFX::Update() { if (m_bWantRemove) return LTFALSE; // Debugging aid... if (s_cvarTweak.GetFloat() > 0) { TweakSystem(); } // Start/stop steam sound if necessary... if (m_hServerObject) { uint32 dwUserFlags; g_pLTClient->GetObjectUserFlags(m_hServerObject, &dwUserFlags); if (!(dwUserFlags & USRFLG_VISIBLE)) { if ((m_dwLastUserFlags & USRFLG_VISIBLE)) { StopSound(); } } else // visible { if (!(m_dwLastUserFlags & USRFLG_VISIBLE)) { StartSound(); } } m_dwLastUserFlags = dwUserFlags; // Make sure the sound is in the correct place (in case we are getting // keyframed)... if (m_hSound) { LTVector vPos; g_pLTClient->GetObjectPos(m_hServerObject, &vPos); g_pLTClient->SetSoundPosition(m_hSound, &vPos); } // Update the steam velocity based on our current rotation (again // for keyframing)... LTRotation rRot; g_pLTClient->GetObjectRotation(m_hServerObject, &rRot); LTVector vU, vR, vF; g_pLTClient->GetRotationVectors(&rRot, &vU, &vR, &vF); m_Steam.SetDriftVel(vF * (m_cs.fVel * 0.75f), vF * m_cs.fVel); } return m_Steam.Update(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CAmbientGenericFMOD::UpdateOnRemove( void ) { //We've been removed. Stop all FMOD handled audio. StopSound( false ); BaseClass::UpdateOnRemove(); }
//----------------------------------------------------------------------------- // Purpose: Start playing personality VO list //----------------------------------------------------------------------------- void CPropGladosCore::TalkingThink( void ) { if ( m_speechEvents.Count() <= 0 || !m_speechEvents.IsValidIndex( m_iSpeechIter ) ) { SetThink ( NULL ); SetNextThink( gpGlobals->curtime ); return; } // Loop the 'look around' animation after the first line. int iCurSequence = GetSequence(); int iLookSequence = LookupSequence( STRING(m_iszLookAnimationName) ); if ( iCurSequence != iLookSequence && m_iSpeechIter > 0 ) { ResetSequence( iLookSequence ); } int iPrevIter = m_iSpeechIter-1; if ( iPrevIter < 0 ) iPrevIter = 0; StopSound( m_speechEvents[iPrevIter].ToCStr() ); float flCurDuration = GetSoundDuration( m_speechEvents[m_iSpeechIter].ToCStr(), GLADOS_CORE_MODEL_NAME ); EmitSound( m_speechEvents[m_iSpeechIter].ToCStr() ); SetNextThink( gpGlobals->curtime + m_flBetweenVOPadding + flCurDuration ); // wrap if we hit the end of the list m_iSpeechIter = (m_iSpeechIter+1)%m_speechEvents.Count(); }
void CDialogActorContext::ResetState() { // stop sound just in case to prevent forgetting to unrgister ourself as sound listener(can lead to a crash due dangling ptr) StopSound(); m_pCurLine = 0; m_pAGState = 0; m_queryID = 0; m_bAnimStarted = false; m_bAnimUseAGSignal = false; m_bAnimUseEP = false; m_lookAtActorID = CDialogScript::NO_ACTOR_ID; m_stickyLookAtActorID = CDialogScript::NO_ACTOR_ID; m_bLookAtNeedsReset = false; m_goalPipeID = 0; m_exPosAnimPipeID = 0; m_phase = eDAC_Idle; m_bInCancel = false; m_bAbortFromAI = false; m_abortReason = CDialogSession::eAR_None; m_bIsAware = true; m_bIsAwareLooking = true; m_bIsAwareInRange = true; m_bSoundStopsAnim = false; m_checkPlayerTimeOut = 0.0f; // start to check player on start m_playerAwareTimeOut = m_pSession->GetPlayerAwarenessGraceTime(); // set timeout m_currentEffectorChannelID = INVALID_FACIAL_CHANNEL_ID; m_bNeedsCancel = false; // no cancel on start m_bSoundStarted = false; }
void C_ASW_Buzzer::UpdateFireEmitters() { bool bOnFire = (m_bOnFire && !IsEffectActive(EF_NODRAW)); if (bOnFire != m_bClientOnFire) { m_bClientOnFire = bOnFire; if (m_bClientOnFire) { if ( !m_pBurningEffect ) { m_pBurningEffect = UTIL_ASW_CreateFireEffect( this ); } EmitSound( "ASWFire.BurningFlesh" ); } else { if ( m_pBurningEffect ) { ParticleProp()->StopEmission( m_pBurningEffect ); m_pBurningEffect = NULL; } StopSound("ASWFire.BurningFlesh"); if ( C_BaseEntity::IsAbsQueriesValid() ) EmitSound("ASWFire.StopBurning"); } } }
void SoundPlayer::UpdateInfantryWalking(bool value) { if (value) PlaySound(SoundSourceInfantryWalking, SoundBufferInfantryMarching, true); else StopSound(SoundSourceInfantryWalking); }