﻿#######################
# YEARLY EVENTS 9000
#######################
namespace = yearly

# 9100 - Trouble in the Garden
# 9110 - The Flower Thief
# 9120 - The Seed Merchant

################################
# Trouble in the Garden
# by Emil Tisander
################################
yearly.9100 = {
	type = character_event
	title = yearly.9100.t
	desc = yearly.9100.desc
	theme = stewardship
	override_background = {
		reference = garden
	}
	left_portrait = scope:gardener
	
	cooldown = { days = 1825 }
	
	trigger = {
		basic_is_valid_for_yearly_events_trigger = yes
		employs_court_position = court_gardener_court_position
		any_court_position_holder = {
			type = court_gardener_court_position
			is_physically_able_adult = yes
		}
	}
	
	immediate = {
		random_court_position_holder = {
			type = court_gardener_court_position
			limit = { is_physically_able_adult = yes }
			select_local_animal_effect = { TYPE = any } # Save scope to limit possible animals: any/big/small/dangerous/harmless/prowling
			save_scope_as = gardener
		}
	}
	
	option = { # Allow me to help!
		name = yearly.9100.a
		
		progress_towards_friend_effect = { # Always gain progress towards becoming friends.
			CHARACTER = scope:gardener
			OPINION = 20
			REASON = friend_gardening
		}
		if = {
			limit = {
				NOT = { has_trait = lifestyle_gardener }
			}
			random_list = {
				40 = { # You learned something - Chance to gain the Gardener trait.
					desc = yearly.9100.a.tooltip_a
					send_interface_toast = {
						title = yearly.9100.a.success
						left_icon = root
						add_trait = lifestyle_gardener
					}
					
					modifier = {
						factor = 1.5
						has_trait = diligent
					}
					modifier = {
						factor = 1.5
						has_trait = patient
					}
					modifier = {
						factor = 1.2
						has_trait = stubborn
					}
					modifier = {
						factor = 0.5
						has_trait = lazy
					}
					modifier = {
						factor = 0.25
						has_lifestyle_trait = yes
					}
					modifier = {
						factor = 1.2
						has_trait = education_stewardship
					}
					modifier = {
						factor = 1.3
						has_trait = education_learning
					}
				}
				60 = { # You made it worse - What a waste of time!
					desc = yearly.9100.a.tooltip_b
					send_interface_toast = {
						title = yearly.9100.a.failure
						left_icon = root
						add_prestige = medium_prestige_loss
					}
					
					modifier = {
						factor = 1.5
						has_trait = impatient
					}
					modifier = {
						factor = 1.5
						has_trait = fickle
					}
					modifier = {
						factor = 1.5
						has_trait = arrogant
					}
					modifier = {
						factor = 1.25
						has_trait = giant
					}
				}
			}
			stress_impact = {
				shy = medium_stress_impact_gain
				arrogant = medium_stress_impact_gain
				arbitrary = major_stress_impact_gain
				lazy = major_stress_impact_gain
			}
		}
		else = {
			stress_impact = {
				base = major_stress_impact_loss
			}
		}
		
		ai_chance = {
			base = 10
			
			modifier = {
				add = 30
				num_of_relation_friend < 2
			}
			modifier = {
				factor = 0.5
				has_trait = shy
			}
		}
	}
	
	option = { # Here is a little something for you hard work!
		name = yearly.9100.b
		
		pay_short_term_gold = {
			target = scope:gardener
			gold = minor_gold_value
		}
		add_prestige = medium_prestige_gain
		scope:gardener = {
			add_opinion = {
				modifier = grateful_opinion
				target = root
				opinion = 30
			}
		}
		every_courtier_or_guest = {
			limit = {
				this != scope:gardener
			}
			custom = all_courtiers_and_guests
			add_opinion = {
				modifier = reputation_opinion
				target = root
				opinion = 15
			}
		}
		
		stress_impact = {
			arbitrary = medium_stress_impact_gain
			paranoid = medium_stress_impact_gain
			callous = medium_stress_impact_gain
			sadistic = medium_stress_impact_gain
			greedy = major_stress_impact_gain
		}
		
		ai_chance = {
			base = 10
			
			modifier = {
				add = 20
				has_trait = generous
			}
			modifier = {
				factor = 0
				has_trait = greedy
			}
		}
	}
	
	option = { # That is unfortunate. But don't stop on my account!
		name = yearly.9100.c
		
		stress_impact = {
			base = medium_stress_impact_loss
		}
		
		ai_chance = {
			base = 10
			
			modifier = {
				factor = 5
				stress >= medium_stress
			}
		}
	}
	
	after = {
		scope:gardener = {
			remove_variable = animal_type
		}
	}
}

################################
# The Flower Thief
# by Emil Tisander
################################
scripted_trigger flower_thieving_councillor = {
	is_available_ai_adult = yes
	is_married = yes
	any_spouse = {
		this != root
	}
	NOT = { has_court_position = court_gardener_court_position }
}

