local InWater = false local function WaterMusic(player) local song = mapheaderinfo[gamemap].watermusic if not (song) then return end local newmusic if (player.mo.eflags & MFE_UNDERWATER) then if not (InWater) InWater = true newmusic = song end else if (InWater) then InWater = false newmusic = mapheaderinfo[gamemap].musname end end if (newmusic) then local pos = S_GetMusicPosition() S_ChangeMusic(newmusic, true, player, 0, pos) end end addHook("PlayerThink", WaterMusic)