# -*- ck2.objectives -*-

# Character plots to fabricate evidence of treason
plot_fabricate_treason = {
	type = realm_characters # All characters in the same realm, plus rivals and relatives of self, parents, children and spouse
	vassal_intrigue_plot = yes

	# Plotter scope
	potential = {
		prisoner = no
		is_adult = yes
		is_playable = yes
		is_incapable = no
		NOT = { trait = in_hiding }
	}

	# Target scope
	target_potential = {
		same_liege = FROM
		is_ruler = yes
		NOT = { trait = in_hiding }
	}

	# Target allow trigger for when players target a specific character in the GUI
	player_allow = {
		is_adult = yes
		prisoner = no
		independent = no
		is_playable = yes
		NOT = { FROM = { is_liege_of = ROOT } }
		NOT = { liege = { opinion = { who = ROOT value = 25 } } }
		NOT = { reverse_has_truce = FROM }
		NOT = { has_non_aggression_pact_with = FROM }
	}

	# Target scope
	allow = {
		is_adult = yes
		prisoner = no
		independent = no
		is_playable = yes
		NOT = { FROM = { is_liege_of = ROOT } }
		NOT = { liege = { opinion = { who = ROOT value = 25 } } }
		NOT = { reverse_has_truce = FROM }
		NOT = { is_allied_with = FROM }
		NOT = { has_non_aggression_pact_with = FROM }
		OR = {
			#at war
			war_with = FROM

			#are rivals
			FROM = { is_foe = ROOT }

			#have a claim on their lands
			FROM = { any_claim = { holder = ROOT } }

			#they are a different religion from both you and their liege
			AND = {
				NOT = { reverse_opinion = { who = FROM value = 0 } }
				NOT = { religion = FROM }
				liege = { NOT = { religion = ROOT } }
			}

			#dislike them, and liege really dislikes them
			AND = {
				NOT = { reverse_opinion = { who = FROM value = 0 } }
				liege = { NOT = { opinion = { who = ROOT value = -50 } } }
			}
		}
	}

	chance = {
		factor = 1
		modifier = {
			factor = 0
			FROM = { lower_tier_than = count }
		}
		modifier = {
			factor = 0
			FROM = {
				OR = {
					NOT = { ai_ambition = -39 }
					trait = honest
					trait = kind
					trait = just
					trait = charitable
				}
				NOT = { trait = lunatic }
				NOT = { has_character_modifier = voice_of_satan }
				NOT = { has_flag = demon_child_non_pagan }
				NOT = { has_flag = demon_child }
			}
		}
		modifier = {
			factor = 2.0
			FROM = { independent = no reverse_opinion = { who = liege value = 100 } }
		}
		modifier = {
			factor = 1.5
			FROM = { independent = no reverse_opinion = { who = liege value = 75 } }
		}
		modifier = {
			factor = 1.5
			FROM = { independent = no reverse_opinion = { who = liege value = 50 } }
		}
		modifier = {
			factor = 1.5
			FROM = { independent = no reverse_opinion = { who = liege value = 25 } }
		}
		modifier = {
			factor = 0.5
			FROM = { independent = no NOT = { reverse_opinion = { who = liege value = 0 } } }
		}
		modifier = {
			factor = 0.25
			FROM = { independent = no NOT = { reverse_opinion = { who = liege value = -25 } } }
		}
		modifier = {
			factor = 0
			FROM = { independent = no NOT = { reverse_opinion = { who = liege value = -50 } } }
		}
		modifier = {
			factor = 0
			FROM = { opinion = { who = ROOT value = 0 } }
		}
		modifier = {
			factor = 0
			FROM = {
				opinion = { who = ROOT value = -25 }
				NOR = {
					trait = lunatic
					trait = possessed
					ai_ambition = 40
					trait = deceitful
					trait = paranoid
				}
			}
		}
		modifier = {
			factor = 2.0
			FROM = { NOT = { opinion = { who = ROOT value = -50 } } }
		}
		modifier = {
			factor = 2.0
			FROM = { NOT = { opinion = { who = ROOT value = -75 } } }
		}
		modifier = {
			factor = 0.5
			FROM = { NOT = { intrigue = 5 } }
		}
		modifier = {
			factor = 0.5
			FROM = { NOT = { intrigue = 10 } }
		}
		modifier = {
			factor = 2
			FROM = { intrigue = 15 }
		}
		modifier = {
			factor = 2
			FROM = { intrigue = 20 }
		}
		modifier = {
			factor = 2.0
			FROM = { trait = paranoid }
		}
		modifier = {
			factor = 4.0
			FROM = { trait = deceitful }
		}
	}

	success = {
		custom_tooltip = { text = ACCUSED_OF_TREASON }
		hidden_tooltip = {
			FROM = { has_flag = plot_success }
		}
	}

	abort = {
		OR = {
			liege = { opinion = { who = ROOT value = 50 } }
			FROM = { is_liege_of = ROOT }
			NOT = { same_liege = FROM }
			independent = yes
			prisoner = yes
			FROM = { has_flag = abort_plot }
			FROM = { prisoner = yes }
			is_alive = no
			FROM = { is_incapable = yes }
		}
	}

	abort_effect = {
		FROM = {
			# Clear flags
			hidden_tooltip = {
				clr_flag = event7040
				clr_flag = plot_in_action
				clr_flag = abort_plot
			}
			emf_remove_plot_assisted_spying = yes
		}
	}
	effect = {
		FROM = {
			any_plot_backer = {
				reverse_opinion = {
					modifier = opinion_grateful
					who = FROM
					years = 5
				}
			}
			emf_remove_plot_assisted_spying = yes
			# Clear flags
			hidden_tooltip = {
				clr_flag = plot_success
				clr_flag = event7040
				clr_flag = plot_in_action
				clr_flag = abort_plot
			}
		}
	}
}

