###DECISIONS LIST###

##
#Become Chakravarti
#Become Lord/Lady of the Sacred River
#Declare Bene Israel
#Found the Empire of Hindustan
##


##########
#Become Chakravarti
# by Petter Vilberg
### Become Chakravarti ###
become_chakravarti_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/hindu_ruler.dds"
	}
	decision_group_type = major
	desc = become_chakravarti_decision_desc

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

	is_shown = {
		OR = {
			religion = religion:hinduism_religion
			religion = religion:buddhism_religion
			religion = religion:jainism_religion
		}
		highest_held_title_tier >= tier_kingdom
		capital_province = {
			geographical_region = world_india
		}
		
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:become_chakravarti_decision
			}
		}
	}

	is_valid = {
		completely_controls = title:e_rajastan
		completely_controls = title:e_deccan
		completely_controls = title:e_bengal
		piety_level >= 5
	}

	is_valid_showing_failures_only = {
		is_landed = yes
		is_adult = yes
		is_available = yes
		top_liege = this
	}

	cost = {
		piety = {
			value = massive_piety_value
		}
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
				}
				add = massive_gold_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
				}
				add = massive_gold_value
			}
		}
	}

	effect = {
		gain_heroic_legend_seed_tooltip_effect = yes
		#Can only happen once
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:become_chakravarti_decision
		}

		custom_tooltip = become_chakravarti_decision_indian_empires_unite_effect
		custom_tooltip = become_chakravarti_decision_new_primary_title_effect
		show_as_tooltip = {
			add_trait = chakravarti
			add_prestige = massive_prestige_value
			add_prestige_level = 2
			faith = {
				add_doctrine = divine_destiny_doctrine
				change_fervor = {
					value = major_fervor_gain
					desc = fervor_gain_chakravarti
				}
			}
		}

		save_scope_as = chakravarti

		trigger_event = south_asia.0001 #I became the Chakravarti
		add_to_temporary_list = received_notification

		every_vassal_or_below = {
			if = {
				limit = {
					OR = {
						faith.religion = faith:vaishnavism.religion
						faith.religion = faith:theravada.religion
						faith.religion = faith:digambara.religion		
					}
				}
				trigger_event = south_asia.0002 #My ruler became the Chakravarti
			}
			else = {
				trigger_event = south_asia.0003 #My ruler became the Chakravarti - convert?
			}
			add_to_temporary_list = received_notification
		}

		every_ruler = {
			limit = {
				NOT = {
					is_in_list = received_notification
				}
			}

			trigger_event = south_asia.0004 #Someone has become the Chakravarti
		}
	}

	ai_will_do = {
		base = 100
	}
}

##########
#Become Lord/Lady of the Sacred River
# by Petter Vilberg
### Take Stewardship of the Sacred River ###
take_stewardship_of_the_sacred_river_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/hindu_religious.dds"
	}
	decision_group_type = major
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 120
		kingdom = 120
		empire = 120
		hegemony = 120
	}

	desc = take_stewardship_of_the_sacred_river_decision_desc

	is_shown = {
		religion = religion:hinduism_religion
		highest_held_title_tier >= tier_duchy
		NOT = { has_character_modifier = ruler_of_the_ganges_modifier }
		#Only if the Hindu Mandala already has their capital in the area
		trigger_if = {
			limit = { government_has_flag = government_is_mandala }
			capital_province = { geographical_region = custom_ganges_plain }
		}
	}

	is_valid = {
		completely_controls_region = custom_ganges_plain
		custom_description = {
			text = capital_province_in_ganges_region
			capital_province = { geographical_region = custom_ganges_plain }
		}
		prestige_level >= 3
		piety_level >= 1
	}

	is_valid_showing_failures_only = {
		is_landed = yes
		is_adult = yes
		is_available = yes
		trigger_if = {
			limit = { has_global_variable = ruler_of_ganges }
			custom_description = {
				text = capital_province_in_ganges_region
				NOR = {
					global_var:ruler_of_ganges = {
						is_alive = yes
						target_is_liege_or_above = root
					}
					AND = {
						global_var:ruler_of_ganges = { is_alive = yes }
						target_is_liege_or_above = global_var:ruler_of_ganges
					}
				}
			}
		}
	}

	cost = {
		piety = {
			value = major_prestige_value
		}
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
				}
				add = major_gold_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
				}
				add = major_gold_value
			}
		}
	}

	effect = {
		gain_heroic_legend_seed_tooltip_effect = yes
		show_as_tooltip = {
			take_stewardship_of_the_sacred_river_effect = yes
		}

		save_scope_as = ruler_of_ganges

		trigger_event = south_asia.0011
		add_to_temporary_list = ruler_of_ganges_notification_sent

		if = {
			limit = {
				exists = global_var:ruler_of_ganges
				global_var:ruler_of_ganges = {
					is_alive = yes
				}
			}
			global_var:ruler_of_ganges = {
				trigger_event = {
				 id = south_asia.0013 #Someone else has taken my title
				 days = 3
				}
				add_to_temporary_list = ruler_of_ganges_notification_sent
			}
		}

		if = { #Only send notification the first time the decision is taken
			limit = {
				NOT = { has_global_variable = ruler_of_ganges_notification_sent }
			}
			every_independent_ruler = {
				limit = {
					religion = religion:hinduism_religion
				}
				trigger_event = {
					id = south_asia.0012
					days = 3
				}
				add_to_temporary_list = ruler_of_ganges_notification_sent
			}
			set_global_variable = {
				name = ruler_of_ganges_notification_sent
				value = yes
			}
		}
	}

	ai_will_do = {
		base = 100
	}
}

