namespace = blg

character_event = {
	id = blg.100
	desc = ca.100.desc
	picture = GFX_evt_emissary
	sound = click

	is_triggered_only = yes

	option = {
		name = ca.110.opt

		repeat_event = { id = blg.110 }
	}

	option = {
		name = ca.120.opt
		repeat_event = { id = blg.120 }
	}

	option = {
		name = TRIGGER_SOCIETY

		trigger = {
			FROM = {
				OR = {
					is_society_discovered = yes
					same_society_as = ROOT
					blg_artifact_mask_any = yes
				}
				NOT = { society_member_of = secret_religious_cult }
			}
		}

		repeat_event = { id = blg.113 }
	}

	option = {
		name = ca.130.opt

		trigger = {
			FROM = {
				OR = {
					has_scarred_trait_trigger = yes
					trait = disfigured
					trait = blinded
					trait = one_eyed
				}
			}
			NOT = { has_game_rule = { name = blg_wounds value = off } }
		}

		repeat_event = { id = blg.130 }
	}

	option = {
		name = FE_EXIT
	}
}

character_event = {
	id = blg.110
	desc = ca.110.desc
	picture = GFX_evt_emissary
	sound = click

	is_triggered_only = yes

	option = {
		name = RD_HEADGEAR

		FROM = {
			if = {
				limit = { has_portrait_property = { layer = 5 index = 0 } }
				set_variable = { which = ca_headgear value = 1 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 1 } }
				set_variable = { which = ca_headgear value = 2 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 2 } }
				set_variable = { which = ca_headgear value = 3 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 3 } }
				set_variable = { which = ca_headgear value = 4 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 4 } }
				set_variable = { which = ca_headgear value = 5 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 5 } }
				set_variable = { which = ca_headgear value = 6 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 6 } }
				set_variable = { which = ca_headgear value = 7 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 7 } }
				set_variable = { which = ca_headgear value = 8 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 8 } }
				set_variable = { which = ca_headgear value = 9 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 9 } }
				set_variable = { which = ca_headgear value = 10 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 10 } }
				set_variable = { which = ca_headgear value = 11 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 11 } }
				set_variable = { which = ca_headgear value = 12 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 12 } }
				set_variable = { which = ca_headgear value = 13 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 13 } }
				set_variable = { which = ca_headgear value = 14 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 14 } }
				set_variable = { which = ca_headgear value = 15 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 15 } }
				set_variable = { which = ca_headgear value = 16 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 16 } }
				set_variable = { which = ca_headgear value = 17 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 17 } }
				set_variable = { which = ca_headgear value = 18 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 18 } }
				set_variable = { which = ca_headgear value = 19 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 5 index = 19 } }
				set_variable = { which = ca_headgear value = 20 }
			}
		}
		repeat_event = { id = blg.111 }
	}

	option = {
		name = RD_CLOTHES

		FROM = {
			if = {
				limit = { has_portrait_property = { layer = 3 index = 0 } }
				set_variable = { which = ca_clothes value = 1 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 1 } }
				set_variable = { which = ca_clothes value = 2 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 2 } }
				set_variable = { which = ca_clothes value = 3 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 3 } }
				set_variable = { which = ca_clothes value = 4 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 4 } }
				set_variable = { which = ca_clothes value = 5 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 5 } }
				set_variable = { which = ca_clothes value = 6 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 6 } }
				set_variable = { which = ca_clothes value = 7 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 7 } }
				set_variable = { which = ca_clothes value = 8 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 8 } }
				set_variable = { which = ca_clothes value = 9 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 9 } }
				set_variable = { which = ca_clothes value = 10 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 10 } }
				set_variable = { which = ca_clothes value = 11 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 11 } }
				set_variable = { which = ca_clothes value = 12 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 12 } }
				set_variable = { which = ca_clothes value = 13 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 13 } }
				set_variable = { which = ca_clothes value = 14 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 14 } }
				set_variable = { which = ca_clothes value = 15 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 15 } }
				set_variable = { which = ca_clothes value = 16 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 16 } }
				set_variable = { which = ca_clothes value = 17 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 17 } }
				set_variable = { which = ca_clothes value = 18 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 3 index = 18 } }
				set_variable = { which = ca_clothes value = 19 }
			}
		}
		repeat_event = { id = blg.112 }
	}

	option = {
		name = ca.114.opt

		trigger = { has_dlc = "Holy Fury" }

		repeat_event = { id = blg.114 }
	}

	option = {
		name = FE_EXIT
	}
}

