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

line_mapping_map_barony = {
	every_barony = {
		county = {
			prev = { set_color_from_title = prev }
		}
	}
}

#### War Maps BEGINS ####
line_mapping_weather_map = {

	every_barony = {
		if = {
			limit = { title_province = { has_province_modifier = winter_mild_modifier } }
			set_color_from_title = title:d_line_map_weather_winter_mild
		}
		else_if = {
			limit = { title_province = { has_province_modifier = winter_normal_modifier } }
			set_color_from_title = title:d_line_map_weather_winter_normal
		}
		else_if = {
			limit = { title_province = { has_province_modifier = winter_harsh_modifier } }
			set_color_from_title = title:d_line_map_weather_winter_harsh
		}
		else = {
			set_color_from_title = title:d_line_map_base
		}
	}

}

line_mapping_warring_map = {

	every_county = {

		if = {
			limit = {
				holder = { is_at_war = yes } 
			}
			every_county_province = {
				barony = {
					if = {
						limit = { title_province = { has_holding = no } }
						set_color_from_title = title:d_line_map_warring_liege_void	##	warring county holder - no holdings
					}
					else_if = {
						limit = { 
							title_province = {
								OR = {
									has_holding_type = castle_holding
									has_holding_type = tribal_holding
								}
							}
						}
						if = {
							limit = { 
								holder = {
									NOT = { completely_controls = prev }
								}
							}
							set_color_from_title = title:d_line_map_warring_liege_sieged ## castle occupied
						}
						else = {
							set_color_from_title = title:d_line_map_warring_liege_castle ##	warring county and barony holder (is castle)
						}
					}
					else = {
						if = {
							limit = { 
								holder = {
									NOT = { completely_controls = prev }
								}
							}
							set_color_from_title = title:d_line_map_warring_liege_occupied ## whole county occupied
						}
						else = {
							set_color_from_title = title:d_line_map_warring_liege	##	warring county and barony holder
						}
					}
				}
			}
		}
		
		else = {
			if = {
				limit = { 
					holder = { 
						any_liege_or_above = { is_at_war = yes } 
					}
				}
				every_county_province = {
					barony = {
						if = {
							limit = { title_province = { has_holding = no } }
							set_color_from_title = title:d_line_map_warring_county_void	## 
						}
						else_if = {
							limit = { 
								title_province = {
									OR = {
										has_holding_type = castle_holding
										has_holding_type = tribal_holding
									}
								}
							}
							if = {
								limit = { 
									holder = {
										NOT = { completely_controls = prev }
									}
								}
								set_color_from_title = title:d_line_map_warring_county_sieged  ## vassal castle occupied
							}
							else = {
								set_color_from_title = title:d_line_map_warring_county_castle	##	warring county and barony holder (is castle)
							}
						}
						else = {
							if = {
								limit = { 
									holder = {
										NOT = { completely_controls = prev }
									}
								}
								set_color_from_title = title:d_line_map_warring_county_occupied  ## whole vassal county occupied
							}
							else = {
								set_color_from_title = title:d_line_map_warring_county
							}
						}
					}
				}
			}
			else = { # If they are not at war, at least show the effects
				if = {
					limit = {
						has_county_modifier = razed_modifier
					}
					every_county_province = {
						barony = {
							set_color_from_title = title:d_line_map_fortification_11
						}
					}
				}
				else_if = { # If they were pillaged
					limit = { 
						has_county_modifier = pillage_modifier
					}
					every_county_province = {
						barony = {
							if = {
								limit = { title_province = { has_holding = no } }
								set_color_from_title = title:d_line_map_base ## general map - no holdings
							}
							else = {
								if = {
									limit = { title_province = { has_province_modifier = burnt_down_modifier } }
									set_color_from_title = title:d_line_map_dynasty_independent_04
								}
								else = {
									set_color_from_title = title:d_line_map_trade_13
								}
							}
						}
					}
				}
				else = {
					every_county_province = {
						barony = {
						set_color_from_title = title:d_line_map_base	## general map
						}
					}
				}
			}
		}
	}

}

