namespace = RR

### Start-up Events

character_event = { # Give Pious Elective succession to those that should have it.
	id = RR.1
	hide_window = yes
	
	only_rulers = yes

	is_triggered_only = yes

	trigger = {
		is_save_game = no
		is_feudal = yes
		is_landed = yes
		primary_title = {
			holder_scope = {
				is_nomadic = no
				OR = {
					independent = yes
					NOT = {
						any_liege = {
							holy_order = yes
						}
					}
				}
				is_merchant_republic = no
				is_patrician = no
				OR = {
					independent = yes
					NOT = {
						any_demesne_title = {
							is_vice_royalty = yes
						}
					}
				}
			}
			rebel = no
			is_primary_type_title = no
			NOT = { holder_scope = { government = confucian_bureaucracy } }
			NOT = { holder_scope = { government = chinese_imperial_government } }
			holder_scope = {
				OR = {
					is_antifeudal_religion_trigger = yes
					#religion = qarmatian
					has_religion_feature = RR_religion_community
				}
			}
		}
	}

	immediate = {
		ROOT = { 
			any_demesne_title = { #First apply law.
				add_law = {
					law = succ_RR_pious_elective
					cooldown = no
					opinion_effect = no
				}
			}
		}
	}
}

character_event = {
	id = RR.2
	hide_window = yes

	only_rulers = yes
	
	is_triggered_only = yes
	
	trigger = {
		is_save_game = no
		is_feudal = yes
		OR = {
			is_antifeudal_religion_trigger = yes
			religion = qarmatian
			has_religion_feature = RR_religion_community
		}
	}
	immediate = {
		ROOT = {
			any_demesne_title = {
				if = {
					limit = { 
						OR = {
							tier = prev
							tier = higher_than_duke
						}
					}
					add_law = succ_RR_pious_elective
					cooldown = no
					opinion_effect = no
				}
			}
			any_vassal = {
				remove_opinion = { modifier = good_succ_law_change who = ROOT }
				remove_opinion = { modifier = bad_succ_law_change who = ROOT }
				remove_opinion = { modifier = succ_law_change who = ROOT }
			}
		}
	}
}


### Doctrine Events

# Joy of Life

character_event = {
	id = RR.100
	desc = EVTDESC_joy
	picture = GFX_evt_feast
	
	is_triggered_only = yes
	
	option = { #party with food and drink
		name = EVTOPT_joy_party
		if = {
			limit = { trait = depressed }
			remove_trait = depressed
		}
		else_if = {
			limit = { trait = stressed }
			remove_trait = stressed
		}
		else = {
			add_character_modifier = {
				name = RR_modifier_joy
				years = 5
			}
		}
		
		if = {
			limit = { trait = temperate }
			random = {
				chance = 15
				remove_trait = temperate
			}
		}
		else_if = {
			limit = { NOT = { trait = gluttonous } }
			random = {
				chance = 15
				add_trait = gluttonous
			}
		}
		else_if = {
			limit = { NOT = { trait = drunkard } }
			random = {
				chance = 15
				add_trait = drunkard
			}
		}
	}
	
	option = { #party with family
		name = EVTOPT_joy_family
		trigger = {
			any_close_relative = {
				same_liege = ROOT
				opinion = { who = ROOT value = 50 }
				reverse_opinion = { who = ROOT value = 50 }
			}
		}
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0.1
				OR = { 
					trait = gluttonous
					trait = drunkard
					trait = hedonist
				}
			}
		}
		any_close_relative = {
			limit = {
				same_liege = ROOT
				opinion = { who = ROOT value = 50 }
				reverse_opinion = { who = ROOT value = 50 }
			}
		}
		if = {
			limit = { trait = depressed }
			remove_trait = depressed
		}
		else_if = {
			limit = { trait = stressed }
			remove_trait = stressed
		}
		else = {
			add_character_modifier = {
				name = RR_modifier_joy_family
				years = 5
			}
		}
	}
	
	option = { #party with friends
		name = EVTOPT_joy_friends
		trigger = {
			any_friend = { same_liege = ROOT }
		}
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0.1
				OR = { 
					trait = gluttonous
					trait = drunkard
					trait = hedonist
				}
			}
		}
		any_friend = { 
			limit = { same_liege = ROOT }
		}
		if = {
			limit = { trait = depressed }
			remove_trait = depressed
		}
		else_if = {
			limit = { trait = stressed }
			remove_trait = stressed
		}
		else = {
			add_character_modifier = {
				name = RR_modifier_joy_friends
				years = 5
			}
		}
	}
}


