﻿#EK NOTE: removed mentions of byzantium
###DECISIONS LIST###

#decision_solve_the_journals

decision_solve_the_journals = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_realm.dds"
	}
	decision_group_type = major
	ai_check_interval = 120
	desc = decision_solve_the_journals_desc
	cooldown = { years = 1 }

	is_shown = {
		any_owned_story = {
			story_type = story_cycle_mysterious_journal
			NOT = { exists = var:journal_complete_solved }
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
	}

	is_valid = {
		custom_tooltip = {
			text = you_have_journal_1_tt
			any_owned_story = {
				story_type = story_cycle_mysterious_journal
				exists = var:mysterious_journal.var:secret_journal
			}
		}
		custom_tooltip = {
			text = you_have_journal_2_tt
			any_owned_story = {
				story_type = story_cycle_mysterious_journal
				exists = var:mysterious_journal.var:secret_puzzle
			}
		}
		custom_tooltip = {
			text = you_have_journal_3_tt
			any_owned_story = {
				story_type = story_cycle_mysterious_journal
				exists = var:mysterious_journal.var:secret_cipher
			}
		}
	}

	effect = {
		hidden_effect = {
			random_owned_story = {
				limit = { story_type = story_cycle_mysterious_journal }
				var:mysterious_journal = { save_scope_as = mysterious_journal }
			}
		}
		duel = {
			skill = learning
			value = high_skill_rating
			50 = { # You solve the puzzle!
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				custom_tooltip = {
					text = open_the_journal_tt
					trigger_event = tour_general.5010
				}
			}
			50 = { # You fail
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				show_as_tooltip = {
					add_stress = major_stress_gain
				}
				hidden_effect = {
					trigger_event = tour_general.5000
				}
			}
		}
	}
	

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}


