library SoundManager initializer Init
// SM__Sound = string
// SM__Sound_Player = player
// SM__Sound_Unit = unit
// SM__Sound_Point = point
// SM__Sound_Volume = integer
// SM__Sound_Pitch = real
// SM__Sound_Is_Looping = boolean
// SM__Sound_Cutoff = real
// SM__Sound_Last_Played = sound
private function SoundPlayGeneral takes nothing returns nothing
local sound snd = CreateSound(udg_SM__Sound, udg_SM__Sound_Is_Looping, false, false, 10, 10, "DefaultEAXON")
call SetSoundChannel(snd, 0)
call SetSoundVolume(snd, udg_SM__Sound_Volume)
if udg_SM__Sound_Player != null then
if GetLocalPlayer() != udg_SM__Sound_Player then
call SetSoundVolume(snd, 0)
endif
endif
call SetSoundPitch(snd, udg_SM__Sound_Pitch)
call StartSound(snd)
if udg_SM__Sound_Is_Looping == false then
call KillSoundWhenDone(snd)
endif
set udg_SM__Sound_Last_Played = snd
set snd = null
endfunction
private function SoundPlay3DUnit takes nothing returns nothing
local sound snd = CreateSound(udg_SM__Sound, udg_SM__Sound_Is_Looping, true, true, 10, 10, "DefaultEAXON")
call SetSoundChannel(snd, 0)
call SetSoundVolume(snd, udg_SM__Sound_Volume)
if udg_SM__Sound_Player != null then
if GetLocalPlayer() != udg_SM__Sound_Player then
call SetSoundVolume(snd, 0)
endif
endif
call SetSoundPitch(snd, udg_SM__Sound_Pitch)
call SetSoundDistances(snd, 600., 10000.)
call SetSoundDistanceCutoff(snd, udg_SM__Sound_Cutoff)
call SetSoundConeAngles(snd, 0., 0., 127)
call SetSoundConeOrientation(snd, 0., 0., 0.)
call AttachSoundToUnit(snd, udg_SM__Sound_Unit)
call StartSound(snd)
if udg_SM__Sound_Is_Looping == false then
call KillSoundWhenDone(snd)
endif
set udg_SM__Sound_Last_Played = snd
set snd = null
endfunction
private function SoundPlay3DLocation takes nothing returns nothing
local sound snd = CreateSound(udg_SM__Sound, udg_SM__Sound_Is_Looping, true, true, 10, 10, "DefaultEAXON")
call SetSoundChannel(snd, 0)
call SetSoundVolume(snd, udg_SM__Sound_Volume)
if udg_SM__Sound_Player != null then
if GetLocalPlayer() != udg_SM__Sound_Player then
call SetSoundVolume(snd, 0)
endif
endif
call SetSoundPitch(snd, udg_SM__Sound_Pitch)
call SetSoundDistances(snd, 600., 10000.)
call SetSoundDistanceCutoff(snd, udg_SM__Sound_Cutoff)
call SetSoundConeAngles(snd, 0., 0., 127)
call SetSoundConeOrientation(snd, 0., 0., 0.)
call SetSoundPosition(snd, GetLocationX(udg_SM__Sound_Point), GetLocationY(udg_SM__Sound_Point), GetLocationZ(udg_SM__Sound_Point))
call StartSound(snd)
if udg_SM__Sound_Is_Looping == false then
call KillSoundWhenDone(snd)
endif
call RemoveLocation(udg_SM__Sound_Point)
set udg_SM__Sound_Last_Played = snd
set snd = null
endfunction
private function Reset takes nothing returns nothing
set udg_SM__Sound_Player = null
set udg_SM__Sound_Unit = null
set udg_SM__Sound_Point = null
set udg_SM__Sound_Is_Looping = false
set udg_SM__Sound_Cutoff = 3000.0
set udg_SM__Sound_Pitch = 1.0
set udg_SM__Sound_Volume = 127
endfunction
function SoundManagerPlay takes nothing returns nothing
if udg_SM__Sound_Unit == null and udg_SM__Sound_Point == null then
call SoundPlayGeneral()
elseif udg_SM__Sound_Unit == null and udg_SM__Sound_Point != null then
call SoundPlay3DLocation()
elseif udg_SM__Sound_Unit != null and udg_SM__Sound_Point == null then
call SoundPlay3DUnit()
else
call SoundPlayGeneral()
endif
call Reset()
endfunction
private function Init takes nothing returns nothing
call Reset()
endfunction
endlibrary