Capture Point Sounds
Adds sounds when a point is captured, entered or exited. Sounds are from Rising Storm 2: Vietnam
Best paired with the Capture Point UI mutator: https://steamcommunity.com/sharedfiles/filedetails/?id=3071478132
Source code:
behaviour("CapturePointSounds")
local instance
function CapturePointSounds:Start()
instance = self
self.volume = self.script.mutator.GetConfigurationRange("volume")
self.enterSound = self.targets.enterSound
self.exitSound = self.targets.exitSound
self.pointWon = self.targets.pointWon
self.pointLost = self.targets.pointLost
self.player = Player.actor
self.inPoint = false
self.outOfPoint = true
self.targets.AudioSource.SetOutputAudioMixer(AudioMixer.FirstPerson)
local vol = self.volume / 100;
self.targets.AudioSource.volume = vol
GameEvents.onCapturePointCaptured.AddListener(self, "OnCapturePointCaptured")
print("Capture Point Sounds Active – have fun!")
end
function CapturePointSounds:Update()
if self.player ~= nil then
currentCapturePoint = self.player.currentCapturePoint
if currentCapturePoint ~= nil then
if not self.inPoint then
— Entered point
self.inPoint = true
self.outOfPoint = false
self.targets.AudioSource.PlayOneShot(self.enterSound)
end
else
— Left point
self.inPoint = false
if self.outOfPoint == false then
self.outOfPoint = true
self.targets.AudioSource.PlayOneShot(self.exitSound)
end
end
end
end
function CapturePointSounds:OnCapturePointCaptured(capturePoint, team)
if team == self.player.team then
self.targets.AudioSource.PlayOneShot(self.pointWon)
else
self.targets.AudioSource.PlayOneShot(self.pointLost)
end
end