HLTSOUND CClientSoundMgr::PlaySoundLocal(const char *pName, SoundPriority ePriority, uint32 dwFlags, uint8 nVolume, float fPitchShift, uint8 nSoundClass ) { if (!pName) return LTNULL; if (!GetConsoleInt("SoundEnable",1)) return LTNULL; PlaySoundInfo psi; PLAYSOUNDINFO_INIT(psi); // See if the passed in name is really a sound bute... int nSoundBute = g_pSoundButeMgr->GetSoundSetFromName( pName ); if( nSoundBute != INVALID_SOUND_BUTE ) { // Ok, it's a soundBute, Get it... SoundBute sb = g_pSoundButeMgr->GetSoundBute( nSoundBute ); // Check for the play chance if( sb.m_fPlayChance < 1.0f ) { if( GetRandom(0.0f,1.0f) > sb.m_fPlayChance ) return LTNULL; } // Get a random sound file from the SoundButes' play list... strncpy( psi.m_szSoundName, g_pSoundButeMgr->GetRandomSoundFileWeighted( nSoundBute ), _MAX_PATH ); // Should we use passed in values or SoundBute values... psi.m_nPriority = (ePriority == SOUNDPRIORITY_MISC_LOW ? SOUNDPRIORITY_MISC_LOW : sb.m_ePriority); psi.m_nVolume = (nVolume == SMGR_DEFAULT_VOLUME ? SMGR_DEFAULT_VOLUME : sb.m_nVolume); psi.m_fPitchShift = (fPitchShift >= 1.0f ? 1.0f : sb.m_fPitch); dwFlags = sb.m_nFlags; } else { // Just a normal sound file, play it with the passed in values... strncpy(psi.m_szSoundName, pName, _MAX_PATH); psi.m_nPriority = ePriority; psi.m_nVolume = nVolume; psi.m_fPitchShift = fPitchShift; psi.m_nSoundVolumeClass = nSoundClass; } psi.m_dwFlags = PLAYSOUND_LOCAL; psi.m_dwFlags |= dwFlags; // Make sure local sounds aren't 3d... psi.m_dwFlags &= ~PLAYSOUND_3D; if (nVolume < 100) { psi.m_dwFlags |= PLAYSOUND_CTRL_VOL; } return PlaySound(psi); }
HLTSOUND CClientSoundMgr::PlayInterfaceSound(char *pName, uint32 dwFlags) { if (!pName) return LTNULL; if (!GetConsoleInt("SoundEnable",1)) return LTNULL; PlaySoundInfo psi; PLAYSOUNDINFO_INIT(psi); psi.m_dwFlags = PLAYSOUND_LOCAL; psi.m_dwFlags |= dwFlags; strncpy(psi.m_szSoundName, pName, _MAX_PATH); psi.m_nPriority = SOUNDPRIORITY_MISC_MEDIUM; // Play interface sounds unfiltered... if (!g_pUnfilteredFilter) { g_pUnfilteredFilter = g_pSoundFilterMgr->GetFilter("UnFiltered"); } psi.m_UserData = g_pUnfilteredFilter->nId; return PlaySound(psi); }
HLTSOUND CGameSoundMgr::PlaySoundFromPos(LTVector & vPos, char const* pName, LTFLOAT fORadius, SoundPriority ePriority, uint32 dwFlags, uint8 nVolume, float fPitchShift, LTFLOAT fIRadius, uint8 nSoundClass ) { if (!pName) return LTNULL; PlaySoundInfo psi; PLAYSOUNDINFO_INIT(psi); LTFLOAT fInnerRadius = fIRadius; if( fORadius > 0.0f && fInnerRadius < 0.0f ) { // If a valid outter radius and invalid inner radius were given // set the inner radius to a percentage of the outter... fInnerRadius = fORadius * m_fInnerRadiusPercent; } // See if the passed in name is really a sound bute... if( !FillPSIFromButeOrParams( pName, psi, fORadius, ePriority, dwFlags, nVolume, fPitchShift, fInnerRadius )) return NULL; if (nVolume < 100) { psi.m_dwFlags |= PLAYSOUND_CTRL_VOL; } psi.m_dwFlags |= dwFlags; psi.m_vPosition = vPos; psi.m_nSoundVolumeClass = nSoundClass; return PlaySound(psi); }
// Plays a sound HSOUNDDE CMainMenus::PlaySound(char *lpszSound, DBOOL bStream, DBOOL bLoop, DBOOL bGetHandle) { PlaySoundInfo playSoundInfo; PLAYSOUNDINFO_INIT(playSoundInfo); playSoundInfo.m_dwFlags = PLAYSOUND_LOCAL; if (bStream) { playSoundInfo.m_dwFlags |= PLAYSOUND_FILESTREAM; } if (bLoop) { playSoundInfo.m_dwFlags |= PLAYSOUND_LOOP; } if (bGetHandle) { playSoundInfo.m_dwFlags |= PLAYSOUND_GETHANDLE; } _mbsncpy((unsigned char*)playSoundInfo.m_szSoundName, (const unsigned char*)lpszSound, sizeof( playSoundInfo.m_szSoundName ) - 1 ); playSoundInfo.m_nPriority = SOUNDPRIORITY_MISC_MEDIUM; // Play the sound if( m_pClientDE->PlaySound (&playSoundInfo) != LT_OK ) return NULL; return playSoundInfo.m_hSound; }
HLTSOUND CGameSoundMgr::PlaySoundFromPos(LTVector & vPos, char *pName, LTFLOAT fRadius, SoundPriority ePriority, uint32 dwFlags, uint8 nVolume, float fPitchShift) { if (!pName) return LTNULL; PlaySoundInfo psi; PLAYSOUNDINFO_INIT(psi); psi.m_dwFlags = PLAYSOUND_3D | PLAYSOUND_REVERB; psi.m_dwFlags |= dwFlags; if (nVolume < 100) { psi.m_dwFlags |= PLAYSOUND_CTRL_VOL; } strncpy(psi.m_szSoundName, pName, _MAX_PATH); psi.m_nPriority = ePriority; psi.m_fOuterRadius = fRadius; psi.m_fInnerRadius = fRadius * m_fInnerRadiusPercent; psi.m_nVolume = nVolume; psi.m_vPosition = vPos; psi.m_fPitchShift = fPitchShift; return PlaySound(psi); }
void CNewStatusBar::UpdateObjectives(char *title, char *string) { if(!m_pClientDE || !m_hObjectives) return; // If we send in a null title or string, reset the objectives if(!title || !string) { InitObjectivesTab(); m_nObjIcon = OBJICON_INVISIBLE; return; } // If we're not in the right game type for objectives, just return if (g_pBloodClientShell->GetGameType() != GAMETYPE_SINGLE && g_pBloodClientShell->GetGameType() != GAMETYPE_CUSTOM) { return; } // Reset the background picture of the objectives DDWORD width, height; m_pClientDE->DrawBitmapToSurface(m_hObjectives, "interface/objectives/objectives.pcx", DNULL, 0, 0); m_pClientDE->GetSurfaceDims(m_hObjectives, &width, &height); // Setup the font and print it out on the surface m_pStatCursor->SetFont(m_pObjectivesFont1); m_pStatCursor->SetDest(m_hObjectives); m_pStatCursor->SetJustify(CF_JUSTIFY_CENTER); m_pStatCursor->SetLoc(OBJTAB_TITLE_CENTER, OBJTAB_TITLE_TOP); m_pStatCursor->Draw(title); m_pStatCursor->SetJustify(CF_JUSTIFY_LEFT); m_pStatCursor->SetLoc(OBJTAB_TEXT_LEFT, OBJTAB_TEXT_TOP); m_pStatCursor->DrawFormat(string, OBJTAB_TEXT_WIDTH); // Turn on the updated icon if we're not currently displaying the objectives if(m_nObjLevel == OBJTAB_INVISIBLE || m_nObjLevel == OBJTAB_SCALE_DOWN) m_nObjIcon = OBJICON_VISIBLE; else m_nObjIcon = OBJICON_INVISIBLE; // Play a sound to let the player know that the objectives have changed PlaySoundInfo playSoundInfo; PLAYSOUNDINFO_INIT(playSoundInfo); playSoundInfo.m_dwFlags = PLAYSOUND_LOCAL; playSoundInfo.m_dwFlags |= PLAYSOUND_FILESTREAM; playSoundInfo.m_nPriority = SOUNDPRIORITY_MISC_MEDIUM; _mbsncpy((unsigned char*)playSoundInfo.m_szSoundName, (const unsigned char*)"Sounds\\Events\\bellding1.wav", sizeof(playSoundInfo.m_szSoundName) - 1); m_pClientDE->PlaySound(&playSoundInfo); }
HLTSOUND CGameSoundMgr::PlaySoundFromObject(HOBJECT hObject, char const* pName, LTFLOAT fORadius, SoundPriority ePriority, uint32 dwFlags, uint8 nVolume, float fPitchShift, LTFLOAT fIRadius, uint8 nSoundClass ) { if (!pName || !hObject) return LTNULL; PlaySoundInfo psi; PLAYSOUNDINFO_INIT(psi); LTFLOAT fInnerRadius = fIRadius; if( fORadius > 0.0f && fInnerRadius < 0.0f ) { // If a valid outter radius and invalid inner radius were given // set the inner radius to a percentage of the outter... fInnerRadius = fORadius * m_fInnerRadiusPercent; } // See if the passed in name is really a sound bute... if( !FillPSIFromButeOrParams( pName, psi, fORadius, ePriority, dwFlags, nVolume, fPitchShift, fInnerRadius )) return NULL; // Incorporate the flags passed in. psi.m_dwFlags |= dwFlags; // If they asked for a clientlocal then turn into a local and remove clientlocal. if (psi.m_dwFlags & PLAYSOUND_CLIENTLOCAL) { psi.m_dwFlags &= ~( PLAYSOUND_3D ); } // Note : CLIENTLOCAL sounds don't work correctly if marked as "attached" else { psi.m_dwFlags |= PLAYSOUND_ATTACHED; } if (psi.m_nVolume < 100) { psi.m_dwFlags |= PLAYSOUND_CTRL_VOL; } psi.m_hObject = hObject; psi.m_vPosition = GetObjectPos(hObject); psi.m_nSoundVolumeClass = nSoundClass; return PlaySound(psi); }
void Gabriel::PlayShieldSound() { CServerDE* pServerDE = GetServerDE(); if (!pServerDE || m_hShieldSound) return; PlaySoundInfo playSoundInfo; PLAYSOUNDINFO_INIT(playSoundInfo); playSoundInfo.m_dwFlags = PLAYSOUND_3D | PLAYSOUND_REVERB | PLAYSOUND_ATTACHED | PLAYSOUND_LOOP | PLAYSOUND_GETHANDLE; strncpy(playSoundInfo.m_szSoundName, "Sounds\\MajorCharacter\\Gabriel\\Shield.wav", _MAX_PATH); playSoundInfo.m_hObject = m_hObject; playSoundInfo.m_fOuterRadius = 2000.0f; playSoundInfo.m_fInnerRadius = m_fSoundRadius * 0.5f; pServerDE->PlaySound(&playSoundInfo); m_hShieldSound = playSoundInfo.m_hSound; }
DBOOL DeathShroud::InitialUpdate(DVector *pMovement) { m_pServerDE = BaseClass::GetServerDE(); if (!m_pServerDE) return DFALSE; if(m_bLoadAnims) { m_Anim_Sound.SetAnimationIndexes(m_hObject); m_Anim_Sound.GenerateHitSpheres(m_hObject); m_Anim_Sound.SetSoundRoot("sounds\\enemies\\DeathShroud"); m_bLoadAnims = DFALSE; } m_InventoryMgr.AddDamageMultiplier(0.5f); AI_Mgr::InitStatics(&m_Anim_Sound); //play ambient looping sound PlaySoundInfo playSoundInfo; PLAYSOUNDINFO_INIT( playSoundInfo ); playSoundInfo.m_dwFlags = PLAYSOUND_3D | PLAYSOUND_ATTACHED | PLAYSOUND_GETHANDLE | PLAYSOUND_REVERB; playSoundInfo.m_dwFlags |= PLAYSOUND_LOOP | PLAYSOUND_CTRL_VOL; _mbsncpy((unsigned char*)playSoundInfo.m_szSoundName, (const unsigned char*)"sounds\\enemies\\deathshroud\\de_loop_2.wav", _MAX_PATH ); playSoundInfo.m_hObject = m_hObject; playSoundInfo.m_nPriority = SOUNDPRIORITY_AI_MEDIUM; playSoundInfo.m_fOuterRadius = 1000; playSoundInfo.m_fInnerRadius = 1000 * 0.1f; playSoundInfo.m_nVolume = 50; g_pServerDE->PlaySound( &playSoundInfo ); m_hLoopSound = playSoundInfo.m_hSound; //fade the deathshroud DVector vColor; DFLOAT fAlpha = 0.0f; m_pServerDE->GetObjectColor(m_hObject,&vColor.x, &vColor.y, &vColor.z, &fAlpha); fAlpha = 0.90f; m_pServerDE->SetObjectColor(m_hObject,vColor.x,vColor.y,vColor.z, fAlpha); return DTRUE; }
void Rotating::StartSound(HSTRING hstrSoundName, DBOOL bLoop) { CServerDE* pServerDE = BaseClass::GetServerDE(); if (!pServerDE) return; // Stop the last sound if there is one... if (m_sndLastSound) { pServerDE->KillSound(m_sndLastSound); m_sndLastSound = DNULL; } if (!hstrSoundName) return; char *pSoundName = pServerDE->GetStringData(hstrSoundName); if (!pSoundName) return; PlaySoundInfo playSoundInfo; PLAYSOUNDINFO_INIT(playSoundInfo); playSoundInfo.m_dwFlags = PLAYSOUND_3D | PLAYSOUND_REVERB; playSoundInfo.m_dwFlags |= PLAYSOUND_ATTACHED; if (bLoop) { playSoundInfo.m_dwFlags |= PLAYSOUND_LOOP | PLAYSOUND_GETHANDLE; } _mbsncpy((unsigned char*)playSoundInfo.m_szSoundName, (const unsigned char*)pSoundName, _MAX_PATH); playSoundInfo.m_hObject = m_hObject; playSoundInfo.m_fOuterRadius = m_fSoundRadius; playSoundInfo.m_fInnerRadius = 200; pServerDE->PlaySound(&playSoundInfo); // Save the handle of the sound... m_sndLastSound = playSoundInfo.m_hSound; }
HLTSOUND CGameSoundMgr::PlaySoundFromObject(HOBJECT hObject, char *pName, LTFLOAT fRadius, SoundPriority ePriority, uint32 dwFlags, uint8 nVolume, float fPitchShift) { if (!pName || !hObject) return LTNULL; PlaySoundInfo psi; PLAYSOUNDINFO_INIT(psi); psi.m_dwFlags = PLAYSOUND_3D | PLAYSOUND_REVERB; psi.m_dwFlags |= dwFlags; if (psi.m_dwFlags & PLAYSOUND_CLIENTLOCAL) { psi.m_dwFlags &= ~PLAYSOUND_3D; } // Note : CLIENTLOCAL sounds don't work correctly if marked as "attached" else { psi.m_dwFlags |= PLAYSOUND_ATTACHED; } if (nVolume < 100) { psi.m_dwFlags |= PLAYSOUND_CTRL_VOL; } strncpy(psi.m_szSoundName, pName, _MAX_PATH); psi.m_nPriority = ePriority; psi.m_fOuterRadius = fRadius; psi.m_fInnerRadius = fRadius * m_fInnerRadiusPercent; psi.m_nVolume = nVolume; psi.m_hObject = hObject; psi.m_fPitchShift = fPitchShift; psi.m_vPosition = GetObjectPos(hObject); return PlaySound(psi); }
HLTSOUND CClientSoundMgr::PlaySoundLocal(char *pName, SoundPriority ePriority, uint32 dwFlags, uint8 nVolume, float fPitchShift) { if (!pName) return LTNULL; if (!GetConsoleInt("SoundEnable",1)) return LTNULL; PlaySoundInfo psi; PLAYSOUNDINFO_INIT(psi); psi.m_dwFlags = PLAYSOUND_LOCAL; psi.m_dwFlags |= dwFlags; if (nVolume < 100) { psi.m_dwFlags |= PLAYSOUND_CTRL_VOL; } strncpy(psi.m_szSoundName, pName, _MAX_PATH); psi.m_nPriority = ePriority; psi.m_nVolume = nVolume; psi.m_fPitchShift = fPitchShift; return PlaySound(psi); }
void CNewStatusBar::ToggleObjectives() { PlaySoundInfo playSoundInfo; PLAYSOUNDINFO_INIT(playSoundInfo); playSoundInfo.m_dwFlags = PLAYSOUND_LOCAL; playSoundInfo.m_dwFlags |= PLAYSOUND_FILESTREAM; playSoundInfo.m_nPriority = SOUNDPRIORITY_MISC_MEDIUM; _mbsncpy((unsigned char*)playSoundInfo.m_szSoundName, (const unsigned char*)"Sounds\\Interface\\MainMenus\\missionobj.wav", sizeof(playSoundInfo.m_szSoundName) - 1); if(m_nObjLevel == OBJTAB_INVISIBLE) { m_nObjLevel = OBJTAB_SCALE_UP; m_fObjUpdateTime = m_pClientDE->GetTime(); m_nObjIcon = OBJICON_INVISIBLE; m_pClientDE->PlaySound (&playSoundInfo); } else if(m_nObjLevel == OBJTAB_STOPPED) { m_nObjLevel = OBJTAB_SCALE_DOWN; m_fObjUpdateTime = m_pClientDE->GetTime(); m_pClientDE->PlaySound (&playSoundInfo); } }
static DDWORD as_MessageFn(LPBASECLASS pObject, DDWORD messageID, void *pData, float lData) { ObjectCreateStruct *pStruct; Sound *pSound; GenericProp genProp; if(messageID == MID_PRECREATE) { pStruct = (ObjectCreateStruct*)pData; pSound = (Sound*)pObject; pStruct->m_ObjectType = OT_NORMAL; if( lData == 0.0f ) { pSound->m_fOuterRadius = 100.0f; pSound->m_fInnerRadius = 10.0f; pSound->m_nVolume = 100; pSound->m_nPriority = 0; pSound->m_bAmbient = DTRUE; pSound->m_bFileStream = DFALSE; } else { if( g_pServerDE->GetPropGeneric( "Filename", &genProp ) == DE_OK ) { SAFE_STRCPY(pSound->m_Filename, genProp.m_String); } else pSound->m_Filename[0] = '\0'; if( g_pServerDE->GetPropGeneric("OuterRadius", &genProp ) == DE_OK ) pSound->m_fOuterRadius = genProp.m_Float; else pSound->m_fOuterRadius = 100.0f; if( g_pServerDE->GetPropGeneric("InnerRadius", &genProp ) == DE_OK ) pSound->m_fInnerRadius = genProp.m_Float; else pSound->m_fInnerRadius = 10.0f; if( g_pServerDE->GetPropGeneric("Volume", &genProp) == DE_OK ) pSound->m_nVolume = (DBYTE)genProp.m_Long; else pSound->m_nVolume = 100; if( g_pServerDE->GetPropGeneric("Priority", &genProp) == DE_OK ) pSound->m_nPriority = (unsigned char)genProp.m_Long; else pSound->m_nPriority = 0; if( g_pServerDE->GetPropGeneric("Ambient", &genProp) == DE_OK ) pSound->m_bAmbient = genProp.m_Bool; else pSound->m_bAmbient = DTRUE; if( g_pServerDE->GetPropGeneric("FileStream", &genProp) == DE_OK ) pSound->m_bFileStream = genProp.m_Bool; else pSound->m_bFileStream = DTRUE; } } else if(messageID == MID_INITIALUPDATE) { PlaySoundInfo playSoundInfo; PLAYSOUNDINFO_INIT( playSoundInfo ); playSoundInfo.m_dwFlags = PLAYSOUND_LOOP; SAFE_STRCPY(playSoundInfo.m_szSoundName, (( Sound * )pObject )->m_Filename); playSoundInfo.m_nPriority = (( Sound * )pObject )->m_nPriority; playSoundInfo.m_fOuterRadius = (( Sound * )pObject )->m_fOuterRadius; playSoundInfo.m_fInnerRadius = (( Sound * )pObject )->m_fInnerRadius; if( (( Sound * )pObject )->m_nVolume < 100 ) { playSoundInfo.m_nVolume = (( Sound * )pObject )->m_nVolume; playSoundInfo.m_dwFlags |= PLAYSOUND_CTRL_VOL; } g_pServerDE->GetObjectPos( pObject->m_hObject, &playSoundInfo.m_vPosition ); if( (( Sound * )pObject )->m_bAmbient ) { playSoundInfo.m_dwFlags |= PLAYSOUND_AMBIENT; } else { playSoundInfo.m_dwFlags |= PLAYSOUND_3D; } if((( Sound * )pObject )->m_bFileStream ) { playSoundInfo.m_dwFlags |= PLAYSOUND_FILESTREAM | PLAYSOUND_TIMESYNC; } g_pServerDE->PlaySound( &playSoundInfo ); // sounds just remove themselves right away. Since they don't do // anything right now, they just take up memory. g_pServerDE->RemoveObject(pObject->m_hObject); } // Pass the message down to the base class. return bc_EngineMessageFn(pObject, messageID, pData, lData); }
void SoundFX::PlaySound() { // Kill the current sound if (m_hsndSound) { g_pLTServer->KillSound(m_hsndSound); m_hsndSound = LTNULL; } char *pSoundFile = g_pLTServer->GetStringData(m_hstrSound); // Play the sound... if (pSoundFile) { PlaySoundInfo playSoundInfo; PLAYSOUNDINFO_INIT(playSoundInfo); playSoundInfo.m_dwFlags = PLAYSOUND_GETHANDLE | PLAYSOUND_TIME; if (m_bLooping) { playSoundInfo.m_dwFlags |= PLAYSOUND_LOOP; } if (m_bAttached) { playSoundInfo.m_dwFlags |= PLAYSOUND_ATTACHED; playSoundInfo.m_hObject = m_hObject; } SAFE_STRCPY(playSoundInfo.m_szSoundName, pSoundFile); playSoundInfo.m_nPriority = m_nPriority; playSoundInfo.m_fOuterRadius = m_fOuterRadius; playSoundInfo.m_fInnerRadius = m_fInnerRadius; if (m_nVolume < 100) { playSoundInfo.m_nVolume = m_nVolume; playSoundInfo.m_dwFlags |= PLAYSOUND_CTRL_VOL; } if (m_fPitchShift != 1.0f) { playSoundInfo.m_dwFlags |= PLAYSOUND_CTRL_PITCH; playSoundInfo.m_fPitchShift = m_fPitchShift; } g_pLTServer->GetObjectPos(m_hObject, &playSoundInfo.m_vPosition); if (m_bAmbient) { playSoundInfo.m_dwFlags |= PLAYSOUND_AMBIENT; } else { playSoundInfo.m_dwFlags |= PLAYSOUND_3D; } playSoundInfo.m_UserData = m_nFilterId; m_hsndSound = g_pServerSoundMgr->PlaySoundDirect(playSoundInfo); if (!m_bLooping && m_hsndSound) { LTFLOAT fDuration; g_pLTServer->GetSoundDuration(m_hsndSound, &fDuration); SetNextUpdate(m_hObject, fDuration); } } }