Avorion
评价数不足
XSF: Sector Music System
   
奖励
收藏
已收藏
取消收藏
Mods: Mod
文件大小
发表于
更新日期
189.189 KB
2024 年 2 月 21 日 下午 4:53
2024 年 4 月 10 日 上午 6:23
2 项改动说明 ( 查看 )

订阅以下载
XSF: Sector Music System

在 LM13 的 1 个合集中
eXtended Scripting Framework - Library collection
13 件物品
描述
Script only! Requires manual setup of music files. No music provided.


Advanced users only - requires manual editing

What is this?

A music system that can play same track for same sectors, while adapting to factions, region and contents.
In other words, sector at X,Y will always play same music - unless something big happens there.

This script was created for my own soundtrack from X3: Terran Conflict - but music files will not be uploaded.

Adding music

Folder structure has been prepared inside this mod.
  • Option A: Copy your music to mod folders
  • Option B: Create folder structure in your game folder ( data/music/background/ )

Custom music has to be in OGG format
Default export to OGG in Audacity software should be enough to convert music

FIles have to be in (1).ogg , (2).ogg naming style. It's easy to do batch renaming in windows.
You can search the internet with "windows batch rename files" for instructions

Setting up files in scripts

If you stick to default folders, all that need to change is 6 numbers at 6 lines.

Example:. putting 8 files into Common folder would need:
RegisterTracks( "Common", 1000, 13 )
being changed into:
RegisterTracks( "Common", 1000, 8 )

Snippet
Line 128 @ [data/scripts/lib/music.lua ]
--- @Example: -- #A: Folder "data/music/background/Common" -- #B: indexing at 1000 - 1013 -- #C: 13 files from (1) to (13).ogg #A: #B: #C: -- RegisterTracks( "Common", 1000, 13 ) -- ========================================== -- Custom Music Sets -- -- You can create custom folders, but no need to -- Put your tracks into those folders -- then change last argument to number of actual tracks -- ========================================== -- Had to be put into function - seems that client hangs and crashes a lot with those on script load function RegisterAllCustomTracks() -- FOLDER_NAME ID NUMBER_OF_TRACKS RegisterTracks( "Common", 1000, 13 ) RegisterTracks( "Friendly", 1100, 10 ) RegisterTracks( "Hostile", 1200, 6 ) RegisterTracks( "Mysterious", 1300, 6 ) RegisterTracks( "Noise", 1400, 3 ) RegisterTracks( "Uncertain", 1500, 4 ) end

Having music files in correct folders, with music.lua file corrected is enough to use custom music.

Advanced settings - Music selection logic
By default, music is picked based on faction relations, population, stations, asteroids and wreckages content. You can change that if you want

Snippet
Line 170 @ [data/scripts/player/client/musiccoordinator.lua ]
-- ------------------------------------ -- @Settings -- ------------------------------------ local BadRelation = -25000 local GoodRelation = 75000 local WreckageLimit = 50 local AsteroidLimit = 1250 local StationCoreLimit = 6 local StationEmptyLimit = 3

Snippet
Line 213 @ [data/scripts/player/client/musiccoordinator.lua ]

-- ------------------------------------ -- @Track Seletion Logic -- ------------------------------------ -- #Barely populated sectors: if stations < 2 then -- @With significant asteroid fields if asteroids > AsteroidLimit then primary = TrackCollection.Desolate() -- @That have nothing else else primary = TrackCollection.Empty() end -- #Small population sectors: elseif ...


Snippet
Line 270 @ [data/scripts/player/client/musiccoordinator.lua ]

-- ------------------------------------ -- @Assign Sector Unique tracks -- ------------------------------------ local _Min = 1 local _Max = #primary -- Don't use secondary tracks secondary = primary -- Use Xavorion Galaxy generator to pick unique tracks for this particular sector local _PrimaryIndex = IGalaxy.GetPredefinedInt(x, y, "SectorProperty.MusicPrimary", _Min, _Max) local _SecondaryIndex = IGalaxy.GetPredefinedInt(x, y, "SectorProperty.MusicSecondary", _Min, _Max) -- You can make up "SectorProperty.Music..." strings to roll more indices, adding more than 2 track to single sector
3 条留言
Adalbert 9 月 22 日 上午 4:53 
Thanks, I'll look into it whenever I'll play Avorion with some bros again.

Also some suggestions:
Combat - non-combat selection
- in addition ability to have pairs of tracks with the same length, that it could switch between seamlessly, like the cool dynamic music some games have.
LM13  [作者] 9 月 22 日 上午 4:45 
@Adalbert

In theory yes, music can change based on any information or callback available on the client.
It does require some modding experience, but shouldn't be that hard to make.

The lazy way would be to just check volume number, then assign a track with player name instead of sector property string.

-- 0,0 to use same music regardless of galaxy map coordinates
.GetPredefinedInt(0, 0, _PlayerName, _Min, _Max)

It would still need a callback route for when player appears and leaves.
Adalbert 9 月 22 日 上午 4:13 
When I played the game in multiplayer, I wished for a mod kinda like this, but for when a specific ship enters a sector, would that be possible?

(I was imagining the flagship of a player having its own theme music that starts playing when the ship shows up.)