character_event = {
	id = blg.111
	desc = ca.111.desc
	picture = GFX_evt_coronation
	sound = click

	is_triggered_only = yes

	option = {
		name = LEDGER_NEXT

		trigger = {
			FROM = {
				trigger_if = {
					limit = {
						blg_ek_clothing = yes
					}
					NOT = { check_variable = { which = ca_headgear value = 20 } }
				}
				trigger_else_if = {
					limit = {
						OR = {
							blg_merchant_headgear = yes
							AND = {
								blg_headgear_chinese = yes
								blg_elite_commander = yes
							}
						}
					}
					NOT = { check_variable = { which = ca_headgear value = 15 } }
				}
				trigger_else_if = {
					limit = { blg_elite_commander = yes }
					NOT = { check_variable = { which = ca_headgear value = 14 } }
				}
				trigger_else = {
					NOT = { check_variable = { which = ca_headgear value = 12 } }
				}
			}
		}

		hidden_effect = {
			FROM = {
				change_variable = { which = ca_headgear value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.111 }
	}

	option = {
		name = LEDGER_PREV

		trigger = {
			FROM = {
				trigger_if = {
					limit = {
						OR = {
							blg_headgear_emperor = yes
							blg_merchant_headgear = yes
						}
					}
					check_variable = { which = ca_headgear value = 2 }
				}
				trigger_else_if = {
					limit = { blg_headgear_king = yes }
					check_variable = { which = ca_headgear value = 3 }
				}
				trigger_else_if = {
					limit = { blg_headgear_duke = yes }
					check_variable = { which = ca_headgear value = 6 }
				}
				trigger_else = {
					check_variable = { which = ca_headgear value = 7 }
				}
			}
		}

		hidden_effect = {
			FROM = {
				subtract_variable = { which = ca_headgear value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.111 }
	}

	option = {
		name = DIPLOWINDOW_ACCEPT

		repeat_event = { id = blg.110 }
	}

	option = {
		name = RD_RESET

		hidden_effect = {
			FROM = {
				set_variable = { which = ca_headgear value = 0 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.110 }
	}
}

character_event = {
	id = blg.112
	desc = ca.112.desc
	picture = GFX_evt_poke_king_in_chest
	sound = click

	is_triggered_only = yes

	option = {
		name = LEDGER_NEXT

		trigger = {
			FROM = {
				trigger_if = {
					limit = {
						blg_ek_clothing = yes
					}
					NOT = { check_variable = { which = ca_clothes value = 19 } }
				}
				trigger_else_if = {
					limit = {
						OR = {
							blg_merchant_clothes = yes
							AND = {
								is_female = no
								blg_clothes_chinese = yes
								blg_elite_commander = yes
							}
						}
					}
					NOT = { check_variable = { which = ca_clothes value = 15 } }
				}
				trigger_else_if = {
					limit = {
						is_female = no
						blg_elite_commander = yes
					}
					NOT = { check_variable = { which = ca_clothes value = 14 } }
				}
				trigger_else = {
					NOT = { check_variable = { which = ca_clothes value = 12 } }
				}
			}
		}

		hidden_effect = {
			FROM = {
				change_variable = { which = ca_clothes value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.112 }
	}

	option = {
		name = LEDGER_PREV

		trigger = {
			FROM = {
				trigger_if = {
					limit = { blg_clothes_royal = yes }
					check_variable = { which = ca_clothes value = 2 }
				}
				trigger_else_if = {
					limit = { blg_clothes_noble = yes }
					check_variable = { which = ca_clothes value = 5 }
				}
				trigger_else = {
					check_variable = { which = ca_clothes value = 8 }
				}
			}
		}

		hidden_effect = {
			FROM = {
				subtract_variable = { which = ca_clothes value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.112 }
	}

	option = {
		name = DIPLOWINDOW_ACCEPT

		repeat_event = { id = blg.110 }
	}

	option = {
		name = RD_RESET

		hidden_effect = {
			FROM = {
				set_variable = { which = ca_clothes value = 0 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.110 }
	}
}

character_event = {
	id = blg.113
	desc = ca.113.desc
	picture = GFX_evt_shadowy_cabal
	sound = click

	is_triggered_only = yes

	option = {
		name = ca.113.WearSocietyGear

		trigger = {
			FROM = {
				NOT = { trait = blgcaon }
			}
		}

		hidden_effect = { FROM = { add_trait = blgcaon } }
		repeat_event = { id = blg.113 }
	}

	option = {
		name = ca.113.RemoveSocietyGear

		trigger = {
			FROM = {
				NOT = { trait = blgcaoff }
			}
		}

		hidden_effect = {
			FROM = {
				add_trait = blgcaoff
				remove_trait = blgquesting
			}
		}
		repeat_event = { id = blg.113 }
	}

	option = {
		name = ca.113.ShowMask

		trigger = {
			FROM = {
				has_character_flag = blgcamaskoff
				blg_artifact_mask_any = yes
			}
		}

		hidden_effect = {
			FROM = {
				clr_character_flag = blgcamaskoff
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.113 }
	}

	option = {
		name = ca.113.RemoveMask

		trigger = {
			FROM = {
				NOT = { has_character_flag = blgcamaskoff }
				blg_artifact_mask_any = yes
			}
		}

		hidden_effect = {
			FROM = {
				set_character_flag = blgcamaskoff
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.113 }
	}

	option = {
		name = FE_EXIT
	}
}

character_event = {
	id = blg.114
	desc = ca.114.desc
	picture = GFX_evt_dancing
	sound = click

	is_triggered_only = yes

	option = {
		name = ca.115.opt

		FROM = {
			if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 1 }
						has_portrait_property = { layer = 32 index = 1 }
					}
				}
				set_variable = { which = ca_overlayer value = 2 }
			}
			else_if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 2 }
						has_portrait_property = { layer = 32 index = 2 }
					}
				}
				set_variable = { which = ca_overlayer value = 3 }
			}
			else_if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 3 }
						has_portrait_property = { layer = 32 index = 3 }
					}
				}
				set_variable = { which = ca_overlayer value = 4 }
			}
			else_if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 4 }
						has_portrait_property = { layer = 32 index = 4 }
					}
				}
				set_variable = { which = ca_overlayer value = 5 }
			}
			else_if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 5 }
						has_portrait_property = { layer = 32 index = 5 }
					}
				}
				set_variable = { which = ca_overlayer value = 6 }
			}
			else_if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 6 }
						has_portrait_property = { layer = 32 index = 6 }
					}
				}
				set_variable = { which = ca_overlayer value = 7 }
			}
			else_if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 7 }
						has_portrait_property = { layer = 32 index = 7 }
					}
				}
				set_variable = { which = ca_overlayer value = 8 }
			}
			else_if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 8 }
						has_portrait_property = { layer = 32 index = 8 }
					}
				}
				set_variable = { which = ca_overlayer value = 9 }
			}
			else_if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 9 }
						has_portrait_property = { layer = 32 index = 9 }
					}
				}
				set_variable = { which = ca_overlayer value = 10 }
			}
			else_if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 10 }
						has_portrait_property = { layer = 32 index = 10 }
					}
				}
				set_variable = { which = ca_overlayer value = 11 }
			}
			else_if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 11 }
						has_portrait_property = { layer = 32 index = 11 }
					}
				}
				set_variable = { which = ca_overlayer value = 12 }
			}
			else_if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 12 }
						has_portrait_property = { layer = 32 index = 12 }
					}
				}
				set_variable = { which = ca_overlayer value = 13 }
			}
			else_if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 13 }
						has_portrait_property = { layer = 32 index = 13 }
					}
				}
				set_variable = { which = ca_overlayer value = 14 }
			}
			else_if = {
				limit = {
					OR = {
						has_portrait_property = { layer = 31 index = 14 }
						has_portrait_property = { layer = 32 index = 14 }
					}
				}
				set_variable = { which = ca_overlayer value = 15 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 32 index = 15 } }
				set_variable = { which = ca_overlayer value = 16 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 32 index = 16 } }
				set_variable = { which = ca_overlayer value = 17 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 32 index = 17 } }
				set_variable = { which = ca_overlayer value = 18 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 32 index = 18 } }
				set_variable = { which = ca_overlayer value = 19 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 32 index = 19 } }
				set_variable = { which = ca_overlayer value = 20 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 32 index = 20 } }
				set_variable = { which = ca_overlayer value = 21 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 32 index = 21 } }
				set_variable = { which = ca_overlayer value = 22 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 32 index = 22 } }
				set_variable = { which = ca_overlayer value = 23 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 32 index = 23 } }
				set_variable = { which = ca_overlayer value = 24 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 32 index = 24 } }
				set_variable = { which = ca_overlayer value = 25 }
			}
			else = {
				set_variable = { which = ca_overlayer value = 1 }
			}
		}
		repeat_event = { id = blg.115 }
	}

	option = {
		name = FE_EXIT
	}
}

