﻿# Using code from Silk Road mod: https://steamcommunity.com/workshop/filedetails/?id=2493459927

line_mapping_dynasty_map = {

	save_scope_as = player_character

	every_county = {
		if = {
			limit = { 
				holder = {
					OR = { 
						has_trait_rank = {
							trait = linefounder
							rank > 0
						}

						has_trait_rank = {
							trait = dynastylineages
							rank > 0
						}
					}
				}
			}
			if = {
				limit = { 
					exists = scope:player_character 
					holder = scope:player_character 
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_independent_01	##	my county
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = linefounder
												rank > 0
											}
					
											has_trait_rank = {
												trait = dynastylineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_01	##	my county, but my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_01    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_independent_01	##	my county
							}
						}
					}
				}
			}
			else = {
				if = {
					limit = {
						exists = scope:player_character 
						holder = { any_liege_or_above = { this = scope:player_character } } 
					}
					every_county_province = {
						barony = {
							if = {
								limit = { title_province = { has_holding = no } }
								set_color_from_title = title:d_line_map_dynasty_01	## my realm, my dynasty domain
							}
							else = {
								if = {
									limit = {
										holder = {
											primary_title = prev
											OR = { 
												has_trait_rank = {
													trait = linefounder
													rank > 0
												}
						
												has_trait_rank = {
													trait = dynastylineages
													rank > 0
												}
											}
										}
									}
									set_color_from_title = title:d_line_map_dynasty_barony_01	## my realm, my dynasty, my dynasty barony
								}
								else_if = {
									limit = { title_province = { has_special_building_slot = yes } }
									set_color_from_title = title:d_line_map_dynasty_special_01    ## special building
								}
								else = {
									set_color_from_title = title:d_line_map_dynasty_01	## my realm, my dynasty domain
								}
							}
						}
					}
				}
				else = {
					if = {
						limit = { holder = { is_independent_ruler = yes } }
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_independent_02	##my dynasty domain, top liege
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait_rank = {
														trait = linefounder
														rank > 0
													}
							
													has_trait_rank = {
														trait = dynastylineages
														rank > 0
													}
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_02	##my dynasty domain, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_02    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_independent_02	##my dynasty domain, top liege
									}
								}
							}
						}
					}
					else = {
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_02	##my dynasty domain
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait_rank = {
														trait = linefounder
														rank > 0
													}
							
													has_trait_rank = {
														trait = dynastylineages
														rank > 0
													}
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_02	##my dynasty domain, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_02    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_02	##my dynasty domain
									}
								}
							}
						}
					}
				}
			}
		}
		else = {
			# Liege has trait (and is player)
			if = {
				limit = { 
					holder = { 
						any_liege_or_above = {
							AND = {
								exists = scope:player_character 
								this = scope:player_character 
								OR = { 
									has_trait_rank = {
										trait = linefounder
										rank > 0
									}
			
									has_trait_rank = {
										trait = dynastylineages
										rank > 0
									}
								}
							}
						} 
					} 
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_realm_01	##my realm
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = linefounder
												rank > 0
											}
					
											has_trait_rank = {
												trait = dynastylineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_01	##my realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_01    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_realm_01	##my realm
							}
						}
					}
				}
			}
			# Liege has trait (and is not player)
			else_if = {
				limit = { 
					holder = { 
						any_liege_or_above = { 
							OR = { 
								has_trait_rank = {
									trait = linefounder
									rank > 0
								}
		
								has_trait_rank = {
									trait = dynastylineages
									rank > 0
								}
							}
						}
					}	
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_realm_02	##my dynasty realm
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = linefounder
												rank > 0
											}
					
											has_trait_rank = {
												trait = dynastylineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_02	##my dynasty realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_02    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_realm_02	##my dynasty realm
							}
						}
					}
				}
			}
			# [NEW] Spouse has trait
			else_if = {
				limit = { 
					holder = {
						any_spouse = {
							OR = { 
								has_trait_rank = {
									trait = linefounder
									rank > 0
								}
								has_trait_rank = {
									trait = dynastylineages
									rank > 0
								}
							}
						}
					}
				}
				if = {
					limit = {
						exists = holder.primary_spouse
						holder.primary_spouse = {
							OR = { 
								has_trait_rank = {
									trait = linefounder
									rank > 0
								}
		
								has_trait_rank = {
									trait = dynastylineages
									rank > 0
								}
							}
						}
					}
					if = {
						limit = {
							holder.primary_spouse = {
								is_female = yes
							}
						}
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_05	## my realm, my dynasty domain
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait_rank = {
														trait = linefounder
														rank > 0
													}
							
													has_trait_rank = {
														trait = dynastylineages
														rank > 0
													}
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_05	## my realm, my dynasty, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_05    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_05	## my realm, my dynasty domain
									}
								}
							}
						}
					}
					else = {
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_03	## my realm, my dynasty domain
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait_rank = {
														trait = linefounder
														rank > 0
													}
							
													has_trait_rank = {
														trait = dynastylineages
														rank > 0
													}
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_03	## my realm, my dynasty, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_03    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_03	## my realm, my dynasty domain
									}
								}
							}
						}
					}
				}
				# ANy spouse has trait
				else = {
					# Any spouse is female
					if = {
						limit = {
							holder = {
								any_spouse = {
									is_female = yes
									OR = { 
										has_trait_rank = {
											trait = linefounder
											rank > 0
										}
				
										has_trait_rank = {
											trait = dynastylineages
											rank > 0
										}
									}
								}
							}
						}
						if = {
							limit = { holder = { is_independent_ruler = yes } }
							every_county_province = {
								barony = {
									if = {
										limit = { title_province = { has_holding = no } }
										set_color_from_title = title:d_line_map_dynasty_independent_06	##my dynasty domain, top liege
									}
									else = {
										if = {
											limit = {
												holder = {
													primary_title = prev
													OR = { 
														has_trait_rank = {
															trait = linefounder
															rank > 0
														}
								
														has_trait_rank = {
															trait = dynastylineages
															rank > 0
														}
													}
												}
											}
											set_color_from_title = title:d_line_map_dynasty_barony_06	##my dynasty domain, my dynasty barony
										}
										else_if = {
											limit = { title_province = { has_special_building_slot = yes } }
											set_color_from_title = title:d_line_map_dynasty_special_06    ## special building
										}
										else = {
											set_color_from_title = title:d_line_map_dynasty_independent_06	##my dynasty domain, top liege
										}
									}
								}
							}
						}
						else = {
							every_county_province = {
								barony = {
									if = {
										limit = { title_province = { has_holding = no } }
										set_color_from_title = title:d_line_map_dynasty_06	##my dynasty domain
									}
									else = {
										if = {
											limit = {
												holder = {
													primary_title = prev
													OR = { 
														has_trait_rank = {
															trait = linefounder
															rank > 0
														}
								
														has_trait_rank = {
															trait = dynastylineages
															rank > 0
														}
													}
												}
											}
											set_color_from_title = title:d_line_map_dynasty_barony_06	##my dynasty domain, my dynasty barony
										}
										else_if = {
											limit = { title_province = { has_special_building_slot = yes } }
											set_color_from_title = title:d_line_map_dynasty_special_06    ## special building
										}
										else = {
											set_color_from_title = title:d_line_map_dynasty_06	##my dynasty domain
										}
									}
								}
							}
						}
					}
					# Any spouse is male
					else = {
						if = {
							limit = { holder = { is_independent_ruler = yes } }
							every_county_province = {
								barony = {
									if = {
										limit = { title_province = { has_holding = no } }
										set_color_from_title = title:d_line_map_dynasty_independent_04	##my dynasty domain, top liege
									}
									else = {
										if = {
											limit = {
												holder = {
													primary_title = prev
													OR = { 
														has_trait_rank = {
															trait = linefounder
															rank > 0
														}
								
														has_trait_rank = {
															trait = dynastylineages
															rank > 0
														}
													}
												}
											}
											set_color_from_title = title:d_line_map_dynasty_barony_04	##my dynasty domain, my dynasty barony
										}
										else_if = {
											limit = { title_province = { has_special_building_slot = yes } }
											set_color_from_title = title:d_line_map_dynasty_special_04    ## special building
										}
										else = {
											set_color_from_title = title:d_line_map_dynasty_independent_04	##my dynasty domain, top liege
										}
									}
								}
							}
						}
						else = {
							every_county_province = {
								barony = {
									if = {
										limit = { title_province = { has_holding = no } }
										set_color_from_title = title:d_line_map_dynasty_04	##my dynasty domain
									}
									else = {
										if = {
											limit = {
												holder = {
													primary_title = prev
													OR = { 
														has_trait_rank = {
															trait = linefounder
															rank > 0
														}
								
														has_trait_rank = {
															trait = dynastylineages
															rank > 0
														}
													}
												}
											}
											set_color_from_title = title:d_line_map_dynasty_barony_04	##my dynasty domain, my dynasty barony
										}
										else_if = {
											limit = { title_province = { has_special_building_slot = yes } }
											set_color_from_title = title:d_line_map_dynasty_special_04    ## special building
										}
										else = {
											set_color_from_title = title:d_line_map_dynasty_04	##my dynasty domain
										}
									}
								}
							}
						}
					}
				}
			}
			# No traits
			else = {
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_base	##base
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = linefounder
												rank > 0
											}
					
											has_trait_rank = {
												trait = dynastylineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_02	##not my realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_special_building    ## special building
							}
							else_if = {
								limit = { is_under_holy_order_lease = yes }
								set_color_from_title = title:d_line_map_holy_order   ## holy order
							}
							else = {
								set_color_from_title = title:d_line_map_base	##base
							}
						}
					}
				}
			}
		}
	}

}

