模組製作

本頁面講述的內容長期有效

模組製作Modding),或者說創建模組,是一種修改遊戲資源或行為的方式,有時候僅僅是為了個人使用,有時候製作者也會發布出來供其它玩家一起使用。可以通過以下途徑了解mod製作Paradox ModsSteam Workshop

在所有的P社遊戲中,十字軍之王3的可修改程度都是相當高的。mod製作者可以修改的內容也相當寬泛,比如語言翻譯,更多的事件和決議,更優秀的地圖,更大程度上的內容修改和作弊。

這篇引導的目的在於降低製作mod的門檻。但是學習的曲線總是曲折的,這需要你通過不斷的練習和閱讀他人優秀mod代碼來提升自己製作mod的水平。

大多數模組會改變校驗碼,這在1.9版本之前的遊戲中將禁用成就。在Crusader Kings III\game中的checksum_manifest.txt查看校驗文件夾和文件。不會改變校驗碼的是替換紋理、字體、著色器或音樂的模組。

提示 & 指引[編輯 | 編輯原始碼]

  • 創建一個mod對遊戲進行修改: 即使是很小的改動,也不要直接修改CK3遊戲本體的遊戲文件,而是要單獨創建一個mod。因為本體更新時會直接覆蓋這些修改,並且沒有任何提示。
  • 使用好的文本編輯器 用來編輯和搜索文件。以下軟體均免費:
    • Visual Studio Code. 可使用Paradox Highlight插件為Crusader Kings III和其它Paradox Games提供最新版的語法高亮。還有一個粉絲自製的CWTools擴展,具有Paradox語法高亮、驗證以及觸發器和效果的工具提示。要安裝它,請到VS左側面板的擴展,搜索CWTools。(注意:驗證規則是不完整的,會在gui和本地化文件中顯示許多錯誤)
    • Notepad++。選擇Perl作為你的語言,因為它可以提供良好的高亮顯示,並允許摺疊代碼塊和注釋。要將其設置為默認語言,請進入「設置」,「樣式器配置器」,在左側列表中找到Perl,並在底部的「User ext.」欄位中添加「gui txt」(不加引號)。
    • Atom。不包括本地化文件所需的UTF-8-BOM編碼。除此之外,其可自定義程度高。選擇Perl 6作為你的語言以獲得更好的效果。要將其設置為默認,請到文件,配置,找到「core:」,並在下面添加:「customFileTypes: "source.perl6"。["txt""gui"]",比如這個例子
    • Sublime Text. 這個連結本身是《大將軍:羅馬》的擴展,但是也可以用在ck3上: Sublime Tools. 這個擴展為效果和觸發器添加了不同的顏色高亮。如果你想要在sublime里切換注釋就還需要在同一個User文件夾里添加this file
  • 總是通過 error.log 文件檢查mod運行中出現的bug。...\Documents\Paradox Interactive\Crusader Kings III\logs
  • 日誌文件夾還包含效果、觸發器和作用域列表。在遊戲中使用控制台命令"script_docs"和"DumpDataTypes"來生成它們。
  • 使用-debug_mode -develop開始遊戲 啟動選項使用控台以及"reload gui", "reload gfx"命令
    • Steam:右鍵點擊遊戲->屬性->啟動選項->填入 -debug_mode -develop
    • Windows: Create a shortcut for the .exe file -> right-click it -> Properties -> add -debug_mode -develop at the end of the Target field
  • CK3文件夾在Linux系統的路徑 ~/.local/share/Paradox Interactive/Crusader Kings III
  • 清晰明了的傳達你的MOD的關鍵內容
    • 你的MOD說明應當以簡短並清晰的描述開始,說明你的MOD為遊戲增添或更改的內容。切忌以長篇大論、長長的告示列表、前提條件以及安裝介紹等等開頭。
    • 不要假設用戶已經了解過這個mod了。(如果他們已經了解了這個mod就不會再讀你的描述了)
    • 標明這個mod支不支持成就和鐵人模式。 (即使你覺得這已經很明顯了也要標出來)
  • 當你訂閱這個mod的steam版本時,記得移除你放在本地的mod,否則這個mod可能會出現問題或者無法運行。
  • 記得保存和備份。要麼手動保存要麼存在github一類的地方。Github同時也是合作製作mod的好工具。
  • WinMerge一類的工具來合併文件夾,更新、修改文件以及打補丁。
  • 當你想要換掉大量的文字時,最好使用正則表達式。 所有上面提到的編輯器都可以用. 資源: RegexOne, RegExr.

