﻿# CFP
cfp_papal = {
	trigger = {
		has_graphical_cfp_papal_culture_group_trigger = yes
	}
}

cfp_hre = {
	trigger = {
		has_graphical_cfp_hre_culture_group_trigger = yes
	}
}

cfp_norse = {
	trigger = {
		has_graphical_cfp_norse_court_trigger = yes

		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = { government_has_flag = government_is_nomadic	}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

cfp_norman = {
	trigger = {
		has_graphical_cfp_norman_culture_group_trigger = yes

		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = { government_has_flag = government_is_nomadic	}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

cfp_goidelic = {
	trigger = {
		has_graphical_cfp_goidelic_culture_group_trigger = yes

		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = { government_has_flag = government_is_nomadic	}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

cfp_iberian = {
	trigger = {
		has_graphical_cfp_iberian_court_trigger = yes

		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = { government_has_flag = government_is_nomadic	}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

cfp_andalusian = {
	trigger = {
		has_graphical_cfp_andalusian_court_trigger = yes

		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = { government_has_flag = government_is_nomadic	}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

cfp_west_african = {
	trigger = {
        has_graphical_cfp_west_african_court_trigger = yes

		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = { government_has_flag = government_is_nomadic	}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

cfp_east_african = {
	trigger = {
		has_graphical_cfp_east_african_court_trigger = yes

		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = { government_has_flag = government_is_nomadic	}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

## Byzantine handling (support for CFP court is user doesnt have EP3 (+ islamic court + iconoclast court)
byzantine = {
	trigger = {
		AND = {
			has_ep3_dlc_trigger = yes
			has_graphical_cfp_byzantine_culture_group_trigger = yes
		}
		religion = religion:christianity_religion
		NOR = { 
			faith = faith:iconoclast
			religion = religion:islam_religion 
		}

		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = { government_has_flag = government_is_nomadic	}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

cfp_byzantine = {
	trigger = {
		AND = {
			NOT = { has_ep3_dlc_trigger = yes }
			has_graphical_cfp_byzantine_culture_group_trigger = yes
		}
		religion = religion:christianity_religion
		NOR = { 
			faith = faith:iconoclast
			religion = religion:islam_religion 
		}

		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = { government_has_flag = government_is_nomadic	}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

cfp_byzantine_mena = {
	trigger = {
		has_graphical_cfp_byzantine_culture_group_trigger = yes
		religion = religion:islam_religion

		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = { government_has_flag = government_is_nomadic	}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

cfp_byzantine_pagan = {
	trigger = {
		has_graphical_cfp_byzantine_culture_group_trigger = yes
		OR = { 
			NOR = {
				AND = {
					religion = religion:christianity_religion
					NOT = { faith = faith:iconoclast }
				}
				religion = religion:islam_religion
			}
			AND = {
				religion = religion:christianity_religion
				faith = faith:iconoclast
			}
		}

		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = { government_has_flag = government_is_nomadic	}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}


## VANILLA OVERWRITE WITH CFP SHUNT
mediterranean = {
	trigger = {
		NOT = { has_graphical_cfp_court_active_trigger = yes }
		NOT = {
			government_has_flag = government_is_nomadic
		}
		capital_county ?= {
			OR = {
				culture = {
					OR = {
						has_graphical_byzantine_culture_group_trigger = yes
						has_graphical_caucasian_culture_group_trigger = yes
						has_graphical_mediterranean_culture_group_trigger = yes
						has_graphical_roman_culture_group_trigger = yes
						has_graphical_sicilian_culture_group_trigger = yes
						has_graphical_southslavic_culture_group_trigger = yes
					}
				}
				AND = {
					culture = {
						has_graphical_iberian_culture_group_trigger = yes
					}
					NOT = { religion = religion:islam_religion }
				}
			}
		}
		trigger_if = { # Byzantine Trigger
			limit = {
				has_ep3_dlc_trigger = yes
			}
			NOR = {
				capital_county ?= title:c_byzantion
				primary_title ?= title:e_byzantium
				primary_title ?= title:h_eastern_roman_empire
				AND = {
					primary_title ?= title:h_roman_empire
					title:h_roman_empire = {
						has_variable = rome_was_restored_by_byzantium
					}
				}
			}
		}
		trigger_if = { # China trigger
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = {
					government_has_flag = government_is_nomadic
				}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

mena = {
	trigger = {
		NOT = { has_graphical_cfp_court_active_trigger = yes }
		NOT = {
			government_has_flag = government_is_nomadic
		}
		trigger_if = {
			limit = {
				has_mpo_dlc_trigger = no            
			}
			exists = capital_county
			capital_county = {
				OR = {
					culture = {
						OR = {
							has_graphical_african_culture_group_trigger = yes
							has_graphical_berber_culture_group_trigger = yes
							has_graphical_bulgar_culture_group_trigger = yes
							has_graphical_ethiopian_culture_group_trigger = yes
							has_graphical_iranian_culture_group_trigger = yes
							has_graphical_mena_culture_group_trigger = yes
							has_graphical_sahelian_culture_group_trigger = yes
							has_graphical_somali_culture_group_trigger = yes
							has_graphical_steppe_culture_group_trigger = yes
							has_graphical_turkish_culture_group_trigger = yes
							AND = {
								has_graphical_iberian_culture_group_trigger  = yes
								prev.religion = religion:islam_religion
							}
						}
					}
				}
			}
		}
		trigger_else = {
			exists = capital_county
			OR = {
				capital_county = {
					culture = {
						OR = {
							has_graphical_bulgar_culture_group_trigger = yes
							has_graphical_iranian_culture_group_trigger = yes
							has_graphical_steppe_culture_group_trigger = yes
						}
					}
					title_province ?= {
						has_holding = yes
						NOR = {
							government_has_flag = government_is_tribal
							government_has_flag = government_is_nomadic
						}
					}
				}
				capital_county.culture = {
					OR = {
						has_graphical_african_culture_group_trigger = yes
						has_graphical_berber_culture_group_trigger = yes
						has_graphical_ethiopian_culture_group_trigger = yes
						has_graphical_mena_culture_group_trigger = yes
						has_graphical_sahelian_culture_group_trigger = yes
						has_graphical_somali_culture_group_trigger = yes
						has_graphical_turkish_culture_group_trigger = yes
						AND = {
							has_graphical_iberian_culture_group_trigger  = yes
							prev.religion = religion:islam_religion
						}
					}
				}
			}
		}
		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = {
					government_has_flag = government_is_nomadic
				}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

steppe = {
	trigger = {
		NOT = { has_graphical_cfp_court_active_trigger = yes }
		has_mpo_dlc_trigger = yes
		OR = {
			government_has_flag = government_is_nomadic
			capital_county ?= {
				culture = {
					OR = {
						has_graphical_bulgar_culture_group_trigger = yes
						has_graphical_iranian_culture_group_trigger = yes
						has_graphical_mongol_culture_group_trigger = yes
						has_graphical_steppe_culture_group_trigger = yes
					}
				}
				title_province ?= {
					has_holding = yes
					OR = {
						has_holding_type = nomad_holding
						has_holding_type = tribal_holding
					}
				}
			}
			#For tribal northerns... this is better than a big feudal western castle, right?
			capital_county ?= {
				culture = {
					OR = {
						has_graphical_steppe_culture_group_trigger = yes
						has_graphical_western_culture_group_trigger = yes
						has_graphical_tundra_culture_group_trigger = yes
						has_graphical_slavic_culture_group_trigger = yes
					}
					OR = {
						has_cultural_pillar = heritage_ugro_permian
						has_cultural_pillar = heritage_volga_finnic
						has_cultural_pillar = heritage_balto_finnic
					}
				}
				title_province ?= {
					has_holding = yes
					OR = {
						has_holding_type = nomad_holding
						has_holding_type = tribal_holding
					}
				}
			}
		}
		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = {
					government_has_flag = government_is_nomadic
				}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

indian = {
	trigger = {
		NOT = {
			government_has_flag = government_is_nomadic
		}
		exists = capital_county
		capital_county = {
			OR = {
				culture = {
					OR = {
						has_graphical_india_culture_group_trigger = yes
					}
				}
			}
		}
		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = {
					government_has_flag = government_is_nomadic
				}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

western = {
	trigger = {
		NOT = { has_graphical_cfp_court_active_trigger = yes }
		NOT = {
			government_has_flag = government_is_nomadic
		}
		exists = capital_county
		capital_county.culture = {
			OR = {
				has_graphical_baltic_culture_group_trigger = yes
				has_graphical_celtic_culture_group_trigger = yes
				has_graphical_croatian_culture_group_trigger = yes
				has_graphical_english_culture_group_trigger = yes
				has_graphical_german_culture_group_trigger = yes
				has_graphical_magyar_culture_group_trigger = yes
				has_graphical_scandinavian_culture_group_trigger = yes
				has_graphical_slavic_culture_group_trigger = yes
				has_graphical_vlach_culture_group_trigger = yes
				has_graphical_western_culture_group_trigger = yes
				has_graphical_norse_culture_group_trigger = yes
				has_graphical_saxon_culture_group_trigger = yes
				has_graphical_tundra_culture_group_trigger = yes
			}
		}
		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = {
					government_has_flag = government_is_nomadic
				}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

chinese = {
	trigger = {
		NOT = {
			government_has_flag = government_is_nomadic
		}
		OR = {
			capital_county.culture = {
				OR = {
					has_graphical_ainu_culture_group_trigger = yes
					has_graphical_chinese_culture_group_trigger = yes
					has_graphical_japanese_culture_group_trigger = yes
					has_graphical_mongol_culture_group_trigger = yes
					has_graphical_tibetan_culture_group_trigger = yes
				}
			}	
			primary_title ?= title:h_china
		}
		# Is a Japanese Ceremonial Liege or indepedent ruler
		trigger_if = {
			limit = {
				tgp_realm_has_ceremonial_liege_trigger = yes
				capital_county.culture ?= {
					OR = {
						has_graphical_ainu_culture_group_trigger = yes
						has_graphical_japanese_culture_group_trigger = yes
					}
				}
			}
			tgp_has_ceremonial_liege_title_trigger = yes
		}
	}
}

japanese = {
	trigger = {
		NOT = {
			government_has_flag = government_is_nomadic
		}
		capital_county.culture ?= {
			OR = {
				has_graphical_ainu_culture_group_trigger = yes
				has_graphical_japanese_culture_group_trigger = yes
			}
		}
		# Is not Ceremonial Liege
		tgp_realm_has_ceremonial_liege_trigger = yes
		tgp_has_ceremonial_liege_title_trigger = no
		trigger_if = {
			limit = {
				has_tgp_dlc_trigger = yes
				NOT = {
					government_has_flag = government_is_nomadic
				}
				tgp_is_ceremonial_regent_trigger = no
			}
			NOT = { primary_title ?= title:h_china }
		}
	}
}

southeast_asia = {
	trigger = {
		NOT = {
			government_has_flag = government_is_nomadic
		}
		capital_county ?= {
			OR = {
				culture = {
					has_graphical_southeast_asia_culture_group_trigger = yes
				}
			}
		}
	}
}

chinese_alt = { 
	trigger = {
		always = no # This is by design, we don't want an ahistorical throne room to spawn for players, in the future we might add a game rule though
	}
}