line_mapping_raiding_map = {

	save_scope_as = player_character

	every_barony = {
		
		# Mark counties recently sacked (not only raided province...)
		if = {
			limit = { 
				county = {
					OR = {
						has_county_modifier = recently_sacked_modifier
						has_county_modifier = recently_enslaved_modifier
						has_county_modifier = dies_robbed_county_modifier
						has_county_modifier = dies_counterfeit_county_modifier
					}
				}
			}
			if = {
				limit = { title_province = { has_holding = no } }
				set_color_from_title = title:d_line_map_base ## general map - no holdings
			}
			else = {
				if = {
					limit = {
						county = { has_county_modifier = recently_sacked_modifier }
					}
					set_color_from_title = title:d_line_map_dynasty_barony_01
				}
				else_if = {
					limit = {
						county = { has_county_modifier = recently_enslaved_modifier }
					}
					set_color_from_title = title:d_line_map_dynasty_05
				}
				else = {
					set_color_from_title = title:d_line_map_dynasty_independent_03
				}
			}
		}

		# Now mark provinces looted
		else_if = {			
			limit = { title_province = { has_province_modifier = recently_looted_modifier } }
			set_color_from_title = title:d_line_map_special_building
		}
	
		else = {
			if = {
				limit = { title_province = { has_holding = no } }
				set_color_from_title = title:d_line_map_base ## general map - no holdings
			}
			else = {
				set_local_variable = {
					name = current_loot
					value = title_province.monthly_income
				}
				change_local_variable = {
					name = current_loot
					multiply = 12 # based on Vanilla
				}

				if = {
					limit = {
						local_var:current_loot < 3
					}
					set_color_from_title = title:d_line_map_loot_1
				}
				else_if = {
					limit = {
						local_var:current_loot < 6
					}
					set_color_from_title = title:d_line_map_loot_2
				}
				else_if = {
					limit = {
						local_var:current_loot < 9
					}
					set_color_from_title = title:d_line_map_loot_3
				}
				else_if = {
					limit = {
						local_var:current_loot < 12
					}
					set_color_from_title = title:d_line_map_loot_4
				}
				else_if = {
					limit = {
						local_var:current_loot < 15
					}
					set_color_from_title = title:d_line_map_loot_5
				}
				else_if = {
					limit = {
						local_var:current_loot < 20
					}
					set_color_from_title = title:d_line_map_loot_6
				}
				else_if = {
					limit = {
						local_var:current_loot < 25
					}
					set_color_from_title = title:d_line_map_loot_7
				}
				else_if = {
					limit = {
						local_var:current_loot < 30
					}
					set_color_from_title = title:d_line_map_loot_8
				}
				else_if = {
					limit = {
						local_var:current_loot < 35
					}
					set_color_from_title = title:d_line_map_loot_9
				}
				else_if = {
					limit = {
						local_var:current_loot < 40
					}
					set_color_from_title = title:d_line_map_loot_10
				}
				else_if = {
					limit = {
						local_var:current_loot < 45
					}
					set_color_from_title = title:d_line_map_loot_11
				}
				else_if = {
					limit = {
						local_var:current_loot < 50
					}
					set_color_from_title = title:d_line_map_loot_12
				}
				else_if = {
					limit = {
						local_var:current_loot < 60
					}
					set_color_from_title = title:d_line_map_loot_13
				}
				else_if = {
					limit = {
						local_var:current_loot < 70
					}
					set_color_from_title = title:d_line_map_loot_14
				}
				else_if = {
					limit = {
						local_var:current_loot < 80
					}
					set_color_from_title = title:d_line_map_loot_15
				}
				else_if = {
					limit = {
						local_var:current_loot < 90
					}
					set_color_from_title = title:d_line_map_loot_16
				}
				else_if = {
					limit = {
						local_var:current_loot < 100
					}
					set_color_from_title = title:d_line_map_loot_17
				}
				else_if = {
					limit = {
						local_var:current_loot < 120
					}
					set_color_from_title = title:d_line_map_loot_18
				}
				else_if = {
					limit = {
						local_var:current_loot < 140
					}
					set_color_from_title = title:d_line_map_loot_19
				}
				else_if = {
					limit = {
						local_var:current_loot < 160
					}
					set_color_from_title = title:d_line_map_loot_20
				}
				else_if = {
					limit = {
						local_var:current_loot < 180
					}
					set_color_from_title = title:d_line_map_loot_21
				}
				else_if = {
					limit = {
						local_var:current_loot > 200
					}
					set_color_from_title = title:d_line_map_loot_22
				}
				else = {
					set_color_from_title = title:d_line_map_loot_0
				}
			}
		}
	}
}