本地化文件[編輯 | 編輯原始碼]

  • 本地化文件夾中的yml後綴結尾的文件必須以UTF-8 + BOM編碼保存,以便遊戲正確讀取。
  • 為了保證遊戲正確讀取文件,文件名需要以*l_<language>.yml形式保存。例如council_l_english.yml
    • 你必須使用美式拼寫"localization"。使用英式拼寫"localization"會無法運行。
  • 如果要重寫原始的本地化數值, 將你修改過的文件放入名為localization文件夾內名為"replace"的文件夾.

創建一個模組[編輯 | 編輯原始碼]

主條目:Mod structure#Creating initial files

推薦使用遊戲官方登陸器來創建初始文件。

上傳/更新模組[編輯 | 編輯原始碼]

再次上傳您的模組更新,

  1. 打開啟動器,
  2. 導航到「Mods」部分,
  3. 點擊「Mod工具」,從下拉菜單中選擇你的模組。
  4. 選擇什麼平台上傳它。
  5. 輸入任何描述。(如果更新,請確保啟動器從網站上複製最新的描述。)
  6. 添加一個縮略圖
    • 對於Steam創意工坊,把thumbnail.png放在mod文件夾里。使用1:1的比例,最大1MB。創意工坊顯示的最大縮略圖約為600x600像素。
    • 對於Paradox Mods,將縮略圖拖到描述下方的區域。建議最小尺寸為900x500,png或jpg,最大1MB。
  7. 點擊「上傳MOD」。
    • 在Steam上,模組將以私人模式上傳,並出現在你的Steam資料->創意工坊項目中。打開它,並將側欄上的可見性改為 「公開」,即可實際發布。
    • 在Paradox Mods上,mod將在驗證過程後被發布。你可能需要編輯你的描述,因為網站通常會刪除換行符和BBCode格式。

保存修改的內容[編輯 | 編輯原始碼]

保存的文件被放在:

  • Windows: Documents\Paradox Interactive\Crusader Kings III\save games
  • Linux: ~/.local/share/Paradox Interactive/Crusader Kings III/save games

鐵人檔是不可修改的!

首先在debug模式下開一局遊戲並且保存。

  • Steam: 在Steam上右鍵單擊遊戲 -> Properties -> Set Launch Options -> 勾選debug_mode
  • Windows: 為.exe文件創建一個快捷方式 -> 右鍵單擊-> Properties -> add -debug_mode at the end of the Target field

PC(Windows):

  1. 在保存遊戲的文件夾內找到你保存的遊戲
  2. 右鍵單擊此文件用7-Zip 或者 WinRar提取出壓縮文件.
  3. 將提取出的'gamestate'文件的擴展名重名為.ck3
  4. 右鍵單擊並且用編輯器打開 (不推薦使用windows notepad,因為這些文件很大).
  5. 編輯並保存文件。
  6. 遊戲中會直接加載mod(不需要重複壓縮)。

你可以直接編輯自動保存的遊戲without extracting the gamestate.

Mac:

  1. 打開終端
  2. 確認當前路徑是正確的
  3. 輸入命令 "unzip FileName.ck3"
  4. 將提取出的'gamestate'文件的擴展名重名為.ck3
  5. 保存此純文本
  6. 遊戲中會直接加載mod(不需要重複壓縮)
平台 保存方式 路徑
Windows 本地 C:\Users\%USERPROFILE%\Documents\Paradox Interactive\Crusader Kings III\save games
Windows Steam 雲端 C:\Program Files (x86)\Steam\userdata\####\1158310\remote\save games
Mac 本地 $HOME/Documents/Paradox Interactive/Crusader Kings III/save games
Linux 本地 $HOME/.local/share/Paradox Interactive/Crusader Kings III/save games

gamestate文件中的內容[編輯 | 編輯原始碼]

The table below contains the possible first-level blocks in the gamestate file. Entries are provided in order of appearance.

