- Joined
- Apr 21, 2018
- Messages
- 18
Hello, I am new to Jass even though I've been playing WC3 for about 16 years now. I followed some tutorials and below is the code I developed to player sound monster.mp3 for the SINGLE player when the monster comes near their character. However, when I tested it the sound played for me no matter who the unit belonged to. Is there an error in my code or is this simply because I was in Test Map mode?
function Trig_Monster_Nearby_Conditions takes nothing returns boolean
if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'hpea' ) ) then
return false
endif
return true
endfunction
function Trig_Monster_Nearby_Actions takes nothing returns nothing
if GetLocalPlayer() == Player(0) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(1) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(2) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(3) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(4) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(5) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(6) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(7) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(8) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(9) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(10) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(11) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(12) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(13) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(14) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(15) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(16) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(17) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(18) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(19) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(20) then
call PlaySoundBJ( gg_snd_monster )
endif
endfunction
//===========================================================================
function InitTrig_Monster_Nearby takes nothing returns nothing
set gg_trg_Monster_Nearby = CreateTrigger( )
call TriggerRegisterUnitInRangeSimple( gg_trg_Monster_Nearby, 700.00, gg_unit_U000_0021 )
call TriggerAddCondition( gg_trg_Monster_Nearby, Condition( function Trig_Monster_Nearby_Conditions ) )
call TriggerAddAction( gg_trg_Monster_Nearby, function Trig_Monster_Nearby_Actions )
endfunction
function Trig_Monster_Nearby_Conditions takes nothing returns boolean
if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'hpea' ) ) then
return false
endif
return true
endfunction
function Trig_Monster_Nearby_Actions takes nothing returns nothing
if GetLocalPlayer() == Player(0) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(1) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(2) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(3) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(4) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(5) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(6) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(7) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(8) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(9) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(10) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(11) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(12) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(13) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(14) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(15) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(16) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(17) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(18) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(19) then
call PlaySoundBJ( gg_snd_monster )
endif
if GetLocalPlayer() == Player(20) then
call PlaySoundBJ( gg_snd_monster )
endif
endfunction
//===========================================================================
function InitTrig_Monster_Nearby takes nothing returns nothing
set gg_trg_Monster_Nearby = CreateTrigger( )
call TriggerRegisterUnitInRangeSimple( gg_trg_Monster_Nearby, 700.00, gg_unit_U000_0021 )
call TriggerAddCondition( gg_trg_Monster_Nearby, Condition( function Trig_Monster_Nearby_Conditions ) )
call TriggerAddAction( gg_trg_Monster_Nearby, function Trig_Monster_Nearby_Actions )
endfunction