line_mapping_fortification_map = {

	every_barony = {
		if = {
			limit = {
				OR = {
					is_capital_barony = yes
					title_province = {
						OR = {
							has_holding_type = castle_holding
							has_holding_type = tribal_holding
						}
					}
				}
			}
			if = {
				limit = {
					title_province = { fort_level < 2 }
				}
				set_color_from_title = title:d_line_map_fortification_1
			}
			else_if = {
				limit = {
					title_province = { fort_level < 3 }
				}
				set_color_from_title = title:d_line_map_fortification_2
			}
			else_if = {
				limit = {
					title_province = { fort_level < 4 }
				}
				set_color_from_title = title:d_line_map_fortification_3
			}
			else_if = {
				limit = {
					title_province = { fort_level < 5 }
				}
				set_color_from_title = title:d_line_map_fortification_4
			}
			else_if = {
				limit = {
					title_province = { fort_level < 6 }
				}
				set_color_from_title = title:d_line_map_fortification_5
			}
			else_if = {
				limit = {
					title_province = { fort_level < 7 }
				}
				set_color_from_title = title:d_line_map_fortification_6
			}
			else_if = {
				limit = {
					title_province = { fort_level < 8 }
				}
				set_color_from_title = title:d_line_map_fortification_7
			}
			else_if = {
				limit = {
					title_province = { fort_level < 9 }
				}
				set_color_from_title = title:d_line_map_fortification_8
			}
			else_if = {
				limit = {
					title_province = {fort_level < 10}
				}
				set_color_from_title = title:d_line_map_fortification_9
			}
			else_if = {
				limit = {
					title_province = {fort_level > 10 }
				}
				set_color_from_title = title:d_line_map_fortification_10
			}
			else = {
				set_color_from_title = title:d_line_map_fortification_0
			}
		}
		else = {
			set_color_from_title = title:d_line_map_base	## general map
		}
	}
}

