commit 4a2c21594ccd853c65f908aead69eac55fcfaebf Author: Ben Fisher Date: Tue Oct 20 15:27:09 2026 -0700 Add Build 42 World Atmosphere Pack mod diff --git a/Contents/mods/WorldAtmospherePack/42/media/lua/client/WorldAtmospherePack.lua b/Contents/mods/WorldAtmospherePack/42/media/lua/client/WorldAtmospherePack.lua new file mode 100644 index 0000000..7f1ce8b --- /dev/null +++ b/Contents/mods/WorldAtmospherePack/42/media/lua/client/WorldAtmospherePack.lua @@ -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) diff --git a/Contents/mods/WorldAtmospherePack/42/media/scripts/WorldAtmosphereSounds.txt b/Contents/mods/WorldAtmospherePack/42/media/scripts/WorldAtmosphereSounds.txt new file mode 100644 index 0000000..db21883 --- /dev/null +++ b/Contents/mods/WorldAtmospherePack/42/media/scripts/WorldAtmosphereSounds.txt @@ -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, + } + } +} diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track1.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track1.ogg new file mode 100644 index 0000000..c71cb9e Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track1.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track10.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track10.ogg new file mode 100644 index 0000000..9615d7b Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track10.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track11.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track11.ogg new file mode 100644 index 0000000..77e1af4 Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track11.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track12.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track12.ogg new file mode 100644 index 0000000..6696d4f Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track12.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track13.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track13.ogg new file mode 100644 index 0000000..062c4f9 Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track13.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track14.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track14.ogg new file mode 100644 index 0000000..c2e78a9 Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track14.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track15.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track15.ogg new file mode 100644 index 0000000..eb2482d Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track15.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track2.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track2.ogg new file mode 100644 index 0000000..e9d9c87 Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track2.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track3.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track3.ogg new file mode 100644 index 0000000..a96c40d Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track3.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track4.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track4.ogg new file mode 100644 index 0000000..461a4e8 Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track4.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track5.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track5.ogg new file mode 100644 index 0000000..98b5788 Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track5.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track6.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track6.ogg new file mode 100644 index 0000000..c2287b4 Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track6.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track7.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track7.ogg new file mode 100644 index 0000000..e96f6b5 Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track7.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track8.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track8.ogg new file mode 100644 index 0000000..dca2d55 Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track8.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track9.ogg b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track9.ogg new file mode 100644 index 0000000..dea8f46 Binary files /dev/null and b/Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/track9.ogg differ diff --git a/Contents/mods/WorldAtmospherePack/42/mod.info b/Contents/mods/WorldAtmospherePack/42/mod.info new file mode 100644 index 0000000..d629a23 --- /dev/null +++ b/Contents/mods/WorldAtmospherePack/42/mod.info @@ -0,0 +1,3 @@ +name=World Atmosphere Pack +id=WorldAtmospherePack +description=Subtle additions to the world atmosphere. diff --git a/SETUP.txt b/SETUP.txt new file mode 100644 index 0000000..ddc34d9 --- /dev/null +++ b/SETUP.txt @@ -0,0 +1,45 @@ +Build 42 World Atmosphere Pack setup + +1. The 15 tracks from MusicOGGFolder are included as track1.ogg through + track15.ogg under: + Contents/mods/WorldAtmospherePack/42/media/sound/WorldAtmospherePack/ + Do not publish music unless you have permission to redistribute it on + Steam Workshop, even if the Workshop item is friends-only. + +2. To add more songs, duplicate a clip { ... } block in + Contents/mods/WorldAtmospherePack/42/media/scripts/WorldAtmosphereSounds.txt, + changing its file path to each new .ogg. The game randomly selects a clip. + All songs should be normalized to a similar loudness. Keep paths and casing exact. + +3. Change MIN_WAIT_MINUTES and MAX_WAIT_MINUTES near the top of + Contents/mods/WorldAtmospherePack/42/media/lua/client/WorldAtmospherePack.lua + to adjust the real-time gap after each song finishes. A currently playing + song is never interrupted by this mod. Each connected player has an + independent random schedule. + +4. The installed upload copy is at + %UserProfile%/Zomboid/Workshop/WorldAtmospherePack (not the game's Workshop + install directory). The Desktop source folder retains its old folder name; + its mod ID and all packaged content use WorldAtmospherePack. Keep only ONE + installed copy enabled. Test the native + Options > Audio > Music slider at zero and while changing it mid-song on + your exact Build 42 version. The mod applies this slider to its playing + track through the UI emitter once per second. Native game music is muted + while a custom track plays and restored to the slider setting afterward. + +5. The 256x256 preview.png was resized from the image in your Pictures folder. + Only publish artwork if you have permission to redistribute it. Use the + game's main-menu Workshop > Create and update items uploader. Choose visibility + (the template starts friends-only) and note the numeric Workshop ID. + If you move the project out of this folder, work on just ONE copy. + +6. In the dedicated server's Zomboid/Server/.ini set: + WorkshopItems= + Mods=WorldAtmospherePack + Append with semicolons if other mods are configured, then restart the server. + Clients joining the server will be prompted to download Workshop content. + +References: +https://pzwiki.net/wiki/Mod_structure +https://pzwiki.net/wiki/Uploading_mods +https://pz-wiki-modding.github.io/PZ-API-Docs/scripts/sound.html diff --git a/preview.png b/preview.png new file mode 100644 index 0000000..d5edaa0 Binary files /dev/null and b/preview.png differ diff --git a/workshop.txt b/workshop.txt new file mode 100644 index 0000000..37598ae --- /dev/null +++ b/workshop.txt @@ -0,0 +1,4 @@ +version=1 +title=World Atmosphere Pack +description=Lightweight world atmosphere additions for Build 42. +visibility=1