yearly.9110 = {
	type = character_event
	title = yearly.9110.t
	desc = yearly.9110.desc
	theme = stewardship
	override_background = {
		reference = garden
	}
	left_portrait = {
		character = scope:gardener
		animation = anger
	}
	right_portrait = {
		character = scope:romantic_councillor
		animation = flirtation
	}
	
	cooldown = { days = 1825 }
	
	trigger = {
		basic_is_valid_for_yearly_events_trigger = yes
		is_adult = yes
		employs_court_position = court_gardener_court_position
		any_court_position_holder = {
			type = court_gardener_court_position
			is_physically_able_adult = yes
			OR = {
				is_married = no
				primary_spouse = {
					this != root
				}
			}
		}
		any_councillor = {
			flower_thieving_councillor = yes
		}
	}
	
	immediate = {
		random_court_position_holder = {
			type = court_gardener_court_position
			limit = {
				is_physically_able_adult = yes
				OR = {
					is_married = no
					primary_spouse = {
						this != root
					}
				}
			}
			save_scope_as = gardener
		}
		random_councillor = {
			limit = {
				flower_thieving_councillor = yes
				OR = {
					has_trait = compassionate
					has_trait = gregarious
				}
				NOR = {
					has_trait = sadistic
					has_trait = callous
				}
			}
			alternative_limit = {
				flower_thieving_councillor = yes
				NOR = {
					has_trait = sadistic
					has_trait = callous
				}
			}
			alternative_limit = {
				flower_thieving_councillor = yes
			}
			save_scope_as = romantic_councillor
			random_spouse = {
				limit = {
					this != root
				}
				save_scope_as = councillor_spouse
			}
		}
		if = {
			limit = {
				is_married = yes
			}
			primary_spouse = {
				save_scope_as = spouse
			}
		}
	}
	
	option = { # Side with the gardener.
		name = yearly.9110.a
		
		scope:gardener = {
			add_opinion = {
				modifier = grateful_opinion
				target = root
				opinion = 20
			}
		}
		scope:romantic_councillor = {
			pay_short_term_gold = {
				target = root
				gold = minor_gold_value
			}
			add_opinion = {
				modifier = angry_opinion
				target = root
				opinion = -25
			}
		}
		
		stress_impact = {
			generous = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		
		ai_chance = {
			base = 10
			
			modifier = {
				factor = 5
				has_trait = greedy
			}
			modifier = {
				factor = 2
				has_trait = vengeful
			}
			modifier = {
				factor = 2
				has_trait = lifestyle_gardener
			}
		}
	}
	
	option = { # Side with the councillor.
		name = yearly.9110.b
		
		if = {
			limit = {
				exists = dynasty
			}
			dynasty = {
				add_dynasty_prestige = 35
			}
		}
		scope:gardener = {
			add_opinion = {
				modifier = angry_opinion
				target = root
				opinion = -25
			}
		}
		scope:romantic_councillor = {
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 25
			}
		}
		
		stress_impact = {
			compassionate = medium_stress_impact_gain
			humble = medium_stress_impact_gain
		}
		
		ai_chance = {
			base = 15
			
			modifier = {
				factor = 5
				has_trait = generous
			}
			modifier = {
				factor = 2
				has_trait = forgiving
			}
		}
	}
	
	option = { # Those flowers does make an excellent gift... For MY spouse.
		name = yearly.9110.c
		trigger = {
			exists = scope:spouse
		}
		
		scope:spouse = {
			add_opinion = {
				modifier = romance_opinion
				target = root
				opinion = 20
			}
			if = {
				limit = {
					can_set_relation_soulmate_trigger = { CHARACTER = root }
					has_relation_lover = root
				}
				set_relation_soulmate = { reason = soulmate_gifting_flowers copy_reason = lover target = root }
			}
			else_if = {
				limit = {
					can_set_relation_lover_trigger = { CHARACTER = root }
				}
				progress_towards_lover_effect = {
					CHARACTER = root
					REASON = lover_flower_bouquet
					OPINION = 0
				}
			}
		}
		scope:gardener = {
			add_opinion = {
				modifier = angry_opinion
				target = root
				opinion = -25
			}
		}
		scope:romantic_councillor = {
			add_opinion = {
				modifier = angry_opinion
				target = root
				opinion = -25
			}
		}
		
		stress_impact = {
			content = medium_stress_impact_gain
			just = major_stress_impact_gain
		}
		
		ai_chance = {
			base = 20
			
			modifier = {
				factor = 0
				OR = {
					has_relation_soulmate = scope:spouse
					has_relation_lover = scope:spouse
				}
			}
		}
	}
	
	option = { # I am not getting involved!
		name = yearly.9110.d
		
		scope:gardener = {
			if = {
				limit = {
					NOT = { has_relation_rival = scope:romantic_councillor }
				}
				set_relation_rival = {
					target = scope:romantic_councillor
					reason = rival_romantic_garden
				}
			}
			else = {
				add_opinion = {
					modifier = angry_opinion
					target = scope:romantic_councillor
					opinion = -25
				}
			}
		}
		
		ai_chance = {
			base = 10
			
			modifier = {
				factor = 2
				has_trait = arrogant
			}
			modifier = {
				factor = 2
				has_trait = impatient
			}
		}
	}
}