line_mapping_alliance_map = {

	save_scope_as = player_character

	every_county = {

		if = {
			limit = {
				exists = holder
			}
			holder = { 
				save_scope_as = county_holder
			}
		}

		## MY DOMAIN
		if = { # My domain, my counties
			limit = {
				exists = holder
				holder = {# is me
					this = scope:player_character
				}
			}
			every_county_province = { 
				barony = { 
					if = { # My County, Baron Ally
						limit = {
							exists = holder
							holder = {
								any_ally = { this = scope:player_character }
							}
						}
						set_color_from_title = title:d_self_barony_ally
					}
					else_if = { # My County, My Barony
						limit = {
							exists = holder
							holder = {
								this = scope:player_character 
							}
							is_leased_out = no
						}
						set_color_from_title = title:d_self
					}
					else = { # My County, other Barons
						set_color_from_title = title:d_self_barony
					} 
				}
			}
		}
		else_if = { # My domain, not my counties
			limit = {
				exists = holder
				holder = {# Liege is me
					any_liege_or_above = { this = scope:player_character }
				}
			}
			every_county_province = { 
				barony = { 
					if = { # My Vassal County, Baron Ally
						limit = {
							exists = holder
							holder = {
								any_ally = { this = scope:player_character }
							}
						}
						set_color_from_title = title:d_self_liege_barony
					}
					else = { # My Vassal's Barony or Baron
						set_color_from_title = title:d_self_liege
					} 
				}
			}
		}

		## MY ALLY
		else_if = { # My ally, his counties
			limit = {
				exists = holder
				holder = {
					any_ally = { this = scope:player_character }
				}
			}
			every_county_province = { 
				barony = { 
					if = { # His County, My Baron Ally
						limit = {
							exists = holder
							holder = {
								any_ally = { this = scope:player_character }
							}
							is_leased_out = no
						}
						set_color_from_title = title:d_allied_barony
					}
					else = { # His County, His Barony or Baron
						set_color_from_title = title:d_allied
					} 
				}
			}
		}
		else_if = { # My ally, not his counties
			limit = {
				exists = holder
				holder = {
					any_liege_or_above = {
						this = {
							any_ally = { this = scope:player_character }
						}
					}
				}
			}
			every_county_province = {
				barony = { 
					if = { # His Vassal County, Baron Ally
						limit = {
							exists = holder
							holder = {
								any_ally = { this = scope:player_character }
							}
						}
						set_color_from_title = title:d_allied_liege_barony
					}
					else = { # His Vassals' Barony or Baron
						set_color_from_title = title:d_allied_liege
					} 
				}
			}
		}

		## MY TRUCE
		else_if = { # Truce
			limit = {
				exists = holder
				holder = {
					OR ={
						any_truce_holder = { this = scope:player_character }
						any_truce_target = { this = scope:player_character }
					}
				}
			}
			every_county_province = { 
				barony = { 
					if = { # His County, but My Baron ally
						limit = {
							exists = holder
							holder = {
								any_ally = { this = scope:player_character }
							}
						}
						set_color_from_title = title:d_allied
					}
					else_if = { # His county, fortification
						limit = {
							title_province = {  
								OR = {
									has_holding_type = castle_holding
									has_holding_type = tribal_holding
								}
							} 
						}
						set_color_from_title = title:d_truce_barony
					}
					else_if = { # His county, no holding
						limit = { 
							title_province = { 
								has_holding = no 
							} 
						}
						set_color_from_title = title:d_truce_void
					}
					else = { # His County, his Barony or his barons
						set_color_from_title = title:d_truce
					} 
				}
			}
		}
		else_if = { # Truce liege, Not his domain
			limit = {
				exists = holder
				holder = {
					any_liege_or_above = {
						this = {
							OR = {
								any_truce_holder = { this = scope:player_character }
								any_truce_target = { this = scope:player_character }
							}
						}
					}
				}
			}
			every_county_province = { 
				barony = { 
					if = { # His County, but My Baron ally
						limit = {
							exists = holder
							holder = {
								any_ally = { this = scope:player_character }
							}
						}
						set_color_from_title = title:d_allied
					}
					else = { # His County, his Barony or his barons
						set_color_from_title = title:d_truce_liege
					} 
				}
			}
		}

		## ALONE
		else_if = { # Alone in the diplomatic world
			limit = {
				exists = holder
				holder = {
					is_independent_ruler = yes
					any_ally = {
						NOR = {
							target_is_vassal_or_below = prev
							target_is_liege_or_above = prev
						}
						count = 0
					}
				}
			}
			every_county_province = { 
				barony = { 
					if = { # His County, but My ally
						limit = {
							exists = holder
							holder = {
								any_ally = { this = scope:player_character }
							}
						}
						set_color_from_title = title:d_allied
					}
					else_if = { # His county, fortification
						limit = {
							title_province = {  
								OR = {
									has_holding_type = castle_holding
									has_holding_type = tribal_holding
								}
							} 
						}
						set_color_from_title = title:d_alone_barony
					}
					else_if = { # His county, no holding
						limit = { 
							title_province = { 
								has_holding = no 
							} 
						}
						set_color_from_title = title:d_alone_void
					}
					else = { # His County, his Barony or his barons
						set_color_from_title = title:d_alone
					} 
				}
			}
		}
		else_if = { # Liege is alone in the diplomatic world
			limit = {
				exists = holder
				holder = {
					any_liege_or_above = {
						this = {
							is_independent_ruler = yes
							any_ally = {
								NOR = {
									target_is_vassal_or_below = prev
									target_is_liege_or_above = prev
								}
								count = 0
							}
						}
					}
				}
			}
			every_county_province = { 
				barony = { 
					if = { # His County, but My ally
						limit = {
							exists = holder
							holder = {
								any_ally = { this = scope:player_character }
							}
						}
						set_color_from_title = title:d_allied
					}
					else = { # His County or Vassals' County, His Barony or his or his vassals' Barons
						set_color_from_title = title:d_alone_liege
					} 
				}
			}
		}
		
		## HIGHLIGHT DOMAIN OF RULER WITH ALLIES
		else_if = { # Independent ruler, has allies
			limit = {
				exists = holder
				holder = {
					is_independent_ruler = yes
				}
			}
			every_county_province = { 
				barony = { 
					if = { # His county, his barony
						limit = {
							title_province = { 
								OR = {
									has_holding_type = castle_holding
									has_holding_type = tribal_holding
								}
							} 
						}
						set_color_from_title = title:d_has_allies_liege
					}
					else_if = { # His county, his barony
						limit = { 
							title_province = { 
								has_holding = no 
							} 
						}
						set_color_from_title = title:d_has_allies_void
					}
					else = { # His county, not his barony
						set_color_from_title = title:d_has_allies
					}
				}
			}
		}

		## REST
		else = {
			every_county_province = { 
				barony = { 
					if = { # Any county, my baron ally
						limit = {
							exists = holder
							holder = {
								any_ally = { this = scope:player_character }
							}
						}
						set_color_from_title = title:d_allied
					}
					else = { # Base color
						set_color_from_title = title:d_line_map_base
					}
				} 
			}
		}
	}
}

