﻿namespace = fp3_clan

########EVENT INDEX############
#fp3_clan.8000 - Usury against Unity, by Ola Jentzsch 
#fp3_clan.8001 - Clan Quarrel, by Ola Jentzsch
#fp3_clan.8002 - Bonds of Faith, by Ola Jentzsch
#fp3_clan.8003 - The Power of a Name, by Ola Jentzsch
#fp3_clan.8004 - Bonds of Fear, by Ola Jentzsch
#fp3_clan.8005 - A Proper Position, by Ola Jentzsch
#fp3_clan.8006 - Small Spies, by Ola Jentzsch

scripted_trigger fp3_usury_trigger = {
	ai_compassion <= low_positive_ai_value
	OR = {
		has_trait = greedy
		has_trait = deceitful
		ai_greed > medium_positive_ai_value 
	}
}

scripted_trigger concerned_character_trigger = {
	fp3_usury_trigger = no
	house != root.house
	is_available_ai_adult = yes
	OR = {
		opinion = {
			target = scope:usurer
			value < 25
		}
		AND = {
			faith = { trait_is_sin = greedy }
			ai_zeal >= medium_positive_ai_value
		}
		ai_greed < medium_positive_ai_value 
	}
}

scripted_trigger usurer_character_trigger = {
	is_available_ai_adult = yes
	NOR = {
		this = root
		is_liege_or_above_of = root
	}
	fp3_usury_trigger = yes
}

fp3_clan.8000 = { # Usury against Unity 
	type = character_event
	title = fp3_clan.8000.t
	desc = fp3_clan.8000.desc
	theme = corruption

	left_portrait = {
		character = root
		animation = disbelief
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = vengeful 
					has_trait = wrathful
					AND = {
						faith = { trait_is_sin = greedy }
						has_trait = zealous
					}
				}
			}
			animation = anger
		}
	}
	right_portrait = {
		character = scope:usurer
		animation = personality_greedy
		triggered_animation = {
			trigger = {
				ai_boldness < low_positive_ai_value
			}
			animation = beg
		}
	}
	lower_left_portrait = {
		character = scope:concerned_one
	}	

	trigger = {	
		has_fp3_dlc_trigger = yes
		is_landed = yes
		government_has_flag = government_is_clan
		house ?= {
			prev = house_head
			house_unity_value >= critical_house_unity

			any_house_unity_member = {
				usurer_character_trigger = yes
				save_temporary_scope_as = usurer
			}
		}

		any_vassal_or_below = {
			concerned_character_trigger = yes
		}

		faith = {
			NOT = { has_doctrine_parameter = unreformed }
		}
	}

	cooldown = {
		years = 25 
	}

	immediate = {
		house = {
			random_house_unity_member = {
				limit = {
					usurer_character_trigger = yes
				}
				save_scope_as = usurer
			}
		}

		random_vassal_or_below = {
			limit = {
				concerned_character_trigger = yes
			}
			weight = {
				base = 1 
				modifier = {
					factor = 10
					OR = {
						has_relation_friend = root
						is_powerful_vassal_of = root
						is_child_of = root
						has_council_position = councillor_spouse
						AND = {
							has_council_position = councillor_steward
							employer = root
						}
					}
				}
			}
			save_scope_as = concerned_one
		}

		hidden_effect = {
			scope:usurer = {
				add_gold = major_gold_value
			}
		}  
	}

	option = {
		name = fp3_clan.8000.a

		scope:usurer = { 
			hard_imprison_character_effect = {
				TARGET = this
				IMPRISONER = root
			}

			add_opinion = {
				target = root
				modifier = imprisoned_me
			}
		}

		custom_tooltip = fp3_relations_reaction_to_imprisonment.tt
		hidden_effect = {
			scope:usurer = {
				every_close_family_member = {
					limit = {
						this != root
					}
					if = {
						limit = {
							this != root
							opinion = {
								target = scope:usurer
								value > 25
							}
						}
						add_opinion = {
							target = root
							modifier = imprisoned_family_member
						}
					}
				}
			}
			every_vassal = {
				if = {
					limit = {
						opinion = {
							target = scope:usurer
							value > 25
						}
					}
					add_opinion = {
						target = root
						modifier = fp3_wrongful_imprisonment_opinion
					}
				}
			}
		}

		scope:concerned_one = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 20
			}
		}

		hidden_effect = { #his ill-gotten gains seep back to his debtors, so the player can't cheese it and steal them by banishing him
			scope:usurer = {
				remove_short_term_gold = major_gold_value
			}
		}

		if = {
			limit = {
				faith = {
					OR = {
						trait_is_sin = greedy
						trait_is_virtue = generous 
					}
				}
			}
			add_piety = medium_piety_gain
		}
		else = {
			add_dread = minor_dread_gain 
		}

		add_clan_unity_interaction_effect = {
            CHARACTER = root
            TARGET = scope:usurer
            VALUE = medium_unity_loss
            DESC = clan_unity_imprisoned_usurer.desc
            REVERSE_NON_HOUSE_TARGET = no
        }

        stress_impact = { 
   			arbitrary = medium_stress_impact_loss
   			just = minor_stress_impact_gain
   			trusting = medium_stress_impact_gain 	
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_boldness = 0.5
           		ai_vengefulness = 1 
           		ai_zeal = 1
           		ai_compassion = -1
        	}
   		} 	
	}

	option = {
		name = fp3_clan.8000.b

		scope:usurer = {
			pay_short_term_gold = {
 				gold = medium_gold_value
				target = root
			}
		}

		scope:usurer = {
			add_opinion = {
				target = root
				modifier = extorted_me_opinion
			}
		}

		stress_impact = { 
   			greedy = medium_stress_impact_loss
   			honest = medium_stress_impact_gain
   			generous = medium_stress_impact_gain
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_greed = 1 
           		ai_honor = -0.5
        	}
   		} 	
	}

	option = {
		name = fp3_clan.8000.c

		add_clan_unity_interaction_effect = {
            CHARACTER = root
            TARGET = scope:usurer
            VALUE = minor_unity_gain
            DESC = clan_unity_defended_usurer.desc
            REVERSE_NON_HOUSE_TARGET = no
        }

        scope:concerned_one = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -20
			}
		}

		stress_impact = { 
			forgiving = minor_stress_impact_loss
   			trusting = medium_stress_impact_loss
   			zealous = minor_stress_impact_gain 
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_sociability = 0.5
           		ai_boldness = 0.5
           		ai_vengefulness = 0.5
           		ai_honor = -1  		
        	}
   		} 	
	}
}