Block Description
meta_data Contains metadata about the game, such as the game version. Used by the main menu screen.
ironman_manager Related to ironman saving.
(various variables) These variables do not belong in a block.
Variable
date
bookmark_date
first_start
speed
random_seed
random_count
variables Contains script flags.
game_rules Contains the save's current game rules.
provinces Contains province data, including buildings.
landed_titles Contains the following sub-blocks:
Sub-block Description
dynamic_templates
landed_titles
(repetition)
Contains an entry for each landed title in the game, in the format:
# Exact formatting in file is different in terms of spaces and lines
# It is usually more compact.
# It has been edited here for clarity and demonstration.


# Index for titles starts at 0
index={
	key="(title id)" # The one used in 00_landed_titles.txt, e.g. k_england

	de_facto_liege=(title index) # Optional
	de_jure_liege=(title index) # Optional. The number at the start of a similar block, NOT the title id
	de_jure_vassals={ (title index...) } # Optional, list of title indices.
	holder="(character id)" # Optional

	name="..."
	adj="..." # Optional
	pre="..." # Optional
	article="..." # Optional

	date=2020.10.27 # yyyy.mm.dd
	heir={ (character id...) } # Optional. List of character ids.
	claim={ (character id...) } # Optional
	history = { (...) } # Optional 
	capital=(province id)
	capital_barony=yes # Optional
	theocratic_lease=yes # Optional
	history_government="(government id)" # Optional
	laws={ "(law id)"... } # Optional. List of law ids.

	# Optional (succession_election).
	succession_election={
		electors = {  (character id...) }
		candidates={ (character id...) }
		nominations={
			{
				elector=(character id)
				candidate=(character id)
				strength=(value)
			}
		
		}
	} # end of succession_election block

	coat_of_arms_id=(coat of arms id)
	localization_key="(localization key)" # Optional

	# All below is used for mercenary bands
	special={
		type=mc
		identity=(id)
	}
	color=rgb { (r) (g) (b) }
	landless=yes
	destroy_if_invalid_heir=yes
	no_automatic_claims=yes
	definite_form=yes
}

In vanilla CK3, this block ends at entry ~12369.

index=(value)
(variable)
dynasties Contains the following sub-blocks:
  • dynasty_house (ends at entry ~6401)
  • dynasties (ends at entry ~6239)
  • static_dynasties (list of numbers)
  • static_dynasty_houses (list of numbers)
