• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] How do you play sound properly?/ Is this leakless?

Status
Not open for further replies.
Level 7
Joined
Mar 8, 2009
Messages
360
I have just created one of my first spells, i tried to remove all leaks but since its my first spell i don't know what leaks and what not. I also don't know if the following way is the best way to play a sound:

JASS:
    call PlaySoundAtPointBJ( gg_snd_detonate, 100, targetLoc, 0 )
    call KillSoundWhenDone( GetLastPlayedSound())

This is my trigger from my spell:
JASS:
function Ether_Pulse_Conditions takes nothing returns boolean    
    return (( GetUnitAbilityLevelSwapped('A008', GetAttacker()) == 1 ) and  ( GetRandomInt(1, 100) <= 10 ))
endfunction

function banishPickedUnit takes nothing returns nothing
    local unit pickedUnit = GetEnumUnit()
    local unit dummy = CreateUnitAtLoc( Player(0), 'h009', GetUnitLoc(pickedUnit), 270 )
    call UnitAddAbility( dummy, 'A00P' )
    call IssueTargetOrder( dummy, "banish", pickedUnit )
endfunction

function isGoodUnit takes nothing returns boolean
    local unit pickedUnit = GetFilterUnit()
    local player owner = GetOwningPlayer(pickedUnit)
    return (( owner == Player(10) ) or (owner == Player(11)))
endfunction

function Trig_Ether_Pulse_Actions takes nothing returns nothing
    local unit target = GetTriggerUnit()
    local location targetLoc = GetUnitLoc(target)
    local effect explode = AddSpecialEffectLoc("Units\\NightElf\\Wisp\\WispExplode.mdl", targetLoc)
    local group targets = GetUnitsInRangeOfLocMatching(300, targetLoc, Condition(function isGoodUnit)) 
    call ForGroup(targets, function banishPickedUnit)
    call DestroyGroup(targets) 
    call DestroyEffect( explode )
    call PlaySoundAtPointBJ( gg_snd_detonate, 100, targetLoc, 0 )
    call KillSoundWhenDone( GetLastPlayedSound())
    call RemoveLocation( targetLoc )
    set target = null
endfunction

//===========================================================================
function InitTrig_Ether_Pulse takes nothing returns nothing
    local trigger gg_trg_Ether_Pulse = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Ether_Pulse, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Ether_Pulse, Condition( function Ether_Pulse_Conditions ) )
    call TriggerAddAction( gg_trg_Ether_Pulse, function Trig_Ether_Pulse_Actions )
    set gg_trg_Ether_Pulse = null
endfunction
In short , the unit with Ether Pulse ability has a 10% chance on attack to create an ether pulse at target location, banishing all enemies in 300 range of target.

Thanks , if you take time and reply :thumbs_up: (+ rep ofc)
 
Status
Not open for further replies.
Top