line_mapping_patrilineage_map = {
	
	save_scope_as = player_character

	every_county = {
		if = {
			limit = { 
				holder = {
					OR = { 
						has_trait_rank = {
							trait = patrilinefounder
							rank > 0
						}
						has_trait_rank = {
							trait = patrilineages
							rank > 0
						}
					}
				}
			}
			if = {
				limit = {
					exists = scope:player_character 
					holder = scope:player_character 
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_independent_03	##	my county
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = patrilinefounder
												rank > 0
											}
					
											has_trait_rank = {
												trait = patrilineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_03	##	my county, but my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_03    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_independent_03	##	my county
							}
						}
					}
				}
			}
			else = {
				if = {
					limit = {
						exists = scope:player_character 
						holder = { any_liege_or_above = { this = scope:player_character } } 
					}
					every_county_province = {
						barony = {
							if = {
								limit = { title_province = { has_holding = no } }
								set_color_from_title = title:d_line_map_dynasty_03	## my realm, my dynasty domain
							}
							else = {
								if = {
									limit = {
										holder = {
											primary_title = prev
											OR = { 
												has_trait_rank = {
													trait = patrilinefounder
													rank > 0
												}
						
												has_trait_rank = {
													trait = patrilineages
													rank > 0
												}
											}
										}
									}
									set_color_from_title = title:d_line_map_dynasty_barony_03	## my realm, my dynasty, my dynasty barony
								}
								else_if = {
									limit = { title_province = { has_special_building_slot = yes } }
									set_color_from_title = title:d_line_map_dynasty_special_03    ## special building
								}
								else = {
									set_color_from_title = title:d_line_map_dynasty_03	## my realm, my dynasty domain
								}
							}
						}
					}
				}
				else = {
					if = {
						limit = { holder = { is_independent_ruler = yes } }
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_independent_04	##my dynasty domain, top liege
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait_rank = {
														trait = patrilinefounder
														rank > 0
													}
							
													has_trait_rank = {
														trait = patrilineages
														rank > 0
													}
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_04	##my dynasty domain, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_04    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_independent_04	##my dynasty domain, top liege
									}
								}
							}
						}
					}
					else = {
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_04	##my dynasty domain
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait_rank = {
														trait = patrilinefounder
														rank > 0
													}
							
													has_trait_rank = {
														trait = patrilineages
														rank > 0
													}
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_04	##my dynasty domain, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_04    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_04	##my dynasty domain
									}
								}
							}
						}
					}
				}
			}
		}
		else = {
			if = {
				limit = { 
					holder = { 
						any_liege_or_above = {
							AND = {
								exists = scope:player_character 
								this = scope:player_character 
								OR = { 
									has_trait_rank = {
										trait = patrilinefounder
										rank > 0
									}
			
									has_trait_rank = {
										trait = patrilineages
										rank > 0
									}
								}
							}
						} 
					} 
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_realm_03	##my realm
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = patrilinefounder
												rank > 0
											}
					
											has_trait_rank = {
												trait = patrilineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_03	##my realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_03    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_realm_03	##my realm
							}
						}
					}
				}
			}
			else_if = {
				limit = { 
					holder = { 
						any_liege_or_above = { 
							OR = { 
								has_trait_rank = {
									trait = patrilinefounder
									rank > 0
								}
		
								has_trait_rank = {
									trait = patrilineages
									rank > 0
								}
							}
						}
					}	
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_realm_04	##my dynasty realm
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = patrilinefounder
												rank > 0
											}
					
											has_trait_rank = {
												trait = patrilineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_04	##my dynasty realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_04    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_realm_04	##my dynasty realm
							}
						}
					}
				}
			}
			else = {
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_base	##base
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = patrilinefounder
												rank > 0
											}
					
											has_trait_rank = {
												trait = patrilineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_04	##not my realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_special_building    ## special building
							}
							else_if = {
								limit = { is_under_holy_order_lease = yes }
								set_color_from_title = title:d_line_map_holy_order   ## holy order
							}
							else = {
								set_color_from_title = title:d_line_map_base	##base
							}
						}
					}
				}
			}
		}
	}

}