character_event = {
	id = blg.115
	desc = ca.115.desc
	picture = GFX_evt_dancing
	sound = click

	is_triggered_only = yes

	option = {
		name = LEDGER_NEXT

		trigger = {
			FROM = {
				trigger_if = {
					limit = { is_female = yes }
					NOT = { check_variable = { which = ca_overlayer value = 25 } }
				}
				trigger_else_if = {
					limit = { blg_headgear_duke = yes }
					NOT = { check_variable = { which = ca_overlayer value = 15 } }
				}
				trigger_else = {
					NOT = { check_variable = { which = ca_overlayer value = 10 } }
				}
			}
		}

		hidden_effect = {
			FROM = {
				change_variable = { which = ca_overlayer value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.115 }
	}

	option = {
		name = LEDGER_PREV

		trigger = {
			FROM = { check_variable = { which = ca_overlayer value = 2 } }
		}

		hidden_effect = {
			FROM = {
				subtract_variable = { which = ca_overlayer value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.115 }
	}

	option = {
		name = DIPLOWINDOW_ACCEPT

		repeat_event = { id = blg.110 }
	}

	option = {
		name = RD_RESET

		hidden_effect = {
			FROM = {
				set_variable = { which = ca_overlayer value = 0 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.110 }
	}
}

character_event = {
	id = blg.116
	desc = ca.116.desc
	picture = GFX_evt_wise_woman
	sound = click

	is_triggered_only = yes

	option = {
		name = LEDGER_NEXT

		trigger = {
			FROM = { NOT = { check_variable = { which = ca_underlayer value = 20 } } }
		}

		hidden_effect = {
			FROM = {
				change_variable = { which = ca_underlayer value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.116 }
	}

	option = {
		name = LEDGER_PREV

		trigger = {
			FROM = { check_variable = { which = ca_underlayer value = 2 } }
		}

		hidden_effect = {
			FROM = {
				subtract_variable = { which = ca_underlayer value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.116 }
	}

	option = {
		name = DIPLOWINDOW_ACCEPT

		repeat_event = { id = blg.110 }
	}

	option = {
		name = RD_RESET

		hidden_effect = {
			FROM = {
				set_variable = { which = ca_underlayer value = 0 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.110 }
	}
}

character_event = {
	id = blg.120
	desc = ca.120.desc
	picture = GFX_evt_market
	sound = click

	is_triggered_only = yes

	option = {
		name = RD_HAIRSTYLE

		FROM = {
			if = {
				limit = { has_portrait_property = { layer = 1 index = 0 } }
				set_variable = { which = ca_hair value = 1 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 1 } }
				set_variable = { which = ca_hair value = 2 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 2 } }
				set_variable = { which = ca_hair value = 3 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 3 } }
				set_variable = { which = ca_hair value = 4 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 4 } }
				set_variable = { which = ca_hair value = 5 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 5 } }
				set_variable = { which = ca_hair value = 6 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 6 } }
				set_variable = { which = ca_hair value = 7 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 7 } }
				set_variable = { which = ca_hair value = 8 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 8 } }
				set_variable = { which = ca_hair value = 9 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 9 } }
				set_variable = { which = ca_hair value = 10 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 10 } }
				set_variable = { which = ca_hair value = 11 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 11 } }
				set_variable = { which = ca_hair value = 12 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 12 } }
				set_variable = { which = ca_hair value = 13 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 13 } }
				set_variable = { which = ca_hair value = 14 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 14 } }
				set_variable = { which = ca_hair value = 15 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 15 } }
				set_variable = { which = ca_hair value = 16 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 16 } }
				set_variable = { which = ca_hair value = 17 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 17 } }
				set_variable = { which = ca_hair value = 18 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 18 } }
				set_variable = { which = ca_hair value = 19 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 1 index = 19 } }
				set_variable = { which = ca_hair value = 20 }
			}
		}
		repeat_event = { id = blg.121 }
	}

	option = {
		name = RD_BEARD

		trigger = {
			FROM = { is_female = no }
		}

		FROM = {
			if = {
				limit = { has_portrait_property = { layer = 4 index = 0 } }
				set_variable = { which = ca_beard value = 1 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 1 } }
				set_variable = { which = ca_beard value = 2 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 2 } }
				set_variable = { which = ca_beard value = 3 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 3 } }
				set_variable = { which = ca_beard value = 4 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 4 } }
				set_variable = { which = ca_beard value = 5 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 5 } }
				set_variable = { which = ca_beard value = 6 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 6 } }
				set_variable = { which = ca_beard value = 7 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 7 } }
				set_variable = { which = ca_beard value = 8 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 8 } }
				set_variable = { which = ca_beard value = 9 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 9 } }
				set_variable = { which = ca_beard value = 10 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 10 } }
				set_variable = { which = ca_beard value = 11 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 11 } }
				set_variable = { which = ca_beard value = 12 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 12 } }
				set_variable = { which = ca_beard value = 13 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 13 } }
				set_variable = { which = ca_beard value = 14 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 14 } }
				set_variable = { which = ca_beard value = 15 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 15 } }
				set_variable = { which = ca_beard value = 16 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 16 } }
				set_variable = { which = ca_beard value = 17 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 17 } }
				set_variable = { which = ca_beard value = 18 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 18 } }
				set_variable = { which = ca_beard value = 19 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 4 index = 19 } }
				set_variable = { which = ca_beard value = 20 }
			}
		}
		repeat_event = { id = blg.122 }
	}

	option = {
		name = FE_EXIT
	}
}

