﻿
gptl_change_laws_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/gptl_change_laws.dds" }
	decision_group_type = major

	title = gptl_change_laws_decision_title
	desc = gptl_change_laws_decision_desc
	selection_tooltip = gptl_change_laws_decision_tooltip
	confirm_text = gptl_change_laws_decision_confirm

	cooldown = { 
		years = 10
	}

	is_shown = {
		is_ai = no
		age >= 12
		is_available = yes
		gptl_basic_liege_trigger = yes
		any_powerful_vassal = {
			count >= 2
			age >= 12
			is_available = yes
			is_imprisoned = no
			is_tributary = no
		}
		gptl_basic_pass_trigger = no
	}

	is_valid = {
		number_of_powerful_vassals >= 4
		is_adult = yes
		is_at_war = no
		has_active_diarchy = no
		is_imprisoned = no
	 #	days_as_ruler >= 1800
	}
	
	cost = {
		prestige = 500
	}

	effect = {
		add_legitimacy = 125

		if = { limit = { has_trait = gregarious } custom_tooltip = gptl_tooltip_gregarious }
		if = { limit = { has_trait = shy } custom_tooltip = gptl_tooltip_shy }
		if = { limit = { has_trait = vengeful } custom_tooltip = gptl_tooltip_vengeful }
		if = { limit = { has_trait = forgiving } custom_tooltip = gptl_tooltip_forgiving }
		if = { limit = { has_trait = zealous } custom_tooltip = gptl_tooltip_zealous }
		if = { limit = { has_trait = cynical } custom_tooltip = gptl_tooltip_cynical }
		if = { limit = { has_trait = compassionate } custom_tooltip = gptl_tooltip_compassionate }
		if = { limit = { has_trait = callous } custom_tooltip = gptl_tooltip_callous }
		if = { limit = { has_trait = brave } custom_tooltip = gptl_tooltip_brave }
		if = { limit = { has_trait = craven } custom_tooltip = gptl_tooltip_craven }
		if = { limit = { has_trait = generous } custom_tooltip = gptl_tooltip_generous }
		if = { limit = { has_trait = greedy } custom_tooltip = gptl_tooltip_greedy }
		if = { limit = { has_trait = just } custom_tooltip = gptl_tooltip_just }
		if = { limit = { has_trait = arbitrary } custom_tooltip = gptl_tooltip_arbitrary }
		if = { limit = { has_trait = trusting } custom_tooltip = gptl_tooltip_trusting }
		if = { limit = { has_trait = paranoid } custom_tooltip = gptl_tooltip_paranoid }
		if = { limit = { has_trait = lustful } custom_tooltip = gptl_tooltip_lustful }
		if = { limit = { has_trait = chaste } custom_tooltip = gptl_tooltip_chaste }
		if = { limit = { has_trait = humble } custom_tooltip = gptl_tooltip_humble }
		if = { limit = { has_trait = arrogant } custom_tooltip = gptl_tooltip_arrogant }
		if = { limit = { has_trait = honest } custom_tooltip = gptl_tooltip_honest }
		if = { limit = { has_trait = deceitful } custom_tooltip = gptl_tooltip_deceitful }
		if = { limit = { has_trait = fickle } custom_tooltip = gptl_tooltip_fickle }
		if = { limit = { has_trait = stubborn } custom_tooltip = gptl_tooltip_stubborn }
		if = { limit = { has_trait = temperate } custom_tooltip = gptl_tooltip_temperate }
		if = { limit = { has_trait = gluttonous } custom_tooltip = gptl_tooltip_gluttonous }
		if = { limit = { has_trait = sadistic } custom_tooltip = gptl_tooltip_sadistic }
		if = { limit = { has_trait = eccentric } custom_tooltip = gptl_tooltip_eccentric }

		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = gregarious } } custom_tooltip = gptl_tooltip_gregarious_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = vengeful } } custom_tooltip = gptl_tooltip_vengeful_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = shy } } custom_tooltip = gptl_tooltip_shy_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = forgiving } } custom_tooltip = gptl_tooltip_forgiving_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = zealous } } custom_tooltip = gptl_tooltip_zealous_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = cynical } } custom_tooltip = gptl_tooltip_cynical_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = compassionate } } custom_tooltip = gptl_tooltip_compassionate_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = callous } } custom_tooltip = gptl_tooltip_callous_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = brave } } custom_tooltip = gptl_tooltip_brave_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = craven } } custom_tooltip = gptl_tooltip_craven_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = generous } } custom_tooltip = gptl_tooltip_generous_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = greedy } } custom_tooltip = gptl_tooltip_greedy_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = just } } custom_tooltip = gptl_tooltip_just_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = arbitrary } } custom_tooltip = gptl_tooltip_arbitrary_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = trusting } } custom_tooltip = gptl_tooltip_trusting_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = paranoid } } custom_tooltip = gptl_tooltip_paranoid_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = lustful } } custom_tooltip = gptl_tooltip_lustful_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = chaste } } custom_tooltip = gptl_tooltip_chaste_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = humble } } custom_tooltip = gptl_tooltip_humble_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = arrogant } } custom_tooltip = gptl_tooltip_arrogant_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = honest } } custom_tooltip = gptl_tooltip_honest_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = deceitful } } custom_tooltip = gptl_tooltip_deceitful_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = fickle } } custom_tooltip = gptl_tooltip_fickle_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = stubborn } } custom_tooltip = gptl_tooltip_stubborn_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = temperate } } custom_tooltip = gptl_tooltip_temperate_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = gluttonous } } custom_tooltip = gptl_tooltip_gluttonous_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = sadistic } } custom_tooltip = gptl_tooltip_sadistic_vassals }
		if = { limit = { any_powerful_vassal = { count >= 2 has_trait = eccentric } } custom_tooltip = gptl_tooltip_eccentric_vassals }

		if = {
			limit = { number_of_powerful_vassals >= 1 }
			random_powerful_vassal = {
				limit = { age >= 12 is_available = yes is_imprisoned = no }
				save_scope_as = gptl_pv1
			}
		}
		if = {
			limit = { number_of_powerful_vassals >= 2 }
			random_powerful_vassal = {
				limit = { age >= 12 is_available = yes is_imprisoned = no NOT = { this = scope:gptl_pv1 } }
				save_scope_as = gptl_pv2
			}
		}
		if = {
			limit = { number_of_powerful_vassals >= 3 }
			random_powerful_vassal = {
				limit = { age >= 12 is_imprisoned = no NOR = { 
					this = scope:gptl_pv1
					this = scope:gptl_pv2
				} }
				save_scope_as = gptl_pv3
			}
		}
		if = {
			limit = { number_of_powerful_vassals >= 4 }
			random_powerful_vassal = {
				limit = { age >= 12 is_imprisoned = no NOR = { 
					this = scope:gptl_pv1
					this = scope:gptl_pv2
					this = scope:gptl_pv3
				} }
				save_scope_as = gptl_pv4
			}
		}
		if = {
			limit = { number_of_powerful_vassals >= 5 }
			random_powerful_vassal = {
				limit = { age >= 12 is_imprisoned = no NOR = { 
					this = scope:gptl_pv1
					this = scope:gptl_pv2
					this = scope:gptl_pv3
					this = scope:gptl_pv4
				} }
				save_scope_as = gptl_pv5
			}
		}
		trigger_event = { id = gptl_intro_events.01 }
		trigger_event = { id = gptl_intro_events.99 days = 5 }
	}

	ai_will_do = {
		base = 0
	}
}

