Add Build 42 World Atmosphere Pack mod
This commit is contained in:
commit
4a2c21594c
21 files changed
+218
No files matched your search
@@ -0,0 +1,81 @@
|
||||
-- All timing and playback happen on the player's client; no world sound is emitted.
|
||||
local SOUND_NAME = "WorldAtmosphereCue"
|
||||
local MIN_WAIT_MINUTES = 30
|
||||
local MAX_WAIT_MINUTES = 60
|
||||
local CHECK_INTERVAL_MS = 1000
|
||||
|
||||
local nextPlayAt = nil
|
||||
local lastCheckAt = 0
|
||||
local playingId = nil
|
||||
local tickRegistered = false
|
||||
local nativeMusicMuted = false
|
||||
|
||||
local function scheduleNext(now)
|
||||
nextPlayAt = now + ZombRandBetween(MIN_WAIT_MINUTES, MAX_WAIT_MINUTES + 1) * 60000
|
||||
end
|
||||
|
||||
local function onTick()
|
||||
if not getPlayer() then return end
|
||||
|
||||
local now = getTimestampMs()
|
||||
if now - lastCheckAt < CHECK_INTERVAL_MS then return end
|
||||
lastCheckAt = now
|
||||
|
||||
local soundManager = getSoundManager()
|
||||
local emitter = soundManager:getUIEmitter()
|
||||
if playingId then
|
||||
if emitter:isPlaying(playingId) then
|
||||
soundManager:setMusicVolume(0)
|
||||
emitter:setVolume(playingId, getCore():getOptionMusicVolume() / 10)
|
||||
return
|
||||
end
|
||||
playingId = nil
|
||||
if nativeMusicMuted then
|
||||
soundManager:setMusicVolume(getCore():getOptionMusicVolume() / 10)
|
||||
nativeMusicMuted = false
|
||||
end
|
||||
scheduleNext(now)
|
||||
return
|
||||
end
|
||||
|
||||
if not nextPlayAt or now < nextPlayAt then return end
|
||||
|
||||
-- The script sound selects a random clip. The UI emitter needs explicit
|
||||
-- per-sound volume to follow the game's music slider.
|
||||
playingId = emitter:playSound(SOUND_NAME)
|
||||
nextPlayAt = nil
|
||||
if playingId and playingId ~= 0 then
|
||||
emitter:set3D(playingId, false)
|
||||
emitter:setVolume(playingId, getCore():getOptionMusicVolume() / 10)
|
||||
soundManager:setMusicVolume(0)
|
||||
nativeMusicMuted = true
|
||||
else
|
||||
playingId = nil
|
||||
scheduleNext(now)
|
||||
end
|
||||
end
|
||||
|
||||
local function onDisconnect()
|
||||
local soundManager = getSoundManager()
|
||||
if playingId then
|
||||
soundManager:getUIEmitter():stopSound(playingId)
|
||||
end
|
||||
if nativeMusicMuted then
|
||||
soundManager:setMusicVolume(getCore():getOptionMusicVolume() / 10)
|
||||
nativeMusicMuted = false
|
||||
end
|
||||
playingId = nil
|
||||
nextPlayAt = nil
|
||||
end
|
||||
|
||||
local function onGameStart()
|
||||
scheduleNext(getTimestampMs())
|
||||
if not tickRegistered then
|
||||
Events.OnTick.Add(onTick)
|
||||
tickRegistered = true
|
||||
end
|
||||
end
|
||||
|
||||
Events.OnGameStart.Add(onGameStart)
|
||||
Events.OnDisconnect.Add(onDisconnect)
|
||||
Events.OnMainMenuEnter.Add(onDisconnect)
|
||||
@@ -0,0 +1,85 @@
|
||||
module WorldAtmospherePack
|
||||
{
|
||||
sound WorldAtmosphereCue
|
||||
{
|
||||
category = Music,
|
||||
master = Music,
|
||||
is3D = false,
|
||||
loop = false,
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track1.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track2.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track3.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track4.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track5.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track6.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track7.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track8.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track9.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track10.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track11.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track12.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track13.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track14.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
clip
|
||||
{
|
||||
file = media/sound/WorldAtmospherePack/track15.ogg,
|
||||
volume = 1.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
name=World Atmosphere Pack
|
||||
id=WorldAtmospherePack
|
||||
description=Subtle additions to the world atmosphere.
|
||||
Reference in new issue
Block a user