﻿### Sponsor Persian Scholars ###
fp3_sponsor_persian_scholars_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_golden_age.dds"
	}
	desc = fp3_sponsor_persian_scholars_decision_desc
	selection_tooltip = fp3_sponsor_persian_scholars_decision_tooltip 
	sort_order = 175
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 120
		empire = 120
		hegemony = 120
	}

	is_shown = {
		culture = { has_cultural_pillar = heritage_iranian }
		has_fp3_dlc_trigger = yes
		can_employ_court_position_type = court_scholar_court_position
	}

	is_valid_showing_failures_only = {
		is_available_healthy_adult = yes
	}

	cost = { prestige = { value = medium_prestige_value } }	

	cooldown = { years = 5 }

	effect = {
		set_variable = {
			name = number_of_invite_scholars_countdown
			value = 3
			days = 1000
		}
		custom_tooltip = fp3_sponsor_persian_scholars_decision.tt
		trigger_event = {
			id = fp3_scholarship.0001
			days = { 20 40 }
		}
	}

	ai_potential = {
		can_employ_court_position_type = court_scholar_court_position
	}

	ai_will_do = {
		base = 0
		# Won't do if employs a decent court scholar already
		modifier = {
			factor = 0
			employs_court_position = court_scholar_court_position
			any_court_position_holder = {
				type = court_scholar_court_position
				aptitude:court_scholar_court_position > 1
			}
		}
		modifier = {
			add = 50
			culture = {
				culture_head ?= root
			}
		}
		modifier = {
			factor = 2
			has_trait = education_learning
		}
	}
}

### Sponsor Research Project ###
fp3_sponsor_research_project_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_golden_age.dds"
	}
	desc = fp3_sponsor_research_project_decision_desc
	selection_tooltip = fp3_sponsor_research_project_decision_tooltip 
	sort_order = 1000

	is_shown = {
		OR = {
			can_employ_court_position_type = court_scholar_court_position
			employs_court_position = court_scholar_court_position 
		}
	}
	is_valid = {
		employs_court_position = court_scholar_court_position 
		custom_tooltip = {
			text = fp3_sponsor_research_project_decision.trigger.learning
			any_court_position_holder = {
				type = court_scholar_court_position
				aptitude = {
					court_position = court_scholar_court_position
					value >= 3
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		trigger_if = {
			limit = {
				employs_court_position = court_scholar_court_position 
			}
			custom_tooltip = {
				text = fp3_sponsor_research_project_decision.trigger.is_available_healthy_adult
				any_court_position_holder = {
					type = court_scholar_court_position
					is_available_healthy_adult = yes
				}
			}
		}
		trigger_if = {
			limit = {
				employs_court_position = court_scholar_court_position 
			}
			custom_tooltip = {
				text = fp3_sponsor_research_project_decision.trigger.busy_inspiration
				any_court_position_holder = {
					type = court_scholar_court_position
					NOT = { exists = inspiration }
				}
			}
		}
	}

	widget = {
		gui = "decision_view_widget_generic_multichoice_with_effects"
		controller = decision_option_list_controller
		decision_to_second_step_button = "CHOOSE_RESEARCH_PATH"
		show_from_start = yes
		
		### Military
		item = {
			value = sponsor_military_research
			current_description = sponsor_military_research_desc
			localization = sponsor_military_research_name
			icon = "gfx/interface/icons/icon_prowess.dds"
			ai_chance = {
				value = 1
				if = {
					limit = {
						is_at_war = yes
					}
					add = 10
				}
				if = {
					limit = {
						martial > learning
					}
					add = 10
				}
			}
		}
		### Research
		item = {
			value = sponsor_civil_research
			current_description = sponsor_civil_research_desc
			localization = sponsor_civil_research_name
			icon = "gfx/interface/icons/icon_domain.dds"
			ai_chance = {
				value = 1
				if = {
					limit = {
						is_at_war = no
					}
					add = 5
				}	
				if = {
					limit = {
						stewardship > martial
					}
					add = 5
				}
				if = {
					limit = {
						learning > martial
					}
					add = 5
				}
			}
		}
	}

	cooldown = { years = 5 }

	cost = {
		gold = {
			value = 0
			if = {
				limit = {
					has_treasury = no
				}
				add = major_gold_value
			}
		}
		treasury = {
			value = 0
			if = {
				limit = {
					has_treasury = yes
				}
				add = major_gold_value
			}
		}
		prestige = medium_prestige_value
	}

	effect = {
		hidden_effect = {
			court_position:court_scholar_court_position ?= {
				set_variable = {
					name = research_success_chance
					value = {
						value = aptitude:court_scholar_court_position
						min = 1
					}
					years = 20 # Just in case
				}
				create_inspiration = research_inspiration
				if = {
					limit = { exists = inspiration }
					inspiration = {
						save_temporary_scope_as = research_project
					}
					root = { sponsor_inspiration = scope:research_project }
				}
			}
			trigger_event = {
				id = fp3_scholarship.8000
			}
		}
		if = {
			limit = {
				scope:sponsor_military_research = yes
			}
			custom_tooltip = {
				text = fp3_sponsor_military_research_project_decision.tt
				court_position:court_scholar_court_position ?= {
					remove_character_flag = civil_research
					add_character_flag = military_research
				}
			}
		}
		if = {
			limit = {
				scope:sponsor_civil_research = yes
			}
			custom_tooltip = {
				text = fp3_sponsor_civil_research_project_decision.tt
				court_position:court_scholar_court_position ?= {
					remove_character_flag = military_research
					add_character_flag = civil_research
				}
			}
		}
	}
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 120
		empire = 120
		hegemony = 120
	}
	ai_potential = {
		employs_court_position = court_scholar_court_position
		any_court_position_holder = {
			type = court_scholar_court_position
			aptitude = {
				court_position = court_scholar_court_position
				value >= 3
			}
		}
		gold >= massive_gold_value
	}
	ai_will_do = {
		base = 0
		modifier = {
			add = 5
			gold >= major_gold_value
		}
		modifier = {
			factor = 5
			learning >= 15
		}
		modifier = {
			factor = 10
			learning >= 20
		}
		modifier = {
			factor = 10
			OR = {
				has_trait = scholar
				has_trait = lifestyle_physician
				has_trait = lifestyle_mystic
			}
		}
		modifier = { # Has a tendency to spend money
			factor = 10
			OR = {
				has_trait = generous
				has_trait = improvident
			}
		}
		modifier = {
			factor = 0
			top_liege != this
		}
	}
}