character_event = {
	id = blg.121
	desc = ca.121.desc
	picture = GFX_evt_courtiers_talking
	sound = click

	is_triggered_only = yes

	option = {
		name = LEDGER_NEXT

		trigger = {
			FROM = {
				trigger_if = {
					limit = {
						blg_hair_ek = yes
					}
					NOT = { check_variable = { which = ca_hair value = 20 } }
				}
				trigger_else_if = {
					limit = {
						OR = {
							blg_hair_cuman = yes
							AND = {
								is_female = yes
								OR = {
									blg_hair_byzantine = yes
									blg_hair_english = yes
									blg_hair_german = yes
									blg_hair_norse = yes
									blg_hair_southern = yes
									blg_hair_ugric = yes
									blg_hair_westafrican = yes
								}
							}
							AND = {
								is_female = no
								blg_hair_indian = yes
							}
						}
					}
					NOT = { check_variable = { which = ca_hair value = 10 } }
				}
				trigger_else_if = {
					limit = {
						OR = {
							blg_hair_norse = yes
							blg_hair_ugric = yes
						}
					}
					NOT = { check_variable = { which = ca_hair value = 13 } }
				}
				trigger_else = {
					NOT = { check_variable = { which = ca_hair value = 15 } }
				}
			}
		}

		hidden_effect = {
			FROM = {
				change_variable = { which = ca_hair value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.121 }
	}

	option = {
		name = LEDGER_PREV

		trigger = {
			FROM = {
				check_variable = { which = ca_hair value = 2 }
			}
		}

		hidden_effect = {
			FROM = {
				subtract_variable = { which = ca_hair value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.121 }
	}

	option = {
		name = DIPLOWINDOW_ACCEPT

		repeat_event = { id = blg.120 }
	}

	option = {
		name = RD_RESET

		hidden_effect = {
			FROM = {
				set_variable = { which = ca_hair value = 0 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.120 }
	}
}

character_event = {
	id = blg.122
	desc = ca.122.desc
	picture = GFX_evt_courtiers_talking
	sound = click

	is_triggered_only = yes

	option = {
		name = LEDGER_NEXT

		trigger = {
			FROM = {
				trigger_if = {
					limit = {
						blg_beard_ek = yes
					}
					NOT = { check_variable = { which = ca_beard value = 20 } }
				}
				trigger_else_if = {
					limit = {
						blg_beard_mongol = yes
					}
					NOT = { check_variable = { which = ca_beard value = 7 } }
				}
				trigger_else_if = {
					limit = {
						OR = {
							blg_beard_celtic = yes
							blg_beard_persian = yes
							blg_beard_turkish = yes
						}
					}
					NOT = { check_variable = { which = ca_beard value = 10 } }
				}
				trigger_else_if = {
					limit = {
						blg_beard_indian = yes
					}
					NOT = { check_variable = { which = ca_beard value = 13 } }
				}
				trigger_else = {
					NOT = { check_variable = { which = ca_beard value = 15 } }
				}
			}
		}

		hidden_effect = {
			FROM = {
				change_variable = { which = ca_beard value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.122 }
	}

	option = {
		name = LEDGER_PREV

		trigger = {
			FROM = {
				check_variable = { which = ca_beard value = 2 }
			}
		}

		hidden_effect = {
			FROM = {
				subtract_variable = { which = ca_beard value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.122 }
	}

	option = {
		name = DIPLOWINDOW_ACCEPT

		repeat_event = { id = blg.120 }
	}

	option = {
		name = RD_RESET

		hidden_effect = {
			FROM = {
				set_variable = { which = ca_beard value = 0 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.120 }
	}
}

character_event = {
	id = blg.130
	desc = ca.130.desc
	picture = GFX_evt_court_physician
	sound = click

	is_triggered_only = yes

	option = {
		name = ca.131.opt

		trigger = {
			FROM = { has_scarred_trait_trigger = yes }
		}

		repeat_event = { id = blg.131 }
	}

	option = {
		name = ca.132.opt

		trigger = {
			FROM = {
				NAND = {
					has_portrait_property = { layer = 12 index = 0 }
					is_variable_equal = { which = ca_mask value = 0 }
				}
			}
		}

		FROM = {
			if = {
				limit = { has_portrait_property = { layer = 12 index = 1 } }
				set_variable = { which = ca_mask value = 1 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 12 index = 2 } }
				set_variable = { which = ca_mask value = 2 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 12 index = 3 } }
				set_variable = { which = ca_mask value = 3 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 12 index = 4 } }
				set_variable = { which = ca_mask value = 4 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 12 index = 5 } }
				set_variable = { which = ca_mask value = 5 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 12 index = 6 } }
				set_variable = { which = ca_mask value = 6 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 12 index = 7 } }
				set_variable = { which = ca_mask value = 7 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 12 index = 8 } }
				set_variable = { which = ca_mask value = 8 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 12 index = 9 } }
				set_variable = { which = ca_mask value = 9 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 12 index = 10 } }
				set_variable = { which = ca_mask value = 10 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 12 index = 11 } }
				set_variable = { which = ca_mask value = 11 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 12 index = 12 } }
				set_variable = { which = ca_mask value = 12 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 12 index = 13 } }
				set_variable = { which = ca_mask value = 13 }
			}
		}
		repeat_event = { id = blg.132 }
	}

	option = {
		name = ca.133.opt

		trigger = {
			FROM = {
				NAND = {
					has_portrait_property = { layer = 13 index = 0 }
					is_variable_equal = { which = ca_eyepatch value = 0 }
				}
			}
		}

		FROM = {
			if = {
				limit = { has_portrait_property = { layer = 13 index = 1 } }
				set_variable = { which = ca_eyepatch value = 2 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 2 } }
				set_variable = { which = ca_eyepatch value = 3 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 3 } }
				set_variable = { which = ca_eyepatch value = 4 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 4 } }
				set_variable = { which = ca_eyepatch value = 5 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 5 } }
				set_variable = { which = ca_eyepatch value = 6 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 6 } }
				set_variable = { which = ca_eyepatch value = 7 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 7 } }
				set_variable = { which = ca_eyepatch value = 8 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 8 } }
				set_variable = { which = ca_eyepatch value = 9 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 9 } }
				set_variable = { which = ca_eyepatch value = 10 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 10 } }
				set_variable = { which = ca_eyepatch value = 11 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 11 } }
				set_variable = { which = ca_eyepatch value = 12 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 12 } }
				set_variable = { which = ca_eyepatch value = 13 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 13 } }
				set_variable = { which = ca_eyepatch value = 14 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 14 } }
				set_variable = { which = ca_eyepatch value = 15 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 15 } }
				set_variable = { which = ca_eyepatch value = 16 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 16 } }
				set_variable = { which = ca_eyepatch value = 17 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 17 } }
				set_variable = { which = ca_eyepatch value = 18 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 18 } }
				set_variable = { which = ca_eyepatch value = 19 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 19 } }
				set_variable = { which = ca_eyepatch value = 20 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 20 } }
				set_variable = { which = ca_eyepatch value = 21 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 21 } }
				set_variable = { which = ca_eyepatch value = 22 }
			}
			else_if = {
				limit = { has_portrait_property = { layer = 13 index = 23 } }
				set_variable = { which = ca_eyepatch value = 24 }
			}
			else = {
				set_variable = { which = ca_eyepatch value = 1 }
			}
		}
		repeat_event = { id = blg.133 }
	}

	option = {
		name = FE_EXIT
	}
}

