Coat of arms modding

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

盾徽Coat of arms)是用於盾牌和旗幟,識別頭銜、宗族和家族的圖像。

定義它們的腳本位於/Crusader Kings III/common/coat_of_arms/coat_of_arms

它們遵循以下的基本腳本語法:

coat_of_arms_name = {
    keyword1 = value1
    keyword2 = value2
    ...
}

如果 "coat_of_arms_name" 與稱號、家族或王朝的鍵名相同(例如 "d_leon" ),遊戲將在遊戲開始時自動使用該紋章作為默認佈局。這也適用於修改過的稱號、家族或王朝。

有效鍵值[編輯 | 編輯原始碼]

鍵值 注釋 舉例
parent 用於繼承,閱讀下文了解更多信息。 parent = k_england
pattern 背景圖案文件的路徑(通常位於 /Crusader Kings III/gfx/coat_of_arms/patterns/.
)。應包含一個圖案,以避免在使用紋理紋章時出現圖形問題。.
pattern = "pattern_vertical_split_01"
color1
color2
color3
color4
color5
指定一種顏色,用於圖案或作為有色徽章中的顏色參考。
通常是指在 /Crusader Kings III/common/named_colors
中定義的顏色。還可以顯式定義RGB、HSV和8位十六進制值。
color1 = "white"
color2 = hsv { 1.0 1.0 1.0 }
color3 = hsv360 { 360 100 100 }
color4 = rgb { 255 255 255 }
color5 = hex { aabbccdd }
textured_emblem --- 可以指定多個紋理標誌。每個標誌本身是一個腳本對象,具有以下有效關鍵字: ---
texture 徽章文件的路徑(通常位於/Crusader Kings III/gfx/coat_of_arms/textured_emblems/中)。
texture = "te_griffin_01.dds"
mask 徽章的背景圖案可用作徽標的剪貼蒙版。
mask = { 1 3 }
instance scale 作為一個二維浮點數,具有默認值 { 1.0, 1.0 }。
instance = { 
	scale = { 0.5 0.5 }  
	position = { 0.75 0.75 } 
	rotation = 45
	depth = 5  
}
position 給定一個二維浮點數,具有默認值 { 0.0, 0.0 }。
rotation 給定為浮點數值,具有默認值0.0。
depth 用於指定渲染順序的值,以浮點數表示,默認為0.0。
colored_emblem --- 可以指定多個彩色標記。每個標記本身是一個帶有以下關鍵字的腳本對象: ---
texture 徽章文件的路徑(通常位於/Crusader Kings III/gfx/coat_of_arms/colored_emblems/)。
texture = "ce_crown.tga"
" 所有來自 textured_emblem 的字段都是有效的。 ---
color1 定義了徽章的基本顏色
color1 = color2
color2 = "white"
#color3 = hsv360 { 360 50 50 }
color2 定義了徽標的輔助顏色(紋理中的綠色通道)
color3 目前不可用,將默認為白色。
sub --- 可以指定多個子對象,每個子對象本身都是一個完整的家族紋章腳本對象,允許設置除另一個子對象以外的所有字段,即不支持嵌套子對象。 ---
instance scale 作為一個二維浮點數,具有默認值 { 1.0, 1.0 }。 ---
offset 給定一個二維浮點數,具有默認值 { 0.0, 0.0 }。 ---
depth 用於指定渲染順序的值,以浮點數表示,默認為0.0。 ---

例子[編輯 | 編輯原始碼]

下面是一些帶有相應盾徽的例子。

flag_with_emblem = {
    pattern = "pattern_vertical_split_01"
    color1 = "lemon_yellow"
    color2 = "sky_blue"
 
    textured_emblem = {
        texture = "te_griffin_01"
    }
}
flag_with_culled_emblem = {
    pattern = "pattern_vertical_split_01"
    color1 = "lemon_yellow"
    color2 = "sky_blue"
 
    textured_emblem = {
        texture = "te_griffin_01"
        mask = { 1 }
    }
}
two_emblems_scaled_and_positioned = {
    pattern = "pattern_vertical_split_01"
    color1 = "lemon_yellow"
    color2 = "sky_blue"
 
    textured_emblem = {
        texture = "te_griffin_01"
        instance = { position = { 0.75 0.75 } scale = { 0.5 0.5 }  }
        instance = { position = { 0.75 0.25 } scale = { 0.5 0.5 }  }
    }
}

Emblem examples.png

繼承和子類[編輯 | 編輯原始碼]