################################
# The Seed Merchant
# by Emil Tisander
################################
yearly.9120 = {
	type = character_event
	title = yearly.9120.t
	desc = yearly.9120.desc
	theme = stewardship
	override_background = {
		reference = market
	}
	left_portrait = {
		character = scope:seed_merchant
		animation = storyteller
	}
	
	cooldown = { days = 3650 }
	
	trigger = {
		basic_is_valid_for_yearly_events_trigger = yes
		is_landed_or_landless_administrative = yes # Need gardens
		is_adult = yes
		has_trait = lifestyle_gardener

		# Unop: To prevent Error: Undefined event target 'barony_market'
		any_held_title = {
			tier = tier_county
			any_county_province = {
				has_holding = yes
			}
		}
	}
	
	immediate = {
		random_held_title = {
			title_tier = county
			random_county_province = {
				limit = { has_holding = yes }
				save_scope_as = barony_market
			}
		}
		if = {
			limit = {
				any_pool_character = {
					province = scope:barony_market
					is_available_ai_adult = yes
					has_no_particular_noble_roots_trigger = yes
				}
			}
			random_pool_character = {
				province = scope:barony_market
				limit = {
					is_available_ai_adult = yes
					has_no_particular_noble_roots_trigger = yes
				}
				save_scope_as = seed_merchant
			}
		}
		else = {
			create_character = {
				template = pool_repopulate_stewardship #merchant_template
				location = scope:barony_market
				save_scope_as = seed_merchant
			}
		}
		hidden_effect = {
			scope:seed_merchant = {
				if = {
					limit = {
						NOR = {
							has_trait = lifestyle_gardener
							has_trait = lifestyle_herbalist
						}
					}
					random_list = {
						50 = { add_trait = lifestyle_gardener }
						50 = { add_trait = lifestyle_herbalist }
					}
				}
			}
		}
	}
	
	option = { # The poisonous one please... For research, that is.
		name = yearly.9120.a
		
		pay_short_term_gold = {
			target = scope:seed_merchant
			gold = minor_gold_value
		}
		add_character_modifier = {
			modifier = poisonous_plants
			years = 10
		}
		
		stress_impact = {
			trusting = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
		
		ai_chance = {
			base = 10
			
			modifier = {
				factor = 3
				has_trait = deceitful
			}
			modifier = {
				factor = 2
				has_trait = paranoid
			}
			modifier = {
				factor = 2
				has_trait = ambitious
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = trusting
					has_trait = compassionate
				}
			}
		}
	}
	
	option = { # Exotic flowers are sure to make my gardens impressive!
		name = yearly.9120.b
		
		pay_short_term_gold = {
			target = scope:seed_merchant
			gold = minor_gold_value
		}
		add_character_modifier = {
			modifier = impressive_flowers
			years = 10
		}
		
		stress_impact = {
			content = medium_stress_impact_gain
			humble = medium_stress_impact_gain
		}
		
		ai_chance = {
			base = 10
			
			modifier = {
				factor = 2
				has_trait = gregarious
			}
			modifier = {
				factor = 2
				has_trait = diligent
			}
			modifier = {
				factor = 2
				has_trait = arrogant
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = content
					has_trait = humble
				}
			}
		}
	}
	
	option = { # Herbs are always useful, I'll take those.
		name = yearly.9120.c
		
		pay_short_term_gold = {
			target = scope:seed_merchant
			gold = minor_gold_value
		}
		add_character_modifier = {
			modifier = useful_herbs
			years = 10
		}
		
		stress_impact = {
			arrogant = medium_stress_impact_gain
			cynical = medium_stress_impact_gain
		}
		
		ai_chance = {
			base = 10
			
			modifier = {
				factor = 2
				has_trait = lifestyle_herbalist
			}
			modifier = {
				factor = 2
				has_trait = temperate
			}
			modifier = {
				factor = 2
				has_trait = humble
			}
			modifier = {
				factor = 2
				has_trait = content
			}
			modifier = {
				factor = 0
				OR = {
					has_trait = arrogant
					has_trait = cynical
				}
			}
		}
	}
	
	option = { # For these outrageous prices?! Not on your life!
		name = yearly.9120.d
		
		ai_chance = {
			base = 10
			
			modifier = {
				factor = 4
				has_trait = greedy
			}
			modifier = {
				factor = 10
				gold < medium_gold_value
			}
		}
	}
}