line_mapping_artifact_map = {

	# Independent
	every_ruler = {
		limit = {
			highest_held_title_tier >= tier_county
		}
		if = {
			limit = {
				exists = capital_province
				has_any_artifact = yes
			}
			if = {
				limit = {
					any_character_artifact = {
						OR = {
							has_variable = historical_unique_artifact
							has_variable = relic
						}
					}
				}
				save_scope_value_as = {
					name = important_artifact
					value = yes
				}
				capital_province.barony = {
					save_scope_as = this_barony
					set_color_from_title = title:d_line_map_warring_liege_sieged
				}
				every_held_title = {
					limit = {
						tier = tier_county
					}
					every_county_province = { 
						barony = {
							if = {
								limit = {
									NOT = { this = scope:this_barony }
								}
								set_color_from_title = title:d_line_map_warring_county_void
							}
						}
					}
				}
			}
			else_if = {
				limit = {
					any_character_artifact = {
						artifact_slot_type = horse
						horse_valid_for_sale_trigger = yes
					}
				}
				if = { # Camels or Elephants
					limit = {
						any_character_artifact = {
							OR = {
								artifact_type = camel
								artifact_type = elephant
							}
							NOT = { has_variable = horse_for_sale }
						}
					}
					capital_province.barony = {
						save_scope_as = this_barony
						set_color_from_title = title:d_line_map_dynasty_independent_07
					}
				}
				else = { # Horses
					capital_province.barony = {
						save_scope_as = this_barony
						set_color_from_title = title:d_line_map_dynasty_independent_03
					}
				}
				every_held_title = {
					limit = {
						tier = tier_county
					}
					every_county_province = { 
						barony = {
							if = {
								limit = {
									NOT = { this = scope:this_barony }
								}
								set_color_from_title = title:d_line_map_dynasty_realm_03
							}
						}
					}
				}
			}
			else_if = {
				limit = {
					any_character_artifact = {
						artifact_type = falcon
						NOT = { has_variable = for_sale }
					}
				}
				capital_province.barony = {
					save_scope_as = this_barony
					set_color_from_title = title:d_line_map_dynasty_independent_01
				}
				every_held_title = {
					limit = {
						tier = tier_county
					}
					every_county_province = { 
						barony = {
							if = {
								limit = {
									NOT = { this = scope:this_barony}
								}
								set_color_from_title = title:d_line_map_dynasty_realm_01
							}
						}
					}
				}
			}
			else_if = {
				limit = {
					any_character_artifact = {
						has_variable = created_for_sale
						NOT = { has_variable = for_sale }
					}
				}
				capital_province.barony = {
					save_scope_as = this_barony
					set_color_from_title = title:d_line_map_dynasty_independent_05
				}
				every_held_title = {
					limit = {
						tier = tier_county
					}
					every_county_province = { 
						barony = {
							if = {
								limit = {
									NOT = { this = scope:this_barony}
								}
								set_color_from_title = title:d_line_map_dynasty_realm_05
							}
						}
					}
				}
			}
			else = {
				capital_province.barony = {
					save_scope_as = this_barony
					set_color_from_title = title:d_line_map_raiding_raided_special
				}
				every_held_title = {
					limit = {
						tier = tier_county
					}
					every_county_province = { 
						barony = {
							if = {
								limit = {
									NOT = { this = scope:this_barony}
								}
								set_color_from_title = title:d_line_map_special_building_raidable
							}
						}
					}
				}
			}
		}
		else = {
			every_held_title = {
				limit = {
					tier = tier_county
				}
				every_county_province = { 
					barony = {
						set_color_from_title = title:d_line_map_base
					}
				}
			}
		}
	}
}

