﻿namespace = enfp_family

# "Unworthy Spouse" — your bad traited spouse is embarrassed at their low status
enfp_family.0001 = {
	type = character_event
	title = enfp_family.0001.t
	desc = enfp_family.0001.desc
	theme = family

	cooldown = { years = 20 }

	trigger = {
		is_landed = yes
		any_spouse = {
			# they need to care about your opinion
			opinion = {
				target = root
				value > 0
			}
			is_ai = yes
			is_available = yes
			OR = {
				has_trait = disinherited
				has_trait = denounced
				has_trait = murderer
				is_lowborn = yes
				has_trait = bastard
				has_trait = legitimized_bastard
				has_trait = leper
				has_trait = lovers_pox
			}
			NOT = {
				OR = {
					has_trait = arrogant
					has_trait = ambitious
					has_trait = sadistic
					has_trait = callous
				}
			}
		}
	}

	immediate = {
		random_spouse = {
			limit = {
				OR = {
					has_trait = disinherited
					has_trait = denounced
					has_trait = murderer
					is_lowborn = yes
					has_trait = bastard
					has_trait = legitimized_bastard
					has_trait = leper
					has_trait = lovers_pox
				}
				opinion = {
					target = root
					value > 0
				}
				NOT = {
					OR = {
						has_trait = arrogant
						has_trait = ambitious
					}
				}
			}
			save_scope_as = badspouse
		}
	}

	left_portrait = {
		character = scope:badspouse
		animation = sadness
	}

	# tell them you like them the way they are
	option = {
		name = enfp_family.0001.a

		scope:badspouse = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 50
			}
		}

		stress_impact = {
			compassionate = major_stress_impact_loss
			humble = medium_stress_impact_loss
			content = medium_stress_impact_loss
			arrogant = medium_stress_impact_gain
			ambitious = minor_stress_impact_gain
			callous = medium_stress_impact_gain
			sadistic = major_stress_impact_gain
		}

		ai_chance = {
			base = 20
			modifier = { add = 30 has_trait = compassionate }
			modifier = { add = 20 has_trait = humble }
			modifier = { add = 10 has_trait = content }
			modifier = { add = -10 has_trait = arrogant }
			modifier = { add = -10 has_trait = ambitious }
			modifier = { add = -15 has_trait = callous }
			modifier = { add = -25 has_trait = sadistic }
		}
	}

	# yeah, you are a disgrace!
	option = {
		name = enfp_family.0001.b

		scope:badspouse = {
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -50
			}
		}

		stress_impact = {
			compassionate = medium_stress_impact_gain
			just = medium_stress_impact_gain
			callous = medium_stress_impact_loss
			arrogant = medium_stress_impact_loss
			sadistic = minor_stress_impact_loss
			humble = medium_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 10
			modifier = { add = -50 has_trait = compassionate }
			modifier = { add = -50 has_trait = just }
			modifier = { add = 20 has_trait = callous }
			modifier = { add = 10 has_trait = arrogant }
			modifier = { add = 15 has_trait = sadistic }
			modifier = { add = -10 has_trait = humble }
			modifier = { add = -5 has_trait = content }
		}
	}

	# Kill them if you are sadistic or a lunatic
	option = {
		name = enfp_family.0001.c
		trait = lunatic_1
		trait = sadistic
		add_internal_flag = dangerous

		trigger = {
			OR = {
				has_trait = sadistic
				has_trait = lunatic_1
			}
		}

		murder_opinion_effect = {
			VICTIM = scope:badspouse
			MURDERER = root
		}

		add_tyranny = major_tyranny_gain

		scope:badspouse = {
			death = {
				death_reason = death_execution
				killer = root
			}
		}

		stress_impact = {
			sadistic = minor_stress_impact_loss
			vengeful = minor_stress_impact_loss
			just = major_stress_impact_gain
			compassionate = major_stress_impact_gain
			callous = minor_stress_impact_loss
			arrogant = minor_stress_impact_loss
			humble = major_stress_impact_gain
		}

		ai_chance = {
			base = 0
			modifier = { add = 50 has_trait = sadistic }
			modifier = { add = 50 has_trait = lunatic }
			modifier = { add = -100 has_trait = compassionate }
			modifier = { add = -50 has_trait = just }
			modifier = { add = 10 has_trait = callous }
			modifier = { add = 5 has_trait = arrogant }
			modifier = { add = -30 has_trait = humble }
		}
	}

	# I want a divorce !
	option = {
		name = enfp_family.0001.d

		trigger = {
			faith = {
				OR = {
					has_doctrine_parameter = divorce_approval
					has_doctrine_parameter = divorce_allowed
				}
			}
		}

		if = {
			limit = {
				faith = { has_doctrine_parameter = divorce_allowed }
			}
			
			divorce_effect = {
				DIVORCER = root
				DIVORCEE = scope:badspouse
			}
		}

		if = {
			limit = {
				faith = {
					has_doctrine_parameter = divorce_approval
					exists = religious_head
				}
			}
			
			divorce_effect = {
				DIVORCER = root
				DIVORCEE = scope:badspouse
			}
			trigger_event = { id = enfp_family.0002 days = 25 }
		}

		stress_impact = {
			compassionate = medium_stress_impact_gain
			just = medium_stress_impact_gain
			callous = minor_stress_impact_loss
			arrogant = minor_stress_impact_loss
			zealous = major_stress_impact_gain
			content = minor_stress_impact_gain
		}

		ai_chance = {
			base = 30
			modifier = { add = -20 has_trait = zealous }
			modifier = { add = 20 has_trait = callous }
			modifier = { add = 10 has_trait = arrogant }
			modifier = { add = -20 has_trait = compassionate }
		}
	}
}