# Truth

# Truth master event, triggers other events.
character_event = {
	id = RR.200
	hide_window = yes

	#only_rulers = yes
	
	is_triggered_only = yes

	trigger = {
		has_ambition = obj_RR_truth # We trust that if a character has the ambition, all other conditions have been met first.
	}
	
	immediate = { #Pick the appropriate event.
		if = {
			limit = { 
				NOT = { trait = honest }
			}
			character_event = { id = RR.210 random = 30 } # Trigger event that either removes Deceitful or adds Honest.
		}
		else_if = {
			limit = { 
				NOT = { trait = just }
			}
			character_event = { id = RR.220 random = 30 } # Trigger event that either removes Arbitrary or adds Just.
		}
		else_if = {
			limit = { 
				NOT = { trait = diligent }
			}
			character_event = { id = RR.230 random = 30 } # Trigger event that either removes Slothful or adds Diligent.
		}
	}
}

#Honesty event
character_event = {
	id = RR.210
	desc = EVTDESC_RR_truth_honest
	picture = GFX_evt_open_book_hf

	#only_rulers = yes
	
	is_triggered_only = yes

	trigger = {
		has_ambition = obj_RR_truth # We trust that if a character has the ambition, all other conditions have been met first.
		NOT = { trait = honest }
	}
	
	option = { # Become more honest.
		name = EVTOPT_RR_truth_honest
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0.5
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = zealous
			}
		}
		if = {
			limit = { trait = deceitful }
			remove_trait = deceitful
		}
		else = {
			add_trait = honest
		}
	}	
	
	option = { # To hell with honesty.
		name = EVTOPT_RR_truth_reject
		prestige = 25
		piety = -25
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				trait = cynical
			}
			modifier = {
				factor = 0.5
				trait = zealous
			}
		}
	}	
}

#Justice event
character_event = {
	id = RR.220
	desc = EVTDESC_RR_truth_just
	picture = GFX_evt_elder_council

	#only_rulers = yes
	
	is_triggered_only = yes

	trigger = {
		has_ambition = obj_RR_truth # We trust that if a character has the ambition, all other conditions have been met first.
		NOT = { trait = just }
	}
	
	option = { # Become more just.
		name = EVTOPT_RR_truth_just
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0.5
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = zealous
			}
		}
		if = {
			limit = { trait = arbitrary }
			remove_trait = arbitrary
		}
		else = {
			add_trait = just
		}
	}	
	
	option = { # To hell with justice.
		name = EVTOPT_RR_truth_reject
		prestige = 25
		piety = -25
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				trait = cynical
			}
			modifier = {
				factor = 0.5
				trait = zealous
			}
		}
	}	
}

#Diligence event
character_event = {
	id = RR.230
	desc = EVTDESC_RR_truth_diligent
	picture = GFX_evt_religious_exultation

	#only_rulers = yes
	
	is_triggered_only = yes

	trigger = {
		has_ambition = obj_RR_truth # We trust that if a character has the ambition, all other conditions have been met first.
		NOT = { trait = diligent }
	}
	
	option = { # Become more diligent.
		name = EVTOPT_RR_truth_diligent
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0.5
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = zealous
			}
		}
		if = {
			limit = { trait = slothful }
			remove_trait = slothful
		}
		else = {
			add_trait = diligent
		}
	}	
	
	option = { # To hell with diligence.
		name = EVTOPT_RR_truth_reject
		prestige = 25
		piety = -25
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				trait = cynical
			}
			modifier = {
				factor = 0.5
				trait = zealous
			}
		}
	}	
}