scripted_trigger bickerer_2_character_trigger = {
	is_available_ai_adult = yes
	NOT = { this ?= scope:$SCOPE$ }
	opinion = { 
		target ?= scope:$SCOPE$
		value < $VALUE$
	}
}

fp3_clan.8001 = { #Clan Quarrel
	type = character_event
	title = fp3_clan.8001.t
	desc = {
		desc = fp3_clan.8001_beginning
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = { 
						NOT = { has_doctrine_parameter = unreformed }
					}
					OR = {
						scope:bickerer_1 = { 
							ai_zeal >= high_positive_ai_value
							NOT = { has_trait = cynical }
						}
						scope:bickerer_2 = {
							ai_zeal >= medium_positive_ai_value
							NOT = { has_trait = cynical }
						}
					}
				}
				desc = fp3_clan.8001_faith_schism
			}
			desc = fp3_clan.8001_generic_fallback
		}
	}
	theme = diplomacy_family_focus

	left_portrait = {
		character = scope:bickerer_1
		animation = disgust
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = vengeful 
					has_trait = wrathful
					has_trait = zealous
					ai_vengefulness >= high_positive_ai_value
				}
			}
			animation = war_over_win
		}
	}
	right_portrait = {
		character = scope:bickerer_2
		animation = disapproval
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = vengeful 
					has_trait = wrathful
					has_trait = zealous
					ai_vengefulness >= high_positive_ai_value
				}
			}
			animation = anger
		}
	}
	lower_left_portrait = {
		character = root
	}

	trigger = {
		has_fp3_dlc_trigger = yes
		is_landed = yes
		government_has_flag = government_is_clan
		is_house_head = yes

		house = {
			house_unity_value > critical_house_unity

			any_house_unity_member = {
				is_available_ai_adult = yes
				NOT = { ai_vengefulness < low_positive_ai_value }
				save_temporary_scope_as = bickerer_1_temp
				house = {
					any_house_unity_member = {
						this != scope:bickerer_1_temp
						is_available_adult = yes
						opinion = {
							target = scope:bickerer_1_temp
							value < 20
						}
					}
				}
			}

			any_house_unity_member = {
				bickerer_2_character_trigger = { 
					VALUE = 20 
					SCOPE = bickerer_1_temp
				}
			}
		}
	}

	cooldown = { years = 10	}

	immediate = {
		house = {
			random_house_unity_member = {
				limit = {
					is_available_ai_adult = yes
					NOT = { ai_vengefulness < low_positive_ai_value }
					save_temporary_scope_as = bickerer_1_temp
					house = {
						any_house_unity_member = {
							this != scope:bickerer_1_temp
							is_available_adult = yes
							opinion = {
								target = scope:bickerer_1_temp
								value < 20
							}
						}
					}
				}
				save_scope_as = bickerer_1
			}

			random_house_unity_member = {
				limit = {
					is_available_ai_adult = yes
					this != scope:bickerer_1
				}
				weight = {
					base = 1
					modifier = {
						factor = 10
						OR = {
							has_relation_rival = scope:bickerer_1
							bickerer_2_character_trigger = { 
								VALUE = 0 
								SCOPE = bickerer_1
							}
						}
					}
				}
				save_scope_as = bickerer_2
			}
		}

		if = {
			limit = {
				scope:bickerer_1 = {
					NOT = { has_relation_rival = scope:bickerer_2 }
				}
			}
			scope:bickerer_1 = {
				progress_towards_rival_effect = {
	 				CHARACTER = scope:bickerer_2
					REASON = rival_generic_history
	 				OPINION = -25
	 			}
	 		}
		}	
	}

	option = {
		name = fp3_clan.8001.a

		duel = {
			skill = diplomacy
			target = scope:bickerer_1

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					max = 40
					min = -40
				}

				desc = fp3_clan.8001.a.success
				send_interface_toast = {
					title = fp3_clan.8001.a.success.tt
					left_icon = root

					add_clan_unity_interaction_effect = {
           				CHARACTER = root
            			TARGET = scope:bickerer_1
            			VALUE = medium_unity_gain
            			DESC = clan_unity_mediated_btw_clan_members.desc
            			REVERSE_NON_HOUSE_TARGET = no
       				}
					
					add_prestige = minor_prestige_gain
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					max = 40
					min = -40
				}

				desc = fp3_clan.8001.a.failure
				send_interface_toast = {
					title = fp3_clan.8001.a.failure.tt
					left_icon = root

					add_clan_unity_interaction_effect = {
           				CHARACTER = root
            			TARGET = scope:bickerer_1
            			VALUE = minor_unity_loss
            			DESC = clan_unity_caused_rift.desc
            			REVERSE_NON_HOUSE_TARGET = no
       				}
				}
			}
		}	

		stress_impact = { 
   			forgiving = medium_stress_impact_loss
   			callous = medium_stress_impact_gain
   			shy = minor_stress_impact_gain
   			paranoid = medium_stress_impact_gain
   			arbitrary = medium_stress_impact_gain
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_sociability = 1 
           		ai_honor = 0.5
           		ai_rationality = 0.5
           		ai_energy = 0.5
        	}
   		} 	
	}

	option = {
		name = fp3_clan.8001.b
		flavor = fp3_clan_making_conflict_worse_flavor

		duel = {
			skill = intrigue
			target = scope:bickerer_1

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					max = 40
					min = -40
				}

				desc = fp3_clan.8001.b.success
				send_interface_toast = {
					title = fp3_clan.8001.b.success.tt
					left_icon = root

					add_clan_unity_interaction_effect = {
           				CHARACTER = root
            			TARGET = scope:bickerer_1
            			VALUE = medium_unity_loss
            			DESC = clan_unity_caused_rift.desc
            			REVERSE_NON_HOUSE_TARGET = no
       				}

       				add_prestige = minor_prestige_gain

       				if = {
						limit = {
							scope:bickerer_1 = {
								NOT = { has_relation_rival = scope:bickerer_2 }
							}
						}
						scope:bickerer_1 = {
							progress_towards_rival_effect = {
	 							CHARACTER = scope:bickerer_2
								REASON = rival_generic_history
	 							OPINION = -25
	 						}
	 					}
					}	
					
					if = {
						limit = { has_lifestyle = intrigue_lifestyle }
						add_intrigue_lifestyle_xp = minor_lifestyle_experience
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					max = 40
					min = -40
				}

				desc = fp3_clan.8001.b.failure
				send_interface_toast = {
					title = fp3_clan.8001.b.failure.tt
					left_icon = root

					add_prestige = minor_prestige_loss 
				}
			}
		}	

		stress_impact = { 
   			compassionate = medium_stress_impact_gain
   			honest = major_stress_impact_gain
   			just = medium_stress_impact_gain	
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_greed = 1 
           		ai_honor = -1
           		ai_vengefulness = 0.5
        	}
   		} 	
	}

	option = {
		name = fp3_clan.8001.c

		trigger = {
			OR = {
				has_trait = diligent 
				has_trait = paranoid
			}
		}

		stress_impact = { 
   			diligent = minor_stress_impact_loss
   			compassionate = medium_stress_impact_gain
   			just = medium_stress_impact_gain
   			paranoid = minor_stress_impact_gain
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_energy = 1 
           		ai_sociability = -0.7
           		ai_rationality = 0.5
        	}
   		} 	
	}

	option = {
		name = fp3_clan.8001.d

		trigger = {
			NOR = {
				has_trait = diligent 
				has_trait = paranoid
			}
		}

		stress_impact = { 
   			base = minor_stress_impact_loss 
   			lazy = minor_stress_impact_loss
   			content = minor_stress_impact_loss
   			ambitious = medium_stress_impact_gain
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_energy = -1 
           		ai_sociability = -0.5
           		ai_rationality = 0.5
        	}
   		} 	
	}
}	