這一部分主要關注繼承問題,但為了促進討論,首先談論一下子類的兩個要點:

第一個"基本家族紋章"是一個隱含的子類:

a = {
    pattern = "pattern_solid.tga"
    color1 = "blue"
    sub = { }
}
# the above is equal to:
b = {
    sub = {
        pattern = "pattern_solid.tga"
        color1 = "blue"
    }
    sub = { }
}

每個實例字段(家族紋章實例,而不是徽標實例)都被轉化為一個獨立的子級:

a = {
    color1 = "blue"
    instance = { offset = { 0 0 } } # A
    instance = { offset = { 1 0 } } # B
    sub {
        color1 = "red"
        instance = { offset= { 0 1 } } # C
        instance = { offset = { 1 1 } } # D
    }
}
# the above is equal to:
b = {
    sub = {
        color1 = "blue"
        instance = { offset = { 0 0 } } # A
    }
    sub = {
        color1 = "blue"
        instance = { offset = { 1 0 } } # B
    }
    sub {
        color1 = "red"
        instance = { offset = { 0 1 } } # C
    }
    sub {
        color1 = "red"
        instance = { offset = { 1 1 } } # D
    }
}

說了這些,讓我們深入探討繼承。

繼承是通過父關鍵字實現的。它基本上表示「取出給定的家族紋章作為值,並用它來填充任何未明確設置的字段」。

舉例:

daddy = {
    pattern = "pattern_checkers_01.tga"
    color1 = "burned_red"
    color2 = "mid_grey"
    colored_emblem = {
        texture = "ce_angel.dds"
        color1 = "rust_brown"
        color2 = "rust_brown"
    }
}
 
child = {
    parent = "daddy"
    pattern = "pattern_checkers_diagonal_01.tga"
    color1 = "mint_green"
    # >color2 = "mid_grey"<        inherited
    # >colored_emblem = { ... }<   inherited
}

當談到徽章時,繼承是"全有或全無"的:如果至少指定一個徽章(任何類型),則不繼承任何徽章,但如果沒有指定徽章,則繼承所有父級的徽章。

一旦涉及到子級,繼承規則會稍微複雜一些。有兩個指導規則:

當指定了一個父級時,所有值都從其第一個子級(通常是"隱式"子級)獲取。

如果一個子級沒有指定父級,它將依附於其第一個子級的父級。然而,在這種情況下,所有值將從父級中相應的子級獲取。設置父級為"none"將禁用此自動繼承。

示例:

daddy = {
    pattern = "pattern_solid.tga"
    sub = { }
    sub = { }
}
 
child = {
    parent = "daddy"
    # this implicit sub inherits from the implicit sub in daddy
    sub = {
        # Since no parent is specified this sub will piggyback on >parent = "daddy"< and inherit from the second sub of "daddy".
    }
    sub = {
        parent = "other_coa"
        # since parent is specified explicitly this will inherit from first sub of "other_coa"
    }
}

繼承鏈("深度繼承")是以自下而上的方式解決的。必須小心,不要創建繼承循環。

grand_dad = {
    pattern = "pattern_solid.tga"
    sub = { }
}
 
daddy = {
    parent = "grand_dad"
    # >pattern = "pattern_solid.tga"< inherited
    color1 = "blue"
    # >sub = { }< inherited
}
 
child = {
    parent = "daddy"
    # >pattern = "pattern_solid.tga"< inherited
    # >color1 = "blue"< inherited
    sub = {
        # this inherits from the second sub in daddy
    }
    sub = {
        # since daddy only has 2 subs, this has no parent
    }
}

最後,一個真實的例子:

k_england_and_france = {
    sub = {
        parent = "k_france"  # defined elsewhere
        instance = { offset = { 0.0 0.0 } scale = { 0.5 0.5 }  } # top left
        instance = { offset = { 0.5 0.5 } scale = { 0.5 0.5 }  } # bottom right
    }
    sub = {
        parent = "k_england"  # defined elsewhere
        instance = { offset = { 0.5 0.0 } scale = { 0.5 0.5 }  } # top right
        instance = { offset = { 0.0 0.5 } scale = { 0.5 0.5 }  } # bottom left
    }
}

輕鬆使用遊戲內設計器[編輯 | 編輯原始碼]

