﻿begin_alan_rebellion_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_realm.dds"
	}
	decision_group_type = major

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 12
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	desc = begin_alan_rebellion_decision_desc
	selection_tooltip = begin_alan_rebellion_decision_tooltip

	is_shown = {
		is_ai = yes
		has_game_rule = okay_alan_independence_war
		game_start_date < 900.1.1
		current_year >= 880
		current_year < 950
		top_liege != this
		primary_title = { this = title:d_alania }
		liege ?= {
			is_ai = yes
			top_liege = this
			primary_title = { this = title:e_caspian-pontic_steppe }
			has_no_war_preventing_relation = yes
		}
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:begin_alan_rebellion_decision
			}
		}
	}
	
	is_valid_showing_failures_only = {
		is_at_war = no
		is_available_adult = yes
	}
	
	effect = {
		# can only happen once
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:begin_alan_rebellion_decision
		}
		
		add_gold = 500
		add_prestige = 1000
		start_war = {
			casus_belli = alan_independence_war
			target = root.liege
		}		
	}
	
	ai_potential = {
		culture = culture:alan
		is_landed = yes
		highest_held_title_tier = tier_duchy
	}
	
	ai_will_do = {
		base = 10
		modifier = {
			add = -10
			current_year < 890
			liege = { is_at_war = no }
		}
		modifier = {
			add = 90
			liege = { is_at_war = yes }
		}
		modifier = {
			add = 20
			current_year >= 890
		}
		modifier = {
			add = 20
			current_year >= 900
		}
		modifier = {
			add = 20
			current_year >= 910
		}
		modifier = {
			factor = 0
			days_of_continuous_peace < 90
		}
		modifier = {
			factor = 0
			has_ongoing_grand_activity_trigger = yes
		}
	}	
}

summon_mogyer_host_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_recruitment.dds"
	}
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 24
		kingdom = 12
		empire = 12
		hegemony = 12
	}
	
	sort_order = 75
	
	desc = summon_mogyer_host_decision_desc
	selection_tooltip = summon_mogyer_host_decision_tooltip
	
	is_shown = {
		has_dynasty = yes
		culture = culture:mogyer
		NOT = { has_game_rule = no_mogyer_changes }
		highest_held_title_tier >= tier_county
		exists = capital_province
		government_has_flag = government_is_tribal
	}
	
	is_valid_showing_failures_only = {
		is_adult = yes
		is_house_head = yes
		is_imprisoned = no
		has_contagious_deadly_disease_trigger = no
		is_incapable = no
		custom_description = {
			text = already_summoned_mogyer_host
			NOT = { has_variable = summoned_mogyer_host }
		}
		custom_description = {
			text = house_has_county_culture
			culture = {
				any_culture_county = { holder.house = root.house }
			}
		}
		trigger_if = {
			limit = { NOT = { has_variable = summoned_mogyer_host } }
			custom_description = {
				text = house_already_summoned_mogyer_host
				NOT = { house = { has_variable = summoned_mogyer_host } }
			}
		}
	}
	
	cost = {
		prestige = {
			value = 250
		}
	}
	
	effect = {
		house = {
			set_variable = {
				name = summoned_mogyer_host
				value = yes
				years = 10
			}
		}
		set_variable = {
			name = summoned_mogyer_host
			value = yes
		}
		capital_county = { save_temporary_scope_as = house_capital }
		custom_tooltip = summon_mogyer_host_tt
		hidden_effect = {
			spawn_army = {
				men_at_arms = {
					type = horse_archers
					stacks = root.mogyer_summoned_host_stacks
				}
				men_at_arms = {
					type = light_horsemen
					stacks = root.mogyer_summoned_host_stacks
				}
				inheritable = no
				uses_supply = no
				location = capital_province
				name = dynasty_mogyer_host_name
			}
		}
	}
	
	ai_potential = {
		culture = culture:mogyer
		is_landed = yes
	}
	
	ai_will_do = {
		base = 100
	}
}

ai_mogyer_adopt_christianity = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/tgp_debate.dds"
	}
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 24
		empire = 24
		hegemony = 0
	}
	
	sort_order = 100
	
	desc = ai_mogyer_adopt_christianity_desc
	selection_tooltip = ai_mogyer_adopt_christianity_tooltip
	
	is_shown = {
		OR = {
			has_game_rule = yes_all_histmod_conversions
			has_game_rule = yes_histmod_only_hungary_conversion
		}
		culture = { has_cultural_pillar = heritage_magyar }
		faith = faith:magyar_pagan
		current_date >= 1000.1.1
		game_start_date < 950.1.1
		sub_realm_size >= 30
		is_ai = yes
		OR = {
			primary_title = title:k_hungary
			primary_title = title:e_carpathia
		}
		#Neighbor to a Catholic kingdom or empire
		any_neighboring_top_liege_realm_owner = {
			faith = faith:catholic
			highest_held_title_tier >= tier_kingdom
		}
		#Can only do it once
		NOR = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_ai_mogyer_adopt_christianity
			}
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_revived_magyar_paganism
			}
		}
		#Magyar Paganism must not have been reformed
		religion:magyar_religion = {
			any_faith = {
				count = all
				has_doctrine_parameter = unreformed
			}
		}
	}
	
	is_valid_showing_failures_only = {
		is_available_ai_adult = yes
		is_at_war = no
		top_liege = this
	}
	
	effect = {
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:flag_ai_mogyer_adopt_christianity
		}
		save_scope_as = scoped_ruler
		faith = { save_scope_as = old_faith }
		cp:councillor_court_chaplain = {
			save_scope_as = old_priest
			if = {
				limit = { NOT = { has_relation_rival = root } }
				set_relation_rival = {
					target = root
					reason = traitor_to_old_faith
				}
			}
		}
		every_vassal = {
			limit = {
				faith = scope:old_faith
				NOR = {
					has_relation_rival = root
					is_imprisoned_by = root
					has_trait = zealous
					has_government = theocracy_government
				}
			}
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 25
			}
		}
		
		#Change yourself, and any willing vassals/family, over to Catholocism
		set_character_faith_with_conversion = faith:catholic
		#Gain nickname
		give_nickname = nick_the_holy
		if = {
			limit = { has_trait = cynical }
			remove_trait = cynical
			add_trait = zealous
		}
		add_piety = -1000
		add_piety_level = 1

		legend_seed_great_deed_faith_effect = {
			ANTAGONIST = scope:old_priest
			OLD_FAITH = scope:old_faith
		}
	
		#Notify players
		every_player = {
			limit = {
				capital_province = { geographical_region = world_europe }
			}
			trigger_event = histmod.0600
		}
	}
	
	ai_potential = {
		culture = { has_cultural_pillar = heritage_magyar }
		faith = faith:magyar_pagan
		OR = {
			primary_title = title:k_hungary
			primary_title = title:e_carpathia
		}
	}
	
	ai_will_do = {
		base = 10
		modifier = {
			add = 30
			has_trait = cynical
		}
		modifier = {
			add = 20
			current_date >= 1020.1.1
		}
		modifier = {
			add = 20
			current_date >= 1040.1.1
		}
		modifier = {
			add = 20
			current_date >= 1060.1.1
		}
		modifier = {
			factor = 0
			has_trait = zealous
		}
		modifier = {
			factor = 0
			years_as_ruler < 1
		}
	}
}