scripted_trigger fp3_vassal_8002_trigger = {
	is_available_ai_adult = yes
	is_powerful_vassal_of = root 
	faith = root.faith 
	opinion = { 
		target = root
		value < 50
	}
}

fp3_clan.8002 = { #Bonds of Faith
	type = character_event
	title = fp3_clan.8002.t
	desc = fp3_clan.8002.desc
	theme = faith
	left_portrait = {
		character = root
		animation = stress
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = cynical
					has_trait = stubborn
					has_trait = wrathful 
					has_trait = vengeful 
					has_trait = arrogant 
				}
			}
			animation = personality_cynical
		}
	}
	right_portrait = {
		character = scope:chaplain
		animation = personality_rational
		triggered_animation = {
			trigger = {
				OR = {
					scope:chaplain = {
						has_dread_level_towards = {
   							target = root
   							level >= 2
   						}
   					}
   					ai_boldness <= low_negative_ai_value
				}
			}
			animation = personality_coward
		}
	}

	lower_left_portrait = {
		character = scope:clan_member
	}

	trigger = {
		has_fp3_dlc_trigger = yes
		government_has_flag = government_is_clan

		OR = {
			num_sinful_traits >= 1
			piety_level < 3
		}

		scriptedtests_piety_income <= 2

		house = {
			house_unity_value < very_high_house_unity
			any_house_unity_member = {
				fp3_vassal_8002_trigger = yes
			}		
		}

		exists = cp:councillor_court_chaplain 

		cp:councillor_court_chaplain  = {
			is_available_ai_adult = yes 
			NOR = {
				has_trait = arrogant
				opinion = { 
					target = root
					value < -30
				}
			}
		}
	}

	cooldown = {
		years = 10
	}

	immediate = {
		house = {
			random_house_unity_member = {
				limit = {
					fp3_vassal_8002_trigger = yes
				}
				weight = {
					base = 1
					modifier = {
						factor = 10
						ai_zeal >= high_positive_ai_value
					}
					modifier = {
						factor = 10
						opinion = { 
							target = root
							value < 0
						}
					}
				}
				save_scope_as = clan_member 
			}		
		}

		cp:councillor_court_chaplain = { save_scope_as = chaplain }
	}

	option = {
		name = fp3_clan.8002.a

		add_character_modifier = {
			modifier = fp3_praying_too_much_modifier
			years = 10
		}

       	add_clan_unity_interaction_effect = {
           	CHARACTER = root
            TARGET = scope:clan_member
            VALUE = minor_unity_gain
            DESC = clan_unity_proved_pious.desc
            REVERSE_NON_HOUSE_TARGET = no
       	}

       	scope:chaplain = {
			add_opinion = {
				target = root
				modifier = took_my_advice_opinion
				opinion = 20
			}
		}

		stress_impact = { 
   			zealous = minor_stress_impact_loss 
   			humble = medium_stress_impact_loss
   			diligent = minor_stress_impact_gain
   			arrogant = massive_stress_impact_gain
   			cynical = major_stress_impact_gain
   			impatient = medium_stress_impact_gain
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_energy = 0.3 
           		ai_rationality = 0.5
           		ai_zeal = 0.7
        	}
   		} 	
	}

	option = {
		name = fp3_clan.8002.b

		trigger = { #this is a bit of an arbitrary exclusion; just to make sure that noone gets more than four options
			NOR = {
				intrigue >= high_skill_rating
				has_trait = deceitful
				has_trait = cynical 
			}
		}

		add_piety = medium_piety_gain
		remove_short_term_gold = medium_gold_value 

		add_clan_unity_interaction_effect = {
           	CHARACTER = root
            TARGET = scope:clan_member
            VALUE = minor_unity_gain
            DESC = clan_unity_founded_worshipful_house.desc
            REVERSE_NON_HOUSE_TARGET = no
       	}

       	scope:chaplain = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 10
			}
		}

		stress_impact = { 
   			generous = medium_stress_impact_loss 
   			greedy = medium_stress_impact_gain
   			content = minor_stress_impact_gain
   			cynical = minor_stress_impact_gain	
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_greed = -1 
           		ai_rationality = 0.5
           		ai_zeal = 0.2
        	}
   		} 	
	}

	option = {
		name = fp3_clan.8002.c
		flavor = fp3_pretending_to_be_pious_flavor

		trigger = {
			OR = {
				intrigue >= high_skill_rating
				has_trait = deceitful
				has_trait = cynical 
			}
		}

		duel = {
			skill = intrigue
			value = average_skill_rating

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					max = 40
					min = -40
				}

				desc = fp3_clan.8002.b.success
				send_interface_toast = {
					title = fp3_clan.8002.b.success.tt
					left_icon = root

					add_clan_unity_interaction_effect = {
           				CHARACTER = root
            			TARGET = scope:clan_member
            			VALUE = minor_unity_gain
            			DESC = clan_unity_proved_pious.desc
            			REVERSE_NON_HOUSE_TARGET = no
       				}

       				add_piety = minor_piety_gain
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					max = 40
					min = -40
				}

				desc = fp3_clan.8002.b.failure
				send_interface_toast = {
					title = fp3_clan.8002.b.failure.tt
					left_icon = root

					add_piety = medium_piety_loss 
				}
			}
		}

		scope:chaplain = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -20
			}
		}	

		stress_impact = { 
   			deceitful = medium_stress_impact_loss
   			arrogant = medium_stress_impact_loss
   			zealous = major_stress_impact_gain
   			honest = massive_stress_impact_gain
   			humble = medium_stress_impact_gain
   			just = medium_stress_impact_gain
   			diligent = minor_stress_impact_gain
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_honor = -1
           		ai_sociability = 0.7
           		ai_rationality = 0.9
           		ai_vengefulness = 0.7
           		ai_zeal = -1
        	}
   		} 	
	}

	option = {
		name = fp3_clan.8002.d

		trigger = { 
			scope:clan_member = {
				has_dread_level_towards = {
   					target = root
   					level >= 1
   				}
			}
		}

		add_clan_unity_interaction_effect = {
        	CHARACTER = root
        	TARGET = scope:clan_member
        	VALUE = minor_unity_loss
        	DESC = clan_unity_threatened_clan_member.desc
        	REVERSE_NON_HOUSE_TARGET = no
       	}

		scope:chaplain = {
			add_opinion = {
				target = root
				modifier = fp3_went_too_far_opinion
			}
		}

		scope:clan_member = {
			add_opinion = {
				target = root
				modifier = fp3_fearing_retribution_opinion
				opinion = -30
			}
		}

		stress_impact = { 
   			vengeful = medium_stress_impact_loss
   			forgiving = major_stress_impact_gain
   			craven = minor_stress_impact_gain
   			paranoid = medium_stress_impact_gain
   			humble = medium_stress_impact_gain
   			compassionate = major_stress_impact_gain
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_boldness = 0.7 
           		ai_vengefulness = 1
           		ai_compassion = -1
           		ai_honor = -0.5
        	}
   		} 	
	}

	option = {
		name = fp3_clan.8002.e

		stress_impact = { 
   			honest = medium_stress_impact_loss
   			deceitful = medium_stress_impact_gain
   			ambitious = medium_stress_impact_gain
   			paranoid = medium_stress_impact_gain
   			zealous = medium_stress_impact_gain
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_energy = -1 
           		ai_honor = 0.5
           		ai_rationality = 0.5
        	}
   		} 	
	}
}