# head of faith condemns your illicit divorce, I am too lazy right now to do other options, just use the vanilla divorce feature anyways, this should probably care about HoF traits too but this my first letter event ok
enfp_family.0002 = {
	type = letter_event

	trigger = {
		NOT = {
			any_held_title = {
				is_head_of_faith = yes
			}
		}
	}

	immediate = {
		root = {
			faith = {
				save_scope_as = rootfaith
				religious_head = {
					save_scope_as = hof
				}
			}
		}
	}

	opening = {
		desc = enfp_family.0002.opening
	}

	desc = enfp_family.0002.desc
	sender = scope:hof

	option = {
		name = enfp_family.0002.a
		flavor = enfp_family.0002.flavor

		scope:hof = {
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -50
			}
		}

		every_vassal = {
			limit = {
				has_faith = scope:rootfaith
				has_vassal_stance = zealot
			}
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -50
			}
		}

		

		ai_chance = {
			base = 100
		}
	}
}

# Family Drama, mostly copied from the bastard event, but does the same thing with family members.
enfp_family.0003 = {
	type = character_event
	title = enfp_family.0003.t
	desc = enfp_family.0003.desc
	theme = family

	cooldown = {years = 20}

	

immediate = {
    
    random_close_family_member = {
        limit = {
            is_available = yes
            is_ai = yes    
            age > 13
            NOT = { this = root }
            
            
            any_close_family_member = {
                NOT = { this = root }
                NOT = { this = prev }
                NOR = {
                    has_relation_friend = prev
                    has_relation_best_friend = prev
                    has_relation_lover = prev
                    has_relation_soulmate = prev
                    has_relation_rival = prev
                    has_relation_nemesis = prev
                }
                is_available = yes
                is_ai = yes
                age > 13
            }
        }
        save_scope_as = angryfamily1
    }
    
    
    if = {
        limit = { exists = scope:angryfamily1 }
        scope:angryfamily1 = {
            random_close_family_member = {
                limit = {
                    NOT = { this = scope:angryfamily1 }
                    NOT = { this = root }
                    NOR = {
                        has_relation_friend = scope:angryfamily1
                        has_relation_best_friend = scope:angryfamily1
                        has_relation_lover = scope:angryfamily1
                        has_relation_soulmate = scope:angryfamily1
                        has_relation_rival = scope:angryfamily1
                        has_relation_nemesis = scope:angryfamily1
                    }
                    is_available = yes
                    is_ai = yes
                    age > 13
                }
                save_scope_as = angryfamily2
            }
        }
    }
    
    
    if = {
        limit = {
            exists = scope:angryfamily1
            exists = scope:angryfamily2
        }
        scope:angryfamily1 = {
            set_relation_rival = {
                target = scope:angryfamily2
                reason = enfp_family_fight
            }
        }
    }
	}

		trigger = {
			age > 13
			any_close_family_member = {
				
				is_available = yes
				is_ai = yes	
				age > 13
				NOT = { this = root }
				save_temporary_scope_as = angryfamilytemp
			}

			scope:angryfamilytemp = {
				any_close_family_member = {
					NOT = { this = root }

					NOT = {this = scope:angryfamilytemp}
					
					NOR = {
					has_relation_friend = scope:angryfamilytemp
					has_relation_best_friend = scope:angryfamilytemp
					has_relation_lover = scope:angryfamilytemp
					has_relation_soulmate = scope:angryfamilytemp
					has_relation_rival = scope:angryfamilytemp
					has_relation_nemesis = scope:angryfamilytemp
				}
					
					is_available = yes
					is_ai = yes
					age > 13
					save_temporary_scope_as = angryfamilytemp2
					
				}
			}

		
			

		}

		left_portrait = {
			character = scope:angryfamily2
			animation = anger
		}

		right_portrait = {
			character = scope:angryfamily1
			animation = disapproval
		}
	
	option = {
		name = enfp_family.0003.a
			scope:angryfamily2 = {
				add_opinion = {
					target = root
					opinion = 50
					modifier = grateful_opinion

				}

			
			}

			scope:angryfamily1 = {
				add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -75
				}	
			}

			ai_chance = {
				base = 50
			}

	}
	
	option = {
		name = enfp_family.0003.b
		scope:angryfamily1 = {
				add_opinion = {
					target = root
					opinion = 50
					modifier = grateful_opinion

				}

			
			}

			scope:angryfamily2 = {
				add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -75
				}	
			}

			ai_chance = {
				base = 50
			}
	}

}