line_mapping_matrilineage_map = {
	
	save_scope_as = player_character

	every_county = {
		if = {
			limit = { 
				holder = {
					OR = { 
						has_trait_rank = {
							trait = matrilinefounder
							rank > 0
						}

						has_trait_rank = {
							trait = matrilineages
							rank > 0
						}
					}
				}
			}
			if = {
				limit = {
					exists = scope:player_character 
					holder = scope:player_character 
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_independent_05	##	my county
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = matrilinefounder
												rank > 0
											}
					
											has_trait_rank = {
												trait = matrilineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_05	##	my county, but my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_05    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_independent_05	##	my county
							}
						}
					}
				}
			}
			else = {
				if = {
					limit = {
						exists = scope:player_character 
						holder = { any_liege_or_above = { this = scope:player_character } } 
					}
					every_county_province = {
						barony = {
							if = {
								limit = { title_province = { has_holding = no } }
								set_color_from_title = title:d_line_map_dynasty_05	## my realm, my dynasty domain
							}
							else = {
								if = {
									limit = {
										holder = {
											primary_title = prev
											OR = { 
												has_trait_rank = {
													trait = matrilinefounder
													rank > 0
												}
						
												has_trait_rank = {
													trait = matrilineages
													rank > 0
												}
											}
										}
									}
									set_color_from_title = title:d_line_map_dynasty_barony_05	## my realm, my dynasty, my dynasty barony
								}
								else_if = {
									limit = { title_province = { has_special_building_slot = yes } }
									set_color_from_title = title:d_line_map_dynasty_special_05    ## special building
								}
								else = {
									set_color_from_title = title:d_line_map_dynasty_05	## my realm, my dynasty domain
								}
							}
						}
					}
				}
				else = {
					if = {
						limit = { holder = { is_independent_ruler = yes } }
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_independent_06	##my dynasty domain, top liege
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait_rank = {
														trait = matrilinefounder
														rank > 0
													}
							
													has_trait_rank = {
														trait = matrilineages
														rank > 0
													}
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_06	##my dynasty domain, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_06    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_independent_06	##my dynasty domain, top liege
									}
								}
							}
						}
					}
					else = {
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_06	##my dynasty domain
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait_rank = {
														trait = matrilinefounder
														rank > 0
													}
							
													has_trait_rank = {
														trait = matrilineages
														rank > 0
													}
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_06	##my dynasty domain, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_06    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_06	##my dynasty domain
									}
								}
							}
						}
					}
				}
			}
		}
		else = {
			if = {
				limit = { 
					holder = { 
						any_liege_or_above = {
							AND = {
								exists = scope:player_character 
								this = scope:player_character 
								OR = { 
									has_trait_rank = {
										trait = matrilinefounder
										rank > 0
									}
			
									has_trait_rank = {
										trait = matrilineages
										rank > 0
									}
								}
							}
						} 
					} 
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_realm_05	##my realm
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = matrilinefounder
												rank > 0
											}
					
											has_trait_rank = {
												trait = matrilineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_05	##my realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_05    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_realm_05	##my realm
							}
						}
					}
				}
			}
			else_if = {
				limit = { 
					holder = { 
						any_liege_or_above = { 
							OR = { 
								has_trait_rank = {
									trait = matrilinefounder
									rank > 0
								}
		
								has_trait_rank = {
									trait = matrilineages
									rank > 0
								}
							}
						}
					}	
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_realm_06	##my dynasty realm
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = matrilinefounder
												rank > 0
											}
					
											has_trait_rank = {
												trait = matrilineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_06	##my dynasty realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_06    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_realm_06	##my dynasty realm
							}
						}
					}
				}
			}
			else = {
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_base	##base
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = matrilinefounder
												rank > 0
											}
					
											has_trait_rank = {
												trait = matrilineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_06	##not my realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_special_building    ## special building
							}
							else_if = {
								limit = { is_under_holy_order_lease = yes }
								set_color_from_title = title:d_line_map_holy_order   ## holy order
							}
							else = {
								set_color_from_title = title:d_line_map_base	##base
							}
						}
					}
				}
			}
		}
	}
}