與皇家宮廷DLC一同,P社還開發了一款便捷的內置編輯器,可用於直接將創建的盾徽導出為有效的腳本代碼。您只需使用設計器創建所需的盾徽,然後按下「複製到剪貼板」即可。遊戲將在使用的計算機的臨時存儲器中創建完整且有效的盾徽所需代碼。 然後,您可以使用CTRL+V鍵組合直接將其插入到相應的修改文件的文本中。您只需確保設置正確的名稱(例如k_england)。 修改者還可以在此處使用一個小技巧,暫時刪除本地化文件;這樣,CK無法加載標題的名稱,而是在遊戲中顯示標題對應的關鍵字。 玩家也可以通過盾徽設計師更改標題名稱,或者在這種情況下,簡單地複製關鍵字並將其粘貼到適當的文件中。通過這種方式,您可以避免後續可能導致盾徽未在遊戲中顯示的拼寫錯誤。

在這一點上需要再次強調,由於動態盾徽,可能會存在多個盾徽,因此它們的名稱可能不直接與標題密鑰匹配。因此,CK解釋器無法識別拼寫錯誤,也不會發出錯誤消息。如果自製的盾徽未顯示出來,應當再次明確檢查其正確的字符精確拼寫。

進階盾徽設計器[編輯 | 編輯原始碼]

默認情況下,CoA Designer僅顯示原始遊戲的徽章。然而,擴展列表非常簡單。要做到這一點,只需將更多的dds文件添加到<mod_root>\gfx\coat_of_arms\colored_emblems\文件夾中 - 如本頁已描述。此外,您現在可以在同一位置創建一個文本文件(一如既往地採用UTF-8 BOM編碼)。在文本文件中,您可以為每個您想在設計師中提供的徽章創建一個單獨的行,使用以下語法:

<pic_name>.dds = { colors = <1,2,3> category = <string> }

圖像的名稱必須與同一文件夾中的圖像文件完全匹配。

您可以將<1、2或3>指定為顏色選項。這指定了用戶可以為所選紋章設置多少種顏色。對此,.dds 圖像文件起決定性作用。 遊戲會自動將

  1. 顏色值 0x000084(藍色)識別為顏色
  2. 顏色值 0x00FF94(淺綠色)識別為顏色
  3. 顏色值 0xFF0084(品紅色)識別為顏色
  4. CK 具有一定的容差,並試圖將其他不同的顏色匹配到這些顏色值之一。

然而,這種校正並不完美,不能完全依賴;製作模組的人應始終確保使用正確的顏色。如果您在相應的文件中設置的值大於實際使用的顏色數,用戶將獲得一個更多的顏色顯示,但不會出錯。然而,如果製作模組的人在文本文件中指定的顏色數過少,自動校正將嘗試將太多的顏色減少到一種顏色(如果它們足夠相似),或者簡單地將未知顏色設置為紅褐色調,這不能由設計人員用戶更改。

遊戲原本支持以下類別之一:動物、圓圈和螺旋、十字和紐結、信仰、人造、自然、圖案、部落印章、文字和圖形。如果使用其他字符串,遊戲將為用戶添加一個新的可選擇類別。由於類別名稱顯示為文本,因此還應為新類別添加一個本地化條目(COA_DESIGNER_CATEGORY_<your_category_string_here>:0 "<您想要在所选语言中显示的类别名称>")。

設計器的缺點[編輯 | 編輯原始碼]

與手動編碼一個紋章對應盾徽相比,設計器可能在直觀上更容易使用,但設計師無法用於繼承或細分紋章。如上所示的真實示例,將英國和法國的紋章放在一起,實際上無法使用設計器創建。甚至包含卡斯蒂利亞、萊昂、阿拉貢、納瓦拉和西西里的歐陸風雲4(EU4)中的西班牙國旗也無法使用設計師重新創建。然而,設計器中的一個可以幫助創建基礎紋章,所以之後您只需要手動編寫繼承關係。

動態盾徽[編輯 | 編輯原始碼]

除了為任何給定的頭銜分配的正常紋章外,您還可以創建動態紋章定義,這些定義存儲在 /Crusader Kings III/\common\coat_of_arms\dynamic_definitions\ 中:

# Name must match a landed title definition
title_name = {
	item = { # One or more items
		trigger = { # 触发条件,当应该选择此项时,选择第一个有效项, root = the title
			<trigger> # 这可以是任何预定义的触发器,或者像正常情况下那样内联定义的触发器。
		}
		coat_of_arms = name # 作为纹章文件中定义的纹章名称使用
	}
}

為了更新紋章,您需要在頭銜範圍內調用update_dynamic_coa = yes。 在所有擁有的頭銜中,這已經在on_character_culture_changeon_character_faith_change中被調用,但是如果您希望在其他任何情況下更新動態紋章,您需要根據on_actions