##########
#Declare Bene Israel
# by James Beaumont
### Consolidate Bene Israel ###
form_bene_israel_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_found_kingdom.dds"
	}
	decision_group_type = major

	desc = form_bene_israel_decision_desc
	selection_tooltip = form_bene_israel_decision_tooltip

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

	is_shown = {
		is_ruler = yes
		is_playable_character = yes
		faith = faith:malabarism
		highest_held_title_tier = tier_duchy
		capital_province = { geographical_region = world_india }
		
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:form_bene_israel_decision
			}
		}
	}

	is_valid = {
		has_title = title:d_chera_nadu
		has_title = title:d_konkana
		completely_controls = title:d_chera_nadu
		completely_controls = title:d_konkana
		custom_description = {
			text = malabarism_religious_head_exists_tt
			subject = this
			faith = { exists = religious_head }
		}
		piety_level >= 3
	}

	is_valid_showing_failures_only = {
		is_landed = yes
		is_adult = yes
		is_available = yes
		top_liege = this
	}

	cost = {
		piety = {
			value = medium_piety_value
		}
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
				}
				add = medium_gold_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
				}
				add = medium_gold_value
			}
		}
	}

	effect = {
		#Can only happen once
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:form_bene_israel_decision
		}

		save_scope_as = founder

		show_as_tooltip = {
			unite_bene_israel_effect = yes
		}

		trigger_event = south_asia.0021 #I formed Bene Israel
		
		every_player = {
			limit = {
				this != scope:founder
				top_liege = {
					OR = {
						this = scope:founder
						any_neighboring_and_across_water_top_liege_realm_owner = { this = scope:founder }
					}
				}
			}
			trigger_event = south_asia.0022
		}
	}

	ai_will_do = {
		base = 100
	}
}

######################################
##	Establish the Theravada Faith	##
##									##
##			by Nick Meredith		##
##			in memory of RDH		##
######################################

### Spread the [ROOT.Char.GetFaith.GetNameNoTooltip] Faith ###
spread_theravada_faith_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/hindu_religious.dds"
	}
	decision_group_type = major
	title = spread_theravada_faith_decision
	desc = spread_theravada_faith_decision_desc
	confirm_text = spread_theravada_faith_decision_confirm # had to use an override for some reason
	selection_tooltip = spread_theravada_faith_decision_tooltip # same here

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 120
		empire = 120
		hegemony = 120
	}
	cooldown = { days = 365 }

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		faith = faith:theravada

		OR = {
			culture = culture:burmese
			culture = culture:mon
		}
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:spread_theravada_faith_flag
			}
		}
		any_vassal = { #so that potential later events don't break
			has_faith = faith:ari
			is_powerful_vassal = yes
		}
		exists = cp:councillor_court_chaplain
	}

	is_valid = {
		highest_held_title_tier >= tier_kingdom
		faith = faith:theravada

		OR = {
			culture = culture:burmese
			culture = culture:mon
		}
		prestige_level >= 3
		piety_level >= 2
	}
	
	is_valid_showing_failures_only = {
		is_landed = yes
	}

	cost = {
		piety = {
			value = major_piety_value
		}
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
				}
				add = medium_gold_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
				}
				add = medium_gold_value
			}
		}
		prestige = {
			value = massive_prestige_value
		}
	}

	effect = {

		show_as_tooltip = {
			custom_tooltip = spread_theravada_faith_decision_cus_tt
		}

		trigger_event = {
			id = south_asia.0030
		}
	}

	ai_will_do = {
		base = 100
	}
}