# Free Love

#Wife reveals spouse isn't real father
character_event = {
	id = RR.300
	desc = EVTDESC_RR_real_father
	picture = GFX_evt_open_book_hf
	
	is_triggered_only = yes
	
	option = {
		name = OK
	}
}

character_event = {
	id = RR.310
	
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		if = {
			limit = { 
				free_love = yes
				NOR = {
					trait = lustful
					trait = chaste
					trait = cynical
				}
			}
			character_event = { id = 38272 } # become lustful
		}
	}
}

character_event = {
	id = RR.320
	
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		if = {
			limit = { 
				free_love = yes
				trait = chaste
				NOT = {
					trait = cynical
				}
			}
			random_list = {
				60 = { character_event = { id = 38258 } } # become cynical
				30 = { character_event = { id = 38303 } } # lose chaste
				10 = { character_event = { id = 38272 } } # become lustful
			}
		}
	}
}


# Sacred Lies

# Sacred lies master event, triggers other events.
character_event = {
	id = RR.500
	hide_window = yes

	#only_rulers = yes
	
	is_triggered_only = yes

	trigger = {
		has_ambition = obj_RR_lies # We trust that if a character has the ambition, all other conditions have been met first.
	}
	
	immediate = { #Pick the appropriate event.
		if = {
			limit = { 
				NOT = { trait = deceitful }
			}
			character_event = { id = RR.510 random = 30 } # Trigger event that either removes Honest or adds Deceitful.
		}
		else_if = {
			limit = { 
				NOT = { trait = groomed }
			}
			character_event = { id = RR.520 random = 30 } # Trigger event that either removes Uncouth or adds Groomed.
		}
		else_if = {
			limit = { 
				NOT = { trait = shrewd }
			}
			random = {
				chance = 30 # Shrewd is a strong trait. Delay this a little.
				character_event = { id = RR.530 random = 30 } # Trigger event that either removes Dull or adds Shrewd.
			}
		}
	}
}

#Deceitful event
character_event = {
	id = RR.510
	desc = EVTDESC_RR_lies_deceitful
	picture = GFX_evt_whispers

	#only_rulers = yes
	
	is_triggered_only = yes

	trigger = {
		has_ambition = obj_RR_lies # We trust that if a character has the ambition, all other conditions have been met first.
		NOT = { trait = deceitful }
	}
	
	option = { # Become more deceitful.
		name = EVTOPT_RR_lies_deceitful
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0.5
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = zealous
			}
		}
		if = {
			limit = { trait = honest }
			remove_trait = honest
		}
		else = {
			add_trait = deceitful
		}
	}	
	
	option = { # It's just religious nonse.
		name = EVTOPT_RR_truth_reject
		prestige = 25
		piety = -25
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				trait = cynical
			}
			modifier = {
				factor = 0.5
				trait = zealous
			}
		}
	}	
}

#Groomed event
character_event = {
	id = RR.520
	desc = EVTDESC_RR_lies_groomed
	picture = GFX_evt_homage_hf

	#only_rulers = yes
	
	is_triggered_only = yes

	trigger = {
		has_ambition = obj_RR_lies # We trust that if a character has the ambition, all other conditions have been met first.
		NOT = { trait = groomed }
	}
	
	option = { # Become more groomed.
		name = EVTOPT_RR_lies_groomed
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0.5
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = zealous
			}
		}
		if = {
			limit = { trait = uncouth }
			remove_trait = uncouth
		}
		else = {
			add_trait = groomed
		}
	}	
	
	option = { # It's just religious nonse.
		name = EVTOPT_RR_truth_reject
		prestige = 25
		piety = -25
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				trait = cynical
			}
			modifier = {
				factor = 0.5
				trait = zealous
			}
		}
	}	
}

