namespace = eps_chain


##################################################
# Two Kinds of Love
# by Ranger
# 0001-####
##################################################

# You come across one woman beating another
eps_chain.0001 = { 
	type = character_event
	title = eps_chain.0001.t
	desc =  eps_chain.0001.desc
	theme = travel

	left_portrait = {
		character = scope:housewife_peasant_scope 
		animation = anger
	}
	right_portrait = {
		character = scope:yandere_peasant_scope
		animation = fear
	}

	cooldown = { years = 40 }
	
	trigger = {
		is_available_travelling = yes
		is_location_valid_for_travel_event_on_land = yes
	}

	immediate = {
		create_character = {
			template = yandere_peasant_character
			location = root.location
			culture = root.location.county.culture
			faith = root.location.county.faith
			dynasty = none
			#Set up the scope
			save_scope_as = yandere_peasant_scope
		}
		create_character = {
			template = generic_female_peasant_character 
			location = root.location
			culture = root.location.county.culture
			faith = root.location.county.faith
			dynasty = none
			#Set up the scope
			save_scope_as = housewife_peasant_scope
		}
		# Ensure characters were created successfully
		if = {
			limit = {
				exists = scope:yandere_peasant_scope
				exists = scope:housewife_peasant_scope
			}
			# Set up initial relationship between the two characters
			scope:yandere_peasant_scope = {
				add_opinion = {
					target = scope:housewife_peasant_scope
					modifier = angry_opinion
					opinion = -50
				}
			}
			scope:housewife_peasant_scope = {
				add_opinion = {
					target = scope:yandere_peasant_scope
					modifier = angry_opinion
					opinion = -50
				}
			}
		}
	}
	
	#Save the pretty peasant and threaten hag
	option = {
		name = eps_chain.0001.a
		trigger = {
			exists = scope:yandere_peasant_scope
		}
		scope:yandere_peasant_scope = {
			add_to_court_and_entourage_effect = yes
		} 
		stress_impact = {
			lustful = medium_stress_impact_loss
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 10 # The AI should really avoid doing this
			modifier = {
				factor = 0
				has_trait = paranoid
					has_trait = arrogant
					has_trait = callous
					has_trait = sadistic
			}
			modifier = {
				factor = 1
				has_trait = compassionate
				has_trait = lustful
			}
			modifier = {
				factor = 0.75
				has_trait = gallant
			}
		}
	}
	#Compensate the wife
	option = {
		name = eps_chain.0001.b
		trigger = {
			exists = scope:housewife_peasant_scope
		}
		
		pay_short_term_gold = {
			target = scope:housewife_peasant_scope
			gold = minor_gold_value
		}
		
		# scope:housewife_peasant_character_scope = {
		# 	add_to_court_and_entourage_effect = yes
		# }
		stress_impact = {
			greedy = minor_stress_impact_gain
			just = medium_stress_impact_loss
		}
		
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = shy
			}
			modifier = {
				factor = 0
				has_trait = callous
			}
			modifier = {
				factor = 1
				has_trait = just
			}
			modifier = {
				factor = 0.75
				has_trait = gallant
			}
			ai_value_modifier = {
				ai_compassion = 0.25
				ai_rationality = 0.25
			}
		}
	}
	# Help beat the homewrecker to death
	option = {
		name = eps_chain.0001.c
		scope:yandere_peasant_scope = {
			death = {
				death_reason = death_maimed
			}
		}
		stress_impact = {
			base = minor_stress_impact_gain
			sadistic = medium_stress_impact_loss
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			modifier = {
				factor = 2
				OR = {
					has_trait = sadistic
					has_trait = callous
					has_trait = wrathful
					has_trait = paranoid
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = gregarious
					has_trait = forgiving
				}
			}
		}
	}
	# Just walk away
	option = {
		name = eps_chain.0001.d
		scope:yandere_peasant_scope = {
			increase_wounds_no_death_effect = { REASON = fight }
		}
		stress_impact = {
			callous = medium_stress_impact_loss
			compassionate = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 1
				NOR = {
					has_trait = callous
					has_trait = arbitrary
				}
			}
			
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = just
					has_trait = brave
				}
			}
		}
	}
}

# Encounter a drunkard on the road
eps_chain.0008 = { 
	type = character_event
	title = eps_chain.0008.t
	desc = eps_chain.0008.desc
	theme = travel
	left_portrait = {
		character = root 
	   	animation = eyeroll
	}
	right_portrait = {
		character = scope:drunkard_scope
		animation = beg
	}
	
	cooldown = { years = 40 }

	trigger = {
		is_available_travelling = yes
		is_playable_character = yes
		is_location_valid_for_travel_event_on_land = yes
	}
	immediate = {
		create_character = {
			template = drunken_peasant_character
			location = root.location
			culture = root.location.county.culture
			faith = root.location.county.faith
			#Set up the scope
			save_scope_as = drunkard_scope
		}
	}
	#Toss them some coins
	option = {
		name = eps_chain.0008.b
		remove_short_term_gold = tiny_gold_value
		stress_impact = {
			generous = medium_stress_impact_loss
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				short_term_gold < tiny_gold_value
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = greedy
					has_trait = gregarious
				}
			}
			ai_value_modifier = {
				ai_sociability = 1
			}
		}
	}

	#Join us, friend!
	option = {
		name = eps_chain.0008.a
		pay_short_term_gold = {
			target = scope:drunkard_scope
			gold = minor_gold_value
		}
		add_courtier = scope:drunkard_scope
		root.current_travel_plan = {
			add_companion = scope:drunkard_scope
		}
		stress_impact = {   
			paranoid = medium_stress_impact_gain
			gregarious = minor_stress_impact_loss
		}
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				OR = {
					has_trait = paranoid
					has_trait = shy
				}
			}
			modifier = {
				factor = 1
				OR = {
					has_trait = gregarious
					has_trait = compassionate
				}
			}
		}
	}

	# Have them beaten up
	option = {
		name = eps_chain.0008.c
		scope:drunkard_scope = {
			increase_wounds_no_death_effect = { REASON = fight }
		}
		stress_impact = {
			base = medium_stress_impact_gain
			sadistic = medium_stress_impact_loss
			wrathful = minor_stress_impact_loss
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			modifier = {
				factor = 2
				OR = {
					has_trait = sadistic
					has_trait = callous
					has_trait = wrathful
					has_trait = paranoid
				}
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = compassionate
					has_trait = gregarious
					has_trait = forgiving
				}
			}
		}
	}
	
	#Get rid of the drunk if they have not been recruited or killed
	after = {
		if = {
			limit = {
				NOT = {
					scope:drunkard_scope = { is_courtier_of = root }
				}
				scope:drunkard_scope = { is_alive = yes }
			}
			scope:drunkard_scope = {
					silent_disappearance_effect = yes
			}
		}
	}
}