line_mapping_family_map = {
	
	save_scope_as = player_character

	every_county = {
		if = {
			limit = { 
				holder = {
					OR = { 
						has_trait = self_family_mark
						has_trait = close_family_mark
						has_trait = extended_family_mark
						has_trait = super_extended_family_mark
					}
				}
			}
			if = {
				limit = { 
					exists = scope:player_character 
					holder = scope:player_character 
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_independent_07	##	my county
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait = self_family_mark
											has_trait = close_family_mark
											has_trait = extended_family_mark
											has_trait = super_extended_family_mark
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_07	##	my county, but my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_07    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_independent_07	##	my county
							}
						}
					}
				}
			}
			else = {
				if = {
					limit = { 
						exists = scope:player_character 
						holder = { any_liege_or_above = { this = scope:player_character } } 
					}
					every_county_province = {
						barony = {
							if = {
								limit = { title_province = { has_holding = no } }
								set_color_from_title = title:d_line_map_dynasty_07	## my realm, my dynasty domain
							}
							else = {
								if = {
									limit = {
										holder = {
											primary_title = prev
											OR = { 
												has_trait = self_family_mark
												has_trait = close_family_mark
												has_trait = extended_family_mark
												has_trait = super_extended_family_mark
											}
										}
									}
									set_color_from_title = title:d_line_map_dynasty_barony_07	## my realm, my dynasty, my dynasty barony
								}
								else_if = {
									limit = { title_province = { has_special_building_slot = yes } }
									set_color_from_title = title:d_line_map_dynasty_special_07    ## special building
								}
								else = {
									set_color_from_title = title:d_line_map_dynasty_07	## my realm, my dynasty domain
								}
							}
						}
					}
				}
				else = {
					if = {
						limit = { holder = { is_independent_ruler = yes } }
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_independent_08	##my dynasty domain, top liege
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait = self_family_mark
													has_trait = close_family_mark
													has_trait = extended_family_mark
													has_trait = super_extended_family_mark
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_08	##my dynasty domain, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_08    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_independent_08	##my dynasty domain, top liege
									}
								}
							}
						}
					}
					else = {
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_08	##my dynasty domain
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait = self_family_mark
													has_trait = close_family_mark
													has_trait = extended_family_mark
													has_trait = super_extended_family_mark
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_08	##my dynasty domain, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_08    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_08	##my dynasty domain
									}
								}
							}
						}
					}
				}
			}
		}
		else = {
			if = {
				limit = { 
					holder = { 
						any_liege_or_above = {
							AND = {
								exists = scope:player_character 
								this = scope:player_character 
								OR = { 
									has_trait = self_family_mark
									has_trait = close_family_mark
									has_trait = extended_family_mark
									has_trait = super_extended_family_mark
								}
							}
						} 
					} 
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_realm_07	##my realm
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait = self_family_mark
											has_trait = close_family_mark
											has_trait = extended_family_mark
											has_trait = super_extended_family_mark
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_07	##my realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_07    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_realm_07	##my realm
							}
						}
					}
				}
			}
			else_if = {
				limit = { 
					holder = { 
						any_liege_or_above = { 
							OR = { 
								has_trait = self_family_mark
								has_trait = close_family_mark
								has_trait = extended_family_mark
								has_trait = super_extended_family_mark
							}
						}
					}	
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_realm_08	##my dynasty realm
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait = self_family_mark
											has_trait = close_family_mark
											has_trait = extended_family_mark
											has_trait = super_extended_family_mark
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_08	##my dynasty realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_08    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_realm_08	##my dynasty realm
							}
						}
					}
				}
			}
			else = {
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_base	##base
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait = self_family_mark
											has_trait = close_family_mark
											has_trait = extended_family_mark
											has_trait = super_extended_family_mark
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_08	##not my realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_special_building    ## special building
							}
							else_if = {
								limit = { is_under_holy_order_lease = yes }
								set_color_from_title = title:d_line_map_holy_order   ## holy order
							}
							else = {
								set_color_from_title = title:d_line_map_base	##base
							}
						}
					}
				}
			}
		}
	}
}

