It is fairly simple to add or change music in Crusader Kings II.
Two things are needed in the Crusader Kings II\music folder:
To convert to ogg format, VLC media player can be used:
As of patch 2.7x the sample rate has to be 44100 Hz, as otherwise songs have a scratchy sound or don't seem to play in game anymore.
In the base game the music files are defined in songs.txt, which is located in the Crusader Kings II\music folder. Music which is added by DLCs such as Hymns of Abraham or Songs of the Caliph is defined in a .txt file within the music folder of DLC's zip file. Songs are defined using a similar system to events. The simplest are those found in the base game, and look something like this:
song = {
name = "crusaderkings2_maintitle.ogg"
song_name = "Crusader Kings 2 Maintitle"
chance = {
modifier = {
factor = 1
}
}
volume = 0.48
}
Each song has:
name, which corresponds to the .ogg file being used.song_name, which can be displayed to the playerfactor within a chance clause which defines how likely it is to be played. Songs in the base game all carry a factor of 1, while those added in DLCs tend to have a larger factor (thus making them play more often).volume to adjust the audio level.
No music on start issue/bug since 2.7x:
It is possible to change the probability that a song will play based on certain conditions. Most of the music-based DLCs add music which is exclusive to a particular culture/culture group or religion/religion group. This is achieved by adding conditions to the modifier clause. For example, the song England Anno 1066 from the Songs of Albion DLC uses the following code:
song = {
name = "englandanno1066.ogg"
chance = {
factor = 2
modifier = {
factor = 0
NOT = { culture = english }
NOT = { culture = saxon }
}
}
}
This gives it a probability factor of 2 (i.e. makes it twice as likely to play as a track in the base game), but restricts it to only play when the player's character is either English or Anglo-Saxon by multiplying the factor by 0 when that is not the case (2 × 0 = 0).
The conditions used are the same as those used in events, so can be incredibly elaborate or be based on very specific triggers.
The free Songs of Yuletide DLC uses the clause NOT = { real_month_of_year = 11 } to reduce the chance to 0 in any month other than December.
The songs in Songs of the Holy Land each carry two modifier clauses: one multiplies the base factor (in this case 5) by 0.1 (5 × 0.1 = 0.5) if there is not currently a crusade; the other multiplies it by 2 (5 × 2 = 10) if there is a crusade and the player is currently in the target kingdom (e.g. leading troops in the crusade or is in their capital, which is within the target kingdom).
song = {
name = "ascalon.ogg"
chance = {
factor = 5
modifier = {
factor = 0.1
has_called_crusade = no
}
modifier = {
factor = 2
crusade_target = {
ROOT = {
location = {
kingdom = {
title = PREVPREVPREV
}
}
}
}
}
}
}
| 历史 | 角色 • 家族 • 省份 • 头衔 • 剧本 |
| 脚本 | 指令 • 条件 • 作用域 • 修正 • 事件 • 决议 |
| 常规 | 定义 • 游戏规则 • 另类开局 • 宗教 • 文化 • 政体 • 特质 • 血脉 • 科技 • 法律 • 建筑 • 宣战理由 • 朝贡国 • 单位 • 目标 • 疾病 • 死亡 • 荣誉头衔 • 社团 • 宝物 • 地图外政权 • 内阁成员 • 贸易路线 • 继承 • 奇观 • 称号 |
| 图像/音效/本地化 | 地图 • 图形 • 盾徽 • 肖像 • 界面 • 小地图 • 音乐 • 本地化 |
| 其他 | 故障排除 • 验证器 • 控制台指令 • 编辑游戏存档 • Steam创意工坊 • EU4转档器模组制作 |
ConditionsDLCDLC filesEU4转档器模组制作Event moddingMusicSteam创意工坊事件模组制作作用域修正内阁成员模组制作决议模组制作剧本模组制作单位模组制作历史模组制作另类开局模组制作图形模组制作地图外政权模组制作地图模组制作头衔模组制作奇观模组制作宗教模组制作定义宝物模组制作宣战理由模组制作家族模组制作小地图模组制作建筑模组制作指令控制台指令政体模组制作故障排除文化模组制作朝贡国类型模组制作本地化条件模组制作死亡模组制作法律模组制作游戏规则模组制作特质模组制作界面模组制作疾病模组制作目标模组制作盾徽模组制作省份模组制作社团模组制作科技模组制作称号模组制作继承模组制作编辑游戏存档肖像模组制作脚本荣誉头衔模组制作血脉模组制作角色模组制作贸易路线模组制作验证器