# Family Drama, but rarer and with more ANGER
enfp_family.0004 = {
	type = character_event
	title = enfp_family.0004.t
	desc = enfp_family.0004.desc
	theme = family
	cooldown = {years = 20}

	

	immediate = {
   
    random_close_family_member = {
        limit = {
            is_available = yes
            is_ai = yes    
            age > 13
            NOT = { this = root }
            
            # ENSURE this family member has a valid target
            any_close_family_member = {
                NOT = { this = root }
                NOT = { this = prev }
                NOR = {
                    has_relation_friend = prev
                    has_relation_best_friend = prev
                    has_relation_lover = prev
                    has_relation_soulmate = prev
                    has_relation_rival = prev
                    has_relation_nemesis = prev
                }
                is_available = yes
                is_ai = yes
                age > 13
            }
        }
        save_scope_as = angryfamily1
    }
    
    
    if = {
        limit = { exists = scope:angryfamily1 }
        scope:angryfamily1 = {
            random_close_family_member = {
                limit = {
                    NOT = { this = scope:angryfamily1 }
                    NOT = { this = root }
                    NOR = {
                        has_relation_friend = scope:angryfamily1
                        has_relation_best_friend = scope:angryfamily1
                        has_relation_lover = scope:angryfamily1
                        has_relation_soulmate = scope:angryfamily1
                        has_relation_rival = scope:angryfamily1
                        has_relation_nemesis = scope:angryfamily1
                    }
                    is_available = yes
                    is_ai = yes
                    age > 13
                }
                save_scope_as = angryfamily2
            }
        }
    }
    
    
    if = {
        limit = {
            exists = scope:angryfamily1
            exists = scope:angryfamily2
        }
        scope:angryfamily1 = {
            set_relation_rival = {
                target = scope:angryfamily2
                reason = enfp_family_fight
            }
        }
    }
	}


		trigger = {
			age > 13
			any_close_family_member = {
				
				is_available = yes
				is_ai = yes	
				age > 13
				NOT = { this = root }
				save_temporary_scope_as = angryfamilytemp
			}

			scope:angryfamilytemp = {
				any_close_family_member = {
					NOT = {this = scope:angryfamilytemp}
					NOT = { this = root }

					NOR = {
					has_relation_friend = scope:angryfamilytemp
					has_relation_best_friend = scope:angryfamilytemp
					has_relation_lover = scope:angryfamilytemp
					has_relation_soulmate = scope:angryfamilytemp
					has_relation_rival = scope:angryfamilytemp
					has_relation_nemesis = scope:angryfamilytemp
				}
					
					is_available = yes
					is_ai = yes
					age > 13
					save_temporary_scope_as = angryfamilytemp2
					
				}
			}
			

		}

		left_portrait = {
			character = scope:angryfamily2
			animation = anger
		}

		right_portrait = {
			character = scope:angryfamily1
			animation = disapproval
		}
	
	option = {
		name = enfp_family.0003.a
			scope:angryfamily2 = {
				add_opinion = {
					target = root
					opinion = 75
					modifier = grateful_opinion

				}

			
			}

			scope:angryfamily1 = {
				add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -100
				}	
			}

			ai_chance = {
				base = 50
			}

	}
	
	option = {
		name = enfp_family.0003.b
		scope:angryfamily1 = {
				add_opinion = {
					target = root
					opinion = 75
					modifier = grateful_opinion

				}

			
			}

			scope:angryfamily2 = {
				add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -100
				}	
			}

			ai_chance = {
				base = 50
			}
	}

}

