Files
barotrauma-localmods/Real Sonar/Lua/soundvolume.lua
2025-03-31 13:19:47 +02:00

36 lines
1.4 KiB
Lua

Hook.Patch(
"Barotrauma.SoundPlayer",
"PlaySound",
{
"Barotrauma.Sounds.Sound",
"Microsoft.Xna.Framework.Vector2",
"System.Single",
"System.Single",
"System.Single",
"Barotrauma.Hull",
"System.Boolean",
"System.Boolean"
},
function(instance, ptable)
local sound = ptable["sound"]
local soundName = sound.filename
if string.find(soundName,"sonarPingWater") or string.find(soundName,"sonarTailWater") then
ptable["volume"] = Single(ptable["volume"] * RealSonar.Config.WaterPingVolume) or ptable["volume"]
elseif string.find(soundName,"sonarPingAir") or string.find(soundName,"sonarTailAir") then
ptable["volume"] = Single(ptable["volume"] * RealSonar.Config.AirPingVolume) or ptable["volume"]
elseif string.find(soundName,"sonarPingSuit") or string.find(soundName,"sonarTailSuit") then
ptable["volume"] = Single(ptable["volume"] * RealSonar.Config.SuitPingVolume) or ptable["volume"]
end
if string.find(soundName,"Tinnitus") then
ptable["volume"] = Single(ptable["volume"] * RealSonar.Config.TinnitusVolume) or ptable["volume"]
end
if string.find(soundName,"sonarDistortion") then
ptable["volume"] = Single(ptable["volume"] * RealSonar.Config.DistortionVolume) or ptable["volume"]
end
end, Hook.HookMethodType.Before)