call_for_acclaimed_knight_candidates_decision = {
	#EK DISABLED: no Byzantium
	#picture = {
	#	trigger = {
	#		NOR = {
	#			government_has_flag = government_is_tribal
	#			government_has_flag = government_is_theocracy
	#			top_liege ?= { government_has_flag = government_is_tribal }
	#			top_liege ?= { government_has_flag = government_is_theocracy }
	#		}
	#		OR = {
	#			culture = { has_cultural_pillar = heritage_byzantine }
	#			top_liege ?= {
	#				OR = {
	#					culture = { has_cultural_pillar = heritage_byzantine }
	#					capital_barony ?= title:b_constantinople
	#					primary_title ?= title:e_byzantium
	#					primary_title ?= title:e_roman_empire
	#				}
	#			}
	#		}
	#	}
	#	reference = "gfx/interface/illustrations/decisions/ep3_cerimonial_decision.dds"
	#}
	picture = {
		trigger = {
			government_has_flag = government_is_nomadic
		}
		reference = "gfx/interface/illustrations/decisions/mpo_decision_confederation.dds"
	}
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_knight_kneeling.dds"
	}
	ai_check_interval = 180
	desc = call_for_acclaimed_knight_candidates_decision_desc
	cooldown = { years = 5 }
	decision_group_type = courtier

	is_shown = {
		has_dlc_feature = accolades
		any_accolade = {
			is_accolade_active = no
		}
		is_landed_or_landless_administrative = yes
	}

	is_valid = {
		custom_tooltip = {
			text = you_have_empty_accolades
			any_accolade = {
				is_accolade_active = no
				NOT = { exists = accolade_successor }
				has_potential_accolade_successors = no
				NOT = {
					primary_type = {
						this = accolade_type:house_knight_attribute 
					}
				}
			}
			exists = root.capital_province
			highest_held_title_tier >= tier_county
			NOT = { government_has_flag = government_is_theocracy }
		}
		
	}

	effect = {
		custom_tooltip = call_for_acclaimed_knight_candidates_decision.tt
		save_scope_as = accolade_owner
		# save all the accolades that are missing knights
		random_accolade = {
			limit = {
				is_accolade_active = no
				NOT = { exists = accolade_successor }
				has_potential_accolade_successors = no
				NOT = {
					primary_type = {
						this = accolade_type:house_knight_attribute 
					}
				}
			}
			save_scope_as = empty_accolade_1
		}
		random_accolade = {
			limit = {
				is_accolade_active = no
				NOT = { exists = accolade_successor }
				has_potential_accolade_successors = no
				NOT = {
					primary_type = {
						this = accolade_type:house_knight_attribute 
					}
				}
				NOT = { this = scope:empty_accolade_1 }
			}
			save_scope_as = empty_accolade_2
		}
		random_accolade = {
			limit = {
				is_accolade_active = no
				NOT = { exists = accolade_successor }
				has_potential_accolade_successors = no
				NOT = {
					primary_type = {
						this = accolade_type:house_knight_attribute 
					}
				}
				NOR = {
					this = scope:empty_accolade_1
					this = scope:empty_accolade_2
				}
			}
			save_scope_as = empty_accolade_3
		}
		random_accolade = {
			limit = {
				is_accolade_active = no
				NOT = { exists = accolade_successor }
				has_potential_accolade_successors = no
				NOT = {
					primary_type = {
						this = accolade_type:house_knight_attribute 
					}
				}
				NOR = {
					this = scope:empty_accolade_1
					this = scope:empty_accolade_2
					this = scope:empty_accolade_3
				}
			}
			save_scope_as = empty_accolade_4
		}
		random_accolade = {
			limit = {
				is_accolade_active = no
				NOT = { exists = accolade_successor }
				has_potential_accolade_successors = no
				NOT = {
					primary_type = {
						this = accolade_type:house_knight_attribute 
					}
				}
				NOR = {
					this = scope:empty_accolade_1
					this = scope:empty_accolade_2
					this = scope:empty_accolade_3
					this = scope:empty_accolade_4
				}
			}
			save_scope_as = empty_accolade_5
		}
		#accolade 1 event
		trigger_event = {
			id = accolade.0008
			days = { 10 20 }
		}
		if = {
			limit = {
				exists = scope:empty_accolade_2
			}
			#accolade 2 event
			trigger_event = {
				id = accolade.0009
				days = { 20 30 }
			}
		}
		if = {
			limit = {
				exists = scope:empty_accolade_3
			}
			#accolade 3 event
			trigger_event = {
				id = accolade.0010
				days = { 30 40 }
			}
		}
		if = {
			limit = {
				exists = scope:empty_accolade_4
			}
			#accolade 4 event
			trigger_event = {
				id = accolade.0011
				days = { 40 50 }
			}
		}
		if = {
			limit = {
				exists = scope:empty_accolade_5
			}
			#accolade 5 event
			trigger_event = {
				id = accolade.0012
				days = { 50 60 }
			}
		}
	}

	cost = {
		prestige = {
			value = 100
			if = {
				limit = {
					highest_held_title_tier >= tier_empire
				}
				add = 100
			}
			else_if = {
				limit = {
					highest_held_title_tier = tier_kingdom
				}
				add = 50
			}
			else_if = {
				limit = {
					highest_held_title_tier = tier_duchy
				}
				add = 25
			}
			if = {
				limit = {
					any_accolade = {
						is_accolade_active = no
						NOT = { exists = accolade_successor }
						has_potential_accolade_successors = no
						NOT = {
							primary_type = {
								this = accolade_type:house_knight_attribute 
							}
						}
					}
				}
				multiply = num_accolades_multiplier
			}
		}
	}

	ai_potential = {
		has_dlc_feature = accolades
	}

	ai_will_do = {
		base = 200
		modifier = {
			any_accolade = {
				is_accolade_active = no
				NOT = { exists = accolade_successor }
				has_potential_accolade_successors = no
				NOT = {
					primary_type = {
						this = accolade_type:house_knight_attribute 
					}
				}
				accolade_rank > 1
			}
			add = 200
		}
		modifier = {
			any_accolade = {
				is_accolade_active = no
				NOT = { exists = accolade_successor }
				has_potential_accolade_successors = no
				NOT = {
					primary_type = {
						this = accolade_type:house_knight_attribute 
					}
				}
				accolade_rank > 3
			}
			add = 500
		}
	}
}