######################################
##	Found the empire of Hindustan	##
##									##
##			by Henrik Lohmander		##
######################################

### Found the Empire of Hindustan ###
found_the_empire_of_hindustan_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_sunder.dds"
	}
	decision_group_type = major

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

	is_shown = {
		is_landed_or_landless_administrative = yes
		exists = dynasty # Everyone should have a dynasty, but in case they don't...
		NOT = {	#Title existance conditions.
			exists = title:e_hindustan.holder #Empire of Hindustan
		}
		capital_province = {
			OR = {
				geographical_region = world_khorasan
				geographical_region = world_transoxiana
				geographical_region = world_makran
				geographical_region = world_kabulistan
				geographical_region = world_india
				geographical_region = world_burma
			}
		}
		NOT = {	#You can only do it once.
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_founded_hindustan
			}
		}
		faith = {
			religion_tag = islam_religion
		}
		OR = {	#Government conditions.
			government_has_flag = government_is_feudal
			government_has_flag = government_is_clan
			government_allows = administrative
			government_has_flag = government_is_landless_adventurer
		}
		OR = {
			highest_held_title_tier <= tier_kingdom
			has_title = title:e_bengal
			has_title = title:e_deccan
			has_title = title:e_rajastan 
		}
	}

	is_valid = {
		#Standard requirements.
		is_independent_ruler = yes
		prestige_level >= very_high_prestige_level
		piety_level >= high_piety_level
		#Title ownership conditions.
		#This is currently significantly easier for AI to get the ball rolling
		trigger_if = {
			limit = {
				is_ai = yes
			}
			OR = {
				completely_controls = title:k_punjab
				has_title = title:k_punjab
			}
			OR = {
				completely_controls = title:k_delhi
				has_title = title:k_delhi
			}
		}
		trigger_if = {
			limit = {
				is_ai = no
			} #And have some additional royal dignity for good measure.
			has_title = title:k_punjab
			has_title = title:k_delhi
			completely_controls = title:d_kuru
			OR = {
				has_title = title:k_kosala
				has_title = title:k_malwa
				has_title = title:k_rajputana
			}
		}
		sub_realm_size >= 40 #This is roughly equal to Punjab, Delhi and Kosala.

		#HoF preference conditions.
		trigger_if = {
			limit = {
				is_ai = no
				exists = faith.religious_head
			}
			OR = {
				faith.religious_head = {	#And they have to actually like you enough to want to invest you.
					opinion = {
						target = root
						value >= high_positive_opinion
					}
				}
				root = { has_strong_usable_hook = faith.religious_head }	#Or you have a strong hook on them that you can actually use.
				root = { has_weak_hook = faith.religious_head }	#Or a regular hook, to be fair, provided you meet the other criteria.
			}
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
	}

	effect = {
		save_scope_as = founder
		show_as_tooltip = {
			found_empire_of_hindustan_scripted_effect = yes
		}
		gain_heroic_legend_seed_tooltip_effect = yes
		if = {
			limit = {
				faith.religious_head ?= { is_playable_character = yes }
			}
			faith.religious_head = { save_scope_as = founder_hof }
			faith.religious_head.capital_province = { save_scope_as = ceremony_locale }
		}
		else = {
			capital_province = { save_scope_as = ceremony_locale }
		}
		trigger_event = {
			id = south_asia.0050
		}
		#Notify other players.
		every_player = {
			limit = {
				is_ai = no
				NOT = { this = root }
				is_within_diplo_range = { CHARACTER = root }
			}
			trigger_event = south_asia.0051
		}
		hidden_effect = {
			add_to_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:flag_founded_hindustan
			}
		}
	}

	cost = {
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
					is_ai = no
				}
				add = 500
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
					is_ai = no
				}
				add = 500
			}
		}
		piety = 200
	}

	ai_potential = {
		is_independent_ruler = yes
	}

	ai_will_do = {
		base = 100
	}
}