line_mapping_lineage_map = { # needs LINE

	every_county = {
		if = {
			limit = { 
				holder = {
					OR = { 
						has_trait_rank = {
							trait = $LINE$linefounder
							rank > 0
						}
						has_trait_rank = {
							trait = $LINE$lineages
							rank > 0
						}
					}
				}
			}
			if = {
				limit = { 
					holder = {
						has_trait_rank = {
							trait = $LINE$linefounder
							rank > 0
						}
					}
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_independent_01	##	my county
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = $LINE$linefounder
												rank > 0
											}
											has_trait_rank = {
												trait = $LINE$lineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_01	##	my county, but my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_01    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_independent_01	##	my county
							}
						}
					}
				}
			}
			else = {
				if = {
					limit = {
						holder = { 
							any_liege_or_above = {
								has_trait_rank = {
									trait = $LINE$linefounder
									rank > 0
								}
							} 
						} 
					}
					every_county_province = {
						barony = {
							if = {
								limit = { title_province = { has_holding = no } }
								set_color_from_title = title:d_line_map_dynasty_01	## my realm, my dynasty domain
							}
							else = {
								if = {
									limit = {
										holder = {
											primary_title = prev
											OR = { 
												has_trait_rank = {
													trait = $LINE$linefounder
													rank > 0
												}
												has_trait_rank = {
													trait = $LINE$lineages
													rank > 0
												}
											}
										}
									}
									set_color_from_title = title:d_line_map_dynasty_barony_01	## my realm, my dynasty, my dynasty barony
								}
								else_if = {
									limit = { title_province = { has_special_building_slot = yes } }
									set_color_from_title = title:d_line_map_dynasty_special_01    ## special building
								}
								else = {
									set_color_from_title = title:d_line_map_dynasty_01	## my realm, my dynasty domain
								}
							}
						}
					}
				}
				else = {
					if = {
						limit = { holder = { is_independent_ruler = yes } }
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_independent_02	##my dynasty domain, top liege
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait_rank = {
														trait = $LINE$linefounder
														rank > 0
													}
													has_trait_rank = {
														trait = $LINE$lineages
														rank > 0
													}
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_02	##my dynasty domain, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_02    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_independent_02	##my dynasty domain, top liege
									}
								}
							}
						}
					}
					else = {
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_02	##my dynasty domain
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait_rank = {
														trait = $LINE$linefounder
														rank > 0
													}
													has_trait_rank = {
														trait = $LINE$lineages
														rank > 0
													}
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_02	##my dynasty domain, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_02    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_02	##my dynasty domain
									}
								}
							}
						}
					}
				}
			}
		}
		else = {
			# Liege has trait (and is player)
			if = {
				limit = { 
					holder = { 
						any_liege_or_above = {
							has_trait_rank = {
								trait = $LINE$linefounder
								rank > 0
							}
						} 
					} 
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_realm_01	##my realm
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = $LINE$linefounder
												rank > 0
											}
											has_trait_rank = {
												trait = $LINE$lineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_01	##my realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_01    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_realm_01	##my realm
							}
						}
					}
				}
			}
			# Liege has trait (and is not player)
			else_if = {
				limit = { 
					holder = { 
						any_liege_or_above = { 
							OR = { 
								has_trait_rank = {
									trait = $LINE$linefounder
									rank > 0
								}
								has_trait_rank = {
									trait = $LINE$lineages
									rank > 0
								}
							}
						}
					}	
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_dynasty_realm_02	##my dynasty realm
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = { 
											has_trait_rank = {
												trait = $LINE$linefounder
												rank > 0
											}
											has_trait_rank = {
												trait = $LINE$lineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_02	##my dynasty realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_dynasty_special_02    ## special building
							}
							else = {
								set_color_from_title = title:d_line_map_dynasty_realm_02	##my dynasty realm
							}
						}
					}
				}
			}
			# [NEW] Spouse has trait
			else_if = {
				limit = { 
					holder = {
						any_spouse = {
							OR = { 
								has_trait_rank = {
									trait = $LINE$linefounder
									rank > 0
								}
								has_trait_rank = {
									trait = $LINE$lineages
									rank > 0
								}
							}
						}
					}
				}
				if = {
					limit = {
						exists = holder.primary_spouse
						holder.primary_spouse = {
							OR = { 
								has_trait_rank = {
									trait = $LINE$linefounder
									rank > 0
								}
								has_trait_rank = {
									trait = $LINE$lineages
									rank > 0
								}
							}
						}
					}
					if = {
						limit = {
							holder.primary_spouse = {
								is_female = yes
							}
						}
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_05	## my realm, my dynasty domain
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait_rank = {
														trait = $LINE$linefounder
														rank > 0
													}
													has_trait_rank = {
														trait = $LINE$lineages
														rank > 0
													}
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_05	## my realm, my dynasty, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_05    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_05	## my realm, my dynasty domain
									}
								}
							}
						}
					}
					else = {
						every_county_province = {
							barony = {
								if = {
									limit = { title_province = { has_holding = no } }
									set_color_from_title = title:d_line_map_dynasty_03	## my realm, my dynasty domain
								}
								else = {
									if = {
										limit = {
											holder = {
												primary_title = prev
												OR = { 
													has_trait_rank = {
														trait = $LINE$linefounder
														rank > 0
													}
													has_trait_rank = {
														trait = $LINE$lineages
														rank > 0
													}
												}
											}
										}
										set_color_from_title = title:d_line_map_dynasty_barony_03	## my realm, my dynasty, my dynasty barony
									}
									else_if = {
										limit = { title_province = { has_special_building_slot = yes } }
										set_color_from_title = title:d_line_map_dynasty_special_03    ## special building
									}
									else = {
										set_color_from_title = title:d_line_map_dynasty_03	## my realm, my dynasty domain
									}
								}
							}
						}
					}
				}
				# ANy spouse has trait
				else = {
					# Any spouse is female
					if = {
						limit = {
							holder = {
								any_spouse = {
									is_female = yes
									OR = { 
										has_trait_rank = {
											trait = $LINE$linefounder
											rank > 0
										}
										has_trait_rank = {
											trait = $LINE$lineages
											rank > 0
										}
									}
								}
							}
						}
						if = {
							limit = { holder = { is_independent_ruler = yes } }
							every_county_province = {
								barony = {
									if = {
										limit = { title_province = { has_holding = no } }
										set_color_from_title = title:d_line_map_dynasty_independent_06	##my dynasty domain, top liege
									}
									else = {
										if = {
											limit = {
												holder = {
													primary_title = prev
													OR = { 
														has_trait_rank = {
															trait = $LINE$linefounder
															rank > 0
														}
														has_trait_rank = {
															trait = $LINE$lineages
															rank > 0
														}
													}
												}
											}
											set_color_from_title = title:d_line_map_dynasty_barony_06	##my dynasty domain, my dynasty barony
										}
										else_if = {
											limit = { title_province = { has_special_building_slot = yes } }
											set_color_from_title = title:d_line_map_dynasty_special_06    ## special building
										}
										else = {
											set_color_from_title = title:d_line_map_dynasty_independent_06	##my dynasty domain, top liege
										}
									}
								}
							}
						}
						else = {
							every_county_province = {
								barony = {
									if = {
										limit = { title_province = { has_holding = no } }
										set_color_from_title = title:d_line_map_dynasty_06	##my dynasty domain
									}
									else = {
										if = {
											limit = {
												holder = {
													primary_title = prev
													OR = { 
														has_trait_rank = {
															trait = $LINE$linefounder
															rank > 0
														}
														has_trait_rank = {
															trait = $LINE$lineages
															rank > 0
														}
													}
												}
											}
											set_color_from_title = title:d_line_map_dynasty_barony_06	##my dynasty domain, my dynasty barony
										}
										else_if = {
											limit = { title_province = { has_special_building_slot = yes } }
											set_color_from_title = title:d_line_map_dynasty_special_06    ## special building
										}
										else = {
											set_color_from_title = title:d_line_map_dynasty_06	##my dynasty domain
										}
									}
								}
							}
						}
					}
					# Any spouse is male
					else = {
						if = {
							limit = { holder = { is_independent_ruler = yes } }
							every_county_province = {
								barony = {
									if = {
										limit = { title_province = { has_holding = no } }
										set_color_from_title = title:d_line_map_dynasty_independent_04	##my dynasty domain, top liege
									}
									else = {
										if = {
											limit = {
												holder = {
													primary_title = prev
													OR = { 
														has_trait_rank = {
															trait = $LINE$linefounder
															rank > 0
														}
														has_trait_rank = {
															trait = $LINE$lineages
															rank > 0
														}
													}
												}
											}
											set_color_from_title = title:d_line_map_dynasty_barony_04	##my dynasty domain, my dynasty barony
										}
										else_if = {
											limit = { title_province = { has_special_building_slot = yes } }
											set_color_from_title = title:d_line_map_dynasty_special_04    ## special building
										}
										else = {
											set_color_from_title = title:d_line_map_dynasty_independent_04	##my dynasty domain, top liege
										}
									}
								}
							}
						}
						else = {
							every_county_province = {
								barony = {
									if = {
										limit = { title_province = { has_holding = no } }
										set_color_from_title = title:d_line_map_dynasty_04	##my dynasty domain
									}
									else = {
										if = {
											limit = {
												holder = {
													primary_title = prev
													OR = { 
														has_trait_rank = {
															trait = $LINE$linefounder
															rank > 0
														}
														has_trait_rank = {
															trait = $LINE$lineages
															rank > 0
														}
													}
												}
											}
											set_color_from_title = title:d_line_map_dynasty_barony_04	##my dynasty domain, my dynasty barony
										}
										else_if = {
											limit = { title_province = { has_special_building_slot = yes } }
											set_color_from_title = title:d_line_map_dynasty_special_04    ## special building
										}
										else = {
											set_color_from_title = title:d_line_map_dynasty_04	##my dynasty domain
										}
									}
								}
							}
						}
					}
				}
			}
			# No traits
			else = {
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_base	##base
						}
						else = {
							if = {
								limit = {
									holder = {
										primary_title = prev
										OR = {
											has_trait_rank = {
												trait = $LINE$linefounder
												rank > 0
											}
											has_trait_rank = {
												trait = $LINE$lineages
												rank > 0
											}
										}
									}
								}
								set_color_from_title = title:d_line_map_dynasty_barony_02	##not my realm, my dynasty barony
							}
							else_if = {
								limit = { title_province = { has_special_building_slot = yes } }
								set_color_from_title = title:d_line_map_special_building    ## special building
							}
							else_if = {
								limit = { is_under_holy_order_lease = yes }
								set_color_from_title = title:d_line_map_holy_order   ## holy order
							}
							else = {
								set_color_from_title = title:d_line_map_base	##base
							}
						}
					}
				}
			}
		}
	}

}