- Joined
- Sep 15, 2006
- Messages
- 426
Trying to get something that plays a sound whenever a unit attacks, regardless if the sound is still playing, and it's not working. Can anyone see what's wrong here?
JASS:
function Trig_Small_Sound_Func002Func001C takes nothing returns boolean
if ( ( GetUnitTypeId(GetTriggerUnit()) == 'H001' ) ) then
return true
endif
if ( ( GetUnitTypeId(GetTriggerUnit()) == 'H000' ) ) then
return true
endif
if ( ( GetUnitTypeId(GetTriggerUnit()) == 'H003' ) ) then
return true
endif
if ( ( GetUnitTypeId(GetTriggerUnit()) == 'H004' ) ) then
return true
endif
if ( ( GetUnitTypeId(GetTriggerUnit()) == 'H002' ) ) then
return true
endif
if ( ( GetUnitTypeId(GetTriggerUnit()) == 'H005' ) ) then
return true
endif
return false
endfunction
function Trig_Small_Sound_Func002C takes nothing returns boolean
if ( not Trig_Small_Sound_Func002Func001C() ) then
return false
endif
return true
endfunction
function Trig_Small_Sound_Conditions takes nothing returns boolean
if ( not Trig_Small_Sound_Func002C() ) then
return false
endif
return true
endfunction
function Trig_Small_Sound_Actions takes nothing returns nothing
local sound s=CreateSound("usp_unsil-1.wav",false,false,false,10,10,"")
call SetSoundPitch(s,1.00)
call SetSoundVolume(s,100)
call SetSoundDistances(s,6000,6000)
call SetSoundDistanceCutoff(s,1000)
call AttachSoundToUnit(s,GetTriggerUnit())
call StartSound(s)
call KillSoundWhenDone(s)
endfunction
//===========================================================================
function InitTrig_Small_Sound takes nothing returns nothing
set gg_trg_Small_Sound = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Small_Sound, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_Small_Sound, Condition( function Trig_Small_Sound_Conditions ) )
call TriggerAddAction( gg_trg_Small_Sound, function Trig_Small_Sound_Actions )
endfunction