#Shrewd event
character_event = {
	id = RR.530
	desc = EVTDESC_RR_lies_shrewd
	picture = GFX_evt_princess_byzantine

	#only_rulers = yes
	
	is_triggered_only = yes

	trigger = {
		has_ambition = obj_RR_lies # We trust that if a character has the ambition, all other conditions have been met first.
		NOT = { trait = shrewd }
	}
	
	option = { # Become more shrewd.
		name = EVTOPT_RR_lies_shrewd
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0.5
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = zealous
			}
		}
		if = {
			limit = { trait = dull }
			remove_trait = dull
		}
		else = {
			add_trait = shrewd
		}
	}	
	
	option = { # It's just religious nonse.
		name = EVTOPT_RR_truth_reject
		prestige = 25
		piety = -25
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = slothful
			}
			modifier = {
				factor = 0.5
				trait = zealous
			}
			modifier = {
				factor = 0.5
				trait = diligent
			}
		}
	}	
}

# eugenics

character_event = { # Make eugenics more reliable.
	id = RR.600
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		has_holy_incest_trigger = yes
		}
	}

	immediate = {
		# genius parents
		if = {
			limit = { 
				NOT = { trait = genius }
				mother_even_if_dead = { trait = genius }
				true_father_even_if_dead = { trait = genius }
			}
			if = {
				limit = { trait = slow }			
				remove_trait = slow
				#add_trait = sickly
			}
			if = {
				limit = { trait = imbecile }			
				remove_trait = imbecile
				#add_trait = sickly
			}
			random = {
				chance = 50
				add_trait = genius
				#add_trait = sickly
			}
		}
		# quick parents
		if = {
			limit = { 
				NOR = {
					trait = genius
					trait = quick
				}
				NOT = {
					mother_even_if_dead = { trait = genius }
					true_father_even_if_dead = { trait = genius }
				}
				OR = {
					mother_even_if_dead = { trait = quick }
					mother_even_if_dead = { trait = genius }
				}
				OR = {
					true_father_even_if_dead = { trait = quick }
					true_father_even_if_dead = { trait = genius }
				}
			}
			if = {
				limit = { trait = slow }			
				remove_trait = slow
				#add_trait = sickly
			}
			if = {
				limit = { trait = imbecile }			
				remove_trait = imbecile
				#add_trait = sickly
			}
			random = {
				chance = 50
				add_trait = quick
				#add_trait = sickly
			}
		}
		# attractive parents
		if = {
			limit = { 
				NOT = { trait = fair }
				mother_even_if_dead = { trait = fair }
				true_father_even_if_dead = { trait = fair }
			}
			if = {
				limit = { trait = ugly }			
				remove_trait = ugly
				#add_trait = sickly
			}
			random = {
				chance = 50
				add_trait = fair
				#add_trait = sickly
			}
		}
		# strong parents
		if = {
			limit = { 
				NOT = { trait = strong }
				mother_even_if_dead = { trait = strong }
				true_father_even_if_dead = { trait = strong }
			}
			if = {
				limit = { trait = weak }			
				remove_trait = weak
				#add_trait = sickly
			}
			random = {
				chance = 50
				add_trait = strong
				#add_trait = sickly
			}
		}
	}
}


character_event = { # Make incest managable.
	id = RR.700
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		has_holy_incest_trigger = yes
	}

	immediate = {
		if = {
			limit = { trait = inbred }
			remove_trait = inbred
			if = {
				limit = {
					NOR = {
						trait = genius
						trait = quick
						trait = slow
					}
				}
				add_trait = slow
			}
			if = {
				limit = {
					NOT = {
						trait = strong
					}
				}
				add_trait = weak
			}
			if = {
				limit = {
					NOT = {
						trait = fair
					}
				}
				add_trait = ugly
			}
		}
	}
}