# Family Drama, but from the perspective of root
enfp_family.0005 = {
	type = character_event
	title = enfp_family.0005.t
	desc = enfp_family.0005.desc
	theme = family
	cooldown = {years = 20}

	trigger = {
		age > 13
		any_close_family_member = {
			NOT = { this = root }
			NOR = {
				has_trait = compassionate
				has_trait = shy
				has_relation_friend = root
				has_relation_best_friend = root
				has_relation_lover = root
				has_relation_soulmate = root
				has_relation_rival = root
				has_relation_nemesis = root

			}
			is_ai = yes
			is_available = yes
			age > 13
			
		}
	}

		immediate = {
			random_close_family_member = {
				limit = {
					NOT = { this = root }
					NOR = {
					has_trait = compassionate
					has_trait = shy
					has_relation_friend = root
					has_relation_best_friend = root
					has_relation_lover = root
					has_relation_soulmate = root
					has_relation_rival = root
					has_relation_nemesis = root

					}
			is_ai = yes
			is_available = yes
			age > 13

				}
				save_scope_as = angryfamily

				set_relation_rival = {
					target = root
					reason = enfp_family_fight
				}
				add_opinion = {
					target = root
					modifier = angry_opinion
					opinion = -75
				}

			}
		}

		left_portrait = {
			character = root
			animation = anger
		}

		right_portrait = {
			character = scope:angryfamily
			animation = disapproval
		}


	option = {
		name = enfp_family.0005.a

	}
		
}
#family drama but for kids! (root perspective)
enfp_family.0006 = {
	type = character_event
	title = enfp_family.0006.t
	desc = enfp_family.0006.desc
	theme = family
	cooldown = {years = 20}

	trigger = {
		age < 13
		any_close_family_member = {
			NOT = { this = root }
			NOR = {
				has_trait = compassionate
				has_trait = shy
				has_relation_friend = root
				has_relation_best_friend = root
				has_relation_lover = root
				has_relation_soulmate = root
				has_relation_rival = root
				has_relation_nemesis = root
			}
			is_ai = yes
			is_available = yes
			age < 13
		}
	}

	immediate = {
		random_close_family_member = {
			limit = {
				NOT = { this = root }
				NOR = {
					has_trait = compassionate
					has_trait = shy
					has_relation_friend = root
					has_relation_best_friend = root
					has_relation_lover = root
					has_relation_soulmate = root
					has_relation_rival = root
					has_relation_nemesis = root
				}
				is_ai = yes
				is_available = yes
				age < 13
			}
			save_scope_as = angryfamily

			set_relation_rival = {
				target = root
				reason = enfp_family_fight
			}
			add_opinion = {
				target = root
				modifier = angry_opinion
				opinion = -75
			}
		}
	}

	left_portrait = {
		character = root
		animation = anger
	}

	right_portrait = {
		character = scope:angryfamily
		animation = disapproval
	}

	option = {
		name = enfp_family.0006.a
	}
}
# Family Drama from kids perspective
enfp_family.0007 = {
	type = character_event
	title = enfp_family.0007.t
	desc = enfp_family.0007.desc
	theme = family
	cooldown = {years = 20}

	immediate = {
		random_close_family_member = {
			limit = {
				is_available = yes
				is_ai = yes    
				age > 13
				NOT = { this = root }

				any_close_family_member = {
					NOT = { this = root }
					NOT = { this = prev }
					NOR = {
						has_relation_friend = prev
						has_relation_best_friend = prev
						has_relation_lover = prev
						has_relation_soulmate = prev
						has_relation_rival = prev
						has_relation_nemesis = prev
					}
					is_available = yes
					is_ai = yes
					age > 13
				}
			}
			save_scope_as = angryfamily1
		}

		if = {
			limit = { exists = scope:angryfamily1 }
			scope:angryfamily1 = {
				random_close_family_member = {
					limit = {
						NOT = { this = scope:angryfamily1 }
						NOT = { this = root }
						NOR = {
							has_relation_friend = scope:angryfamily1
							has_relation_best_friend = scope:angryfamily1
							has_relation_lover = scope:angryfamily1
							has_relation_soulmate = scope:angryfamily1
							has_relation_rival = scope:angryfamily1
							has_relation_nemesis = scope:angryfamily1
						}
						is_available = yes
						is_ai = yes
						age > 13
					}
					save_scope_as = angryfamily2
				}
			}
		}

		if = {
			limit = {
				exists = scope:angryfamily1
				exists = scope:angryfamily2
			}
			scope:angryfamily1 = {
				set_relation_rival = {
					target = scope:angryfamily2
					reason = enfp_family_fight
				}
			}
		}
	}

	trigger = {
		age < 13
		any_close_family_member = {
			is_available = yes
			is_ai = yes
			age > 13
			NOT = { this = root }
			save_temporary_scope_as = angryfamilytemp
		}
		scope:angryfamilytemp = {
			any_close_family_member = {
				NOT = { this = scope:angryfamilytemp }
				NOT = { this = root }
				NOR = {
					has_relation_friend = scope:angryfamilytemp
					has_relation_best_friend = scope:angryfamilytemp
					has_relation_lover = scope:angryfamilytemp
					has_relation_soulmate = scope:angryfamilytemp
					has_relation_rival = scope:angryfamilytemp
					has_relation_nemesis = scope:angryfamilytemp
				}
				is_available = yes
				is_ai = yes
				age > 13
				save_temporary_scope_as = angryfamilytemp2
			}
		}
	}

	left_portrait = {
		character = scope:angryfamily2
		animation = anger
	}

	right_portrait = {
		character = scope:angryfamily1
		animation = disapproval
	}

	option = {
		name = enfp_family.0007.a
	}
}
# "Barren Loins," your spouse becomes totally infertile
enfp_family.0008 = {
	type = character_event
	title = enfp_family.0008.t
	desc = enfp_family.0008.desc
	theme = family
	cooldown = { years = 20 }

	trigger = {
		exists = primary_spouse
		primary_spouse = {
			age < 45 
			is_ai = yes
			is_available = yes
			NOT = {
				has_character_modifier = enfp_infertility
			}
		}
	}

	immediate = {
		random_spouse = {
			limit = {
				age < 45
				is_ai = yes
				is_available = yes
				NOT = {
				has_character_modifier = enfp_infertility
				}

			}
			save_scope_as = infertilespouse
		}
	}

	left_portrait = {
		character = root
		animation = worry
	}

	right_portrait = {
		character = scope:infertilespouse
		animation = shame
	}

	option = {
		name = enfp_family.0008.a
		scope:infertilespouse = {
			add_character_modifier = enfp_infertility
		}
	}
}

# "Barren Loins," YOU become totally infertile
enfp_family.0009 = {
	type = character_event
	title = enfp_family.0009.t
	desc = enfp_family.0009.desc
	theme = family
	cooldown = { years = 20 }

	trigger = {
		age < 45
		is_adult = yes
		exists = primary_spouse
		primary_spouse = {
			is_ai = yes
			is_available = yes
			
		}
		NOT = {
			has_character_modifier = enfp_infertility
		}
	}

	immediate = {
		random_spouse = {
			limit = {
				
				is_ai = yes
				is_available = yes
				
			}
			save_scope_as = unluckyspouse
		}
	}

	left_portrait = {
		character = root
		animation = shame
	}

	right_portrait = {
		character = scope:unluckyspouse
		animation = worry
	}

	option = {
		name = enfp_family.0009.a
		add_character_modifier = enfp_infertility
	}
}








