
#############################################
# Do some basic missionary work				#
# by James Beaumont							#
#############################################

hasan_evangelize_the_faith = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_secret_faith.dds"
	}
	sort_order = 500
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 36
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	desc = hasan_evangelize_the_faith_desc
	selection_tooltip = hasan_evangelize_the_faith_tooltip
	decision_group_type = story_cycle_hasan

	cooldown = { months = 1 }

	is_shown = {
		#DLC check.
		has_ep3_dlc_trigger = yes
		is_landed = no
		any_owned_story = {
			type = story_hasan
		}
	}

	is_valid = {
		domicile.domicile_location.county ?= {
			OR = {
				hasan_evangelize_province_trigger = yes
				custom_tooltip = {
					text = or_a_neigbouring_county_tt
					save_temporary_scope_as = county_check
					any_neighboring_county = {
						hasan_evangelize_province_trigger = yes
						holder.top_liege = scope:county_check.holder.top_liege
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_alive = yes
		is_available_adult = yes
		has_contagious_deadly_disease_trigger = no
	}

	cost = { piety = 250 }

	effect = {
		domicile.domicile_location.county ?= {
			if = {
				limit = { hasan_evangelize_province_trigger = yes }
				save_scope_as = location
			}
			else = {
				save_temporary_scope_as = county_check
				random_neighboring_county = {
					limit = {
						hasan_evangelize_province_trigger = yes
						holder.top_liege = scope:county_check.holder.top_liege
					}
					save_scope_as = location
				}
			}
		}
		trigger_event = hasan_sabbah.1010
		custom_tooltip = chance_to_advance_to_the_assassins_tt
	}

	ai_potential = { this = character:41702 }

	ai_will_do = {
		base = 200
	}
}
#############################################
# Do some RADICAL missionary work 🕶🤙		#
# by James Beaumont							#
#############################################

hasan_agitate_the_populace = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp3/antagonistic.dds"
	}
	sort_order = 500
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 36
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	desc = hasan_agitate_the_populace_desc
	selection_tooltip = hasan_agitate_the_populace_tooltip
	decision_group_type = story_cycle_hasan

	cooldown = { months = 1 }

	is_shown = {
		#DLC check.
		has_ep3_dlc_trigger = yes
		is_landed = no
		any_owned_story = {
			type = story_hasan
		}
	}

	is_valid = {
		hasan_camp_in_foes_realm_trigger = yes
		OR = {
			domicile.domicile_location.county = {
				faith != root.faith
				NOT = { has_county_modifier = ep3_agitated_populace }
				NOT = { has_county_modifier = tougher_to_convert }
			}
			custom_tooltip = {
				text = or_a_neigbouring_county_tt
				domicile.domicile_location.county = {
					save_temporary_scope_as = county_check
					any_neighboring_county = {
						faith != root.faith
						NOT = { has_county_modifier = ep3_agitated_populace }
						NOT = { has_county_modifier = tougher_to_convert }
						holder.top_liege = scope:county_check.holder.top_liege
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_alive = yes
		is_available_adult = yes
		has_contagious_deadly_disease_trigger = no
	}

	cost = { prestige = 250 }

	effect = {
		if = {
			limit = {
				domicile.domicile_location.county = {
					faith != root.faith
					NOT = { has_county_modifier = ep3_agitated_populace }
					NOT = { has_county_modifier = tougher_to_convert }
				}
			}
			domicile.domicile_location.county = { save_scope_as = location }
		}
		else = {
			domicile.domicile_location.county = {
				save_temporary_scope_as = county_check
				random_neighboring_county = {
					limit = {
						faith != root.faith
						NOT = { has_county_modifier = ep3_agitated_populace }
						NOT = { has_county_modifier = tougher_to_convert }
						holder.top_liege = scope:county_check.holder.top_liege
					}
					save_scope_as = location
				}
			}
		}
		trigger_event = hasan_sabbah.1040
	}

	ai_potential = { this = character:41702 }

	ai_will_do = {
		base = 200
	}
}
#############################################
# Become death, destroyer of Seljuks		#
# by James Beaumont							#
#############################################
hasan_ignite_the_flames = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_strength.dds"
	}
	sort_order = 500
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 36
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	desc = hasan_ignite_the_flames_desc
	selection_tooltip = hasan_ignite_the_flames_tooltip
	decision_group_type = story_cycle_hasan

	cooldown = { months = 1 }

	is_shown = {
		#DLC check.
		has_ep3_dlc_trigger = yes
		any_owned_story = {
			type = story_hasan
		}
	}

	is_valid = {
		hasan_camp_in_foes_realm_trigger = yes
		is_at_war = no
		custom_tooltip = {
			text = at_least_5_counties_are_nizari
			domicile.domicile_location.county.holder.top_liege = {
				any_sub_realm_county = {
					count >= 5
					faith = root.faith
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_alive = yes
		is_available_adult = yes
		has_contagious_deadly_disease_trigger = no
	}

	cost = {
		prestige = 250
	}

	effect = {
		random_owned_story = {
			type = story_hasan
			var:ultimate_foe = { save_scope_as = ultimate_foe }
		}
		hasan_sabbah_ignite_decision_effect = yes
	}

	ai_potential = { this = character:41702 }

	ai_will_do = {
		base = 200
	}
}

#############################################
# Found the Assassins						#
# by James Beaumont							#
#############################################
hasan_found_the_assassins = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_sunder.dds"
	}
	sort_order = 500
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 36
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	desc = hasan_found_the_assassins_desc
	selection_tooltip = hasan_found_the_assassins_tooltip
	decision_group_type = story_cycle_hasan

	is_shown = {
		#DLC check.
		has_ep3_dlc_trigger = yes
		any_owned_story = {
			type = story_hasan
			NOT = { exists = var:assassins }
		}
		is_landed = no
		faith = faith:nizari
		NOT = {
			has_character_flag = founded_assassins_already
		}
	}

	is_valid = {
		hasan_camp_in_foes_realm_trigger = yes
		domicile.domicile_location.barony = { is_leased_out = no }
		domicile.domicile_location.county.faith = root.faith
		custom_tooltip = {
			text = is_mountainous_desc
			domicile.domicile_location = { is_mountainous_trigger = yes }
		}
		domicile.domicile_location = {
			is_county_capital = no
		}
	}

	is_valid_showing_failures_only = {
		is_alive = yes
		is_available_adult = yes
		has_contagious_deadly_disease_trigger = no
	}

	cost = { piety = 1500 }

	effect = {
		domicile.domicile_location = { save_scope_as = location }
		if = {
			limit = {
				scope:location = {
					has_holding = no
				}
			}
			if = {
				limit = {
					scope:location.county.holder = {
						government_has_flag = government_is_tribal
					}
				}
				scope:location = {
					set_holding_type = church_holding
				}
			}
			else = {
				scope:location = {
					set_holding_type = castle_holding
				}
			}
		}
		create_character = {
			template = holy_order_leader_character
			location = scope:location
			save_scope_as = leader
		}
		hidden_effect = {
			create_title_and_vassal_change = {
				type = leased_out
				save_scope_as = change
				add_claim_on_loss = no
			}
			scope:location.barony = {
				change_title_holder_include_vassals = {
					holder = scope:location.barony.holder.top_liege
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change
		}
		create_holy_order = {
			leader = scope:leader
			capital = scope:location.barony
			save_scope_as = new_holy_order
		}
		scope:new_holy_order ?= {
			title = { set_title_name = holy_order_hashshashin }
		}
		create_holy_order_effect = yes
		random_owned_story = {
			type = story_hasan
			set_variable = {
				name = assassins
				value = scope:new_holy_order
			}
		}
		add_character_flag = founded_assassins_already
		scope:location = {
			if = {
				limit = {
					has_special_building = no
				}
				add_special_building = assassin_castle_01
			}
			else_if = {
				limit = {
					has_building_or_higher = alamut_castle_01
				}
				hidden_effect = {
					remove_building = alamut_castle_01
				}
				add_special_building = alamut_castle_02
			}
		}
		add_intrigue_skill = 2
		give_nickname = nick_old_man_of_the_mountain
	}

	ai_potential = { this = character:41702 }

	ai_will_do = {
		base = 200
	}
}

#############################################
# Expand the Assassins						#
# by James Beaumont							#
#############################################
hasan_expand_the_assassins = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_legitimacy.dds"
	}
	sort_order = 500
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 36
		kingdom = 0
		empire = 0
		hegemony = 0
	}

	desc = hasan_expand_the_assassins_desc
	selection_tooltip = hasan_expand_the_assassins_tooltip
	decision_group_type = story_cycle_hasan

	is_shown = {
		#DLC check.
		has_ep3_dlc_trigger = yes
		any_owned_story = {
			type = story_hasan
			has_variable = assassins
		}
		is_landed = no
		faith = faith:nizari
	}

	is_valid = {
		hasan_camp_in_foes_realm_trigger = yes
		domicile.domicile_location.barony = { is_leased_out = no }
		domicile.domicile_location.county.faith = root.faith
		custom_tooltip = {
			text = is_mountainous_desc
			domicile.domicile_location = { is_mountainous_trigger = yes }
		}
	}

	is_valid_showing_failures_only = {
		is_alive = yes
		is_available_adult = yes
		has_contagious_deadly_disease_trigger = no
		domicile.domicile_location = { is_county_capital = no }
	}

	cost = { piety = 250 }

	effect = {
		random_owned_story = {
			type = story_hasan
			var:assassins = { save_scope_as = assassins }
		}
		show_as_tooltip = {
			domicile.domicile_location.barony = { lease_out_to = scope:assassins }
		}
		hidden_effect = {
			if = {
				limit = { domicile.domicile_location.barony.holder != root }
				create_title_and_vassal_change = {
					type = leased_out
					save_scope_as = change
					add_claim_on_loss = no
				}
				domicile.domicile_location.barony = {
					change_title_holder_include_vassals = {
						holder = holder.top_liege
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
				domicile.domicile_location.barony = { lease_out_to = scope:assassins }
			}
		}
	}

	ai_potential = { this = character:41702 }

	ai_will_do = {
		base = 200
	}
}


