void CMusicMgr::DoEvent(Event eEvent) { if ( !m_bEnabled ) return; if ( m_bLockedEvent ) return; if ( m_acEvents[eEvent] != 0 && (m_afEventChances[eEvent] > GetRandom(0.0, 1.0f)) ) { char szMusic[128]; uint32 iEvent = GetRandom(0, m_acEvents[eEvent]-1); sprintf(szMusic, "MUSIC PM %s %s Beat", m_szTheme, m_aaszEvents[eEvent][iEvent]); #ifndef _FINAL if ( g_ShowMusicTrack.GetFloat() > 0 ) { g_pLTServer->CPrint("Server sending client Music Message: (%s)", szMusic); } #endif HSTRING hMusic = g_pLTServer->CreateString(szMusic); CAutoMessage cMsg; cMsg.Writeuint8(MID_MUSIC); cMsg.WriteHString(hMusic); g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED); FREE_HSTRING(hMusic); } }
void CMusicMgr::Update() { if ( !m_bEnabled ) return; if ( m_bLockedMood ) { if ( m_bRestoreMusicIntensity ) { char szMusic[128]; sprintf(szMusic, "MUSIC I %d measure", m_iRestoreMusicIntensity); #ifndef _FINAL if ( g_ShowMusicTrack.GetFloat() > 0 ) { g_pLTServer->CPrint("Server sending client Music Message: (%s)", szMusic); } #endif HSTRING hMusic = g_pLTServer->CreateString(szMusic); CAutoMessage cMsg; cMsg.Writeuint8(MID_MUSIC); cMsg.WriteHString(hMusic); g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED); FREE_HSTRING(hMusic); m_eLastMood = eMoodInvalid; m_bRestoreMusicIntensity = LTFALSE; } return; } LTBOOL bChoseMood = LTFALSE; for ( int32 iMood = kNumMoods-1 ; iMood >= 0 ; --iMood ) { if ( !bChoseMood && (m_afMoods[iMood] != 0.0f || (iMood == eMoodNone)) ) { if ( m_eLastMood == iMood ) { bChoseMood = LTTRUE; } else { SetMood(( Mood )iMood ); bChoseMood = LTTRUE; } } m_afMoods[iMood] = Max<LTFLOAT>(m_afMoods[iMood] - g_pLTServer->GetFrameTime(), 0.0f); } }
bool CMusicMgr::SetMood( Mood eMood ) { char szMusic[128]; uint32 iLevel = GetRandom(0, m_acMoods[eMood]-1); sprintf(szMusic, "MUSIC I %d measure", m_aanMoods[eMood][iLevel]); #ifndef _FINAL if ( g_ShowMusicTrack.GetFloat() > 0 ) { g_pLTServer->CPrint("Server sending client Music Message: (%s)", szMusic); } #endif HSTRING hMusic = g_pLTServer->CreateString(szMusic); CAutoMessage cMsg; cMsg.Writeuint8(MID_MUSIC); cMsg.WriteHString(hMusic); g_pLTServer->SendToClient(cMsg.Read(), LTNULL, MESSAGE_GUARANTEED); FREE_HSTRING(hMusic); m_eLastMood = eMood; return true; }