gptl_change_laws_decision_ai = {
	picture = { reference = "gfx/interface/illustrations/decisions/gptl_change_laws.dds" }
	decision_group_type = major

	title = gptl_change_laws_decision_title
	desc = gptl_change_laws_decision_desc
	selection_tooltip = gptl_change_laws_decision_tooltip
	confirm_text = gptl_change_laws_decision_confirm

	ai_check_interval = 6

	cooldown = { 
		years = 8
	}

	is_shown = {
		is_ai = yes
		is_available = yes
		years_from_game_start >= 8
		gptl_basic_liege_trigger = yes
		any_vassal_or_below = {
			is_ai = no
			age >= 14
			gptl_basic_vassal_trigger = yes
		}
		number_of_powerful_vassals >= 4
		any_powerful_vassal = {
			count >= 2
			age >= 12
			is_available = yes
			is_imprisoned = no
		}
	}

	is_valid = {
		days_as_ruler >= 2880
		is_adult = yes
		is_at_war = no
	 	has_active_diarchy = no
		is_imprisoned = no
	}
	
	cost = {
	}

	effect = {
		if = {
			limit = { number_of_powerful_vassals >= 1 }
			random_powerful_vassal = {
				limit = { is_ai = yes age >= 12 is_available = yes is_imprisoned = no is_tributary = no }
				save_scope_as = gptl_pv1
			}
		}
		if = {
			limit = { number_of_powerful_vassals >= 2 }
			random_powerful_vassal = {
				limit = { is_ai = yes age >= 12 is_available = yes is_imprisoned = no is_tributary = no NOT = { this = scope:gptl_pv1 } }
				save_scope_as = gptl_pv2
			}
		}
		if = {
			limit = { number_of_powerful_vassals >= 3 }
			random_powerful_vassal = {
				limit = { is_ai = yes age >= 12 is_imprisoned = no is_tributary = no NOR = { 
					this = scope:gptl_pv1
					this = scope:gptl_pv2
				} }
				save_scope_as = gptl_pv3
			}
		}
		if = {
			limit = { number_of_powerful_vassals >= 4 }
			random_powerful_vassal = {
				limit = { is_ai = yes age >= 12 is_imprisoned = no is_tributary = no NOR = { 
					this = scope:gptl_pv1
					this = scope:gptl_pv2
					this = scope:gptl_pv3
				} }
				save_scope_as = gptl_pv4
			}
		}
		if = {
			limit = { number_of_powerful_vassals >= 5 }
			random_powerful_vassal = {
				limit = { age >= 12 is_imprisoned = no is_tributary = no NOR = { 
					this = scope:gptl_pv1
					this = scope:gptl_pv2
					this = scope:gptl_pv3
					this = scope:gptl_pv4
				} }
				save_scope_as = gptl_pv5
			}
		}
		every_vassal_or_below = {
			limit = { is_ai = no is_tributary = no }
			trigger_event = { id = gptl_intro_events_vassal.01 }
		}
		trigger_event = { id = gptl_intro_events.99 days = 5 }
	}

	ai_potential = {
		is_at_war = no
	}

	ai_will_do = {
		base = 1000
	}
}