character_event = {
	id = blg.131
	desc = ca.131.desc
	picture = GFX_evt_doctor_crazy_treatment
	sound = click

	is_triggered_only = yes

	option = {
		name = LEDGER_NEXT

		trigger = {
			FROM = {
				NOT = { trait = scarred_type_10 }
			}
		}

		hidden_effect = {
			FROM = {
				if = {
					limit = { trait = scarred_type_9 }
					add_trait = scarred_type_10
				}
				else_if = {
					limit = { trait = scarred_type_8 }
					add_trait = scarred_type_9
				}
				else_if = {
					limit = { trait = scarred_type_7 }
					add_trait = scarred_type_8
				}
				else_if = {
					limit = { trait = scarred_type_6 }
					add_trait = scarred_type_7
				}
				else_if = {
					limit = { trait = scarred_type_5 }
					add_trait = scarred_type_6
				}
				else_if = {
					limit = { trait = scarred_type_4 }
					add_trait = scarred_type_5
				}
				else_if = {
					limit = { trait = scarred_type_3 }
					add_trait = scarred_type_4
				}
				else_if = {
					limit = { trait = scarred_type_2 }
					add_trait = scarred_type_3
				}
				else_if = {
					limit = { trait = scarred_type_1 }
					add_trait = scarred_type_2
				}
			}
		}
		repeat_event = { id = blg.131 }
	}

	option = {
		name = LEDGER_PREV

		trigger = {
			FROM = {
				NOT = { trait = scarred_type_1 }
			}
		}

		hidden_effect = {
			FROM = {
				if = {
					limit = { trait = scarred_type_2 }
					add_trait = scarred_type_1
				}
				else_if = {
					limit = { trait = scarred_type_3 }
					add_trait = scarred_type_2
				}
				else_if = {
					limit = { trait = scarred_type_4 }
					add_trait = scarred_type_3
				}
				else_if = {
					limit = { trait = scarred_type_5 }
					add_trait = scarred_type_4
				}
				else_if = {
					limit = { trait = scarred_type_6 }
					add_trait = scarred_type_5
				}
				else_if = {
					limit = { trait = scarred_type_7 }
					add_trait = scarred_type_6
				}
				else_if = {
					limit = { trait = scarred_type_8 }
					add_trait = scarred_type_7
				}
				else_if = {
					limit = { trait = scarred_type_9 }
					add_trait = scarred_type_8
				}
				else_if = {
					limit = { trait = scarred_type_10 }
					add_trait = scarred_type_9
				}
			}
		}
		repeat_event = { id = blg.131 }
	}

	option = {
		name = DIPLOWINDOW_ACCEPT

		repeat_event = { id = blg.130 }
	}
}

