diff --git a/scripting/FartsysAss.sp b/scripting/FartsysAss.sp index c533611..fe559fe 100644 --- a/scripting/FartsysAss.sp +++ b/scripting/FartsysAss.sp @@ -47,7 +47,7 @@ public void OnFastFire2Ready(){ cvarSNDDefault = CreateConVar("sm_fartsysass_sound", "3", "Default sound for new users, 3 = Everything, 2 = Sounds Only, 1 = Music Only, 0 = Nothing"); AssLogger(LOGLVL_INFO, "####### STARTUP COMPLETE (v%s) #######", PLUGIN_VERSION); CreateTimer(15.0, StatsTracker); - AudioManager.Reset(); + GlobalAudio.Reset(); WeatherManager.Reset(); CreateTimer(1.0, SelectAdminTimer); sudo(1002); @@ -56,7 +56,7 @@ public void OnFastFire2Ready(){ //Process ticks and requests in real time public void OnGameFrame() { if(WeatherManager.TornadoWarning) WeatherManager.TickSiren(); - if (AudioManager.shouldTick) AudioManager.TickBGM(); + if (GlobalAudio.shouldTick) GlobalAudio.Tick(); if (BossHandler.shouldTick) BossHandler.Tick(); if (BossHandler.tickBusterNuclear) BossHandler.TickBusterNuclear(); if (core.gamemode == 2 && core.isWave) TickBodyCheck(); diff --git a/scripting/include/fartsy/ass_bosshandler.inc b/scripting/include/fartsy/ass_bosshandler.inc index 2944e4c..a0644b5 100644 --- a/scripting/include/fartsy/ass_bosshandler.inc +++ b/scripting/include/fartsy/ass_bosshandler.inc @@ -32,8 +32,8 @@ enum struct BOSSHANDLER { //Metallizer (wip) To Do: Only change to Inferno if we're in boss attack range. Use a trigger_multiple for this. To Do, delay this by like 1 second so the DJMM sound can play properly. case 2:{ sudo(1001); - AudioManager.Stop(); - AudioManager.indexBGM = 20; + GlobalAudio.Stop(); + GlobalAudio.setBGM(20, true); CustomSoundEmitter(SFXArray[106].realPath, 65, false, 0, 1.0, 100); //DJMM SFX CreateTimer(1.5, DelayedMetalFace); } @@ -123,7 +123,7 @@ enum struct BOSSHANDLER { } case 2:{ //PrintToChatAll("Recognized 1 -> 2, things are heating up!"); - AudioManager.ChangeBGM(22, false); + GlobalAudio.setBGM(22, false); FastFire2("FB.MetalFace.Train", "TeleportToPathTrack", "MFT1x0", 3.00, false); FastFire2("FB.MetalFace.SkeleSpawner", "Enable", "", 0.0, false); FastFire2("FB.MetalFace.SkeleSpawner", "Disable", "", 120.0, false); @@ -137,7 +137,7 @@ enum struct BOSSHANDLER { } case 3:{ //PrintToChatAll("Recognized 2 -> 3, oh boi"); - AudioManager.ChangeBGM(24, false); + GlobalAudio.setBGM(24, false); FastFire2("FB.MetalFace.Train", "TeleportToPathTrack", "MFT2x0", 3.00, false); FastFire2("FB.MetalFace.MerasmusSpawner", "ForceSpawn", "", 5.0, false); //Spawn halloween bosses at MetalFace's location FastFire2("FB.MetalFace.MonoculusSpawner", "ForceSpawn", "", 7.0, false); //Spawn halloween bosses at MetalFace's location @@ -149,7 +149,7 @@ enum struct BOSSHANDLER { } case 4:{ //PrintToChatAll("Recognized 3 -> 4, OHSHITOHFUCKOHNO"); - AudioManager.ChangeBGM(26, true); + GlobalAudio.setBGM(26, true); FastFire2("FB.MetalFace.Train", "TeleportToPathTrack", "MFT3x0", 3.00, false); FastFire2("FB.MetalFace.GigaBuster", "ForceSpawn", "", 10.0, false); } @@ -218,7 +218,7 @@ enum struct BOSSHANDLER { CSEClient(i, BGMArray[iBGM0].realPath, BGMArray[iBGM0].SNDLVL, true, 1, 1.0, 100); } } - AudioManager.indexBGM = iBGM0; + GlobalAudio.setBGM(iBGM0, false); } } //Tank buster thing @@ -592,8 +592,7 @@ public Action ResetTickBuster(Handle time){ //Spawn metal face public Action DelayedMetalFace(Handle timer){ - AudioManager.indexBGM = 20; - AudioManager.stopBGM = true; + GlobalAudio.setBGM(20, true); CustomSoundEmitter(SFXArray[68].realPath, 65, false, 0, 1.0, 100); //Evil Laugh CreateTimer(3.2, QueueBossSound, GetRandomInt(10,14)); sudo(1000); diff --git a/scripting/include/fartsy/ass_commands.inc b/scripting/include/fartsy/ass_commands.inc index 4be43cd..b205405 100644 --- a/scripting/include/fartsy/ass_commands.inc +++ b/scripting/include/fartsy/ass_commands.inc @@ -111,11 +111,11 @@ public int MenuHandlerFartsysAss(Menu menu, MenuAction action, int client, int i public Action Command_GetCurrentSong(int client, int args) { char buffer[16]; char tbuffer[16]; - int sPos = RoundToFloor(AudioManager.engineSecondsAdjusted() - AudioManager.timeSeconds); - int tPos = RoundToFloor(AudioManager.loopSeconds); + int sPos = RoundToFloor(AudioManager[client].engineSecondsAdjusted() - AudioManager[client].timeSeconds); + int tPos = RoundToFloor(AudioManager[client].loopSeconds); Format(buffer, 16, "%02d:%02d", sPos / 60, sPos % 60); Format(tbuffer, 16, "%02d:%02d", tPos / 60, tPos % 60); - CPrintToChat(client, "The current song (%i) is: {limegreen}%s {orange}(%s / %s)", AudioManager.indexBGM, AudioManager.songName, buffer, tbuffer); + CPrintToChat(client, "The current song (%i) is: {limegreen}%s {orange}(%s / %s)", AudioManager[client].indexBGM, AudioManager[client].songName, buffer, tbuffer); return Plugin_Handled; } diff --git a/scripting/include/fartsy/ass_enhancer.inc b/scripting/include/fartsy/ass_enhancer.inc index 68ef449..9bbc8f8 100644 --- a/scripting/include/fartsy/ass_enhancer.inc +++ b/scripting/include/fartsy/ass_enhancer.inc @@ -1,4 +1,5 @@ -//Fartsy's Scene Enhancer v1.0.0 (Inspired by Mrbt0907/Weather2Remastered) +//Fartsy's Scene Enhancer (Inspired by Mrbt0907/Weather2Remastered) +char FSE_VER[8] = "2.0.0"; //All background music enum struct BGM { char realPath[64]; @@ -15,6 +16,7 @@ enum struct SFXARRAY { int SNDLVL; } SFXARRAY SFXArray[127]; + //Sound preference menu char sndPrefs[][128] = { "Sounds are currently DISABLED.", @@ -25,6 +27,7 @@ char sndPrefs[][128] = { }; Handle cvarSNDDefault = INVALID_HANDLE; int soundPreference[MAXPLAYERS + 1]; + //Get client sound prefs public void SQL_SNDPrefs(Database db, DBResultSet results, const char[] error, int client) { if (!results) { @@ -34,21 +37,33 @@ public void SQL_SNDPrefs(Database db, DBResultSet results, const char[] error, i if (!IsValidClient(client)) return; if (results.FetchRow()) soundPreference[client] = results.FetchInt(0); } -//Music system rewrite for the 7th time. I will never make a change. My code will never mend. Still everything's the same and it all just fades to math. Stage 7, Luigi. I don't even know what that is but it's bad! + +//Music system rewrite for the 8th time. I will never make a change. My code will never mend. Still everything's the same and it all just fades to math. Stage 7, Luigi. I don't even know what that is but it's bad! +/**I have rewritten this stupid thing 8 times now. It now exists in its final form. + * This is the audio manager. It plays music. It plays music PER CLIENT. It is good at playing MUSIC. + * It syncs music. It tracks the EXACT MILLISECOND POSITION of the currently playing song. +*/ +int g_chanBGM; +int g_indexBGM; enum struct AUDIOMANAGER { bool bgmPlaying; + bool EventMode; bool shouldTick; bool stopBGM; bool hasTimeOffset; + bool clientIsFresh; char cachedPath[128]; char songName[128]; float timeSeconds; float loopSeconds; float introSeconds; - int chanBGM; + int Client; int indexBGM; int loops; int VIPBGM; + bool isEventMode() { + return this.EventMode; + } /** Gets the engine time, accounting for intro offset seconds **/ float engineSecondsAdjusted() { return GetEngineTime() + this.introSeconds; @@ -60,9 +75,9 @@ enum struct AUDIOMANAGER { void ChangeBGM(int bgm, bool instant) { if (instant) { //this.ticksBGM = -2; - this.timeSeconds = 0.0; + this.timeSeconds = GetEngineTime() - this.loopSeconds; } - this.indexBGM = (this.VIPBGM >= 0 ? this.VIPBGM : bgm == 0 ? GetRandomInt(1,4) : bgm); + this.indexBGM = (this.VIPBGM >= 0 ? this.VIPBGM : bgm == 0 ? g_indexBGM : bgm); this.shouldTick = true; this.hasTimeOffset = BGMArray[this.indexBGM].introSeconds > 0 ? true : false; this.stopBGM = (!StrEqual(this.cachedPath, BGMArray[this.indexBGM].realPath) ? true : false); @@ -72,44 +87,118 @@ enum struct AUDIOMANAGER { void Reset() { this.stopBGM = true; this.loops = 0; - this.indexBGM = GetRandomInt(1, 4); + this.indexBGM = 0; this.timeSeconds = 0.0; - for (int i = 0; ++i < MaxClients;) if (IsValidClient(i)) for (int s = this.indexBGM; s < sizeof(BGMArray); s++) StopSound(i, this.chanBGM, BGMArray[s].realPath); //Very quick, very dirty, very suboptimal, but gets the job done... This stops all boss music. + if (IsValidClient(this.Client)) for (int s = this.indexBGM; s < sizeof(BGMArray); s++) StopSound(this.Client, g_chanBGM, BGMArray[s].realPath); //Very quick, very dirty, very suboptimal, but gets the job done... This stops all boss music. AssLogger(LOGLVL_DEBUG, "AudioManager has been reset!"); } + void SetInEvent(bool inEvent){ + this.EventMode = inEvent; + } void Stop() { this.bgmPlaying = false; + this.indexBGM = 0; this.loops = 0; this.stopBGM = true; this.timeSeconds = 0.0; this.shouldTick = false; } void TickBGM() { + if (!IsValidClient(this.Client)) { + this.Stop(); + return; + } + if (this.indexBGM == 0) this.indexBGM = g_indexBGM; if (this.engineSecondsAdjusted() > this.timeSeconds + this.loopSeconds) { this.timeSeconds = GetEngineTime(); this.loops++; - for (int i = 0; ++i < MaxClients;) { - if (this.stopBGM) { - StopSound(i, this.chanBGM, this.cachedPath); - this.loops = 0; - } - //if(core.gamemode > 0 && isClientInEvent(i)) continue;// To test if client is experiencing anything odd..... - CSEClient(i, BGMArray[this.indexBGM].realPath, BGMArray[this.indexBGM].SNDLVL, true, 1, 1.0, 100); + if (this.stopBGM) { + StopSound(this.Client, g_chanBGM, this.cachedPath); + this.loops = 0; } this.stopBGM = false; - if (GetClientCount(true) == 0) { - AssLogger(LOGLVL_INFO, "Server is empty. Music queue stopped."); - this.indexBGM = GetRandomInt(1, 4); - this.Stop(); - } + CSEClient(this.Client, BGMArray[this.indexBGM].realPath, BGMArray[this.indexBGM].SNDLVL, true, 1, 1.0, 100); strcopy(this.songName, sizeof(this.songName), BGMArray[this.indexBGM].songName); this.introSeconds = this.loops >= 1 ? BGMArray[this.indexBGM].introSeconds : 0.0; this.loopSeconds = BGMArray[this.indexBGM].loopSeconds; - CreateTimer(1.0, SyncMusic, this.indexBGM); + CreateTimer(1.0, SyncMusic, this.Client); + } + } + /**When a client joins the server, set this audio manager to theirs */ + void OnClientConnected(int client) { + this.Client = client; + this.clientIsFresh = true; + PrintToServer("Handling new client: %N", client); + } + /**When a client respawns */ + void OnClientRespawned() { + if (this.clientIsFresh) { + PrintToServer("Client respawned, %N", this.Client); + if (soundPreference[this.Client] == 1 || soundPreference[this.Client] == 3) CPrintToChat(this.Client, "[AudioManager v%s] Welcome! We are listening to %s", FSE_VER, BGMArray[g_indexBGM].songName); + this.ChangeBGM(g_indexBGM, true); + this.clientIsFresh = false; } } } -AUDIOMANAGER AudioManager; +AUDIOMANAGER AudioManager[MAXPLAYERS+1]; + +enum struct AUDIOCONTROLLER { + bool shouldTick; + int VIPBGM; + int VIPIndex; + void init() { + AssLogger(LOGLVL_INFO, "Initializing Global Audio..."); + g_chanBGM = 6; + for (int i = 0; i < MaxClients; ++i) { + AudioManager[i].bgmPlaying = false; + AudioManager[i].stopBGM = false; + AudioManager[i].shouldTick = false; + AudioManager[i].cachedPath = "null"; + AudioManager[i].songName = "null"; + AudioManager[i].indexBGM = 0; + AudioManager[i].loopSeconds = 0.0; + if (IsValidClient(i)){ + AudioManager[i].Client = i; + for (int x = 0; x < sizeof(BGMArray); ++x) StopSound(i, g_chanBGM, BGMArray[x].realPath); + } + //this.shouldTick = true; + //this.UpdateBGM(); + } + g_indexBGM = GetRandomInt(1, 4); + this.VIPBGM = -1; + this.VIPIndex = -1; + this.UpdateBGM(); + CreateTimer(1.0, EnableAudio); + } + void Reset(){ + g_indexBGM = GetGameMode() < 2 ? GetRandomInt(1, 4) : 28; + for (int i = 0; i < MaxClients; ++i) AudioManager[i].Reset(); + } + void setBGM(int bgm, bool instant){ + g_indexBGM = bgm == 0 ? GetRandomInt(1,4) : bgm; + for (int i = 0; i < MaxClients; ++i) AudioManager[i].ChangeBGM(bgm, instant); + } + void Stop(){ + for (int i = 0; i < MaxClients; ++i) AudioManager[i].Stop(); + } + void Tick(){ + for (int i = 0; i < MaxClients; ++i) if (IsValidClient(i) && AudioManager[i].shouldTick) AudioManager[i].TickBGM(); + } + /** Sets EVERYONE'S BGM in sync! Unless they're in an event... */ + void UpdateBGM(){ + for (int i = 0; i < MaxClients; ++i) if (IsValidClient(i)) { + if (AudioManager[i].isEventMode() || !IsValidClient(i)) continue; + AudioManager[i].ChangeBGM(this.VIPBGM > 0 ? this.VIPBGM : AudioManager[i].indexBGM == 0 ? g_indexBGM : AudioManager[i].indexBGM, true); + AudioManager[i].shouldTick = true; + } + } +} +AUDIOCONTROLLER GlobalAudio; + +public Action EnableAudio(Handle timer){ + GlobalAudio.shouldTick = true; + return Plugin_Stop; +} //Custom sound emitter, I don't know how many fucking times I've rewritten this! See potato.sp //int flags: // SND_NOFLAGS= 0, /**< Nothing */ @@ -124,13 +213,13 @@ AUDIOMANAGER AudioManager; void CustomSoundEmitter(char[] sndName, int TSNDLVL, bool isBGM, int flags, float vol, int pitch) { for (int i = 1; i <= MaxClients; i++) { if (!IsValidClient(i)) continue; - if (isBGM && (soundPreference[i] == 1 || soundPreference[i] == 3) || !isBGM && soundPreference[i] >= 2) EmitSoundToClient(i, sndName, _, AudioManager.chanBGM, TSNDLVL, flags, vol, pitch, _, _, _, _, _); + if (isBGM && (soundPreference[i] == 1 || soundPreference[i] == 3) || !isBGM && soundPreference[i] >= 2) EmitSoundToClient(i, sndName, _, g_chanBGM, TSNDLVL, flags, vol, pitch, _, _, _, _, _); } } //Play sound to client. Ripped straight from potato. Allows us to play sounds directly to people when they join. void CSEClient(int client, char[] sndName, int TSNDLVL, bool isBGM, int flags, float vol, int pitch) { if (!IsValidClient(client)) return; - if (isBGM && (soundPreference[client] == 1 || soundPreference[client] == 3) || !isBGM && soundPreference[client] >= 2) EmitSoundToClient(client, sndName, _, AudioManager.chanBGM, TSNDLVL, flags, vol, pitch, _, _, _, _, _); + if (isBGM && (soundPreference[client] == 1 || soundPreference[client] == 3) || !isBGM && soundPreference[client] >= 2) EmitSoundToClient(client, sndName, _, g_chanBGM, TSNDLVL, flags, vol, pitch, _, _, _, _, _); } //VIP Music Menu public Action Command_Music(int client, int args) { @@ -201,7 +290,7 @@ public int MenuHandlerFartsy(Menu menu, MenuAction action, int param1, int param public Action RefireMusicForClient(Handle timer, int client) { if (IsValidClient(client)) { if (GetClientTeam(client) == 0) CreateTimer(1.0, RefireMusicForClient, client); - else if (GetClientTeam(client) == 2) CSEClient(client, BGMArray[AudioManager.indexBGM].realPath, BGMArray[AudioManager.indexBGM].SNDLVL, true, 1, 1.0, 100); + else if (GetClientTeam(client) == 2) CSEClient(client, BGMArray[AudioManager[client].indexBGM].realPath, BGMArray[AudioManager[client].indexBGM].SNDLVL, true, 1, 1.0, 100); } return Plugin_Stop; } diff --git a/scripting/include/fartsy/ass_events.inc b/scripting/include/fartsy/ass_events.inc index 3b5b0a3..5875b65 100644 --- a/scripting/include/fartsy/ass_events.inc +++ b/scripting/include/fartsy/ass_events.inc @@ -1,6 +1,8 @@ //Sync client stats when they leave public void OnClientDisconnect(int client) { //Database Ass_Database = Get_Ass_Database(); + AudioManager[client].Client = -1; + PrintToServer("[AudioManager @ %i] Client %N disconnected, shutting down gracefully!", client, client); int steamID = GetSteamAccountID(client); if (steamID) { iDmgHealingTotal -= EmnityManager[client].iDamage; @@ -19,6 +21,7 @@ public Action EventSpawn(Event Spawn_Event, const char[] Spawn_Name, bool Spawn_ int client = GetClientOfUserId(Spawn_Event.GetInt("userid")); if (IsValidClient(client)) { int class = Spawn_Event.GetInt("class"); + if (class) AudioManager[client].OnClientRespawned(); int steamID = GetSteamAccountID(client); if (!Ass_Database || !steamID || !class) return Plugin_Handled; char strClass[32]; diff --git a/scripting/include/fartsy/ass_helper.inc b/scripting/include/fartsy/ass_helper.inc index 54aee95..a749fb7 100644 --- a/scripting/include/fartsy/ass_helper.inc +++ b/scripting/include/fartsy/ass_helper.inc @@ -608,7 +608,6 @@ void SetupCoreData(){ bombState[3].shouldFreezeBots = true; bombState[0].state = 0; bombState[0].stateMax = 0; - AudioManager.bgmPlaying = false; core.bombReset = false; core.brawler_emergency = false; core.canCrusaderNuke = false; @@ -625,14 +624,9 @@ void SetupCoreData(){ core.monitorColor = true; core.sacrificedByClient = false; core.sephiroth = false; - AudioManager.stopBGM = false; core.tacobell = false; core.tickingClientHealth = false; - AudioManager.shouldTick = false; WeatherManager.TornadoWarning = false; - AudioManager.cachedPath = "null"; - AudioManager.songName = "null"; - AudioManager.indexBGM = 1; core.FailedCount = 0; core.INCOMINGDISPLAYED = 0; core.camSel = 0; @@ -640,15 +634,13 @@ void SetupCoreData(){ core.curWave = 0; core.failsafeCount = 0; core.lastAdmin = 0; - AudioManager.loopSeconds = 0.0; core.sacPoints = 0; core.sacPointsMax = 60; - AudioManager.chanBGM = 6; - AudioManager.VIPBGM = -1; core.VIPIndex = 0; core.waveFlags = 0; core.HWNMin = 210.0; core.HWNMax = 380.0; + GlobalAudio.init(); AssLogger(1, "Setting up bosses..."); HWBoss[0].index = 0; HWBoss[0].fireCount = 2; @@ -1116,9 +1108,10 @@ void RegisterAndPrecacheAllFiles(){ } //Used to keep StopSound from stopping the music we're trying to play - now with support for loop offsets! -public Action SyncMusic(Handle timer, int index) { - AudioManager.cachedPath = BGMArray[index].realPath; - AssLogger(LOGLVL_INFO, "We are on wave %i, now playing: %s (from %s) for %f seconds. It will start looping in %f seconds.", core.curWave, AudioManager.songName, BGMArray[index].realPath, AudioManager.loopSeconds, BGMArray[index].introSeconds); +public Action SyncMusic(Handle timer, int client) { + int index = AudioManager[client].indexBGM; + AudioManager[client].cachedPath = BGMArray[index].realPath; + AssLogger(LOGLVL_INFO, "[AudioManager for %N]: We are on wave %i, now playing: %s (from %s) for %f seconds. It will start looping in %f seconds.", client, core.curWave, BGMArray[index].songName, BGMArray[index].realPath, BGMArray[index].loopSeconds, BGMArray[index].introSeconds); return Plugin_Stop; } @@ -1380,10 +1373,10 @@ public int MenuHandlerFartsyMusic(Menu menu, MenuAction action, int client, int if (action == MenuAction_Select) { int cWave = GetCurWave(); CPrintToChat(client, (bgm == 0 ? "{darkgreen}[CORE] Confirmed. Next song set to {aqua}Default{darkgreen}." : "{limegreen}[CORE] Confirmed. Next song set to {aqua}%s{limegreen}."), BGMArray[bgm].songName); - AudioManager.indexBGM = (bgm == 0 ? (core.tacobell ? tacoBellBGMIndex[cWave] : core.sephiroth ? 16 : core.isWave ? DefaultsArray[cWave].defBGMIndex : GetRandomInt(1, 4)) : bgm); - AudioManager.stopBGM = (!StrEqual(AudioManager.cachedPath, BGMArray[bgm].realPath) ? true : false); - AudioManager.VIPBGM = (bgm == 0 ? -1 : bgm); - core.VIPIndex = client; + GlobalAudio.VIPBGM = (bgm == 0 ? -1 : bgm); + GlobalAudio.setBGM(bgm == 0 ? (core.tacobell ? tacoBellBGMIndex[cWave] : core.sephiroth ? 16 : core.isWave ? DefaultsArray[cWave].defBGMIndex : GetRandomInt(1, 4)) : bgm, false); + for (int i = 0; i < MaxClients; ++i) AudioManager[i].stopBGM = (!StrEqual(AudioManager[i].cachedPath, BGMArray[bgm].realPath) ? true : false); + GlobalAudio.VIPIndex = client; } else if (action == MenuAction_End) CloseHandle(menu); return 0; } @@ -1538,13 +1531,13 @@ public Action PerformWaveAdverts(Handle timer) { char tbuffer[16]; char HintText[256]; //int sPos = RoundToFloor((AudioManager.timeSeconds() / (GetEngineTime() + AudioManager.loopSeconds)) * AudioManager.loopSeconds); - int sPos = RoundToFloor(AudioManager.engineSecondsAdjusted() - AudioManager.timeSeconds); - int tPos = RoundToFloor(AudioManager.loopSeconds); - Format(buffer, 16, "%02d:%02d", sPos / 60, sPos % 60); - Format(tbuffer, 16, "%02d:%02d", tPos / 60, tPos % 60); - Format(HintText, sizeof(HintText), (bombState[0].isMoving ? "Payload: MOVING (%i/%i) | !sacpoints: %i/%i \n Music: %s (%s/%s)" : bombState[0].isReady ? "Payload: READY (%i/%i) | !sacpoints: %i/%i \n Music: %s (%s/%s)" : "Payload: PREPARING (%i/%i) | !sacpoints: %i/%i \n Music: %s (%s/%s)"), bombState[0].state, bombState[0].stateMax, core.sacPoints, core.sacPointsMax, AudioManager.songName, buffer, tbuffer); for (int i = 0; i <= MaxClients; ++i) { //might need to be i++?? if (IsValidClient(i)) { + int sPos = RoundToFloor(AudioManager[i].engineSecondsAdjusted() - AudioManager[i].timeSeconds); + int tPos = RoundToFloor(AudioManager[i].loopSeconds); + Format(buffer, 16, "%02d:%02d", sPos / 60, sPos % 60); + Format(tbuffer, 16, "%02d:%02d", tPos / 60, tPos % 60); + Format(HintText, sizeof(HintText), (bombState[0].isMoving ? "Payload: MOVING (%i/%i) | !sacpoints: %i/%i \n Music: %s (%s/%s)" : bombState[0].isReady ? "Payload: READY (%i/%i) | !sacpoints: %i/%i \n Music: %s (%s/%s)" : "Payload: PREPARING (%i/%i) | !sacpoints: %i/%i \n Music: %s (%s/%s)"), bombState[0].state, bombState[0].stateMax, core.sacPoints, core.sacPointsMax, AudioManager[i].songName, buffer, tbuffer); emnity = EmnityManager[i].getClientEmnity(); PrintHintText(i, (WeatherManager.TornadoWarning ? "%s \n\n[TORNADO WARNING]" : "%s\n\nEmnity: %i٪"), HintText, emnity >= 0 ? emnity : 0); StopSound(i, SNDCHAN_STATIC, "UI/hint.wav"); @@ -1737,7 +1730,6 @@ public Action SacrificePointsTimer(Handle timer) { } //Queue music for new clients, also track their stats. public void OnClientPostAdminCheck(int client) { - if (!IsFakeClient(client) && AudioManager.bgmPlaying) CreateTimer(1.0, RefireMusicForClient, client); int steamID = GetSteamAccountID(client); if (!steamID || steamID <= 10000) return; else { @@ -1749,7 +1741,7 @@ public void OnClientPostAdminCheck(int client) { CreateTimer(1.0, TickClientHealth); core.tickingClientHealth = true; } - if (!AudioManager.bgmPlaying) AudioManager.ChangeBGM(GetRandomInt(1, 4), true); + if(!IsFakeClient(client)) AudioManager[client].OnClientConnected(client); char query[1024]; Format(query, sizeof(query), "INSERT INTO ass_activity (name, steamid, date, damagedealtsession, killssession, deathssession, bombsresetsession, sacrificessession) VALUES ('%N', %d, CURRENT_DATE, 0, 0, 0, 0, 0) ON DUPLICATE KEY UPDATE name = '%N', date = CURRENT_DATE, damagedealtsession = 0, killssession = 0, deathssession = 0, bombsresetsession = 0, sacrificessession = 0;", client, steamID, client); Ass_Database.Query(Database_FastQuery, query); diff --git a/scripting/include/fartsy/ass_sudo.inc b/scripting/include/fartsy/ass_sudo.inc index 44fb2ee..0bf2e64 100644 --- a/scripting/include/fartsy/ass_sudo.inc +++ b/scripting/include/fartsy/ass_sudo.inc @@ -1,4 +1,4 @@ -public char PLUGIN_VERSION[8] = "8.3.0c"; +public char PLUGIN_VERSION[8] = "8.4.0"; void sudo(int task) { AssLogger(LOGLVL_DEBUG, "Calling sudo with %i", task); switch (task) { @@ -9,6 +9,7 @@ void sudo(int task) { } //Prepare yourself! case 1: { + GlobalAudio.Reset(); core.tacobell = false; ServerCommand("fb_startmoney 50000"); CPrintToChatAll("{darkviolet}[{yellow}INFO{darkviolet}] {red}PROFESSOR'S ASS {white}v0x22 (Core-v%s). Prepare yourself for the unpredictable... [{limegreen}by TTV/ProfessorFartsalot{white}]", PLUGIN_VERSION); @@ -26,7 +27,7 @@ void sudo(int task) { PerformWaveSetup(); float hwn = GetRandomFloat(core.HWNMin, core.HWNMax); CreateTimer(hwn, HWBosses); - AudioManager.ChangeBGM(core.tacobell ? tacoBellBGMIndex[core.curWave] : DefaultsArray[core.curWave].defBGMIndex, true); + GlobalAudio.setBGM(core.tacobell ? tacoBellBGMIndex[core.curWave] : DefaultsArray[core.curWave].defBGMIndex, true); PrintToChatAll("WARNING, AUDIOMANAGER'S CHANGEBGM FUNCTION IS DEPRECATED IN FAVOR OF THE NEW CONFIGS. FIX THIS IMMEDIATELY."); return; } @@ -591,7 +592,7 @@ void sudo(int task) { } //Reset Map case 300: { - AudioManager.Reset(); + GlobalAudio.Reset(); BossHandler.shouldTick = false; core.Reset(); for (int i = 0; i < sizeof(EmnityManager); i++) EmnityManager[i].Reset(); @@ -618,17 +619,17 @@ void sudo(int task) { } //TEMP FUNCTIONS case 301: { - EmitSoundToAll(BGMArray[5].realPath, _, AudioManager.chanBGM, BGMArray[5].SNDLVL, SND_CHANGEVOL, 0.05, _, _, _, _, _, _); + EmitSoundToAll(BGMArray[5].realPath, _, g_chanBGM, BGMArray[5].SNDLVL, SND_CHANGEVOL, 0.05, _, _, _, _, _, _); } //TEMP FUNCTIONS case 302: { - EmitSoundToAll(BGMArray[5].realPath, _, AudioManager.chanBGM, BGMArray[5].SNDLVL, SND_CHANGEVOL, 1.0, _, _, _, _, _, _); + EmitSoundToAll(BGMArray[5].realPath, _, g_chanBGM, BGMArray[5].SNDLVL, SND_CHANGEVOL, 1.0, _, _, _, _, _, _); } case 304: { - EmitSoundToAll(BGMArray[6].realPath, _, AudioManager.chanBGM, BGMArray[6].SNDLVL, SND_CHANGEVOL, 0.05, _, _, _, _, _, _); + EmitSoundToAll(BGMArray[6].realPath, _, g_chanBGM, BGMArray[6].SNDLVL, SND_CHANGEVOL, 0.05, _, _, _, _, _, _); } case 305: { - EmitSoundToAll(BGMArray[6].realPath, _, AudioManager.chanBGM, BGMArray[6].SNDLVL, SND_CHANGEVOL, 1.0, _, _, _, _, _, _); + EmitSoundToAll(BGMArray[6].realPath, _, g_chanBGM, BGMArray[6].SNDLVL, SND_CHANGEVOL, 1.0, _, _, _, _, _, _); } case 420:{ // Init/Reset Wave Null. CPrintToChatAll("{red} [CORE] WARNING: Initializing Wave Null... Welcome to a new kind of tension, everything isn't meant to be okay. :')"); @@ -638,19 +639,19 @@ void sudo(int task) { } case 421:{ FastFire2("weather.sky", "Skin", "2", 0.0, false); - AudioManager.ChangeBGM(28, false); + GlobalAudio.setBGM(28, false); WeatherManager.fogColorRTarget = 95.0; WeatherManager.fogColorGTarget = 35.0; WeatherManager.fogColorBTarget = 35.0; } case 422:{ - AudioManager.ChangeBGM(29, false); + GlobalAudio.setBGM(29, false); } case 423:{ - AudioManager.ChangeBGM(30, false); + GlobalAudio.setBGM(30, false); } case 424:{ - AudioManager.ChangeBGM(31, false); + GlobalAudio.setBGM(31, false); } case 425:{ for (int i = 0; i < 32; i++) { @@ -677,29 +678,25 @@ void sudo(int task) { } //LOOP SYSTEM case 500: { - AudioManager.indexBGM = 9; - AudioManager.stopBGM = true; + GlobalAudio.setBGM(9, false); } case 501: { - AudioManager.indexBGM = 10; - AudioManager.stopBGM = true; + GlobalAudio.setBGM(10, false); } case 502: { PrintToChatAll("Got 502 but not implemented in popfile, please report this to fartsy!"); PrintToConsoleAll("[CORE] Phase Change started... phase 4!"); - AudioManager.indexBGM = 11; - AudioManager.stopBGM = true; + GlobalAudio.setBGM(11, false); } - // FINAL Music system rewrite (again) AGAINNNNNNNNNNNN.... and again!... and again :p + // FINAL Music system rewrite (again) AGAINNNNNNNNNNNN.... and again!... and again :p and again! case 1000: { - AudioManager.shouldTick = true; - AudioManager.ChangeBGM(AudioManager.indexBGM, true); + GlobalAudio.UpdateBGM(); } //Stop current song case 1001: { - if (StrEqual(BGMArray[AudioManager.indexBGM].realPath, "null")) return; - for (int i = 1; i <= MaxClients; i++) { - StopSound(i, AudioManager.chanBGM, BGMArray[AudioManager.indexBGM].realPath); + for (int i = 1; i <= MaxClients; i++){ + if (StrEqual(BGMArray[AudioManager[i].indexBGM].realPath, "null")) continue; + StopSound(i, g_chanBGM, BGMArray[AudioManager[i].indexBGM].realPath); } return; } @@ -736,7 +733,7 @@ void sudo(int task) { } //Crusader case 1006: { - AudioManager.shouldTick = false; + GlobalAudio.shouldTick = false; sudo(1001); core.crusader = true; CreateTimer(1.75, CRUSADERINCOMING); @@ -829,9 +826,6 @@ void sudo(int task) { case 9000: { CreateTimer(10.0, BossHPTimer); } - case 9001: { - PrintToServer("BGM State is %b", AudioManager.bgmPlaying); - } case 9010: { CustomSoundEmitter(TBGM6, 65, true, 1, 1.0, 100); CustomSoundEmitter(TBGM4, 65, true, 1, 0.05, 100); @@ -915,7 +909,7 @@ void sudo(int task) { PerformWaveSetup(); float hwn = GetRandomFloat(core.HWNMin, core.HWNMax); CreateTimer(hwn, HWBosses); - AudioManager.ChangeBGM(27, true); + GlobalAudio.setBGM(29, true); return; } case 42690:{ @@ -962,7 +956,7 @@ public Action CommandOverride(int client, const char[] command, int argc) public Action TimedOperator(Handle timer, int job) { switch (job) { case 0: { - CPrintToChatAll(AudioManager.VIPBGM >= 0 ? "{darkviolet}[{forestgreen}CORE{darkviolet}] {white}Wave %i: {forestgreen}%s{white} (requested by VIP {forestgreen}%N{white})" : "{darkviolet}[{forestgreen}CORE{darkviolet}] {white}Wave %i: {forestgreen}%s", core.curWave, AudioManager.songName, core.VIPIndex); + for (int i = 0; i < MaxClients; ++i) CPrintToChat(i, GlobalAudio.VIPBGM >= 0 ? "{darkviolet}[{forestgreen}CORE{darkviolet}] {white}Wave %i: {forestgreen}%s{white} (requested by VIP {forestgreen}%N{white})" : "{darkviolet}[{forestgreen}CORE{darkviolet}] {white}Wave %i: {forestgreen}%s", core.curWave, AudioManager[i].songName, GlobalAudio.VIPIndex); } //Boss script case 2: { @@ -971,9 +965,7 @@ public Action TimedOperator(Handle timer, int job) { } //Boss script pt 2 case 3: { - AudioManager.indexBGM = 16; - AudioManager.songName = BGMArray[AudioManager.indexBGM].songName; - CustomSoundEmitter(BGMArray[AudioManager.indexBGM].realPath, BGMArray[AudioManager.indexBGM].SNDLVL, true, 0, 1.0, 100); + GlobalAudio.setBGM(16, true); FastFire2("FB.FadeTotalBLCK", "Fade", "", 0.0, false); FastFire2("FB.FadeTotalBLCK", "Fade", "", 3.0, false); FastFire2("FB.FadeTotalBLCK", "Fade", "", 7.0, false); @@ -1003,7 +995,7 @@ public Action TimedOperator(Handle timer, int job) { case 7: { core.sephiroth = true; //AudioManager.ticksBGM = 0; - AudioManager.loopSeconds = BGMArray[16].loopSeconds; + //AudioManager.loopSeconds = BGMArray[16].loopSeconds; } //Signal boss to actually spawn after delay. case 8: {