fp3_clan.8003 = { #The Power of a Name
	type = character_event
	title = fp3_clan.8003.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					dread >= 50
				}
				desc = fp3_clan.8003_fear_opening
			}
			triggered_desc = {
				trigger = {
					faith.religious_head = {
						opinion = {
							target = root
							value >= 50
						}
					}
				}
				desc = fp3_clan.8003_respect_opening
			}
		}
		desc = fp3_clan.8003_ending
	}
	theme = faith

	override_background = { reference = throne_room }
	
	left_portrait = {
		character = root
		animation = personality_honorable
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = loyal
					has_trait = greedy
					has_trait = arrogant
					has_trait = zealous 
					has_trait = trusting
				}
			}
			animation = happiness
		}
	
	}
	right_portrait = {
		character = scope:hof_emissary
		animation = chancellor
	}
	
	lower_left_portrait = { character = scope:righteous_caliph }

	trigger = {
		has_fp3_dlc_trigger = yes
		is_landed = yes
		has_religion = religion:islam_religion

		trigger_if = {
			limit = {
				government_has_flag = government_is_clan
			}
			house = { house_unity_value > decent_house_unity }
		}

		exists = faith.religious_head
		exists = faith.religious_head.location

		prestige_level >= 3

		OR = {
			faith.religious_head =  {
				opinion = {
					target = root
					value >= 50
				}		
			}
			dread >= 50		
		}

		faith.religious_head = { #If he already has a hook on you, there's no need for him to bestow upon you this honor
			NOR = { 
				this = root 
				has_hook = root
			}
		}

		OR = { #You must either be independent, or a vassal of the HoF, or have him as your direct vassal 
			top_liege = this
			faith.religious_head = { is_liege_or_above_of = root }
			any_vassal = {	this = root.faith.religious_head }
		}								
	}

	cooldown = {
		years = 25
	}

	immediate = {
		faith.religious_head = { 
			location = {
        		save_scope_as = caliphal_location
			}
			save_scope_as = righteous_caliph 
		}
		
		create_character = { #this is the head of faith's emissary 
			age = { 25 75 } 
			location = root.capital_province
			faith = root.faith.religious_head.faith
			gender_female_chance = root_faith_dominant_gender_female_chance #could be female, if given the right context.  
			trait = diplomat  
			template = priest_character_template
			save_scope_as = hof_emissary 	#this saves him as a scope so we can get nice effects to bounce off him! 
		}
	}

	option = {
		name = fp3_clan.8003.a

		trigger = {
			NOR = {
				has_trait = shy
				has_trait = humble
				
			}
		}

		add_character_modifier = {
			modifier = fp3_honored_by_the_faithful_modifier
			years = 10
		}

		if = {
			limit = {
				OR = {
					faith.religious_head = { is_liege_or_above_of = root }
					any_vassal = {	this = root.faith.religious_head }
				}
			}
			add_piety = major_piety_gain
		}
		else = { add_piety = minor_piety_gain }

		scope:righteous_caliph = {
			add_hook = {
  				type = favor_hook
   				target = root
   			}
		}

		stress_impact = { 
   			paranoid = minor_stress_impact_gain	
   			zealous = medium_stress_impact_loss
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_greed = 1
           		ai_boldness = 1
           		ai_rationality = -0.4		
        	}
   		} 
	}

	option = {
		name = fp3_clan.8003.b

		trigger = {
			OR = {
				has_trait = shy
				has_trait = humble
			}
		}

		add_piety = medium_piety_gain

		stress_impact = { 
   			zealous = minor_stress_impact_loss
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_greed = -0.7
           		ai_rationality = 1
           		ai_vengefulness = 0.5  		
        	}
   		} 
	}

	option = {
		name = fp3_clan.8003.c

		stress_impact = { 
   			humble = major_stress_impact_loss
   			content = medium_stress_impact_loss
   			ambitious = major_stress_impact_gain
   			arrogant = medium_stress_impact_gain	
   			greedy = minor_stress_impact_gain
   			zealous = minor_stress_impact_gain 
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_greed = -1
           		ai_boldness = 0.5
           		ai_honor = 1  		
        	}
   		} 	
	}
}

