Coat of arms modding

本页面讲述的内容长期有效
咯咯炀讨论 | 贡献2020年10月18日 (日) 22:06的版本 (同步到官方百科 11:30, 20 September 2020‎ Lillebror)

Coat of arms are images used on shields and flags to identify titles, dynasties, and houses.

They are scripted in /Crusader Kings III/common/coat_of_arms/coat_of_arms.

They follow the basic scripting syntax of:

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

Valid keywords

Keyword Comment Example
parent Used for inheritance, read more below. parent = k_england
pattern The path to the file for the background pattern (usually located in /Crusader Kings III/gfx/coat_of_arms/patterns/.
A pattern should be included to avoid graphical issues with the masking textures when using textured emblems.
pattern = "pattern_vertical_split_01"
color1
color2
color3
color4
color5
Specifies a color, to be used in the pattern or as a color reference in colored_emblems.
Usually refers to a color defined in /Crusader Kings III/common/named_colors.
Can also explicitly define RGB, HSV and 8-Digit Hexadecimal values.
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 --- Multiple textured emblems can be specified. Each is itself a scripting object with the following valid keywords: ---
texture The path to the file for the emblem (usually located in /Crusader Kings III/gfx/coat_of_arms/textured_emblems/).
texture = "te_griffin_01.dds"
mask The coat of arms' background pattern can be used as a clipping mask for emblems.
mask = { 1 3 }
instance scale Given as a 2-dim float, has default value { 1.0 1.0 }
instance = { 
	scale = { 0.5 0.5 }  
	position = { 0.75 0.75 } 
	rotation = 45
	depth = 5  
}
position Given as a 2-dim float, has default value { 0.0 0.0 }
rotation Given as float value, has default value 0.0
depth Used to order rendering, given as float value with default of 0.0
colored_emblem --- Multiple colored emblems can be specified. Each is itself a scripting object with the following keywords: ---
texture The path to the file for the emblem (usually located in /Crusader Kings III/gfx/coat_of_arms/colored_emblems/).
texture = "ce_crown.tga"
" All fields from textured_emblem are valid ---
color1 defines the base colour of the emblem
color1 = color2
color2 = "white"
#color3 = hsv360 { 360 50 50 }
color2 defines the secondary color of the emblem (the Green channel in the texture)
color3 currently unavailable, will default to white
sub --- Multiple subs can be specified, each is itself a complete coat of arms scripting object, allowing all fields except another sub, i.e. no sub nesting. ---
instance scale Given as a 2-dim float, has default value { 1.0 1.0 } ---
offset Given as a 2-dim float, has default value { 0.0 0.0 } ---
depth Used to order rendering, given as float value with default of 0.0 ---

Examples

Here follows a few examples with their corresponding coat of arms.

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

Inheritance and subs

This section is largely dedicated towards inheritance, but to facilitate that discussion, first two points on subs:

The first "base coat of arms" is an implicit sub:

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

Each instance field (coat of arms instances, not emblem instances) is transformed into a separate 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
    }
}

With that out of the way, let's dive into inheritance.

Inheritance is achieved through the parent keyword. It basically says "Fetch the coat of arms given as value, and use it to populate any fields not explicitly set".

Example:

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
}

When it comes to emblems the inheritance is "all or nothing": if at least one emblem (of any type) is specified, no emblems are inherited, but if no emblem is specified, all the parent's emblems are inherited.

The inheritance rules become slightly more complicated once subs are involved. The two guiding rules are:

When a parent is specified, all values are fetched from its first sub (which many times will be an "implicit" sub). If a sub doesn't specify a parent it will piggyback on the parent of its first sub. However, in this case all values will be fetched from the corresponding sub in the parent. Setting parent = "none" disables this automatic inheritance. Example:

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"
    }
}

Inheritance chains ("deep inheritance") is resolved in a bottom up manner. Users must take care not to create inheritance loops.

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
    }
}

And finally, a real example:

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
    }
}