character_event = {
	id = blg.132
	desc = ca.132.desc
	picture = GFX_evt_illness
	sound = click

	is_triggered_only = yes

	option = {
		name = LEDGER_NEXT

		trigger = {
			FROM = {
				NOT = { check_variable = { which = ca_mask value = 14 } }
			}
		}

		hidden_effect = {
			FROM = {
				change_variable = { which = ca_mask value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.132 }
	}

	option = {
		name = LEDGER_PREV

		trigger = {
			FROM = {
				NOT = { is_variable_equal = { which = ca_mask value = 1 } }
			}
		}

		hidden_effect = {
			FROM = {
				subtract_variable = { which = ca_mask value = 1 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.132 }
	}

	option = {
		name = DIPLOWINDOW_ACCEPT

		repeat_event = { id = blg.130 }
	}

	option = {
		name = RD_RESET

		hidden_effect = {
			FROM = {
				set_variable = { which = ca_mask value = 0 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.130 }
	}
}

character_event = {
	id = blg.133
	desc = ca.133.desc
	picture = GFX_evt_lunatic
	sound = click

	is_triggered_only = yes

	option = {
		name = LEDGER_NEXT

		trigger = {
			FROM = {
				trigger_if = {
					limit = { trait = blinded }
					NOT = { check_variable = { which = ca_eyepatch value = 24 } }
				}
				trigger_else = {
					OR = {
						NOT = { check_variable = { which = ca_eyepatch value = 14 } }
						check_variable = { which = ca_eyepatch value = 24 }
					}
				}
			}
		}

		hidden_effect = {
			FROM = {
				change_variable = { which = ca_eyepatch value = 1 }
				if = {
					limit = { is_variable_equal = { which = ca_eyepatch value = 25 } }
					set_variable = { which = ca_eyepatch value = 1 }
				}
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.133 }
	}

	option = {
		name = LEDGER_PREV

		trigger = {
			FROM = {
				trigger_if = {
					limit = { trait = blinded }
					NOT = { is_variable_equal = { which = ca_eyepatch value = 15 } }
				}
				trigger_else = {
					NOT = { is_variable_equal = { which = ca_eyepatch value = 24 } }
				}
			}
		}

		hidden_effect = {
			FROM = {
				subtract_variable = { which = ca_eyepatch value = 1 }
				if = {
					limit = { is_variable_equal = { which = ca_eyepatch value = 0 } }
					set_variable = { which = ca_eyepatch value = 24 }
				}
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.133 }
	}

	option = {
		name = DIPLOWINDOW_ACCEPT

		repeat_event = { id = blg.130 }
	}

	option = {
		name = RD_RESET

		hidden_effect = {
			FROM = {
				set_variable = { which = ca_eyepatch value = 0 }
				refresh_portrait = yes
			}
		}
		repeat_event = { id = blg.130 }
	}
}
