Warcraft III resources & community, 2003–2006 · archived

EnableAmbientSound

not rated
Submitted by PitzerMikeAI0 downloads
Can be used to disable and re-enable ambient sounds (animal noise and such) which is trickier than one might think.

I once wrote this function for some cinematic guys and they were quite happy with it - so here it is.

To clear things up: IsNoVictoryCheat is supposed to always return false, so the triggers that start ambient sounds again will never execute.

Source

//============================================================================================================ 
//
// For more JASS scripts, visit us at http://www.wc3JASS.com
//
//============================================================================================================ 

function EnableAmbientSound takes boolean On returns nothing
if not On then
  call StopSound(bj_dayAmbientSound,false,true)
  call StopSound(bj_nightAmbientSound,false,true)
  call TriggerAddCondition(bj_dncSoundsDawn,Condition(function IsNoVictoryCheat))
  call TriggerAddCondition(bj_dncSoundsDusk,Condition(function IsNoVictoryCheat))
  call TriggerAddCondition(bj_dncSoundsDay,Condition(function IsNoVictoryCheat))
  call TriggerAddCondition(bj_dncSoundsNight,Condition(function IsNoVictoryCheat))
else
  call TriggerClearConditions(bj_dncSoundsDawn)
  call TriggerClearConditions(bj_dncSoundsDusk)
  call TriggerClearConditions(bj_dncSoundsDay)
  call TriggerClearConditions(bj_dncSoundsNight)
  call SetDNCSoundsDay()
  call SetDNCSoundsNight()
endif
endfunction

Comments

4
Thanks Pitzer it's very useful
really useful for cinematics and custom multiboard menues
Updated the function :)
Nice script. Might be useful. I have just a suggestion.
You can get rid of the "AlwaysReturnFalse" function by abusing a nice one of the blizzard.j
This is the function:
function IsDawnDuskEnabled takes nothing returns boolean
    return bj_useDawnDuskSounds
endfunction
All ya need to do now is reqriting the function like this:
function EnableAmbientSound takes boolean On returns nothing
    if not On then
        set bj_useDawnDuskSounds = false
        call StopSound(bj_dayAmbientSound,false,true)
        call StopSound(bj_nightAmbientSound,false,true)
        call TriggerAddCondition(bj_dncSoundsDawn,Condition(function IsDawnDuskEnabled))
        call TriggerAddCondition(bj_dncSoundsDusk,Condition(function IsDawnDuskEnabled))
        call TriggerAddCondition(bj_dncSoundsDay,Condition(function IsDawnDuskEnabled))
        call TriggerAddCondition(bj_dncSoundsNight,Condition(function IsDawnDuskEnabled))
        call SetMusicVolumeBJ(100.00)
    else
        set bj_useDawnDuskSounds = true
        call TriggerClearConditions(bj_dncSoundsDawn)
        call TriggerClearConditions(bj_dncSoundsDusk)
        call TriggerClearConditions(bj_dncSoundsDay)
        call TriggerClearConditions(bj_dncSoundsNight)
        call SetDNCSoundsDay()
        call SetDNCSoundsNight()
        call SetMusicVolumeBJ(100.00)
    endif
endfunction