###JD Decisions###

#Written by:
#Drikus Kuiper
#Matthew Clohessy


decisions = {

#	adopt_chinese_imperialism = {

#	}
#
#	raise_chinese_honor_guard = {
#		
#	}
#	
#	raise_chinese_regiment = {

#	}
#	
	tributary_independence_normal = {
		only_playable = yes
		is_high_prio = yes
		ai_check_interval = 6

		potential = {
			OR = {
				is_tributary = {
					type = default
				}
				is_tributary = {
					type = permanent
				}
				is_tributary = {
					type = nomadic
				}
			}
		}
		allow = {
			war = no
			conditional_tooltip = {
				trigger = { 
					is_tributary = {
						type = default
					}
				}
				suzerain = {
					independent = no
				}
			}
			conditional_tooltip = {
				trigger = { 
					is_tributary = {
						type = permanent
					}
				}
				suzerain = {
					OR = {
						AND = {
							NOT = {
								prestige = 0
							}
							ROOT = {
								prestige = 0
							}
							custom_tooltip = {
								text = recently_made_tributary_tt
								hidden_tooltip = {
									ROOT = {
										NOT = {
											has_opinion_modifier = {
												modifier = opinion_forced_tributary
												who = PREV
											}
										}
									}
								}
							}
						}
						relative_realm_size = {
							who = ROOT 
							size < 1
						}
						independent = no
					}
				}
			}
			conditional_tooltip = {
				trigger = { 
					is_tributary = {
						type = nomadic
					}
				}
				suzerain = {
					OR = {
						AND = {
							NOT = {
								prestige = 0
							}
							ROOT = {
								prestige = 0
							}
							custom_tooltip = {
								text = recently_made_tributary_tt
								hidden_tooltip = {
									suzerain = {
										ROOT = {
											NOT = {
												has_opinion_modifier = {
													modifier = opinion_forced_tributary
													who = PREV
												}
											}
										}
									}
								}
							}
						}
						is_nomadic = no
					}
				}
			}
		}
		effect = {
			any_suzerain = {
				character_event = { id = JD.2200 }
				remove_tributary = ROOT
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.5 # Slow down
				NOT = {
					trait = ambitious
				}
			}
		}
	}
	
#	tributary_independence_china = {

#	}

	write_a_book = {
		only_playable = yes
		ai_check_interval = 36

		potential = {
			age = 10
			learning = 1
			has_dlc = "Jade Dragon"
			is_landed = yes
			is_lowborn = no
		}
		allow = {
			learning = 8
			scaled_wealth = {
			    value = 1
			    min = 50
			    max = 1002
			}
			custom_tooltip = {
				text = not_currently_working_on_a_book_tt
				NOT = { has_character_flag = currently_working_on_a_book }
			}

			custom_tooltip = {
				text = has_not_explored_all_topics_tt
				NOT = { has_character_flag = has_explored_all_topics }

				OR = {
					NOT = { has_character_flag = wrote_about_dynasty }
					custom_tooltip = {
						text = has_an_education_or_related_attribute_above_ten_tt
						OR = {
							AND = {
								NOT = { has_character_flag = wrote_about_battle }
								OR = {
				    				martial = 10
				    				has_education_martial_trigger = yes
								}
							}
							AND = {
								NOT = { has_character_flag = wrote_about_administration }
								OR = {
									stewardship = 10
									has_education_stewardship_trigger = yes
								}
							}
							AND = {
								NOT = { has_character_flag = wrote_about_religion }
								OR = {
									learning = 10
									is_monastic_member_trigger = yes
									has_education_learning_trigger = yes
								}
							}
							AND = {
								NOT = { has_character_flag = wrote_about_relationships }
								OR = {
									diplomacy = 10
									intrigue = 10
									has_education_diplomacy_trigger = yes
									has_education_intrigue_trigger = yes
								}
							}
						}
					}
				}
			}
			NOT = { has_character_modifier = uninspired }
		}
		effect = {
			custom_tooltip = {
				text = choose_a_topic_tt
			}
			scaled_wealth = {
			    value = -1
			    min = -50
			    max = -1002
			}

			set_character_flag = currently_working_on_a_book
			character_event = { id = JD.10060 }
		}
		
		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1 #Slow down
			}
			modifier = {
				factor = 0.1
				NOR = {
					government = theocracy_government
					government = republic_government
				}
			}
			modifier = {
				factor = 0
				any_artifact = {
					has_artifact_flag = book
				}
			}
			modifier = {
				factor = 0.1
				trait = slothful
			}
			modifier = {
				factor = 0.1
				war = yes
			}
			modifier = {
				factor = 0.1
				is_inaccessible_trigger = yes
			}
			modifier = {
				factor = 0.1
				is_learned_trigger = no
			}
			modifier = {
				factor = 0.1
				has_top_tier_education_trait_trigger = no
			}
			modifier = {
				factor = 0.1
				has_bottom_tier_education_trait_trigger = yes
			}
		}
	}
	
#	bon_tolerate_indians = {

#	}
}

targeted_decisions = {
	negotiate_with_adventurer = {
		only_playable = yes
		
		filter = independent_rulers
		ai_target_filter = independent_rulers
		
		is_high_prio = yes

		ai_check_interval = 24

		from_potential = {
			independent = yes
			NOT = { culture = wilderness }
		}

		potential = {
			has_character_flag = raiding_adventurer
			OR = {
				location = {
					county = {
						holder_scope = {
							top_liege = {
								character = FROM
							}
						}
					}
				}
				any_unit = {
					location = {
						county = {
							holder_scope = {
								top_liege = {
									character = FROM
								}
							}
						}
					}
				}
			}
		}

		allow = {
			FROM = {
				show_scope_change = no
				higher_tier_than = DUKE
			}
			custom_tooltip = {
				text = not_negotiated_recently_tt
				hidden_tooltip = {
					FROM = {
						NOT = {
							has_character_modifier = adventurer_negotiate_cd
						}
					}
				}
			}
			custom_tooltip = {
				text = has_valid_province_tt
				hidden_tooltip = {
					FROM = {
						OR = {
							any_demesne_province = {
								is_capital = no 
								num_of_settlements = 1
								NOT = {
									has_province_modifier = nomad_agitation
								}
								OR = {
									AND = {
										ROOT = { is_seafarer = yes }
										port = yes
									}
									ROOT = { is_seafarer = no }
									NOT = { any_demesne_province = { port = yes } }
								}
							}
							any_vassal = {
								any_demesne_province = {
									is_capital = no 
									num_of_settlements = 1
									NOT = {
										has_province_modifier = nomad_agitation
									}
									OR = {
										AND = {
											ROOT = { is_seafarer = yes }
											port = yes
										}
										ROOT = { is_seafarer = no }
										NOT = { any_demesne_province = { port = yes } }
									}
								}
							}
						}
					}
				}
			}
		}

		effect = {
			FROM = {
				save_event_target_as = adventurer_decision_taker_override
				set_character_flag = negotiating_with_adventurer
				set_character_flag = peaceful_negotiation
				hidden_effect = {
					add_character_modifier = {
						name = adventurer_negotiate_cd
						hidden = yes
						years = 1
					}
				}
			}
			save_event_target_as = adventurer_decision_target_override
			FROM = {
				character_event = { id = ADV.1 }
			}
			custom_tooltip = {
				text = dangerous_negotiations_tt
			}
		}

		revoke_allowed = { always = no }

		ai_will_do = {
			factor = 0
		}
	}
}