﻿begin_conquer_russia_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 = 12
		empire = 0
		hegemony = 0
	}
	
	desc = begin_conquer_russia_decision_desc
	selection_tooltip = begin_conquer_russia_decision_tooltip
	
	is_shown = {
		is_ai = yes
		game_start_date < 1000.1.1
		current_year >= 880
		current_year < 1000
		has_game_rule = yes_full_stronger_rurikid
		NOR = {
			has_game_rule = no_conquerors_frequency
			# russian empire has never been formed
			exists = title:e_russia.holder
		}
		is_rurikid_candidate_ruler = yes
		can_be_histmod_conqueror = yes
		# no other Rurikid candidates who are players or who have larger realms
		NOT = {
			any_independent_ruler = {
				NOT = { this = root }
				is_rurikid_candidate_ruler = yes
				OR = {
					has_trait = conqueror
					has_character_modifier = ai_weak_conqueror_modifier
					is_ai = no
					AND = {
						can_be_histmod_conqueror = yes
						max_military_strength > root.max_military_strength
					}
				}
			}
		}
	}
	
	is_valid_showing_failures_only = {
		is_at_war = no
		is_available_ai_adult = yes
	}
	
	effect = {
		add_gold = 500
		add_prestige = 800
		add_character_flag = histmod_seeking_russia
		create_story = histmod_conqueror_story_cycle
		every_vassal = {
			limit = { has_vassal_stance = glory_hound }
			add_opinion = {
				modifier = approving_opinion
				target = root
				opinion = 20
			}
		}
		every_vassal = {
			limit = { has_vassal_stance = parochial }
			add_opinion = {
				modifier = disapproving_opinion
				opinion = -20
				target = root
			}
		}
		if = {
			limit = { has_fp1_dlc_trigger = yes }
			spawn_army = {
				name = varangian_novgorod_troops_name
				levies = 1000
				men_at_arms = {
					type = huscarl
					stacks = 5
				}
				men_at_arms = {
					type = varangian_veterans
					stacks = 5
				}
				men_at_arms = {
					type = armored_footmen
					stacks = 3
				}
				location = root.capital_province
				origin = root.capital_province
				inheritable = no
				uses_supply = no
			}
		}
		else = {
			spawn_army = {
				name = varangian_novgorod_troops_name
				levies = 1000
				men_at_arms = {
					type = huscarl
					stacks = 5
				}
				men_at_arms = {
					type = armored_footmen
					stacks = 5
				}
				location = root.capital_province
				origin = root.capital_province
				inheritable = no
				uses_supply = no
			}
		}
	}
	
	ai_potential = {
		is_landed = yes
		highest_held_title_tier >= tier_duchy
	}

	ai_will_do = {
		base = 100
	}
}

ai_russia_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_russia_adopt_christianity_desc
	selection_tooltip = ai_russia_adopt_christianity_tooltip
	
	is_shown = {
		OR = {
			has_game_rule = yes_all_histmod_conversions
			has_game_rule = yes_histmod_only_russia_conversion
		}
		culture = culture:russian
		faith = faith:slavic_pagan
		current_date >= 980.1.1
		game_start_date < 950.1.1
		sub_realm_size >= 30
		is_ai = yes
		OR = {
			highest_held_title_tier = tier_kingdom
			highest_held_title_tier = tier_empire
		}
		exists = capital_county
		capital_county.empire = title:e_russia
		title:e_byzantium = {
			exists = yes
			holder.faith = faith:orthodox
		}
		#Can only do it once
		NOR = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_ai_russia_adopt_christianity
			}
			any_independent_ruler = {
				OR = {
					highest_held_title_tier = tier_kingdom
					highest_held_title_tier = tier_empire
				}
				is_ai = yes
				culture = culture:russian
				faith = faith:slavic_pagan
				exists = capital_county
				capital_county.empire = title:e_russia
				sub_realm_size > root.sub_realm_size
			}
		}
		#Slavic Paganism must not have been reformed
		faith = { has_doctrine = unreformed_faith_doctrine }
	}
	
	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_russia_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 Orthodox
		set_character_faith_with_conversion = faith:orthodox
		#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 = {
				OR = {
					capital_province = { geographical_region = world_europe }
					capital_county.empire = title:e_byzantium
				}
			}
			trigger_event = histmod.0601
		}
	}
	
	ai_potential = {
		culture = culture:russian
		faith = faith:slavic_pagan
		OR = {
			highest_held_title_tier = tier_kingdom
			highest_held_title_tier = tier_empire
		}
	}
	
	ai_will_do = {
		base = 10
		modifier = {
			add = 30
			has_trait = cynical
		}
		modifier = {
			add = 20
			current_date >= 980.1.1
		}
		modifier = {
			add = 20
			current_date >= 1000.1.1
		}
		modifier = {
			add = 20
			current_date >= 1020.1.1
		}
		modifier = {
			factor = 0
			has_trait = zealous
		}
		modifier = {
			factor = 0
			years_as_ruler < 1
		}
	}
}

