# 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 = {

	CHT_Cheats = {
	    filter =  all_including_me

	
	    from_potential = {
		   ai = no
		}
		
		potential = { always = yes }
		allow = { always = yes }
		effect = {
			if = {
				limit = { NOT = { has_global_flag = CHT_active } }
				set_global_flag = CHT_active
				break = yes
			}
			if = {
				limit = { has_global_flag = CHT_active }
				clr_global_flag = CHT_active
				break = yes
			}
		}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	add_honorable = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { trait = honorable }
		}
		allow = { NOT = {trait = honorable } 
		}
		effect = {
		ROOT = {
		add_trait = honorable
		add_trait = fair
		give_nickname = nick_the_honorable
	    }}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	remove_honorable = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			trait = honorable
		}
		allow = {
		trait = honorable 
		}
		effect = {
		ROOT = {
		remove_trait = honorable
		remove_nickname = nick_the_honorable
	    }}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	add_legend = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { trait = legend }
		}
		allow = { NOT = {trait = legend } 
		}
		effect = {
		ROOT = {
		add_trait = legend
		add_trait = fair
		give_nickname = nick_the_legend
	    }}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	remove_legend = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			trait = legend
		}
		allow = {
		trait = legend 
		}
		effect = {
		ROOT = {
		remove_trait = legend
		remove_nickname = nick_the_legend
	    }}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	add_immortal = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { trait = immortal }
		}
		allow = { NOT = {trait = immortal } 
		}
		effect = {
		ROOT = {
		add_trait = immortal
	    }}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	remove_immortal = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			trait = immortal
		}
		allow = {
		trait = immortal
		}
		effect = {
		ROOT = {
		remove_trait = immortal
	    }}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	add_builder = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { trait = ch_builder }
		}
		allow = { NOT = {trait = ch_builder } 
		}
		effect = {
		ROOT = {
		add_trait = ch_builder
	    }}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	remove_builder = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			trait = ch_builder
		}
		allow = {
		trait = ch_builder
		}
		effect = {
		ROOT = {
		remove_trait = ch_builder
	    }}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	add_tactical_genius = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { trait = tactical_genius }
		}
		allow = { NOT = {trait = tactical_genius } 
		}
		effect = {
		ROOT = {
		add_trait = tactical_genius
		add_trait = genius
		add_trait = strong
		add_trait = quick
	    }}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	remove_tactical_genius = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			trait = tactical_genius
		}
		allow = {
		trait = tactical_genius
		}
		effect = {
		ROOT = {
		remove_trait = tactical_genius
		remove_trait = genius
		remove_trait = strong
		remove_trait = quick
	    }}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	add_prosperous = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { trait = prosperous }
		}
		allow = { NOT = {trait = prosperous } 
		}
		effect = {
		ROOT = {
		add_trait = prosperous
		add_trait = fair
	    }}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	remove_prosperous = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			trait = prosperous
		}
		allow = {
		trait = prosperous
		}
		effect = {
		ROOT = {
		remove_trait = prosperous
	    }}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	remove_bad_traits = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
		}
		allow = {
		}
		effect = {
		ROOT = {
		remove_trait = sickly
		remove_trait = has_aztec_disease
		remove_trait = lisp
		remove_trait = lustful
		remove_trait = gluttonous
		remove_trait = greedy
		remove_trait = slothful
		remove_trait = envious
		remove_trait = wroth
		remove_trait = proud
		remove_trait = shy
	    remove_trait = stressed
		remove_trait = depressed
		remove_trait = lunatic
		remove_trait = possessed
		remove_trait = ill
		remove_trait = pneumonic
		remove_trait = syphilitic
		remove_trait = leper
		remove_trait = wounded
		remove_trait = maimed
		remove_trait = scarred
		remove_trait = infirm
		remove_trait = incapable
		remove_trait = has_tuberculosis
		remove_trait = has_typhoid_fever
		remove_trait = has_typhus
		remove_trait = has_bubonic_plague
		remove_trait = has_measles
		remove_trait = has_small_pox
		remove_trait = blinded
		remove_trait = eunuch
		remove_trait = drunkard
		remove_trait = ugly
		remove_trait = harelip
		remove_trait = hunchback
		remove_trait = stutter
		remove_trait = slow
		remove_trait = imbecile
		remove_trait = inbred
		remove_trait = weak
		remove_trait = arbitrary
		remove_trait = cruel
		remove_trait = clubfooted
		remove_trait = paranoid
		
	    }}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	ch_kill_ai = {
	filter =  all_including_me
        from_potential = {
			has_global_flag = CHT_active
			ai = no
		}
		potential = {
		}
		allow = {
			always = yes
		}
		effect = {
			death = { death_reason = death_murder_unknown killer = FROM } 
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}

	CHT_Add_Friend = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			NOT = { is_friend = FROM }
		}
		allow = { NOT = { is_friend = FROM } }
		effect = { FROM = { add_friend = ROOT 
		}}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	CHT_Remove_Friend = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			is_friend = FROM
		}
		allow = { is_friend = FROM }
		effect = { FROM = { remove_friend = ROOT 
		}}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Add_Rival = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			NOT = { is_rival = FROM }
		}
		allow = { NOT = { is_rival = FROM } }
		effect = { FROM = { add_rival = ROOT 
		}}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	CHT_Remove_Rival = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			is_rival = FROM
		}
		allow = { is_rival = FROM }
		effect = { FROM = { remove_rival = ROOT 
		}}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Add_Lover = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			NOT = { is_lover = FROM }
		}
		allow = { NOT = { is_lover = FROM } }
		effect = { FROM = { add_lover = ROOT 
		}}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	CHT_Remove_Lover = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			is_lover = FROM
		}
		allow = { is_lover = FROM }
		effect = { FROM = { remove_lover = ROOT 
		}}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Offer_to_Join_War = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			is_ruler = yes
			OR = {
				is_primary_war_defender = yes
				is_primary_war_attacker = yes
			}
		}
		allow = {
			OR = {
				is_primary_war_defender = yes
				is_primary_war_attacker = yes
			}
		}
		effect = {
			FROM = {
				join_defender_wars = ROOT
				join_attacker_wars = ROOT
			}
		}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Call_to_Arms = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			is_ruler = yes
			FROM = {
				OR = {
					is_primary_war_defender = yes
					is_primary_war_attacker = yes
				}
			}
		}
		allow = {
			FROM = {
				OR = {
					is_primary_war_defender = yes
					is_primary_war_attacker = yes
				}
			}
		}
		effect = {
			ROOT = {
				join_defender_wars = FROM
				join_attacker_wars = FROM
			}
		}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Invite_to_Court = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			is_ruler = no
			NOT = { FROM = { is_liege_of = ROOT } }
		}
		allow = { NOT = { FROM = { is_liege_of = ROOT } } }
		effect = { FROM = { reverse_banish = ROOT } }
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Banish_from_Court = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			is_ruler = no
			FROM = { is_liege_of = ROOT }
		}
		allow = { FROM = { is_liege_of = ROOT } }
		effect = { ROOT = { banish = yes } }
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Banish_Lowborns = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = { character = FROM }
		allow = { any_courtier = { dynasty = 0 } }
		effect = {
			any_courtier = {
				if = {
					limit = {
						is_ruler = no
						dynasty = 0
					}
					banish = yes
				}
			}
		}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Imprison = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			ROOT = { prisoner = no }
		}
		allow = { ROOT = { prisoner = no } }
		effect = { ROOT = { imprison = FROM } }
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Establish_Patrician = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = { is_patrician = no }
		allow = { is_patrician = no }
		effect = { ROOT = { create_family_palace = yes } }
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Offer_Vassalization = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			is_ruler = yes
			lower_tier_than = FROM
			NOT = { FROM = { is_liege_of = ROOT } }
		}
		allow = { NOT = { FROM = { is_liege_of = ROOT } } }
		effect = { ROOT = { set_defacto_liege = FROM } }
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Swear_Fealty = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			is_ruler = yes
			higher_tier_than = FROM
			NOT = { ROOT = { is_liege_of = FROM } }
		}
		allow = { NOT = { ROOT = { is_liege_of = FROM } } }
		effect = { FROM = { set_defacto_liege = ROOT } }
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Make_Tributary = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			is_ruler = yes
			NOT = { pays_tribute_to = FROM }
		}
		allow = { NOT = { pays_tribute_to = FROM } }
		effect = { FROM = { make_tributary = { who = ROOT percentage = 0.4 } } }
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Become_Tributary = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { character = FROM }
			is_ruler = yes
			NOT = { FROM = { pays_tribute_to = ROOT } }
		}
		allow = { NOT = { FROM = { pays_tribute_to = ROOT } } }
		effect = { ROOT = { make_tributary = { who = FROM percentage = 0.05 } } }
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Grant_Independence = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			is_ruler = yes
			independent = no
		}
		allow = { independent = no }
		effect = { ROOT = { set_defacto_liege = THIS } }
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 } = 
	}

	CHT_Create_County = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = { is_ruler = yes }
		allow = { is_ruler = yes }
		effect = {
			primary_title = {
				create_title = {
					tier = COUNT
					landless = no
					temporary = no
					custom_created = yes
					culture = ROOT
					holder = ROOT
					base_title = THIS
					copy_title_laws = yes
				}
			}
		}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Create_Duchy = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = { is_ruler = yes }
		allow = { is_ruler = yes }
		effect = {
			primary_title = {
				create_title = {
					tier = DUKE
					landless = no
					temporary = no
					custom_created = yes
					culture = ROOT
					holder = ROOT
					base_title = THIS
					copy_title_laws = yes
				}
			}
		}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}

	CHT_Create_Kingdom = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = { is_ruler = yes }
		allow = { is_ruler = yes }
		effect = {
			primary_title = {
				create_title = {
					tier = KING
					landless = no
					temporary = no
					custom_created = yes
					culture = ROOT
					holder = ROOT
					base_title = THIS
					copy_title_laws = yes
				}
			}
		}
		revoke_allowed = { always = no }
		ai_will_do = { factor = 0 }
	}
	
	CHT_abdicate = {
	filter =  all_including_me
	    from_potential = {
	    ai = no
	    has_global_flag = CHT_active
	    }
		filter = self
		ai_target_filter = self
		potential = {
			is_adult = yes
			is_ruler = yes
		}
		allow = {
			is_adult = yes
			is_ruler = yes
		}
		effect = {
			prestige = -500
			abdicate = yes
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = {
					prisoner = yes
				}
			}
		}
	}
	
	kill_character_ai = {
	filter =  all_including_me
		filter = all
		
		from_potential = {
			ai = no
		}
		potential = {
		}
		allow = {
			always = yes
		}
		effect = {
			death = { death_reason = death_murder_unknown killer = FROM } 
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0
		}
	}

}