scripted_trigger clan_member_paranoia_trigger = {
	is_available_healthy_ai_adult = yes
	NOR = {
		has_council_position = councillor_spymaster
		has_court_position = master_assassin_court_position
	}
	OR = {
		AND = {
			OR = { #we're looking for someone with ambition
				has_trait = ambitious
				has_trait = deceitful
				has_trait = greedy
			}
			NOT = {
				opinion = {
					target = root
					value >= 25
				}
			}
		}
		opinion = { #or just someone who dislikes root 
			target = root
			value < 0
		}
	}
}

fp3_clan.8004 = { #Bonds of Fear
	type = character_event
	title = fp3_clan.8004.t
	desc = fp3_clan.8004.desc
	theme = dread
	left_portrait = {
		character = root
		animation = personality_cynical
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = callous
					has_trait = vengeful
					has_trait = arbitrary
					has_trait = sadistic
					has_trait = deceitful
				}
			}
			animation = personality_dishonorable
		}
	}
	right_portrait = {
		character = scope:murder_enthusiast
		animation = spymaster
	}

	lower_left_portrait = {
		character = scope:clan_member
	}

	trigger = {
		has_fp3_dlc_trigger = yes
		government_has_flag = government_is_clan

		house = {
			NOR = {
				house_unity_value > very_high_house_unity
				house_unity_value < critical_house_unity	
			}
			house_head = root

			any_house_unity_member = {
				clan_member_paranoia_trigger = yes
			}		
		}

		OR = {
			AND = {
				exists = cp:councillor_spymaster
				cp:councillor_spymaster = {
					is_available_healthy_ai_adult = yes
					NOT = { ai_compassion >= low_positive_ai_value }
				}
			}
			AND = {
				employs_court_position = master_assassin_court_position
 				any_court_position_holder = { 
 					type = master_assassin_court_position
 					is_available_healthy_ai_adult = yes	
 					NOT = { ai_compassion >= low_positive_ai_value }
 				}	
			}
		}
	}

	cooldown = {
		years = 10 
	}

	immediate = {
		if = {
			limit = {
				employs_court_position = master_assassin_court_position
				any_court_position_holder = {
					has_court_position = master_assassin_court_position
 					is_available_healthy_ai_adult = yes	
 					NOT = { ai_compassion >= low_positive_ai_value }
				}
			}
			random_court_position_holder = {
				limit = {
					has_court_position = master_assassin_court_position
 					is_available_healthy_ai_adult = yes	
 					NOT = { ai_compassion >= low_positive_ai_value }
				}
				save_scope_as = murder_enthusiast
			}
		}
		else_if = {
			limit = { 
				exists = cp:councillor_spymaster
				cp:councillor_spymaster = { 
					is_available_healthy_ai_adult = yes
					NOT = { ai_compassion >= low_positive_ai_value }
				}
			}
			cp:councillor_spymaster = { save_scope_as = murder_enthusiast }
		}	

		house = {
			random_house_unity_member = {
				limit = {
					clan_member_paranoia_trigger = yes
					has_relation_rival = scope:murder_enthusiast
				}
				alternative_limit = {
					clan_member_paranoia_trigger = yes
					is_powerful_vassal_of = root
				}
				alternative_limit = {
					clan_member_paranoia_trigger = yes
					is_close_family_of = root
				}
				alternative_limit = {
					clan_member_paranoia_trigger = yes
					is_claimant = yes 
				}
				alternative_limit = {
					clan_member_paranoia_trigger = yes
					can_be_knight_trigger = {
						ARMY_OWNER = root
					}
				}
				alternative_limit = {
					clan_member_paranoia_trigger = yes
				}
				save_scope_as = clan_member 
			}		
		}
	}

	option = {
		name = fp3_clan.8004.a #murder some peepl

		scope:murder_enthusiast = {
			duel = {
				skill = intrigue
				value = scope:clan_member.intrigue

				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3.5
						max = 40
						min = -40
					}

					desc = fp3_clan.8004.a.success
					root = {
						send_interface_toast = {
							title = fp3_clan.8004.a.success.tt
							left_icon = root

							add_clan_unity_interaction_effect = {
								CHARACTER = root
								TARGET = scope:clan_member
								VALUE = medium_unity_gain
								DESC = clan_unity_scared_into_sub.desc
								REVERSE_NON_HOUSE_TARGET = no
							}
 
							add_dread = medium_dread_gain 

							add_character_modifier = {
								modifier = fp3_rule_by_fear_modifier
								years = 20	
							}

       						scope:clan_member = {
								if = {
									limit = {
										ai_boldness < high_positive_ai_value
									}
									add_opinion = {
										target = root
										modifier = scared_opinion
										opinion = -10
									}
								}
								else = {
									add_opinion = {
										target = root
										modifier = fp3_murdered_my_servants_opinion
										opinion = -30
									}
								}
							}
						}
					}
				}
				50 = {
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3.5
						max = 40
						min = -40
					}

					desc = fp3_clan.8004.a.failure
					root = {
						send_interface_toast = {
							title = fp3_clan.8004.a.failure.tt
							left_icon = root

							add_clan_unity_interaction_effect = {
           						CHARACTER = root
            					TARGET = scope:clan_member
            					VALUE = minor_unity_loss
            					DESC = clan_unity_failed_scary.desc
            					REVERSE_NON_HOUSE_TARGET = no
       						}

       						add_dread = minor_dread_gain 

							if = {
								limit = {
									root.faith = {
										NOR = {
											has_doctrine_parameter = adherents_more_likely_to_join_schemes
											has_doctrine = doctrine_kinslaying_accepted
										}
									}
								}
								add_piety_level = -1
							}

							scope:clan_member = {
								if = {
									limit = {
										ai_boldness < high_positive_ai_value
										NOT = { has_relation_rival = root }
									}
									add_opinion = {
										target = root
										modifier = scared_opinion
										opinion = -10
									}
								}
								else_if = {
									limit = {
										NOT = {
											has_relation_rival = root
										}
									}
									root = {
										progress_towards_rival_effect = {
	 										CHARACTER = scope:clan_member
											REASON = rival_murdered_servants
	 										OPINION = -25
										}	
									}				
								}
								else = {
									add_opinion = {
										target = root
										modifier = fp3_murdered_my_servants_opinion
										opinion = -30
									}
								}
							}
						}
					}
				}
			}
		}

		scope:murder_enthusiast = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 30
			}
		}

		stress_impact = {  
   			deceitful = minor_stress_impact_loss
   			callous = minor_stress_impact_loss
   			compassionate = massive_stress_impact_gain
   			just = major_stress_impact_gain
   			forgiving = medium_stress_impact_gain
   			honest = medium_stress_impact_gain
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_vengefulness = 1 
           		ai_boldness = 0.5
           		ai_greed = 0.5
           		ai_honor = -1
           		ai_compassion = -1
        	}
   		} 	
	}

	option = { #you know what...there's no need to be discreet. 
		name = fp3_clan.8004.b

		add_clan_unity_interaction_effect = {
           	CHARACTER = root
            TARGET = scope:clan_member
            VALUE = minor_unity_loss
            DESC = clan_unity_murdered_servants.desc
            REVERSE_NON_HOUSE_TARGET = no
       	}

       	add_dread = major_dread_gain

		if = {
			limit = {
				root.faith = {
					NOR = {
						has_doctrine_parameter = adherents_more_likely_to_join_schemes
						has_doctrine = doctrine_kinslaying_accepted
					}
				}
			}
			root = { add_piety_level = -1 }
		}

		scope:clan_member = {
			if = {
				limit = {
					ai_boldness < high_positive_ai_value
					NOT = { has_relation_rival = root }
				}
				add_opinion = {
					target = root
					modifier = scared_opinion
					opinion = -10
				}
			}
			else_if = {
				limit = {
					NOT = {
						has_relation_rival = root
					}
				}
				root = {
					progress_towards_rival_effect = {
	 					CHARACTER = scope:clan_member
						REASON = rival_murdered_servants
	 					OPINION = -25
					}
				}
			}
			else = {
				add_opinion = {
					target = root
					modifier = fp3_murdered_my_servants_opinion
					opinion = -30
				}
			}
		}

		
		stress_impact = { 
			compassionate = massive_stress_impact_gain
			just = major_stress_impact_gain
			forgiving = medium_stress_impact_gain
			honest = medium_stress_impact_gain
			callous = minor_stress_impact_loss
		}

		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_vengefulness = 1 
				ai_boldness = 1
				ai_rationality = -0.8
		 		ai_compassion = -1 	
			}
		}
	}

	option = {
		name = fp3_clan.8004.c #be horrified

		scope:murder_enthusiast = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -20
			}
		}

		stress_impact = { 
			sadistic = major_stress_impact_gain
			callous = major_stress_impact_gain
			paranoid = medium_stress_impact_gain
			forgiving = minor_stress_impact_loss
		}

		ai_chance = { 
			base = 100
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = 1
				ai_rationality = 0.3
				ai_vengefulness = -1
				ai_boldness = -0.3
			}
		}
	}
}