line_mapping_military_strength_map = {

	save_scope_as = player_character

	every_ruler = {

		if = {
			limit = {
				is_independent_ruler = yes
			}

			save_scope_as = independent_army_liege

			set_variable = {
				name = military_strength_proportion
				value = scope:player_character.max_military_strength
			}

			set_variable = {
				name = ruler_military_strength
				value = max_military_strength
			}
			if = { # max to avoid divion by zero
				limit = {
					max_military_strength = 0
				}
				change_variable = {
					name = ruler_military_strength
					add = 1
				}
			}
			change_variable = {
				name = military_strength_proportion
				divide = var:ruler_military_strength
			}

			barony_color_military = {
				PROPORTION = var:military_strength_proportion
			}

			every_realm_county = {
				if = {
					limit = {
						holder = scope:independent_army_liege
					}
					every_county_province = { 
						barony = {
							set_color_from_title = scope:independent_army_liege.var:barony_color
						}
					}
				}
			}
		}
		else = {
			if = {
				limit = {
					this.liege = {
						is_independent_ruler = yes
					}
				}

				save_scope_as = independent_army_vassal
			
				set_variable = {
					name = military_strength_proportion
					value = scope:player_character.max_military_strength
				}
				
				set_variable = {
					name = ruler_military_strength
					value = max_military_strength
				}
				if = { # max to avoid divion by zero
					limit = {
						max_military_strength = 0
					}
					change_variable = {
						name = ruler_military_strength
						add = 1
					}
				}
				change_variable = {
					name = military_strength_proportion
					divide = var:ruler_military_strength
				}

				barony_color_military = {
					PROPORTION = var:military_strength_proportion
				}

				every_realm_county = {
					if = {
						limit = {
							holder = scope:independent_army_vassal
						}
						every_county_province = { 
							barony = {
								set_color_from_title = scope:independent_army_vassal.var:barony_color
							}
						}
					}
				}
			}
			else = {
				if = {
					limit = {
						this.liege = {
							is_independent_ruler = no
							highest_held_title_tier >= tier_duchy
						}
					}

					save_scope_as = independent_army_vassal
	
					set_variable = {
						name = military_strength_proportion
						value = scope:player_character.max_military_strength
					}
					
					set_variable = {
						name = ruler_military_strength
						value = max_military_strength
					}
					if = { # max to avoid divion by zero
						limit = {
							max_military_strength = 0
						}
						change_variable = {
							name = ruler_military_strength
							add = 1
						}
					}
					change_variable = {
						name = military_strength_proportion
						divide = var:ruler_military_strength
					}
	
					barony_color_military = {
						PROPORTION = var:military_strength_proportion
					}
	
					every_realm_county = {
						if = {
							limit = {
								holder = scope:independent_army_vassal
							}
							every_county_province = { 
								barony = {
									set_color_from_title = scope:independent_army_vassal.var:barony_color
								}
							}
						}
					}
				}
				else = {
					if = {
						limit = {
							highest_held_title_tier = tier_county
						}

						save_scope_as = independent_army_vassal
		
						set_variable = {
							name = military_strength_proportion
							value = scope:player_character.max_military_strength
						}

						set_variable = {
							name = ruler_military_strength
							value = max_military_strength
						}
						if = { # max to avoid divion by zero
							limit = {
								max_military_strength = 0
							}
							change_variable = {
								name = ruler_military_strength
								add = 1
							}
						}
						change_variable = {
							name = military_strength_proportion
							divide = var:ruler_military_strength
						}
		
						barony_color_military = {
							PROPORTION = var:military_strength_proportion
						}
		
						every_realm_county = {
							if = {
								limit = {
									holder = scope:independent_army_vassal
								}
								every_county_province = { 
									barony = {
										set_color_from_title = scope:independent_army_vassal.var:barony_color
									}
								}
							}
							else = {
								every_county_province = { 
									barony = {
										set_color_from_title = title:d_line_map_base	## general map
									}
								}
							}
						}
					}
				}
			}
		}
	}
}


