﻿##################################################
# Found New Hegemony
# shameless edit of vanilla empires decision
##################################################

found_hegemony_decision = {
	picture = {
		trigger = {
			government_is_japanese_trigger = yes
		}
		reference = "gfx/interface/illustrations/event_story/tgp_japanese_shogunate.dds"
	}
	picture = {
		trigger = { culture = { has_graphical_east_asia_culture_group_trigger = yes } }
		reference = "gfx/interface/illustrations/event_story/tgp_dynastic_cycle_stability.dds"
	}
	picture = {
		trigger = { culture = { has_graphical_india_culture_group_trigger = yes } }
		reference = "gfx/interface/illustrations/decisions/tgp_decision_mandala.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_dynasty_house.dds"
	}
	decision_group_type = major
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 60
		hegemony = 0
	}
	desc = found_empire_decision_desc

	is_shown = {
		highest_held_title_tier = tier_empire
		OR = {
			top_liege = this
			any_held_title = {
				count >= 3
				title_tier = empire
			}
		}
		NOT = {
			has_game_rule = off_custom_hegemonies
		}
		is_landed_or_landless_administrative = yes
		is_confederation_member = no
	}

	is_valid = {
		prestige_level >= 5
		trigger_if = {
			limit = { has_game_rule = on_custom_hegemonies }
			trigger_if = {
				limit = {
					government_has_flag = government_is_nomadic
				}
				OR = {
					sub_realm_size >= 180
					AND = {
						custom_description = {
							text = found_hegemony_decision_three_empires_held
							any_held_title = {
								count >= 3
								title_tier = empire
							}
						}
						sub_realm_size >= 120
					}
				}
			}
			trigger_else = {
				OR = {
					sub_realm_size >= 360
					AND = {
						custom_description = {
							text = found_hegemony_decision_three_empires_held
							any_held_title = {
								count >= 3
								title_tier = empire
							}
						}
						sub_realm_size >= 240
					}
				}
			}

			trigger_if = {
				limit = {
					government_has_flag = government_is_nomadic
				}
				OR = {
					has_realm_law = nomadic_authority_5
					has_realm_law = nomadic_authority_4
				}
			}

			trigger_if = {
				limit = {
					exists = struggle:iberian_struggle
					# only display the condition for people from relevant faiths and cultures
					struggle:iberian_struggle = {
						OR = {
							is_culture_involved_in_struggle = root.culture
							is_faith_involved_in_struggle = root.faith
						}
					}
					# and living nearby
					any_realm_county = {
						title_province = {
							OR = {
								geographical_region = ghw_region_north_africa
								geographical_region = world_europe_west
								geographical_region = world_europe_south
							}
						}
					}
				}
				custom_description = {
					text = found_empire_decision_not_part_of_iberian_struggle
					NOT = {
						any_character_struggle = {
							is_struggle_type = iberian_struggle
						}
					}
				}
			}
		}
		trigger_else = {
			trigger_if = {
				limit = {
					government_has_flag = government_is_nomadic
				}
				OR = {
					sub_realm_size >= 300
					AND = {
						custom_description = {
							text = found_hegemony_decision_five_empires_held
							any_held_title = {
								count >= 5
								title_tier = empire
							}
						}
						sub_realm_size >= 200
					}
				}
			}
			trigger_else = {
				OR = {
					sub_realm_size >= 600
					AND = {
						custom_description = {
							text = found_hegemony_decision_five_empires_held
							any_held_title = {
								count >= 5
								title_tier = empire
							}
						}
						sub_realm_size >= 400
					}
				}
			}

			trigger_if = {
				limit = {
					government_has_flag = government_is_nomadic
				}
				OR = {
					has_realm_law = nomadic_authority_5
					has_realm_law = nomadic_authority_4
				}
			}

			trigger_if = {
				limit = {
					exists = struggle:iberian_struggle
					# only display the condition for people from relevant faiths and cultures
					struggle:iberian_struggle = {
						OR = {
							is_culture_involved_in_struggle = root.culture
							is_faith_involved_in_struggle = root.faith
						}
					}
					# and living nearby
					any_realm_county = {
						title_province = {
							OR = {
								geographical_region = ghw_region_north_africa
								geographical_region = world_europe_west
								geographical_region = world_europe_south
							}
						}
					}
				}
				custom_description = {
					text = found_empire_decision_not_part_of_iberian_struggle
					NOT = {
						any_character_struggle = {
							is_struggle_type = iberian_struggle
						}
					}
				}
			}
		}
		rule_title_creation_imperial_power_projection_title_creation_trigger = yes
	}

	is_valid_showing_failures_only = {
		top_liege = this
		is_available_adult = yes
		is_at_war = no
	}

	cost = {
		gold = {
			value = 5000
			if = {
				limit = {
					OR = {
						government_has_flag = government_is_nomadic
						has_treasury = yes
					}
				}
				multiply = 0
			}
		}
		treasury = {
			value = 5000
			if = {
				limit = {
					has_treasury = no
				}
				multiply = 0
			}
		}
		prestige = 10000
		piety = {
			value = 3000
			if = {
				limit = {
					government_has_flag = government_is_nomadic
				}
				multiply = 0
			}
		}
	}

	effect = {
		if = {
			limit = {
				NOT = { government_has_flag = government_is_nomadic }
			}
			mgr_create_custom_hegemony_effect = yes
			gain_heroic_legend_seed_tooltip_effect = yes
			#TO DO
			#hidden_effect = {
			#	legend_seed_new_title_effect = yes
			#}
		}
		else = {
			mgr_create_custom_hegemony_effect = yes
		}
		if = {
			limit = {
				is_ai = no
				NOT = { exists = global_var:found_hegemony_decision  }
			}
			set_global_variable = {
				name = found_hegemony_decision
				value = root
			}
			set_global_variable = {
				name = found_hegemony_decision_hegemony
				value = root.primary_title
			}
		}
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}