deleted_characters
living Contains entries of living characters. The following format is used for each character:
index={
	first_name="..."
	birth=(date) # Format: yyy.m.d
	female=yes # Optional
	was_playable=yes # Optional
	nickname="nick_..." # Optional
	culture=(culture index) # Optional if dynasty_house is specified, defaults to dynasty_house culture. Required if no dynasty_house, or culture different from that of dynasty_house.
	faith=(faith index) # Optional if dynasty_house is specified, defaults to dynasty_house faith.  Required if no dynasty_house or faith different from that of dynasty_house.
	dynasty_house=(dynasty house index) # Optional, must specify culture and faith if omitted
	skill={ (diplomacy) (stewardship) (martial) (intrigue) (learning) (prowess) } # One value for each skill
	prowess_age=(value) # Optional. Negative value.
	dna="(dna string)" # Optional
	mass=(value) # Optional, exclusive with weight
	weight={ # Optional, exclusive with mass
		base=(value)
		current=(value) # Optional
		target=(value) # Optional
	}

	sexuality=(value) # Optional. Defaults to heterosexual. Valid values: ho, bi, as, none. None is for children under 10.
	traits={ (trait index...) } # Optional. List of trait indices. Typically omitted for young children.
	recessive_traits = { (trait index...) } # Optional. List of trait indices
	inactive_traits = { (trait index...) } # Optional. List of trait indices
	
	# Optional (family_data)
	family_data={
		real_father=(character id) # Optional
		betrothed=(character id) # Optional
		primary_spouse=(character id) # Optional. Equal to one of the spouse ids.
		spouse=(character id) # Optional. First spouse
		spouse=(character id) # Optional. Second spouse
		spouse=(character id) # Optional. Third spouse
		spouse=(character id) # Optional. Fourth spouse
		concubine=(character id) # Optional. First concubine
		concubine=(character id) # Optional. Second concubine
		concubine=(character id) # Optional. Third concubine
		former_spouses={ (character id...) } # Optional. List of character ids
		former_concubines={ (character id...) } # Optional. List of character ids
		former_concubinists={ (character id...) } # Optional. List of character ids
		child = { (character id...) } # Optional. List of character ids
	}

	alive_data={

		# Optional (variables), contains flags
		variables={
			data={
				# (...)
			}
		}

		# Optional (modifiers), various locations in alive_data
		modifier={
			modifier="(modifier)"
			expiration_date=(date)
		}

		gold=(value) # Optional
		income=(value) # Optional
		location=(landed title index) # Optional
		stress=(value) # Optional
		fertility=(value)
		health=(value)
		piety={
			currency=(value)
			accumulated=(value) # Optional. Devotion
		}
		prestige={
			currency=(value) # Optional
			accumulated=(value) # Optional. Fame
		}
		focus={ # Optional
			type="(value)" # Education or lifestyle
			date=(date)
			changes=(value)
			progress=(value)
		}
		secrets= { (id...) } # Optional. List of ids
		targeting_secrets={ (id...) } # Optional. List of ids
		schemes={ (id...) } # Optional. List of ids
		targeting_schemes={ (id...) } # Optional. List of ids
		heir={ (ids...) } # Optional. List of ids
		pretender={ (ids...) } # Optional. List of ids
		claim={ { # Optional. List of claims
			title=(title id)
			pressed=yes # Optional
			}
		}
		used_punishments={ # Optional. List of reasons
			(value)={
				imprisonment_reason=yes # Optional
				revoke_title_reason=yes # Optional
			}
		}
		lifestyle_xp={ # Optional
			diplomacy_lifestyle=(value) # Optional
			martial_lifestyle=(value) # Optional
			stewardship_lifestyle=(value) # Optional
			intrigue_lifestyle=(value) # Optional
			learning_lifestyle=(value) # Optional
		}
		perk={ ... } # Optional. List of perks
		prison_data={ # Optional
			imprisoner=(character id)
			date=(date)
			imprison_type_date=(date)
			type="(value)" # house_arrest or dungeon
		}
		weight_update=(value) # Optional
		kills={ (character ids... } # Optional. List of character ids
		pool_history=(date) # Optional
		wars={ (value) (value) (value) (value) } # Optional
	} # End of alive_data block

	court_data={
		# All keys within this block are optional
		host=(value)
		employer=(character id)
		council_task=(council task index)
		special_council_tasks={ (value...) }
		army=(value)
		regiment=(regiment index)
		knight=yes
		wants_to_leave_court=yes
		leave_court_date=(date)
	}

	# Optional (landed_data)
	landed_data={
		domain={ (landed title index...) } # List of landed title indices
		vassal_contracts={ (values) } # List of values
		units= { (values...) } # Optional
		last_war_finish_date=(date) # Optional
		last_raid=(date) # Optional
		became_ruler_date=(date)
		laws={ "(law id)"... } # List of law ids
		strength=(value)
		strength_for_liege=(value) # Optional
		liege_tax=(value) # Optional
		balance=(value)
		dread=(value) # Optional
		known_schemes={ (ids...) } # Optional. List of ids
		succession={ (character id...) } # List of character ids
		is_powerful_vassal=yes # Optional
		vassal_power_value=(value) # Optional
		domain_limit=(value)
		vassal_limit=(value) # Optional
		vassals_towards_limit=(value) # Optional
		government="(government id)"
		realm_capital=(value)
		ai_allowed_to_marry=yes
		council={ (value...) } # List of values
		at_peace_penalty=(value)
		diplo_centers={ (value...) } # List of values
		election_titles={ (landed title index...) } # List of landed title indices
		absolute_control=yes # Optional
		interaction_cooldowns={ # Optional
			(interaction)=(date)
		}
	} # End of landed_data block

	# Optional (playable_data)
	playable_data={
		knights={ (character id...) } # List of character ids
		was_player=yes
	}

}

dead_unprunable Contains character entries.
characters Contains the following sub-blocks:
  • dead_prunable (contains character entries)
  • prune_queue
  • dummy_female (contains a character entry)
  • dummy_male (contains a character entry)
  • unborn (contains unborn data entries)
  • natural_deaths
  • current_natural_death
  • sexuality_chances
character_lookup
units
activities
opinions Contains the following sub-blocks:
  • active_opinions (contains opinion entries)
relations Encompasses hooks, alliances, Contains the following sub-blocks:
  • active_relations
schemes Contains the following sub-blocks:
  • active (contains scheme entries)
stories Contains the following sub-blocks:
  • active (contains story entries)
  • next=(date) (variable)
pending_character_interactions Contains the following sub-blocks:
  • data
  • player
secrets Contains the following sub-blocks:
  • secrets (contains entries of secrets) (repetition)
    • indices
      • type
      • target
        • type
        • identity=(id)
      • owner=(id)
      • relation_type
      • participants = { (ids)}
  • known_secrets = {
    • secret=(id)
    • owner=(id)
armies Contains the following sub-blocks:
  • regiments
  • army_regiments
  • armies
religion Contains the following sub-blocks:
  • religions
  • faiths
  • great_holy_wars
  • holy_sites
wars Contains the following sub-blocks:
  • active_wars
  • names
sieges Contains the following sub-blocks:
  • sieges (repetition)
raid Contains the following sub-blocks:
  • raid (repetition)
succession
holdings
ai Contains the following sub-blocks:
  • war_coordinator_db
  • war_plan_db
  • ai_stategies
county_manager Contains the following sub-blocks:
  • counties
  • monthly_increase (list of values)
fleet_manager Contains the following sub-blocks:
  • fleets
council_task_manager Contains the following sub-blocks:
  • active
important_action_manager Contains the following sub-blocks:
  • active
faction_manager Contains the following sub-blocks:
  • factions
culture_manager Contains the following sub-blocks:
  • cultures
  • template_cultures (list of numbers)
  • era_discovery
mercenary_company_manager Contains the following sub-blocks:
  • mercenary_companies
holy_orders Contains the following sub-blocks:
  • holy_orders
  • religion_name
  • faith_name
coat_of_arms Contains the following sub-blocks:
  • coat_of_arms_manager_name_map
  • coat_of_arms_manager_database (ends at entry ~17278)
  • next_id=(id) (variable)
(triggered events) Each triggered event has its own block, started using triggered_event={
next_player_event_id=(value) (variable)
played_character Contains the following sub-blocks:
  • name="..." (variable)
  • character=(character id) (variable)
  • player=(value) (variable)
  • important_decisions
  • legacy
  • rally_points
currently_played_characters={ (character id...) } List of character ids.

從Microsoft Store版本中提取文件[編輯 | 編輯原始碼]

你可以用UWPDumper來提取文件。

  1. 下載最新的x64版本的UWPDumper
  2. 打開開發者模式 (Windows設置 ->更新和安全> 開發者選項-> 開發人員模式)。
  3. 運行ck3.
  4. 運行你剛剛下載的UWPInjector.exe.
  5. 輸入ck3.exe旁邊的數字作為processID: ParadoxInteractive.ProjectTitus_zfnrdv2de78ny.
  6. 查看他儲存文件的地址 (可能類似於 C:\Users\%USERPROFILE%\AppData\Local\Packages\ParadoxInteractive.ProjectTitus_zfnrdv2de78ny\TempState\DUMP
  7. 等待程序運行完畢。

之後這些文件就會被放到上面提到的地址處。如果你想修改這些文件,創建一個mod並且把你想改的文件複製進去。

工具與實用程序[編輯 | 編輯原始碼]

  • Paradox Highlight: 一個為CK3和其它Paradox遊戲代碼文件提供語法高亮的VSCode插件。
  • Exporters (Maya and Photoshop)
  • Clausewitz Maya Exporter: 一個可以創建和導出3D模型並且在CK3和其他Clausewitz遊戲中使用的工具。
  • UWPDumper:一個從微軟商店遊戲中提取文件的工具。

外部連結[編輯 | 編輯原始碼]


機制 
角色 角色屬性特質資源生活方式宗族親族文化革新傳統修正寶物
領地與管理 領地封臣內閣宮廷謀略政體法律決議頭銜男爵領伯爵領朝廷建築
戰爭 戰爭宣戰理由同盟軍隊受僱軍隊
信仰 宗教信仰教義核心教義聖地
模組製作補丁可下載內容開發者日誌成就術語