title_decisions = {

	CHT_Usurp_Title = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = { NOT = { holder_scope = { character = FROM } } }
		allow = { NOT = { holder_scope = { character = FROM } } }
		effect = { ROOT = { grant_title = FROM } }
		ai_will_do = { factor = 0 }
	}

	CHT_Claim = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			NOT = { holder_scope = { character = FROM } }
			NOT { claimed_by = FROM }
		}
		allow = { NOT { claimed_by = FROM } }
		effect = { ROOT = { add_claim = FROM } }
		ai_will_do = { factor = 0 }
	}

	CHT_Destroy = {
	filter =  all_including_me
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = { higher_tier_than = COUNT }
		allow = { higher_tier_than = COUNT }
		effect = { ROOT = { destroy_landed_title = THIS } }
		ai_will_do = { factor = 0 }
	}

	CHT_Build_Castle = {
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			tier = COUNT
			location = { has_empty_holding = yes }
		}
		allow = { location = { has_empty_holding = yes } }
		effect = {
			location = {
				build_holding = {
					title = b_custom
					type = castle
					holder = FROM
				}
			}
		}
		ai_will_do = { factor = 0 }
	}

	CHT_Build_City = {
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			tier = COUNT
			location = { has_empty_holding = yes }
		}
		allow = { location = { has_empty_holding = yes } }
		effect = {
			location = {
				build_holding = {
					type = city
					holder = FROM
				}
			}
		}
		ai_will_do = { factor = 0 }
	}

	CHT_Build_Temple = {
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = {
			tier = COUNT
			location = { has_empty_holding = yes }
		}
		allow = { location = { has_empty_holding = yes } }
		effect = {
			location = {
				build_holding = {
					type = temple
					holder = FROM
				}
			}
		}
		ai_will_do = { factor = 0 }
	}
}


settlement_decisions = {

	CHT_Raze = {
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = { NOT = { is_capital = yes } }
		allow = { NOT = { is_capital = yes } }
		effect = { destroy_settlement = THIS }
		ai_will_do = { factor = 0 }
	}

	CHT_Convert_to_Castle = {
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = { NOT = { holding_type = castle } }
		allow = { NOT = { holding_type = castle } }
		effect = { convert_to = castle }
		ai_will_do = { factor = 0 }
	}

	CHT_Convert_to_City = {
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = { NOT = { holding_type = city } }
		allow = { NOT = { holding_type = city } }
		effect = { convert_to = city }
		ai_will_do = { factor = 0 }
	}

	CHT_Convert_to_Temple = {
		from_potential = {
			ai = no
			has_global_flag = CHT_active
		}
		potential = { NOT = { holding_type = temple } }
		allow = { NOT = { holding_type = temple } }
		effect = { convert_to = temple }
		ai_will_do = { factor = 0 }
	}

 }
