// generally put sounds in a queue... but maybe some sounds are so important they must interrupt all other sounds and stop them. // when interrupting sounds. have a one second break. imagine if he let go of the play button of his speaker. // certain reminders should prevent other reminders from being played. like, only play one reminder within 5 minutes. // play all gameplay events EVERY TIME? // g_Game.PrecacheGeneric( "../media/valve.mp3" ); // g_Game.PrecacheGeneric( "debris/beamstart7.wav" ); // g_SoundSystem.EmitSound( self.edict(), CHAN_STATIC, "../media/valve.mp3", 1.0f, ATTN_NONE ); // g_SoundSystem.PlaySound( self.edict(), CHAN_STATIC, "../media/valve.mp3", 1.0f, ATTN_NONE ); // g_SoundSystem.StopSound( self.edict(), CHAN_STATIC, "../media/valve.mp3" ); // https://www.gamedev.net/forums/topic/680446-nested-dictionaries/ dictionary voiceList = { {'0_intro1', dictionary = {{'voiceFile', 'mustard/maxwell/0_intro1.wav'}, {'lengthSeconds', 6.8}, {'priority', 99}, {'triggerTarget', 'none'}}}, {'1_intro2', dictionary = {{'voiceFile', 'mustard/maxwell/1_intro2.wav'}, {'lengthSeconds', 10.8}, {'priority', 99}, {'triggerTarget', 'none'}}}, {'2_briefing', dictionary = {{'voiceFile', 'mustard/maxwell/2_briefing.wav'}, {'lengthSeconds', 85}, {'priority', 99}, {'triggerTarget', 'none'}}}, {'3_lobby', dictionary = {{'voiceFile', 'mustard/maxwell/3_lobby.wav'}, {'lengthSeconds', 10.1}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'4_switchflipped', dictionary = {{'voiceFile', 'mustard/maxwell/4_switchflipped.wav'}, {'lengthSeconds', 22.2}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'5_grindinginstructions', dictionary = {{'voiceFile', 'mustard/maxwell/5_grindinginstructions.wav'}, {'lengthSeconds', 31.8}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'6_sabotageintro', dictionary = {{'voiceFile', 'mustard/maxwell/6_sabotageintro.wav'}, {'lengthSeconds', 62.2}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'7_storagereached', dictionary = {{'voiceFile', 'mustard/maxwell/7_storagereached.wav'}, {'lengthSeconds', 23.2}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'8_goonsarrive', dictionary = {{'voiceFile', 'mustard/maxwell/8_goonsarrive.wav'}, {'lengthSeconds', 4.3}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'9_gotogrind', dictionary = {{'voiceFile', 'mustard/maxwell/9_gotogrind.wav'}, {'lengthSeconds', 3.1}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'10_gotomixing', dictionary = {{'voiceFile', 'mustard/maxwell/10_gotomixing.wav'}, {'lengthSeconds', 3}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'11_gotopacking', dictionary = {{'voiceFile', 'mustard/maxwell/11_gotopacking.wav'}, {'lengthSeconds', 3.1}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'12_gotogenerator', dictionary = {{'voiceFile', 'mustard/maxwell/12_gotogenerator.wav'}, {'lengthSeconds', 2.9}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'13_mixingreached', dictionary = {{'voiceFile', 'mustard/maxwell/13_mixingreached.wav'}, {'lengthSeconds', 24.6}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'14_greasefound2', dictionary = {{'voiceFile', 'mustard/maxwell/14_greasefound2.wav'}, {'lengthSeconds', 42.9}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'14_greasefound4', dictionary = {{'voiceFile', 'mustard/maxwell/14_greasefound4.wav'}, {'lengthSeconds', 43.0}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'15_packingstarted', dictionary = {{'voiceFile', 'mustard/maxwell/15_packingstarted.wav'}, {'lengthSeconds', 8.6}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'16_automatons', dictionary = {{'voiceFile', 'mustard/maxwell/16_automatons.wav'}, {'lengthSeconds', 15.1}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'17_firstrift', dictionary = {{'voiceFile', 'mustard/maxwell/17_firstrift.wav'}, {'lengthSeconds', 60}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'18_weelads', dictionary = {{'voiceFile', 'mustard/maxwell/18_weelads.wav'}, {'lengthSeconds', 53}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'19_valveturned1', dictionary = {{'voiceFile', 'mustard/maxwell/19_valveturned1.wav'}, {'lengthSeconds', 4.2}, {'priority', 3}, {'triggerTarget', 'none'}}}, {'20_valveturned2', dictionary = {{'voiceFile', 'mustard/maxwell/20_valveturned2.wav'}, {'lengthSeconds', 4.9}, {'priority', 3}, {'triggerTarget', 'none'}}}, {'21_valveturned3', dictionary = {{'voiceFile', 'mustard/maxwell/21_valveturned3.wav'}, {'lengthSeconds', 2.8}, {'priority', 3}, {'triggerTarget', 'none'}}}, {'22_valveturned4', dictionary = {{'voiceFile', 'mustard/maxwell/22_valveturned4.wav'}, {'lengthSeconds', 22}, {'priority', 3}, {'triggerTarget', 'none'}}}, {'23_halfdrained', dictionary = {{'voiceFile', 'mustard/maxwell/23_halfdrained.wav'}, {'lengthSeconds', 11.1}, {'priority', 2}, {'triggerTarget', 'none'}}}, {'24_90drained', dictionary = {{'voiceFile', 'mustard/maxwell/24_90drained.wav'}, {'lengthSeconds', 14.7}, {'priority', 4}, {'triggerTarget', 'none'}}}, {'25_fullydrained', dictionary = {{'voiceFile', 'mustard/maxwell/25_fullydrained.wav'}, {'lengthSeconds', 26.2}, {'priority', 999}, {'triggerTarget', 'none'}}}, {'26_bossarrives1', dictionary = {{'voiceFile', 'mustard/maxwell/26_bossarrives1.wav'}, {'lengthSeconds', 20.2}, {'priority', 100}, {'triggerTarget', 'none'}}}, {'27_bossarrives2', dictionary = {{'voiceFile', 'mustard/maxwell/27_bossarrives2.wav'}, {'lengthSeconds', 20.7}, {'priority', 99}, {'triggerTarget', 'none'}}}, {'28_pillarbreak', dictionary = {{'voiceFile', 'mustard/maxwell/28_pillarbreak.wav'}, {'lengthSeconds', 1.1}, {'priority', 999}, {'triggerTarget', 'none'}}}, {'29_sevenrifts', dictionary = {{'voiceFile', 'mustard/maxwell/29_sevenrifts.wav'}, {'lengthSeconds', 2.3}, {'priority', 999}, {'triggerTarget', 'none'}}}, {'30_dailygoalreached', dictionary = {{'voiceFile', 'mustard/maxwell/30_dailygoalreached.wav'}, {'lengthSeconds', 6.1}, {'priority', 999}, {'triggerTarget', 'none'}}}, {'31_dailygoalreached2', dictionary = {{'voiceFile', 'mustard/maxwell/31_dailygoalreached2.wav'}, {'lengthSeconds', 12.7}, {'priority', 999}, {'triggerTarget', 'none'}}}, {'32_grindsabotage', dictionary = {{'voiceFile', 'mustard/maxwell/32_grindsabotage.wav'}, {'lengthSeconds', 5.3}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'33_mixsabotage', dictionary = {{'voiceFile', 'mustard/maxwell/33_mixsabotage.wav'}, {'lengthSeconds', 3.8}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'34_packsabotage', dictionary = {{'voiceFile', 'mustard/maxwell/34_packsabotage.wav'}, {'lengthSeconds', 8}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'35_generatorsabotage', dictionary = {{'voiceFile', 'mustard/maxwell/35_generatorsabotage.wav'}, {'lengthSeconds', 8.1}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'36_repairreminder_angry', dictionary = {{'voiceFile', 'mustard/maxwell/36_repairreminder_angry.wav'}, {'lengthSeconds', 8.9}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'37_repairreminder_lessangry', dictionary = {{'voiceFile', 'mustard/maxwell/37_repairreminder_lessangry.wav'}, {'lengthSeconds', 4.9}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'38_repairreminder_urgent', dictionary = {{'voiceFile', 'mustard/maxwell/38_repairreminder_urgent.wav'}, {'lengthSeconds', 10.7}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'39_repairedgrinding', dictionary = {{'voiceFile', 'mustard/maxwell/39_repairedgrinding.wav'}, {'lengthSeconds', 4.2}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'40_repairedmixing', dictionary = {{'voiceFile', 'mustard/maxwell/40_repairedmixing.wav'}, {'lengthSeconds', 4.1}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'41_repairedpacking', dictionary = {{'voiceFile', 'mustard/maxwell/41_repairedpacking.wav'}, {'lengthSeconds', 4.4}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'42_generatorrepaired', dictionary = {{'voiceFile', 'mustard/maxwell/42_generatorrepaired.wav'}, {'lengthSeconds', 3.5}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'43_reminderhandbook', dictionary = {{'voiceFile', 'mustard/maxwell/43_reminderhandbook.wav'}, {'lengthSeconds', 11.9}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'44_reminderhandbook2', dictionary = {{'voiceFile', 'mustard/maxwell/44_reminderhandbook2.wav'}, {'lengthSeconds', 15.1}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'45_mustardproduced', dictionary = {{'voiceFile', 'mustard/maxwell/45_mustardproduced.wav'}, {'lengthSeconds', 2.9}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'46_keepthemcoming', dictionary = {{'voiceFile', 'mustard/maxwell/46_keepthemcoming.wav'}, {'lengthSeconds', 1.8}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'47_quitedecent', dictionary = {{'voiceFile', 'mustard/maxwell/47_quitedecent.wav'}, {'lengthSeconds', 1.7}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'48_goodwork', dictionary = {{'voiceFile', 'mustard/maxwell/48_goodwork.wav'}, {'lengthSeconds', 1.1}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'49_largebatch', dictionary = {{'voiceFile', 'mustard/maxwell/49_largebatch.wav'}, {'lengthSeconds', 4.4}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'50_soclose', dictionary = {{'voiceFile', 'mustard/maxwell/50_soclose.wav'}, {'lengthSeconds', 5}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'51_faster', dictionary = {{'voiceFile', 'mustard/maxwell/51_faster.wav'}, {'lengthSeconds', 7}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'52_faster', dictionary = {{'voiceFile', 'mustard/maxwell/52_faster.wav'}, {'lengthSeconds', 4.7}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'53_faster', dictionary = {{'voiceFile', 'mustard/maxwell/53_faster.wav'}, {'lengthSeconds', 8.2}, {'priority', 1}, {'triggerTarget', 'none'}}}, // {'54_faster', dictionary = {{'voiceFile', 'mustard/maxwell/54_faster.wav'}, {'lengthSeconds', 999}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'55_faster', dictionary = {{'voiceFile', 'mustard/maxwell/55_faster.wav'}, {'lengthSeconds', 6.2}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'56_faster', dictionary = {{'voiceFile', 'mustard/maxwell/56_faster.wav'}, {'lengthSeconds', 5.6}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'57_fastermustardmustardmustard', dictionary = {{'voiceFile', 'mustard/maxwell/57_fastermustardmustardmustard.wav'}, {'lengthSeconds', 16.9}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'58_riftopened', dictionary = {{'voiceFile', 'mustard/maxwell/58_riftopened.wav'}, {'lengthSeconds', 4.2}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'59_5rifts', dictionary = {{'voiceFile', 'mustard/maxwell/59_5rifts.wav'}, {'lengthSeconds', 6.4}, {'priority', 2}, {'triggerTarget', 'none'}}}, {'60_6rifts', dictionary = {{'voiceFile', 'mustard/maxwell/60_6rifts.wav'}, {'lengthSeconds', 7.7}, {'priority', 3}, {'triggerTarget', 'none'}}}, {'61_riftclosed', dictionary = {{'voiceFile', 'mustard/maxwell/61_riftclosed.wav'}, {'lengthSeconds', 3.2}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'62_riftclosed', dictionary = {{'voiceFile', 'mustard/maxwell/62_riftclosed.wav'}, {'lengthSeconds', 3.3}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'63_reminderrifts', dictionary = {{'voiceFile', 'mustard/maxwell/63_reminderrifts.wav'}, {'lengthSeconds', 7.6}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'64_reminder5rifts', dictionary = {{'voiceFile', 'mustard/maxwell/64_reminder5rifts.wav'}, {'lengthSeconds', 12.8}, {'priority', 3}, {'triggerTarget', 'none'}}}, {'65_bossurge', dictionary = {{'voiceFile', 'mustard/maxwell/65_bossurge.wav'}, {'lengthSeconds', 8}, {'priority', 2}, {'triggerTarget', 'none'}}}, {'66_bossurge2', dictionary = {{'voiceFile', 'mustard/maxwell/66_bossurge2.wav'}, {'lengthSeconds', 8.6}, {'priority', 2}, {'triggerTarget', 'none'}}}, {'67_manyproblems', dictionary = {{'voiceFile', 'mustard/maxwell/67_manyproblems.wav'}, {'lengthSeconds', 28.7}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'68_manyproblems', dictionary = {{'voiceFile', 'mustard/maxwell/68_manyproblems.wav'}, {'lengthSeconds', 13.4}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'69_manyproblems', dictionary = {{'voiceFile', 'mustard/maxwell/69_manyproblems.wav'}, {'lengthSeconds', 14.1}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'70_singlebatch', dictionary = {{'voiceFile', 'mustard/maxwell/70_singlebatch.wav'}, {'lengthSeconds', 8}, {'priority', 1}, {'triggerTarget', 'none'}}}, {'badabing', dictionary = {{'voiceFile', 'mustard/badabing.wav'}, {'lengthSeconds', 1.2}, {'priority', 999}, {'triggerTarget', 'none'}}} }; bool grindingInstructionsGiven = false; bool mixingInstructionsGiven = false; bool firstPackingStarted = false; bool firstDrainWarning = false; bool secondDrainWarning = false; bool firstPackWarning = false; bool secondPackWarning = false; bool priorityXOccurred = false; void mixingInstructionsGivenBoolean() { mixingInstructionsGiven = true; } // function called from trigger_script, ie location based triggers void playVoice(CBaseEntity@ pActivator, CBaseEntity@ pCaller, USE_TYPE useType, float flValue) { string targetname = pCaller.pev.targetname; //targetname.SubString(0, 5); if (switchFlipped == false && targetname == 'voice_3_lobby') { dictionary voiceLine = cast( voiceList['3_lobby'] ); g_Scheduler.SetTimeout( "addDictionaryToQueue", 2, voiceLine ); // addDictionaryToQueue(voiceLine); } if (switchFlipped == true && targetname == 'voice_5_grindinginstructions') { dictionary voiceLine = cast( voiceList['5_grindinginstructions'] ); g_Scheduler.SetTimeout( "addDictionaryToQueue", 3, voiceLine ); // addDictionaryToQueue(voiceLine); g_EntityFuncs.FireTargets( 'voice_5_m_r', null, null, USE_TOGGLE, 0.0f, 0.0f ); //disable trigger for grinding instructions grindingInstructionsGiven = true; } if (firstSabotageOccurred == true && targetname == 'voice_7_storagereached') { dictionary voiceLine = cast( voiceList['7_storagereached'] ); g_Scheduler.SetTimeout( "addDictionaryToQueue", 1, voiceLine ); // addDictionaryToQueue(voiceLine); CBaseEntity@ voice_7_storagereached = g_EntityFuncs.FindEntityByTargetname(null, 'voice_7_storagereached'); //null means find the first entity with the targetname g_EntityFuncs.Remove( voice_7_storagereached ); } if (grindingInstructionsGiven == true && sabotageSpeechGiven == true && targetname == 'voice_13_mixingreached') { dictionary voiceLine = cast( voiceList['13_mixingreached'] ); g_Scheduler.SetTimeout( "addDictionaryToQueue", 3, voiceLine ); // addDictionaryToQueue(voiceLine); g_EntityFuncs.FireTargets( 'voice_13_m_r', null, null, USE_TOGGLE, 0.0f, 0.0f ); //disable trigger for mixing instructions //mixingInstructionsGiven = true; g_Scheduler.SetTimeout( "mixingInstructionsGivenBoolean", 25 + 90); //to ensure packing instructions do not play until mixing intro is spoken. 25 is sound file length. } if (mixingInstructionsGiven == true && targetname == 'voice_14_greasefound') { if (mustardGoal == 8) { dictionary voiceLine = cast( voiceList['14_greasefound2'] ); // addDictionaryToQueue(voiceLine); g_Scheduler.SetTimeout( "addDictionaryToQueue", 3, voiceLine ); } else if (mustardGoal == 16) { dictionary voiceLine = cast( voiceList['14_greasefound4'] ); g_Scheduler.SetTimeout( "addDictionaryToQueue", 3, voiceLine ); } CBaseEntity@ voice_14_greasefound = g_EntityFuncs.FindEntityByTargetname(null, 'voice_14_greasefound'); //null means find the first entity with the targetname g_EntityFuncs.Remove( voice_14_greasefound ); } } array voiceQueue; bool queueInterrupted = false; void addDictionaryToQueue(dictionary voiceLine) { // dictionary voiceLineDict = cast( voiceList['0_intro1'] ); // string voiceFile = cast( voiceLineDict['voiceFile'] ); // float lengthSeconds = cast( voiceLineDict['lengthSeconds'] ); // int priority = cast( voiceLineDict['priority'] ); // string triggerTarget = cast( voiceLineDict['triggerTarget'] ); string voiceFile; float lengthSeconds; int priority; string triggerTarget; voiceLine.get('voiceFile', voiceFile ); voiceLine.get('lengthSeconds', lengthSeconds ); voiceLine.get('priority', priority ); voiceLine.get('triggerTarget', triggerTarget ); addVoiceToQueue(voiceFile, lengthSeconds, priority, triggerTarget); } void addVoiceToQueue(string voiceFile, float lengthSeconds, int priority, string triggerTarget) { if (priorityXOccurred == true && priority < 999 ) { //once a line with priority 999 has been added, adding lines with lower priority is disabled. return; } if (priorityXOccurred == false && priority == 999) { priorityXOccurred = true; } dictionary voiceLine = {{'voiceFile', voiceFile}, {'lengthSeconds', lengthSeconds}, {'priority', priority}, {'triggerTarget', triggerTarget}}; if (voiceQueue.length() == 0) { //check if somethin voiceQueue.insertAt(0, voiceLine); // CBaseEntity@ pWorld = g_EntityFuncs.Instance( 0 ); CBaseEntity@ speechOrigin = g_EntityFuncs.FindEntityByTargetname(null, 'maxwell_speech_origin'); g_SoundSystem.PlaySound( speechOrigin.edict(), CHAN_STATIC, voiceFile, 1.0f, ATTN_NONE ); g_Scheduler.SetTimeout( "voiceLineHasEnded", lengthSeconds ); // if (triggerTarget == 'beginBossBattle') { // beginBossBattle(); // } } else if (priority == 999) { string currentVoiceFile; voiceQueue[0].get('voiceFile', currentVoiceFile ); // CBaseEntity@ pWorld = g_EntityFuncs.Instance( 0 ); CBaseEntity@ speechOrigin = g_EntityFuncs.FindEntityByTargetname(null, 'maxwell_speech_origin'); g_SoundSystem.StopSound( speechOrigin.edict(), CHAN_STATIC, currentVoiceFile ); voiceQueue.resize(0); voiceQueue.insertAt(0, voiceLine); g_SoundSystem.PlaySound( speechOrigin.edict(), CHAN_STATIC, voiceFile, 1.0f, ATTN_NONE ); queueInterrupted = true; g_Scheduler.SetTimeout( "voiceLineHasEnded", lengthSeconds ); } else if (voiceQueue.length() > 0) { for( uint n = 1; n < voiceQueue.length(); n++ ){ //voice at index 0 is safe int currentArrayPriority; voiceQueue[n].get('priority', currentArrayPriority ); if (priority > currentArrayPriority) { voiceQueue.insertAt(n, voiceLine); return; } } voiceQueue.insertLast(voiceLine); //if the priority is lower than everything in the array, add the line to the end of the array } } void playVoiceLine(string voiceFile) { //useful when adding 1 second delay // CBaseEntity@ pWorld = g_EntityFuncs.Instance( 0 ); CBaseEntity@ speechOrigin = g_EntityFuncs.FindEntityByTargetname(null, 'maxwell_speech_origin'); g_SoundSystem.PlaySound( speechOrigin.edict(), CHAN_STATIC, voiceFile, 1.0f, ATTN_NONE ); } void voiceLineHasEnded() { if (queueInterrupted == true) { //if interrupted, that means a voiceline was playing and was interrupted. this function is going to be called, so i disable the function queueInterrupted = false; return; } string triggerTarget; if (voiceQueue.length() > 1) { // special case where sabotage instructions play after grinding instructions // float potentialBufferLength = 0; string currentLine; voiceQueue[0].get('voiceFile', currentLine ); string nextLine; voiceQueue[1].get('voiceFile', nextLine ); if (currentLine == 'mustard/maxwell/5_grindinginstructions.wav' && nextLine == 'mustard/maxwell/6_sabotageintro.wav') { potentialBufferLength = 20; //if i increase this in the future, increase trackTwoCounter and trackOneCounter correspondingly. also consider increasing g_Scheduler.SetTimeout( "addDictionaryToQueue", 20, voiceLine ); } // end special case where sabotage instructions play after grinding instructions // voiceQueue[1].get('triggerTarget', triggerTarget ); //we check the triggerTarget of the following voiceline in the queue, because for now we only trigger things at the beginning, not the end of a line) //if (triggerTarget != 'none') { // call function // i dont think its possible to pass function name as a parameter. hgardcode a list of functions to call? //} for( uint n = 0; n < voiceQueue.length() -1; n++ ){ //dont look at last index voiceQueue[n] = voiceQueue[n+1]; } string voiceFile; voiceQueue[0].get('voiceFile', voiceFile ); float lengthSeconds; voiceQueue[0].get('lengthSeconds', lengthSeconds ); g_Scheduler.SetTimeout( "playVoiceLine", 1 + potentialBufferLength, voiceFile ); g_Scheduler.SetTimeout( "voiceLineHasEnded", lengthSeconds + 1 + potentialBufferLength ); // if (triggerTarget == 'beginBossBattle' && activeBoss == false) { // beginBossBattle(); // } } voiceQueue.removeLast(); } // first check // g_Scheduler.SetTimeout( "checkReminder", checkReminderInterval ); int checkReminderInterval = Math.RandomLong(360,480); array hurryArray = { "51_faster", "52_faster", "53_faster", "55_faster", "56_faster", "57_fastermustardmustardmustard" }; array shamblesArray = { "68_manyproblems", "67_manyproblems", "69_manyproblems" }; void checkReminder() { array possibleReminders(0); bool behindWorkQuota = false; bool machinesInShambles = false; dictionary voiceLine; if ((mustardGoal == 8 && brokenMachinesCount > 7 )or (mustardGoal == 16 && brokenMachinesCount > 11)) { voiceLine = cast( voiceList['38_repairreminder_urgent'] ); possibleReminders.insertLast( voiceLine ); machinesInShambles = true; } else if (brokenMachinesCount > 3) { int randomPick = Math.RandomLong(1,2); switch( randomPick ) { case 1: voiceLine = cast( voiceList['36_repairreminder_angry'] ); break; case 2: voiceLine = cast( voiceList['37_repairreminder_lessangry'] ); break; } possibleReminders.insertLast(voiceLine ); } if (mustardGoal == 8) { if ( mustardProduced + mixesBeingProcessed < 3 && workTimeAccumulated > 900) { behindWorkQuota = true; } else if ( mustardProduced + mixesBeingProcessed < 6 && workTimeAccumulated > 1500) { behindWorkQuota = true; } else if ( mustardProduced + mixesBeingProcessed < 8 && workTimeAccumulated > 2100) { behindWorkQuota = true; } } else if (mustardGoal == 16) { if ( mustardProduced + mixesBeingProcessed < 6 && workTimeAccumulated > 900) { behindWorkQuota = true; } else if ( mustardProduced + mixesBeingProcessed < 11 && workTimeAccumulated > 1500) { behindWorkQuota = true; } else if ( mustardProduced + mixesBeingProcessed < 16 && workTimeAccumulated > 2100) { behindWorkQuota = true; } } if (behindWorkQuota == true) { if (hurryArray.length() == 0) hurryArray = { "51_faster", "52_faster", "53_faster", "55_faster", "56_faster", "57_fastermustardmustardmustard"}; int randomPick = Math.RandomLong(0,hurryArray.length()-1); string voiceFileHurry = hurryArray[randomPick]; voiceLine = cast( voiceList[voiceFileHurry] ); hurryArray.removeAt(randomPick); // switch( randomPick ) // { // case 1: // dictionary voiceLine = cast( voiceList['51_faster'] ); // break; // case 2: // dictionary voiceLine = cast( voiceList['52_faster'] ); // break; // case 3: // dictionary voiceLine = cast( voiceList['53_faster'] ); // break; // case 4: // dictionary voiceLine = cast( voiceList['55_faster'] ); // break; // case 5: // dictionary voiceLine = cast( voiceList['56_faster'] ); // break; // case 6: // dictionary voiceLine = cast( voiceList['57_fastermustardmustardmustard'] ); // break; // } possibleReminders.insertLast(voiceLine ); } if (activeRiftsCounter > 1 && activeRiftsCounter < 5) { voiceLine = cast( voiceList['63_reminderrifts'] ); possibleReminders.insertLast( voiceLine ); } else if (activeRiftsCounter > 4 ) { voiceLine = cast( voiceList['64_reminder5rifts'] ); possibleReminders.insertLast( voiceLine ); addDictionaryToQueue(voiceLine); loopCheckReminder(); return; } if (activeRiftsCounter > 3 && behindWorkQuota && machinesInShambles && shamblesArray.length() > 0 ) { //does it make sense he gets less intense when he has complained 3 times? voiceLine = cast( voiceList[shamblesArray[0]] ); shamblesArray.removeAt(0); //possibleReminders.insertLast(voiceLine ); addDictionaryToQueue(voiceLine); loopCheckReminder(); return; } if (possibleReminders.length() > 0) { uint randomReminder = Math.RandomLong(0 , possibleReminders.length() - 1 ); string voiceFile; float lengthSeconds; int priority; string triggerTarget; possibleReminders[randomReminder].get('voiceFile', voiceFile ); possibleReminders[randomReminder].get('lengthSeconds', lengthSeconds ); possibleReminders[randomReminder].get('priority', priority ); possibleReminders[randomReminder].get('triggerTarget', triggerTarget ); addVoiceToQueue(voiceFile, lengthSeconds, priority, triggerTarget); } loopCheckReminder(); } void loopCheckReminder() { checkReminderInterval = Math.RandomLong(360,480); g_Scheduler.SetTimeout( "checkReminder", checkReminderInterval ); } void precacheSounds() { //g_Game.PrecacheGeneric( "sound/mustard/maxwell/0_intro1.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/0_intro1.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/1_intro2.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/2_briefing.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/3_lobby.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/4_switchflipped.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/5_grindinginstructions.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/6_sabotageintro.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/7_storagereached.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/8_goonsarrive.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/9_gotogrind.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/10_gotomixing.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/11_gotopacking.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/12_gotogenerator.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/13_mixingreached.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/14_greasefound2.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/14_greasefound4.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/15_packingstarted.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/16_automatons.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/17_firstrift.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/18_weelads.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/19_valveturned1.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/20_valveturned2.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/21_valveturned3.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/22_valveturned4.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/23_halfdrained.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/24_90drained.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/25_fullydrained.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/26_bossarrives1.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/27_bossarrives2.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/28_pillarbreak.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/29_sevenrifts.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/30_dailygoalreached.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/31_dailygoalreached2.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/32_grindsabotage.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/33_mixsabotage.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/34_packsabotage.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/35_generatorsabotage.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/36_repairreminder_angry.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/37_repairreminder_lessangry.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/38_repairreminder_urgent.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/39_repairedgrinding.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/40_repairedmixing.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/41_repairedpacking.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/42_generatorrepaired.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/43_reminderhandbook.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/44_reminderhandbook2.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/45_mustardproduced.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/46_keepthemcoming.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/47_quitedecent.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/48_goodwork.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/49_largebatch.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/50_soclose.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/51_faster.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/52_faster.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/53_faster.wav" ); //g_SoundSystem.PrecacheSound( "mustard/maxwell/54_faster.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/55_faster.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/56_faster.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/57_fastermustardmustardmustard.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/58_riftopened.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/59_5rifts.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/60_6rifts.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/61_riftclosed.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/62_riftclosed.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/63_reminderrifts.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/64_reminder5rifts.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/65_bossurge.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/66_bossurge2.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/67_manyproblems.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/68_manyproblems.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/69_manyproblems.wav" ); g_SoundSystem.PrecacheSound( "mustard/maxwell/70_singlebatch.wav" ); g_SoundSystem.PrecacheSound( "mustard/badabing.wav" ); }