namespace = court_astrologer_events

#Triggered by the "Consult the Skies" decision
court_astrologer_events.0001 = {	
	type = character_event
	title = court_astrologer_events.0001.t
	desc = court_astrologer_events.0001.desc
	theme = faith
	override_effect_2d = {
		reference = legend_glow
	}
	left_portrait = {
		character = root
		triggered_animation = { 
			trigger = {
				has_trait = zealous
			}
			animation = beg
		}
		triggered_animation = { 
			trigger = {
				OR = {
					has_trait = craven
					has_trait = paranoid
				}
			}
			animation = worry
		}
		triggered_animation = { 
			trigger = {
				OR = {
					has_trait = cynical
					has_trait = arrogant
				}
			}
			animation = boredom
		}
		animation = prayer
	}
	right_portrait = {
		character = scope:astrologer
		animation = holding_staff
	}
	
	immediate = {
		random_courtier = {
			limit = { has_court_position = court_astrologer_court_position }
			save_scope_as = astrologer
		}
	}
	
	option = { # Tell me about my love life
		name = court_astrologer_events.0001.a
		random_list = {
			50 = {
				desc = court_astrologer_events.0001.a.success
				send_interface_toast = {
					title = court_astrologer_events.0001.a.success
					left_icon = root
					custom_tooltip = court_astrologer_events.0001.a.success.tt
					if = {
						limit = {
							culture ?= { has_cultural_pillar = ethos_spiritual }
						}
						add_character_modifier = {
							modifier = mpo_divination_love_spiritual_modifier
							years = 5
						}
					}
					else = {
						add_character_modifier = {
							modifier = mpo_divination_love_modifier
							years = 5
						}
					}				
				}
			}
			50 = {
				desc = court_astrologer_events.0001.a.failure
				send_interface_toast = {
					title = court_astrologer_events.0001.a.failure
					left_icon = root
					add_stress = minor_stress_loss
				}
			}
		}
		stress_impact = {
			paranoid = miniscule_stress_impact_gain
			cynical = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
	
	option = { # Tell me about war
		name = court_astrologer_events.0001.b
		random_list = {
			50 = {
				desc = court_astrologer_events.0001.b.success
				send_interface_toast = {
					title = court_astrologer_events.0001.b.success
					left_icon = root
					if = {
						limit = {
							culture ?= { has_cultural_pillar = ethos_spiritual }
						}
						add_character_modifier = {
							modifier = mpo_divination_war_spiritual_modifier
							years = 5
						}
					}
					else = {
						add_character_modifier = {
							modifier = mpo_divination_war_modifier
							years = 5
						}
					}
				}
			}
			50 = {
				desc = court_astrologer_events.0001.a.failure
				send_interface_toast = {
					title = court_astrologer_events.0001.a.failure
					left_icon = root
					add_stress = minor_stress_loss
				}
			}
		}
		stress_impact = {
			paranoid = miniscule_stress_impact_gain
			cynical = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
	
	option = { # Just tell me about life
		name = court_astrologer_events.0001.c
		random_list = {
			50 = {
				desc = court_astrologer_events.0001.c.success
				send_interface_toast = {
					title = court_astrologer_events.0001.c.success
					left_icon = root
					if = {
						limit = {
							culture ?= { has_cultural_pillar = ethos_spiritual }
						}
						add_character_modifier = {
							modifier = mpo_divination_life_spiritual_modifier
							years = 5
						}
					}
					else = {
						add_character_modifier = {
							modifier = mpo_divination_life_modifier
							years = 5
						}
					}
				}
			}
			50 = {
				desc = court_astrologer_events.0001.a.failure
				send_interface_toast = {
					title = court_astrologer_events.0001.a.failure
					left_icon = root
					add_stress = minor_stress_loss
				}
			}
		}
		stress_impact = {
			paranoid = miniscule_stress_impact_gain
			cynical = miniscule_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
	
	option = { # Actually, not right now
		name = court_astrologer_events.0001.d
		remove_decision_cooldown = mpo_divination_decision
		ai_chance = {
			base = 0
		}
	}
}

# Migration Suggestion
scripted_trigger court_astrologer_events_0002_neighbour_trigger = {
	government_has_flag = government_is_nomadic
	current_domain_fertility >= root.current_domain_fertility
	is_independent_ruler = yes
}

court_astrologer_events.0002 = {	
	type = character_event
	title = court_astrologer_events.0002.t
	desc = {
		desc = court_astrologer_events.0002.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					location.county.county_fertility <= bad_county_fertility_level
				}
				desc = court_astrologer_events.0002.desc.bad
			}
			desc = court_astrologer_events.0002.desc.meh
		}
		desc = court_astrologer_events.0002.desc.outro
	}
	theme = nomads
	override_background = { reference = mpo_steppe_evening }
	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = scope:astrologer
		animation = holding_staff
	}
	lower_center_portrait = scope:target_realm_owner
	cooldown = { years = 5 }
	
	trigger = {
		has_mpo_dlc_trigger = yes
		government_has_flag = government_is_nomadic
		is_available = yes
		employs_court_position = court_astrologer_court_position
		court_position:court_astrologer_court_position = { is_available = yes }
		any_neighboring_realm_same_rank_owner = {
			court_astrologer_events_0002_neighbour_trigger = yes
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			current_domain_fertility <= bad_county_fertility_level
			factor = 2
		}
	}
	
	immediate = {
		court_position:court_astrologer_court_position = {
			save_scope_as = astrologer
			get_quirk_character_effect = yes
		}
		ordered_neighboring_realm_same_rank_owner = {
			limit = {
				court_astrologer_events_0002_neighbour_trigger = yes
			}
			order_by = current_domain_fertility
			save_scope_as = target_realm_owner
			primary_title = { save_scope_as = target_realm }
		}
	}
	
	option = { # Sounds like a great idea
		name = court_astrologer_events.0002.a
		custom_tooltip = court_astrologer_events.0002.a.tt
		set_variable = {
			name = astrologer_desired_area
			value = scope:target_realm
			years = 5
		}
		stress_impact = {
			paranoid = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
	
	option = { # Thank you for your feedback
		name = court_astrologer_events.0002.b
		scope:astrologer = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = 20
			}
		}
		stress_impact = {
			paranoid = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
	
	option = { # I'm good
		name = court_astrologer_events.0002.c
		add_prestige = minor_prestige_gain
		stress_impact = {
			paranoid = medium_stress_impact_gain
			gregarious = medium_stress_impact_gain
		}
		ai_chance = {
			base = 100
		}
	}
}
