• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[JASS] Does a custom channeling sound system exist?

Hello hive,

I'm wondering if there is an existing system for playing a custom sound when channeling an ability that also stops the sound instantly if the ability is interrupted. The Battle Cruiser's Yamato cannon charge sound in Starcraft 2 is an example of what I mean.

So far I have done a google custom search of hive and a search of the spells section before asking this.
 
Hi, you don’t really need a full system for this, just a simple start + interrupt check.

--Start the sound when the unit begins channeling
--Periodically check if the channel broke
--Stop the sound immediately when it does


In GUI terms it’s something like:

On channel start:
  • Event: Unit begins channeling ability
  • Play sound and attach it to the unit
  • Store the unit + sound in variables
  • Turn on a short periodic trigger (0.3–0.5)
Interrupt check (loop):

--If any of these happen:
  • unit is dead
  • unit is stunned/paused
  • current order ≠ channel (this can be tricky, make sure order string is channel)
  • (optional) channel buff is gone
    → then stop the sound and turn the loop off.

Edit: Saw the [JASS] tag too late, note that this is not MUI:

Code:
globals
    sound ChannelSound = null
    unit ChannelUnit = null
    trigger InterruptTrig = CreateTrigger()
endglobals


function OnChannelStart takes nothing returns nothing
    if GetSpellAbilityId() == 'A000' then
        set ChannelUnit = GetTriggerUnit()
        set ChannelSound = CreateSound("Abilities\\Spells\\Other\\YourSound.wav", false, false, false, 10, 10, "")
        call AttachSoundToUnit(ChannelSound, ChannelUnit)
        call StartSound(ChannelSound)
        call EnableTrigger(InterruptTrig)
    endif
endfunction


function CheckInterrupt takes nothing returns nothing
    if ChannelUnit != null then
        if GetWidgetLife(ChannelUnit) < 0.405 or GetUnitCurrentOrder(ChannelUnit) != 852600 then
            call StopSound(ChannelSound, true, true)
            call DestroySound(ChannelSound)
            set ChannelSound = null
            set ChannelUnit = null
            call DisableTrigger(InterruptTrig)
        endif
    endif
endfunction

*As I mentioned before:
Code:
(Order("channel") = 852600, but depends on ability order string)

 
Last edited:
Back
Top