line_mapping_county_opinion_map = {

	every_county = {
		if = {
			limit = { county_opinion < -95 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_bad_10 }
			}
		}
		else_if = {
			limit = { county_opinion < -90 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_bad_9 }
			}
		}
		else_if = {
			limit = { county_opinion < -80 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_bad_8 }
			}
		}
		else_if = {
			limit = { county_opinion < -70 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_bad_7 }
			}
		}
		else_if = {
			limit = { county_opinion < -60 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_bad_6 }
			}
		}
		else_if = {
			limit = { county_opinion < -50 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_bad_5 }
			}
		}
		else_if = {
			limit = { county_opinion < -40 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_bad_4 }
			}
		}
		else_if = {
			limit = { county_opinion < -30 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_bad_3 }
			}
		}
		else_if = {
			limit = { county_opinion < -20 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_bad_2 }
			}
		}
		else_if = {
			limit = { county_opinion < -10 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_bad_1 }
			}
		}
		else_if = {
			limit = { county_opinion < -0 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_bad_0 }
			}
		}
		else_if = {
			limit = { county_opinion < 10 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_good_0 }
			}
		}
		else_if = {
			limit = { county_opinion < 20 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_good_1 }
			}
		}
		else_if = {
			limit = { county_opinion < 30 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_good_2 }
			}
		}
		else_if = {
			limit = { county_opinion < 40 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_good_3 }
			}
		}
		else_if = {
			limit = { county_opinion < 50 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_good_4 }
			}
		}
		else_if = {
			limit = { county_opinion < 60 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_good_5 }
			}
		}
		else_if = {
			limit = { county_opinion < 70 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_good_6 }
			}
		}
		else_if = {
			limit = { county_opinion < 80 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_good_7 }
			}
		}
		else_if = {
			limit = { county_opinion < 90 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_good_8 }
			}
		}
		else_if = {
			limit = { county_opinion < 95 }
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_good_9 }
			}
		}
		else = {
			every_county_province = {
				barony = { set_color_from_title = title:d_line_map_army_good_10 }
			}
		}
	}
}

line_mapping_stationed_map = {

	save_scope_as = player_character 

	every_barony = {
		if = {
			limit = {
				title_province = {
					OR = {
						has_holding_type = castle_holding
						has_holding_type = tribal_holding
					}
				}
			}
			if = {
				limit = {
					holder = scope:player_character 
				}
				if = {
					limit = { title_province = { has_stationed_regiment = yes } }
					set_color_from_title = title:d_self
				}
				else = {
					set_color_from_title = title:d_truce
				}
			}
			else_if = {
				limit = {
					holder = {
						any_liege_or_above = {
							this = scope:player_character 
						}
					}
				}
				if = {
					limit = { title_province = { has_stationed_regiment = yes } }
					set_color_from_title = title:d_self_liege
				}
				else = {
					set_color_from_title = title:d_line_map_army_bad_3
				}
			}
			else = {
				if = {
					limit = { title_province = { has_stationed_regiment = yes } }
					set_color_from_title = title:d_line_map_army_bad_10
				}
				else = {
					set_color_from_title = title:d_line_map_army_good_0
				}
			}
		}
		else = {
			set_color_from_title = title:d_line_map_base
		}
	}

}

############

barony_color_military = {
	# scope = character
	if = {
		limit = { $PROPORTION$ < 0.05 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_bad_10
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 0.1 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_bad_9
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 0.2 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_bad_8
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 0.3 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_bad_7
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 0.4 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_bad_6
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 0.5 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_bad_5
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 0.6 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_bad_4
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 0.7 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_bad_3
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 0.8 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_bad_2
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 0.9 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_bad_1
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 1 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_bad_0
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 1.1 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_good_0
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 1.25 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_good_1
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 1.4 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_good_2 
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 1.7 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_good_3
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 2 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_good_4
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 2.5 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_good_5
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 3 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_good_6
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 4 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_good_7
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 6 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_good_8
		}
	}
	else_if = {
		limit = { $PROPORTION$ < 8 }
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_good_9
		}
	}
	else = {
		set_variable = {
			name = barony_color
			value = title:d_line_map_army_good_10
		}
	}
}
#### War Maps ENDS ####