###################################
# A Proper Position, by Ola Jentzsch
###################################

scripted_trigger clan_harem_intrigue_parent_trigger = {
	is_available_adult = yes
	is_courtier = yes 
	NOT = {
		has_trait = content
		has_trait = craven 
	}
	any_child = {
		count > 0
		clan_harem_intrigue_child_trigger = yes 
	}
}

scripted_trigger clan_harem_intrigue_child_trigger = {
	is_available_child = yes 
	age > 5
	NOT = { is_primary_heir_of = root }
	fp3_proper_gender_for_dynastic_ambition_trigger = yes
	any_heir_title = {
  		count < 1
    	tier >= tier_county
    }
}

fp3_clan.8005 = { #A Proper Position
	type = character_event  
	title = fp3_clan.8005.t
	desc = fp3_clan.8005.desc
	theme = crown

	left_portrait = {
		character = scope:ambitious_consort
		animation = disapproval
		triggered_animation = {
			trigger = {
				ai_vengefulness >= medium_positive_ai_value
			}
			animation = schadenfreude 
		}
		triggered_animation = {
			trigger = {
				ai_boldness < low_positive_ai_value
			}
			animation = beg
		}
	}

	right_portrait = {
		character = root
		animation = personality_cynical
	}
	lower_left_portrait = { character = scope:empowered_child }

	lower_center_portrait = { character = scope:heir_parent } 

	lower_right_portrait = { character = scope:heir_child }

	trigger = { 
		has_fp3_dlc_trigger = yes
		government_has_flag = government_is_clan

		NOT = { 
			house = {
				house_unity_value > very_high_house_unity
			}
		}

		any_held_title = {
			title_tier = county
			is_landless_type_title = no
			this != root.capital_county
		}

		domain_size > 4 

		any_consort = { 
			clan_harem_intrigue_parent_trigger = yes
			save_temporary_scope_as = consort_1
			any_child = {
				clan_harem_intrigue_child_trigger = yes
			}
			NOT = {
				any_child = { is_primary_heir_of = root }
			}
		}

		any_consort = {
			this != scope:consort_1
			is_available_adult = yes
			is_courtier = yes 
			any_child = {
				is_child_of = root
				is_primary_heir_of = root 
			}
		}
	}

	cooldown = { years = 10 }

	immediate = {
		save_scope_as = special_root_scope #this is used to trigger a player-facing toast in the hidden follow-up event

		random_consort = {
			limit = {
				clan_harem_intrigue_parent_trigger = yes 
				any_child = { clan_harem_intrigue_child_trigger = yes }
				NOT = {
					any_child = { is_primary_heir_of = root }
				}
			}
			random_child = {
				limit = {
					clan_harem_intrigue_child_trigger = yes
				}
				save_scope_as = empowered_child
			}
			save_scope_as = ambitious_consort
		}

		random_consort = {
			limit = { 
				this != scope:ambitious_consort
				is_available_adult = yes
				is_courtier = yes 
				any_child = {
					is_child_of = root
					is_primary_heir_of = root 
				}
			}
			random_child = {
				limit = {
					this != scope:empowered_child
					is_child_of = root
					is_primary_heir_of = root 
				}
				save_scope_as = heir_child 
			}
			save_scope_as = heir_parent
		}

		random_held_title = {
			title_tier = county
			limit = {
				is_landless_type_title = no
				this != root.capital_county
			}
			save_scope_as = title_to_grant
		}

		scope:ambitious_consort = {
			progress_towards_rival_effect = {
	 		 CHARACTER = scope:heir_parent
				REASON = rival_harem_intrigue
	 			OPINION = -25
			}	
		}	
	}

	option = {
		name = fp3_clan.8005.a

		trigger = { #if you're a certain personality, you can scare them into submission
			OR = {
				dread >= high_dread
				has_trait = vengeful
				has_trait = wrathful
				has_trait = arbitrary 
			}
		}

		add_dread = minor_dread_gain 

		scope:ambitious_consort = {
			if = {
				limit = {
					OR = {
						ai_vengefulness >= medium_positive_ai_value
						ai_boldness >= medium_positive_ai_value 
					}
				}
				add_opinion = {
					target = root
					opinion = -40
					modifier = angry_opinion
				}
				scope:ambitious_consort = {
					progress_towards_rival_effect = {
	 		 			CHARACTER = scope:heir_parent
						REASON = rival_harem_intrigue
	 					OPINION = -25
					}	
				}
			}
			else = {
				add_opinion = {
					target = root
					opinion = -25
					modifier = scared_opinion
				}	
			}
		}

		stress_impact = { 
   			wrathful = minor_stress_impact_loss
   			calm = major_stress_impact_gain
   			compassionate = medium_stress_impact_gain
   			generous = medium_stress_impact_gain
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_vengefulness = 1
           		ai_compassion = -1
           		ai_greed = 0.4
        	}
   		} 	
	}

	option = { #Give the child the title
		name = fp3_clan.8005.b	
		flavor = original_heir_upset_flavor

		scope:title_to_grant.current_heir = {
			add_opinion = {
				target = root
				opinion = -30
				modifier = angry_opinion
			}
		}

		create_title_and_vassal_change = {
			type = granted
			save_scope_as = change
		}
		scope:title_to_grant = {
			change_title_holder = {
				holder = scope:empowered_child
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change	

		scope:empowered_child = {
			hidden_effect = {
				trigger_event = {
					id = fp3_clan.8007
					years = { 2 4 }
				}
			}
			custom_tooltip = fp3_empowered_child.tt
		}

		scope:ambitious_consort = {
			add_opinion = {
				target = root
				opinion = 30
				modifier = happy_opinion
			}
		}

		stress_impact = { 
   			generous = medium_stress_impact_loss
   			greedy = medium_stress_impact_gain
   			ambitious = minor_stress_impact_gain
   			stubborn = minor_stress_impact_gain
   		}

		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_greed = -0.6
           		ai_compassion = 0.4
           		ai_honor = 0.4
        	}
   		} 	
	}

	option = { #A bit young for a court position, don't you think? 
		name = fp3_clan.8005.d

		trigger = {
			scope:empowered_child = { age <= 10 } 
		}

		scope:ambitious_consort = {
			progress_towards_rival_effect = {
	 		 CHARACTER = scope:heir_parent
				REASON = rival_harem_intrigue
	 			OPINION = -25
			}	

			add_opinion = {
				target = root
				opinion = -30
				modifier = angry_opinion
			}
		}

		stress_impact = { 
   			generous = minor_stress_impact_gain
   			craven = minor_stress_impact_gain
   			trusting = minor_stress_impact_gain 
   		}

   		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_rationality = 0.8
           		ai_compassion = -0.2
        	}
   		} 		
	}

	option = {  #Reassure her
		name = fp3_clan.8005.e

		duel = {
			skill = diplomacy
			value = scope:ambitious_consort.diplomacy

			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					max = 40
					min = -40
				}

				modifier = {
					add = 100
					scope:ambitious_consort = {
						opinion = { 
							target = root
							value > 50
						}
					}
				}

				modifier = {
					add = 50
					scope:ambitious_consort = {	has_trait = trusting }
				}

				desc = fp3_clan.8005.e.success
				send_interface_toast = {
					title = fp3_clan.8005.e.success.tt
					left_icon = root

					add_clan_unity_interaction_effect = {
						CHARACTER = root
						TARGET = scope:ambitious_consort
						VALUE = minor_unity_gain
						DESC = clan_unity_promise_inheritance.desc
						REVERSE_NON_HOUSE_TARGET = no
					}

					scope:ambitious_consort = {
						add_opinion = {
							target = root
							opinion = 20
							modifier = trust_opinion
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					max = 40
					min = -40
				}

				desc = fp3_clan.8005.e.failure
				send_interface_toast = {
					title = fp3_clan.8005.e.failure.tt
					left_icon = root

					scope:ambitious_consort = {
						add_opinion = {
							target = root
							opinion = -30
							modifier = angry_opinion
						}
					}

					scope:ambitious_consort = {
						progress_towards_rival_effect = {
	 						CHARACTER = scope:heir_parent
							REASON = rival_harem_intrigue
	 						OPINION = -25
						}	
					}
				}
			}
		}

		stress_impact = { 
   			wrathful = medium_stress_impact_gain
   			arrogant = medium_stress_impact_gain
   			callous = medium_stress_impact_gain
   		}

   		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_compassion = 0.7
           		ai_honor = 0.4
           		ai_sociability = 1
           		ai_vengefulness = -1
        	}
   		} 			
	}
}


