# Targetted decisions are possible vs _all_ other characters and shown are in the Diplomacy View, not the Intrigue View. The taker is in the FROM scope.
#
# filter = [self/court/home_court/vassals/sub_realm/realm/dynasty/all] ('self' MUST be set for decisions targetting only the taker, the other filter types can be set to lessen CPU load)
# ai_target_filter = [self/court/home_court/vassals/sub_realm/realm/dynasty/all] (which characters for which the AI evaluates the decision.)
#	court: all characters in the AI's host court, including prisoners, and characters currently away (wards, prisoners, etc)
#	home_court: all characters in the AI's home court, including prisoners, and characters currently away (wards, prisoners, etc)
#	vassals: direct vassal rulers of the AI's employer
#	sub_realm: all characters below the AI's employer
#	realm: all characters in the same top realm as the AI
#	dynasty: all members of the same dynasty
#	rivals: your rivals plus any character you have an opinion modifier with 'crime = yes' set (the same set of characters the 'is_foe' trigger evaluates)
#	all: all living characters (Avoid if possible. VERY CPU-HEAVY!)
#	

targetted_decisions = {

	dip_decision = {
		ai_target_filter = realm
		
		from_potential = {
			is_ruler = yes
			OR = {
				higher_tier_than = BARON
				is_merchant_republic = yes
			}
			has_regent = no
			holy_order = no
			mercenary = no
			is_attending_event = no
			NOT = { is_inaccessible_trigger = yes }
			OR = {
				independent = no
				ai = no
			}
		}
		
		potential = {
			NOT = {character = FROM}
			is_ruler = yes
			has_regent = no
			OR = {
				higher_tier_than = BARON
				is_merchant_republic = yes
			}
			holy_order = no
			mercenary = no
			OR = {
				FROM = {ai = no}
				same_liege = FROM
			}
			NOT = {
				any_liege = {
					character = FROM
				}
			}
			is_attending_event = no
			NOT = { is_inaccessible_trigger = yes }
			NOT = {
				FROM = {
					any_liege = {
						character = ROOT
					}
				}
			}

			OR = {
				independent = no
				FROM = {ai = no}
			}

		}
		
		allow = {
			FROM = {
				war = no
			}
			war = no
			NOT = {is_rival = FROM}
			NOT = {has_non_aggression_pact_with = FROM}
			custom_tooltip = {
				text = tooltip_not_diplo
				hidden_tooltip = {
					NOT = {
						has_opinion_modifier = {
							modifier = diplo_challenge
							who = FROM
						}
					}
				}
			}
			
			custom_tooltip = {
				text = diplo_cd
				hidden_tooltip = {
					NOT = {
						FROM = {
							has_character_modifier = dipcd
						}
					}
				}
			}
			hidden_tooltip = {
				
				NOT = {is_vassal_or_below = FROM}
				NOT = {is_liege_or_above = FROM}
			}
			is_within_diplo_range = FROM # CPU HEAVY!
		}
		
		effect = {
			hidden_tooltip = {
			
				FROM = {
					add_character_modifier = {
						name = dipcd
						duration = 365
						hidden = yes
					}
					
				}
				add_character_modifier = {
					name = dip_rec
					duration = 365
					hidden = yes
				}
				opinion = {
					modifier = diplo_challenge
					who = FROM
					months = 1200
				}
				character_event = {
					id = ALY.100
					days = 1
				}
			}
			
		}
		
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				has_character_modifier = dip_rec
			}
			
			modifier = {
				factor = 0
				NOT = {same_realm = FROM}
				independent = no
			}
			
			modifier = {
				factor = 0.01
				attribute_diff = {
					character = FROM
					attribute = diplomacy
					value = 10 #He's too good
				}
			}
			
			
			
			modifier = {
				factor = 0.1
				NOT = {FROM = {diplomacy = 20}}
			}
			
			modifier = {
				factor = 0.1
				NOT = {FROM = {diplomacy = 10}}
			}
			modifier = {
				factor = 0.1
				NOT = {FROM = {diplomacy = 5}}
			}
		}
	}
	
	

}