###################################
# Smaller Spies, by Ola Jentzsch
###################################

scripted_trigger suitable_spy_child_trigger = {
	is_child_of = root
	is_available_child = yes 
	is_courtier_of = root
	age >= 7
	age <= 14
	OR = {
		has_trait = curious
		has_trait = rowdy
		has_trait = charming	
		has_trait = deceitful
		has_trait = paranoid 
		has_trait = callous
	}
	NOT = { is_primary_heir_of = root }
}

scripted_trigger assassin_spymaster_trigger = {
	is_available_healthy_ai_adult = yes	
 	ai_compassion <= low_positive_ai_value
}

fp3_clan.8006 = {
	type = character_event  
	title = fp3_clan.8006.t
	desc = fp3_clan.8006.desc
	theme = intrigue_skulduggery_focus

	left_portrait = {
		character = scope:sneaky_child
		animation = disapproval
		triggered_animation = {
			trigger = {
				AND = {
					ai_compassion < low_positive_ai_value
					ai_vengefulness >= low_positive_ai_value
				}
			}
			animation = personality_callous
		}
		triggered_animation = {
			trigger = {
				ai_compassion >= low_positive_ai_value
			}
			animation = paranoia
		}
	}

	right_portrait = {
		character = scope:paranoia_enthusiast
		animation = scheme
		triggered_animation = {
			trigger = {
				ai_vengefulness >= medium_positive_ai_value
			}
			animation = schadenfreude 
		}
	}

	lower_left_portrait = { character = root }

	cooldown = { years = 10 }

	trigger = {
		has_fp3_dlc_trigger = yes
		government_has_flag = government_is_clan

		house = { 
			house_unity_value <= mediocre_house_unity
			any_house_unity_member = { #checking that a decent amount of other adult clan members exists, this event wouldn't make sense otherwise
				is_adult = yes
				count >= 4
			}		
		}
		
		any_child = {
			is_available_ai = yes
			suitable_spy_child_trigger = yes
		}

		OR = {
			AND = {
				exists = cp:councillor_spymaster
				cp:councillor_spymaster = {
					assassin_spymaster_trigger = yes
				}
			}
			AND = {
				employs_court_position = master_assassin_court_position
 				any_court_position_holder = { 
 					type = master_assassin_court_position
 					assassin_spymaster_trigger = yes
 				}
			}
		}
	}

	immediate = {
		random_child = {
			limit = {
				is_available_ai = yes
				suitable_spy_child_trigger = yes
			}
			save_scope_as = sneaky_child
		}

		if = {
			limit = {
				employs_court_position = master_assassin_court_position
				any_court_position_holder = {
					has_court_position = master_assassin_court_position
 					assassin_spymaster_trigger = yes
				}
			}
			random_court_position_holder = {
				limit = {
					has_court_position = master_assassin_court_position
 					assassin_spymaster_trigger = yes
				}
				save_scope_as = paranoia_enthusiast
			}
		}
		else_if = {
			limit = { 
				exists = cp:councillor_spymaster
				cp:councillor_spymaster = { 
					assassin_spymaster_trigger = yes
				}
			}
			cp:councillor_spymaster = { save_scope_as = paranoia_enthusiast }
		}

		scope:sneaky_child = {
			if = {
				limit = {
					any_relation = {
						type = guardian
					}
				}
				random_relation = {
					type = guardian
					save_scope_as = little_sneakys_guardian
				}
			}
		}
	}

	option = {
		name = fp3_clan.8006.a

		add_clan_unity_interaction_effect = {
			CHARACTER = root
			TARGET = scope:sneaky_child
			VALUE = minor_unity_gain
			DESC = clan_unity_asserted_child_status.desc
			REVERSE_NON_HOUSE_TARGET = no
		}

		scope:paranoia_enthusiast = {
			add_opinion = {
				target = root
				opinion = -10
				modifier = disappointed_opinion
			}
		}

		scope:sneaky_child = {
			add_opinion = {
				target = root
				opinion = -30
				modifier = fp3_denied_me_an_opportunity_opinion
			}
		}

		stress_impact = { 
   			ambitious = minor_stress_impact_gain
   			paranoid = minor_stress_impact_gain
   			deceitful = minor_stress_impact_gain
   		}

   		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_honor = 1
           		ai_sociability = 1
           		ai_vengefulness = -1
           		ai_boldness = 0.5
        	}
   		}
	}

	option = {
		name = fp3_clan.8006.b
		
		add_clan_unity_interaction_effect = {
			CHARACTER = root
			TARGET = scope:sneaky_child
			VALUE = minor_unity_loss
			DESC = clan_unity_let_child_become_spy.desc
			REVERSE_NON_HOUSE_TARGET = no
		}

		add_character_modifier = {
			modifier = fp3_minor_child_spy_network_modifier
			years = 15
		}

		if = {
			limit = {
				exists = scope:little_sneakys_guardian
				scope:little_sneakys_guardian = {
					OR = {
						is_ai = yes
						this = root 
					}
					this != scope:paranoia_enthusiast
				}
			}
			scope:sneaky_child = {
				remove_relation_guardian = scope:little_sneakys_guardian
			}
		}
 
		scope:sneaky_child = {
			if = {
				limit = {
					OR = {
						num_of_relation_guardian < 1
						any_relation = {
							type = guardian
							OR = {
								is_ai = yes
								this = root
							}
							this != scope:paranoia_enthusiast
						}
					}
				}
				set_relation_guardian = scope:paranoia_enthusiast
				add_intrigue_skill = 1
			}
			else = {
				add_intrigue_skill = 1
			}	
		}

		scope:sneaky_child = {
			add_opinion = {
				target = root
				opinion = 20
				modifier = happy_opinion
			}
		}

		scope:paranoia_enthusiast = {
			add_opinion = {
				target = root
				opinion = 15
				modifier = took_my_advice_opinion
			}
		}

		stress_impact = { 
   			compassionate = medium_stress_impact_gain
   			honest = medium_stress_impact_gain
   		}

   		ai_chance = { 
        	base = 50
        	ai_value_modifier = {
           		ai_boldness = 0.3
           		ai_sociability = 0.3
           		ai_vengefulness = 1
           		ai_honor = -0.5
           		ai_compassion = -0.8
        	}
   		}
	}

	option = {
		name = fp3_clan.8006.c

		pay_short_term_gold = {
 			target = scope:paranoia_enthusiast
 			gold = minor_gold_value
 		}

		add_character_modifier = {
			modifier = fp3_minor_child_spy_network_modifier
			years = 15
		}

		scope:sneaky_child = {
			add_opinion = {
				target = root
				opinion = -30
				modifier = fp3_denied_me_an_opportunity_opinion
			}
		}

		stress_impact = { 
   			deceitful = minor_stress_impact_gain
   			greedy = minor_stress_impact_gain
   		}

   		ai_chance = { 
        	base = 100
        	ai_value_modifier = {
           		ai_honor = 1
           		ai_compassion = 1
           		ai_rationality = 0.5
           		ai_vengefulness = -1
           		ai_boldness = -0.5
        	}
   		} 	
	}
}

scripted_effect random_skill_chance_effect = {
	send_interface_toast = {
		title = fp3_8007_studies_pay_off_toast
		left_icon = scope:empowered_child
		scope:empowered_child = {
			add_stewardship_skill = 1
			add_$SKILL_2$_skill = 1
		}
	}
}

fp3_clan.8007 = { #Hidden event to set up child's traits
	hidden = yes

	trigger = {
		has_fp3_dlc_trigger = yes
		exists = scope:empowered_child
		any_held_title = {
			this = scope:title_to_grant
		}
	}

	immediate = {
		random_list = {
			25 = {
				random_skill_chance_effect = { SKILL_2 = martial }
			}
			25 = {
				random_skill_chance_effect = { SKILL_2 = diplomacy }
			}
			25 = {
				random_skill_chance_effect = { SKILL_2 = learning }
			}
			25 = {
				random_skill_chance_effect = { SKILL_2 = intrigue }
			}
		}
	}
}

	
	

	
