# -*- ck2.scripted_effects -*-

###TRAIT ADDING EFFECTS###
#Add new ones in alphabetical order.

#With notification
add_trait_ambitious_effect = {
	if = {
		limit = {
			NOR = {
				trait = ambitious
				trait = content
			}
		}
		add_trait = ambitious
		hidden_tooltip = { character_event = { id = 38278 } }
	}
}

add_trait_arbitrary_effect = {
	if = {
		limit = {
			NOR = {
				trait = arbitrary
				trait = just
			}
		}
		add_trait = arbitrary
		hidden_tooltip = { character_event = { id = 38266 } }
	}
}

add_trait_brave_effect  = {
	if = {
		limit = {
			NOR = {
				trait = brave
				trait = craven
			}
		}
		add_trait = brave
		hidden_tooltip = { character_event = { id = 38270 } }
	}
}


add_trait_charitable_effect = {
	if = {
		limit = {
			NOR = {
				trait = charitable
				trait = greedy
			}
		}
		add_trait = charitable
		hidden_tooltip = { character_event = { id = 38273 } } # Notify Charitable
	}
}

add_trait_chaste_effect = {
	if = {
		limit = {
			NOR = {
				trait = chaste
				trait = lustful
			}
		}
		add_trait = chaste
		hidden_tooltip = { character_event = { id = 38274 } }
	}
}

add_trait_craven_effect  = {
	if = {
		limit = {
			NOR = {
				trait = brave
				trait = craven
			}
		}
		add_trait = craven
		hidden_tooltip = { character_event = { id = 38257 } }
	}
}

add_trait_cruel_effect  = {
	if = {
		limit = {
			NOR = {
				trait = cruel
				trait = kind
			}
		}
		add_trait = cruel
		hidden_tooltip = { character_event = { id = 38259 } }
	}
}

add_trait_cynical_effect = {
	if = {
		limit = {
			NOR = {
				trait = cynical
				trait = zealous
			}
		}
		add_trait = cynical
		hidden_tooltip = { character_event = { id = 38258 } } #notify cynical
	}
}

add_trait_deceitful_effect = {
	if = {
		limit = {
			NOR = {
				trait = deceitful
				trait = honest
			}
		}
		add_trait = deceitful
		hidden_tooltip = { character_event = { id = 38255 } }
	}
}

add_trait_depressed_effect = {
	if = {
		limit = { NOT = { trait = depressed } }
		add_trait = depressed
		hidden_tooltip = { character_event = { id = 38288 } }
	}
}

add_trait_diligent_effect = {
	if = {
		limit = {
			NOR = {
				trait = diligent
				trait = slothful
			}
		}
		add_trait = diligent
		hidden_tooltip = { character_event = { id = 38256 } } #notify diligent
	}
}

add_trait_envious_effect = {
	if = {
		limit = {
			NOR = {
				trait = kind
				trait = envious
			}
		}
		add_trait = envious
		hidden_tooltip = { character_event = { id = 38271 } }
	}
}

add_trait_gluttonous_effect = {
	if = {
		limit = {
			NOR = {
				trait = temperate
				trait = gluttonous
			}
		}
		add_trait = gluttonous
		hidden_tooltip = { character_event = { id = 38277 } } #Notify Gluttonous
	}
}

add_trait_greedy_effect = {
	if = {
		limit = {
			NOR = {
				trait = greedy
				trait = charitable
			}
		}
		add_trait = greedy
		hidden_tooltip = { character_event = { id = 38252 } }
	}
}

add_trait_gregarious_effect = {
	if = {
		limit = {
			NOR = {
				trait = gregarious
				trait = shy
			}
		}
		add_trait = gregarious
		hidden_tooltip = { character_event = { id = 38265 } }
	}
}

add_trait_honest_effect = {
	if = {
		limit = {
			NOR = {
				trait = honest
				trait = deceitful
			}
		}
		add_trait = honest
		hidden_tooltip = { character_event = { id = 38262 } } #Notify Honest
	}
}
add_trait_humble_effect = {
	if = {
		limit = {
			NOR = {
				trait = humble
				trait = proud
			}
		}
		add_trait = humble
		hidden_tooltip = { character_event = { id = 38260 } } #Notify Humble
	}
}

add_trait_kind_effect = {
	if = {
		limit = {
			NOR = {
				trait = kind
				trait = envious
				trait = cruel
			}
		}
		add_trait = kind
		hidden_tooltip = { character_event = { id = 38268 } }
	}
}

add_trait_lustful_effect = {
	if = {
		limit = {
			NOR = {
				trait = lustful
				trait = chaste
			}
		}
		add_trait = lustful
		hidden_tooltip = { character_event = { id = 38272 } }
	}
}

add_trait_one_eyed_effect = {
	if = {
		limit = {
			NOR = {
				trait = one_eyed
				trait = blinded
			}
		}
		add_trait = one_eyed
		hidden_tooltip = { character_event = { id = RIP.11501 } }
		add_trait_severely_injured_effect = yes

	}
}

add_trait_one_handed_effect = {
	if = {
		limit = { NOT = { trait = one_handed } }
		add_trait = one_handed
		hidden_tooltip = { character_event = { id = RIP.11502 } }
		add_trait_severely_injured_effect = yes
	}
}

add_trait_paranoid_effect = {
	if = {
		limit = {
			NOR = {
				trait = trusting
				trait = paranoid
			}
		}
		add_trait = paranoid
		hidden_tooltip = { character_event = { id = 38275 } } #Notify Paranoid
	}
}

add_trait_patient_effect = {
	if = {
		limit = {
			NOR = {
				trait = patient
				trait = wroth
			}
		}
		add_trait = patient
		hidden_tooltip = { character_event = { id = 38264 } } # Notify Patient
	}
}

add_trait_possessed_effect = {
	if = {
		limit = {
			NOT = {
				trait = possessed
			}
		}
		add_trait = possessed
		hidden_tooltip = { character_event = { id = 38315 } } # Notify Possessed
	}
}

add_trait_proud_effect = {
	if = {
		limit = {
			NOR = {
				trait = proud
				trait = humble
			}
		}
		add_trait = proud
		hidden_tooltip = { character_event = { id = 38261 } } # Notify Proud
	}
}

add_trait_severely_injured_effect = {
	if = {
		limit = { NOT = { trait = severely_injured } }
		add_trait = severely_injured

		hidden_tooltip = {
			random_list = {
				75 = { #Get rid of severely_injured
					character_event = { id = RIP.11000 days = 90 random = 275}
				}
				25 = { #Get rid of severely_injured but develop infection
					set_character_flag = pending_infection
					character_event = { id = RIP.11000 days = 90 random = 275}
				}
			}
		}
	}
}

add_trait_shy_effect = {
	if = {
		limit = {
			NOR = {
				trait = gregarious
				trait = shy
			}
		}
		add_trait = shy
		hidden_tooltip = { character_event = { id = 38295 } }
	}
}

add_trait_slothful_effect = {
	if = {
		limit = {
			NOR = {
				trait = diligent
				trait = slothful
			}
		}
		add_trait = slothful
		hidden_tooltip = { character_event = { id = 38251 } } #notify slothful
	}
}

add_trait_stressed_effect = {
	if = {
		limit = {
			NOR = {
				trait = stressed
			}
		}
		add_trait = stressed
		hidden_tooltip = { character_event = { id = 38282 } } #notify stressed
	}
}

add_trait_temperate_effect = {
	if = {
		limit = {
			NOR = {
				trait = temperate
				trait = gluttonous
			}
		}
		add_trait = temperate
		hidden_tooltip = { character_event = { id = 38276 } } #Notify Temperate
	}
}

add_trait_trusting_effect = {
	if = {
		limit = {
			NOR = {
				trait = trusting
				trait = paranoid
			}
		}
		add_trait = trusting
		hidden_tooltip = { character_event = { id = 38250 } } #Notify Trusting
	}
}

add_trait_wounded_effect = {
	if = {
		limit = { NOT = { trait = wounded } }
		add_trait = wounded
		hidden_tooltip = { character_event = { id = 38280 } }
	}
}

add_trait_wroth_effect = {
	if = {
		limit = {
			NOR = {
				trait = wroth
				trait = patient
			}
		}
		add_trait = wroth
		hidden_tooltip = { character_event = { id = 38254 } }
	}
}

add_trait_zealous_effect = {
	if = {
		limit = {
			NOR = {
				trait = cynical
				trait = zealous
			}
		}
		add_trait = zealous
		hidden_tooltip = { character_event = { id = 38269 } }
	}
}

#Without notification
add_trait_silently_ambitious_effect = {
	if = {
		limit = {
			NOR = {
				trait = ambitious
				trait = content
			}
		}
		add_trait = ambitious
	}
}

add_trait_silently_arbitrary_effect = {
	if = {
		limit = {
			NOR = {
				trait = arbitrary
				trait = just
			}
		}
		add_trait = arbitrary
	}
}

add_trait_silently_brave_effect  = {
	if = {
		limit = {
			NOR = {
				trait = brave
				trait = craven
			}
		}
		add_trait = brave
	}
}


add_trait_silently_charitable_effect = {
	if = {
		limit = {
			NOR = {
				trait = charitable
				trait = greedy
			}
		}
		add_trait = charitable
	}
}

add_trait_silently_chaste_effect = {
	if = {
		limit = {
			NOR = {
				trait = chaste
				trait = lustful
			}
		}
		add_trait = chaste
	}
}

add_trait_silently_craven_effect  = {
	if = {
		limit = {
			NOR = {
				trait = brave
				trait = craven
			}
		}
		add_trait = craven
	}
}

add_trait_silently_cruel_effect  = {
	if = {
		limit = {
			NOR = {
				trait = cruel
				trait = kind
			}
		}
		add_trait = cruel
	}
}

add_trait_silently_cynical_effect = {
	if = {
		limit = {
			NOR = {
				trait = cynical
				trait = zealous
			}
		}
		add_trait = cynical
	}
}

add_trait_silently_content_effect = {
	if = {
		limit = {
			NOR = {
				trait = content
				trait = ambitious
			}
		}
		add_trait = content
	}
}

add_trait_silently_deceitful_effect = {
	if = {
		limit = {
			NOR = {
				trait = deceitful
				trait = honest
			}
		}
		add_trait = deceitful
	}
}

add_trait_silently_depressed_effect = {
	if = {
		limit = { NOT = { trait = depressed } }
		add_trait = depressed
	}
}

add_trait_silently_diligent_effect = {
	if = {
		limit = {
			NOR = {
				trait = diligent
				trait = slothful
			}
		}
		add_trait = diligent
	}
}

add_trait_silently_envious_effect = {
	if = {
		limit = {
			NOR = {
				trait = kind
				trait = envious
			}
		}
		add_trait = envious

	}
}

add_trait_silently_gluttonous_effect = {
	if = {
		limit = {
			NOR = {
				trait = temperate
				trait = gluttonous
			}
		}
		add_trait = gluttonous
	}
}

add_trait_silently_greedy_effect = {
	if = {
		limit = {
			NOR = {
				trait = greedy
				trait = charitable
			}
		}
		add_trait = greedy
	}
}

add_trait_silently_gregarious_effect = {
	if = {
		limit = {
			NOR = {
				trait = gregarious
				trait = shy
			}
		}
		add_trait = gregarious
	}
}

add_trait_silently_honest_effect = {
	if = {
		limit = {
			NOR = {
				trait = honest
				trait = deceitful
			}
		}
		add_trait = honest
	}
}

add_trait_silently_humble_effect = {
	if = {
		limit = {
			NOR = {
				trait = humble
				trait = proud
			}
		}
		add_trait = humble
	}
}

add_trait_silently_kind_effect = {
	if = {
		limit = {
			NOR = {
				trait = kind
				trait = envious
				trait = cruel
			}
		}
		add_trait = kind

	}
}

add_trait_silently_lustful_effect = {
	if = {
		limit = {
			NOR = {
				trait = lustful
				trait = chaste
			}
		}
		add_trait = lustful
	}
}

add_trait_silently_one_eyed_effect = {
	if = {
		limit = {
			NOR = {
				trait = one_eyed
				trait = blinded
			}
		}
		add_trait = one_eyed

		add_trait_silently_severely_injured_effect = yes

	}
}

add_trait_silently_one_handed_effect = {
	if = {
		limit = { NOT = { trait = one_handed } }
		add_trait = one_handed

		add_trait_silently_severely_injured_effect = yes
	}
}

add_trait_silently_patient_effect = {
	if = {
		limit = {
			NOR = {
				trait = patient
				trait = wroth
			}
		}
		add_trait = patient
	}
}

add_trait_silently_possessed_effect = {
	if = {
		limit = {
			NOT = {
				trait = possessed
			}
		}
		add_trait = possessed
	}
}

add_trait_silently_proud_effect = {
	if = {
		limit = {
			NOR = {
				trait = proud
				trait = humble
			}
		}
		add_trait = proud
	}
}

add_trait_silently_severely_injured_effect = {
	if = {
		limit = { NOT = { trait = severely_injured } }
		add_trait = severely_injured

		hidden_tooltip = {
			random_list = {
				75 = { #Get rid of severely_injured
					character_event = { id = RIP.11000 days = 90 random = 275}
				}
				25 = { #Get rid of severely_injured but develop infection
					set_character_flag = pending_infection
					character_event = { id = RIP.11000 days = 90 random = 275}
				}
			}
		}
	}
}

add_trait_silently_shy_effect = {
	if = {
		limit = {
			NOR = {
				trait = gregarious
				trait = shy
			}
		}
		add_trait = shy
	}
}

add_trait_silently_slothful_effect = {
	if = {
		limit = {
			NOR = {
				trait = diligent
				trait = slothful
			}
		}
		add_trait = slothful
	}
}

add_trait_silently_temperate_effect = {
	if = {
		limit = {
			NOR = {
				trait = temperate
				trait = gluttonous
			}
		}
		add_trait = temperate
	}
}

add_trait_silently_wounded_effect = {
	if = {
		limit = { NOT = { trait = wounded } }
		add_trait = wounded
	}
}

add_trait_silently_wroth_effect = {
	if = {
		limit = {
			NOR = {
				trait = wroth
				trait = patient
			}
		}
		add_trait = wroth
	}
}

#TRAIT REMOVAL EFFECTS
#Add new ones in alphabetical order.

#Add with notification

remove_trait_brave_effect = {
	if = {
		limit = { trait = brave }
		remove_trait = brave
		hidden_tooltip = { character_event = { id = 38320 } }
	}
}
remove_trait_charitable_effect = {
	if = {
		limit = { trait = charitable }
		remove_trait = charitable
		hidden_tooltip = { character_event = { id = 38321 } }
	}
}

remove_trait_chaste_effect = {
	if = {
		limit = { trait = chaste }
		remove_trait = chaste
		hidden_tooltip = { character_event = {	id = 38303 } } #Notify Removed Chaste
	}
}

remove_trait_content_effect = {
	if = {
		limit = { trait = content }
		remove_trait = content
		hidden_tooltip = { character_event = {	id = 38299 } }
	}
}

remove_trait_craven_effect = {
	if = {
		limit = { trait = craven }
		remove_trait = craven
		hidden_tooltip = { character_event = { id = 38296 } }
	}
}

remove_trait_cruel_effect = {
	if = {
		limit = { trait = cruel }
		remove_trait = cruel
	}
}

remove_trait_depressed_effect = {
	if = {
		limit = { trait = depressed }
		remove_trait = depressed
		hidden_tooltip = { character_event = { id = 38314 } }
	}
}

remove_trait_diligent_effect = {
	if = {
		limit = { trait = diligent }
		remove_trait = diligent
		hidden_tooltip = { character_event = { id = 38319 } }
	}
}

remove_trait_envious_effect = {
	if = {
		limit = { trait = envious }
		remove_trait = envious
	}
}

remove_trait_greedy_effect = {
	if = {
		limit = { trait = greedy }
		remove_trait = greedy
		hidden_tooltip = { character_event = { id = 38322 } }
	}
}

remove_trait_gregarious_effect = {
	if = {
		limit = { trait = gregarious }
		remove_trait = gregarious
		hidden_tooltip = { character_event = { id = 38297 } }
	}
}

remove_trait_honest_effect = {
	if = {
		limit = { trait = honest }
		remove_trait = honest
		hidden_tooltip = { character_event = { id = 38311 } }
	}
}

remove_trait_humble_effect = {
	if = {
		limit = { trait = humble }
		remove_trait = humble
	}
}

remove_trait_just_effect = {
	if = {
		limit = { trait = just }
		remove_trait = just
		hidden_tooltip = { character_event = { id = 38317 } }
	}
}

remove_trait_kind_effect = {
	if = {
		limit = { trait = kind }
		remove_trait = kind
		hidden_tooltip = { character_event = { id = 38307 } }
	}
}

remove_trait_patient_effect = {
	if = {
		limit = { trait = patient }
		remove_trait = patient
	}
}

remove_trait_proud_effect = {
	if = {
		limit = { trait = proud }
		remove_trait = proud
	}
}

remove_trait_shy_effect = {
	if = {
		limit = { trait = shy }
		remove_trait = shy
		hidden_tooltip = { character_event = { id = 38295 } }
	}
}

remove_trait_slothful_effect = {
	if = {
		limit = { trait = slothful }
		remove_trait = slothful
		hidden_tooltip = {
			character_event = {
				id = 38298 #Notify Remove Slothful
			}
		}
	}
}

remove_trait_temperate_effect = {
	if = {
		limit = { trait = temperate }
		remove_trait = temperate
		hidden_tooltip = { character_event = { id = 38311 } }
	}
}

remove_trait_trusting_effect = {
	if = {
		limit = { trait = trusting }
		remove_trait = trusting
	}
}

remove_trait_wroth_effect = {
	if = {
		limit = { trait = wroth }
		remove_trait = wroth
	}
}

remove_trait_zealous_effect = {
	if = {
		limit = { trait = zealous }
		remove_trait = zealous
		hidden_tooltip = { character_event = { id = 38310 } }
	}
}

#Silently
remove_trait_silently_ambitious_effect = {
	if = {
		limit = { trait = ambitious }
		remove_trait = ambitious
	}
}
remove_trait_silently_brave_effect = {
	if = {
		limit = { trait = brave }
		remove_trait = brave
	}
}
remove_trait_silently_charitable_effect = {
	if = {
		limit = { trait = charitable }
		remove_trait = charitable
	}
}

remove_trait_silently_chaste_effect = {
	if = {
		limit = { trait = chaste }
		remove_trait = chaste
	}
}

remove_trait_silently_content_effect = {
	if = {
		limit = { trait = content }
		remove_trait = content
	}
}

remove_trait_silently_craven_effect = {
	if = {
		limit = { trait = craven }
		remove_trait = craven
	}
}

remove_trait_silently_cruel_effect = {
	if = {
		limit = { trait = cruel }
		remove_trait = cruel
	}
}

remove_trait_silently_diligent_effect = {
	if = {
		limit = { trait = diligent }
		remove_trait = diligent
	}
}

remove_trait_silently_gluttonous_effect = {
	if = {
		limit = { trait = gluttonous }
		remove_trait = gluttonous
	}
}

remove_trait_silently_greedy_effect = {
	if = {
		limit = { trait = greedy }
		remove_trait = greedy
	}
}

remove_trait_silently_gregarious_effect = {
	if = {
		limit = { trait = gregarious }
		remove_trait = gregarious
	}
}

remove_trait_silently_honest_effect = {
	if = {
		limit = { trait = honest }
		remove_trait = honest
	}
}

remove_trait_silently_humble_effect = {
	if = {
		limit = { trait = humble }
		remove_trait = humble
	}
}

remove_trait_silently_just_effect = {
	if = {
		limit = { trait = just }
		remove_trait = just
	}
}

remove_trait_silently_kind_effect = {
	if = {
		limit = { trait = kind }
		remove_trait = kind
	}
}

remove_trait_silently_lustful_effect = {
	if = {
		limit = { trait = lustful }
		remove_trait = lustful
	}
}

remove_trait_silently_patient_effect = {
	if = {
		limit = { trait = patient }
		remove_trait = patient
	}
}

remove_trait_silently_proud_effect = {
	if = {
		limit = { trait = proud }
		remove_trait = proud
	}
}

remove_trait_silently_shy_effect = {
	if = {
		limit = { trait = shy }
		remove_trait = shy
	}
}

remove_trait_silently_slothful_effect = {
	if = {
		limit = { trait = slothful }
		remove_trait = slothful
	}
}

remove_trait_silently_temperate_effect = {
	if = {
		limit = { trait = temperate }
		remove_trait = temperate
	}
}

remove_trait_silently_trusting_effect = {
	if = {
		limit = { trait = trusting }
		remove_trait = trusting
	}
}

remove_trait_silently_wroth_effect = {
	if = {
		limit = { trait = wroth }
		remove_trait = wroth
	}
}

remove_trait_silently_zealous_effect = {
	if = {
		limit = { trait = zealous }
		remove_trait = zealous
	}
}

###REAPER's DUE###

remove_patrons_effect = {
	remove_character_modifier = patron_shiva
	remove_character_modifier = patron_vishnu
	remove_character_modifier = patron_brahma
	remove_character_modifier = patron_kali
	remove_character_modifier = patron_ganesha
	remove_character_modifier = patron_ganga
}

increase_mercenary_troop_support_effect = {
	if = {
		limit = {
			has_mercenary_maintenance_modifier = maintaining_mercenary_band_6
		}
		set_mercenary_maintenance_modifier = maintaining_mercenary_band_7
		change_title_army_size = 0.3
	}
	if = {
		limit = {
			has_mercenary_maintenance_modifier = maintaining_mercenary_band_5
		}
		set_mercenary_maintenance_modifier = maintaining_mercenary_band_6
		change_title_army_size = 0.3
	}
	if = {
		limit = {
			has_mercenary_maintenance_modifier = maintaining_mercenary_band_4
		}
		set_mercenary_maintenance_modifier = maintaining_mercenary_band_5
		change_title_army_size = 0.3
	}
	if = {
		limit = {
			has_mercenary_maintenance_modifier = maintaining_mercenary_band_3
		}
		set_mercenary_maintenance_modifier = maintaining_mercenary_band_4
		change_title_army_size = 0.3
	}
	if = {
		limit = {
			has_mercenary_maintenance_modifier = maintaining_mercenary_band_2
		}
		set_mercenary_maintenance_modifier = maintaining_mercenary_band_3
		change_title_army_size = 0.3
	}
	if = {
		limit = {
			has_mercenary_maintenance_modifier = maintaining_mercenary_band
		}
		set_mercenary_maintenance_modifier = maintaining_mercenary_band_2
		change_title_army_size = 0.3
	}
}

increase_mercenary_ambition_level_effect = {
	if = {
		limit = {
			has_character_flag = mercenary_ambition_8
		}
		clr_character_flag = mercenary_ambition_8
		set_character_flag = mercenary_ambition_9
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_7
		}
		clr_character_flag = mercenary_ambition_7
		set_character_flag = mercenary_ambition_8
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_6
		}
		clr_character_flag = mercenary_ambition_6
		set_character_flag = mercenary_ambition_7
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_5
		}
		clr_character_flag = mercenary_ambition_5
		set_character_flag = mercenary_ambition_6
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_4
		}
		clr_character_flag = mercenary_ambition_4
		set_character_flag = mercenary_ambition_5
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_3
		}
		clr_character_flag = mercenary_ambition_3
		set_character_flag = mercenary_ambition_4
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_2
		}
		clr_character_flag = mercenary_ambition_2
		set_character_flag = mercenary_ambition_3
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_1
		}
		clr_character_flag = mercenary_ambition_1
		set_character_flag = mercenary_ambition_2
	}
}

decrease_mercenary_ambition_level_effect = {
	if = {
		limit = {
			has_character_flag = mercenary_ambition_2
		}
		clr_character_flag = mercenary_ambition_2
		set_character_flag = mercenary_ambition_1
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_3
		}
		clr_character_flag = mercenary_ambition_3
		set_character_flag = mercenary_ambition_2
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_4
		}
		clr_character_flag = mercenary_ambition_4
		set_character_flag = mercenary_ambition_3
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_5
		}
		clr_character_flag = mercenary_ambition_5
		set_character_flag = mercenary_ambition_4
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_6
		}
		clr_character_flag = mercenary_ambition_6
		set_character_flag = mercenary_ambition_5
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_7
		}
		clr_character_flag = mercenary_ambition_7
		set_character_flag = mercenary_ambition_6
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_8
		}
		clr_character_flag = mercenary_ambition_8
		set_character_flag = mercenary_ambition_7
	}
	if = {
		limit = {
			has_character_flag = mercenary_ambition_9
		}
		clr_character_flag = mercenary_ambition_9
		set_character_flag = mercenary_ambition_8
	}
}

add_symptom_effect = {
	if = {
		limit = {
			NOT = { has_dlc = "Reapers" }
			NOT = { trait = ill }
		}
		add_trait = ill
		hidden_tooltip = {
			character_event = { id = 38290 } # notify ill
		}
	}
	if = {
		limit = {
			has_dlc = "Reapers"
		}
		custom_tooltip = {
			text = add_symptom_tooltip
			hidden_tooltip = {
				random_list = {
					10 = {
						modifier = {
							factor = 0
							trait = cough
						}
						character_event = { id = RIP.5000 days = 1 }
					}
					10 = {
						modifier = {
							factor = 0
							trait = fever
						}
						character_event = { id = RIP.5001 days = 1 }
					}
					10 = {
						modifier = {
							factor = 0
							trait = diarrhea

						}
						character_event = { id = RIP.5002 days = 1 }
					}
					10 = {
						modifier = {
							factor = 0
							trait = vomiting
						}
						character_event = { id = RIP.5003 days = 1 }
					}
					10 = {
						modifier = {
							factor = 0
							trait = headache
						}
						character_event = { id = RIP.5004 days = 1 }
					}
					10 = {
						modifier = {
							factor = 0
							trait = chest_pain
						}
						character_event = { id = RIP.5005 days = 1 }
					}
					10 = {
						modifier = {
							factor = 0
							trait = cramps
						}
						character_event = { id = RIP.5006 days = 1 }
					}
					10 = {
						modifier = {
							factor = 0
							trait = rash
						}
						character_event = { id = RIP.5007 days = 1 }
					}
					10 = {
						modifier = {
							factor = 0
							trait = abdominal_pain
						}
						character_event = { id = RIP.5008 days = 1 }
					}
					10 = {
						modifier = {
							factor = 0
							trait = fatigue
						}
						character_event = { id = RIP.5009 days = 1 }
					}
					10 = {
						modifier = {
							factor = 0
							trait = malaise
						}
						character_event = { id = RIP.5010 days = 1 }
					}
				}
			}
		}
	}
}

add_maimed_trait_effect = {
	custom_tooltip = {
		text = maimed_effect_tooltip
		hidden_tooltip = {
			random_list = {
				10 = {
					modifier = {
						factor = 0
						has_dlc = "Reapers"
					}
					add_trait = maimed
					character_event = { id = 38281 }
				}
				15 = {
					modifier = {
						factor = 0
						OR = {
							trait = one_eyed
							trait = blinded
							NOT = { has_dlc = "Reapers" }
						}
					}
					add_trait = one_eyed
					character_event = { id = RIP.11501 }
				}
				10 = {
					modifier = {
						factor = 0
						OR = {
							trait = one_legged
							NOT = { has_dlc = "Reapers" }
						}
					}
					add_trait = one_legged
					character_event = { id = RIP.11503 }
				}
				20 = {
					modifier = {
						factor = 0
						OR = {
							trait = one_handed
							NOT = { has_dlc = "Reapers" }
						}
					}
					add_trait = one_handed
					character_event = { id = RIP.11502 }
				}
				10 = {
					modifier = {
						factor = 0
						OR = {
							trait = disfigured
							NOT = { has_dlc = "Reapers" }
						}
					}
					add_trait = disfigured
					character_event = { id = RIP.11504 }
				}
				5 = {
					modifier = {
						factor = 0
						OR = {
							trait = mangled
							NOT = { has_dlc = "Reapers" }
						}
					}
					add_trait = mangled
					character_event = { id = RIP.11505 }
				}
			}
		}
	}
	if = {
		limit = {
			has_dlc = "Reapers"
			NOT = { trait = severely_injured }
		}
		add_trait = severely_injured
		hidden_tooltip = {
			random_list = {
				75 = { #Get rid of severely_injured
					character_event = { id = RIP.11000 days = 90 random = 275}
				}
				25 = { #Get rid of severely_injured but develop infection
					set_character_flag = pending_infection
					character_event = { id = RIP.11000 days = 90 random = 275}
				}
			}
		}
	}
}

add_plague_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = malaise
			}
			character_event = { id = RIP.5010 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fever
			}
			character_event = { id = RIP.5001 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = cramps
			}
			character_event = { id = RIP.5006 }
		}
	}
}

add_pneumonia_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = cough
			}
			character_event = { id = RIP.5000 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fever
			}
			character_event = { id = RIP.5001 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = chest_pain
			}
			character_event = { id = RIP.5005 }
		}
	}
}

add_syphilis_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = rash
			}
			character_event = { id = RIP.5007 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fever
			}
			character_event = { id = RIP.5001 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = headache
			}
			character_event = { id = RIP.5004 }
		}
	}
}

add_tuberculosis_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = cough
			}
			character_event = { id = RIP.5000 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fever
			}
			character_event = { id = RIP.5001 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = chest_pain
			}
			character_event = { id = RIP.5005 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fatigue
			}
			character_event = { id = RIP.5009 }
		}
	}
}

add_typhoid_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = diarrhea
			}
			character_event = { id = RIP.5002 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fever
			}
			character_event = { id = RIP.5001 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = abdominal_pain
			}
			character_event = { id = RIP.5008 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = malaise
			}
			character_event = { id = RIP.5010 }
		}
	}
}

add_typhus_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = diarrhea
			}
			character_event = { id = RIP.5002 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fever
			}
			character_event = { id = RIP.5001 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = abdominal_pain
			}
			character_event = { id = RIP.5008 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fatigue
			}
			character_event = { id = RIP.5009 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = rash
			}
			character_event = { id = RIP.5007 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = headache
			}
			character_event = { id = RIP.5004 }
		}
	}
}

add_measles_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = rash
			}
			character_event = { id = RIP.5007 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fever
			}
			character_event = { id = RIP.5001 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = cough
			}
			character_event = { id = RIP.5000 }
		}
	}
}

add_smallpox_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = rash
			}
			character_event = { id = RIP.5007 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fever
			}
			character_event = { id = RIP.5001 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = headache
			}
			character_event = { id = RIP.5004 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = malaise
			}
			character_event = { id = RIP.5010 }
		}
	}
}

add_flu_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = fatigue
			}
			character_event = { id = RIP.5009 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fever
			}
			character_event = { id = RIP.5001 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = headache
			}
			character_event = { id = RIP.5004 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = malaise
			}
			character_event = { id = RIP.5010 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = cough
			}
			character_event = { id = RIP.5000 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = abdominal_pain
			}
			character_event = { id = RIP.5008 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = diarrhea
			}
			character_event = { id = RIP.5002 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = vomiting
			}
			character_event = { id = RIP.5003 }
		}
	}
}

add_dysentery_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = diarrhea
			}
			character_event = { id = RIP.5002 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fever
			}
			character_event = { id = RIP.5001 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = abdominal_pain
			}
			character_event = { id = RIP.5008 }
		}
	}
}

add_gout_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = fatigue
			}
			character_event = { id = RIP.5009 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fever
			}
			character_event = { id = RIP.5001 }
		}
	}
}

add_food_poisoning_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = diarrhea
			}
			character_event = { id = RIP.5002 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fever
			}
			character_event = { id = RIP.5001 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = cramps
			}
			character_event = { id = RIP.5006 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = vomiting
			}
			character_event = { id = RIP.5003 }
		}
	}
}

add_rabies_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = malaise
			}
			character_event = { id = RIP.5010 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fever
			}
			character_event = { id = RIP.5001 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = fatigue
			}
			character_event = { id = RIP.5009 }
		}
	}
}

add_cancer_symptom_effect = {
	random_list = {
		10 = {
			modifier = {
				factor = 0
				trait = fatigue
			}
			character_event = { id = RIP.5009 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = chest_pain
			}
			character_event = { id = RIP.5005 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = headache
			}
			character_event = { id = RIP.5004 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = malaise
			}
			character_event = { id = RIP.5010 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = cough
			}
			character_event = { id = RIP.5000 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = abdominal_pain
			}
			character_event = { id = RIP.5008 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = diarrhea
			}
			character_event = { id = RIP.5002 }
		}
		10 = {
			modifier = {
				factor = 0
				trait = vomiting
			}
			character_event = { id = RIP.5003 }
		}
	}
}

increase_depopulation_effect = {
	if = {
		limit = {
			has_province_modifier = depopulated_2
		}
		random_list = {
			40 = {
				modifier = {
					factor = 1.5
					any_province_holding = {
						OR = {
							holding_type = nomad
							holding_type = tribal
						}
					}
					NOT = { num_of_settlements = 3 }
				}
				modifier = {
					factor = 1.2
					hospital_level = 1
				}
				modifier = {
					factor = 1.2
					hospital_level = 2
				}
				modifier = {
					factor = 1.2
					hospital_level = 3
				}
				modifier = {
					factor = 1.2
					hospital_level = 4
				}
				modifier = {
					factor = 1.2
					hospital_level = 5
				}
				modifier = {
					factor = 1.2
					hospital_level = 6
				}
			}
			60 = {
				modifier = {
					factor = 0
					any_province_holding = {
						NOR = {
							holding_type = city
							holding_type = temple
							holding_type = castle
							holding_type = tribal
						}
					}
				}
				remove_province_modifier = depopulated_2
				add_province_modifier = {
					name = depopulated_3
					duration = -1
				}
				clr_province_flag = recent_depopulation_2
				set_province_flag = recent_depopulation_3
			}
		}
	}
	if = {
		limit = {
			has_province_modifier = depopulated_1
		}
		random_list = {
			20 = {
				modifier = {
					factor = 4
					any_province_holding = {
						OR = {
							holding_type = nomad
							holding_type = tribal
						}
					}
					NOT = { num_of_settlements = 3 }
				}
				modifier = {
					factor = 1.4
					hospital_level = 1
				}
				modifier = {
					factor = 1.4
					hospital_level = 2
				}
				modifier = {
					factor = 1.4
					hospital_level = 3
				}
				modifier = {
					factor = 1.4
					hospital_level = 4
				}
				modifier = {
					factor = 1.4
					hospital_level = 5
				}
				modifier = {
					factor = 1.4
					hospital_level = 6
				}
			}
			80 = {
				modifier = {
					factor = 0
					any_province_holding = {
						NOR = {
							holding_type = city
							holding_type = temple
							holding_type = castle
							holding_type = tribal
						}
					}
				}
				remove_province_modifier = depopulated_1
				add_province_modifier = {
					name = depopulated_2
					duration = -1
				}
				clr_province_flag = recent_depopulation_1
				set_province_flag = recent_depopulation_2
			}
		}

	}
	if = {
		limit = {
			NOR = {
				has_province_modifier = depopulated_1
				has_province_modifier = depopulated_2
				has_province_modifier = depopulated_3
			}
		}
		random_list = {
			5 = {
				modifier = {
					factor = 15
					any_province_holding = {
						OR = {
							holding_type = nomad
							holding_type = tribal
						}
					}
					NOT = { num_of_settlements = 3 }
				}
				modifier = {
					factor = 1.5
					hospital_level = 1
				}
				modifier = {
					factor = 1.5
					hospital_level = 2
				}
				modifier = {
					factor = 1.5
					hospital_level = 3
				}
				modifier = {
					factor = 1.5
					hospital_level = 4
				}
				modifier = {
					factor = 1.5
					hospital_level = 5
				}
				modifier = {
					factor = 1.5
					hospital_level = 6
				}
			}
			95 = {
				modifier = {
					factor = 0
					any_province_holding = {
						NOR = {
							holding_type = city
							holding_type = temple
							holding_type = castle
							holding_type = tribal
						}
					}
				}
				set_variable = { which = prosperity_value value = 0 }
				remove_province_modifier = prosperity_modifier_1
				remove_province_modifier = prosperity_modifier_2
				remove_province_modifier = prosperity_modifier_3
				add_province_modifier = {
					name = depopulated_1
					duration = -1
				}
				set_province_flag = recent_depopulation_1
			}
		}
	}
}

decrease_depopulation_effect = {
	if = {
		limit = {
			has_province_modifier = depopulated_1
		}
		remove_province_modifier = depopulated_1
	}
	if = {
		limit = {
			has_province_modifier = depopulated_2
		}
		remove_province_modifier = depopulated_2
		add_province_modifier = {
			name = depopulated_1
			duration = -1
		}
	}
	if = {
		limit = {
			has_province_modifier = depopulated_3
		}
		remove_province_modifier = depopulated_3
		add_province_modifier = {
			name = depopulated_2
			duration = -1
		}
	}
}

prisoner_mutilate_effect = {

	random = {
		chance = 20
		if = {
				limit = { NOR = { trait = craven trait = berserker } }
				add_trait = craven
				hidden_tooltip = { character_event = { id = 38257 } }
			}
	}

	random_list = {
		80 = {
			if = {
					limit = { NOT = { trait = stressed } }
					add_trait = stressed
					hidden_tooltip = { character_event = { id = 38282 } }
				}
		}
		10 = {
			if = {
					limit = { NOT = { trait = lunatic } }
					add_trait = lunatic
					hidden_tooltip = { character_event = { id = 38304 } }
				}
		}
		10 = {
			#no effect
		}
	}

	add_trait = severely_injured
	hidden_tooltip = {
		random_list = {
			75 = { #Get rid of severely_injured
				character_event = { id = RIP.11000 days = 90 random = 275}
			}
			25 = { #Get rid of severely_injured but develop infection
				set_character_flag = pending_infection
				character_event = { id = RIP.11000 days = 90 random = 275}
			}
		}
	}
}

jailor_mutilate_effect = {

	if = {
		limit = { NOR = { trait = craven trait = berserker } }
		random = {
			chance = 20
			add_trait = craven
			hidden_tooltip = { character_event = { id = 38257 } } # Notify craven
		}
	}

	add_trait = severely_injured
	hidden_tooltip = {
		random_list = {
			75 = { #Get rid of severely_injured
				character_event = { id = RIP.11000 days = 90 random = 275}
			}
			25 = { #Get rid of severely_injured but develop infection
				set_character_flag = pending_infection
				character_event = { id = RIP.11000 days = 90 random = 275}
			}
		}
	}

	custom_tooltip = { text = might_affect_mental_health_tt }
	hidden_effect = {
		random_list = {
			80 = {
				add_trait = stressed
			}
			10 = {
				add_trait = lunatic
			}
			10 = {
				#no effect
			}
		}
	}
}

prisoner_torture_effect = {
	add_character_modifier = { name = tortured years = 2 }

	random_list = {
		80 = {
			if = {
				limit = { NOT = { trait = stressed } }
				add_trait = stressed
				hidden_tooltip = { character_event = { id = 38282 } }
			}
		}
		10 = {
			if = {
				limit = { NOR = { trait = craven trait = berserker } }
				add_trait = craven
				hidden_tooltip = { character_event = { id = 38257 } }
			}
		}
		5 = {
			if = {
				limit = { NOT = { trait = lunatic } }
				add_trait = lunatic
				hidden_tooltip = { character_event = { id = 38304 } }
			}
		}
		5 = {
			#nothing
		}
	}
}

jailor_torture_effect = {
	add_character_modifier = { name = tortured years = 2 }

	random_list = {
		80 = {
				if = {
					limit = { trait = stressed }
					health = -0.25
				}
				else = {
					add_trait = stressed
				}
			}
		10 = {
			if = {
				limit = { OR = { trait = craven trait = berserker } }
				health = -0.5
			}
			else = {
				add_trait = craven
			}
		}
		5 = {
			if = {
				limit = { trait = lunatic }
				health = -1.0
			}
			else = {
				add_trait = lunatic
			}
		}
		5 = {
			#nothing
		}
	}
}

jailor_humiliation_effect = {
	random_list = {
		15 = {
			add_trait = stressed
		}
		30 = {
			add_trait = humble
		}
		30 = {
			add_trait = shy
		}
		25 = {
			#nothing happens
		}
	}
}

prisoner_humiliation_effect = {
	random_list = {
		15 = {
			modifier = {
				factor = 0
				trait = stressed
			}
			add_trait = stressed
			hidden_tooltip = {
				character_event = { id = 38282 } # Notify Stressed
			}
		}
		30 = {
			modifier = {
				factor = 0
				trait = humble
			}
			add_trait = humble
			hidden_tooltip = {
				character_event = { id = 38260 } # Notify Humble
			}
		}
		30 = {
			modifier = {
				factor = 0
				trait = shy
			}
			add_trait = shy
			hidden_tooltip = {
				character_event = { id = 38263 } # Notify Shy
			}
		}
		25 = {
			#nothing happens
		}
	}
}

maim_hand_effect = {
	if = {
		limit = {
			NOT = {
				has_dlc = "Reapers"
			}
		}
		add_trait = maimed
	}
	if = {
		limit = {
			has_dlc = "Reapers"
		}
		if = {
			limit = {
				trait = one_handed
				NOT = { trait = mangled }
			}
			add_trait = mangled
			hidden_tooltip = { character_event = { id = RIP.11505 } }
		}
		if = {
			limit = {
				NOT = { trait = one_handed }
			}
			add_trait = one_handed
			hidden_tooltip = { character_event = { id = RIP.11502 } }
		}
	}
	add_trait = severely_injured
	hidden_tooltip = {
		hidden_tooltip = {
			random_list = {
				75 = { #Get rid of severely_injured
					character_event = { id = RIP.11000 days = 90 random = 275}
				}
				25 = { #Get rid of severely_injured but develop infection
					set_character_flag = pending_infection
					character_event = { id = RIP.11000 days = 90 random = 275}
				}
			}
		}
	}
}

mangle_effect = {
	if = {
		limit = {
			NOT = {
				has_dlc = "Reapers"
			}
		}
		add_trait = maimed
	}
	if = {
		limit = {
			has_dlc = "Reapers"
		}
		if = {
			limit = {
				NOT = { trait = mangled }
			}
			add_trait = mangled
			hidden_tooltip = { character_event = { id = RIP.11505 } }
		}
	}
	add_trait = severely_injured
	hidden_tooltip = {
		hidden_tooltip = {
			random_list = {
				75 = { #Get rid of severely_injured
					character_event = { id = RIP.11000 days = 90 random = 275}
				}
				25 = { #Get rid of severely_injured but develop infection
					set_character_flag = pending_infection
					character_event = { id = RIP.11000 days = 90 random = 275}
				}
			}
		}
	}
}

remove_treatment_modifiers_effect = {
	remove_character_modifier = successful_treatment_1
	remove_character_modifier = successful_treatment_2
	remove_character_modifier = successful_treatment_3
	remove_character_modifier = failed_treatment_1
	remove_character_modifier = failed_treatment_2
	remove_character_modifier = mystic_treatment_decent
	remove_character_modifier = mystic_treatment_poor
	remove_character_modifier = mystic_treatment_terrible
	remove_character_modifier = symptom_treatment_1
	remove_character_modifier = symptom_treatment_2
	remove_character_modifier = symptom_treatment_3
	remove_character_modifier = symptom_treatment_4
}

remove_disease_flags_effect = {
	clr_character_flag = developing_illness
	clr_character_flag = got_syphilis
	clr_character_flag = got_tuberculosis
	clr_character_flag = got_typhoid_fever
	clr_character_flag = got_typhus
	clr_character_flag = got_bubonic_plague
	clr_character_flag = got_measles
	clr_character_flag = got_smallpox
	clr_character_flag = got_aztec_disease
	clr_character_flag = got_flu
	clr_character_flag = got_dysentery
	clr_character_flag = got_gout
	clr_character_flag = got_food_poisoning
	clr_character_flag = got_rabies
	clr_character_flag = got_cancer
	clr_character_flag = got_pneumonia
	clr_character_flag = manifest_syphilis
	clr_character_flag = manifest_tuberculosis
	clr_character_flag = manifest_typhoid_fever
	clr_character_flag = manifest_typhus
	clr_character_flag = manifest_bubonic_plague
	clr_character_flag = manifest_measles
	clr_character_flag = manifest_small_pox
	clr_character_flag = manifest_aztec_disease
	clr_character_flag = manifest_flu
	clr_character_flag = manifest_dysentery
	clr_character_flag = manifest_gout
	clr_character_flag = manifest_food_poisoning
	clr_character_flag = manifest_rabies
	clr_character_flag = manifest_cancer
	clr_character_flag = manifest_pneumonia
}

leave_court_effect = {
	reverse_opinion = {
		modifier = opinion_leave
		who = ROOT
	}

	banish = yes

	reverse_remove_opinion = {
		modifier = opinion_leave
		who = ROOT
	}
}

courtiers_leaving_effect = {
	hidden_effect = { #To get a banishment reason
		reverse_opinion = {
			modifier = opinion_leave
			who = ROOT
		}

		banish = yes

		reverse_remove_opinion = {
			modifier = opinion_leave
			who = ROOT
		}
	}
	opinion = {
		modifier = opinion_left_court
		who = root
	}
}

leave_court_and_die_effect = {
	death = { death_reason = death_missing }
}

give_epidemic_disease_effect = {
	if = {
		limit = {
			location = { disease = tuberculosis }
			NOT = { has_character_flag = immune_tuberculosis }
		}

		set_character_flag = got_tuberculosis
		set_character_flag = developing_illness

		character_event = { id = RIP.5015 }

		break = yes
	}
	if = {
		limit = {
			location = { disease = typhoid_fever }
			NOT = { has_character_flag = immune_typhoid_fever }
		}

		set_character_flag = got_typhoid_fever
		set_character_flag = developing_illness

		character_event = { id = RIP.5016 }

		break = yes
	}
	if = {
		limit = {
			location = { disease = typhus }
			NOT = { has_character_flag = immune_typhus }
		}

		set_character_flag = got_typhus
		set_character_flag = developing_illness

		character_event = { id = RIP.5017 }

		break = yes
	}
	if = {
		limit = {
			location = { disease = bubonic_plague }
			NOT = { has_character_flag = immune_bubonic_plague }
		}

		set_character_flag = got_bubonic_plague
		set_character_flag = developing_illness

		character_event = { id = RIP.5012 }

		break = yes
	}
	if = {
		limit = {
			location = { disease = measles }
			NOT = { has_character_flag = immune_measles }
		}

		set_character_flag = got_measles
		set_character_flag = developing_illness

		character_event = { id = RIP.5018 }

		break = yes
	}
	if = {
		limit = {
			location = { disease = small_pox }
			NOT = { has_character_flag = immune_smallpox }
		}

		set_character_flag = got_small_pox
		set_character_flag = developing_illness

		character_event = { id = RIP.5019 }

		break = yes
	}
	if = {
		limit = {
			location = { disease = syphilis }
			NOT = { has_character_flag = immune_syphilis }
		}

		set_character_flag = got_syphilis
		set_character_flag = developing_illness

		character_event = { id = RIP.5014 }

		break = yes
	}
}

blessing_removes_disease_effect = {
	if = {
		limit = {
			has_dlc = "The Old Gods"
			has_character_flag = old_gods_blessing
			has_character_modifier = blessing_of_health
		}
		hidden_tooltip = { character_event = { id = TOG.7015 days = 30 } }
	}
	if = {
		limit = {
			has_dlc = "Sons of Abraham"
			has_character_flag = pilgrim_blessing
			has_character_modifier = blessing_of_health
		}
		hidden_tooltip = { character_event = { id = SoA.5068 days = 30 } }
	}
}

deaths_gift_removes_disease_effect = {
	if = {
		limit = {
			has_dlc = "Reapers"
			has_character_modifier = deaths_gift
		}
		hidden_tooltip = { character_event = { id = RIP.30233 days = 30 } }
	}
}

remove_disease_trait_effect = {
	if = {
		 limit = { trait = ill }
		 remove_trait = ill
	}
	if = {
		 limit = { trait = has_tuberculosis }
		 remove_trait = has_tuberculosis
	}
	if = {
		 limit = { trait = has_typhoid_fever }
		 remove_trait = has_typhoid_fever
	}
	if = {
		 limit = { trait = has_typhus }
		 remove_trait = has_typhus
	}
	if = {
		 limit = { trait = has_bubonic_plague }
		 remove_trait = has_bubonic_plague
	}
	if = {
		 limit = { trait = has_measles }
		 remove_trait = has_measles
	}
	if = {
		 limit = { trait = has_small_pox }
		 remove_trait = has_small_pox
	}
	if = {
		 limit = { trait = has_aztec_disease }
		 remove_trait = has_aztec_disease
	}
	if = {
		 limit = { trait = syphilitic }
		 remove_trait = syphilitic
	}
	if = {
		 limit = { trait = flu }
		 remove_trait = flu
	}
	if = {
		 limit = { trait = dysentery }
		 remove_trait = dysentery
	}
	if = {
		 limit = { trait = gout }
		 remove_trait = gout
	}
	if = {
		 limit = { trait = food_poisoning }
		 remove_trait = food_poisoning
	}
	if = {
		 limit = { trait = rabies }
		 remove_trait = rabies
	}
	if = {
		 limit = { trait = cancer }
		 remove_trait = cancer
	}
	if = {
		 limit = { trait = pneumonic }
		 remove_trait = pneumonic
	}
	if = {
		 limit = { trait = scurvy }
		 remove_trait = scurvy
	}
	if = {
		 limit = { trait = dancing_plague }
		 remove_trait = dancing_plague
	}
	if = {
		 limit = { trait = leper }
		 remove_trait = leper
	}
	clear_disease_level_effect = yes
}

resolve_severely_injured_effect = {
	hidden_tooltip = {
		random_list = {
			70 = { #Get rid of severely_injured
				character_event = { id = RIP.11000 days = 100 random = 300 }
			}
			30 = { #Get rid of severely_injured but develop infection
				set_character_flag = pending_infection
				character_event = { id = RIP.11000 days = 100 random = 300 }
			}
		}
	}
}

#For when you "only" become really injured, but still want the risk of infection...
add_severely_injured_effect = {
	add_trait = severely_injured
	resolve_severely_injured_effect = yes
}

leave_council_position_effect = {
	if = {
		limit = { has_job_title = job_chancellor }
		remove_title = job_chancellor
		add_character_modifier = {
			modifier = resigned_in_anger
			years = 2
			hidden = yes
		}
	}
	if = {
		limit = { has_job_title = job_marshal }
		remove_title = job_marshal
		add_character_modifier = {
			modifier = resigned_in_anger
			years = 2
			hidden = yes
		}
	}
	if = {
		limit = { has_job_title = job_treasurer }
		remove_title = job_treasurer
		add_character_modifier = {
			modifier = resigned_in_anger
			years = 2
			hidden = yes
		}
	}
	if = {
		limit = { has_job_title = job_spymaster }
		remove_title = job_spymaster
		add_character_modifier = {
			modifier = resigned_in_anger
			years = 2
			hidden = yes
		}
	}
	if = {
		limit = { has_job_title = job_spiritual }
		remove_title = job_spiritual
		add_character_modifier = {
			modifier = resigned_in_anger
			years = 2
			hidden = yes
		}
	}
	if = {
		limit = { has_minor_title = title_councilmember_king }
		remove_title = title_councilmember_king
		add_character_modifier = {
			modifier = resigned_in_anger
			years = 2
			hidden = yes
		}
	}
	if = {
		limit = { has_minor_title = title_councilmember_emperor }
		remove_title = title_councilmember_emperor
		add_character_modifier = {
			modifier = resigned_in_anger
			years = 2
			hidden = yes
		}
	}
}

increase_prosperity_effect = {
	if = {
		limit = {
			NOR = {
				has_province_modifier = prosperity_modifier_1
				has_province_modifier = prosperity_modifier_2
				has_province_modifier = prosperity_modifier_3
				has_province_modifier = depopulated_1
				has_province_modifier = depopulated_2
				has_province_modifier = depopulated_3
			}
		}

		add_province_modifier = { name = prosperity_modifier_1 duration = -1 }
		hidden_tooltip = { set_variable = { which = prosperity_value value = 100 } }
		break = yes
	}

	if = {
		limit = { has_province_modifier = prosperity_modifier_1 }

		hidden_tooltip = { remove_province_modifier = prosperity_modifier_1 }
		add_province_modifier = { name = prosperity_modifier_2 duration = -1 }
		hidden_tooltip = { set_variable = { which = prosperity_value value = 250 } }
		break = yes
	}

	if = {
		limit = { has_province_modifier = prosperity_modifier_2 }

		hidden_tooltip = { remove_province_modifier = prosperity_modifier_2 }
		add_province_modifier = { name = prosperity_modifier_3 duration = -1 }
		hidden_tooltip = { set_variable = { which = prosperity_value value = 500 } }
		break = yes
	}
}

decrease_prosperity_effect = {
	if = {
		limit = {
			has_province_modifier = prosperity_modifier_3
		}
		hidden_tooltip = {
			remove_province_modifier = prosperity_modifier_3
			set_variable = { which = prosperity_value value = 250 }
		}
		add_province_modifier = { name = prosperity_modifier_2 duration = -1 }
	}
}

add_disease_level_effect = {
		random_list = {
			65 = {
				custom_tooltip = {
					text = become_normal_ill
				}
			}
			20 = {
				modifier = {
					factor = 2
					trait = strong
				}
				modifier = {
					factor = 2
					trait = robust
				}
				custom_tooltip = {
					text = become_mild_ill
					hidden_tooltip = {
						add_character_modifier = { name = mild_illness duration = -1 }
					}
				}
			}
			10 = {
				modifier = {
					factor = 1.5
					trait = feeble
				}
				modifier = {
					factor = 1.5
					trait = weak
				}
				modifier = {
					factor = 0.5
					trait = strong
				}
				modifier = {
					factor = 0.5
					trait = robust
				}
				modifier = {
					factor = 1.5
					age = 50
				}
				modifier = {
					factor = 1.5
					age = 60
				}
				modifier = {
					factor = 1.5
					age = 70
				}
				modifier = {
					factor = 1.5
					age = 80
				}
				custom_tooltip = {
					text = become_severe_ill
					hidden_tooltip = {
						add_character_modifier = { name = severe_illness duration = -1 }
					}
				}
			}
			5= {
				modifier = {
					factor = 0
					immortal = yes
				}
				modifier = {
					factor = 2
					trait = feeble
				}
				modifier = {
					factor = 2
					trait = weak
				}
				modifier = {
					factor = 0.5
					trait = strong
				}
				modifier = {
					factor = 0.5
					trait = robust
				}
				 modifier = {
					factor = 2
					age = 50
				}
				modifier = {
					factor = 2
					age = 60
				}
				modifier = {
					factor = 2
					age = 70
				}
				modifier = {
					factor = 2
					age = 80
				}
				custom_tooltip = {
					text = become_bedridden_ill
					hidden_tooltip = {
						add_character_modifier = { name = bedridden_illness duration = -1 }
						add_trait = sick_incapable
					}
				}
			}
		}
}

clear_disease_level_effect = {
	if = {
		limit = { has_character_modifier = mild_illness }
		remove_character_modifier = mild_illness
	}
	if = {
		limit = { has_character_modifier = severe_illness }
		remove_character_modifier = severe_illness
	}
	if = {
		limit = { has_character_modifier = bedridden_illness }
		remove_character_modifier = bedridden_illness
		hidden_tooltip = {
			remove_trait = sick_incapable
		}
	}
}

end_inaccessibility_effect = {
	if = {
		limit = { trait = in_hiding }
		remove_trait = in_hiding

		clr_character_flag = do_not_disturb

		add_character_modifier = {
			name = went_out_of_hiding_timer
			duration = 180
			hidden = yes
		}
		hidden_tooltip = { character_event = { id = CM.6400 } } # Notify plotters and family
	}
	if = {
		limit = { has_character_modifier = in_seclusion }

		remove_character_modifier = in_seclusion

		if = {
			limit = { is_ruler = yes }

			clr_character_flag = do_not_disturb
			clr_character_flag = exposed_to_outside
			clr_character_flag = seclusion_piling_corpses
			clr_character_flag = seclusion_lazy_seduction
			clr_character_flag = seclusion_nightmares
			clr_character_flag = seclusion_gained_friend
			clr_character_flag = seclusion_child_has_lover
			clr_character_flag = seclusion_tunnel
			clr_character_flag = seclusion_food_events

			custom_tooltip = { text = open_the_gates_info_tooltip }

			add_character_modifier = {
				name = recently_opened_gates
				duration = 365
			}
			hidden_tooltip = {
				clr_character_flag = seclusion_events_on
				character_event = { id = RIP.11557 days = 40 random = 20} #clears starvation modifiers
				any_courtier = {
					clr_character_flag = seclusion_events_on
					remove_character_modifier = in_seclusion
					character_event = { id = RIP.11557 days = 40 random = 20} #clears starvation modifiers
				}
				any_vassal = {
					limit = {
						OR = {
							is_councillor = yes
							has_minor_title = title_councilmember_king
							has_minor_title = title_councilmember_emperor
						}
						is_landed = yes
						liege = { character = ROOT }
						NOT = {
							has_character_modifier = in_seclusion
						}
						host = { NOT = { character = ROOT } }
					}
					force_host = ROOT
				}
			}
			if = { # Rejoin your liege's court if both of you are not in seclusion
				limit = {
					OR = {
						is_councillor = yes
						has_minor_title = title_councilmember_king
						has_minor_title = title_councilmember_emperor
					}
					NOT = {
						liege = {
							has_character_modifier = in_seclusion
						}
					}
				}
				liege = {
					ROOT = {
						force_host = PREV
					}
				}
			}
		}
	}
}

#Effects for adding diseases
give_pneumonic_effect = {
	if = {
		limit = { NOT = { trait = pneumonic } }

		if = {
			limit = {
				has_dlc = "Reapers"
				NOT = { has_character_flag = developing_illness }
				NOT = { has_character_flag = disease_not_serious }
			}
			tooltip = { add_trait = pneumonic }
			set_character_flag = got_pneumonia
			set_character_flag = developing_illness
			hidden_tooltip = { character_event = { id = RIP.5011 days = 3 random = 10 } }
		}
		if = {
			limit = { NOT = { has_dlc = "Reapers" } }
			add_trait = pneumonic
		}
	}
}


give_has_tuberculosis_effect = {
	if = {
		limit = { NOT = { trait = has_tuberculosis } }

		if = {
			limit = {
				has_dlc = "Reapers"
				NOT = { has_character_flag = developing_illness }
				NOT = { has_character_flag = disease_not_serious }
			}
			set_character_flag = got_tuberculosis
			set_character_flag = developing_illness
			hidden_tooltip = { character_event = { id = RIP.5015 days = 3 random = 40 } }
		}
		if = {
			limit = { NOT = { has_dlc = "Reapers" } }
			add_trait = has_tuberculosis
		}
	}
}

give_has_typhoid_fever_effect = {
	if = {
		limit = { NOT = { trait = has_typhoid_fever } }

		if = {
			limit = {
				has_dlc = "Reapers"
				NOT = { has_character_flag = developing_illness }
				NOT = { has_character_flag = disease_not_serious }
			}
			set_character_flag = got_typhoid_fever
			set_character_flag = developing_illness
			hidden_tooltip = { character_event = { id = RIP.5016 days = 3 random = 10 } }
		}
		if = {
			limit = { NOT = { has_dlc = "Reapers" } }
			add_trait = has_typhoid_fever
		}
	}
}

give_has_bubonic_plague_effect = {
	if = {
		limit = { NOT = { trait = has_bubonic_plague } }

		if = {
			limit = {
				has_dlc = "Reapers"
				NOT = { has_character_flag = developing_illness }
				NOT = { has_character_flag = disease_not_serious }
			}
			set_character_flag = got_bubonic_plague
			set_character_flag = developing_illness
			hidden_tooltip = { character_event = { id = RIP.5012 days = 3 random = 10 } }
		}
		if = {
			limit = { NOT = { has_dlc = "Reapers" } }
			add_trait = has_bubonic_plague
		}
	}
}

give_has_measles_effect = {
	if = {
		limit = { NOT = { trait = has_measles } }

		if = {
			limit = {
				has_dlc = "Reapers"
				NOT = { has_character_flag = developing_illness }
				NOT = { has_character_flag = disease_not_serious }
			}
			set_character_flag = got_measles
			set_character_flag = developing_illness
			hidden_tooltip = { character_event = { id = RIP.5018 days = 3 random = 10 } }
		}
		if = {
			limit = { NOT = { has_dlc = "Reapers" } }
			add_trait = has_measles
		}
	}
}

give_has_small_pox_effect = {
	if = {
		limit = { NOT = { trait = has_small_pox } }

		if = {
			limit = {
				has_dlc = "Reapers"
				NOT = { has_character_flag = developing_illness }
				NOT = { has_character_flag = disease_not_serious }
			}
			set_character_flag = got_smallpox
			set_character_flag = developing_illness
			hidden_tooltip = { character_event = { id = RIP.5019 days = 3 random = 10 } }
		}
		if = {
			limit = { NOT = { has_dlc = "Reapers" } }
			add_trait = has_small_pox
		}
	}
}

give_has_aztec_disease_effect = {
	if = {
		limit = { NOT = { trait = has_aztec_disease } }

		if = {
			limit = {
				has_dlc = "Reapers"
				NOT = { has_character_flag = developing_illness }
				NOT = { has_character_flag = disease_not_serious }
			}
			set_character_flag = got_aztec_disease
			set_character_flag = developing_illness
			hidden_tooltip = { character_event = { id = RIP.5014 days = 3 random = 40 } }
		}
		if = {
			limit = { NOT = { has_dlc = "Reapers" } }
			add_trait = has_aztec_disease
		}
	}
}

give_syphilitic_effect = {
	if = {
		limit = {
			NOT = { trait = syphilitic }
		}

		if = {
			limit = {
				has_dlc = "Reapers"
				NOT = { has_character_flag = developing_illness }
				NOT = { has_character_flag = disease_not_serious }
			}
			set_character_flag = got_syphilis
			set_character_flag = developing_illness
			hidden_tooltip = { character_event = { id = RIP.5014 days = 3 random = 40 } }
		}
		if = {
			limit = { NOT = { has_dlc = "Reapers" } }
			add_trait = syphilitic
		}
	}
}

give_flu_effect = {
	if = {
		limit = {
			NOT = { trait = flu }
			has_dlc = "Reapers"
			NOT = { has_character_flag = developing_illness }
			NOT = { has_character_flag = disease_not_serious }
		}

		set_character_flag = got_flu
		set_character_flag = developing_illness
		hidden_tooltip = { character_event = { id = RIP.5020 days = 3 random = 3 } }
	}
}

give_dysentery_effect = {
	if = {
		limit = {
			NOT = { trait = dysentery }
			has_dlc = "Reapers"
			NOT = { has_character_flag = developing_illness }
			NOT = { has_character_flag = disease_not_serious }
		}

		set_character_flag = got_dysentery
		set_character_flag = developing_illness
		hidden_tooltip = { character_event = { id = RIP.5021 days = 3 random = 10 } }
	}
}

give_gout_effect = {
	if = {
		limit = {
			NOT = { trait = gout }
			has_dlc = "Reapers"
			NOT = { has_character_flag = developing_illness }
			NOT = { has_character_flag = disease_not_serious }
		}

		set_character_flag = got_gout
		set_character_flag = developing_illness
		hidden_tooltip = { character_event = { id = RIP.5022 days = 30 random = 60 } }
	}
}

give_food_poisoning_effect = {
	if = {
		limit = {
			NOT = { trait = food_poisoning }
			has_dlc = "Reapers"
			NOT = { has_character_flag = developing_illness }
			NOT = { has_character_flag = disease_not_serious }
		}

		set_character_flag = got_food_poisoning
		set_character_flag = developing_illness
		hidden_tooltip = { character_event = { id = RIP.5023 days = 1 random = 2 } }
	}
}

give_rabies_effect = {
	if = {
		limit = {
			NOT = { trait = rabies }
			has_dlc = "Reapers"
			NOT = { has_character_flag = developing_illness }
			NOT = { has_character_flag = disease_not_serious }
		}

		set_character_flag = got_rabies
		set_character_flag = developing_illness
		hidden_tooltip = { character_event = { id = RIP.5024 days = 30 random = 60 } }
	}
}

give_cancer_effect = {
	if = {
		limit = {
			NOT = { trait = cancer }
			has_dlc = "Reapers"
			NOT = { has_character_flag = developing_illness }
			NOT = { has_character_flag = disease_not_serious }
		}

		set_character_flag = got_cancer
		set_character_flag = developing_illness
		hidden_tooltip = { character_event = { id = RIP.5025 days = 30 random = 60 } }
	}
}

give_ill_effect = {
	if = {
		limit = {
			NOR = {
				has_dlc = "Reapers"
				trait = ill
			}
		}
		add_trait = ill
		hidden_tooltip = {
			character_event = {
				days = 3
				id = 38290 #Notify Ill
			}
		}
	}
	if = {
		limit = { has_dlc = "Reapers" }
		tooltip = { add_trait = flu }
		give_flu_effect = yes
	}
}

#Impregnation and venereal disease handling between event_target:sex_partner and THIS. Used in THIS scope.
unprotected_sex_effect_event_target = {
	random = {
		chance = 50
		venereal_disease_effect_event_target = yes
	}
	random = {
		chance = 10
		modifier = {
			factor = 2
			is_fertile_trigger = yes
		}
		modifier = {
			factor = 2
			event_target:sex_partner = { is_fertile_trigger = yes }
		}
		modifier = {
			factor = 0.5
			is_infertile_trigger = yes
		}
		modifier = {
			factor = 0.5
			event_target:sex_partner = { is_infertile_trigger = yes }
		}
		impregnate_effect_event_target = yes
	}
}

#Transfers venereal diseases between event_target:sex_partner and THIS.
venereal_disease_effect_event_target = {
	#Great pox and aztec disease for sex_partner
	if = {
		limit = {
			NOR = {
				event_target:sex_partner = { has_character_flag = developing_illness }
				event_target:sex_partner = { has_character_flag = disease_not_serious }
			}
		}

		if = {
			limit = { trait = syphilitic }
			event_target:sex_partner = { give_syphilitic_effect = yes }
		}
		if = {
			limit = { trait = has_aztec_disease }
			event_target:sex_partner = { give_has_aztec_disease_effect = yes }
		}
	}

	#Great pox and aztec disease for THIS
	if = {
		limit = {
			NOR = {
				has_character_flag = developing_illness
				has_character_flag = disease_not_serious
			}
		}

		if = {
			limit = { event_target:sex_partner = { trait = syphilitic } }
			give_syphilitic_effect = yes
		}
		if = {
			limit = { event_target:sex_partner = { trait = has_aztec_disease } }
			give_has_aztec_disease_effect = yes
		}
	}

	#Lover's pox
	if = {
		limit = {
			OR = {
				trait = lovers_pox
				has_character_modifier = minor_disease_herpes
			}
			NOR = {
				event_target:sex_partner = { trait = lovers_pox }
				event_target:sex_partner = { has_character_modifier = minor_disease_herpes }
			}
		}
		hidden_tooltip = { event_target:sex_partner = { character_event = { id = 6359 days = 15 random = 5 } } }
	}
	if = {
		limit = {
			OR = {
				event_target:sex_partner = { trait = lovers_pox }
				event_target:sex_partner = { has_character_modifier = minor_disease_herpes }
			}
			NOR = {
				trait = lovers_pox
				has_character_modifier = minor_disease_herpes
			}
		}
		hidden_tooltip = { character_event = { id = 6359 days = 15 random = 5 } }
	}
}

#Tries to impregnate either event_target:sex_partner or THIS if all conditions are met
impregnate_effect_event_target = {
	if = {
		limit = { is_opposite_sex = event_target:sex_partner }

		#If THIS is a female which can get pregnant
		if = {
			limit = {
				is_female = yes
				NOT = { age = 45 }
				is_pregnant = no
				health = 3
				event_target:sex_partner = { NOT = { trait = eunuch } }
			}

			#THIS is not consort/spouse of anyone or is consort/spouse of event_target:sex_partner
			if = {
				limit = {
					OR = {
						AND = {
							is_married = no
							is_consort = no
						}
						AND = {
							is_consort = yes
							consort = { character = event_target:sex_partner }
						}
						AND = {
							is_married = yes
							spouse = { character = event_target:sex_partner }
						}
					}
				}
				event_target:sex_partner = { impregnate = PREV }
			}

			#THIS is consort/spouse of someone else than event_target:sex_partner
			if = {
				limit = {
					OR = {
						 AND = {
							 is_married = yes
							 NOT = { spouse = { character = event_target:sex_partner } }
						 }
						 AND = {
							 is_consort = yes
							 NOT = { consort = { character = event_target:sex_partner } }
						 }
					}
				}
				event_target:sex_partner = { impregnate_cuckoo = PREV }
			}
		}

		#If event_target:sex_partner is a female which can get pregnant
		if = {
			limit = {
				event_target:sex_partner = {
					is_female = yes
					NOT = { age = 45 }
					is_pregnant = no
					health = 3
					PREV = { NOT = { trait = eunuch } }
				}
			}

			#event_target:sex_partner is not consort/spouse of anyone or is consort/spouse of THIS
			if = {
				limit = {
					event_target:sex_partner = {
						OR = {
							AND = {
								is_married = no
								is_consort = no
							}
							AND = {
								is_consort = yes
								consort = { character = PREVPREV }
							}
							AND = {
								is_married = yes
								spouse = { character = PREVPREV }
							}
						}
					}
				}
				impregnate = event_target:sex_partner
			}

			#event_target:sex_partner is consort/spouse of someone else than THIS
			if = {
				limit = {
					event_target:sex_partner = {
						OR = {
							 AND = {
								 is_married = yes
								 NOT = { spouse = { character = PREVPREV } }
							 }
							 AND = {
								 is_consort = yes
								 NOT = { consort = { character = PREVPREV } }
							 }
						}
					}
				}

				impregnate_cuckoo = event_target:sex_partner
			}
		}
	}
}

#Impregnation and venereal disease handling between FROM and ROOT. Used in ROOT scope.
unprotected_sex_effect = {
	random = {
		chance = 50
		venereal_disease_effect = yes
	}
	random = {
		chance = 10
		modifier = {
			factor = 2
			is_fertile_trigger = yes
		}
		modifier = {
			factor = 2
			FROM = { is_fertile_trigger = yes }
		}
		modifier = {
			factor = 0.5
			is_infertile_trigger = yes
		}
		modifier = {
			factor = 0.5
			FROM = { is_infertile_trigger = yes }
		}
		impregnate_effect = yes
	}
}

#Transfers venereal diseases between FROM and ROOT
venereal_disease_effect = {
	#Great pox and aztec disease for FROM
	if = {
		limit = {
			NOR = {
				FROM = { has_character_flag = developing_illness }
				FROM = { has_character_flag = disease_not_serious }
			}
		}

		if = {
			limit = { trait = syphilitic }
			FROM = { give_syphilitic_effect = yes }
		}
		if = {
			limit = { trait = has_aztec_disease }
			FROM = { give_has_aztec_disease_effect = yes }
		}
	}

	#Great pox and aztec disease for ROOT
	if = {
		limit = {
			NOR = {
				has_character_flag = developing_illness
				has_character_flag = disease_not_serious
			}
		}

		if = {
			limit = { FROM = { trait = syphilitic } }
			give_syphilitic_effect = yes
		}
		if = {
			limit = { FROM = { trait = has_aztec_disease } }
			give_has_aztec_disease_effect = yes
		}
	}

	#Lover's pox
	if = {
		limit = {
			OR = {
				trait = lovers_pox
				has_character_modifier = minor_disease_herpes
			}
			NOR = {
				FROM = { trait = lovers_pox }
				FROM = { has_character_modifier = minor_disease_herpes }
			}
		}
		hidden_tooltip = { FROM = { character_event = { id = 6359 days = 15 random = 5 } } }
	}
	if = {
		limit = {
			OR = {
				FROM = { trait = lovers_pox }
				FROM = { has_character_modifier = minor_disease_herpes }
			}
			NOR = {
				trait = lovers_pox
				has_character_modifier = minor_disease_herpes
			}
		}
		hidden_tooltip = { character_event = { id = 6359 days = 15 random = 5 } }
	}
}

#Tries to impregnate either ROOT or FROM if all conditions are met
impregnate_effect = {
	if = {
		limit = { is_opposite_sex = FROM }

		#If ROOT is a female which can get pregnant
		if = {
			limit = {
				is_female = yes
				NOT = { age = 45 }
				is_pregnant = no
				health = 3
				FROM = { NOT = { trait = eunuch } }
			}

			#ROOT is not consort/spouse of anyone or is consort/spouse of FROM
			if = {
				limit = {
					OR = {
						AND = {
							is_married = no
							is_consort = no
						}
						AND = {
							is_consort = yes
							consort = { character = FROM }
						}
						AND = {
							is_married = yes
							spouse = { character = FROM }
						}
					}
				}
				FROM = { impregnate = ROOT }
			}

			#ROOT is consort/spouse of someone else than FROM
			if = {
				limit = {
					OR = {
						 AND = {
							 is_married = yes
							 NOT = { spouse = { character = FROM } }
						 }
						 AND = {
							 is_consort = yes
							 NOT = { consort = { character = FROM } }
						 }
					}
				}
				FROM = { impregnate_cuckoo = ROOT }
			}
		}

		#If FROM is a female which can get pregnant
		if = {
			limit = {
				FROM = {
					is_female = yes
					NOT = { age = 45 }
					is_pregnant = no
					health = 3
					ROOT = { NOT = { trait = eunuch } }
				}
			}

			#FROM is not consort/spouse of anyone or is consort/spouse of ROOT
			if = {
				limit = {
					FROM = {
						OR = {
							AND = {
								is_married = no
								is_consort = no
							}
							AND = {
								is_consort = yes
								consort = { character = ROOT }
							}
							AND = {
								is_married = yes
								spouse = { character = ROOT }
							}
						}
					}
				}
				impregnate = FROM
			}

			#FROM is consort/spouse of someone else than ROOT
			if = {
				limit = {
					FROM = {
						OR = {
							 AND = {
								 is_married = yes
								 NOT = { spouse = { character = ROOT } }
							 }
							 AND = {
								 is_consort = yes
								 NOT = { consort = { character = ROOT } }
							 }
						}
					}
				}

				impregnate_cuckoo = FROM
			}
		}
	}
}

will_not_marry_effect = {
	add_character_modifier = {
		modifier = will_not_marry
		duration = -1
	}
	add_trait = cannot_marry
}

female_councilor_effect_1 = {
	reverse_opinion = {
		modifier = opinion_given_council_position_1
		who = FROM
		years = 5
	}
	add_character_modifier = {
		name = scandalous_councillor_1
		months = 60
	}
}

female_councilor_effect_2 = {
	reverse_opinion = {
		modifier = opinion_given_council_position_2
		who = FROM
		years = 5
	}
	add_character_modifier = {
		name = scandalous_councillor_2
		months = 60
	}
}

female_councilor_effect_3 = {
	reverse_opinion = {
		modifier = opinion_given_council_position_3
		who = FROM
		years = 5
	}
	add_character_modifier = {
		name = scandalous_councillor_3
		months = 60
	}
}

#Use to remove any opinion giving a prison reason. Must set appropriate event targets before using this effect.
remove_prison_reason_effect = {
	event_target:remove_prison_reason_effect_accuser = {
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_traitor }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_rebel_traitor }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_dishonorable }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_regicide_traitor }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = slut_seductress }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = attempted_murder_of_spouse }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = attempted_murder_of_child }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = attempted_murder_of_parent }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = attempted_murder_of_sibling }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = attempted_murder_of_vassal }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = attempted_murder }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_spouse_slayer }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_murder_attempt }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_killed_close_kin }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_killed_father }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_hajj_attempt_murder }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_castrated_me }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_blinded_me }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_castrated_family }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_castrated_close_kin }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_blinded_family }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_blinded_close_kin }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_fatwa_target }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_refused_order }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_witch }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_takfir }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_unfaithful_wife }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_unfaithful_husband_crime }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_unfaithful_husband }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_cuckolded }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_killed_lover }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_charge_heresiarch }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_charge_infidel }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_charge_deviant }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_charge_illegitimate }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_charge_traitor }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_charge_slanderer }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = abuse_of_office }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_tortured_me }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_tortured_family }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_tortured_close_kin }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_mutilated_me }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_mutilated_family }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_mutilated_close_kin }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = mad_heretic }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = attempted_kidnapping }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = attempted_kidnapping_of_kin }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = attempted_kidnapping_of_vassal }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = devious_plotter }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_kidnapped_kin }
		remove_opinion = { who = event_target:remove_prison_reason_effect_accused modifier = opinion_civil_war_loser }
	}
}

add_cat_effect = {
	if = {
		limit =  { NOT = { has_character_modifier = pet_cat } }
		add_character_modifier = {
			name = pet_cat
			duration = -1
		}
		hidden_tooltip = { character_event = { id = 77802 days = 3000 random = 2000 } } # Cat dies
		hidden_tooltip = { character_event = { id = 77861 days = 30 random = 100 } } # Cat & dog
	}
}

add_crusade_trait_effect = {
	if = {
		limit = {
			OR = {
				religion = norse_pagan
				religion = norse_pagan_reformed
			}
		}
		add_trait = valhalla_bound
		break = yes
	}
	if = {
		limit = {
			OR = {
				religion = tengri_pagan
				religion = tengri_pagan_reformed
			}
		}
		add_trait = tengri_warrior
		break = yes
	}
	if = {
		limit = {
			OR = {
				religion = baltic_pagan
				religion = baltic_pagan_reformed
			}
		}
		add_trait = romuvas_own
		break = yes
	}
	if = {
		limit = {
			OR = {
				religion = finnish_pagan
				religion = finnish_pagan_reformed
			}
		}
		add_trait = ukkos_shield
		break = yes
	}
	if = {
		limit = {
			OR = {
				religion = aztec
				religion = aztec_reformed
			}
		}
		add_trait = eagle_warrior
		break = yes
	}
	if = {
		limit = {
			OR = {
				religion = slavic_pagan
				religion = slavic_pagan_reformed
			}
		}
		add_trait = peruns_chosen
		break = yes
	}
	if = {
		limit = {
			OR = {
				religion = west_african_pagan
				religion = west_african_pagan_reformed
			}
		}
		add_trait = nyames_shield
		break = yes
	}
	if = {
		limit = {
			OR = {
				religion = zun_pagan
				religion = zun_pagan_reformed
			}
		}
		add_trait = sun_warrior
		break = yes
	}
	if = {
		limit = {
			OR = {
				religion = hellenic_pagan
				religion = hellenic_pagan_reformed
			}
		}
		add_trait = ares_own
		break = yes
	}
	if = {
		limit = {
			OR = {
				religion = bon
				religion = bon_reformed
			}
		}
		add_trait = kailash_guardian
		break = yes
	}
	if = {
		limit = {
			religion_group = muslim
		}
		add_trait = mujahid
		break = yes
	}
	if = {
		limit = {
			religion_group = christian
		}
		add_trait = crusader
		break = yes
	}
	if = {
		limit = {
			religion_group = zoroastrian_group
		}
		add_trait = gondi_shahansha
		break = yes
	}
	if = {
		limit = {
			religion_group = jewish_group
		}
		add_trait = shaddai
	}
}

###MONKS & MYSTICS###
remove_assassins_debt_effect = {
	if = {
		limit = { has_character_modifier = assassins_debt }
		remove_character_modifier = assassins_debt
		hidden_tooltip = {
			set_variable = { which = assassins_debt value = 0 }
		}
		clr_character_flag = assassins_target_debt
		clear_delayed_event = { id = MNM.6009 }
	}
}

remove_secret_religion_trait_effect = {
	clear_secret_religion = yes
}

pay_back_assassins_effect = {
	if = {
		limit = { is_variable_equal = { which = assassins_debt value = 50 } }
		wealth = -50
		hidden_tooltip = {
			event_target:grand_master  = {
				if = {
					limit = {
						ai = yes
						primary_title = { title = d_hashshashin }
					}
					wealth = 50
				}
			}
		}
	}
	if = {
		limit = { is_variable_equal = { which = assassins_debt value = 250 } }
		wealth = -250
		hidden_tooltip = {
			event_target:grand_master  = {
				if = {
					limit = {
						ai = yes
						primary_title = { title = d_hashshashin }
					}
					wealth = 250
				}
			}
		}
	}
	if = {
		limit = { is_variable_equal = { which = assassins_debt value = 300 } }
		wealth = -300
		hidden_tooltip = {
			event_target:grand_master  = {
				if = {
					limit = {
						ai = yes
						primary_title = { title = d_hashshashin }
					}
					wealth = 300
				}
			}
		}
	}
	if = {
		limit = { is_variable_equal = { which = assassins_debt value = 500 } }
		wealth = -500
		hidden_tooltip = {
			event_target:grand_master = {
				if = {
					limit = {
						ai = yes
						primary_title = { title = d_hashshashin }
					}
					wealth = 500
				}
			}
		}
	}
}

major_soul_corruption_effect = {
	custom_tooltip = {
		text = major_soul_corruption_effect_tooltip
	}
	hidden_effect = {
		if = {
			limit = {
				NAND = {
					trait = cruel
					trait = arbitrary
					trait = deceitful
					trait = possessed
				}
			}
			random_list = {
				20 = {
					modifier = {
						factor = 0
						OR = {
							NOT = { trait = kind }
							trait = cruel
							has_character_flag = corruption_remove_kind
						}
					}
					set_character_flag = corruption_remove_kind
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				20 = {
					modifier = {
						factor = 0
						OR = {
							trait = kind
							trait = cruel
							has_character_flag = corruption_add_cruel
						}
					}
					set_character_flag = corruption_add_cruel
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				15 = {
					modifier = {
						factor = 0
						OR = {
							NOT = { trait = just }
							trait = arbitrary
							has_character_flag = corruption_remove_just
						}
					}
					set_character_flag = corruption_remove_just
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				15 = {
					modifier = {
						factor = 0
						OR = {
							trait = just
							trait = arbitrary
							has_character_flag = corruption_add_arbitrary
						}
					}
					set_character_flag = corruption_add_arbitrary
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				10 = {
					modifier = {
						factor = 0
						OR = {
							NOT = { trait = honest }
							trait = deceitful
							has_character_flag = corruption_remove_honest
						}
					}
					set_character_flag = corruption_remove_honest
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				10 = {
					modifier = {
						factor = 0
						OR = {
							trait = honest
							trait = deceitful
							has_character_flag = corruption_add_deceitful
						}
					}
					set_character_flag = corruption_add_deceitful
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				5 = {
					modifier = {
						factor = 0
						trait = possessed
						has_character_flag = corruption_add_possessed
					}
					set_character_flag = corruption_add_possessed
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				50 = { }
			}
		}
		random_list = { #Risk of getting weaker
			10 = {
				trigger = { NOT = { trait = stressed } }
				character_event = { id = MNM.7051 days = 32 random = 5 }
			}
			5 = {
				trigger = { NOT = { trait = lunatic } }
				character_event = { id = MNM.7052 days = 32 random = 5 }
			}
			5 = {
				trigger = { NOT = { trait = stutter } }
				character_event = { id = MNM.7053 days = 32 random = 5 }
			}
			5 = {
				trigger = { NOT = { trait = clubfooted } }
				character_event = { id = MNM.7054 days = 32 random = 5}
			}
			5 = {
				trigger = { NOT = { trait = hunchback } }
				character_event = { id = MNM.7055 days = 32 random = 5 }
			}
			5 = {
				trigger = { NOT = { trait = ugly } }
				character_event = { id = MNM.7056 days = 32 random = 5 }
			}
			5 = {
				trigger = {
					NOR = {
						trait = feeble
						trait = weak
						trait = strong
					}
				}
				character_event = { id = MNM.7059 days = 32 random = 5 }
			}
			40 = {
				#trigger = {
				#	NOR = {
				#		NOT = { health = 3 }
				#		has_character_modifier = corrupting_magic_minor
				#		has_character_modifier = corrupting_magic_major
				#	}
				#}
				character_event = { id = MNM.7057 days = 32 random = 5 }
			}
			220 = { # High visibility (ability abuse) increases the risk of getting weaker
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 10 }
				}
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 15 }
				}
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 20 }
				}
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 25 }
				}
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 30 }
				}
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 35 }
				}
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 40 }
				}
			}
		}
		random = {
			chance = 2
			set_character_flag = has_it_coming
			character_event = { id = MNM.7854 days = 30 random = 50 } #Demon hunters come after you...
		}
	}
}

minor_soul_corruption_effect = {
	custom_tooltip = {
		text = minor_soul_corruption_effect_tooltip
	}
	hidden_effect = {
		if = {
			limit = {
				NAND = {
					trait = cruel
					trait = arbitrary
					trait = deceitful
					trait = possessed
				}
			}
			random_list = {
				10 = {
					modifier = {
						factor = 0
						OR = {
							NOT = { trait = kind }
							trait = cruel
							has_character_flag = corruption_remove_kind
						}
					}
					set_character_flag = corruption_remove_kind
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				5 = {
					modifier = {
						factor = 0
						OR = {
							trait = kind
							trait = cruel
							has_character_flag = corruption_add_cruel
						}
					}
					set_character_flag = corruption_add_cruel
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				10 = {
					modifier = {
						factor = 0
						OR = {
							NOT = { trait = just }
							trait = arbitrary
							has_character_flag = corruption_remove_just
						}
					}
					set_character_flag = corruption_remove_just
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				5 = {
					modifier = {
						factor = 0
						OR = {
							trait = just
							trait = arbitrary
							has_character_flag = corruption_add_arbitrary
						}
					}
					set_character_flag = corruption_add_arbitrary
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				10 = {
					modifier = {
						factor = 0
						OR = {
							NOT = { trait = honest }
							trait = deceitful
							has_character_flag = corruption_remove_honest
						}
					}
					set_character_flag = corruption_remove_honest
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				5 = {
					modifier = {
						factor = 0
						OR = {
							trait = honest
							trait = deceitful
							has_character_flag = corruption_add_deceitful
						}
					}
					set_character_flag = corruption_add_deceitful
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				5 = {
					modifier = {
						factor = 0
						trait = possessed
						has_character_flag = corruption_add_possessed
					}
					set_character_flag = corruption_add_possessed
					character_event = { id = MNM.7050 days = 3 random = 27 }
				}
				80 = { }
			}
		}
		random_list = { #Risk of getting weaker
			15 = {
				trigger = { NOT = { trait = stressed } }
				character_event = { id = MNM.7051 days = 32 random = 5 }
			}
			5 = {
				trigger = { NOT = { trait = lunatic } }
				character_event = { id = MNM.7052 days = 32 random = 5 }
			}
			5 = {
				trigger = { NOR = { trait = stutter } }
				character_event = { id = MNM.7053 days = 32 random = 5 }
			}
			5 = {
				trigger = { NOR = { trait = clubfooted } }
				character_event = { id = MNM.7054 days = 32 random = 5 }
			}
			5 = {
				trigger = { NOR = { trait = hunchback } }
				character_event = { id = MNM.7055 days = 32 random = 5 }
			}
			5 = {
				trigger = { NOR = { trait = ugly } }
				character_event = { id = MNM.7056 days = 32 random = 5 }
			}
			5 = {
				trigger = {
					NOR = {
						trait = feeble
						trait = weak
						trait = strong
					}
				}
				character_event = { id = MNM.7059 days = 32 random = 5 }
			}
			50 = {
				#trigger = { 
				#	NOR = { 
				#		NOT = { health = 3 }
				#		has_character_modifier = corrupting_magic_minor
				#		has_character_modifier = corrupting_magic_major
				#	}
				#}
				character_event = { id = MNM.7058 days = 32 random = 5 }
			}
			450 = {  # High visibility (ability abuse) increases the risk of getting weaker
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 10 }
				}
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 15 }
				}
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 20 }
				}
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 25 }
				}
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 30 }
				}
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 35 }
				}
				modifier = {
					factor = 0.9
					check_variable = { which = visibility_value value = 40 }
				}
			}
		}
	}
}

add_society_currency_trivial_effect = {
	if = {
		limit = { is_in_society = yes }
		change_society_currency = 10
	}
}

add_society_currency_tiny_effect = {
	if = {
		limit = { is_in_society = yes }
		change_society_currency = 50
	}
}

add_society_currency_minor_effect = {
	if = {
		limit = { is_in_society = yes }
		change_society_currency = 100
	}
}

add_society_currency_medium_effect = {
	if = {
		limit = { is_in_society = yes }
		change_society_currency = 200
	}
}

add_society_currency_major_effect = {
	if = {
		limit = { is_in_society = yes }
		change_society_currency = 300
	}
}

add_society_currency_large_effect = {
	if = {
		limit = { is_in_society = yes }
		change_society_currency = 500
	}
}

add_society_currency_massive_effect = {
	if = {
		limit = { is_in_society = yes }
		change_society_currency = 1000
	}
}

detract_society_currency_trivial_effect = {
	if = {
		limit = { is_in_society = yes }
		change_society_currency = -15
	}
}

detract_society_currency_tiny_effect = {
	if = {
		limit = { is_in_society = yes }
		change_society_currency = -50
	}
}

detract_society_currency_minor_effect = {
	if = {
		limit = { is_in_society = yes }
		change_society_currency = -150
	}
}

detract_society_currency_medium_effect = {
	if = {
		limit = { is_in_society = yes }
		change_society_currency = -300
	}
}

detract_society_currency_major_effect = {
	if = {
		limit = { is_in_society = yes }
		change_society_currency = -500
	}
}

remove_random_maimed_effect = { #remember to clear flags if using this effect :D
	random_list = {
		40 = {
			modifier = {
				NOT = { trait = maimed }
				factor = 0
			}
			set_character_flag = removed_maimed
		}
		40 = {
			modifier = {
				NOT = {trait = mangled}
				factor = 0
			}
			set_character_flag = removed_mangled
		}
		10 = {
			modifier = {
				NOT = {trait = one_eyed}
				factor = 0
			}
			set_character_flag = removed_one_eyed
		}
		10 = {
			modifier = {
				NOT = {trait = one_handed}
				factor = 0
			}
			set_character_flag = removed_one_handed
		}
		10 = {
			modifier = {
				NOT = {trait = one_legged}
				factor = 0
			}
			set_character_flag = removed_one_legged
		}
		5 = {
			modifier = {
				NOT = {trait = disfigured}
				factor = 0
			}
			set_character_flag = removed_disfigured
		}
	}
}

remove_random_disease_effect = { # Do actual trait removal in event. This is a clunky solution, but communication to player has been prioritised for the sake of event MNM.7119
	random_list = {
		40 = {
			modifier = {
				NOT = { trait = flu }
				factor = 0
			}
			set_character_flag = removing_flu
		}
		20 = {
			modifier = {
				NOT = { trait = has_measles }
				factor = 0
			}
			set_character_flag = removing_measles
		}
		40 = {
			modifier = {
				NOT = {
					trait = food_poisoning
				}
				factor = 0
			}
			set_character_flag = removing_food_poisoning
		}
		20 = {
			modifier = {
				NOT = { trait = gout }
				factor = 0
			}
			set_character_flag = removing_gout
		}
		40 = {
			modifier = {
				NOT = { trait = scurvy }
				factor = 0
			}
			set_character_flag = removing_scurvy
		}
		20 = {
			modifier = {
				NOT = { trait = lovers_pox }
				factor = 0
			}
			set_character_flag = removing_lovers_pox
		}
		5 = {
			modifier = {
				NOT = { trait = cancer }
				factor = 0
			}
			set_character_flag = removing_cancer
		}
		10 = {
			modifier = {
				NOT = { trait = pneumonic }
				factor = 0
			}
			set_character_flag = removing_pneumonic
		}
		10 = {
			modifier = {
				NOT = { trait = syphilitic }
				factor = 0
			}
			set_character_flag = removing_syphilitic
		}
		5 = {
			modifier = {
				NOT = { trait = leper }
				factor = 0
			}
			set_character_flag = removing_leper
		}
	}
}

remove_random_epidemic_disease_effect = {
	random_list = {
		10 = {
			modifier = {
				NOT = { trait = has_tuberculosis}
				factor = 0
			}
			set_character_flag = removing_has_tuberculosis
		}
		10 = {
			modifier = {
				NOT = { trait = has_aztec_disease}
				factor = 0
			}
			set_character_flag = removing_has_aztec_disease
		}
		10 = {
			modifier = {
				NOT = { trait = has_small_pox}
				factor = 0
			}
			set_character_flag = removing_has_small_pox
		}
		10 = {
			modifier = {
				NOT = { trait = has_bubonic_plague}
				factor = 0
			}
			set_character_flag = removing_has_bubonic_plague
		}
		10 = {
			modifier = {
				NOT = { trait = has_typhus}
				factor = 0
			}
			set_character_flag = removing_has_typhus
		}
		10 = {
			modifier = {
				NOT = { trait = has_typhoid_fever}
				factor = 0
			}
			set_character_flag = removing_has_typhoid_fever
		}
		10 = {
			modifier = {
				NOT = { trait = has_measles}
				factor = 0
			}
			set_character_flag = removing_measles
		}

	}
}

remove_symptoms_effect = {
	if = {
		limit = { trait = cough}
		remove_trait = cough
	}
	if = {
		limit = { trait = fever}
		remove_trait = fever
	}
	if = {
		limit = { trait = diarrhea}
		remove_trait = diarrhea
	}
	if = {
		limit = { trait = vomiting}
		remove_trait = vomiting
	}
	if = {
		limit = { trait = chest_pain}
		remove_trait = chest_pain
	}
	if = {
		limit = { trait = cramps}
		remove_trait = cramps
	}
	if = {
		limit = { trait = rash}
		remove_trait = rash
	}
	if = {
		limit = { trait = headache}
		remove_trait = headache
	}
	if = {
		limit = { trait = abdominal_pain}
		remove_trait = abdominal_pain
	}
	if = {
		limit = { trait = fatigue}
		remove_trait = fatigue
	}
	if = {
		limit = { trait = malaise}
		remove_trait = malaise
	}
}

remove_random_negative_congenital_effect = {
	random_list = {
		10 = {
			modifier = {
				NOT = { trait = clubfooted }
				factor = 0
			}
			remove_trait = clubfooted
		}
		10 = {
			modifier = {
				NOT = { trait = harelip }
				factor = 0
			}
			remove_trait = harelip
		}
		10 = {
			modifier = {
				NOT = { trait = hunchback }
				factor = 0
			}
			remove_trait = hunchback
		}
		10 = {
			modifier = {
				NOT = { trait = lisp }
				factor = 0
			}
			remove_trait = lisp
		}
		10 = {
			modifier = {
				NOT = { trait = stutter }
				factor = 0
			}
			remove_trait = stutter
		}
		10 = {
			modifier = {
				NOT = { trait = ugly }
				factor = 0
			}
			remove_trait = ugly
		}
		10 = {
			modifier = {
				NOT = { trait = dwarf }
				factor = 0
			}
			remove_trait = dwarf
		}
		10 = {
			modifier = {
				NOT = { trait = giant }
				factor = 0
			}
			remove_trait = giant
		}
		10 = {
			modifier = {
				NOT = { trait = slow }
				factor = 0
			}
			remove_trait = slow
		}
		10 = {
			modifier = {
				NOT = { trait = imbecile }
				factor = 0
			}
			remove_trait = imbecile
		}
		10 = {
			modifier = {
				NOT = { trait = inbred }
				factor = 0
			}
			remove_trait = inbred
		}
		10 = {
			modifier = {
				NOT = { trait = weak }
				factor = 0
			}
			remove_trait = weak
		}
	}
}

remove_all_negative_congenital_traits_effect = {
	if = {
		limit = { trait = ugly }
		remove_trait = ugly
	}
	if = {
		limit = { trait = clubfooted }
		remove_trait = clubfooted
	}
	if = {
		limit = { trait = hunchback }
		remove_trait = hunchback
	}
	if = {
		limit = { trait = dwarf }
		remove_trait = dwarf
	}
	if = {
		limit = { trait = giant }
		remove_trait = giant
	}
	if = {
		limit = { trait = harelip }
		remove_trait = harelip
	}
	if = {
		limit = { trait = stutter }
		remove_trait = stutter
	}
	if = {
		limit = { trait = lisp }
		remove_trait = lisp
	}
	if = {
		limit = { trait = slow }
		remove_trait = slow
	}
	if = {
		limit = { trait = inbred }
		remove_trait = inbred
	}
	if = {
		limit = { trait = weak }
		remove_trait = weak
	}
	if = {
		limit = { trait = imbecile }
		remove_trait = imbecile
	}
}

join_from_devil_worshiper_society_effect = {
	FROM = {
		if = {
			limit = {
				society_member_of = the_satanists
			}
			ROOT = {
				join_society = the_satanists
			}
		}
		if = {
			limit = {
				society_member_of = the_cold_ones
			}
			ROOT = {
				join_society = the_cold_ones
			}
		}
		if = {
			limit = {
				society_member_of = the_plaguebringers
			}
			ROOT = {
				join_society = the_plaguebringers
			}
		}
		if = {
			limit = {
				society_member_of = the_cult_of_kali
			}
			ROOT = {
				join_society = the_cult_of_kali
			}
		}
		if = {
			limit = {
				society_member_of = the_trollcrafters
			}
			ROOT = {
				join_society = the_trollcrafters
			}
		}
		if = {
			limit = {
				society_member_of = the_bacchants
			}
			ROOT = {
				join_society = the_bacchants
			}
		}
		if = {
			limit = {
				society_member_of = the_vodouns
			}
			ROOT = {
				join_society = the_vodouns
			}
		}
	}
}

remove_demonic_blessing_effect = {
	if = { limit = { has_character_modifier = blessing_of_azazel }
		remove_character_modifier = blessing_of_azazel
	}
	if = { limit = { has_character_modifier = blessing_of_avnas }
		remove_character_modifier = blessing_of_avnas
	}
	if = { limit = { has_character_modifier = blessing_of_belial }
		remove_character_modifier = blessing_of_belial
	}
	if = { limit = { has_character_modifier = blessing_of_mammon }
		remove_character_modifier = blessing_of_mammon
	}
	if = { limit = { has_character_modifier = blessing_of_vetis }
		remove_character_modifier = blessing_of_vetis
	}
}

add_prolong_life_effect = {
	if = {
		limit = {
			NOR = {
				has_character_modifier = stolen_life_minor
				has_character_modifier = stolen_life_medium
				has_character_modifier = stolen_life_major
			}
		}
		random_list = {
			10 = {
				add_character_modifier = {
					name = stolen_life_minor
					days = 3650
				}
			}
			10 = {
				add_character_modifier = {
					name = stolen_life_medium
					days = 3650
				}
			}
			10 = {
				add_character_modifier = {
					name = stolen_life_major
					days = 3650
				}
			}
		}
		break = yes
	}
	if = {
		limit = {
			OR = {
				has_character_modifier = stolen_life_minor
				has_character_modifier = stolen_life_medium
			}
		}
		hidden_effect = {
			remove_character_modifier = stolen_life_minor
			remove_character_modifier = stolen_life_medium
		}
		add_character_modifier = {
					name = stolen_life_major
					days = 3650
		}
		break = yes
	}
	add_character_modifier = {
		name = stolen_life_major
		days = 3650
	}
}

join_prev_devil_worshiper_society_effect = {
	if = {
		limit = { PREV = { society_member_of = the_satanists } }
		join_society = the_satanists
	}
	if = {
		limit = { PREV = { society_member_of = the_cold_ones } }
		join_society = the_cold_ones
	}
	if = {
		limit = { PREV = { society_member_of = the_plaguebringers } }
		join_society = the_plaguebringers
	}
	if = {
		limit = { PREV = { society_member_of = the_cult_of_kali } }
		join_society = the_cult_of_kali
	}
	if = {
		limit = { PREV = { society_member_of = the_trollcrafters } }
		join_society = the_trollcrafters
	}
	if = {
		limit = { PREV = { society_member_of = the_bacchants } }
		join_society = the_bacchants
	}
	if = {
		limit = { PREV = { society_member_of = the_vodouns } }
		join_society = the_vodouns
	}
}

join_prev_warrior_lodge_society_effect = {
	if = {
		limit = { PREV = { society_member_of = warrior_lodge_norse } }
		join_society = warrior_lodge_norse
	}
	if = {
		limit = { PREV = { society_member_of = warrior_lodge_tengri } }
		join_society = warrior_lodge_tengri
	}
	if = {
		limit = { PREV = { society_member_of = warrior_lodge_baltic } }
		join_society = warrior_lodge_baltic
	}
	if = {
		limit = { PREV = { society_member_of = warrior_lodge_finnish } }
		join_society = warrior_lodge_finnish
	}
	if = {
		limit = { PREV = { society_member_of = warrior_lodge_slavic } }
		join_society = warrior_lodge_slavic
	}
	if = {
		limit = { PREV = { society_member_of = warrior_lodge_west_african } }
		join_society = warrior_lodge_west_african
	}
	if = {
		limit = { PREV = { society_member_of = warrior_lodge_zun } }
		join_society = warrior_lodge_zun
	}
	if = {
		limit = { PREV = { society_member_of = warrior_lodge_bon } }
		join_society = warrior_lodge_bon
	}
	if = {
		limit = { PREV = { society_member_of = warrior_lodge_hellenic } }
		join_society = warrior_lodge_hellenic
	}
}

give_this_warrior_lodge_religion_effect = { #Mostly for spawned characters.
	if = {
		limit = { 
			society_member_of = warrior_lodge_norse 
			NOT = { has_global_flag = norse_reformation }
		}
		religion = norse_pagan
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_norse 
			has_global_flag = norse_reformation
		}
		religion = norse_pagan_reformed
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_tengri 
			NOT = { has_global_flag = tengri_reformation }
		}
		religion = tengri_pagan
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_tengri 
			has_global_flag = tengri_reformation
		}
		religion = tengri_pagan_reformed
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_baltic 
			NOT = { has_global_flag = baltic_reformation }
		}
		religion = baltic_pagan
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_baltic 
			has_global_flag = baltic_reformation
		}
		religion = baltic_pagan_reformed
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_finnish 
			NOT = { has_global_flag = finnish_reformation }
		}
		religion = finnish_pagan
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_finnish 
			has_global_flag = finnish_reformation
		}
		religion = finnish_pagan_reformed
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_slavic 
			NOT = { has_global_flag = slavic_reformation }
		}
		religion = slavic_pagan
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_slavic 
			has_global_flag = slavic_reformation
		}
		religion = slavic_pagan_reformed
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_west_african 
			NOT = { has_global_flag = west_african_reformation }
		}
		religion = west_african_pagan
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_west_african 
			has_global_flag = west_african_reformation
		}
		religion = west_african_pagan_reformed
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_zun 
			NOT = { has_global_flag = zun_reformation }
		}
		religion = zun_pagan
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_zun 
			has_global_flag = zun_reformation
		}
		religion = zun_pagan_reformed
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_bon 
			NOT = { has_global_flag = bon_reformation }
		}
		religion = bon
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_bon 
			has_global_flag = bon_reformation
		}
		religion = bon_reformed
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_hellenic 
			NOT = { has_global_flag = hellenic_reformation }
		}
		religion = hellenic_pagan
	}
	if = {
		limit = { 
			society_member_of = warrior_lodge_hellenic 
			has_global_flag = hellenic_reformation
		}
		religion = hellenic_pagan_reformed
	}
}

remove_education_effect = {
	remove_trait = naive_appeaser
	remove_trait = underhanded_rogue
	remove_trait = charismatic_negotiator
	remove_trait = grey_eminence
	remove_trait = misguided_warrior
	remove_trait = tough_soldier
	remove_trait = skilled_tactician
	remove_trait = brilliant_strategist
	remove_trait = indulgent_wastrel
	remove_trait = thrifty_clerk
	remove_trait = fortune_builder
	remove_trait = midas_touched
	remove_trait = amateurish_plotter
	remove_trait = flamboyant_schemer
	remove_trait = intricate_webweaver
	remove_trait = elusive_shadow
	remove_trait = detached_priest
	remove_trait = martial_cleric
	remove_trait = scholarly_theologian
	remove_trait = mastermind_theologian
}

remove_lifestyle_trait_effect = {
	remove_trait = hedonist
	remove_trait = scholar
	remove_trait = gardener
	remove_trait = mystic
	remove_trait = impaler
	remove_trait = duelist
	remove_trait = hunter
	remove_trait = seducer
	remove_trait = seductress
	remove_trait = administrator
	remove_trait = architect
	remove_trait = strategist
	remove_trait = socializer
	remove_trait = schemer
	remove_trait = theologian
	remove_trait = gamer
}

monastic_order_purity_effect = {
	if = {
		limit = {
			is_monastic_member_trigger = yes
			OR = {
				trait = cynical
				trait = gluttonous
				trait = greedy
				trait = slothful
				trait = envious
				trait = wroth
				trait = proud
				trait = deceitful
				trait = cruel
				AND = {
					trait = lustful
					NOT = { religion = hindu }
				}
				trait = ambitious
				NOT = { trait = humble }
				NOT = { trait = charitable }
				NOT = { trait = kind }
				NOT = { trait = temperate }
				NOT = { trait = honest }
				NAND = {
					trait = chaste
					NOT = { religion = hindu }
				}
				NOT = { trait = patient }
				NOT = { trait = diligent }
				NOT = { trait = content }
			}
		}

		random = {
			chance = 20
			modifier = {
				factor = 1.3
				society_rank == 2
			}
			modifier = {
				factor = 1.5
				society_rank == 3
			}
			modifier = {
				factor = 1.7
				society_rank == 4
			}
			modifier = {
				factor = 1.1
				piety = 100
			}
			modifier = {
				factor = 1.3
				piety = 300
			}
			modifier = {
				factor = 1.5
				piety = 500
			}
			modifier = {
				factor = 2
				piety = 1000
			}
			character_event = { id = MNM.4400 days = 10 random = 10 }
		}
	}
}

join_prev_monastic_order_society = {
	if = {
		limit = { PREV = { society_member_of = monastic_order_orthodox } }
		join_society = monastic_order_orthodox
	}
	if = {
		limit = { PREV = { society_member_of = monastic_order_benedictine } }
		join_society = monastic_order_benedictine
	}
	if = {
		limit = { PREV = { society_member_of = monastic_order_dominican } }
		join_society = monastic_order_dominican
	}
	if = {
		limit = { PREV = { society_member_of = monastic_order_nestorian } }
		join_society = monastic_order_nestorian
	}
	if = {
		limit = { PREV = { society_member_of = monastic_order_monophysite } }
		join_society = monastic_order_monophysite
	}
	if = {
		limit = { PREV = { society_member_of = monastic_order_hindu } }
		join_society = monastic_order_hindu
	}
	if = {
		limit = { PREV = { society_member_of = monastic_order_buddhist } }
		join_society = monastic_order_buddhist
	}
	if = {
		limit = { PREV = { society_member_of = monastic_order_jain } }
		join_society = monastic_order_jain
	}
	if = {
		limit = { PREV = { society_member_of = monastic_order_stoics } }
		join_society = monastic_order_stoics
	}
}

clr_artifact_flagsmodifiers_effect = {
	event_target:relic_ruler = {
		if = {
			limit = { has_character_modifier = relic_rumor_minor }
			remove_character_modifier = relic_rumor_minor
		}
		if = {
			limit = { has_character_modifier = relic_rumor_medium }
			remove_character_modifier = relic_rumor_medium
		}
		if = {
			limit = { has_character_modifier = relic_rumor_major }
			remove_character_modifier = relic_rumor_major
		}
	}
	clr_artifact_searcher_effect = yes
}

clr_artifact_searcher_effect = {
	event_target:relic_ruler = {
		if = {
			limit = { has_character_modifier = pays_for_artifact_hunt_minor }
			remove_character_modifier = pays_for_artifact_hunt_minor
		}
		if = {
			limit = { has_character_modifier = pays_for_artifact_hunt_medium }
			remove_character_modifier = pays_for_artifact_hunt_medium
		}
		if = {
			limit = { has_character_modifier = pays_for_artifact_hunt_major }
			remove_character_modifier = pays_for_artifact_hunt_major
		}
		# from the progress events....
		if = {
			limit = { has_character_modifier = treasure_hunting_diplomats }
			remove_character_modifier = treasure_hunting_diplomats
		}
		if = {
			limit = { has_character_modifier = treasure_hunting_soldiers }
			remove_character_modifier = treasure_hunting_soldiers
		}
		if = {
			limit = { has_character_modifier = treasure_hunting_stewards }
			remove_character_modifier = treasure_hunting_stewards
		}
		if = {
			limit = { has_character_modifier = treasure_hunting_spies }
			remove_character_modifier = treasure_hunting_spies
		}
		if = {
			limit = { has_character_modifier = treasure_hunting_scholars }
			remove_character_modifier = treasure_hunting_scholars
		}
		clr_character_flag = they_asked_for_your_help
	}
	hidden_effect = {
		event_target:relic_hunter = { clr_character_flag = relic_hunter }
	}
}

add_artifact_search_payment_effect = {
	if = {
		limit = { has_character_modifier = relic_rumor_minor }
		add_character_modifier =  { name = pays_for_artifact_hunt_minor duration = -1 }
	}
	if = {
		limit = { has_character_modifier = relic_rumor_medium }
		add_character_modifier =  { name = pays_for_artifact_hunt_medium duration = -1 }
	}
	if = {
		limit = { has_character_modifier = relic_rumor_major }
		add_character_modifier =  { name = pays_for_artifact_hunt_major duration = -1 }
	}
}

random_accident_death_effect = {
	tooltip = { death = { death_reason = death_accident } }
	hidden_effect = {
		random_list = {
			10 = {
				modifier = { factor = 0 host = { capital_scope = { region = world_africa } } }
				death = { death_reason = death_accident_drowning }
			}
			10 = {
				modifier = { factor = 0 host = { capital_scope = { region = world_africa } } }
				death = { death_reason = death_accident_bear }
			}
			10 = {
				death = { death_reason = death_accident_boar }
			}
			10 = {
				death = { death_reason = death_accident_fall }
			}
			10 = {
				death = { death_reason = death_accident_arrow }
			}
			10 = {
				death = { death_reason = death_accident_snakes }
			}
			10 = {
				modifier = { factor = 0 host = { capital_scope = { region = world_india } } }
				death = { death_reason = death_accident_tiger }
			}
		}
	}
}

spawn_peasant_army_effect = {
	if = {
		limit = {
			has_game_rule = {
				name = provincial_revolt_strength
				value = default
			}
		}
		random_list = {
			17 = {			  
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 0.75
					troops = {
						archers = { 6 6 }
						light_cavalry = { 4 4 }
						light_infantry = { 10 10 }
					}
					attrition = 1.0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			17 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 0.5
					troops = {
						archers = { 6 6 }
						light_cavalry = { 4 4 }
						light_infantry = { 10 10 }
					}
					attrition = 1.0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			16 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 0.75
					troops = {
						archers = { 6 6 }
						light_cavalry = { 3 3 }
						light_infantry = { 11 11 }
					}
					attrition = 1.0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			17 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 0.5
					troops = {
						archers = { 6 6 }
						light_cavalry = { 3 3 }
						light_infantry = { 11 11 }
					}
					attrition = 1.0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			16 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 0.75
					troops = {
						archers = { 6 6 }
						light_infantry = { 14 14 }
					}
					attrition = 1.0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			17 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 0.5
					troops = {
						archers = { 6 6 }
						light_infantry = { 14 14 }
					}
					attrition = 1.0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
		}
	}
	if = {
		limit = {
			NOT = {
				has_game_rule = {
					name = provincial_revolt_strength
					value = default
				}
			}
		}
		random_list = {
			17 = {			  
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 0.75
					troops = {
						archers = { 6 6 }
						light_cavalry = { 4 4 }
						light_infantry = { 10 10 }
					}
					attrition = 0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			17 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 0.5
					troops = {
						archers = { 6 6 }
						light_cavalry = { 4 4 }
						light_infantry = { 10 10 }
					}
					attrition = 0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			16 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 0.75
					troops = {
						archers = { 6 6 }
						light_cavalry = { 3 3 }
						light_infantry = { 11 11 }
					}
					attrition = 0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			17 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 0.5
					troops = {
						archers = { 6 6 }
						light_cavalry = { 3 3 }
						light_infantry = { 11 11 }
					}
					attrition = 0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			16 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 0.75
					troops = {
						archers = { 6 6 }
						light_infantry = { 14 14 }
					}
					attrition = 0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			17 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 0.5
					troops = {
						archers = { 6 6 }
						light_infantry = { 14 14 }
					}
					attrition = 0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
		}
	}
}

spawn_peasant_reinforcements_effect = {
	if = {
		limit = {
			has_game_rule = {
				name = provincial_revolt_strength
				value = default
			}
		}
		random_list = {
			17 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			17 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			16 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 1.0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			17 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 1.0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			16 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			17 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
		}
	}
	if = {
		limit = {
			NOT = {
				has_game_rule = {
					name = provincial_revolt_strength
					value = default
				}
			}
		}
		random_list = {
			17 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			17 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			16 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			17 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_cavalry = { 3 3 }
							light_infantry = { 11 11 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			16 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.75
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			17 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 31
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 0.5
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
		}
	}
}

spawn_heretic_army_effect = {
	if = {
		limit = {
			has_game_rule = {
				name = provincial_revolt_strength
				value = default
			}
		}
		random_list = {
			34 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 1.0
					troops = {
						archers = { 6 6 }
						light_cavalry = { 4 4 }
						light_infantry = { 10 10 }
					}
					attrition = 1.0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 1.0
					troops = {
						archers = { 6 6 }
						light_cavalry = { 2 2 }
						light_infantry = { 12 12 }
					}
					attrition = 1.0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 1.0
					troops = {
						archers = { 6 6 }
						light_infantry = { 14 14 }
					}
					attrition = 1.0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
		}
	}
	if = {
		limit = {
			NOT = {
				has_game_rule = {
					name = provincial_revolt_strength
					value = default
				}
			}
		}
		random_list = {
			34 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 1.0
					troops = {
						archers = { 6 6 }
						light_cavalry = { 4 4 }
						light_infantry = { 10 10 }
					}
					attrition = 0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 1.0
					troops = {
						archers = { 6 6 }
						light_cavalry = { 2 2 }
						light_infantry = { 12 12 }
					}
					attrition = 0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 1.0
					troops = {
						archers = { 6 6 }
						light_infantry = { 14 14 }
					}
					attrition = 0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
		}
	}
}

spawn_heretic_reinforcements_effect = {
	if = {
		limit = {
			has_game_rule = {
				name = provincial_revolt_strength
				value = default
			}
		}
		random_list = {
			34 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 1.0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
		}
	}
	if = {
		limit = {
			NOT = {
				has_game_rule = {
					name = provincial_revolt_strength
					value = default
				}
			}
		}
		random_list = {
			34 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
		}
	}
}

spawn_nationalist_army_effect = {
	create_character = {
		random_traits = yes
		dynasty = none
		religion = ROOT
		culture = ROOT
		female = no
		age = 34
		attributes = {
			martial = 7
		}
		trait = skilled_tactician
	}
	new_character = {
		emf_new_character_noble = yes
		spawn_unit = {
			province = ROOT
			home = ROOT
			owner = PREV
			#leader = THIS
			scaled_by_biggest_garrison = 1.75
			troops = {
				archers = { 6 6 }
				light_cavalry = { 3 3 }
				knights = { 1 1 }
				light_infantry = { 7 7 }
				heavy_infantry = { 3 3 }
			}
		}
	}

	create_character = {
		random_traits = yes
		dynasty = none
		religion = ROOT
		culture = ROOT
		female = no
		age = 23
		attributes = {
			martial = 7
		}
		trait = skilled_tactician
	}
	new_character = {
		emf_new_character_noble = yes
		spawn_unit = {
			province = ROOT
			home = ROOT
			owner = PREV
			#leader = THIS
			scaled_by_biggest_garrison = 1.75
			troops = {
				archers = { 6 6 }
				light_cavalry = { 3 3 }
				knights = { 1 1 }
				light_infantry = { 7 7 }
				heavy_infantry = { 3 3 }
			}
		}
	}
}

spawn_nationalist_reinforcements_effect = {
	create_character = {
		random_traits = yes
		dynasty = none
		religion = ROOT
		culture = ROOT
		female = no
		age = 24
		attributes = {
			martial = 7
		}
		trait = skilled_tactician
	}
	new_character = {
		emf_new_character_noble = yes
		spawn_unit = {
			province = ROOT
			home = ROOT
			owner = PREV
			#leader = THIS
			scaled_by_biggest_garrison = 1.75
			troops = {
				archers = { 6 6 }
				light_cavalry = { 3 3 }
				knights = { 1 1 }
				light_infantry = { 7 7 }
				heavy_infantry = { 3 3 }
			}
		}
	}
	create_character = {
		random_traits = yes
		dynasty = none
		religion = ROOT
		culture = ROOT
		female = no
		age = 27
		attributes = {
			martial = 7
		}
		trait = skilled_tactician
	}
	new_character = {
		emf_new_character_noble = yes
		spawn_unit = {
			province = ROOT
			home = ROOT
			owner = PREV
			#leader = THIS
			scaled_by_biggest_garrison = 1.75
			troops = {
				archers = { 6 6 }
				light_cavalry = { 3 3 }
				knights = { 1 1 }
				light_infantry = { 7 7 }
				heavy_infantry = { 3 3 }
			}
		}
	}
	create_character = {
		random_traits = yes
		dynasty = none
		religion = ROOT
		culture = ROOT
		female = no
		age = 30
		attributes = {
			martial = 7
		}
		trait = skilled_tactician
	}
	new_character = {
		emf_new_character_noble = yes
		spawn_unit = {
			province = ROOT
			home = ROOT
			owner = PREV
			#leader = THIS
			scaled_by_biggest_garrison = 1.75
			troops = {
				archers = { 6 6 }
				light_cavalry = { 3 3 }
				knights = { 1 1 }
				light_infantry = { 7 7 }
				heavy_infantry = { 3 3 }
			}
		}
	}
}

spawn_religious_army_effect = {
	if = {
		limit = {
			has_game_rule = {
				name = provincial_revolt_strength
				value = default
			}
		}
		random_list = {
			34 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 1.0
					troops = {
						archers = { 6 6 }
						light_cavalry = { 4 4 }
						light_infantry = { 10 10 }
					}
					attrition = 1.0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 1.0
					troops = {
						archers = { 6 6 }
						light_cavalry = { 2 2 }
						light_infantry = { 12 12 }
					}
					attrition = 1.0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 1.0
					troops = {
						archers = { 6 6 }
						light_infantry = { 14 14 }
					}
					attrition = 1.0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
		}
	}
	if = {
		limit = {
			NOT = {
				has_game_rule = {
					name = provincial_revolt_strength
					value = default
				}
			}
		}
		random_list = {
			34 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 1.0
					troops = {
						archers = { 6 6 }
						light_cavalry = { 4 4 }
						light_infantry = { 10 10 }
					}
					attrition = 0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 1.0
					troops = {
						archers = { 6 6 }
						light_cavalry = { 2 2 }
						light_infantry = { 12 12 }
					}
					attrition = 0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				spawn_unit = {
					province = ROOT
					home = ROOT
					owner = THIS
					#leader = THIS
					scaled_by_biggest_garrison = 1.0
					troops = {
						archers = { 6 6 }
						light_infantry = { 14 14 }
					}
					attrition = 0
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
		}
	}
}

spawn_religious_reinforcements_effect = {
	if = {
		limit = {
			has_game_rule = {
				name = provincial_revolt_strength
				value = default
			}
		}
		random_list = {
			34 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 1.0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 1.0
						disband_on_peace = yes
					}
				}
			}
		}   
	}
	if = {
		limit = {
			NOT = {
				has_game_rule = {
					name = provincial_revolt_strength
					value = default
				}
			}
		}
		random_list = {
			34 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 4 4 }
							light_infantry = { 10 10 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_cavalry = { 2 2 }
							light_infantry = { 12 12 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
			33 = {
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 25
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 30
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
				create_character = {
					random_traits = yes
					dynasty = none
					religion = THIS
					culture = THIS
					female = no
					age = 23
					trait = peasant_leader
					trait = tough_soldier
				}
				new_character = {
					emf_new_character = yes
					spawn_unit = {
						province = ROOT
						home = ROOT
						owner = PREV
						scaled_by_biggest_garrison = 1.0
						troops = {
							archers = { 6 6 }
							light_infantry = { 14 14 }
						}
						attrition = 0
						disband_on_peace = yes
					}
				}
			}
		}
	}
}

add_ascetic_trait_effect = {
	if = {
		limit = { is_female = yes }
		if = {
			limit = {
				religion_group = christian
				NOT = { religion = miaphysite }
			}
			add_trait = nun
		}
		else_if = {
			limit = { religion = miaphysite }
			add_trait = desert_mother
		}
		else_if = {
			limit = { religion = jain }
			add_trait = aryika
		}
		else_if = {
			limit = { religion = buddhist }
			add_trait = bhikkhuni
		}
		else_if = {
			limit = { religion = hindu }
			add_trait = sanyasini
		}
	}
	if = {
		limit = { is_female = no }
		if = {
			limit = { religion = miaphysite }
			add_trait = desert_father
		}
		else_if = {
			limit = { religion_group = christian }
			add_trait = monk
		}
		else_if = {
			limit = { religion = jain }
			add_trait = muni
		}
		else_if = {
			limit = { religion = buddhist }
			add_trait = bhikkhu
		}
		else_if = {
			limit = { religion = hindu }
			add_trait = sanyasi
		}
	}
}

print_scope_effect = {
	log = "------------------------------"
	log = "- Printing the current scope -"
	log = "- This: [This.GetName][This.GetBestName]"
	log = "- Root: [Root.GetName][Root.GetBestName]"
	log = "- Prev: [Prev.GetName][Prev.GetBestName]"
	log = "- PrevPrev: [PrevPrev.GetName][PrevPrev.GetBestName]"
	log = "- PrevPrevPrev: [PrevPrevPrev.GetName][PrevPrevPrev.GetBestName]"
	log = "- PrevPrevPrevPrev: [PrevPrevPrevPrev.GetName][PrevPrevPrevPrev.GetBestName]"
	log = "- From: [From.GetName][From.GetBestName]"
	log = "- FromFrom: [FromFrom.GetName][FromFrom.GetBestName]"
	log = "- FromFromFrom: [FromFromFrom.GetName][FromFromFrom.GetBestName]"
	log = "- FromFromFromFrom: [FromFromFromFrom.GetName][FromFromFromFrom.GetBestName]"
	log = "- Event_target:test_target1: [test_target1.GetName][test_target1.GetBestName]"
	log = "- Event_target:test_target2: [test_target2.GetName][test_target2.GetBestName]"
	log = "- Event_target:test_target3: [test_target3.GetName][test_target3.GetBestName]"
	log = "------------------------------"
}

add_sympathy_for_prevs_true_religion_effect = {
	if = {
		limit = { 
			PREV = { true_religion_group_christian_trigger = yes } 
			NOT = { religion_group = christian }
		}
		add_trait = sympathy_christendom
	}
	if = {
		limit = { 
			PREV = { true_religion_group_muslim_trigger = yes } 
			NOT = { religion_group = muslim }
		}
		add_trait = sympathy_islam
	}
	if = {
		limit = { 
			PREV = { true_religion_group_pagan_group_trigger = yes } 
			NOT = { religion_group = pagan_group }
		}
		add_trait = sympathy_pagans
	}
	if = {
		limit = { 
			PREV = { true_religion_group_zoroastrian_group_trigger = yes } 
			NOT = { religion_group = zoroastrian_group }
		}
		add_trait = sympathy_zoroastrianism
	}
	if = {
		limit = { 
			PREV = { true_religion_group_jewish_group_trigger = yes } 
			NOT = { religion_group = jewish_group }
		}
		add_trait = sympathy_judaism
	}
	if = {
		limit = { 
			PREV = { true_religion_group_indian_group_trigger = yes } 
			NOT = { religion_group = indian_group }
		}
		add_trait = sympathy_indian
	}
}

add_sympathy_for_prevs_open_religion_effect = {
	if = {
		limit = { 
			PREV = { religion_group = christian } 
			NOT = { religion_group = christian }
		}
		add_trait = sympathy_christendom
	}
	if = {
		limit = { 
			PREV = { religion_group = muslim } 
			NOT = { religion_group = muslim }
		}
		add_trait = sympathy_islam
	}
	if = {
		limit = { 
			PREV = { religion_group = pagan_group } 
			NOT = { religion_group = pagan_group }
		}
		add_trait = sympathy_pagans
	}
	if = {
		limit = { 
			PREV = { religion_group = zoroastrian_group } 
			NOT = { religion_group = zoroastrian_group }
		}
		add_trait = sympathy_zoroastrianism
	}
	if = {
		limit = { 
			PREV = { religion_group = jewish_group } 
			NOT = { religion_group = jewish_group }
		}
		add_trait = sympathy_judaism
	}
	if = {
		limit = { 
			PREV = { religion_group = indian_group } 
			NOT = { religion_group = indian_group }
		}
		add_trait = sympathy_indian
	}
}

add_trait_for_prevs_secret_religion_society_effect = {
	set_secret_religion = PREV
}

flip_to_secret_religion_effect = {
	convert_to_secret_religion = yes
}

add_prevs_secret_religion_trait_effect = {
	set_secret_religion = PREV
}

#Used in different sutiation, there conditions on effect. Flag has precedence over religion.
add_secret_religion_trait_trigger_is_religion_or_old_religion_flag_clear_flag_after_effect_is_run_this_name_is_a_tribute_to_m_effect = {
	emf_sr_set_sr_and_clr_religion_char_flag = yes
}

add_religion_char_flag_effect = {
	emf_sr_add_religion_char_flag = yes
}

clr_religion_char_flag_effect = {
	emf_sr_clr_religion_char_flag = yes
}

event_target_old_religion_from_flag_effect = {
	emf_sr_event_target_old_religion_from_flag = yes
}

increase_visibility_effect = {
	#custom_tooltip = { text = debug_vis }
	hidden_effect = {
		change_variable = { which = visibility_value value = 5 }
		if = {
			limit = {
				check_variable = { which = visibility_value value = 15 }
				NOR = {
					has_character_modifier = under_suspicion
					has_character_modifier = highly_suspect
				}
			}
			add_character_modifier = {
				name = under_suspicion
				duration = -1
			}
			character_event = { id = MNM.6662 days = 1 }
		}
		if = {
			limit = {
				check_variable = { which = visibility_value value = 25 }
				NOT = {
					has_character_modifier = highly_suspect
				}
			}
			remove_character_modifier = under_suspicion
			add_character_modifier = {
				name = highly_suspect duration = -1
			}
			character_event = { id = MNM.6663 days = 1 }
			liege = {
				set_character_flag = secret_societies_interference
				character_event = { id = MNM.6661 days = 1095 random = 1095 }
			}
		}
		if = { # Too visible? You auto-reveal yourself if you are independent
			limit = {
				independent = yes
				is_ruler = yes
				check_variable = { which = visibility_value value = 40 }
				NOT = {
					has_character_flag = self_reveal
				}
			}
			set_character_flag = self_reveal
			character_event = { id = MNM.6668 days = 1 }
		}
	}
}

increase_visibility_minor_effect = {
	#custom_tooltip = { text = debug_vis }
	hidden_effect = {
		change_variable = { which = visibility_value value = 2 }
		if = {
			limit = {
				check_variable = { which = visibility_value value = 15 }
				NOR = {
					has_character_modifier = under_suspicion
					has_character_modifier = highly_suspect
				}
			}
			add_character_modifier = {
				name = under_suspicion
				duration = -1
			}
			character_event = { id = MNM.6662 days = 1 }
		}
		if = {
			limit = {
				check_variable = { which = visibility_value value = 25 }
				NOT = {
					has_character_modifier = highly_suspect
				}
			}
			remove_character_modifier = under_suspicion
			add_character_modifier = {
				name = highly_suspect duration = -1
			}
			character_event = { id = MNM.6663 days = 1 }
			liege = {
				set_character_flag = secret_societies_interference
				character_event = { id = MNM.6661 days = 1095 random = 1095 }
			}
		}
		if = { # Too visible? You auto-reveal yourself if you are independent
			limit = {
				independent = yes
				is_ruler = yes
				check_variable = { which = visibility_value value = 40 }
				NOT = {
					has_character_flag = self_reveal
				}
			}
			set_character_flag = self_reveal
			if = {
				limit = {
					is_devil_worshiper_trigger = yes
				}
				add_character_modifier = {
					name = known_satanist
					duration = -1
				}
			}
			if = {
				limit = {
					is_devil_worshiper_trigger = no
				}
				add_character_modifier = {
					name = accused_apostate
					duration = -1
				}
			}
			if = {
				limit = {
					controls_religion = no
					emf_can_religion_excommunicate = yes
				}
				add_trait = excommunicated
			}
			character_event = { id = MNM.6668 days = 1 }
		}
	}
}

decrease_visibility_effect = {
	hidden_effect = {
		if = {
			limit = {
				check_variable = { which = visibility_value value = 1 }
			}
			random_list = {
				50 = {
					change_variable = { which = visibility_value value = -1 }
				}
				20 = {
					change_variable = { which = visibility_value value = -2 }
					modifier = {
						factor = 1.5
						OR = {
							trait = schemer
							trait = deceitful
							trait = patient
							trait = paranoid
						}
					}
					modifier = {
						factor = 1.25
						intrigue = 12
					}
					modifier = {
						factor = 1.25
						intrigue = 14
					}
					modifier = {
						factor = 1.25
						intrigue = 16
					}
				}
				15 = {
					change_variable = { which = visibility_value value = -3 }
					modifier = {
						factor = 1.5
						OR = {
							trait = schemer
							trait = deceitful
							trait = patient
							trait = paranoid
						}
					}
					modifier = {
						factor = 1.25
						intrigue = 12
					}
					modifier = {
						factor = 1.25
						intrigue = 14
					}
					modifier = {
						factor = 1.25
						intrigue = 16
					}
				}
				10 = {
					change_variable = { which = visibility_value value = -4 }
					modifier = {
						factor = 1.5
						OR = {
							trait = schemer
							trait = deceitful
							trait = patient
							trait = paranoid
						}
					}
					modifier = {
						factor = 1.25
						intrigue = 12
					}
					modifier = {
						factor = 1.25
						intrigue = 14
					}
					modifier = {
						factor = 1.25
						intrigue = 16
					}
				}
				5 = {
					change_variable = { which = visibility_value value = -5 }
					modifier = {
						factor = 1.5
						OR = {
							trait = schemer
							trait = deceitful
							trait = patient
							trait = paranoid
						}
					}
					modifier = {
						factor = 1.25
						intrigue = 12
					}
					modifier = {
						factor = 1.25
						intrigue = 14
					}
					modifier = {
						factor = 1.25
						intrigue = 16
					}
				}
			}
		}
		if = {
			limit = {
				NOT = { check_variable = { which = visibility_value value = 0 } } #safety
			}
			set_variable = { which = visibility_value value = 0 }
		}
	}
	if = {
		limit = {
			NOT = { check_variable = { which = visibility_value value = 25 } }
			has_character_modifier = highly_suspect
		}
		remove_character_modifier = highly_suspect
		add_character_modifier = {
			name = under_suspicion
			duration = -1
		}
		character_event = { id = MNM.6664 }
	}
	if = {
		limit = {
			NOT = { check_variable = { which = visibility_value value = 15 } }
			has_character_modifier = under_suspicion
		}
		remove_character_modifier = under_suspicion
		character_event = { id = MNM.6665 }
	}
}

hermetic_add_herbal_ingredient_effect = {
	hidden_effect = {
		random_list = {
			50 = {
				add_artifact = ingredient_herb1
			}
			50 = {
				add_artifact = ingredient_herb2
			}
			50 = {
				add_artifact = ingredient_herb3
			}
			50 = {
				add_artifact = ingredient_herb4
			}
			50 = {
				add_artifact = ingredient_herb5
			}
			50 = {
				add_artifact = ingredient_herb6
			}
			50 = {
				add_artifact = ingredient_herb7
			}
			50 = {
				add_artifact = ingredient_herb8
			}
			50 = {
				add_artifact = ingredient_herb9
			}
		}
	}
}

hermetic_add_animal_ingredient_effect = {
	hidden_effect = {
		random_list = {
			50 = {
				add_artifact = ingredient_animal1
			}
			50 = {
				add_artifact = ingredient_animal2
			}
			50 = {
				add_artifact = ingredient_animal3
			}
			50 = {
				add_artifact = ingredient_animal4
			}
			50 = {
				add_artifact = ingredient_animal5
			}
			50 = {
				add_artifact = ingredient_animal6
			}
			50 = {
				add_artifact = ingredient_animal7
			}
			50 = {
				add_artifact = ingredient_animal8
			}
			50 = {
				add_artifact = ingredient_animal9
			}
		}
	}
}

hermetic_add_misc_ingredient_effect = {
	hidden_effect = {
		random_list = {
			50 = {
				add_artifact = ingredient_metal_exotic1
			}
			50 = {
				add_artifact = ingredient_metal_exotic2
			}
			50 = {
				add_artifact = ingredient_metal_exotic3
			}
			50 = {
				add_artifact = ingredient_metal_exotic4
			}
			50 = {
				add_artifact = ingredient_metal_exotic5
			}
			50 = {
				add_artifact = ingredient_metal_exotic6
			}
			50 = {
				add_artifact = ingredient_metal_exotic7
			}
			50 = {
				add_artifact = ingredient_metal_exotic8
			}
			50 = {
				add_artifact = ingredient_metal_exotic9
			}
		}
	}
}

remove_scrying_omen_modifiers_effect = { #For cleaning up end-states of the Hermetics Scrying Power
	if = {
		limit = { has_character_modifier = good_battle_omen }
		remove_character_modifier = good_battle_omen
	}
	if = {
		limit = { has_character_modifier = bad_battle_omen }
		remove_character_modifier = bad_battle_omen
	}
	if = {
		limit = { has_character_modifier = good_relationship_omen }
		remove_character_modifier = good_relationship_omen
	}
	if = {
		limit = { has_character_modifier = bad_relationship_omen }
		remove_character_modifier = bad_relationship_omen
	}
	if = {
		limit = { has_character_modifier = good_power_omen }
		remove_character_modifier = good_power_omen
	}
	if = {
		limit = { has_character_modifier = bad_power_omen }
		remove_character_modifier = bad_power_omen
	}
	hidden_effect = { remove_character_modifier = scrying_cooldown }
	clr_character_flag = positive_reaction_to_scrying_flag
	clr_character_flag = negative_reaction_to_scrying_flag
	clr_character_flag = positive_event_flag
	clr_character_flag = negative_event_flag
	clear_delayed_event = { id = MNM.1225 }
	clear_delayed_event = { id = MNM.1226 }
	clear_delayed_event = { id = MNM.1227 }
}

calculate_scrying_outcome_effect = { # the positive_event_flag/negative_event_flag need to be set somewhere in the target event in order for this to work...
	custom_tooltip = { text = tooltip_info_omen_tt }

	if = {
		limit = {
			OR = {
				AND = {
					has_positive_omen_modifier_trigger = yes
					has_character_flag = positive_event_flag
				}
				AND = {
					has_negative_omen_modifier_trigger = yes
					has_character_flag = negative_event_flag
				}
			}
		}
		upgrade_seer_modifier_effect = yes
	}
	if = {
		limit = {
			OR = {
				AND = {
					has_positive_omen_modifier_trigger = yes
					has_character_flag = negative_event_flag
				}
				AND = {
					has_negative_omen_modifier_trigger = yes
					has_character_flag = positive_event_flag
				}
			}
		}
		downgrade_seer_modifier_effect = yes
	}
	clr_character_flag = positive_event_flag
	clr_character_flag = negative_event_flag
}

upgrade_seer_modifier_effect = { # Modifiers gotten at end-states of the Hermetics Scrying Power
	if = {
		limit = {
			has_a_seer_modifier_trigger = yes
		}
		trigger_switch = {
			on_trigger = has_character_modifier
			fulfilled_vision_worst = {
				remove_character_modifier = fulfilled_vision_worst
				add_character_modifier = {
					name = fulfilled_vision_bad
					duration = 2555
				}
			}
			fulfilled_vision_bad = {
				remove_character_modifier = fulfilled_vision_bad
				add_character_modifier = {
					name = fulfilled_vision_ok
					duration = 2555
				}
			}
			fulfilled_vision_ok = {
				remove_character_modifier = fulfilled_vision_ok
				add_character_modifier = {
					name = fulfilled_vision_great
					duration = 2555
				}
			}
			fulfilled_vision_great = {
				add_character_modifier = {
					name = fulfilled_vision_great
					duration = 2555
				}
			}
		}
	}
	if = {
		limit = {
			has_a_seer_modifier_trigger = no
		}
		add_character_modifier = {
			name = fulfilled_vision_ok
			duration = 2555
		}
	}
}

downgrade_seer_modifier_effect = { # Modifiers gotten at end-states of the Hermetics Scrying Power
	if = {
		limit = {
			has_a_seer_modifier_trigger = yes
		}
		trigger_switch = {
			on_trigger = has_character_modifier
			fulfilled_vision_great = {
				remove_character_modifier = fulfilled_vision_great
				add_character_modifier = {
					name = fulfilled_vision_ok
					duration = 2555
				}
			}
			fulfilled_vision_ok = {
				remove_character_modifier = fulfilled_vision_ok
				add_character_modifier = {
					name = fulfilled_vision_bad
					duration = 2555
				}
			}
			fulfilled_vision_bad = {
				remove_character_modifier = fulfilled_vision_bad
				add_character_modifier = {
					name = fulfilled_vision_worst
					duration = 2555
				}
			}
			fulfilled_vision_worst = {
				add_character_modifier = {
					name = fulfilled_vision_worst
					duration = 2555
				}
			}
		}
	}
	if = {
		limit = {
			has_a_seer_modifier_trigger = no
		}
		add_character_modifier = {
			name = fulfilled_vision_bad
			duration = 2555
		}
	}
}

scrying_omen_fulfilled_by_gaining_disease_effect = { #scrying result are sent if someone gets sick and you are carrying an omen (fired from rip_symptom_events)
	hidden_effect = {
		host = {
			if = {
				limit = {
					OR = {
						is_close_relative = ROOT
						is_friend = ROOT
					}
					OR = {
						has_character_modifier = bad_relationship_omen
						has_character_modifier = good_relationship_omen
					}
				}
				character_event = { id = MNM.1221 days = 5 random = 5 } #to the host of sick character
			}
		}
		father = {
			if = {
				limit = {
					is_liege_of = ROOT
					OR = {
						has_character_modifier = bad_relationship_omen
						has_character_modifier = good_relationship_omen
					}
				}
				character_event = { id = MNM.1221 days = 5 random = 5 }
			}
		}
		mother = {
			if = {
				limit = {
					is_liege_of = ROOT
					OR = {
						has_character_modifier = bad_relationship_omen
						has_character_modifier = good_relationship_omen
					}
				}
				character_event = { id = MNM.1221 days = 5 random = 5 }
			}
		}
		spouse = {
			if = {
				limit = {
					is_liege_of = ROOT
					OR = {
						has_character_modifier = bad_relationship_omen
						has_character_modifier = good_relationship_omen
					}
				}
				character_event = { id = MNM.1221 days = 5 random = 5 }
			}
		}
		any_consort = {
			if = {
				limit = {
					is_liege_of = ROOT
					OR = {
						has_character_modifier = bad_relationship_omen
						has_character_modifier = good_relationship_omen
					}
				}
				character_event = { id = MNM.1221 days = 5 random = 5 }
			}
		}
		any_lover = {
			if = {
				limit = {
					is_liege_of = ROOT
					OR = {
						has_character_modifier = bad_relationship_omen
						has_character_modifier = good_relationship_omen
					}
				}
				character_event = { id = MNM.1221 days = 5 random = 5 }
			}
		}

		if = {
			limit = {
				OR = {
					has_character_modifier = bad_power_omen
					has_character_modifier = good_power_omen
				}
			}
			character_event = { id = MNM.1220 days = 5 random = 5 } #to the sick character themselves
		}
	}
}

scrying_omen_fulfilled_by_removing_disease_effect = { #scrying result are sent if someone gets sick and you are carrying an omen (fired from rip_symptom_events)
	hidden_effect = {
		host = {
			if = {
				limit = {
					OR = {
						is_close_relative = ROOT
						is_friend = ROOT
					}
					OR = {
						has_character_modifier = good_relationship_omen
						has_character_modifier = bad_relationship_omen
					}
				}
				character_event = { id = MNM.1223 days = 5 random = 5 } #to the host of sick character
			}
		}
		father = {
			if = {
				limit = {
					is_liege_of = ROOT
					OR = {
						has_character_modifier = good_relationship_omen
						has_character_modifier = bad_relationship_omen
					}
				}
				character_event = { id = MNM.1223 days = 5 random = 5 }
			}
		}
		mother = {
			if = {
				limit = {
					is_liege_of = ROOT
					OR = {
						has_character_modifier = good_relationship_omen
						has_character_modifier = bad_relationship_omen
					}
				}
				character_event = { id = MNM.1223 days = 5 random = 5 }
			}
		}
		spouse = {
			if = {
				limit = {
					is_liege_of = ROOT
					OR = {
						has_character_modifier = good_relationship_omen
						has_character_modifier = bad_relationship_omen
					}
				}
				character_event = { id = MNM.1223 days = 5 random = 5 }
			}
		}
		any_consort = {
			if = {
				limit = {
					is_liege_of = ROOT
					OR = {
						has_character_modifier = bad_relationship_omen
						has_character_modifier = good_relationship_omen
					}
				}
				character_event = { id = MNM.1223 days = 5 random = 5 }
			}
		}
		any_lover = {
			if = {
				limit = {
					is_liege_of = ROOT
					OR = {
						has_character_modifier = good_relationship_omen
						has_character_modifier = bad_relationship_omen
					}
				}
				character_event = { id = MNM.1223 days = 5 random = 5 }
			}
		}

		if = {
			limit = {
				OR = {
					has_character_modifier = good_power_omen
					has_character_modifier = bad_power_omen
				}
			}
			character_event = { id = MNM.1222 days = 5 random = 5 } #to the sick character themselves
		}
	}
}

add_pet_owl_effect = {
	add_character_modifier = {
		name = pet_owl
		duration = -1
	}
	hidden_tooltip = { character_event = { id = 77800 days = 3500 random = 2000 } } # Owl dies
}

add_mission_succeed_influence_effect = {
	add_society_modifier =	 {
		modifier = successful_mission
		years = 10
	}
}

add_mission_fail_influence_effect = {
	add_society_modifier =	 {
		modifier = failed_mission
		years = 10
	}
}

add_mission_decline_influence_effect = {
	add_society_modifier =	 {
		modifier = declined_mission
		years = 2
	}
}

clean_up_horoscope_effect = {
	clr_character_flag = avoided_destiny
	clr_character_flag = horoscope_maker_died
	clr_character_flag = destined_artist
	clr_character_flag = destined_fighter
	clr_character_flag = destined_diplomat
	clr_character_flag = destined_schemer
	clr_character_flag = destined_scholar
	clr_character_flag = encouraged_horoscope_pattern
	clr_character_flag = discouraged_horoscope_pattern
	clr_character_flag = horoscope_child_evaluate
	clr_character_flag = horoscope_path_1
	clr_character_flag = horoscope_maker_is_mother
	clr_character_flag = horoscope_maker_is_father
	remove_character_modifier = horoscope_cooldown
}

upgrade_education_effect = {
	trigger_switch = {
		on_trigger = trait

		### Intrigue ###
		amateurish_plotter = {
			remove_trait = amateurish_plotter
			add_trait = flamboyant_schemer
		}
		flamboyant_schemer = {
			remove_trait = flamboyant_schemer
			add_trait = intricate_webweaver
		}
		intricate_webweaver = {
			remove_trait = intricate_webweaver
			add_trait = elusive_shadow
		}
		elusive_shadow = {
			# already maxed
		}

		### Diplomacy ###
		naive_appeaser = {
			remove_trait = naive_appeaser
			add_trait = underhanded_rogue
		}
		underhanded_rogue = {
			remove_trait = underhanded_rogue
			add_trait = charismatic_negotiator
		}
		charismatic_negotiator = {
			remove_trait = charismatic_negotiator
			add_trait = grey_eminence
		}
		grey_eminence = {
			# already maxed
		}

		### Stewardship ###
		indulgent_wastrel = {
			remove_trait = indulgent_wastrel
			add_trait = thrifty_clerk
		}
		thrifty_clerk = {
			remove_trait = thrifty_clerk
			add_trait = fortune_builder
		}
		fortune_builder = {
			remove_trait = fortune_builder
			add_trait = midas_touched
		}
		midas_touched = {
			# already maxed
		}

		### Martial ###
		misguided_warrior = {
			remove_trait = misguided_warrior
			add_trait = tough_soldier
		}
		tough_soldier = {
			remove_trait = tough_soldier
			add_trait = skilled_tactician
		}
		skilled_tactician = {
			remove_trait = skilled_tactician
			add_trait = brilliant_strategist
		}
		brilliant_strategist = {
			# already maxed
		}

		### Learning ###
		detached_priest = {
			remove_trait = detached_priest
			add_trait = martial_cleric
		}
		martial_cleric = {
			remove_trait = martial_cleric
			add_trait = scholarly_theologian
		}
		scholarly_theologian = {
			remove_trait = scholarly_theologian
			add_trait = mastermind_theologian
		}
		mastermind_theologian = {
			# already maxed
		}
	}
}

set_horoscope_modifier_effect = { # Modifiers received by target during the Hermetics Horoscope Power
	if = {
		limit = {
			has_childhood_horoscope_modifier_trigger = yes
			NOT = { has_character_flag = avoided_destiny }
		}
		trigger_switch = {
			on_trigger = has_character_modifier
			guided_by_horoscope_diplomacy = {
				remove_character_modifier = guided_by_horoscope_diplomacy
				add_character_modifier = {
					name = guided_by_horoscope_diplomacy_adult
					duration = 2555
				}
			}
			guided_by_horoscope_martial = {
				remove_character_modifier = guided_by_horoscope_martial
				add_character_modifier = {
					name = guided_by_horoscope_martial_adult
					duration = 2555
				}
			}
			guided_by_horoscope_stewardship = {
				remove_character_modifier = guided_by_horoscope_stewardship
				add_character_modifier = {
					name = guided_by_horoscope_stewardship_adult
					duration = 2555
				}
			}
			guided_by_horoscope_intrigue = {
				remove_character_modifier = guided_by_horoscope_intrigue
				add_character_modifier = {
					name = guided_by_horoscope_intrigue_adult
					duration = 2555
				}
			}
			guided_by_horoscope_learning = {
				remove_character_modifier = guided_by_horoscope_learning
				add_character_modifier = {
					name = guided_by_horoscope_learning_adult
					duration = 2555
				}
			}
		}
		break = yes
	}

	if = {
		limit = {
			has_childhood_horoscope_modifier_trigger = no
			is_adult = no
			NOT = { has_character_flag = avoided_destiny }
		}
		trigger_switch = {
			on_trigger = has_character_flag
			destined_steward = {
				add_character_modifier = {
					name = guided_by_horoscope_stewardship
					duration =-1
				}
			}
			destined_fighter = {
				add_character_modifier = {
					name = guided_by_horoscope_martial
					duration =-1
				}
			}
			destined_diplomat = {
				add_character_modifier = {
					name = guided_by_horoscope_diplomacy
					duration =-1
				}
			}
			destined_schemer = {
				add_character_modifier = {
					name = guided_by_horoscope_intrigue
					duration =-1
				}
			}
			destined_scholar = {
				add_character_modifier = {
					name = guided_by_horoscope_learning
					duration =-1
				}
			}
		}
		break = yes
	}

	if = {
		limit = {
			has_childhood_horoscope_modifier_trigger = no
			has_character_flag = avoided_destiny
		}
		trigger_switch = {
			on_trigger = has_character_flag
			destined_steward = {
				add_character_modifier = {
					name = horoscope_outcome_jittery
					years = 15
				}
			}
			destined_fighter = {
				add_character_modifier = {
					name = horoscope_outcome_brute
					years = 15
				}
			}
			destined_diplomat = {
				add_character_modifier = {
					name = horoscope_outcome_artist
					years = 15
				}
			}
			destined_schemer = {
				add_character_modifier = {
					name = horoscope_outcome_arrogant
					years = 15
				}
			}
			destined_scholar = {
				add_character_modifier = {
					name = horoscope_outcome_scatterbrain
					years = 15
				}
			}
		}
		break = yes
	}

	if = {
		limit = {
			has_childhood_horoscope_modifier_trigger = yes
			has_character_flag = avoided_destiny
		}
		trigger_switch = {
			on_trigger = has_character_flag
			destined_steward = {
				if = { limit = { has_character_modifier = guided_by_horoscope_stewardship }
					remove_character_modifier = guided_by_horoscope_stewardship
				}
				add_character_modifier = {
					name = horoscope_outcome_jittery
					years = 15
				}
			}
			destined_fighter = {
				if = { limit = { has_character_modifier = guided_by_horoscope_martial }
					remove_character_modifier = guided_by_horoscope_martial
				}
				add_character_modifier = {
					name = horoscope_outcome_brute
					years = 15
				}
			}
			destined_diplomat = {
				if = { limit = { has_character_modifier = guided_by_horoscope_diplomacy }
					remove_character_modifier = guided_by_horoscope_diplomacy
				}
				add_character_modifier = {
					name = horoscope_outcome_artist
					years = 15
				}
			}
			destined_schemer = {
				if = { limit = { has_character_modifier = guided_by_horoscope_intrigue }
					remove_character_modifier = guided_by_horoscope_intrigue
				}
				add_character_modifier = {
					name = horoscope_outcome_arrogant
					years = 15
				}
			}
			destined_scholar = {
				if = { limit = { has_character_modifier = guided_by_horoscope_learning }
					remove_character_modifier = guided_by_horoscope_learning
				}
				add_character_modifier = {
					name = horoscope_outcome_scatterbrain
					years = 15
				}
			}
		}
		break = yes
	}
}

increase_astronomical_insights_modifier_effect = {
	custom_tooltip = { text = increase_astronomical_insight_tt }
	trigger_switch = {
		on_trigger = has_character_modifier
		astronomical_insights_1 = {
			hidden_effect = {
				remove_character_modifier = astronomical_insights_1
			}
			add_character_modifier = {
				modifier = astronomical_insights_2
				duration = -1
			}
		}
		astronomical_insights_2 = {
			hidden_effect = {
				remove_character_modifier = astronomical_insights_2
			}
			add_character_modifier = {
				modifier = astronomical_insights_3
				duration = -1
			}
		}
		astronomical_insights_3 = {
			hidden_effect = {
				remove_character_modifier = astronomical_insights_3
			}
			add_character_modifier = {
				modifier = astronomical_insights_4
				duration = -1
			}
		}
	}
	if = {
		limit = {
			NOR = {
				has_character_modifier = astronomical_insights_1
				has_character_modifier = astronomical_insights_2
				has_character_modifier = astronomical_insights_3
				has_character_modifier = astronomical_insights_4
			}
		}
		add_character_modifier = {
			modifier = astronomical_insights_1
			duration = -1
		}
	}
}

remove_astronomical_insight_modifier_effect = {
	hidden_effect = {
		remove_character_modifier = astronomical_insights_1
		remove_character_modifier = astronomical_insights_2
		remove_character_modifier = astronomical_insights_3
		remove_character_modifier = astronomical_insights_4
	}
}

add_Aries_sign_trait_effect = {
	random_list = {
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_aries #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = stubborn
		}
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_aries #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = ambitious
		}
		100 = {
			trigger = { 
				has_dlc = "Holy Fury"
				NOT = { trait = zodiac_aries } 
			}
			add_trait = zodiac_aries
		}
	}
}

add_Taurus_sign_trait_effect = {
	random_list = {
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_taurus #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = content
		}
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_taurus #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = patient
		}
		100 = {
			trigger = { 
				has_dlc = "Holy Fury"
				NOT = { trait = zodiac_taurus } 
			}
			add_trait = zodiac_taurus
		}
	}
}
add_Gemini_sign_trait_effect = {
	random_list = {
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_gemini #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = wroth
		}
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_gemini #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = diligent
		}
		100 = {
			trigger = { 
				has_dlc = "Holy Fury"
				NOT = { trait = zodiac_gemini } 
			}
			add_trait = zodiac_gemini
		}
	}
}
add_Cancer_sign_trait_effect = {
	random_list = {
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_cancer #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = honest
		}
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_cancer #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = kind
		}
		100 = {
			trigger = { 
				has_dlc = "Holy Fury"
				NOT = { trait = zodiac_cancer } 
			}
			add_trait = zodiac_cancer
		}
	}
}
add_Leo_sign_trait_effect = {
	random_list = {
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_leo #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = cruel
		}
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_leo #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = gregarious
		}
		100 = {
			trigger = { 
				has_dlc = "Holy Fury"
				NOT = { trait = zodiac_leo } 
			}
			add_trait = zodiac_leo
		}
	}
}
add_Virgo_sign_trait_effect = {
	random_list = {
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_virgo #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = shy
		}
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_virgo #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = humble
		}
		100 = {
			trigger = { 
				has_dlc = "Holy Fury"
				NOT = { trait = zodiac_virgo } 
			}
			add_trait = zodiac_virgo
		}
	}
}
add_Libra_sign_trait_effect = {
	random_list = {
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_libra #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = trusting
		}
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_libra #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = temperate
		}
		100 = {
			trigger = { 
				has_dlc = "Holy Fury"
				NOT = { trait = zodiac_libra } 
			}
			add_trait = zodiac_libra
		}
	}
}
add_Scorpius_sign_trait_effect = {
	random_list = {
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_scorpio #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = deceitful
		}
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_scorpio #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = lustful
		}
		100 = {
			trigger = { 
				has_dlc = "Holy Fury"
				NOT = { trait = zodiac_scorpio } 
			}
			add_trait = zodiac_scorpio
		}
	}
}
add_Sagittarius_sign_trait_effect = {
	random_list = {
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_sagittarius #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = wroth
		}
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_sagittarius #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = charitable
		}
		100 = {
			trigger = { 
				has_dlc = "Holy Fury"
				NOT = { trait = zodiac_sagittarius } 
			}
			add_trait = zodiac_sagittarius
		}
	}
}
add_Capricorn_sign_trait_effect = {
	random_list = {
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_capricorn #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = proud
		}
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_capricorn #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = temperate
		}
		100 = {
			trigger = { 
				has_dlc = "Holy Fury"
				NOT = { trait = zodiac_capricorn } 
			}
			add_trait = zodiac_capricorn
		}
	}
}
add_Aquarius_sign_trait_effect = {
	random_list = {
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_aquarius #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = slothful
		}
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_aquarius #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = ambitious
		}
		100 = {
			trigger = { 
				has_dlc = "Holy Fury"
				NOT = { trait = zodiac_aquarius } 
			}
			add_trait = zodiac_aquarius
		}
	}
}
add_Pisces_sign_trait_effect = {
	random_list = {
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_pisces #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = trusting
		}
		10 = {
			trigger = { 
				OR = { 
					NOT = { has_dlc = "Holy Fury" } 
					trait = zodiac_pisces #If an hellenic hermetic gets the zodiac event, give him the character trait instead.
				}
			}
			add_trait = kind
		}
		100 = {
			trigger = { 
				has_dlc = "Holy Fury"
				NOT = { trait = zodiac_pisces } 
			}
			add_trait = zodiac_pisces
		}
	}
}

add_western_zodiac_trait_effect = {
	custom_tooltip = {
		text = gain_zodiac_trait_effect_tt
	}
	if = { limit = { is_born_under_Aries_trigger = yes }
		add_trait = zodiac_aries
	}
	if = { limit = { is_born_under_Taurus_trigger = yes }
		add_trait = zodiac_taurus
	}
	if = { limit = { is_born_under_Gemini_trigger = yes }
		add_trait = zodiac_gemini
	}
	if = { limit = { is_born_under_Cancer_trigger = yes }
		add_trait = zodiac_cancer
	}
	if = { limit = { is_born_under_Leo_trigger = yes }
		add_trait = zodiac_leo
	}
	if = { limit = { is_born_under_Virgo_trigger = yes }
		add_trait = zodiac_virgo
	}
	if = { limit = { is_born_under_Libra_trigger = yes }
		add_trait = zodiac_libra
	}
	if = { limit = { is_born_under_Scorpius_trigger = yes }
		add_trait = zodiac_scorpio
	}
	if = { limit = { is_born_under_Sagittarius_trigger = yes }
		add_trait = zodiac_sagittarius
	}
	if = { limit = { is_born_under_Capricorn_trigger = yes }
		add_trait = zodiac_capricorn
	}
	if = { limit = { is_born_under_Aquarius_trigger = yes }
		add_trait = zodiac_aquarius
	}
	if = { limit = { is_born_under_Pisces_trigger = yes }
		add_trait = zodiac_pisces
	}
}

flip_secret_religious_community_provinces = {
	emf_sr_flip_secret_community_provinces = yes
}

clean_up_after_leaving_society_effect = {
	hidden_effect = {
		clr_character_flag = do_not_disturb
		remove_character_modifier = quest_cooldown_timer

		#Powers, Missions and Interactions: the Assassins
		#quest_the_assassins_assassination
		#quest_the_assassins_collect_debt
		#quest_the_assassins_convert_province
		#quest_the_assassins_occupy_holding
		#quest_the_assassins_protege
		clr_character_flag = ongoing_recruitment
		clr_character_flag = approves_of_shia
		clr_character_flag = disapproves_of_shia
		clr_character_flag = willing_to_join
		clr_character_flag = unwilling_to_join
		clr_character_flag = assassins_attempted_recruitment
		clr_character_flag = escape_successful
		clr_character_flag = escape_injured
		clr_character_flag = escape_death
		clr_character_flag = escape_bribe

		#Powers, Missions and Interactions: Devil Worshipers
		clr_character_flag = attempted_corrupt_priest
		clr_character_flag = possessing_courtier
		clr_character_flag = desecration_in_progress
		clr_character_flag = desecration_violent
		clr_character_flag = desecration_at_home
		clr_character_flag = desecration_plotting
		clr_character_flag = approves_of_satanism
		clr_character_flag = disapproves_of_satanism
		clr_character_flag = has_ill_lover_loc
		clr_character_flag = has_ill_spouse_loc
		clr_character_flag = has_ill_child_loc
		clr_character_flag = has_money_troubles_loc
		clr_character_flag = has_some_illness_loc
		clr_character_flag = has_need_of_winning_battles_loc
		clr_character_flag = has_a_rival_loc
		clr_character_flag = is_weak_loc
		clr_character_flag = is_dumb_loc
		clr_character_flag = being_recruited_by_the_satanists
		clr_character_flag = being_recruited_by_the_trollcrafters
		clr_character_flag = being_recruited_by_the_cult_of_kali
		clr_character_flag = being_recruited_by_the_cold_ones
		clr_character_flag = being_recruited_by_the_plaguebringers
		clr_character_flag = being_recruited_by_the_vodouns
		clr_character_flag = being_recruited_by_the_bacchants

		#Powers, Missions and Interactions: Secret Religious
		clr_character_flag = sr_too_honest
		clr_character_flag = sr_too_wroth
		clr_character_flag = sr_too_slothful
		clr_character_flag = sr_too_trusting
		clr_character_flag = sr_too_indiscreet
		clr_character_flag = free_help
		clr_character_flag = help_for_cost
		clr_character_flag = conduct_secret_ceremony_timer
		remove_character_modifier = attempting_to_blend_in
		clr_character_flag = blending_in_timer
		clr_character_flag = attempting_to_convince_stubborn_courtier
		clr_character_flag = attempting_to_convince_concerned_friend
		clr_character_flag = blend_in_struggled_with_trait
		clr_character_flag = blend_in_attended_house_of_worship
		clr_character_flag = blend_in_general_progress
		#quest_secret_religious_societies_induct_ruler
		#quest_secret_religious_societies_sympathy_ruler

		#Powers, Missions and Interactions: Monastic orders
		clr_character_flag = monastic_orders_holy_seclusion
		clr_character_flag = monastic_orders_mission_charity
		clr_character_flag = monastic_orders_mission_theology
		clr_character_flag = monastic_orders_mission_christian_pilgrimage
		clr_character_flag = monastic_orders_mission_dharmic_pilgrimage
		clr_character_flag = monastic_orders_mission_temple
		clr_character_flag = ascetic_arriving
		clr_character_flag = monastic_artifact_lover
		if = { 
			limit = { NOT = { has_character_flag = flag_monastic_mid_theft } }
			clr_character_flag = monastic_artifact_seamless_robe_of_jesus
			clr_character_flag = monastic_artifact_crown_of_thorns
			clr_character_flag = monastic_artifact_fragment_of_true_cross
			clr_character_flag = monastic_artifact_holy_foreskin
			clr_character_flag = monastic_artifact_image_of_edessa
			clr_character_flag = monastic_artifact_elaborate_danda
			clr_character_flag = monastic_artifact_sariraka_actual_body_part
			clr_character_flag = monastic_artifact_sarira
		}
		clr_character_flag = suggestion_A_flag
		clr_character_flag = suggestion_B_flag
		clr_character_flag = 3264_deceitful_flag
		clr_character_flag = 3264_publish_flag
		clr_character_flag = 3264_depressed_flag
		clr_character_flag = 4202_visit_monastery_flag
		clr_character_flag = 4202_hire_someone_flag
		clr_character_flag = 4202_send_my_own_samples_flag
		clr_character_flag = 4212_woke_them_up_flag
		clr_character_flag = 4212_let_them_sleep_flag
		clr_character_flag = 4212_pranked_them_flag
		remove_character_modifier = in_meditation
		remove_character_modifier = doing_penance
		clr_character_flag = holy_seclusion_timer
		clr_character_flag = holy_seclusion_struggled_with_vice
		clr_character_flag = holy_seclusion_lustful
		clr_character_flag = holy_seclusion_gluttonous
		clr_character_flag = holy_seclusion_greedy
		clr_character_flag = holy_seclusion_slothful
		clr_character_flag = holy_seclusion_struggled_with_loneliness
		clr_character_flag = holy_seclusion_scripture_reading
		clr_character_flag = holy_seclusion_interrupting_child
		clr_character_flag = success_seculison_desc_A
		clr_character_flag = success_seculison_desc_B
		clr_character_flag = success_seculison_desc_C

		#Powers, Missions and Interactions: Hermetics
		clr_character_flag = power_hungry_scrying_flag
		clr_character_flag = relationship_focused_scrying_flag
		clr_character_flag = battle_focused_scrying_flag
		remove_character_modifier = writing_magnum_opus
		remove_character_modifier = acquire_ingredients_decision_cooldown_timer
		clr_character_flag = building_laboratory
		clr_character_flag = decided_on_glass
		clr_character_flag = decided_on_crucibles
		clr_character_flag = decided_on_tools
		clr_character_flag = decided_on_books
		clr_character_flag = bribed_guards
		clr_character_flag = guards_wake_up
		clr_character_flag = distraction_failed
		clr_character_flag = caught_stealing
		clr_character_flag = caught_destroying
		remove_scrying_omen_modifiers_effect = yes
		clr_character_flag = lab_destruction
		clr_character_flag = lab_damage
		clr_character_flag = lab_explosion_death

		#Warrior Lodges: everything
		if = {
			limit = {
				has_character_flag = call_to_legend_active
				has_character_modifier = out_traveling
			}
			remove_character_modifier = out_traveling #Should hopefully only remove this when relevant
		}
		clr_character_flag = call_to_legend_active
		clr_character_flag = start_bracket
		clr_character_flag = mid_bracket
		clr_character_flag = top_bracket
		clr_character_flag = call_it_a_day
		clr_character_flag = i_will_survive
		clr_character_flag = bloodline_quality_1
		clr_character_flag = bloodline_quality_2
		clr_character_flag = bloodline_quality_3
		clr_character_flag = player_was_involved
		
		#tombola events...
		clr_character_flag = HF_legend_artifact
		clr_character_flag = HF_legend_feast
		clr_character_flag = HF_legend_skull
		clr_character_flag = HF_legend_eagle
		clr_character_flag = HF_legend_upgrade_weapon

		#Duel outcomes...
		clr_character_flag = WL_desc_A
		clr_character_flag = WL_desc_B
		clr_character_flag = WL_desc_C
		clr_character_flag = WL_desc_D
		clr_character_flag = WL_desc_E
		clr_character_flag = WL_desc_F
		clr_character_flag = had_WL_desc_A
		clr_character_flag = had_WL_desc_B
		clr_character_flag = had_WL_desc_C
		clr_character_flag = had_WL_desc_D
		clr_character_flag = had_WL_desc_E
		clr_character_flag = had_WL_desc_F
		clr_character_flag = WL_desc_X
		clr_character_flag = WL_desc_Y
		clr_character_flag = WL_desc_Z
	}
}


increase_council_power_effect = {
	custom_tooltip = {
		text = council_power_increased
		hidden_tooltip = {
			set_variable = { which = "laws" value = 0 }
			if = {
				limit = {
					has_law = law_voting_power_0
					NOT = {
						check_variable = { which = "laws" value = 2 }
					}
				}
				add_law_w_cooldown = law_voting_power_1
				change_variable = { which = "laws" value = 1 }
			}
			if = {
				limit = {
					has_law = war_voting_power_0
					NOT = {
						check_variable = { which = "laws" value = 2 }
					}
				}
				add_law_w_cooldown = war_voting_power_1
				change_variable = { which = "laws" value = 1 }
			}
			if = {
				limit = {
					has_law = titles_voting_power_0
					NOT = {
						check_variable = { which = "laws" value = 2 }
					}
				}
				add_law_w_cooldown = titles_voting_power_1
				change_variable = { which = "laws" value = 1 }
			}
			if = {
				limit = {
					has_law = justice_voting_power_0
					NOT = {
						check_variable = { which = "laws" value = 2 }
					}
				}
				add_law_w_cooldown = justice_voting_power_1
				change_variable = { which = "laws" value = 1 }
			}
			set_variable = { which = "laws" value = 0 }
		}
	}
}

increase_vassal_freedom_effect = {
	if = {
		limit = {
			crownlaw_title = { title = PREV }
			has_law = king_peace_1
		}
		add_law = king_peace_0
	}
	if = {
		limit = {
			crownlaw_title = { title = PREV }
			has_law = king_peace_2
		}
		add_law = king_peace_1
	}
}

spawn_good_commander_effect = {
	if = { 
		limit = { has_religion_feature = religion_matriarchal }
		create_random_soldier = {
			random_traits = yes
			dynasty = random
			female = yes
			attributes = {
				diplomacy = 2
				learning = 2
				stewardship = 2
				intrigue = 2
				martial = 8
			}
		}
	}
	else_if = { 
		limit = { gender_equality_trigger = yes }
		create_random_soldier = {
			random_traits = yes
			dynasty = random
			female = 50
			attributes = {
				diplomacy = 2
				learning = 2
				stewardship = 2
				intrigue = 2
				martial = 8
			}
		}
	}
	else = {
		create_random_soldier = {
			random_traits = yes
			dynasty = random
			female = no
			attributes = {
				diplomacy = 2
				learning = 2
				stewardship = 2
				intrigue = 2
				martial = 8
			}
		}
	}
	new_character = {
		remove_trait = weak
		remove_trait = slow
		remove_trait = imbecile
		remove_trait = dull
		
		remove_trait = mystic
		remove_trait = socializer
		remove_trait = gamer
		remove_trait = hedonist
		remove_trait = duelist
		remove_trait = hunter
		remove_trait = strategist
		remove_trait = administrator
		remove_trait = architect
		remove_trait = gardener
		remove_trait = schemer
		remove_trait = impaler
		remove_trait = seducer
		remove_trait = seductress
		remove_trait = theologian
		remove_trait = scholar
		
		random_list = { # Flavor Randomization
			35 = { 
				# Nothing
			}
			15 = {
				change_martial = 2
			}
			10 = {
				add_trait = robust
			}
			10 = {
				add_trait = duelist
			}
			10 = {
				add_trait = hunter
			}
			5 = {
				add_trait = strategist
			}
			5 = {
				change_martial = 4
			}
			5 = {
				if = {
					limit = {
						has_dlc = "Reapers"
					}
					add_trait = one_eyed
				}
			}
			5 = { 
				add_trait = shrewd
			}
			3 = { 
				add_trait = giant
			}
		}
		emf_new_character_noble = yes
		set_character_flag = invited_soldier
		save_event_target_as = invited_character
	}
}

spawn_great_commander_effect = {
	if = { 
		limit = { has_religion_feature = religion_matriarchal }
		create_random_soldier = {
			random_traits = yes
			dynasty = random
			female = yes
			attributes = {
				diplomacy = 3
				learning = 3
				stewardship = 3
				intrigue = 3
				martial = 9
			}
		}
	}
	else_if = { 
		limit = { gender_equality_trigger = yes }
		create_random_soldier = {
			random_traits = yes
			dynasty = random
			female = 50
			attributes = {
				diplomacy = 3
				learning = 3
				stewardship = 3
				intrigue = 3
				martial = 9
			}
		}
	}
	else = {
		create_random_soldier = {
			random_traits = yes
			dynasty = random
			female = no
			attributes = {
				diplomacy = 3
				learning = 3
				stewardship = 3
				intrigue = 3
				martial = 9
			}
		}
	}
	new_character = {
		remove_trait = weak
		remove_trait = slow
		remove_trait = imbecile
		remove_trait = dull
		remove_trait = dwarf
		remove_trait = giant
		remove_trait = hunchback
		remove_trait = clubfooted
		remove_trait = craven
		
		remove_trait = mystic
		remove_trait = socializer
		remove_trait = gamer
		remove_trait = hedonist
		remove_trait = duelist
		remove_trait = hunter
		remove_trait = strategist
		remove_trait = administrator
		remove_trait = architect
		remove_trait = gardener
		remove_trait = schemer
		remove_trait = impaler
		remove_trait = seducer
		remove_trait = seductress
		remove_trait = theologian
		remove_trait = scholar
		
		remove_trait = misguided_warrior
		remove_trait = tough_soldier
		remove_trait = skilled_tactician
		remove_trait = brilliant_strategist

		random_list = {
			5 = { add_trait = misguided_warrior }
			10 = { add_trait = tough_soldier }
			20 = { add_trait = skilled_tactician }
			30 = { add_trait = brilliant_strategist }
		}
	
		random_list = { # Flavor Randomization
			35 = { 
				# Nothing
			}
			15 = {
				change_martial = 2
			}
			10 = {
				add_trait = robust
			}
			10 = {
				add_trait = duelist
			}
			10 = {
				add_trait = hunter
			}
			5 = {
				add_trait = strategist
			}
			5 = {
				change_martial = 4
			}
			5 = {
				if = {
					limit = {
						has_dlc = "Reapers"
					}
					add_trait = one_eyed
				}
			}
			5 = { 
				add_trait = shrewd
			}
			1 = { 
				add_trait = giant
			}
		}
		random_list = {
			50 = {
				#Nothing
			}
			10 = {
				add_trait = narrow_flank_leader
			}
			10 = {
				add_trait = defensive_leader
			}
			10 = {
				add_trait = experimenter
			}
			10 = {
				add_trait = flanker
			}
			10 = {
				add_trait = heavy_infantry_leader
			}
			10 = {
				add_trait = inspiring_leader
			}
			10 = {
				add_trait = organizer
			}
			10 = {
				add_trait = siege_leader
			}
			10 = {
				add_trait = trickster
			}
			10 = {
				add_trait = aggressive_leader
			}
		}
		emf_new_character_noble = yes
		set_character_flag = invited_soldier
		save_event_target_as = invited_character
	}
}

spawn_fantastic_commander_effect = {

	if = { 
		limit = { has_religion_feature = religion_matriarchal }
		create_random_soldier = {
			random_traits = yes
			dynasty = actually_culture
			female = yes
			attributes = {
				diplomacy = 4
				learning = 4
				stewardship = 4
				intrigue = 4
				martial = 12
			}
		}
	}
	else_if = { 
		limit = { gender_equality_trigger = yes }
		create_random_soldier = {
			random_traits = yes
			dynasty = actually_culture
			female = 50
			attributes = {
				diplomacy = 4
				learning = 4
				stewardship = 4
				intrigue = 4
				martial = 12
			}
		}
	}
	else = {
		create_random_soldier = {
			random_traits = yes
			dynasty = actually_culture
			female = no
			attributes = {
				diplomacy = 4
				learning = 4
				stewardship = 4
				intrigue = 4
				martial = 12
			}
		}
	}
	new_character = {
		remove_trait = weak
		remove_trait = slow
		remove_trait = imbecile
		remove_trait = dull
		remove_trait = dwarf
		remove_trait = giant
		remove_trait = hunchback
		remove_trait = clubfooted
		remove_trait = craven
		remove_trait = paranoid
		
		remove_trait = mystic
		remove_trait = socializer
		remove_trait = gamer
		remove_trait = hedonist
		remove_trait = duelist
		remove_trait = hunter
		remove_trait = strategist
		remove_trait = administrator
		remove_trait = architect
		remove_trait = gardener
		remove_trait = schemer
		remove_trait = impaler
		remove_trait = seducer
		remove_trait = seductress
		remove_trait = theologian
		remove_trait = scholar
		
		remove_trait = misguided_warrior
		remove_trait = tough_soldier
		remove_trait = skilled_tactician
		
		add_trait = brilliant_strategist
		
		random_list = {
			20 = {
				add_trait = robust
			}
			10 = {
				add_trait = strong
			}
			5 = {
				health = 1
			}
		}
		
		random_list = {
			10 = {
				add_trait = narrow_flank_leader
			}
			10 = {
				add_trait = defensive_leader
			}
			10 = {
				add_trait = experimenter
			}
			10 = {
				add_trait = flanker
			}
			10 = {
				add_trait = heavy_infantry_leader
			}
			10 = {
				add_trait = inspiring_leader
			}
			10 = {
				add_trait = organizer
			}
			10 = {
				add_trait = siege_leader
			}
			10 = {
				add_trait = trickster
			}
			10 = {
				add_trait = aggressive_leader
			}
		}
		
		random_list = { # Flavor Randomization
			20 = {
				add_trait = giant
				add_trait = robust
				add_trait = hunter
				change_martial = 2
				give_nickname = nick_the_giant
			}
			20 = {
				modifier = {
					factor = 0
					NOT = {
						has_dlc = "Reapers"
					}
				}
				add_trait = giant
				add_trait = robust
				add_trait = strategist
				add_trait = one_eyed
				change_martial = 1
				give_nickname = nick_the_cyclops
			}
			20 = {
				add_trait = holy_warrior
				add_trait = scarred
				change_martial = 3
				give_nickname = nick_the_hammer
			}
			20 = {
				add_trait = brave
				add_trait = poet
				change_martial = 2
				give_nickname = nick_the_fearless
			}
			20 = {
				add_trait = robust
				remove_trait = temperate
				add_trait = wroth
				add_trait = falconer
				change_martial = 1
				give_nickname = nick_the_ill_tempered
			}
			20 = {
				add_trait = unyielding_leader
				remove_trait = wroth
				add_trait = patient
				change_martial = 2
				give_nickname = nick_the_defender
			}
			20 = {
				add_trait = aggressive_leader
				remove_trait = patient
				add_trait = wroth
				change_martial = 3
				give_nickname = nick_the_destroyer
			}
			20 = {
				add_trait = shrewd
				add_trait = brave
				change_martial = 2
				give_nickname = nick_the_brave
			}
			20 = {
				add_trait = robust
				add_trait = strategist
				change_martial = 1
				give_nickname = nick_the_strong
			}
			20 = {
				add_trait = genius
				add_trait = socializer
				add_trait = poet
				change_martial = 4
				give_nickname = nick_the_noble
			}
			20 = {
				add_trait = blinded
				add_trait = strategist
				add_trait = genius
				change_martial = 4
				give_nickname = nick_the_blind
			}
			20 = {
				remove_trait = humble
				add_trait = proud
				add_trait = duelist
				change_martial = 2
				give_nickname = nick_the_proud
			}
			20 = {
				add_trait = hunter
				add_trait = shrewd
				change_martial = 3
				give_nickname = nick_the_hunter
			}
			20 = {
				modifier = {
					factor = 0
					NOT = {
						has_dlc = "Reapers"
					}
				}
				add_trait = disfigured
				add_trait = scarred
				add_trait = genius
				change_martial = 2
				change_intrigue = 12
				give_nickname = nick_of_a_thousand_faces
			}
			20 = {
				add_trait = genius
				add_trait = clubfooted
				change_martial = 1
				give_nickname = nick_the_bear
			}
			20 = {
				add_trait = trusting
				add_trait = quick
				change_martial = 4
				give_nickname = nick_the_loyal
			}
			20 = {
				add_trait = ugly
				add_trait = strong
				add_trait = duelist
				change_martial = 1
				give_nickname = nick_the_boar
			}
			20 = {
				add_trait = fair
				add_trait = strategist
				change_martial = 4
				give_nickname = nick_the_lion
			}
			20 = {
				add_trait = brave
				add_trait = duelist
				change_martial = 3
				give_nickname = nick_the_bold
			}
			20 = {
				add_trait = shrewd
				add_trait = hedonist
				change_martial = 4
				give_nickname = nick_the_quarreller
			}
			20 = {
				add_trait = shrewd
				add_trait = cavalry_leader
				change_martial = 2
				give_nickname = nick_the_wolf
			}
		}
		emf_new_character_noble = yes
		set_character_flag = invited_soldier
		save_event_target_as = invited_character
	}
}

spawn_fantastic_diplomat_effect = {

	if = { 
		limit = { has_religion_feature = religion_matriarchal }
		create_random_diplomat = {
			random_traits = yes
			dynasty = actually_culture
			female = yes
			attributes = {
				diplomacy = 12
				learning = 4
				stewardship = 4
				intrigue = 4
				martial = 4
			}
		}
	}
	else_if = { 
		limit = { gender_equality_trigger = yes }
		create_random_diplomat = {
			random_traits = yes
			dynasty = actually_culture
			female = 50
			attributes = {
				diplomacy = 12
				learning = 4
				stewardship = 4
				intrigue = 4
				martial = 4
			}
		}
	}
	else = {
		create_random_diplomat = {
			random_traits = yes
			dynasty = actually_culture
			female = no
			attributes = {
				diplomacy = 12
				learning = 4
				stewardship = 4
				intrigue = 4
				martial = 4
			}
		}
	}
	new_character = {
		remove_trait = weak
		remove_trait = slow
		remove_trait = imbecile
		remove_trait = dull
		remove_trait = dwarf
		remove_trait = giant
		remove_trait = hunchback
		remove_trait = clubfooted
		remove_trait = craven
		remove_trait = paranoid
		
		remove_trait = mystic
		remove_trait = socializer
		remove_trait = gamer
		remove_trait = hedonist
		remove_trait = duelist
		remove_trait = hunter
		remove_trait = strategist
		remove_trait = administrator
		remove_trait = architect
		remove_trait = gardener
		remove_trait = schemer
		remove_trait = impaler
		remove_trait = seducer
		remove_trait = seductress
		remove_trait = theologian
		remove_trait = scholar
		
		remove_trait = naive_appeaser
		remove_trait = underhanded_rogue
		remove_trait = charismatic_negotiator
		
		add_trait = grey_eminence

		random_list = {
			27 = {
				add_trait = shrewd
			}
			3 = {
				add_trait = quick
			}
			70 = {
				health = 1
			}
		}
		if = {
			limit = {
				has_global_flag = christian_crusades_unlocked
				OR = {
					religion = catholic
					religion = fraticelli
				}
			}
			random = { 
				chance = 20 
				add_trait = crusader
			}
		}
		
		emf_new_character_noble = yes
		set_character_flag = invited_soldier
		save_event_target_as = invited_character
	}
}

spawn_fantastic_scholar_effect = {
	random_list = {
		50 = {
			modifier = {
				factor = 0
				religion_allows_male_temple_holders = no
			}
			create_random_priest = {
				random_traits = yes
				dynasty = actually_culture
				female = no
				attributes = {
					diplomacy = 4
					learning = 12
					stewardship = 4
					intrigue = 4
					martial = 4
				}
			}
		}
		50 = {
			modifier = {
				factor = 0
				religion_allows_female_temple_holders = no
			}
			create_random_priest = {
				random_traits = yes
				dynasty = actually_culture
				female = yes
				attributes = {
					diplomacy = 4
					learning = 12
					stewardship = 4
					intrigue = 4
					martial = 4
				}
			}
		}
	}
	new_character = {
		remove_trait = weak
		remove_trait = slow
		remove_trait = imbecile
		remove_trait = dull
		remove_trait = dwarf
		remove_trait = giant
		remove_trait = hunchback
		remove_trait = clubfooted
		remove_trait = craven
		remove_trait = paranoid
		
		remove_trait = mystic
		remove_trait = socializer
		remove_trait = gamer
		remove_trait = hedonist
		remove_trait = duelist
		remove_trait = hunter
		remove_trait = strategist
		remove_trait = administrator
		remove_trait = architect
		remove_trait = gardener
		remove_trait = schemer
		remove_trait = impaler
		remove_trait = seducer
		remove_trait = seductress
		remove_trait = theologian
		remove_trait = scholar
		
		remove_trait = detached_priest
		remove_trait = martial_cleric
		remove_trait = scholarly_theologian
		
		add_trait = mastermind_theologian

		random_list = {
			27 = {
				add_trait = shrewd
			}
			3 = {
				add_trait = quick
			}
			70 = {
				change_diplomacy = 1
			}
		}
		if = {
			limit = { has_dharmic_religion_trigger = yes }
			if = {
				limit = { religion = hindu }
				add_trait = brahmin
			}
			character_event = { id = RoI.30121 }
		}
		emf_new_character = yes
		set_character_flag = invited_soldier
		save_event_target_as = invited_character
	}
}

spawn_elder_effect = {
	random_list = {
		50 = {
			modifier = {
				factor = 0
				has_religion_feature = religion_matriarchal
			}
			create_random_priest = {
				random_traits = yes
				dynasty = actually_culture
				female = no
				age = 50
				attributes = {
					diplomacy = 4
					learning = 10
					stewardship = 6
					intrigue = 4
					martial = 4
				}
			}
		}
		50 = {
			modifier = {
				factor = 0
				has_religion_feature = religion_patriarchal
			}
			create_random_priest = {
				random_traits = yes
				dynasty = actually_culture
				female = yes
				age = 50
				attributes = {
					diplomacy = 4
					learning = 10
					stewardship = 6
					intrigue = 4
					martial = 4
				}
			}
		}
	}
	new_character = {
		remove_trait = weak
		remove_trait = slow
		remove_trait = imbecile
		remove_trait = dull
		remove_trait = dwarf
		remove_trait = giant
		remove_trait = hunchback
		remove_trait = clubfooted
		remove_trait = craven
		remove_trait = paranoid
		
		remove_trait = mystic
		remove_trait = socializer
		remove_trait = gamer
		remove_trait = hedonist
		remove_trait = duelist
		remove_trait = hunter
		remove_trait = strategist
		remove_trait = administrator
		remove_trait = architect
		remove_trait = gardener
		remove_trait = schemer
		remove_trait = impaler
		remove_trait = seducer
		remove_trait = seductress
		remove_trait = theologian
		remove_trait = scholar
		
		remove_trait = detached_priest
		remove_trait = martial_cleric
		remove_trait = scholarly_theologian
		remove_trait = mastermind_theologian
		
		add_character_modifier = { name = elder_long_life_modifier years = 100 }
		give_nickname = nick_the_elder 

		random_list = {
			50 = {
				add_trait = martial_cleric
			}
			25 = {
				add_trait = scholarly_theologian
			}
			10 = {
				add_trait = mastermind_theologian
			}
		}
		random_list = {
			5 = {
				add_trait = stubborn
			}
			1 = {
				add_trait = mystic
			}
			1 = {
				add_trait = hunchback
			}
			1 = {
				add_trait = ugly
			}
			10 = {
				add_scarred_tiered_effect = yes
			}
			70 = {
				change_stewardship = 1
			}
		}
		
		hidden_tooltip = {
			if = { # Assign African face paint
				limit = {
					OR = { 
						religion = west_african_pagan
						religion = west_african_pagan_reformed
						has_religion_feature = religion_animistic
					}
				}
				random_list = {
					25 = { #Nothing
					}
					15 = { 
						add_trait = african_tattoo_1
					}
					15 = { 
						add_trait = african_tattoo_2
					}
					15 = { 
						add_trait = african_tattoo_3
					}
					15 = { 
						add_trait = african_tattoo_4
					}
					5 = { 
						add_trait = african_tattoo_5
					}
					4 = { 
						add_trait = african_tattoo_6
					}
					3 = { 
						add_trait = african_tattoo_7
					}
					2 = { 
						add_trait = african_tattoo_8
					}
					10 = { 
						add_trait = african_tattoo_9
					}
					10 = { 
						add_trait = african_tattoo_10
					}
					10 = { 
						add_trait = african_tattoo_11
					}
					10 = { 
						add_trait = african_tattoo_12
					}
				}
				if = { 
					limit = { NOT = { age = 23 } }
					random_list = { #Modifier, if young enough.
						10 = { #Nothing
						}
						25 = { 
							trigger = {
								OR = {
									trait = african_tattoo_12
									trait = african_tattoo_8
									trait = african_tattoo_2
								}
							}
							add_character_modifier = {
								name = african_adulthood_rites_1
								years = 6
							} 
						}
						25 = { 
							trigger = {
								OR = {
									trait = african_tattoo_10
									trait = african_tattoo_7
									trait = african_tattoo_1
								}
							}
							add_character_modifier = {
								name = african_adulthood_rites_2
								years = 6
							} 
						}
						25 = { 
							trigger = {
								OR = {
									trait = african_tattoo_9
									trait = african_tattoo_6
									trait = african_tattoo_3
								}
							}
							add_character_modifier = {
								name = african_adulthood_rites_3
								years = 6
							} 
						}
						25 = { 
							trigger = {
								OR = {
									trait = african_tattoo_11
									trait = african_tattoo_5
									trait = african_tattoo_4
								}
							}
							add_character_modifier = {
								name = african_adulthood_rites_4
								years = 6
							} 
						}
					}
				}
			}
		}
		if = {
			limit = { has_dharmic_religion_trigger = yes }
			if = {
				limit = { religion = hindu }
				add_trait = brahmin
			}
			character_event = { id = RoI.30121 }
		}
		emf_new_character = yes
		set_character_flag = invited_elder
		save_event_target_as = invited_character
	}
}
select_random_hermetic_ingredient_herb_effect = { # If run once, this will set a flag on ONE herbal ingredient. If run twice, it will set a second flag on another herbal ingredient...
	if = {
		limit = {
			any_artifact = {
				has_artifact_flag = selected_ingredient_1
			}
			NOT = {
				any_artifact = {
					has_artifact_flag = selected_ingredient_2
				}
			}
		}
		random_artifact = {
			limit = {
				is_ingredient_herb_trigger = yes
				NOT = { has_artifact_flag = selected_ingredient_1 }
				NOT = { has_artifact_flag = selected_ingredient_2 }
			}
			set_artifact_flag = selected_ingredient_2
		}
	}
	if = {
		limit = {
			NOT = {
				any_artifact = {
					has_artifact_flag = selected_ingredient_1
				}
			}	
		}
		random_artifact = {
			limit = {
				is_ingredient_herb_trigger = yes
				NOT = { has_artifact_flag = selected_ingredient_1 }
				NOT = { has_artifact_flag = selected_ingredient_2 }
			}
			set_artifact_flag = selected_ingredient_1
		}
	}
}

select_random_hermetic_ingredient_animal_part_effect = { 
	if = {
		limit = {
			any_artifact = {
				has_artifact_flag = selected_ingredient_1
			}
			NOT = {
				any_artifact = {
					has_artifact_flag = selected_ingredient_2
				}
			}
		}
		random_artifact = {
			limit = {
				is_ingredient_animal_part_trigger = yes
				NOT = { has_artifact_flag = selected_ingredient_1 }
				NOT = { has_artifact_flag = selected_ingredient_2 }
			}
			set_artifact_flag = selected_ingredient_2
		}
	}
	if = {
		limit = {
			NOT = {
				any_artifact = {
					has_artifact_flag = selected_ingredient_1
				}
			}	
		}
		random_artifact = {
			limit = {
				is_ingredient_animal_part_trigger = yes
				NOT = { has_artifact_flag = selected_ingredient_1 }
				NOT = { has_artifact_flag = selected_ingredient_2 }
			}
			set_artifact_flag = selected_ingredient_1
		}
	}
}

select_random_hermetic_ingredient_powder_effect = {
	if = {
		limit = {
			any_artifact = {
				has_artifact_flag = selected_ingredient_1
			}
			NOT = {
				any_artifact = {
					has_artifact_flag = selected_ingredient_2
				}
			}
		}
		random_artifact = {
			limit = {
				is_ingredient_powder_trigger = yes
				NOT = { has_artifact_flag = selected_ingredient_1 }
				NOT = { has_artifact_flag = selected_ingredient_2 }
			}
			set_artifact_flag = selected_ingredient_2
		}
	}
	if = {
		limit = {
			NOT = {
				any_artifact = {
					has_artifact_flag = selected_ingredient_1
				}
			}	
		}
		random_artifact = {
			limit = {
				is_ingredient_powder_trigger = yes
				NOT = { has_artifact_flag = selected_ingredient_1 }
				NOT = { has_artifact_flag = selected_ingredient_2 }
			}
			set_artifact_flag = selected_ingredient_1
		}
	}
}

select_random_hermetic_ingredient_liquid_effect = {
	if = {
		limit = {
			any_artifact = {
				has_artifact_flag = selected_ingredient_1
			}
			NOT = {
				any_artifact = {
					has_artifact_flag = selected_ingredient_2
				}
			}
		}
		random_artifact = {
			limit = {
				is_ingredient_liquid_trigger = yes
				NOT = { has_artifact_flag = selected_ingredient_1 }
				NOT = { has_artifact_flag = selected_ingredient_2 }
			}
			set_artifact_flag = selected_ingredient_2
		}
	}
	if = {
		limit = {
			NOT = {
				any_artifact = {
					has_artifact_flag = selected_ingredient_1
				}
			}	
		}
		random_artifact = {
			limit = {
				is_ingredient_liquid_trigger = yes
				NOT = { has_artifact_flag = selected_ingredient_1 }
				NOT = { has_artifact_flag = selected_ingredient_2 }
			}
			set_artifact_flag = selected_ingredient_1
		}
	}
}

select_random_hermetic_ingredient_effect = { #when it doesn't matter if it's a herb/animal part/metal/liquid
	if = {
		limit = {
			has_selected_ingredient_1_trigger = yes
			has_selected_ingredient_2_trigger = no
		}
		random_artifact = {
			limit = {
				NOT = { has_artifact_flag = selected_ingredient_1 }
				NOT = { has_artifact_flag = selected_ingredient_2 }
				has_artifact_flag = ingredient
			}
			set_artifact_flag = selected_ingredient_2
		}
	}
	if = {
		limit = {
			has_selected_ingredient_1_trigger = no
			any_artifact = {
				has_artifact_flag = ingredient
			}
		}
		random_artifact = {
			limit = {
				NOT = { has_artifact_flag = selected_ingredient_1 }
				NOT = { has_artifact_flag = selected_ingredient_2 }
				has_artifact_flag = ingredient
			}
			set_artifact_flag = selected_ingredient_1
		}
	}
}

remove_selection_of_ingredients_effect = { #for clearing selection of ingredients
	hidden_effect = {
		any_artifact = {
			clr_artifact_flag = selected_ingredient_1
			clr_artifact_flag = selected_ingredient_2
		}
	}
}

destroy_selected_ingredient_1_effect = { #for removing the ingredient in question
	custom_tooltip = { text = destroy_selected_ingredient_1_tt }
	hidden_effect = {
		random_artifact = {
			limit = { has_artifact_flag = selected_ingredient_1 }
			destroy_artifact = yes
		}
	}
}

destroy_selected_ingredient_2_effect = { #for removing the ingredient in question
	custom_tooltip = { text = destroy_selected_ingredient_2_tt }
	hidden_effect = {
		random_artifact = {
			limit = { has_artifact_flag = selected_ingredient_2 }
			destroy_artifact = yes
		}
	}
}

destroy_selected_ingredient_1_and_2_effect = { #for removing both selected ingredients
	custom_tooltip = { text = destroy_selected_ingredient_1_and_2_tt }
	hidden_effect = {
		random_artifact = {
			limit = { has_artifact_flag = selected_ingredient_1 }
			destroy_artifact = yes
		}
		random_artifact = {
			limit = { has_artifact_flag = selected_ingredient_2 }
			destroy_artifact = yes
		}
	}
}

destroy_selected_ingredient_1_plus_random_other_ingredient_effect = { #for removing the ingredient in question PLUS a random other one (unnamed in tooltip)
	custom_tooltip = { text = destroy_selected_ingredient_1_plus_random_other_ingredient_tt }
	hidden_effect = {
		random_artifact = {
			limit = { has_artifact_flag = selected_ingredient_1 }
			destroy_artifact = yes
		}
		random_artifact = {
			limit = {
				has_artifact_flag = ingredient
			}
			destroy_artifact = yes
		}
	}
}

destroy_random_herb_ingredient_effect = {
	random_artifact = {
		limit = {
			has_artifact_flag = ingredient
			is_ingredient_herb_trigger = yes
		}
		destroy_artifact = yes
	}
}

destroy_random_animal_part_ingredient_effect = {
	random_artifact = {
		limit = {
			has_artifact_flag = ingredient
			is_ingredient_animal_part_trigger = yes
		}
		destroy_artifact = yes
	}
}

destroy_random_powder_ingredient_effect = {
	random_artifact = {
		limit = {
			has_artifact_flag = ingredient
			is_ingredient_powder_trigger = yes
		}
		destroy_artifact = yes
	}
}

destroy_random_liquid_ingredient_effect = {
	random_artifact = {
		limit = {
			has_artifact_flag = ingredient
			is_ingredient_liquid_trigger = yes
		}
		destroy_artifact = yes
	}
}

destroy_random_herb_or_animal_part_ingredients_effect = {
	hidden_effect = {
		random_list = {
			5 = {
				trigger = { has_a_herb_ingredient_trigger = yes }
				destroy_random_herb_ingredient_effect = yes
			}
			5 = {
				trigger = { has_an_animal_part_ingredient_trigger = yes }
				destroy_random_animal_part_ingredient_effect = yes
			}
			20 = {
				trigger = {
					any_artifact = {
						count = 2
						is_ingredient_herb_trigger = yes
						has_artifact_flag = ingredient
					}
				}
				destroy_random_herb_ingredient_effect = yes
				destroy_random_herb_ingredient_effect = yes
			}
			20 = {
				trigger = {
					any_artifact = {
						count = 2
						is_ingredient_animal_part_trigger = yes
						has_artifact_flag = ingredient
					}
				}
				destroy_random_animal_part_ingredient_effect = yes
				destroy_random_animal_part_ingredient_effect = yes
			}
			20 = {
				trigger = {
					has_a_herb_ingredient_trigger = yes
					has_an_animal_part_ingredient_trigger = yes
				}
				destroy_random_herb_ingredient_effect = yes
				destroy_random_animal_part_ingredient_effect = yes
			}
			20 = {
				trigger = {
					any_artifact = {
						count = 3
						is_ingredient_herb_trigger = yes
						has_artifact_flag = ingredient
					}
				}
				destroy_random_herb_ingredient_effect = yes
				destroy_random_herb_ingredient_effect = yes
				destroy_random_herb_ingredient_effect = yes
			}
			20 = {
				trigger = {
					any_artifact = {
						count = 3
						is_ingredient_animal_part_trigger = yes
						has_artifact_flag = ingredient
					}
				}
				destroy_random_animal_part_ingredient_effect = yes
				destroy_random_animal_part_ingredient_effect = yes
				destroy_random_animal_part_ingredient_effect = yes
			}
			50 = {
				trigger = {
					any_artifact = {
						count = 2
						is_ingredient_herb_trigger = yes
						has_artifact_flag = ingredient
					}
					has_an_animal_part_ingredient_trigger = yes
				}
				destroy_random_herb_ingredient_effect = yes
				destroy_random_herb_ingredient_effect = yes
				destroy_random_animal_part_ingredient_effect = yes
			}
			50 = {
				trigger = {								
					any_artifact = {
						count = 2
						is_ingredient_animal_part_trigger = yes
						has_artifact_flag = ingredient
					}
					has_a_herb_ingredient_trigger = yes
				}
				destroy_random_herb_ingredient_effect = yes
				destroy_random_animal_part_ingredient_effect = yes
				destroy_random_animal_part_ingredient_effect = yes
			}
		}
	}
}

destroy_random_ingredients_effect = {
	custom_tooltip = { text = random_ingredients_are_destroyed_tt }
	hidden_effect = {
		random_list = {
			5 = {
				random_artifact = {
					limit = { has_artifact_flag = ingredient }
					destroy_artifact = yes
				}
			}
			50 = {
				trigger = {
					any_artifact = {
						count = 2
						has_artifact_flag = ingredient
					}
				}
				random_artifact = {
					limit = { has_artifact_flag = ingredient }
					destroy_artifact = yes
				}
				random_artifact = {
					limit = { has_artifact_flag = ingredient }
					destroy_artifact = yes
				}
			}
			100 = {
				trigger = {
					any_artifact = {
						count = 3
						has_artifact_flag = ingredient
					}
				}
				random_artifact = {
					limit = { has_artifact_flag = ingredient }
					destroy_artifact = yes
				}
				random_artifact = {
					limit = { has_artifact_flag = ingredient }
					destroy_artifact = yes
				}
				random_artifact = {
					limit = { has_artifact_flag = ingredient }
					destroy_artifact = yes
				}
			}
			150 = {
				trigger = {
					any_artifact = {
						count = 4
						has_artifact_flag = ingredient
					}
				}
				random_artifact = {
					limit = { has_artifact_flag = ingredient }
					destroy_artifact = yes
				}
				random_artifact = {
					limit = { has_artifact_flag = ingredient }
					destroy_artifact = yes
				}
				random_artifact = {
					limit = { has_artifact_flag = ingredient }
					destroy_artifact = yes
				}
				random_artifact = {
					limit = { has_artifact_flag = ingredient }
					destroy_artifact = yes
				}
			}
		}
	}
}

destroy_all_ingredients_effect = {
	custom_tooltip = { text = destroy_all_ingredients_tt }
	hidden_effect = {
        if = {
        	limit = {
        		any_artifact = {
		    		has_artifact_flag = ingredient
	    		}
        	}
        	any_artifact = {
        		limit = { has_artifact_flag = ingredient }
        		destroy_artifact = yes
        	}
        }
	}
}


calculate_health_level_of_ingredient_1_effect = {
	hidden_effect = {
        set_variable = { # Reset potion quality
    		which = current_potion_quality
    		value = 0
    	}
    	if = {
    		limit = {
    			any_artifact = { has_artifact_flag = selected_ingredient_1 }
    			ingredient_is_perceived_healthy_trigger = yes
    		}
 			ROOT = {
                change_variable = {
                    which = current_potion_quality
                    value = 1
                }
            }
    	}
    	if = {
    		limit = {
    			any_artifact = { has_artifact_flag = selected_ingredient_1 }
    			ingredient_is_unhealthy_trigger = yes
    		}
 			ROOT = {
                change_variable = {
                    which = current_potion_quality
                    value = -1
                }
            }
    	}
    }
}

calculate_health_level_of_ingredient_2_effect = {
	hidden_effect = {
        set_variable = { # Reset potion quality
    		which = current_potion_quality
    		value = 0
    	}
    	if = {
    		limit = {
    			any_artifact = { has_artifact_flag = selected_ingredient_2 }
    			ingredient_is_perceived_healthy_trigger = yes
    		}
 			ROOT = {
                change_variable = {
                    which = current_potion_quality
                    value = 1
                }
            }
    	}
    	if = {
    		limit = {
    			any_artifact = { has_artifact_flag = selected_ingredient_2 }
    			ingredient_is_unhealthy_trigger = yes
    		}
 			ROOT = {
                change_variable = {
                    which = current_potion_quality
                    value = -1
                }
            }
    	}
    }
}

calculate_health_level_of_ingredient_1_and_2_effect = {
	hidden_effect = {
        set_variable = { # Reset potion quality
    		which = current_potion_quality
    		value = 0
    	}
		while = {
			limit = {
				any_artifact = {
		            OR = {
						has_artifact_flag = selected_ingredient_1
						has_artifact_flag = selected_ingredient_2
					}
		            NOT = { has_artifact_flag = ingredient_counted }
		        }
		    }
		    random_artifact = {
		        limit = {
		            OR = {
						has_artifact_flag = selected_ingredient_1
						has_artifact_flag = selected_ingredient_2
					}
		            NOT = { has_artifact_flag = ingredient_counted }
		        }
		        set_artifact_flag = ingredient_counted
		        if = {
		            limit = {
		                ingredient_is_perceived_healthy_trigger = yes
		            }
		            ROOT = {
		                change_variable = {
		                    which = current_potion_quality
		                    value = 1
		                }
		            }
		        }
		        if = {
		            limit = {
		                ingredient_is_unhealthy_trigger = yes
		            }
		            ROOT = {
		                change_variable = {
		                    which = current_potion_quality
		                    value = -1
		                }
		            }
		        }
		    }
		}
		any_artifact = {
			clr_artifact_flag = ingredient_counted
		}
    }
}

calculate_health_level_of_all_ingredients_effect = {
	hidden_effect = {
		while = {
			limit = {
				any_artifact = {
		            has_artifact_flag = ingredient
		            NOT = { has_artifact_flag = ingredient_counted }
		        }
		    }
		    random_artifact = {
		        limit = {
		            has_artifact_flag = ingredient
		            NOT = { has_artifact_flag = ingredient_counted }
		        }
		        set_artifact_flag = ingredient_counted
		        if = {
		            limit = {
		                ingredient_is_perceived_healthy_trigger = yes
		            }
		            ROOT = {
		                change_variable = {
		                    which = current_potion_quality
		                    value = 1
		                }
		            }
		        }
		        if = {
		            limit = {
		                ingredient_is_unhealthy_trigger = yes
		            }
		            ROOT = {
		                change_variable = {
		                    which = current_potion_quality
		                    value = -1
		                }
		            }
		        }
		    }
		}
		any_artifact = {
			clr_artifact_flag = ingredient_counted
		}
    }
}
#Raiding adventurer war declaration effect
raiding_adventurer_war_declaration_effect = {
	custom_tooltip = { text = raiding_adventurer_war_declaration_tooltip }

	event_target:selling_province = {
		event_target:raiding_adventurer = {
			unsafe_war = {
				target = PREVPREV
				casus_belli = duchy_adventure
				thirdparty_title = PREV
				tier = DUKE
			}
			any_army = {
				set_can_toggle_looting = yes
				set_looting = no
			}
		}
	}
	
	clr_character_flag = adventurer_unsafe_duchy_war
	clr_character_flag = adventurer_safe_duchy_war
	clr_character_flag = negotiating_with_adventurer

	hidden_effect = {
		event_target:raiding_adventurer = {
			clr_character_flag = raiding_adventurer
		}
	}
}


#Grace effects
add_grace_trivial_effect = {
	add_offmap_currency = {
		offmap = offmap_china
		value = 100
	}
}

add_grace_minor_effect = {
	add_offmap_currency = {
		offmap = offmap_china
		value = 200
	}
}

add_grace_medium_effect = {
	add_offmap_currency = {
		offmap = offmap_china
		value = 300
	}	
}

add_grace_major_effect = {
	add_offmap_currency = {
		offmap = offmap_china
		value = 500
	}
}

add_grace_massive_effect = {
	add_offmap_currency = {
		offmap = offmap_china
		value = 1000
	}
}

add_grace_super_huge_effect = {
	add_offmap_currency = {
		offmap = offmap_china
		value = 2000
	}
}

detract_grace_trivial_effect = {
	add_offmap_currency = {
		offmap = offmap_china
		value = -100
	}
}

detract_grace_minor_effect = {
	add_offmap_currency = {
		offmap = offmap_china
		value = -200
	}
}

detract_grace_medium_effect = {
	add_offmap_currency = {
		offmap = offmap_china
		value = -300
	}
}

detract_grace_major_effect = {
	add_offmap_currency = {
		offmap = offmap_china
		value = -500
	}
}

detract_grace_massive_effect = {
	add_offmap_currency = {
		offmap = offmap_china
		value = -1000
	}
}

detract_grace_super_huge_effect = {
	add_offmap_currency = {
		offmap = offmap_china
		value = -2000
	}
}

set_china_boon_cd_effect = {  #added via tribute to China decisions... Always one year.
	add_character_modifier = {
		hidden = yes
		name = jd_china_boon_cd
		days = 365 #If this is changed, edit  china_offmap_boon_decisions_enabled_trigger_cd_tt
	}
}

set_china_tribute_cd_effect = { #added via tribute to China decisions... Always one year.
	add_character_modifier = {
		hidden = yes
		name = jd_china_tribute_cd
		days = 365
	}
}

leave_court_for_china_effect = { # NOTE: this does not set a "killer", meaning if you want them to be ORDERED to go to China, a killer needs to be set (eg: "killer = ROOT")
	custom_tooltip = {
		text = will_leave_for_china_tt
	}
	set_character_flag = ignore_refund
	hidden_effect = { death = { death_reason = death_went_to_china } }
}

return_to_china_effect = { # NOTE: this does not set a "killer", meaning if you want them to be ORDERED to go to China, a killer needs to be set (eg: "killer = ROOT")
	custom_tooltip = {
		text = will_return_to_china_tt
	}
	set_character_flag = ignore_refund
	hidden_effect = { death = { death_reason = death_went_back_to_china } }
}

# Utilizes china_war_minimum_commander_martial variable on the current scope to spawn characters with at least that amount of martial skill.
china_spawn_commander_effect = {
	create_random_soldier = {
		random_traits = yes
		religion = liege
		culture = liege
		dynasty = none
		female = no
		age = 28
	}
	new_character = {
		unsafe_give_minor_title = title_commander
		
		set_variable = {
			which = china_war_minimum_commander_martial
			which = PREV
		}
		if = {
			limit = {
				NOT = { trait = brilliant_strategist }
			}
			remove_trait = misguided_warrior
			remove_trait = tough_soldier
			remove_trait = skilled_tactician
			add_trait = skilled_tactician
			# Make sure they have a tier 3 or tier 4 education
		}
		random_list = { # Give a chance to get Chinese commander traits
			30 = {
				trigger = {
					can_have_more_leadership_traits = yes
					NOT = { trait = master_of_flame }
				}
				add_trait = master_of_flame
			}
			30 = {
				trigger = {
					can_have_more_leadership_traits = yes
					NOT = { trait = logistics_expert }
				}
				add_trait = logistics_expert
			}
			30 = {
				trigger = {
					can_have_more_leadership_traits = yes
					NOT = { trait = levy_coordinator }
				}
				add_trait = levy_coordinator
			}
			30 = {
				trigger = {
					can_have_more_leadership_traits = yes
					NOT = { trait = sapper }
				}
				add_trait = sapper
			}
			90 = {}
		}
		while = { # Increase the martial skill with base or martial traits until the minimum is reached
			limit = {
				NOT = {
					martial = china_war_minimum_commander_martial
				}
			}
			random_list = {
				40 = {
					change_martial = 1
				}
				5 = {
					trigger = { 
						NOR = { 
							trait = strong
							trait = robust
							calc_true_if = {
								amount = 3
								trait = strong 
								trait = robust 
								trait = shrewd 
								trait = duelist 
								trait = hunter 
								trait = strategist 
								trait = architect 
								trait = diligent 
								trait = brave 
								trait = ambitious
							}
						}
					}
					add_trait = strong
				}
				5 = {
					trigger = { 
						NOR = { 
							trait = strong
							trait = robust
							calc_true_if = {
								amount = 3
								trait = strong 
								trait = robust 
								trait = shrewd 
								trait = duelist 
								trait = hunter 
								trait = strategist 
								trait = architect 
								trait = diligent 
								trait = brave 
								trait = ambitious
							}
						}
					}
					add_trait = robust
				}
				5 = {
					trigger = { 
						NOR = { 
							trait = shrewd
							trait = genius
							calc_true_if = {
								amount = 3
								trait = strong 
								trait = robust 
								trait = shrewd 
								trait = duelist 
								trait = hunter 
								trait = strategist 
								trait = architect 
								trait = diligent 
								trait = brave 
								trait = ambitious
							}
						}
					}
					add_trait = shrewd
				}
				5 = {
					trigger = { 
						NOR = { 
							trait = duelist
							trait = hunter
							trait = strategist
							trait = architect
							calc_true_if = {
								amount = 3
								trait = strong 
								trait = robust 
								trait = shrewd 
								trait = duelist 
								trait = hunter 
								trait = strategist 
								trait = architect 
								trait = diligent 
								trait = brave 
								trait = ambitious
							}
						}
					}
					add_trait = duelist
				}
				5 = {
					trigger = { 
						NOR = { 
							trait = duelist
							trait = hunter
							trait = strategist
							trait = architect
							calc_true_if = {
								amount = 3
								trait = strong 
								trait = robust 
								trait = shrewd 
								trait = duelist 
								trait = hunter 
								trait = strategist 
								trait = architect 
								trait = diligent 
								trait = brave 
								trait = ambitious
							}
						}
					}
					add_trait = hunter
				}
				5 = {
					trigger = { 
						NOR = { 
							trait = duelist
							trait = hunter
							trait = strategist
							trait = architect
							calc_true_if = {
								amount = 3
								trait = strong 
								trait = robust 
								trait = shrewd 
								trait = duelist 
								trait = hunter 
								trait = strategist 
								trait = architect 
								trait = diligent 
								trait = brave 
								trait = ambitious
							}
						}
					}
					add_trait = strategist
				}
				5 = {
					trigger = { 
						NOR = { 
							trait = duelist
							trait = hunter
							trait = strategist
							trait = architect
							calc_true_if = {
								amount = 3
								trait = strong 
								trait = robust 
								trait = shrewd 
								trait = duelist 
								trait = hunter 
								trait = strategist 
								trait = architect 
								trait = diligent 
								trait = brave 
								trait = ambitious
							}
						}
					}
					add_trait = architect
				}
				5 = {
					trigger = { 
						NOR = { 
							trait = diligent
							calc_true_if = {
								amount = 3
								trait = strong 
								trait = robust 
								trait = shrewd 
								trait = duelist 
								trait = hunter 
								trait = strategist 
								trait = architect 
								trait = diligent 
								trait = brave 
								trait = ambitious
							}
						}
					}
					add_trait = diligent
				}
				5 = {
					trigger = { 
						NOR = { 
							trait = brave
							calc_true_if = {
								amount = 3
								trait = strong 
								trait = robust 
								trait = shrewd 
								trait = duelist 
								trait = hunter 
								trait = strategist 
								trait = architect 
								trait = diligent 
								trait = brave 
								trait = ambitious
							}
						}
					}
					add_trait = brave
				}
				5 = {
					trigger = { 
						NOR = { 
							trait = ambitious
							calc_true_if = {
								amount = 3
								trait = strong 
								trait = robust 
								trait = shrewd 
								trait = duelist 
								trait = hunter 
								trait = strategist 
								trait = architect 
								trait = diligent 
								trait = brave 
								trait = ambitious
							}
						}
					}
					add_trait = ambitious
				}
			}
		}
		emf_new_character_noble = yes
	}
}

china_war_spawn_troops_effect = {
	# Requires the current things to function properly:
	# event_target:spawn_province
	# variable: china_war_troop_quality
	# variable: china_war_troop_quantity
	while = {
		limit = {
			check_variable = {
				which = china_war_troop_quantity
				value = 1
			}
		}
		change_variable = {	
			which = china_war_troop_quantity
			value = -1
		}
		
		random_list = { # Not really random but decent flow control
			10 = {
				trigger = {
					NOT = {
						check_variable = {
							which = china_war_troop_quality
							value = 2
						}
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 168 168 }
						light_infantry = { 284 284 }
						heavy_infantry = { 0 0 }
						pikemen = { 0 0 }
						light_cavalry = { 41 41 }
						knights = { 0 0 }
					}
					#attrition = 1
					disband_on_peace = yes
					merge = yes
				}
			}
			10 = {
				trigger = {
					check_variable = {
						which = china_war_troop_quality
						value = 2
					}
					NOT = {
						check_variable = {
							which = china_war_troop_quality
							value = 3
						}
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 148 148 }
						light_infantry = { 264 264 }
						heavy_infantry = { 0 0 }
						pikemen = { 0 0 }
						light_cavalry = { 81 81 }
						knights = { 0 0 }
					}
					#attrition = 1
					disband_on_peace = yes
					merge = yes
				}
			}
			10 = {
				trigger = {
					check_variable = {
						which = china_war_troop_quality
						value = 3
					}
					NOT = {
						check_variable = {
							which = china_war_troop_quality
							value = 4
						}
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 144 144 }
						light_infantry = { 221 221 }
						heavy_infantry = { 49 49 }
						pikemen = { 0 0 }
						light_cavalry = { 79 79 }
						knights = { 0 0 }
					}
					#attrition = 1
					disband_on_peace = yes
					merge = yes
				}
			}
			10 = {
				trigger = {
					check_variable = {
						which = china_war_troop_quality
						value = 4
					}
					NOT = {
						check_variable = {
							which = china_war_troop_quality
							value = 5
						}
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 144 144 }
						light_infantry = { 203 203 }
						heavy_infantry = { 66 66 }
						pikemen = { 19 19 }
						light_cavalry = { 61 61 }
						knights = { 0 0 }
					}
					#attrition = 1
					disband_on_peace = yes
					merge = yes
				}
			}
			10 = {
				trigger = {
					check_variable = {
						which = china_war_troop_quality
						value = 5
					}
					NOT = {
						check_variable = {
							which = china_war_troop_quality
							value = 6
						}
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 136 136 }
						light_infantry = { 134 134 }
						heavy_infantry = { 102 102 }
						pikemen = { 41 41 }
						light_cavalry = { 80 80 }
						knights = { 0 0 }
					}
					#attrition = 1
					disband_on_peace = yes
					merge = yes
				}
			}
			10 = {
				trigger = {
					check_variable = {
						which = china_war_troop_quality
						value = 6
					}
					NOT = {
						check_variable = {
							which = china_war_troop_quality
							value = 7
						}
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 122 122 }
						light_infantry = { 71 71 }
						heavy_infantry = { 85 85 }
						pikemen = { 78 78 }
						light_cavalry = { 113 113 }
						knights = { 24 24 }
					}
					#attrition = 1
					disband_on_peace = yes
					merge = yes
				}
			}
			10 = {
				trigger = {
					check_variable = {
						which = china_war_troop_quality
						value = 7
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 107 107 }
						light_infantry = { 22 22 }
						heavy_infantry = { 106 106 }
						pikemen = { 96 96 }
						light_cavalry = { 111 111 }
						knights = { 51 51 }
					}
					#attrition = 1
					disband_on_peace = yes
					merge = yes
				}
			}
		}
	}
}

china_war_spawn_troops_no_disband_effect = {
	# Requires the current things to function properly:
	# event_target:spawn_province
	# variable: china_war_troop_quality
	# variable: china_war_troop_quantity
	while = {
		limit = {
			check_variable = {
				which = china_war_troop_quantity
				value = 1
			}
		}
		change_variable = {	
			which = china_war_troop_quantity
			value = -1
		}
		
		random_list = { # Not really random but decent flow control
			10 = {
				trigger = {
					NOT = {
						check_variable = {
							which = china_war_troop_quality
							value = 2
						}
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 168 168 }
						light_infantry = { 284 284 }
						heavy_infantry = { 0 0 }
						pikemen = { 0 0 }
						light_cavalry = { 41 41 }
						knights = { 0 0 }
					}
					attrition = 0.1
					disband_on_peace = no
					merge = yes
				}
			}
			10 = {
				trigger = {
					check_variable = {
						which = china_war_troop_quality
						value = 2
					}
					NOT = {
						check_variable = {
							which = china_war_troop_quality
							value = 3
						}
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 148 148 }
						light_infantry = { 264 264 }
						heavy_infantry = { 0 0 }
						pikemen = { 0 0 }
						light_cavalry = { 81 81 }
						knights = { 0 0 }
					}
					attrition = 0.1
					disband_on_peace = no
					merge = yes
				}
			}
			10 = {
				trigger = {
					check_variable = {
						which = china_war_troop_quality
						value = 3
					}
					NOT = {
						check_variable = {
							which = china_war_troop_quality
							value = 4
						}
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 144 144 }
						light_infantry = { 221 221 }
						heavy_infantry = { 49 49 }
						pikemen = { 0 0 }
						light_cavalry = { 79 79 }
						knights = { 0 0 }
					}
					attrition = 0.1
					disband_on_peace = no
					merge = yes
				}
			}
			10 = {
				trigger = {
					check_variable = {
						which = china_war_troop_quality
						value = 4
					}
					NOT = {
						check_variable = {
							which = china_war_troop_quality
							value = 5
						}
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 144 144 }
						light_infantry = { 203 203 }
						heavy_infantry = { 66 66 }
						pikemen = { 19 19 }
						light_cavalry = { 61 61 }
						knights = { 0 0 }
					}
					attrition = 0.1
					disband_on_peace = no
					merge = yes
				}
			}
			10 = {
				trigger = {
					check_variable = {
						which = china_war_troop_quality
						value = 5
					}
					NOT = {
						check_variable = {
							which = china_war_troop_quality
							value = 6
						}
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 136 136 }
						light_infantry = { 134 134 }
						heavy_infantry = { 102 102 }
						pikemen = { 41 41 }
						light_cavalry = { 80 80 }
						knights = { 0 0 }
					}
					attrition = 0.1
					disband_on_peace = no
					merge = yes
				}
			}
			10 = {
				trigger = {
					check_variable = {
						which = china_war_troop_quality
						value = 6
					}
					NOT = {
						check_variable = {
							which = china_war_troop_quality
							value = 7
						}
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 122 122 }
						light_infantry = { 71 71 }
						heavy_infantry = { 85 85 }
						pikemen = { 78 78 }
						light_cavalry = { 113 113 }
						knights = { 24 24 }
					}
					attrition = 0.1
					disband_on_peace = no
					merge = yes
				}
			}
			10 = {
				trigger = {
					check_variable = {
						which = china_war_troop_quality
						value = 7
					}
				}
				spawn_unit = {
					owner = THIS
					province = event_target:spawn_province
					home = event_target:spawn_province
					troops = {
						archers = { 107 107 }
						light_infantry = { 22 22 }
						heavy_infantry = { 106 106 }
						pikemen = { 96 96 }
						light_cavalry = { 111 111 }
						knights = { 51 51 }
					}
					attrition = 0.1
					disband_on_peace = no
					merge = yes
				}
			}
		}
	}
}

china_war_modify_variables_by_status_effect = {
	# variable: china_war_troop_quality
	# variable: china_war_troop_quantity
	# variable: china_war_minimum_commander_martial
	# variable: china_war_target_match_mult
	
	random_list = {
		1 = {
			trigger = {
				offmap_china = { has_status = china_stable }
			}
			change_variable = { which = china_war_troop_quality value = 1 }
			change_variable = { which = china_war_minimum_commander_martial value = 3 }
		}
		1 = {
			trigger = {
				offmap_china = { has_status = china_unrest }
			}
			change_variable = { which = china_war_troop_quantity value = -6 }
			change_variable = { which = china_war_target_match_mult value = -0.15 }
		}
		1 = {
			trigger = {
				offmap_china = { has_status = china_civil_war }
			}
			change_variable = { which = china_war_troop_quantity value = -6 }
			change_variable = { which = china_war_target_match_mult value = -0.25 }
			change_variable = { which = china_war_troop_quality value = -1 }
			change_variable = { which = china_war_minimum_commander_martial value = -6 }
		}
		1 = {
			trigger = {
				OR = {
					offmap_china = { has_status = china_jurchen_invasion }
					offmap_china = { has_status = china_mongol_invasion }
				}
			}
			change_variable = { which = china_war_troop_quantity value = -7 }
			change_variable = { which = china_war_target_match_mult value = -0.4 }
			change_variable = { which = china_war_troop_quality value = -1 }
			change_variable = { which = china_war_minimum_commander_martial value = -2 }
		}
		1 = {
			trigger = {
				offmap_china = { has_status = china_famine }
			}
			change_variable = { which = china_war_troop_quantity value = -4 }
			change_variable = { which = china_war_target_match_mult value = -0.30 }
			change_variable = { which = china_war_troop_quality value = -2 }
			change_variable = { which = china_war_minimum_commander_martial value = -2 }
		}
		1 = {
			trigger = {
				offmap_china = { has_status = china_plague }
			}
			change_variable = { which = china_war_troop_quantity value = -6 }
			change_variable = { which = china_war_target_match_mult value = -0.35 }
			change_variable = { which = china_war_troop_quality value = -1 }
			change_variable = { which = china_war_minimum_commander_martial value = -4 }
		}
		1 = {
			trigger = {
				offmap_china = { has_status = china_golden_age }
			}
			change_variable = { which = china_war_target_match_mult value = 0.65 }
			change_variable = { which = china_war_troop_quality value = 2 }
			change_variable = { which = china_war_minimum_commander_martial value = 5 }
		}
	}
}


#Checks whether the Emperor likes target and shows tooltips (used in event JD.10010)
check_likes_or_dislikes_THIS_effect = {
 	if = {  #If the current Emperor LIKES target
        limit = {
            is_liked_by_China_trigger = yes
        }
        offmap_china = {
			show_scope_change = no
            custom_tooltip = { text = emperor_likes_THIS_tt }
        }
    }

    if = { #If the current Emperor DISLIKES target
        limit = {
           is_disliked_by_China_trigger = yes
        }
        offmap_china = {
			show_scope_change = no
			custom_tooltip = { text = emperor_dislikes_THIS_tt }
        }
    }

    if = { #If the current Emperor LIKES *and* DISLIKES target
        limit = {
            is_liked_and_disliked_by_China = yes
        }
        offmap_china = {
			show_scope_change = no
            custom_tooltip = { text = emperor_has_ambiguous_feelings_of_THIS_tt }
        }
    }
}

print_china_status_update_effect = {
	log = "----------------"
	log = "China Logging:"
	log = "China's status of [This.GetPrevStatus] ended after [global_temp_status_years.GetValue] years."
	log = "China's new status is [This.GetStatus]."
	log = "----------------"
	set_variable = {
		which = global_temp_status_years
		value = 0
	}
	random_list = {
		10 = {
			trigger = {
				has_status = china_stable
			}
			change_variable = {
				which = global_amount_of_times_china_stable
				value = 1
			}
		}
		10 = {
			trigger = {
				has_status = china_unrest
			}
			change_variable = {
				which = global_amount_of_times_china_unrest
				value = 1
			}
		}
		10 = {
			trigger = {
				has_status = china_civil_war
			}
			change_variable = {
				which = global_amount_of_times_china_civil_war
				value = 1
			}
		}
		10 = {
			trigger = {
				has_status = china_mongol_invasion
			}
			change_variable = {
				which = global_amount_of_times_china_mongol_invasion
				value = 1
			}
		}
		10 = {
			trigger = {
				has_status = china_jurchen_invasion
			}
			change_variable = {
				which = global_amount_of_times_china_jurchen_invasion
				value = 1
			}
		}
		10 = {
			trigger = {
				has_status = china_famine
			}
			change_variable = {
				which = global_amount_of_times_china_famine
				value = 1
			}
		}
		10 = {
			trigger = {
				has_status = china_plague
			}
			change_variable = {
				which = global_amount_of_times_china_plague
				value = 1
			}
		}
		10 = {
			trigger = {
				has_status = china_golden_age
				NOT = { has_policy = china_expansionist }
			}
			change_variable = {
				which = global_amount_of_times_china_golden_age
				value = 1
			}
		}
		10 = {
			trigger = {
				has_status = china_golden_age
				has_policy = china_expansionist
			}
			change_variable = {
				which = global_amount_of_times_china_golden_age_expansionist
				value = 1
			}
		}
	}
}

print_china_policy_update_effect = {
	log = "----------------"
	log = "China Logging:"
	log = "China's policy of [This.GetPrevPolicy] ended after [global_temp_policy_years.GetValue] years."
	log = "China's new policy is [This.GetPolicy]."
	log = "----------------"
	set_variable = {
		which = global_temp_policy_years
		value = 0
	}
	random_list = {
		10 = {
			trigger = {
				has_policy = china_open
			}
		}
		10 = {
			trigger = {
				has_policy = china_isolationist
			}
			change_variable = {
				which = global_amount_of_times_china_isolationist_policy
				value = 1
			}
		}
		10 = {
			trigger = {
				has_policy = china_expansionist
			}
			change_variable = {
				which = global_amount_of_times_china_expansionist_policy
				value = 1
			}
		}
	}
}


china_war_modify_variables_by_century_effect = {
	random_list = {
		10 = {
			trigger = {
				year = 700
				NOT = { year = 800 }
			}
		}
		10 = {
			trigger = {
				year = 800
				NOT = { year = 900 }
			}
			change_variable = {
				which = china_war_troop_quantity
				value = 2
			}
		}
		10 = {
			trigger = {
				year = 900
				NOT = { year = 1000 }
			}
			change_variable = {
				which = china_war_troop_quantity
				value = 3
			}
		}
		10 = {
			trigger = {
				year = 1000
				NOT = { year = 1100 }
			}
			change_variable = {
				which = china_war_troop_quantity
				value = 4
			}
		}
		10 = {
			trigger = {
				year = 1100
				NOT = { year = 1200 }
			}
			change_variable = {
				which = china_war_troop_quantity
				value = 5
			}
			change_variable = {
				which = china_war_target_match_mult
				value = 0.05
			}
		}
		10 = {
			trigger = {
				year = 1200
				NOT = { year = 1300 }
			}
			change_variable = {
				which = china_war_troop_quantity
				value = 7
			}
			change_variable = {
				which = china_war_target_match_mult
				value = 0.05
			}
			change_variable = {
				which = china_war_troop_quality
				value = 1
			}
		}
		10 = {
			trigger = {
				year = 1300
			}
			change_variable = {
				which = china_war_troop_quantity
				value = 8
			}
			change_variable = {
				which = china_war_target_match_mult
				value = 0.05
			}
			change_variable = {
				which = china_war_troop_quality
				value = 1
			}
		}
	}
}

print_china_ruler_update_effect = {
	log = "----------------"
	log = "Ruler of China died at the age of [From.GetAgeYears]."
	log = "New Ruler of China is [Root.GetBestName] ([From.GetCulture], From.GetReligion])."
	log = "----------------"
}

# THIS is getting the trait added, the kinslayer_target target is the person dying
# Save the event target before running this effect any time you publicly kill someone, the effect automatically checks they are a relative so you don't need to
# The event target is cleared after the trait is added so re-save the target and re-run the effect to check for another character in the same event
# The traits will overwrite each other kinslayer > familial_kinslayer > dynastic_kinslayer
add_kinslayer_trait_effect = {
	if = { #Parents, children, direct ancestors or descendants 
		limit = {
			NOT = { trait = kinslayer }
			NOT = { religion_group = muslim }
			OR = {
				is_ancestor_of = event_target:kinslayer_target
				is_descendant_of = event_target:kinslayer_target
				sibling = event_target:kinslayer_target
			}
			OR = {
				NOT = { has_dlc = "Holy Fury" }
				is_tribal = no
			}
		}
		add_trait = kinslayer
		hidden_effect = {
			character_event = {
				id = 38287 #Notify Kinslayer
			}
		}
	}
	else_if = { #Cousins, aunts/uncles (blood ones only), nieces/nephews
		limit = {
			NOR = { 
				trait = kinslayer
				trait = familial_kinslayer
			}
			NOT = { religion_group = muslim }
			OR = {
				is_cousin_of = event_target:kinslayer_target
				is_aunt_uncle_of = event_target:kinslayer_target
				is_nibling_of = event_target:kinslayer_target
			}
			OR = {
				NOT = { has_dlc = "Holy Fury" }
				is_tribal = no
			}
		}
		add_trait = familial_kinslayer
		hidden_effect = {
			character_event = {
				id = 38287 #Notify Kinslayer
			}
		}
	}
	else_if = { #Dynasty members
		limit = { 
			NOR = { 
				trait = kinslayer
				trait = familial_kinslayer
				trait = dynastic_kinslayer
			}
			NOT = { religion_group = muslim }
			is_lowborn = no
			dynasty = event_target:kinslayer_target
			OR = {
				NOT = { has_dlc = "Holy Fury" }
				is_tribal = no
			}
		}
		add_trait = dynastic_kinslayer
		hidden_effect = {
			character_event = {
				id = 38287 #Notify Kinslayer
			}
		}
	}
	else_if = { #Holy Fury Tribal only: any relative
		limit = { 
			NOR = { 
				trait = kinslayer
				trait = familial_kinslayer
				trait = dynastic_kinslayer
				trait = tribal_kinslayer
			}
			NOT = { religion_group = muslim }
			is_lowborn = no

			OR = {
				is_cousin_of = event_target:kinslayer_target
				is_aunt_uncle_of = event_target:kinslayer_target
				is_nibling_of = event_target:kinslayer_target
				dynasty = event_target:kinslayer_target
				is_ancestor_of = event_target:kinslayer_target
				is_descendant_of = event_target:kinslayer_target
				sibling = event_target:kinslayer_target
			}

			has_dlc = "Holy Fury"
			is_tribal = yes
		}
		add_trait = tribal_kinslayer
		hidden_effect = {
			character_event = {
				id = 38287 #Notify Kinslayer
			}
		}
	}
	else = {
	}
	clear_event_target = kinslayer_target
}

set_higher_quality_of_book_flags_effect = {
	if = {
		limit = {
			NOT = { has_character_flag = decent_book_potential }
			has_character_flag = good_book_potential
			has_character_flag = great_book_potential
		}
		clr_character_flag = good_book_potential
	}
	if = {
		limit = {
			NOT = { has_character_flag = decent_book_potential }
			has_character_flag = good_book_potential
			NOT = { has_character_flag = great_book_potential }
		}
		set_character_flag = great_book_potential
	}			
	if = {
		limit = {
			has_character_flag = decent_book_potential
			has_character_flag = good_book_potential
			has_character_flag = great_book_potential
		}
		clr_character_flag = decent_book_potential
	}
	if = {
		limit = {
			has_character_flag = decent_book_potential
			has_character_flag = good_book_potential
			NOT = { has_character_flag = great_book_potential }
		}
		set_character_flag = great_book_potential
	}
	if = {
		limit = {
			has_character_flag = decent_book_potential
			NOT = { has_character_flag = good_book_potential }
			NOT = { has_character_flag = great_book_potential }
		}
		set_character_flag = good_book_potential
	}
	#Fallback in case flags have cleared somehow...
	if = {
		limit = {
			NOR = {
				has_character_flag = decent_book_potential
        		has_character_flag = good_book_potential
        		has_character_flag = great_book_potential
			}
		}
		set_character_flag = decent_book_potential
	}
}

set_lower_quality_of_book_flags_effect = {
	if = {
		limit = {
			has_character_flag = decent_book_potential
			has_character_flag = good_book_potential
			NOT = { has_character_flag = great_book_potential }
		}
		clr_character_flag = good_book_potential
	}
	if = {
		limit = {
			NOT = { has_character_flag = decent_book_potential }
			has_character_flag = good_book_potential
			NOT = { has_character_flag = great_book_potential }
		}
		set_character_flag = decent_book_potential
	}
	if = {
		limit = {
			has_character_flag = decent_book_potential
			has_character_flag = good_book_potential
			has_character_flag = great_book_potential
		}
		clr_character_flag = great_book_potential
	}
	if = {
		limit = {
			NOT = { has_character_flag = decent_book_potential }
			has_character_flag = good_book_potential
			has_character_flag = great_book_potential
		}
		set_character_flag = decent_book_potential
	}
	if = {
		limit = {
			NOT = { has_character_flag = decent_book_potential }
			NOT = { has_character_flag = good_book_potential }
			has_character_flag = great_book_potential
		}
		set_character_flag = good_book_potential
	}

	#Fallback in case flags have cleared somehow...
	if = {
		limit = {
			NOR = {
				has_character_flag = decent_book_potential
        		has_character_flag = good_book_potential
        		has_character_flag = great_book_potential
			}
		}
		set_character_flag = decent_book_potential
	}
}

send_final_book_outcome_event_effect = {
	#character_event = { id = JD.10070 days = 5 random = 10 } #Testing values...
	character_event = { id = JD.10070 days = 565 random = 3650 }
}

abort_kow_tow_effect = {
	if = {
		limit = {
			NOT = { has_character_flag = kow_tow_hide_abort_notification }
		}
		character_event = { id = JD.32299 }
	}
	clear_delayed_event = { id = JD.32005 }
	clear_delayed_event = { id = JD.32200 }
	clear_delayed_event = { id = JD.32113 }
	clear_delayed_event = { id = JD.32111 }
	clear_delayed_event = { id = JD.32210 }
	clear_delayed_event = { id = JD.32290 }
	clr_character_flag = went_on_kow_tow_pilgrimage
	clean_up_after_kow_tow_effect = yes
}

return_to_travel_tombola_effect = {
	hidden_effect = {
		event_target:kow_tow_traveler = {
			subtract_variable = {
				which = china_kow_tow_travel_events
				value = 1
			}
			character_event = {
				id = JD.32005
				days = 90
				random = 60
			}
		}
	}
}

return_to_china_tombola_effect = {
	hidden_effect = {
		event_target:kow_tow_traveler = {
			subtract_variable = {
				which = china_kow_tow_travel_events
				value = 1
			}
			character_event = {
				id = JD.32210
				days = 70
				random = 30
			}
		}
	}
}

clean_up_after_kow_tow_effect = {
	remove_trait = kow_tow_travels
	clr_character_flag = do_not_disturb
	
	clr_character_flag = read_the_guanzi
	clr_character_flag = missed_loved_one
	clr_character_flag = met_mercenaries
	clr_character_flag = met_traveling_merchant
	clr_character_flag = visited_market
	clr_character_flag = kow_tow_invited_by_local_lord
	clr_character_flag = kow_tow_heavy_rain
	clr_character_flag = kow_tow_played_go
	clr_character_flag = kow_tow_hide_abort_notification
	clr_character_flag = kow_tow_visited_temple
}

add_chinese_artifact_effect = { #Used in event JD.15016 (possible to use elsewhere!)
	hidden_effect = {
		random_list = {
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_artwork } } }
				add_artifact = chinese_artwork
				new_artifact = {
					set_name = chinese_artwork_name
				}
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_calligraphy } } }
				add_artifact = chinese_calligraphy
				new_artifact = {
					set_name = chinese_calligraphy_name
				}
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_sculpture } } }
				add_artifact = chinese_sculpture
				new_artifact = {
					set_name = chinese_sculpture_name
				}
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_ceremonial_robes } } }
				add_artifact = chinese_ceremonial_robes
			}
			10 = {
				offmap_china = {
					offmap_prev_ruler = {
						save_event_target_as = prev_emperor
					}
				}
				add_artifact = chinese_prev_emperor_sculpture
				new_artifact = {
					set_name = chinese_figurine_name
				}
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_arm_protector } } }
				add_artifact = chinese_arm_protector
				new_artifact = {
					set_name = chinese_arm_protector_name
				}
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_serpent_spear } } }
				add_artifact = chinese_serpent_spear
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_ji } } }
				add_artifact = chinese_ji
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_crossbow } } }
				add_artifact = chinese_crossbow
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_bronze_sculpture } } }
				add_artifact = chinese_bronze_sculpture
				new_artifact = {
					set_name = chinese_bronze_sculpture_name 
				}
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_book_health } } }
				add_artifact = chinese_book_health
				new_artifact = {
					set_name = chinese_book_health_name
				}
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_book_law } } }
				add_artifact = chinese_book_law
				new_artifact = {
					set_name = chinese_book_law_name
				}
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_book_history } } }
				add_artifact = chinese_book_history
				new_artifact = {
					set_name = chinese_book_history_name
				}
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_book_economy } } }
				add_artifact = chinese_book_economy
				new_artifact = {
					set_name = chinese_book_economy_name
				}
			}
			1 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_painting_of_glitterhoof } } }
				add_artifact = chinese_painting_of_glitterhoof
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_tapestry } } }
				random_independent_ruler = {
					limit = {
						any_realm_province = {
							trade_route = silk_road
						}
					}
					random_realm_province = {
						limit = {
							trade_route = silk_road
						}
						save_event_target_as = tapestry_target
					}
				}
				add_artifact = chinese_tapestry
				new_artifact = {
					set_name = chinese_tapestry_name
				}
			}
			10 = {
				trigger = { ROOT = { NOT = { has_artifact = chinese_tapestry_grand } } }
				add_artifact = chinese_tapestry_grand
				new_artifact = {
					set_name = chinese_tapestry_grand_name
				}
				trigger = { ROOT = { NOT = { has_artifact = chinese_tapestry_grand } } }
			}
		}
		new_artifact = {
			save_event_target_as = chinese_artifact
		}
	}
}

root_secret_religion_provinces_convert_effect = {
	ROOT = { emf_sr_flip_secret_community_provinces_of_PREV = yes }
}

random_coronation_events_effect = {
	random_list = {
			#King befriends foreign ruler
			#King befriends vassal
			#King's new acquaintances improve his diplomacy/stewardship
			#King's new acquaintances improve his intrigue/learning
			#King's diplomacy helps him improve opinion of all guests
			#King's new resolve makes him lose slothful/content.
			#Proud King's trepidation makes him gain ambitious.
			#Child King's flattered and can become haughty or conscientious.
			#The coronation_priest approves of the ceremony.
			#Temperate/Celibate coronation_priest disapproves of the extravagant ceremony.
			#HRE/Francia Emperor gets a talk from the priest about being the heir of Charlemagne (chance for prestige, learning, diligent)
			#The Pope talks to the King about his duties as protector of Christendom (chance to gain zealous, cynical, learning).
			#Child king is taught by foreign ruler about stewardship.
			#Two foreign Kings (guests) become (or are) rivals, coronation_ruler with high diplomacy can help them lose rivalry and become his friends.
			#Cynical vassal (or wicked priest) annoys the coronation_priest. High diplomacy ruler may help and gain gregarious.
			#A knight comes to pledge his service to the new King/Emperor, if ruler is female/child, chance to become friend/lover or increase martial.
			#A wise priest joins the court.
			#King becomes rival of one of his vassals.

			#King is embarassed of secluded coronation, chance to gain stressed or paranoid.
			#King's vassals are offended by secluded coronation (chance to avoid with high diplomacy).
			#Coronation_priest is disappointed by secluded ceremony.
			#King is disraught by secluded ceremony (chance to lose ambitious, gain content/slothful).
			#King reflects upon secluded coronation (chance to lose proud, gain humble).
			#King's Councillor becomes his rival due to secluded coronation.

		1 = { #No events
			modifier = { 
				factor = 0.1 
				has_character_flag = flag_extravagant_coronation
			}
			event_target:coronation_ruler = { character_event = { id = HF.20366 days = 15 } } #Directly fire coronation
		}
		4 = {
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_foreign_friendship 
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 0 
				num_of_friends = 3
			}
			modifier = { 
				factor = 2 
				NOT = { num_of_friends = 1 }
			}
			modifier = { 
				factor = 1.5
				tier = EMPEROR
			}
			modifier = { 
				factor = 1.5
				trait = gregarious
			}
			modifier = { 
				factor = 1.5 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 0
				NOT = {
					any_independent_ruler = { 
						has_opinion_modifier = { 
							who = ROOT 
							modifier = opinion_coronation_guest 
						}
						NOT = { is_rival = ROOT } 
						NOT = { is_friend = ROOT } 
						NOT = { is_lover = ROOT } 
						NOT = { is_married = ROOT }
						NOT = { num_of_friends = 3 }
						opinion = { who = from value = -20 }
					}
				}
			}
			character_event = { id = HF.20306 } # Frendship with foreign ruler guest.
		}
		4 = { 

			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_vassal_friendship  
			}
			modifier = { 
				factor = 0 
				num_of_friends = 3
			}
			modifier = { 
				factor = 2 
				NOT = { num_of_friends = 1 }
			}
			modifier = { 
				factor = 1.5
				tier = EMPEROR
			}
			modifier = { 
				factor = 1.5
				trait = gregarious
			}
			modifier = { 
				factor = 0.1
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 1.5 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 0
				NOT = {
					any_vassal = { 
						has_opinion_modifier = { 
							who = ROOT 
							modifier = opinion_coronation_guest 
						}
						NOT = { is_rival = ROOT } 
						NOT = { is_friend = ROOT } 
						NOT = { is_lover = ROOT } 
						NOT = { is_married = ROOT }
						NOT = { num_of_friends = 3 }
						opinion = { who = from value = -20 }
					}
				}
			}

			character_event = { id = HF.20310 } # Frendship with vassal guest.
		}
		4 = { 
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_diplomacy_boost  
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 1.5 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 1.5
				trait = gregarious
			}

			character_event = { id = HF.20311 } # Increase diplomacy/stewardship.
		}
		4 = { 
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_learning_boost  
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 1.5 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 1.5
				trait = shy
			}

			character_event = { id = HF.20314 } # Increase intrigue/learning.
		}
		4 = { 
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_guest_opinions  
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 1.5 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 1.5
				trait = gregarious
			}
			modifier = { 
				factor = 0.75
				NOT = { diplomacy = 10 }
			}

			character_event = { id = HF.20316 } # Improve guests opinion.
		}
		4 = { 
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_gain_diligent  
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 2
				trait = content
				trait = slothful
			}
			modifier = { 
				factor = 0 
				NOR = { 
					trait = content 
					trait = slothful
				}
			}

			character_event = { id = HF.20321 } # Gain diligent.
		}
		4 = { 

			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_gain_ambitious  
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 2
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 0 
				trait = ambitious
			}
			modifier = { 
				factor = 0 
				NOT = { trait = proud }
			}
			character_event = { id = HF.20322 } # Gain ambitious.
		}
		4 = { 
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_haughty_child  
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 2 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 0
				age = 16
			}
			modifier = { 
				factor = 1.5 
				NOR = { 
					trait = haughty 
					trait = conscientious
				}
			}

			character_event = { id = HF.20323 } # Child becomes haughty.
		}
		4 = { 

			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_priest_approves  
			}
			modifier = { 
				factor = 0 #Can't approve and disapprove within the course of the same ceremony.
				has_character_flag = flag_coronation_priest_disapproves  
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 1.5 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 1.75 
				event_target:coronation_priest = { trait = hedonist }
			}
			modifier = { 
				factor = 1.5 
				event_target:coronation_priest = { trait = gluttonous }
			}
			modifier = { 
				factor = 1.5 
				event_target:coronation_priest = { trait = drunkard }
			}
			modifier = { 
				factor = 1.5 
				event_target:coronation_priest = { trait = gregarious }
			}
			character_event = { id = HF.20324 } # Priest approves of ceremony.
		}
		4 = { 

			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_hre_talk  
			}
			modifier = { 
				factor = 0 
				has_character_flag = is_charlemagne	#Shouldn't happen anyway, but, just to be safe... 
			}
			modifier = { 
				factor = 0.5
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 1.5 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 0
				emf_has_hre = no
			}
			modifier = { 
				factor = 1.5 
				event_target:coronation_priest = { trait = zealous }
			}
			character_event = { id = HF.20326 } # Priest talks about responsibilities of HRE.
		}
		4 = { 

			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_pope_talk  
			}
			modifier = { 
				factor = 0.5
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 2 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 0
				NOT = { event_target:coronation_priest = { has_landed_title = k_papal_state } }
			}
			character_event = { id = HF.20327 } # Pope talks about responsibilities of Christian King.
		}
		4 = { 
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_foreign_teacher  
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 1.5 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 0
				age = 16
			}
			modifier = { 
				factor = 0 
				NOT = {
					any_independent_ruler = { 
						has_opinion_modifier = { 
							who = ROOT 
							modifier = opinion_coronation_guest 
						}
						NOT = { is_rival = ROOT } 
						stewardship = 8
						opinion = { who = ROOT value = 0 }
					}
				}
			}

			random_independent_ruler = {
				limit = { 
					has_opinion_modifier = { 
						who = ROOT 
						modifier = opinion_coronation_guest 
					}
					NOT = { is_rival = ROOT } 
					stewardship = 8
					opinion = { who = ROOT value = 0 }
				}
				character_event = { id = HF.20328 } # Foreign ruler teaches child statemanship.
			}
		}
		4 = { 

			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_priest_disapproves  
			}
			modifier = { 
				factor = 0 #Can't approve and disapprove within the course of the same ceremony.
				has_character_flag = flag_coronation_priest_approves  
			}
			modifier = { 
				factor = 0 # This event is for disapproving of excess.
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 1.5 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 0.25 
				NOR = { 
					trait = hedonist 
					trait = drunkard
					trait = gluttonous
				}
			}
			modifier = { 
				factor = 1.5 
				trait = hedonist
			}
			modifier = { 
				factor = 1.5 
				trait = gluttonous
			}
			modifier = { 
				factor = 1.5 
				trait = drunkard
			}
			modifier = { 
				factor = 0.1 
				event_target:coronation_priest = { trait = hedonist }
			}
			modifier = { 
				factor = 0.5 
				event_target:coronation_priest = { trait = gluttonous }
			}
			modifier = { 
				factor = 0.5 
				event_target:coronation_priest = { trait = drunkard }
			}
			modifier = { 
				factor = 1.5 
				event_target:coronation_priest = { trait = temperate }
			}
			modifier = { 
				factor = 1.5 
				event_target:coronation_priest = { trait = celibate }
			}
			modifier = { 
				factor = 1.5 
				event_target:coronation_priest = { lower_tier_than = KING }
			}
			modifier = { 
				factor = 1.5 
				event_target:coronation_priest = { religion = fraticelli }
			}
			character_event = { id = HF.20332 } # Priests disapproves of ceremony.
		}
		4 = { 
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_diplomatic_incident  
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 0.9
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 0 
				NOT = { 
					any_independent_ruler = { 
						has_opinion_modifier = { 
							who = ROOT
							modifier = opinion_coronation_guest 
						}
						OR = { 
							any_rival = { 
								independent = yes
								has_opinion_modifier = { 
									who = event_target:coronation_ruler 
									modifier = opinion_coronation_guest 
								}
							}
							any_independent_ruler = { 
								has_opinion_modifier = { 
									who = event_target:coronation_ruler
									modifier = opinion_coronation_guest 
								}
								NOT = {
									reverse_opinion = { 
										who = PREV
										value = -30 
									}
								}
							}
						}
					}
				}
			}


			random_independent_ruler = { #Check for two potential rivals amongst the foreign guests at the coronation ceremony
				limit = { 
					has_opinion_modifier = { 
						who = ROOT
						modifier = opinion_coronation_guest 
					}
					OR = { 
						any_rival = { 
							independent = yes
							has_opinion_modifier = { 
								who =  event_target:coronation_ruler 
								modifier = opinion_coronation_guest 
							}
						}
						any_independent_ruler = { 
							has_opinion_modifier = { 
								who = event_target:coronation_ruler
								modifier = opinion_coronation_guest 
							}
							NOT = {
								reverse_opinion = { 
									who = PREV
									value = -30 
								}
							}
						}
					}
				}
				character_event = { id = HF.20334 } # Foreign ruler guests are rivals.
			}
		}
		2 = { 
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_cynic_taunts  
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 0.75 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 0
				NOT = { 
					any_independent_ruler = { 
						has_opinion_modifier = { 
							who = ROOT
							modifier = opinion_coronation_guest 
						}
						NOT = { event_target:coronation_priest = { character = PREV } }
						NOT = { event_target:coronation_ruler = { character = PREV } }
						OR = { 
							trait = cynical
							trait = bad_priest_christian
						}
					}
				}
			}
			modifier = { 
				factor = 0.5
				NOT = { 
					any_independent_ruler = { 
						has_opinion_modifier = { 
							who = ROOT
							modifier = opinion_coronation_guest 
						}
						NOT = { event_target:coronation_priest = { character = PREV } }
						NOT = { event_target:coronation_ruler = { character = PREV } }
						OR = { 
							trait = cynical
							trait = bad_priest_christian
						}
					}
					lower_tier_than = DUKE
				}
			}

			random_independent_ruler = { 
				limit = { 
					has_opinion_modifier = { 
						who = ROOT
						modifier = opinion_coronation_guest 
					}
					NOT = { event_target:coronation_priest = { character = PREV } }
					NOT = { event_target:coronation_ruler = { character = PREV } }
					OR = { 
						trait = cynical
						trait = bad_priest_christian
					}
				}
				preferred_limit = { 
					higher_tier_than = DUKE 
					OR = { 
						trait = possessed
						trait = lunatic
					}
				}
				preferred_limit = { higher_tier_than = DUKE }
				character_event = { id = HF.20342 } # Cynic/wicked vassal guest offends the coronation_priest.
			}
		}
		2 = { #One version for vassal guests, one for foreign guests.

			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_cynic_taunts  
			}
			modifier = { 
				factor = 0.75 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 0
				NOT = { 
					any_vassal = { 
						has_opinion_modifier = { 
							who = ROOT
							modifier = opinion_coronation_guest 
						}
						NOT = { event_target:coronation_priest = { character = PREV } }
						NOT = { event_target:coronation_ruler = { character = PREV } }
						OR = { 
							trait = cynical
							trait = bad_priest_christian
						}
					}
				}
			}
			random_vassal = {
				limit = { 
					has_opinion_modifier = { 
						who = ROOT
						modifier = opinion_coronation_guest 
					}
					NOT = { event_target:coronation_priest = { character = PREV } }
					OR = { 
						trait = cynical
						trait = bad_priest_christian
					}
				}
				character_event = { id = HF.20342 } # Cynic/wicked foreign guest offends the coronation_priest.
			}
		}
		4 = { 

			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_wandering_knight   
			}
			modifier = { 
				factor = 0.25 
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 1.5 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 1.25 
				is_female = yes
			}
			modifier = { 
				factor = 1.25 
				NOT = { age = 16 }
			}
			modifier = { 
				factor = 1.5 
				tier = EMPEROR
			}
			character_event = { id = HF.20346 } # Wandering knight reaches court.
		}
		4 = { 

			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_wandering_priest 
			}
			modifier = { 
				factor = 0.5 
				has_character_flag = flag_secluded_coronation
			}
			modifier = { 
				factor = 1.5 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 1.5 
				tier = EMPEROR
			}
			modifier = { 
				factor = 1.5 
				piety = 300
			}
			character_event = { id = HF.20351 } # Wandering priest reaches court.
		}
		4 = { 
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_random_rivalry  
			}
			modifier = { 
				factor = 1.5 
				has_character_flag = flag_extravagant_coronation
			}
			modifier = { 
				factor = 0 
				NOT = {
					any_vassal = { 
						has_opinion_modifier = { 
							who = ROOT
							modifier = opinion_coronation_guest 
						}
						NOT = { event_target:coronation_priest = { character = PREV } }
						OR = { 
							trait = envious
							is_rival = ROOT
							opinion = { 
								who = ROOT
								value = -30 
							}
						}
					}
				}
			}

			random_vassal = {
				limit = { 
					has_opinion_modifier = { 
						who = ROOT
						modifier = opinion_coronation_guest 
					}
					NOT = { event_target:coronation_priest = { character = PREV } }
					OR = { 
						trait = envious
						is_rival = ROOT
						opinion = { 
							who = ROOT
							value = -30 
						}
					}
				}
				character_event = { id = HF.20352 } # Envious/Hateful vassal shows rivalry.
			}
		}
		4 = { 
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_secluded_embarassed  
			}
			modifier = { 
				factor = 0 
				NOT = { has_character_flag = flag_secluded_coronation }
			}
			modifier = { 
				factor = 0 
				trait = stressed
				trait = paranoid
			}

			character_event = { id = HF.20355 } # Secluded coronation: ruler embarassed.
		}
		4 = { 
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_secluded_vassals  
			}
			modifier = { 
				factor = 0 
				NOT = { has_character_flag = flag_secluded_coronation }
			}

			character_event = { id = HF.20356 } # Secluded coronation: uninvited vassals are upset.
		}
		4 = { 
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_secluded_priest  
			}
			modifier = { 
				factor = 0 
				NOT = { has_character_flag = flag_secluded_coronation }
			}

			character_event = { id = HF.20358 } # Secluded coronation: priest is upset of poor ceremony.
		}
		4 = { 
			trigger = { 
				war = no
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_secluded_ambitious  
			}
			modifier = { 
				factor = 0 
				NOT = { has_character_flag = flag_secluded_coronation }
			}
			modifier = { 
				factor = 0.25
				NOT = { trait = ambitious }
			}

			character_event = { id = HF.20360 } # Secluded coronation: ruler loses ambition.
		}
		4 = { 
			trigger = { 
				war = no
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_secluded_proud  
			}
			modifier = { 
				factor = 0 
				NOT = { has_character_flag = flag_secluded_coronation }
			}
			modifier = { 
				factor = 0.25
				NOT = { trait = proud }
			}
			modifier = { 
				factor = 0
				trait = humble
			}

			character_event = { id = HF.20361 } # Secluded coronation: ruler humbled.
		}
		4 = { 
			trigger = { 
				war = no
			}
			modifier = { 
				factor = 0 
				has_character_flag = flag_coronation_secluded_steward  
			}
			modifier = { 
				factor = 0 
				NOT = { has_character_flag = flag_secluded_coronation }
			}
			modifier = { 
				factor = 0 
				NOT = { 
					any_courtier = {
						has_job_title = job_treasurer
					}
				}
			}
			modifier = { 
				factor = 0 
				any_courtier = {
					has_job_title = job_treasurer
					is_rival = ROOT
				}
			}

			character_event = { id = HF.20362 } # Secluded coronation: ruler hates steward for poor ceremony.
		}

	} 

} 

troubled_pregnancy_chance_low_effect = { 
random_list = { 
	70 = { custom_tooltip = { text = tooltip_pregnancy_stable } }
	30 = { custom_tooltip = { text = tooltip_pregnancy_gets_worse }
		modifier = { 
			factor = 0.85
			has_character_modifier = mother_dark_rest
		}
		modifier = { 
			factor = 0.95
			has_character_modifier = mother_chatting
		}
		modifier = { 
			factor = 0.85
			has_character_modifier = mother_fertility_festival_1
		}
		modifier = { 
			factor = 0.75
			has_character_modifier = mother_fertility_festival_2
		}
		modifier = { 
			factor = 0.75
			has_character_modifier = mother_festival_blessing
		}
		modifier = { 
			factor = 0.75
			has_character_modifier = mother_praying_health
		} 
		modifier = { 
			factor = 0.5
			has_character_modifier = mother_resting_health
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_partying_health
		} 
		modifier = { 
			factor = 0.75
			has_character_modifier = mother_minor_rest
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_good_omen
		} 
		modifier = { 
			factor = 1.2
			has_character_modifier = mother_bad_omen
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_chastity
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_humility
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_charity
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_temperance
		} 
		modifier = { 
			factor = 1.75
			has_character_modifier = mother_exposed_to_elements
		} 
		modifier = { 
			factor = 0.8
			has_character_modifier = mother_comforted
		} 
		modifier = { 
			factor = 1.5
			NOT = { age = 19 } #Too young
		} 
		modifier = { 
			factor = 1.25
			age = 27 #Too old
		} 
		modifier = { 
			factor = 1.25
			age = 30 #Too old
		} 
		modifier = { 
			factor = 1.25
			age = 35 #Too old
		} 
		modifier = { 
			factor = 1.5
			age = 40 #Too old
		} 	
		modifier = { 	
			factor = 1.5
			age = 45 #Too old
		} 
		modifier = { 
			factor = 1.75
			age = 50 #Too old
		} 
		modifier = { 
			factor = 1.25
			num_of_children = 2
		} 
		modifier = { 
			factor = 1.25
			num_of_children = 3 #Womb is worn out
		} 
		modifier = { 
			factor = 1.5
			num_of_children = 4 #Womb is worn out
		} 
		modifier = { 
			factor = 2
			num_of_children = 5 #Womb is worn out
		} 
		modifier = { 
			factor = 4
			has_character_flag = survivor_mom		#Should have stopped after last time.
		} 
		modifier = { 
			factor = 1.25
			NOR = {  
				trait = misguided_warrior
				trait = tough_soldier
				trait = skilled_tactician
				trait = brilliant_strategist
			}
		} 
		modifier = { 
			factor = 0.95
			trait = misguided_warrior
		} 
		modifier = { 
			factor = 0.85
			trait = tough_soldier
		} 
		modifier = { 
			factor = 0.75
			trait = skilled_tactician
		} 
		modifier = { 
			factor = 0.65
			trait = brilliant_strategist
		} 
		modifier = { 
			factor = 1.5
			trait = stressed
		} 
		modifier = { 
			factor = 1.75
			trait = depressed
		} 
		modifier = { 
			factor = 1.5
			trait = lunatic
		} 
		modifier = { 
			factor = 1.5
			trait = possessed
		} 
		modifier = { 
			factor = 1.35
			trait = wounded
		} 
		modifier = { 
			factor = 1.75
			trait = maimed
		} 
		modifier = { 
			factor = 1.5
			trait = infirm
		} 
		modifier = { 
			factor = 5
			trait = incapable #Probably going to die.
		} 
		modifier = { 
			factor = 1.25
			trait = drunkard
		} 
		modifier = { 
			factor = 1.15
			trait = scarred
		} 
		modifier = { 
			factor = 1.5
			trait = ill
		} 
		modifier = { 
			factor = 1.65
			trait = pneumonic
		} 
		modifier = { 
			factor = 1.5
			trait = syphilitic
		} 
		modifier = { 
			factor = 3
			trait = leper
		} 
		modifier = { 
			factor = 1.85
			trait = has_tuberculosis
		} 
		modifier = { 
			factor = 1.65
			trait = has_typhoid_fever
		} 
		modifier = { 
			factor = 1.5
			trait = has_typhus
		} 
		modifier = { 
			factor = 5
			trait = has_bubonic_plague
		} 
		modifier = { 
			factor = 1.75
			trait = has_measles
		} 
		modifier = { 
			factor = 1.45
			trait = has_small_pox
		} 
		modifier = { 
			factor = 1.65
			trait = has_aztec_disease
		} 
		modifier = { 
			factor = 1.25
			trait = flu
		} 
		modifier = { 
			factor = 1.75
			trait = dysentery
		} 
		modifier = { 
			factor = 1.35
			trait = gout
		} 
		modifier = { 
			factor = 1.75
			trait = food_poisoning
		} 
		modifier = { 
			factor = 1.5
			trait = rabies
		} 
		modifier = { 
			factor = 3
			trait = cancer
		} 
		modifier = { 
			factor = 4
			trait = dancing_plague
		} 
		modifier = { 
			factor = 1.25
			trait = scurvy
		} 
		modifier = { 
			factor = 2
			trait = mangled
		} 
		modifier = { 
			factor = 3
			trait = severely_injured
		} 
		modifier = { 
			factor = 0.75
			trait = strong
		} 
		modifier = { 
			factor = 1.45
			trait = hunchback
		} 
		modifier = { 
			factor = 1.5
			trait = dwarf
		} 
		modifier = { 
			factor = 5
			trait = inbred
		} 
		modifier = { 
			factor = 1.5
			trait = weak
		} 
		modifier = { 
			factor = 0.5
			trait = robust
		} 
		modifier = { 
			factor = 2
			trait = feeble
		} 
		modifier = { 
			factor = 1.35
			trait = hedonist
		} 
		modifier = { 
			factor = 0.85
			trait = mystic
		} 	
		modifier = { 	
			factor = 0.85	
			trait = gardener
		} 
		modifier = { 
			factor = 0.85
			trait = duelist
		} 
		modifier = { 
			factor = 0.75
			trait = hunter
		} 
		modifier = { 
			factor = 0.75
			trait = falconer
		} 
		modifier = { 
			factor = 1.35
			trait = gluttonous
		} 
		modifier = { 
			factor = 1.45
			trait = wroth
		} 
		modifier = { 
			factor = 1.45
			trait = slothful
		} 
		modifier = { 
			factor = 0.85
			trait = temperate
		} 
		modifier = { 
			factor = 1.5
			trait = blinded
		} 
		modifier = { 
			factor = 1.5
			trait = berserker
		} 
		modifier = { 
			factor = 1.25
			trait = lovers_pox
		} 
		modifier = { 
			factor = 1.5
			NOT = { health = 1 }
		} 
		modifier = { 
			factor = 1.5
			NOT = { health = 2 }
		} 
		modifier = { 
			factor = 1.5
			NOT = { health = 3 }
		} 
		modifier = { 
			factor = 0.75
			health = 5
		} 
		character_event = { id = HFP.20500  days = 35 random = 75 } #Critical failure: troubled pregnancy begins.
		}
	}
}

troubled_pregnancy_chance_medium_effect = { 
random_list = { 
	50 = { custom_tooltip = { text = tooltip_pregnancy_stable } }
	50 = { custom_tooltip = { text = tooltip_pregnancy_gets_worse }
		modifier = { 
			factor = 0.85
			has_character_modifier = mother_dark_rest
		}
		modifier = { 
			factor = 0.95
			has_character_modifier = mother_chatting
		}
		modifier = { 
			factor = 0.85
			has_character_modifier = mother_fertility_festival_1
		}
		modifier = { 
			factor = 0.75
			has_character_modifier = mother_fertility_festival_2
		}
		modifier = { 
			factor = 0.75
			has_character_modifier = mother_festival_blessing
		}
		modifier = { 
			factor = 0.75
			has_character_modifier = mother_praying_health
		} 
		modifier = { 
			factor = 0.5
			has_character_modifier = mother_resting_health
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_partying_health
		} 
		modifier = { 
			factor = 0.75
			has_character_modifier = mother_minor_rest
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_good_omen
		} 
		modifier = { 
			factor = 1.2
			has_character_modifier = mother_bad_omen
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_chastity
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_humility
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_charity
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_temperance
		} 
		modifier = { 
			factor = 1.75
			has_character_modifier = mother_exposed_to_elements
		} 
		modifier = { 
			factor = 0.8
			has_character_modifier = mother_comforted
		} 
		modifier = { 
			factor = 1.5
			NOT = { age = 19 } #Too young
		} 
		modifier = { 
			factor = 1.25
			age = 27 #Too old
		} 
		modifier = { 
			factor = 1.25
			age = 30 #Too old
		} 
		modifier = { 
			factor = 1.25
			age = 35 #Too old
		} 
		modifier = { 
			factor = 1.5
			age = 40 #Too old
		} 	
		modifier = { 	
			factor = 1.5
			age = 45 #Too old
		} 
		modifier = { 
			factor = 1.75
			age = 50 #Too old
		} 
		modifier = { 
			factor = 1.25
			num_of_children = 2
		} 
		modifier = { 
			factor = 1.25
			num_of_children = 3 #Womb is worn out
		} 
		modifier = { 
			factor = 1.5
			num_of_children = 4 #Womb is worn out
		} 
		modifier = { 
			factor = 2
			num_of_children = 5 #Womb is worn out
		} 
		modifier = { 
			factor = 4
			has_character_flag = survivor_mom		#Should have stopped after last time.
		} 
		modifier = { 
			factor = 1.25
			NOR = {  
				trait = misguided_warrior
				trait = tough_soldier
				trait = skilled_tactician
				trait = brilliant_strategist
			}
		} 
		modifier = { 
			factor = 0.95
			trait = misguided_warrior
		} 
		modifier = { 
			factor = 0.85
			trait = tough_soldier
		} 
		modifier = { 
			factor = 0.75
			trait = skilled_tactician
		} 
		modifier = { 
			factor = 0.65
			trait = brilliant_strategist
		} 
		modifier = { 
			factor = 1.5
			trait = stressed
		} 
		modifier = { 
			factor = 1.75
			trait = depressed
		} 
		modifier = { 
			factor = 1.5
			trait = lunatic
		} 
		modifier = { 
			factor = 1.5
			trait = possessed
		} 
		modifier = { 
			factor = 1.35
			trait = wounded
		} 
		modifier = { 
			factor = 1.75
			trait = maimed
		} 
		modifier = { 
			factor = 1.5
			trait = infirm
		} 
		modifier = { 
			factor = 5
			trait = incapable #Probably going to die.
		} 
		modifier = { 
			factor = 1.25
			trait = drunkard
		} 
		modifier = { 
			factor = 1.15
			trait = scarred
		} 
		modifier = { 
			factor = 1.5
			trait = ill
		} 
		modifier = { 
			factor = 1.65
			trait = pneumonic
		} 
		modifier = { 
			factor = 1.5
			trait = syphilitic
		} 
		modifier = { 
			factor = 3
			trait = leper
		} 
		modifier = { 
			factor = 1.85
			trait = has_tuberculosis
		} 
		modifier = { 
			factor = 1.65
			trait = has_typhoid_fever
		} 
		modifier = { 
			factor = 1.5
			trait = has_typhus
		} 
		modifier = { 
			factor = 5
			trait = has_bubonic_plague
		} 
		modifier = { 
			factor = 1.75
			trait = has_measles
		} 
		modifier = { 
			factor = 1.45
			trait = has_small_pox
		} 
		modifier = { 
			factor = 1.65
			trait = has_aztec_disease
		} 
		modifier = { 
			factor = 1.25
			trait = flu
		} 
		modifier = { 
			factor = 1.75
			trait = dysentery
		} 
		modifier = { 
			factor = 1.35
			trait = gout
		} 
		modifier = { 
			factor = 1.75
			trait = food_poisoning
		} 
		modifier = { 
			factor = 1.5
			trait = rabies
		} 
		modifier = { 
			factor = 3
			trait = cancer
		} 
		modifier = { 
			factor = 4
			trait = dancing_plague
		} 
		modifier = { 
			factor = 1.25
			trait = scurvy
		} 
		modifier = { 
			factor = 2
			trait = mangled
		} 
		modifier = { 
			factor = 3
			trait = severely_injured
		} 
		modifier = { 
			factor = 0.75
			trait = strong
		} 
		modifier = { 
			factor = 1.45
			trait = hunchback
		} 
		modifier = { 
			factor = 1.5
			trait = dwarf
		} 
		modifier = { 
			factor = 5
			trait = inbred
		} 
		modifier = { 
			factor = 1.5
			trait = weak
		} 
		modifier = { 
			factor = 0.5
			trait = robust
		} 
		modifier = { 
			factor = 2
			trait = feeble
		} 
		modifier = { 
			factor = 1.35
			trait = hedonist
		} 
		modifier = { 
			factor = 0.85
			trait = mystic
		} 	
		modifier = { 	
			factor = 0.85	
			trait = gardener
		} 
		modifier = { 
			factor = 0.85
			trait = duelist
		} 
		modifier = { 
			factor = 0.75
			trait = hunter
		} 
		modifier = { 
			factor = 0.75
			trait = falconer
		} 
		modifier = { 
			factor = 1.35
			trait = gluttonous
		} 
		modifier = { 
			factor = 1.45
			trait = wroth
		} 
		modifier = { 
			factor = 1.45
			trait = slothful
		} 
		modifier = { 
			factor = 0.85
			trait = temperate
		} 
		modifier = { 
			factor = 1.5
			trait = blinded
		} 
		modifier = { 
			factor = 1.5
			trait = berserker
		} 
		modifier = { 
			factor = 1.25
			trait = lovers_pox
		} 
		modifier = { 
			factor = 1.5
			NOT = { health = 1 }
		} 
		modifier = { 
			factor = 1.5
			NOT = { health = 2 }
		} 
		modifier = { 
			factor = 1.5
			NOT = { health = 3 }
		} 
		modifier = { 
			factor = 0.75
			health = 5
		} 
		character_event = { id = HFP.20500  days = 35 random = 75 } #Critical failure: troubled pregnancy begins.
		}
	}
}

troubled_pregnancy_variable_easy_effect = { 
	random_list = { 
		60 = { 
		modifier = { 
			factor = 1.25
			has_character_modifier = mother_dark_rest
		}
		modifier = { 
			factor = 1.05
			has_character_modifier = mother_chatting
		}
		modifier = { 
			factor = 1.25
			has_character_modifier = mother_fertility_festival_1
		}
		modifier = { 
			factor = 1.5
			has_character_modifier = mother_fertility_festival_2
		}
		modifier = { 
			factor = 1.5
			has_character_modifier = mother_festival_blessing
		}
		modifier = { 
			factor = 0.7
			NOT = { health = 1 }
		}
		modifier = { 
			factor = 0.8
			NOT = { health = 2 }
		}
		modifier = { 
			factor = 0.9
			NOT = { health = 3 }
		}
		modifier = { 
			factor = 0.8
			trait = wounded
		}
		modifier = { 
			factor = 0.8
			trait = maimed
		}
		modifier = { 
			factor = 0.9
			trait = cough
		}
		modifier = { 
			factor = 0.8
			trait = fever
		}
		modifier = { 
			factor = 0.9
			trait = diarrhea
		}
		modifier = { 
			factor = 0.9
			trait = vomiting
		}
		modifier = { 
			factor = 0.7
			trait = chest_pain
		}
		modifier = { 
			factor = 0.8
			trait = cramps
		}
		modifier = { 
			factor = 0.9
			trait = rash
		}
		modifier = { 
			factor = 0.9
			trait = headache
		}
		modifier = { 
			factor = 0.7
			trait = abdominal_pain
		}
		modifier = { 
			factor = 0.9
			trait = fatigue
		}
		modifier = { 
			factor = 0.9
			trait = malaise
		}
		modifier = { 
			factor = 0.8
			trait = infection
		}
		modifier = { 
			factor = 1.1
			has_character_flag = pregnancy_priest_comfort
		}
		modifier = { 
			factor = 1.2
			has_character_flag = pregnancy_shaman_comfort
		}
		modifier = { 
			factor = 1.3
			has_character_flag = pregnancy_spouse_comfort
		}
		modifier = { 
			factor = 1.4
			has_character_flag = pregnancy_healer_help
		}
		modifier = { 
			factor = 0.7
			persistent_event_target:pregnancy_mother_physician_per = { NOT = { learning = 5 } }
		}
		modifier = { 
			factor = 0.8
			persistent_event_target:pregnancy_mother_physician_per = { NOT = { learning = 10 } }
		}
		modifier = { 
			factor = 0.9
			persistent_event_target:pregnancy_mother_physician_per = { trait = slow }
		}
		modifier = { 
			factor = 0.8
			persistent_event_target:pregnancy_mother_physician_per = { trait = imbecile }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_mother_physician_per = { trait = scholar }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_mother_physician_per = { trait = physician }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_mother_physician_per = { trait = quick }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_mother_physician_per = { trait = genius }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_mother_physician_per = { learning = 10 }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_mother_physician_per = { learning = 15 }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_mother_physician_per = { learning = 20 }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_mother_physician_per = { learning = 25 }
		}
		modifier = { 
			factor = 0.7
			persistent_event_target:pregnancy_spouse_physician_per = { NOT = { learning = 5 } }
		}
		modifier = { 
			factor = 0.8
			persistent_event_target:pregnancy_spouse_physician_per = { NOT = { learning = 10 } }
		}
		modifier = { 
			factor = 0.9
			persistent_event_target:pregnancy_spouse_physician_per = { trait = slow }
		}
		modifier = { 
			factor = 0.8
			persistent_event_target:pregnancy_spouse_physician_per = { trait = imbecile }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_spouse_physician_per = { trait = scholar }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_spouse_physician_per = { trait = physician }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_spouse_physician_per = { trait = quick }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_spouse_physician_per = { trait = genius }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_spouse_physician_per = { learning = 10 }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_spouse_physician_per = { learning = 15 }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_spouse_physician_per = { learning = 20 }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_spouse_physician_per = { learning = 25 }
		}
		modifier = { 
			factor = 0.7
			persistent_event_target:pregnancy_regent_physician_per = { NOT = { learning = 5 } }
		}
		modifier = { 
			factor = 0.8
			persistent_event_target:pregnancy_regent_physician_per = { NOT = { learning = 10 } }
		}
		modifier = { 
			factor = 0.9
			persistent_event_target:pregnancy_regent_physician_per = { trait = slow }
		}
		modifier = { 
			factor = 0.8
			persistent_event_target:pregnancy_regent_physician_per = { trait = imbecile }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_regent_physician_per = { trait = scholar }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_regent_physician_per = { trait = physician }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_regent_physician_per = { trait = quick }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_regent_physician_per = { trait = genius }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_regent_physician_per = { learning = 10 }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_regent_physician_per = { learning = 15 }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_regent_physician_per = { learning = 20 }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_regent_physician_per = { learning = 25 }
		}
		change_variable =  { which = troubled_pregnancy_variable value = -2 }
	} 
	40 = { 
		modifier = { 
			factor = 0.75
			has_character_modifier = mother_praying_health
		} 
		modifier = { 
			factor = 0.5
			has_character_modifier = mother_resting_health
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_partying_health
		} 
		modifier = { 
			factor = 0.75
			has_character_modifier = mother_minor_rest
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_good_omen
		} 
		modifier = { 
			factor = 1.2
			has_character_modifier = mother_bad_omen
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_chastity
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_humility
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_charity
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_temperance
		} 
		modifier = { 
			factor = 1.75
			has_character_modifier = mother_exposed_to_elements
		} 
		modifier = { 
			factor = 0.8
			has_character_modifier = mother_comforted
		} 
		change_variable =  { which = troubled_pregnancy_variable value = 2 }
	}
	}
}

troubled_pregnancy_variable_hard_effect = { 
	random_list = { 
		30 = { 
		modifier = { 
			factor = 1.25
			has_character_modifier = mother_dark_rest
		}
		modifier = { 
			factor = 1.05
			has_character_modifier = mother_chatting
		}
		modifier = { 
			factor = 1.25
			has_character_modifier = mother_fertility_festival_1
		}
		modifier = { 
			factor = 1.5
			has_character_modifier = mother_fertility_festival_2
		}
		modifier = { 
			factor = 1.5
			has_character_modifier = mother_festival_blessing
		}
		modifier = { 
			factor = 0.7
			NOT = { health = 1 }
		}
		modifier = { 
			factor = 0.8
			NOT = { health = 2 }
		}
		modifier = { 
			factor = 0.9
			NOT = { health = 3 }
		}
		modifier = { 
			factor = 0.8
			trait = wounded
		}
		modifier = { 
			factor = 0.8
			trait = maimed
		}
		modifier = { 
			factor = 0.9
			trait = cough
		}
		modifier = { 
			factor = 0.8
			trait = fever
		}
		modifier = { 
			factor = 0.9
			trait = diarrhea
		}
		modifier = { 
			factor = 0.9
			trait = vomiting
		}
		modifier = { 
			factor = 0.7
			trait = chest_pain
		}
		modifier = { 
			factor = 0.8
			trait = cramps
		}
		modifier = { 
			factor = 0.9
			trait = rash
		}
		modifier = { 
			factor = 0.9
			trait = headache
		}
		modifier = { 
			factor = 0.7
			trait = abdominal_pain
		}
		modifier = { 
			factor = 0.9
			trait = fatigue
		}
		modifier = { 
			factor = 0.9
			trait = malaise
		}
		modifier = { 
			factor = 0.8
			trait = infection
		}
		modifier = { 
			factor = 1.1
			has_character_flag = pregnancy_priest_comfort
		}
		modifier = { 
			factor = 1.2
			has_character_flag = pregnancy_shaman_comfort
		}
		modifier = { 
			factor = 1.3
			has_character_flag = pregnancy_spouse_comfort
		}
		modifier = { 
			factor = 1.4
			has_character_flag = pregnancy_healer_help
		}
		modifier = { 
			factor = 0.7
			persistent_event_target:pregnancy_mother_physician_per = { NOT = { learning = 5 } }
		}
		modifier = { 
			factor = 0.8
			persistent_event_target:pregnancy_mother_physician_per = { NOT = { learning = 10 } }
		}
		modifier = { 
			factor = 0.9
			persistent_event_target:pregnancy_mother_physician_per = { trait = slow }
		}
		modifier = { 
			factor = 0.8
			persistent_event_target:pregnancy_mother_physician_per = { trait = imbecile }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_mother_physician_per = { trait = scholar }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_mother_physician_per = { trait = physician }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_mother_physician_per = { trait = quick }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_mother_physician_per = { trait = genius }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_mother_physician_per = { learning = 10 }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_mother_physician_per = { learning = 15 }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_mother_physician_per = { learning = 20 }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_mother_physician_per = { learning = 25 }
		}
		modifier = { 
			factor = 0.7
			persistent_event_target:pregnancy_spouse_physician_per = { NOT = { learning = 5 } }
		}
		modifier = { 
			factor = 0.8
			persistent_event_target:pregnancy_spouse_physician_per = { NOT = { learning = 10 } }
		}
		modifier = { 
			factor = 0.9
			persistent_event_target:pregnancy_spouse_physician_per = { trait = slow }
		}
		modifier = { 
			factor = 0.8
			persistent_event_target:pregnancy_spouse_physician_per = { trait = imbecile }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_spouse_physician_per = { trait = scholar }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_spouse_physician_per = { trait = physician }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_spouse_physician_per = { trait = quick }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_spouse_physician_per = { trait = genius }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_spouse_physician_per = { learning = 10 }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_spouse_physician_per = { learning = 15 }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_spouse_physician_per = { learning = 20 }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_spouse_physician_per = { learning = 25 }
		}
		modifier = { 
			factor = 0.7
			persistent_event_target:pregnancy_regent_physician_per = { NOT = { learning = 5 } }
		}
		modifier = { 
			factor = 0.8
			persistent_event_target:pregnancy_regent_physician_per = { NOT = { learning = 10 } }
		}
		modifier = { 
			factor = 0.9
			persistent_event_target:pregnancy_regent_physician_per = { trait = slow }
		}
		modifier = { 
			factor = 0.8
			persistent_event_target:pregnancy_regent_physician_per = { trait = imbecile }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_regent_physician_per = { trait = scholar }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_regent_physician_per = { trait = physician }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_regent_physician_per = { trait = quick }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_regent_physician_per = { trait = genius }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_regent_physician_per = { learning = 10 }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_regent_physician_per = { learning = 15 }
		}
		modifier = { 
			factor = 1.25
			persistent_event_target:pregnancy_regent_physician_per = { learning = 20 }
		}
		modifier = { 
			factor = 1.5
			persistent_event_target:pregnancy_regent_physician_per = { learning = 25 }
		}
		change_variable =  { which = troubled_pregnancy_variable value = -3 }
	} 
	70 = { 
		modifier = { 
			factor = 0.75
			has_character_modifier = mother_praying_health
		} 
		modifier = { 
			factor = 0.5
			has_character_modifier = mother_resting_health
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_partying_health
		} 
		modifier = { 
			factor = 0.75
			has_character_modifier = mother_minor_rest
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_good_omen
		} 
		modifier = { 
			factor = 1.2
			has_character_modifier = mother_bad_omen
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_chastity
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_humility
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_charity
		} 
		modifier = { 
			factor = 0.9
			has_character_modifier = mother_vow_temperance
		} 
		modifier = { 
			factor = 1.75
			has_character_modifier = mother_exposed_to_elements
		} 
		modifier = { 
			factor = 0.8
			has_character_modifier = mother_comforted
		} 
		change_variable =  { which = troubled_pregnancy_variable value = 3 }
	}
	} 
}

tiered_prestige_reward_effect = {
	if = {
		limit = {
			AND = { 
				is_ruler = no
				spouse = { is_ruler = no }
				father_even_if_dead = { is_ruler = no }
				mother_even_if_dead = { is_ruler = no }
			}
		}
		prestige = 5
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = BARON
					NOR = { 
						father_even_if_dead = { higher_tier_than = BARON } 
						mother_even_if_dead = { higher_tier_than = BARON } 
					} 
				}
				AND = { 
					is_ruler = no
					spouse = { tier = BARON } 
				}
				AND = { 
					is_ruler = no
					father_even_if_dead = { tier = BARON } 
				}
				AND = { 
					is_ruler = no
					mother_even_if_dead = { tier = BARON } 
				}
			}
			NOR = { 
				AND = { 
					tier = COUNT
					NOR = { 
						father_even_if_dead = { higher_tier_than = COUNT } 
						mother_even_if_dead = { higher_tier_than = COUNT } 
					} 
				}
				AND = { 
					lower_tier_than = COUNT
					spouse = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					father_even_if_dead = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					mother_even_if_dead = { tier = COUNT } 
				}
			}
		}
		prestige = 10
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = COUNT
					NOR = { 
						father_even_if_dead = { higher_tier_than = COUNT } 
						mother_even_if_dead = { higher_tier_than = COUNT } 
					} 
				}
				AND = { 
					lower_tier_than = COUNT
					spouse = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					father_even_if_dead = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					mother_even_if_dead = { tier = COUNT } 
				}
			}
			NOR = { 
				AND = { 
					tier = DUKE
					NOR = { 
						father_even_if_dead = { higher_tier_than = DUKE } 
						mother_even_if_dead = { higher_tier_than = DUKE } 
					} 
				}
				AND = { 
					lower_tier_than = DUKE
					spouse = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					father_even_if_dead = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					mother_even_if_dead = { tier = DUKE } 
				}
			}
		}
		prestige = 25
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = DUKE
					NOR = { 
						father_even_if_dead = { higher_tier_than = DUKE } 
						mother_even_if_dead = { higher_tier_than = DUKE } 
					} 
				}
				AND = { 
					lower_tier_than = DUKE
					spouse = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					father_even_if_dead = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					mother_even_if_dead = { tier = DUKE } 
				}
			}
			NOR = { 
				AND = { 
					tier = KING
					NOR = { 
						father_even_if_dead = { higher_tier_than = KING } 
						mother_even_if_dead = { higher_tier_than = KING } 
					} 
				}
				AND = { 
					lower_tier_than = KING
					spouse = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					father_even_if_dead = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					mother_even_if_dead = { tier = KING } 
				}
			}
		}
		prestige = 50
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = KING
					NOR = { 
						father_even_if_dead = { higher_tier_than = KING } 
						mother_even_if_dead = { higher_tier_than = KING } 
					} 
				}
				AND = { 
					lower_tier_than = KING
					spouse = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					father_even_if_dead = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					mother_even_if_dead = { tier = KING } 
				}
			}
			NOR = { 
				AND = { 
					tier = EMPEROR
					NOR = { 
						father_even_if_dead = { higher_tier_than = EMPEROR } 
						mother_even_if_dead = { higher_tier_than = EMPEROR } 
					} 
				}
				AND = { 
					lower_tier_than = EMPEROR
					spouse = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					father_even_if_dead = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					mother_even_if_dead = { tier = EMPEROR } 
				}
			}
		}
		prestige = 75
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = EMPEROR
					NOR = { 
						father_even_if_dead = { higher_tier_than = EMPEROR } 
						mother_even_if_dead = { higher_tier_than = EMPEROR } 
					} 
				}
				AND = { 
					lower_tier_than = EMPEROR
					spouse = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					father_even_if_dead = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					mother_even_if_dead = { tier = EMPEROR } 
				}
			}
		}
		prestige = 100
	}
}

tiered_piety_reward_effect = {
	if = {
		limit = {
			AND = { 
				is_ruler = no
				spouse = { is_ruler = no }
				father_even_if_dead = { is_ruler = no }
				mother_even_if_dead = { is_ruler = no }
			}
		}
		piety = 5
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = BARON
					NOR = { 
						father_even_if_dead = { higher_tier_than = BARON } 
						mother_even_if_dead = { higher_tier_than = BARON } 
					} 
				}
				AND = { 
					is_ruler = no
					spouse = { tier = BARON } 
				}
				AND = { 
					is_ruler = no
					father_even_if_dead = { tier = BARON } 
				}
				AND = { 
					is_ruler = no
					mother_even_if_dead = { tier = BARON } 
				}
			}
			NOR = { 
				AND = { 
					tier = COUNT
					NOR = { 
						father_even_if_dead = { higher_tier_than = COUNT } 
						mother_even_if_dead = { higher_tier_than = COUNT } 
					} 
				}
				AND = { 
					lower_tier_than = COUNT
					spouse = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					father_even_if_dead = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					mother_even_if_dead = { tier = COUNT } 
				}
			}
		}
		piety = 10
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = COUNT
					NOR = { 
						father_even_if_dead = { higher_tier_than = COUNT } 
						mother_even_if_dead = { higher_tier_than = COUNT } 
					} 
				}
				AND = { 
					lower_tier_than = COUNT
					spouse = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					father_even_if_dead = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					mother_even_if_dead = { tier = COUNT } 
				}
			}
			NOR = { 
				AND = { 
					tier = DUKE
					NOR = { 
						father_even_if_dead = { higher_tier_than = DUKE } 
						mother_even_if_dead = { higher_tier_than = DUKE } 
					} 
				}
				AND = { 
					lower_tier_than = DUKE
					spouse = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					father_even_if_dead = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					mother_even_if_dead = { tier = DUKE } 
				}
			}
		}
		piety = 15
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = DUKE
					NOR = { 
						father_even_if_dead = { higher_tier_than = DUKE } 
						mother_even_if_dead = { higher_tier_than = DUKE } 
					} 
				}
				AND = { 
					lower_tier_than = DUKE
					spouse = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					father_even_if_dead = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					mother_even_if_dead = { tier = DUKE } 
				}
			}
			NOR = { 
				AND = { 
					tier = KING
					NOR = { 
						father_even_if_dead = { higher_tier_than = KING } 
						mother_even_if_dead = { higher_tier_than = KING } 
					} 
				}
				AND = { 
					lower_tier_than = KING
					spouse = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					father_even_if_dead = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					mother_even_if_dead = { tier = KING } 
				}
			}
		}
		piety = 20
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = KING
					NOR = { 
						father_even_if_dead = { higher_tier_than = KING } 
						mother_even_if_dead = { higher_tier_than = KING } 
					} 
				}
				AND = { 
					lower_tier_than = KING
					spouse = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					father_even_if_dead = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					mother_even_if_dead = { tier = KING } 
				}
			}
			NOR = { 
				AND = { 
					tier = EMPEROR
					NOR = { 
						father_even_if_dead = { higher_tier_than = EMPEROR } 
						mother_even_if_dead = { higher_tier_than = EMPEROR } 
					} 
				}
				AND = { 
					lower_tier_than = EMPEROR
					spouse = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					father_even_if_dead = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					mother_even_if_dead = { tier = EMPEROR } 
				}
			}
		}
		piety = 25
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = EMPEROR
					NOR = { 
						father_even_if_dead = { higher_tier_than = EMPEROR } 
						mother_even_if_dead = { higher_tier_than = EMPEROR } 
					} 
				}
				AND = { 
					lower_tier_than = EMPEROR
					spouse = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					father_even_if_dead = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					mother_even_if_dead = { tier = EMPEROR } 
				}
			}
		}
		piety = 30
	}
}

tiered_prestige_negative_effect = {
	if = {
		limit = {
			AND = { 
				is_ruler = no
				spouse = { is_ruler = no }
				mother_even_if_dead = { is_ruler = no }
				father_even_if_dead = { is_ruler = no }
			}
		}
		prestige = -5
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = BARON
					NOR = { 
						father_even_if_dead = { higher_tier_than = BARON } 
						mother_even_if_dead = { higher_tier_than = BARON } 
					} 
				}
				AND = { 
					is_ruler = no
					spouse = { tier = BARON } 
				}
				AND = { 
					is_ruler = no
					father_even_if_dead = { tier = BARON } 
				}
				AND = { 
					is_ruler = no
					mother_even_if_dead = { tier = BARON } 
				}
			}
			NOR = { 
				AND = { 
					tier = COUNT
					NOR = { 
						father_even_if_dead = { higher_tier_than = COUNT } 
						mother_even_if_dead = { higher_tier_than = COUNT } 
					} 
				}
				AND = { 
					lower_tier_than = COUNT
					spouse = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					father_even_if_dead = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					mother_even_if_dead = { tier = COUNT } 
				}
			}
		}
		prestige = -10
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = COUNT
					NOR = { 
						father_even_if_dead = { higher_tier_than = COUNT } 
						mother_even_if_dead = { higher_tier_than = COUNT } 
					} 
				}
				AND = { 
					lower_tier_than = COUNT
					spouse = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					father_even_if_dead = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					mother_even_if_dead = { tier = COUNT } 
				}
			}
			NOR = { 
				AND = { 
					tier = DUKE
					NOR = { 
						father_even_if_dead = { higher_tier_than = DUKE } 
						mother_even_if_dead = { higher_tier_than = DUKE } 
					} 
				}
				AND = { 
					lower_tier_than = DUKE
					spouse = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					father_even_if_dead = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					mother_even_if_dead = { tier = DUKE } 
				}
			}
		}
		prestige = -25
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = DUKE
					NOR = { 
						father_even_if_dead = { higher_tier_than = DUKE } 
						mother_even_if_dead = { higher_tier_than = DUKE } 
					} 
				}
				AND = { 
					lower_tier_than = DUKE
					spouse = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					father_even_if_dead = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					mother_even_if_dead = { tier = DUKE } 
				}
			}
			NOR = { 
				AND = { 
					tier = KING
					NOR = { 
						father_even_if_dead = { higher_tier_than = KING } 
						mother_even_if_dead = { higher_tier_than = KING } 
					} 
				}
				AND = { 
					lower_tier_than = KING
					spouse = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					father_even_if_dead = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					mother_even_if_dead = { tier = KING } 
				}
			}
		}
		prestige = -50
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = KING
					NOR = { 
						father_even_if_dead = { higher_tier_than = KING } 
						mother_even_if_dead = { higher_tier_than = KING } 
					} 
				}
				AND = { 
					lower_tier_than = KING
					spouse = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					father_even_if_dead = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					mother_even_if_dead = { tier = KING } 
				}
			}
			NOR = { 
				AND = { 
					tier = EMPEROR
					NOR = { 
						father_even_if_dead = { higher_tier_than = EMPEROR } 
						mother_even_if_dead = { higher_tier_than = EMPEROR } 
					} 
				}
				AND = { 
					lower_tier_than = EMPEROR
					spouse = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					father_even_if_dead = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					mother_even_if_dead = { tier = EMPEROR } 
				}
			}
		}
		prestige = -75
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = EMPEROR
					NOR = { 
						father_even_if_dead = { higher_tier_than = EMPEROR } 
						mother_even_if_dead = { higher_tier_than = EMPEROR } 
					} 
				}
				AND = { 
					lower_tier_than = EMPEROR
					spouse = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					father_even_if_dead = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					mother_even_if_dead = { tier = EMPEROR } 
				}
			}
		}
		prestige = -100
	}
}

tiered_piety_negative_effect = {
	if = {
		limit = {
			AND = { 
				is_ruler = no
				spouse = { is_ruler = no }
				father_even_if_dead = { is_ruler = no }
				mother_even_if_dead = { is_ruler = no }
			}
		}
		piety = -5
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = BARON
					NOR = { 
						father_even_if_dead = { higher_tier_than = BARON } 
						mother_even_if_dead = { higher_tier_than = BARON } 
					} 
				}
				AND = { 
					is_ruler = no
					spouse = { tier = BARON } 
				}
				AND = { 
					is_ruler = no
					father_even_if_dead = { tier = BARON } 
				}
				AND = { 
					is_ruler = no
					mother_even_if_dead = { tier = BARON } 
				}
			}
			NOR = { 
				AND = { 
					tier = COUNT
					NOR = { 
						father_even_if_dead = { higher_tier_than = COUNT } 
						mother_even_if_dead = { higher_tier_than = COUNT } 
					} 
				}
				AND = { 
					lower_tier_than = COUNT
					spouse = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					father_even_if_dead = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					mother_even_if_dead = { tier = COUNT } 
				}
			}
		}
		piety = -10
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = COUNT
					NOR = { 
						father_even_if_dead = { higher_tier_than = COUNT } 
						mother_even_if_dead = { higher_tier_than = COUNT } 
					} 
				}
				AND = { 
					lower_tier_than = COUNT
					spouse = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					father_even_if_dead = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					mother_even_if_dead = { tier = COUNT } 
				}
			}
			NOR = { 
				AND = { 
					tier = DUKE
					NOR = { 
						father_even_if_dead = { higher_tier_than = DUKE } 
						mother_even_if_dead = { higher_tier_than = DUKE } 
					} 
				}
				AND = { 
					lower_tier_than = DUKE
					spouse = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					father_even_if_dead = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					mother_even_if_dead = { tier = DUKE } 
				}
			}
		}
		piety = -15
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = DUKE
					NOR = { 
						father_even_if_dead = { higher_tier_than = DUKE } 
						mother_even_if_dead = { higher_tier_than = DUKE } 
					} 
				}
				AND = { 
					lower_tier_than = DUKE
					spouse = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					father_even_if_dead = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					mother_even_if_dead = { tier = DUKE } 
				}
			}
			NOR = { 
				AND = { 
					tier = KING
					NOR = { 
						father_even_if_dead = { higher_tier_than = KING } 
						mother_even_if_dead = { higher_tier_than = KING } 
					} 
				}
				AND = { 
					lower_tier_than = KING
					spouse = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					father_even_if_dead = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					mother_even_if_dead = { tier = KING } 
				}
			}
		}
		piety = -20
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = KING
					NOR = { 
						father_even_if_dead = { higher_tier_than = KING } 
						mother_even_if_dead = { higher_tier_than = KING } 
					} 
				}
				AND = { 
					lower_tier_than = KING
					spouse = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					father_even_if_dead = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					mother_even_if_dead = { tier = KING } 
				}
			}
			NOR = { 
				AND = { 
					tier = EMPEROR
					NOR = { 
						father_even_if_dead = { higher_tier_than = EMPEROR } 
						mother_even_if_dead = { higher_tier_than = EMPEROR } 
					} 
				}
				AND = { 
					lower_tier_than = EMPEROR
					spouse = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					father_even_if_dead = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					mother_even_if_dead = { tier = EMPEROR } 
				}
			}
		}
		piety = -25
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = EMPEROR
					NOR = { 
						father_even_if_dead = { higher_tier_than = EMPEROR } 
						mother_even_if_dead = { higher_tier_than = EMPEROR } 
					} 
				}
				AND = { 
					lower_tier_than = EMPEROR
					spouse = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					father_even_if_dead = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					mother_even_if_dead = { tier = EMPEROR } 
				}
			}
		}
		piety = -30
	}
}

tiered_high_piety_negative_effect = {
	if = {
		limit = {
			AND = { 
				is_ruler = no
				spouse = { is_ruler = no }
				father_even_if_dead = { is_ruler = no }
				mother_even_if_dead = { is_ruler = no }
			}
		}
		piety = -25
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = BARON
					NOR = { 
						father_even_if_dead = { higher_tier_than = BARON } 
						mother_even_if_dead = { higher_tier_than = BARON } 
					} 
				}
				AND = { 
					is_ruler = no
					spouse = { tier = BARON } 
				}
				AND = { 
					is_ruler = no
					father_even_if_dead = { tier = BARON } 
				}
				AND = { 
					is_ruler = no
					mother_even_if_dead = { tier = BARON } 
				}
			}
			NOR = { 
				AND = { 
					tier = COUNT
					NOR = { 
						father_even_if_dead = { higher_tier_than = COUNT } 
						mother_even_if_dead = { higher_tier_than = COUNT } 
					} 
				}
				AND = { 
					lower_tier_than = COUNT
					spouse = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					father_even_if_dead = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					mother_even_if_dead = { tier = COUNT } 
				}
			}
		}
		piety = -40
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = COUNT
					NOR = { 
						father_even_if_dead = { higher_tier_than = COUNT } 
						mother_even_if_dead = { higher_tier_than = COUNT } 
					} 
				}
				AND = { 
					lower_tier_than = COUNT
					spouse = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					father_even_if_dead = { tier = COUNT } 
				}
				AND = { 
					lower_tier_than = COUNT
					mother_even_if_dead = { tier = COUNT } 
				}
			}
			NOR = { 
				AND = { 
					tier = DUKE
					NOR = { 
						father_even_if_dead = { higher_tier_than = DUKE } 
						mother_even_if_dead = { higher_tier_than = DUKE } 
					} 
				}
				AND = { 
					lower_tier_than = DUKE
					spouse = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					father_even_if_dead = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					mother_even_if_dead = { tier = DUKE } 
				}
			}
		}
		piety = -70
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = DUKE
					NOR = { 
						father_even_if_dead = { higher_tier_than = DUKE } 
						mother_even_if_dead = { higher_tier_than = DUKE } 
					} 
				}
				AND = { 
					lower_tier_than = DUKE
					spouse = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					father_even_if_dead = { tier = DUKE } 
				}
				AND = { 
					lower_tier_than = DUKE
					mother_even_if_dead = { tier = DUKE } 
				}
			}
			NOR = { 
				AND = { 
					tier = KING
					NOR = { 
						father_even_if_dead = { higher_tier_than = KING } 
						mother_even_if_dead = { higher_tier_than = KING } 
					} 
				}
				AND = { 
					lower_tier_than = KING
					spouse = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					father_even_if_dead = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					mother_even_if_dead = { tier = KING } 
				}
			}
		}
		piety = -100
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = KING
					NOR = { 
						father_even_if_dead = { higher_tier_than = KING } 
						mother_even_if_dead = { higher_tier_than = KING } 
					} 
				}
				AND = { 
					lower_tier_than = KING
					spouse = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					father_even_if_dead = { tier = KING } 
				}
				AND = { 
					lower_tier_than = KING
					mother_even_if_dead = { tier = KING } 
				}
			}
			NOR = { 
				AND = { 
					tier = EMPEROR
					NOR = { 
						father_even_if_dead = { higher_tier_than = EMPEROR } 
						mother_even_if_dead = { higher_tier_than = EMPEROR } 
					} 
				}
				AND = { 
					lower_tier_than = EMPEROR
					spouse = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					father_even_if_dead = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					mother_even_if_dead = { tier = EMPEROR } 
				}
			}
		}
		piety = -150
	}
	if = {
		limit = {
			OR = { 
				AND = { 
					tier = EMPEROR
					NOR = { 
						father_even_if_dead = { higher_tier_than = EMPEROR } 
						mother_even_if_dead = { higher_tier_than = EMPEROR } 
					} 
				}
				AND = { 
					lower_tier_than = EMPEROR
					spouse = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					father_even_if_dead = { tier = EMPEROR } 
				}
				AND = { 
					lower_tier_than = EMPEROR
					mother_even_if_dead = { tier = EMPEROR } 
				}
			}
		}
		piety = -350
	}
}
#Used for gluttonous and hedonistic actions.
gain_weight_small_effect = {
	custom_tooltip = {
		hidden_tooltip = {
		change_variable = { which = physique_variable value = 5 }
		}
	}
} 
gain_weight_medium_effect = {
	custom_tooltip = {
		hidden_tooltip = {
		change_variable = { which = physique_variable value = 10 }
		}
	}
} 
gain_weight_large_effect = {
	custom_tooltip = {
		hidden_tooltip = {
		change_variable = { which = physique_variable value = 15 }
		}
	}
}

#Used for training and balanced lifestyle.
balance_weight_small_effect =  {
	custom_tooltip = {
		hidden_tooltip = {
			#If variable is above 1, reduce it. If it's below 1 increase it.
			if = { 
				limit = {
					check_variable = { which = physique_variable value = 1 }
				}
				change_variable = { which = physique_variable value = -2 }
			}
			if = { 
				limit = {
					NOT = { check_variable = { which = physique_variable value = -1 } }
				}
				change_variable = { which = physique_variable value = 2 }
			}
		}
	}
} 
balance_weight_medium_effect = {
	custom_tooltip = {
		hidden_tooltip = {
			#If variable is above 1, reduce it. If it's below 1 increase it.
			if = { 
				limit = {
					check_variable = { which = physique_variable value = 1 }
				}
				change_variable = { which = physique_variable value = -5 }
			}
			if = { 
				limit = {
					NOT = { check_variable = { which = physique_variable value = -1 } }
				}
				change_variable = { which = physique_variable value = 5 }
			}
		}
	}
} 

balance_weight_large_effect = { #Should be used rarely.
	custom_tooltip = {
		hidden_tooltip = {
			#If variable is above 1, reduce it. If it's below 1 increase it.
			if = { 
				limit = {
					check_variable = { which = physique_variable value = 1 }
				}
				change_variable = { which = physique_variable value = -10 }
			}
			if = { 
				limit = {
					NOT = { check_variable = { which = physique_variable value = -1 } }
				}
				change_variable = { which = physique_variable value = 10 }
			}
		}
	}
} 

#Used for seclusions, fasting, dungeon starvation, etc.
lose_weight_small_effect = {
	custom_tooltip = {
		hidden_tooltip = {
		change_variable = { which = physique_variable value = -6 } #Because of the way trigger works, checks if you are below -5/-10/-15
		}
	}
} 
lose_weight_medium_effect = {
	custom_tooltip = {
		hidden_tooltip = {
	change_variable = { which = physique_variable value = -11 }
		}
	}
} 
lose_weight_large_effect = {
	custom_tooltip = {
		hidden_tooltip = {
	change_variable = { which = physique_variable value = -16 }
		}
	}
}  

#Doesn't change the variable, only checks if the character has the correct trait assigned.
weight_trait_check_effect = { 

	#Debilitating effects are gained by special events, usually later in life (40s), but they can be cleared up if the character's variable goes back towards 0 again.
	if = { 
		limit = {
			NOT = { check_variable = { which = physique_variable value = 30 } }
			has_character_modifier = obese_modifier
		}
		remove_character_modifier = obese_modifier
	}
	if = { 
		limit = {
			check_variable = { which = physique_variable value = -30 }
			has_character_modifier = severely_underweight_modifier
		}
		remove_character_modifier = severely_underweight_modifier
	}

	if = { 
		limit = {
			trait = is_fat
			NOT = { check_variable = { which = physique_variable value = 15 } }
			check_variable = { which = physique_variable value = -15 } 
		}
		remove_trait = is_fat
		hidden_tooltip = { 
			remove_weight_modifier_effect = yes
			character_event = { id = HFP.20601 } #Notification
		} 
	}
	if = { 
		limit = {
			trait = is_fat
			NOT = { check_variable = { which = physique_variable value = -15 } }
		}
		remove_trait = is_fat
		add_trait = is_malnourished
		hidden_tooltip = { 
			remove_weight_modifier_effect = yes
			character_event = { id = HFP.20602 } #Notification
		} 
	}
	if = { 
		limit = {
			trait = is_malnourished
			NOT = { check_variable = { which = physique_variable value = 15 } }
			check_variable = { which = physique_variable value = -15 } 
		}
		remove_trait = is_malnourished
		hidden_tooltip = { 
			remove_weight_modifier_effect = yes
			character_event = { id = HFP.20603 } #Notification
		} 
	}
	if = { 
		limit = {
			trait = is_malnourished
			check_variable = { which = physique_variable value = 15 }
		}
		remove_trait = is_malnourished
		add_trait = is_fat
		hidden_tooltip = { 
			remove_weight_modifier_effect = yes
			character_event = { id = HFP.20600 } #Notification
		} 
	}
	if = { 
		limit = {
			NOR = { 
				trait = is_malnourished 
				trait = is_fat
			}
			check_variable = { which = physique_variable value = 15 }
		}
		#First time try to fire a special event if character meets any of the conditions, otherwise simply notify.
		weight_flavor_conditions_effect = yes
		add_trait = is_fat
		hidden_tooltip = { character_event = { id = HFP.20600 } } #Notification
	}
	if = { 
		limit = {
			NOR = { 
				trait = is_malnourished 
				trait = is_fat
			}
			NOT = { check_variable = { which = physique_variable value = -15 } }
		}
		#First time try to fire a special event if character meets any of the conditions, otherwise simply notify.
		weight_flavor_conditions_effect = yes
		add_trait = is_malnourished
		hidden_tooltip = { character_event = { id = HFP.20602 } } #Notification
	}

}  
apply_weight_modifier_effect = { 
	if = { 
		limit = {
			OR = {
				has_character_flag = flag_fat_for_gluttony
				has_character_flag = flag_fat_for_boredom
			}
		}
		add_character_modifier = {
			name = coping_glutton
			duration = 5000
		}
	}
	if = { 
		limit = {
			OR = {
				has_character_flag = flag_fat_for_sloth
				has_character_flag = flag_malnourished_for_sloth
				has_character_flag = flag_fat_for_stress
				has_character_flag = flag_malnourished_for_stress
				has_character_flag = flag_fat_for_lust
				has_character_flag = flag_fat_for_wroth
				has_character_flag = flag_malnourished_for_craven
			}
		}
		add_character_modifier = {
			name = stress_relief
			duration = 5000
		}
	}
	if = { 
		limit = {
			OR = {
				has_character_flag = flag_fat_for_depression
				has_character_flag = flag_malnourished_for_depression
			}
		}
		add_character_modifier = {
			name = anti_depression
			duration = 5000
		}
	}
	if = { 
		limit = {
			OR = {
				has_character_flag = flag_fat_for_hedonism
				has_character_flag = flag_fat_for_carousing
				has_character_flag = flag_fat_for_drunkard
			}
		}
		add_character_modifier = {
			name = munificent_modifier
			duration = 5000
		}
	}
	if = { 
		limit = {
			OR = {
				has_character_flag = flag_fat_for_family
				has_character_flag = flag_fat_for_content
			}
			is_female = yes
		}
		add_character_modifier = {
			name = jolly_matron_modifier
			duration = 5000
		}
	}
	if = { 
		limit = {
			OR = {
				has_character_flag = flag_fat_for_family
				has_character_flag = flag_fat_for_content
			}
			is_female = no
		}
		add_character_modifier = {
			name = jolly_patriarch_modifier
			duration = 5000
		}
	}
	if = { 
		limit = {
			OR = {
				has_character_flag = flag_malnourished_for_temperance
				has_character_flag = flag_malnourished_for_boredom
			}
		}
		add_character_modifier = {
			name = extremely_temperate
			duration = 5000
		}
	}
	if = { 
		limit = {
			has_character_flag = flag_malnourished_for_study
		}
		add_character_modifier = {
			name = restless_study
			duration = 5000
		}
	}
	if = { 
		limit = {
			has_character_flag = flag_malnourished_for_faith
		}
		add_character_modifier = {
			name = restless_prayer
			duration = 5000
		}
	}
	if = { 
		limit = {
			has_character_flag = flag_malnourished_for_paranoia
		}
		add_character_modifier = {
			name = malnourished_paranoia
			duration = 5000
		}
	}
	if = { 
		limit = {
			has_character_flag = flag_malnourished_for_diligence
		}
		add_character_modifier = {
			name = tireless_worker
			duration = 5000
		}
	}
	if = { 
		limit = {
			has_character_flag = flag_malnourished_for_cannibal
		}
		add_character_modifier = {
			name = refined_palate
			duration = 5000
		}
	}
}
remove_weight_modifier_effect = {
	if = { 
		limit = { 
			has_character_modifier = coping_glutton
		}
		remove_character_modifier = coping_glutton
	}
	if = { 
		limit = {
			has_character_modifier = stress_relief
		}
		remove_character_modifier = stress_relief
	}
	if = { 
		limit = {
			has_character_modifier = anti_depression
		}
		remove_character_modifier = anti_depression
	}
	if = { 
		limit = {
			has_character_modifier = munificent_modifier
		}
		remove_character_modifier = munificent_modifier
	}
	if = { 
		limit = {
			has_character_modifier = jolly_matron_modifier
		}
		remove_character_modifier = jolly_matron_modifier
	}
	if = { 
		limit = {
			has_character_modifier = jolly_patriarch_modifier
		}
		remove_character_modifier = jolly_patriarch_modifier
	}
	if = { 
		limit = {
			has_character_modifier = extremely_temperate
		}
		remove_character_modifier = extremely_temperate
	}
	if = { 
		limit = {
			has_character_modifier = restless_study
		}
		remove_character_modifier = restless_study
	}
	if = { 
		limit = {
			has_character_modifier = restless_prayer
		}
		remove_character_modifier = restless_prayer
	}
	if = { 
		limit = {
			has_character_modifier = malnourished_paranoia
		}
		remove_character_modifier = malnourished_paranoia
	}
	if = { 
		limit = {
			has_character_modifier = tireless_worker
		}
		remove_character_modifier = tireless_worker
	}
}
clear_fat_flags_effect = {
	clr_character_flag = flag_fat_for_gluttony 
	clr_character_flag = flag_fat_for_stress
	clr_character_flag = flag_fat_for_depression
	clr_character_flag = flag_fat_for_sloth
	clr_character_flag = flag_fat_for_hedonism
	clr_character_flag = flag_fat_for_carousing
	clr_character_flag = flag_fat_for_family 
	clr_character_flag = flag_fat_for_content 
	clr_character_flag = flag_fat_for_lust
	clr_character_flag = flag_fat_for_wroth
	clr_character_flag = flag_fat_for_drunkard
	clr_character_flag = flag_fat_for_boredom
}
clear_malnourished_flags_effect = {
	clr_character_flag = flag_malnourished_for_temperance 
	clr_character_flag = flag_malnourished_for_stress
	clr_character_flag = flag_malnourished_for_depression
	clr_character_flag = flag_malnourished_for_sloth
	clr_character_flag = flag_malnourished_for_study
	clr_character_flag = flag_malnourished_for_faith
	clr_character_flag = flag_malnourished_for_paranoia 
	clr_character_flag = flag_malnourished_for_diligence
	clr_character_flag = flag_malnourished_for_cannibal
	clr_character_flag = flag_malnourished_for_craven
	clr_character_flag = flag_malnourished_for_boredom
}
weight_flavor_conditions_effect = {

	if = { #If already about to become fat and fulfilling one of the special conditions, fire the specific event to give more flavor.
		limit = { 
			check_variable = { which = physique_variable value = 12 }
			NOT = { trait = is_fat }
			NOT = { has_character_flag = flag_primed_physique }
			#NOT = { trait = temperate }
			NOT = { trait = incapable }
			age = 20
			prisoner = no
			is_inaccessible_trigger = no
			NOT = { #Can happen only once
				has_fat_for_flag_trigger = yes
			}
			OR = { 				#Possible reasons
				trait = gluttonous
				trait = stressed 
				trait = depressed
				trait = slothful
				trait = hedonist
				trait = wroth
				trait = drunkard
				has_focus = focus_carousing 
				AND = { #Happy mom
					OR = { 
						trait = kind
						trait = content
						has_focus = focus_family 
						trait = patient
					}
					NOR = { 
						trait = cruel 
						trait = envious
					}
					is_female = yes
					any_child = { 
						is_alive = yes 
						is_adult = no
					}
				}
				AND = { #Content husband
					OR = { 
						trait = kind
						trait = content
						has_focus = focus_family 
						trait = patient
					}
					NOR = { 
						trait = cruel 
						trait = envious
					}
					is_female = no
					is_married = yes
					OR = { 
						num_of_consorts = 2
						num_of_children = 2
						num_of_spouses = 2
					}
				}
				AND = { #Frustrated lustful survivor mom
					has_character_flag = survivor_mom
					trait = celibate
					trait = lustful
				}
				AND = { #Frustrated eunuch
					trait = eunuch
					trait = lustful
				}
				AND = { #Generic fallback
					NOT = { trait = temperate }
					check_variable = { which = physique_variable value = 15 }
				}
			}
		}
		if = { 
			limit = { NOT = { check_variable = { which = physique_variable value = 15 } } }
			gain_weight_small_effect = yes
		}
		set_character_flag = flag_primed_physique
		character_event = { id = HFP.20605 days = 10 }
	}
	if = { #If already about to become malnourished and fulfilling one of the special conditions, fire the specific event to give more flavor.
		limit = { 
			NOT = { check_variable = { which = physique_variable value = -12 } }
			NOT = { trait = is_malnourished }
			#NOT = { trait = gluttonous }
			NOT = { trait = incapable }
			NOT = { has_character_flag = flag_primed_physique }
			age = 20
			prisoner = no
			is_inaccessible_trigger = no
			NOT = { #Can happen only once
				has_malnourished_for_flag_trigger = yes
			}
			OR = { 				#Possible reasons
				trait = temperate
				trait = stressed
				trait = depressed
				trait = slothful
				trait = scholar
				trait = cannibal_trait
				trait = craven
				has_focus = focus_scholarship
				AND = { 
					NOT = { trait = cynical }
					trait = theologian
					OR = { 
						religion_group = christian
						religion_group = muslim
						religion_group = jewish_group
						religion_group = indian_group
					}
				}
				AND = { 
					NOT = { trait = cynical }
					has_focus = focus_theology
					OR = { 
						religion_group = christian
						religion_group = muslim
						religion_group = jewish_group
						religion_group = indian_group
					}
				}
				trait = paranoid
				trait = diligent
				AND = { #Generic fallback
					NOT = { trait = gluttonous }
					NOT = { check_variable = { which = physique_variable value = -15 } }
				}
			}
		}
		if = { 
			limit = { check_variable = { which = physique_variable value = -15 } }
			lose_weight_small_effect = yes
		}
		set_character_flag = flag_primed_physique
		character_event = { id = HFP.20628 days = 10 }
	}	
}

#Copied to facilitate use elsewhere.
this_post_weight_gain_flavor_effect = { 
	random_list = { 
		25 = { }
		5 = { 
			trigger = { 
				trait = stressed
			}
			character_event = { id = HFP.20607 days = 50 random = 50 } #Lose stressed
		}
		5 = { 
			trigger = { 
				trait = depressed
			}
			character_event = { id = HFP.20608 days = 50 random = 50 } #Lose depressed
		}
		2 = { 
			modifier = { 
				factor = 0.5
				check_variable = { which = physique_variable value = 20 }
			}
			modifier = { 
				factor = 0.5
				NOT = { trait = feeble }
			}
			character_event = { id = HFP.20609 days = 50 random = 50 } #Gain health
		}
		2 = { 
			modifier = { 
				factor = 1.5
				check_variable = { which = physique_variable value = 20 }
			}
			modifier = { 
				factor = 1.75
				trait = sturdy
			}
			character_event = { id = HFP.20610 days = 50 random = 50 } #Lose health
		}
		3 = { 
			modifier = { 
				factor = 0.5
				trait = greedy
			}
			character_event = { id = HFP.20611 days = 50 random = 50 } #become charitable, vassal opinion.
		}
		5 = { 
			trigger = { 
				is_ruler = yes
				NOR = { 
					trait = stressed
					trait = depressed
					trait = wroth
				}
			}
			character_event = { id = HFP.20663 days = 50 random = 50 } #Become proud.
		}
		5 = { 
			trigger = { 
				NOT = { 
					trait = wroth
				}
			}
			character_event = { id = HFP.20664 days = 50 random = 50 } #Become patient.
		}
		1 = { 
			trigger = { 
				NOR = { 
					trait = stressed
					trait = depressed
					trait = wroth
				}
			}
			character_event = { id = HFP.20665 days = 50 random = 50 } #Become content.
		}
	}
}

this_post_weight_loss_flavor_effect = { 
	random_list = { 
		25 = { }
		5 = { 
			trigger = { 
				trait = stressed
			}
			character_event = { id = HFP.20607 days = 50 random = 50 } #Lose stressed
		}
		5 = { 
			trigger = { 
				trait = depressed
			}
			character_event = { id = HFP.20608 days = 50 random = 50 } #Lose depressed
		}
		2 = { 
			modifier = { 
				factor = 0.5
				check_variable = { which = physique_variable value = 20 }
			}
			modifier = { 
				factor = 0.5
				NOT = { trait = feeble }
			}
			character_event = { id = HFP.20609 days = 50 random = 50 } #Gain health
		}
		2 = { 
			modifier = { 
				factor = 1.5
				check_variable = { which = physique_variable value = 20 }
			}
			modifier = { 
				factor = 1.75
				trait = sturdy
			}
			character_event = { id = HFP.20610 days = 50 random = 50 } #Lose health
		}
		3 = { 
			modifier = { 
				factor = 0.5
				trait = greedy
			}
			character_event = { id = HFP.20611 days = 50 random = 50 } #become charitable, vassal opinion.
		}
		5 = { 
			trigger = { 
				is_ruler = yes
				NOR = { 
					trait = stressed
					trait = depressed
					trait = wroth
				}
			}
			character_event = { id = HFP.20663 days = 50 random = 50 } #Become proud.
		}
		5 = { 
			trigger = { 
				NOT = { 
					trait = wroth
				}
			}
			character_event = { id = HFP.20664 days = 50 random = 50 } #Become patient.
		}
		1 = { 
			trigger = { 
				NOR = { 
					trait = stressed
					trait = depressed
					trait = wroth
				}
			}
			character_event = { id = HFP.20665 days = 50 random = 50 } #Become content.
		}
	}
}

# Referenced by Alternate Start religion feature generation
reset_religion_features_effect = {
	set_peace_piety_gain = 0
	set_pacifist = no
	set_convert_other_groups = 2
	set_convert_same_group = 2
	set_peace_prestige_loss = 0
	set_ai_aggression = 1
	set_unit_modifier = {}
	set_unit_home_modifier = {}
	set_hard_to_convert = no
	set_raised_vassal_opinion_loss = yes
	set_piety_loss_for_attacking_same_religion = no
	set_max_wives = 1
	set_max_consorts = 0
	set_feminist = no
	set_heir_designation = no
	set_short_reign_opinion_year_mult = -1000
	set_jizya_tax = no
	set_can_retire_to_monastery = no
	set_can_excommunicate = no
	set_can_grant_divorce = no
	set_can_grant_invasion_cb = no
	set_can_grant_claim = no
	set_can_call_crusade = no
	set_pc_marriage = no
	set_bs_marriage = no
	set_psc_marriage = yes
	set_cousin_marriage = yes
	set_seafaring = no
	set_allow_looting = no
	set_allow_rivermovement = no
	set_autocephaly = no
	set_pentarchy = no
	set_divine_blood = no
	set_uses_decadence = no
	set_can_have_antipopes = no
	set_priests_can_marry = no
	set_priests_can_inherit = yes
	set_ignores_defensive_attrition = no
	set_defensive_attrition = no
	clear_intermarry = no
	set_character_modifier = {}
	clear_intermarry = yes
	set_allows_matrilineal_marriage = yes
}

random_antagonizer_slander_roll_effect = { 
	random_list = { 
		75 = { #Nothing
			modifier = { 
				factor = 0.75
				FROM = { 
					attribute_diff = { character = ROOT attribute = intrigue  value = 4 }
				} 
			}
			modifier = { 
				factor = 0.75
				FROM = { 
					attribute_diff = { character = ROOT attribute = intrigue  value = 6 }
				} 
			}
			modifier = { 
				factor = 0.5
				FROM = { 
					attribute_diff = { character = ROOT attribute = intrigue  value = 8 }
				} 
			}
			modifier = { 
				factor = 0.5
				FROM = { 
					attribute_diff = { character = ROOT attribute = intrigue  value = 10 }
				} 
			}
		}
		25 = { #Bonus event
			modifier = { 
				factor = 0.5
				NOR = { 
					trait = stressed
					trait = depressed
				} 
				opinion = { who = FROM value = 20 } 
			}
			modifier = { 
				factor = 0.1
				FROM = { 
					has_character_flag = flag_antagonize_slander_generic 
				} 
			}
			modifier = { 
				factor = 1.5
				FROM = { 
					intrigue = 15
				} 
			}
			modifier = { 
				factor = 1.5
				FROM = { 
					intrigue = 18
				} 
			}
			modifier = { 
				factor = 1.5
				FROM = { 
					intrigue = 21
				} 
			}
			modifier = { 
				factor = 1.5
				FROM = { 
					intrigue = 25
				} 
			}
			modifier = { 
				factor = 1.75
				FROM = { 
					intrigue = 30
				} 
			}
			random_antagonizer_slander_effect = yes
		}
	}
}
random_antagonizer_slander_effect = { #Chance of this effect firing is tied to the Antagonizer's intrigue.
	#Gain rival.
	#Rival of target becomes friend.
	#Prestige from antagonizing a higher tier ruler.
	#Appeased's Claimant moves to court.
	#Prestige loss.
	#Piety loss.
	#Sanity loss.
	#Evil Antagonized losing depressed. 
	#Evil Antagonized losing Stressed.
	#Evil Antagonized gaining Diplomacy modifier (happy disposition).
	#Evil Antagonized gaining Intrigue.
	#Evil Antagonized gaining Deceitful.
	#Evil Antagonized gaining Patient.





	random_list = { 
		35 = {
			trigger = { 
				NOT = { 
					persistent_event_target:antagonize_target = { 
						opinion = { 
							who = FROM 
							value = 10 
						} 
					} 
				} 
			}
			modifier = { 
				factor = 0
				FROM = { 
					persistent_event_target:antagonize_target = { 
						is_rival = FROM 
					} 
				} 
			}
			modifier = { 
				factor = 1.25
				FROM = { 
					persistent_event_target:antagonize_target = { 
						NOT = { 
							opinion = { 
								who = FROM 
								value = -10 
							} 
						} 
					} 
				} 
			}
			modifier = { 
				factor = 1.5
				FROM = { 
					persistent_event_target:antagonize_target = { 
						NOT = { 
							opinion = { 
								who = FROM 
								value = -30 
							} 
						} 
					} 
				} 
			}
			modifier = { 
				factor = 1.5
				FROM = { 
					persistent_event_target:antagonize_target = { 
						NOT = { 
							opinion = { 
								who = FROM 
								value = -50 
							} 
						} 
					} 
				} 
			}
			modifier = { 
				factor = 1.75
				FROM = { 
					persistent_event_target:antagonize_target = { 
						NOT = { 
							opinion = { 
								who = FROM 
								value = -70 
							} 
						} 
					} 
				} 
			}
			FROM = { persistent_event_target:antagonize_target = { character_event = { id = HF.22030 days = 15 } } } #Antagonized gets the event.
		}
		25 = {
			modifier = { 
				factor = 0
				NOT = { 
					FROM = { 
						persistent_event_target:antagonize_target = { 
							any_realm_character = { 
								age = 14
								NOR = {
									trait = incapable
									is_rival = PREVPREV 
								} 
								NOT = { 
									opinion = { 
										who = PREV 
										value = -20 
									} 
								} 
							} 
						} 
					} 
				} 
			}
			FROM = { 
				persistent_event_target:antagonize_target = { 
					random_realm_character = { 
						limit = { 
							age = 14
							NOR = {
								trait = incapable
								is_rival = PREVPREV 
							}
							NOT = { 
								opinion = { 
									who = PREV 
									value = -20 
								} 
							}
						}
						character_event = { id = HF.22032 days = 15 } #Third party notified.
					} 
				} 
			} 
		}
		25 = {
			modifier = { 
				factor = 0
				FROM = { 
					persistent_event_target:antagonize_target = { 
						lower_tier_than = FROM
					} 
				} 
			}
			modifier = { 
				factor = 1.75
				FROM = { 
					lower_tier_than = KING
					persistent_event_target:antagonize_target = { 
						higher_tier_than = DUKE
					} 
				} 
			}
			FROM = { character_event = { id = HF.22035 days = 15 } } #Antagonizer gets the event.
		}
		5 = {
			FROM = { character_event = { id = HF.22042 days = 15 } } #Antagonizer gets the event. - Prestige loss for Antagonized.
		}
		5 = {
			FROM = { character_event = { id = HF.22044 days = 15 } } #Antagonizer gets the event. - Piety loss for Antagonized.
		}
		5 = {
			FROM = { character_event = { id = HF.22046 days = 15 } } #Antagonizer gets the event. - Opinion loss for Antagonized.
		}
		1 = {
			modifier = { 
				factor = 0
				persistent_event_target:antagonize_target = { 
					NOT = { trait = depressed } 
				} 
			}
			FROM = { character_event = { id =  HF.22048 days = 15 } } #Antagonizer gets the event. - Sanity loss for Depressed Antagonized.
		}
		25 = {
			modifier = { 
				factor = 0
				NOT = { 
					age = 14
					is_ruler = no
					any_claim = { holder_scope = { character = ROOT } }
					NOR = {
						any_spouse = { is_ruler = yes }
						host = { character = FROM }
						is_rival = FROM
						trait = incapable
						persistent_event_target:antagonize_target = { current_heir = { character = PREVPREV } }
					}
					NOT = { 
						opinion = { 
							who = ROOT
							value = -20 
						} 
					}
					opinion = { 
						who = FROM
						value = 10 
					} 
				} 
			}
			random_character = {
				limit = { 
					age = 14
					is_ruler = no
					any_claim = { holder_scope = { character = ROOT } }
					NOR = {
						any_spouse = { is_ruler = yes }
						host = { character = FROM }
						is_rival = FROM
						trait = incapable
						persistent_event_target:antagonize_target = { current_heir = { character = PREVPREV } }
					}
					NOT = { 
						opinion = { 
							who = ROOT
							value = -20 
						} 
					}
					opinion = { 
						who = FROM
						value = 10 
					}  
				}
				character_event = { id = HF.22036 days = 15 } #Claimant notified.
			} 
		}
		5 = {
			trigger = { 

				FROM = { 
					OR = { 
						trait = impaler
						trait = cruel 
						trait = arbitrary
						trait = deceitful
						trait = envious
					}  
				} 
				FROM = { trait = depressed }
			}
			FROM = { character_event = { id = HF.22113 days = 15 } } #Evil Antagonized loses depressed.
		}
		5 = {
			trigger = { 

				FROM = { 
					OR = { 
						trait = impaler 
						trait = cruel 
						trait = arbitrary
						trait = deceitful
						trait = envious
					}  
				} 
				FROM = { trait = stressed }
			}
			FROM = { character_event = { id = HF.22114 days = 15 } } #Evil Antagonized loses stressed.
		}
		5 = {
			trigger = { 

				FROM = { 
					OR = { 
						trait = impaler
						trait = cruel 
						trait = arbitrary
						trait = deceitful
						trait = envious
					}  
					NOR = { 
						trait = stressed 
						trait = depressed
					}  
				} 
				FROM = { NOT = { has_character_modifier = antagonizer_good_mood } }
			}
			FROM = { character_event = { id = HF.22115 days = 15 } } #Evil Antagonized gains Diplomacy modifier.
		}
		1 = {
			trigger = { 
				FROM = { 
					OR = { 
						trait = impaler
						trait = cruel 
						trait = arbitrary
						trait = deceitful
						trait = envious
					}  
				} 
			}
			FROM = { character_event = { id = HF.22116 days = 15 } } #Evil Antagonized gains Intrigue.
		}
		3 = {
			trigger = { 
				FROM = { 
					OR = { 
						trait = impaler
						trait = cruel 
						trait = arbitrary
						trait = envious
					}  
					NOT = { 
						trait = deceitful
					}  
				} 
			}
			FROM = { character_event = { id = HF.22117 days = 15 } } #Evil Antagonized gains Deceitful/loses Honest.
		}
		5 = {
			trigger = { 
				FROM = { 
					OR = { 
						trait = impaler
						trait = cruel 
						trait = arbitrary
						trait = deceitful
						trait = envious
					}  
					NOT = { 
						trait = patient
					} 
				} 
				NOR = { 
					trait = patient
					diplomacy = 12
				} 
			}
			FROM = { character_event = { id = HF.22118 days = 15 } } #Evil Antagonized gains Patient/loses Wroth.
		}
	#	5 = {
	#		modifier = { 
	#			factor = 0
	#			FROM = { 
	#				any_claim = { 
	#					holder_scope = { 
	#						character = ROOT
	#					} 
	#				} 
	#			} 
	#		}
	#		modifier = { #Only against dangerous Antagonize targets.
	#			factor = 0
	#			persistent_event_target:antagonize_target = { 
	#				lower_tier_than = FROM 
	#			} 
	#		}
	#		modifier = { #Only against dangerous Antagonize targets.
	#			factor = 0.25
	#			persistent_event_target:antagonize_target = { 
	#				prestige = 500
	#			} 
	#		}
	#		modifier = { #Needs to be hated already. The Antagonizer should receive the claim only if the Antagonized is already mad at him and is a more powerful ruler.
	#			factor = 0
	#			persistent_event_target:antagonize_target = { 
	#				opinion = { 
	#					who = FROM
	#					value = 10 
	#				}  
	#			} 
	#		}
	#		FROM = { character_event = { id = HF.22038 days = 15 } } #Antagonizer gets the claim.
	#	}
	}
}

select_and_save_fellow_society_member_effect = { #[Runs for ROOT]
	### Scripted triggers involved:
	# block_general_event_trigger	- NOTE, if you want to reuse this and allow children be selected, this blocks it
	
	# root_has_terrible_opinion_modifier_of_this_trigger	- To not select folks that have HATRED between them...
	# this_has_terrible_opinion_modifier_of_root_trigger
	
	# root_potentially_platonically_interested_in_this_trigger	- In the best case, selects characters that have shared POSITIVE experiences...
	# potentially_platonically_interested_in_root_trigger
	# current_scope_and_root_make_sense_as_friendlies_trigger

	random_society_member = { #Worst case scenario...
        limit = { 
            same_society_as = ROOT
            NOT = { character = ROOT }
            prisoner = no
        }
        save_event_target_as = fellow_member
    }
    random_society_member = { #Second worst, etc...
        limit = { 
            same_society_as = ROOT
            NOT = { character = ROOT }
            prisoner = no
        }
        save_event_target_as = fellow_member
    }
    random_society_member = {
        limit = { 
            same_society_as = ROOT
            NOT = { character = ROOT }
            block_general_event_trigger = no
            root_has_terrible_opinion_modifier_of_this_trigger = no
        }
        save_event_target_as = fellow_member
    }
    random_society_member = {
        limit = { 
            same_society_as = ROOT
            NOT = { character = ROOT }
            block_general_event_trigger = no
            this_has_terrible_opinion_modifier_of_root_trigger = no
        }
        save_event_target_as = fellow_member
    }
    random_society_member = {
        limit = { 
            same_society_as = ROOT
            NOT = { character = ROOT }
            block_general_event_trigger = no
            root_has_terrible_opinion_modifier_of_this_trigger = no
            this_has_terrible_opinion_modifier_of_root_trigger = no
        }
        save_event_target_as = fellow_member
    }
    random_society_member = {
        limit = { 
            same_society_as = ROOT
            NOT = { character = ROOT }
            block_general_event_trigger = no
            root_potentially_platonically_interested_in_this_trigger = yes
        }
        save_event_target_as = fellow_member
    }
    random_society_member = {
        limit = { 
            same_society_as = ROOT
            NOT = { character = ROOT }
            block_general_event_trigger = no
            potentially_platonically_interested_in_root_trigger = yes
        }
        save_event_target_as = fellow_member
    }
    random_society_member = { #Best case scenario...
        limit = { 
            same_society_as = ROOT
            NOT = { character = ROOT }
            block_general_event_trigger = no
            current_scope_and_root_make_sense_as_friendlies_trigger = yes
        }
        save_event_target_as = fellow_member
    }
}

add_warrior_lodge_leader_trait_effect = {
	trigger_switch = {
		on_trigger = society_member_of
		warrior_lodge_norse = {
			add_trait = norse_leader
		}
		warrior_lodge_tengri = {
			add_trait = tengri_leader
		}
		warrior_lodge_baltic = {
			add_trait = baltic_leader
		}
		warrior_lodge_finnish = {
			add_trait = finnish_leader
		}
		warrior_lodge_slavic = {
			add_trait = slavic_leader
		}
		warrior_lodge_west_african = {
			add_trait = west_african_leader
		}
		warrior_lodge_zun = {
			add_trait = zun_leader
		}
		warrior_lodge_bon = {
			add_trait = bon_leader
		}
		warrior_lodge_hellenic = {
			add_trait = hellenic_leader
		}
		#RTP
		warrior_lodge_aztec = {
			add_trait = aztec_leader
		}
		warrior_lodge_catholic = {
			add_trait = christian_leader
		}
		warrior_lodge_orthodox = {
			add_trait = christian_leader
		}
		warrior_lodge_miaphysite = {
			add_trait = christian_leader
		}
		warrior_lodge_nestorian = {
			add_trait = christian_leader
		}
		warrior_lodge_jewish = {
			add_trait = jewish_leader
		}
		warrior_lodge_sunni = {
			add_trait = muslim_leader
		}
		warrior_lodge_shiite = {
			add_trait = muslim_leader
		}
		warrior_lodge_ibadi = {
			add_trait = muslim_leader
		}
		warrior_lodge_zoroastrian = {
			add_trait = zoroastrian_leader
		}
		warrior_lodge_eastern = {
			add_trait = eastern_leader
		}
	}
}
fire_haruspicy_event_effect = {
	hidden_tooltip = { #Divination.
		if = {
			limit = { 
				attacker = { 
					OR = { 
						religion = hellenic_pagan 
						religion = hellenic_pagan_reformed
						has_religion_feature = religion_haruspicy 
					} 
				} 
			}
			attacker = {  
				character_event = { id = HF.23005 }
			}
		}
		if = {
			limit = { 
				defender = { 
					OR = { 
						religion = hellenic_pagan 
						religion = hellenic_pagan_reformed
						has_religion_feature = religion_haruspicy 
					} 
				} 
			}
			defender = {  
				character_event = { id = HF.23005 }
			}
		}
	}
}

remove_opinions_with_prison_reason_effect = { # TODO: codegenerate this
	#Removes the specified opinion about "who" (PREV), from current scope
	#NOTE: If you add a new opinion with "prison_reason" to the game, add it here, too!
	remove_opinion = { modifier = opinion_dishonorable who = PREV }
	remove_opinion = { modifier = opinion_traitor who = PREV }
	remove_opinion = { modifier = opinion_rebel_traitor who = PREV }
	remove_opinion = { modifier = opinion_regicide_traitor who = PREV }
	remove_opinion = { modifier = attempted_murder_of_spouse who = PREV }
	remove_opinion = { modifier = attempted_murder_of_child who = PREV }
	remove_opinion = { modifier = attempted_murder_of_parent who = PREV }
	remove_opinion = { modifier = attempted_murder_of_sibling who = PREV }
	remove_opinion = { modifier = attempted_murder_of_vassal who = PREV }
	remove_opinion = { modifier = attempted_murder_of_spouse_vassal who = PREV }
	remove_opinion = { modifier = attempted_murder who = PREV }
	remove_opinion = { modifier = opinion_spouse_slayer who = PREV }
	remove_opinion = { modifier = opinion_murder_attempt who = PREV }
	remove_opinion = { modifier = opinion_killed_close_kin who = PREV }
	remove_opinion = { modifier = opinion_killed_father who = PREV }
	remove_opinion = { modifier = opinion_hajj_attempt_murder who = PREV }
	remove_opinion = { modifier = opinion_fatwa_target who = PREV }
	remove_opinion = { modifier = opinion_refused_order who = PREV }
	remove_opinion = { modifier = opinion_castrated_me who = PREV }
	remove_opinion = { modifier = opinion_blinded_me who = PREV }
	remove_opinion = { modifier = opinion_castrated_family who = PREV }
	remove_opinion = { modifier = opinion_castrated_close_kin who = PREV }
	remove_opinion = { modifier = opinion_blinded_family who = PREV }
	remove_opinion = { modifier = opinion_blinded_close_kin who = PREV }
	remove_opinion = { modifier = opinion_witch who = PREV }
	remove_opinion = { modifier = opinion_takfir who = PREV }
	remove_opinion = { modifier = opinion_attempted_abduction who = PREV }
	remove_opinion = { modifier = opinion_unfaithful_wife who = PREV }
	remove_opinion = { modifier = opinion_unfaithful_husband_crime who = PREV }
	remove_opinion = { modifier = opinion_cuckolded who = PREV }
	remove_opinion = { modifier = opinion_killed_lover who = PREV }
	remove_opinion = { modifier = opinion_charge_heresiarch who = PREV }
	remove_opinion = { modifier = opinion_charge_infidel who = PREV }
	remove_opinion = { modifier = opinion_charge_deviant who = PREV }
	remove_opinion = { modifier = opinion_charge_illegitimate who = PREV }
	remove_opinion = { modifier = opinion_charge_cultist who = PREV }
	remove_opinion = { modifier = opinion_charge_dw who = PREV }
	remove_opinion = { modifier = opinion_charge_traitor who = PREV }
	remove_opinion = { modifier = opinion_charge_slanderer who = PREV }
	remove_opinion = { modifier = abuse_of_office who = PREV }
	remove_opinion = { modifier = opinion_tortured_me who = PREV }
	remove_opinion = { modifier = opinion_tortured_family who = PREV }
	remove_opinion = { modifier = opinion_tortured_close_kin who = PREV }
	remove_opinion = { modifier = opinion_mutilated_me who = PREV }
	remove_opinion = { modifier = opinion_mutilated_family who = PREV }
	remove_opinion = { modifier = opinion_mutilated_close_kin who = PREV }
	remove_opinion = { modifier = opinion_thief who = PREV }
	remove_opinion = { modifier = opinion_outlawed_society who = PREV }
	remove_opinion = { modifier = opinion_accused_apostate who = PREV }
}



randomize_ABC_desc_flag_effect = {
	# Actually, this is not needed, but won't remove for fear of breaking something.
	# Instead, to randomize descs, simply define (in the event), multiple descs.

	# Example below:
	# desc = text_1
	# desc = text_2
	# desc = text_3
	
	clr_ABC_desc_flag_effect = yes
	random_list = {
		10 = { set_character_flag = desc_A }
		10 = { set_character_flag = desc_B }
		10 = { set_character_flag = desc_C }
	}
}
clr_ABC_desc_flag_effect = {
	clr_character_flag = desc_A
	clr_character_flag = desc_B
	clr_character_flag = desc_C
}

#Find someone to reference... (event_target:my_beloved) 
# NOTE: might be platonic, children, etc
save_beloved_character_effect = {
	if = {
		limit = { #In case you have a spouse outside of your realm...
			is_married = yes
			any_spouse = {
				ROOT_possibly_romantically_interested_trigger = yes
				root_has_terrible_opinion_modifier_of_this_trigger = no
				is_landed = yes
			}
		}
		random_spouse = {
			limit = {
				ROOT_possibly_romantically_interested_trigger = yes
				root_has_terrible_opinion_modifier_of_this_trigger = no
				is_landed = yes
			}
			save_event_target_as = my_beloved
		}
	}
	else = { #In case you do not...
		any_courtier_or_vassal = {
			limit = {
				NOT = { character = event_target:enemy_commander }
				NOT = { character = event_target:enemy_liege }
			}
			score_value = { #Prioritizes selecting some kind of loved person...
                value = 1
                beloved_target_selection_score = yes
            }
			#Effect:
			save_event_target_as = my_beloved
		}
	}
}

child_of_destiny_journey_start_effect = {
	if = {
		limit = {
			has_global_flag = cod_test_values
		}
		character_event = { id = HF.210 days = 1 } # The journey begins... Test Value
	}
	else = {
		character_event = { id = HF.210 days = 200 random = 200 } # The journey begins...
	}
}

child_of_destiny_journey_resume_effect = {
	if = {
		limit = {
			has_global_flag = cod_test_values
		}
		character_event = { id = HF.210 days = 1 }  # Back to the journey tombola! Test Value
	}
	else = {
		character_event = { id = HF.210 days = 365 random = 500 } # Back to the journey tombola!
	}
}

pacifists_lose_piety_effect = {
	if = {
		limit = {
			religion = jain
			NOT = {
				has_alternate_start_parameter = { key = religion_names value = random }
			}
		}
		piety = -20
		custom_tooltip = { text = jain_ahimsa_tooltip }
	}
	else_if = {
		limit = {
			pacifist = yes
		}
		piety = -20
		custom_tooltip = { text = pacifist_alt_tooltip }
	}
}

#Current variable values: Scarred = 1, Very Scarred = 5, Horrifically Scarred = 10. To rebalance how quickly a character moves up from one to the other, just change the variable effects on all the following scripted_effects.
add_scarred_tiered_effect = {
	if = {
		limit = { has_dlc = "Holy Fury" }
		hidden_tooltip = { change_variable = { which = scarred_variable value = 1 } } 
		if = {
			limit = {
				check_variable = { which = scarred_variable value = 1 }
				NOT = { check_variable = { which = scarred_variable value = 5 } } 
			}
			if = { 
				limit = { trait = scarred_mid } 
				remove_trait = scarred_mid 
			}
			if = { 
				limit = { trait = scarred_high } 
				remove_trait = scarred_high 
			}
			add_trait = scarred
		}
		if = {
			limit = {
				check_variable = { which = scarred_variable value = 5 }
				NOT = { check_variable = { which = scarred_variable value = 10 } } 
			}
			if = { 
				limit = { trait = scarred } 
				remove_trait = scarred
			}
			if = { 
				limit = { trait = scarred_high } 
				remove_trait = scarred_high 
			}
			add_trait = scarred_mid
		}
		if = {
			limit = {
				check_variable = { which = scarred_variable value = 10 }
			}
			if = { 
				limit = { trait = scarred_mid } 
				remove_trait = scarred_mid 
			}
			if = { 
				limit = { trait = scarred } 
				remove_trait = scarred 
			}
			if = {
				limit = {
					NOT = { trait = scarred_high }
				}
				add_trait = scarred_high
			}
		}
	}
	else_if =  { 
		limit = { NOT = { has_dlc = "Holy Fury" } }
		add_trait = scarred
	}
	hidden_tooltip = {
		if = {
			limit = {
				NOR = { 
					trait = scarred_type_1
					trait = scarred_type_2
					trait = scarred_type_3
					trait = scarred_type_4
					trait = scarred_type_5
					trait = scarred_type_6
					trait = scarred_type_7
					trait = scarred_type_8
					trait = scarred_type_9
					trait = scarred_type_10
				}
			}
			random_list = { 
				10 = { add_trait = scarred_type_1 } 
				10 = { add_trait = scarred_type_2 } 
				10 = { add_trait = scarred_type_3 } 
				10 = { add_trait = scarred_type_4 } 
				10 = { add_trait = scarred_type_5 } 
				10 = { add_trait = scarred_type_6 } 
				10 = { add_trait = scarred_type_7 } 
				10 = { add_trait = scarred_type_8 } 
				10 = { add_trait = scarred_type_9 } 
				10 = { add_trait = scarred_type_10 }
			}
		}
	}
}

add_scarred_medium_effect = {
	if = { 
		limit = { has_dlc = "Holy Fury" }
	hidden_tooltip = { set_variable = { which = scarred_variable value = 5 } }
		if = {
			limit = {
				check_variable = { which = scarred_variable value = 5 }
				NOT = { check_variable = { which = scarred_variable value = 10 } } 
			}
			if = { 
				limit = { trait = scarred_high } 
				remove_trait = scarred_high 
			}
			if = { 
				limit = { trait = scarred } 
				remove_trait = scarred
			}
			add_trait = scarred_mid
		}
	}
	else_if =  { 
		limit = { NOT = { has_dlc = "Holy Fury" } }
		add_trait = scarred
	}
	hidden_tooltip = { 
		if = {
			limit = {
				NOR = { 
					trait = scarred_type_1
					trait = scarred_type_2
					trait = scarred_type_3
					trait = scarred_type_4
					trait = scarred_type_5
					trait = scarred_type_6
					trait = scarred_type_7
					trait = scarred_type_8
					trait = scarred_type_9
					trait = scarred_type_10
				}
			}
			random_list = { 
				10 = { add_trait = scarred_type_1 } 
				10 = { add_trait = scarred_type_2 } 
				10 = { add_trait = scarred_type_3 } 
				10 = { add_trait = scarred_type_4 } 
				10 = { add_trait = scarred_type_5 } 
				10 = { add_trait = scarred_type_6 } 
				10 = { add_trait = scarred_type_7 } 
				10 = { add_trait = scarred_type_8 } 
				10 = { add_trait = scarred_type_9 } 
				10 = { add_trait = scarred_type_10 }
			}
		}
	}
}
add_scarred_high_effect = {
	if = { 
		limit = { has_dlc = "Holy Fury" }
	hidden_tooltip = { set_variable = { which = scarred_variable value = 10 } } 
		if = {
			limit = {
				check_variable = { which = scarred_variable value = 10 }
			}
			if = { 
				limit = { trait = scarred } 
				remove_trait = scarred
			}
			if = { 
				limit = { trait = scarred_mid } 
				remove_trait = scarred_mid
			}
			add_trait = scarred_high
		}
	}
	else_if =  { 
		limit = { NOT = { has_dlc = "Holy Fury" } }
		add_trait = scarred
	}
	hidden_tooltip = { 
		if = {
			limit = {
				NOR = { 
					trait = scarred_type_1
					trait = scarred_type_2
					trait = scarred_type_3
					trait = scarred_type_4
					trait = scarred_type_5
					trait = scarred_type_6
					trait = scarred_type_7
					trait = scarred_type_8
					trait = scarred_type_9
					trait = scarred_type_10
				}
			}
			random_list = { 
				10 = { add_trait = scarred_type_1 } 
				10 = { add_trait = scarred_type_2 } 
				10 = { add_trait = scarred_type_3 } 
				10 = { add_trait = scarred_type_4 } 
				10 = { add_trait = scarred_type_5 } 
				10 = { add_trait = scarred_type_6 } 
				10 = { add_trait = scarred_type_7 } 
				10 = { add_trait = scarred_type_8 } 
				10 = { add_trait = scarred_type_9 } 
				10 = { add_trait = scarred_type_10 }
			}
		}
	}
}

add_scarred_start_effect = {
	if = { 
		limit = { has_dlc = "Holy Fury" }
		if = {
			limit = {
				trait = scarred
			}
			change_variable = { which = scarred_variable value = 1 }
		}
		if = {
			limit = {
				trait = scarred_mid
			}
			change_variable = { which = scarred_variable value = 5 }
		}
		if = {
			limit = {
				trait = scarred_high
			}
			change_variable = { which = scarred_variable value = 10 }
		}
	}
	else_if =  { 
		limit = { NOT = { has_dlc = "Holy Fury" } }
		add_trait = scarred
	}
	hidden_tooltip = { 
		if = {
			limit = {
				NOR = { 
					trait = scarred_type_1
					trait = scarred_type_2
					trait = scarred_type_3
					trait = scarred_type_4
					trait = scarred_type_5
					trait = scarred_type_6
					trait = scarred_type_7
					trait = scarred_type_8
					trait = scarred_type_9
					trait = scarred_type_10
				}
			}
			random_list = { 
				10 = { add_trait = scarred_type_1 } 
				10 = { add_trait = scarred_type_2 } 
				10 = { add_trait = scarred_type_3 } 
				10 = { add_trait = scarred_type_4 } 
				10 = { add_trait = scarred_type_5 } 
				10 = { add_trait = scarred_type_6 } 
				10 = { add_trait = scarred_type_7 } 
				10 = { add_trait = scarred_type_8 } 
				10 = { add_trait = scarred_type_9 } 
				10 = { add_trait = scarred_type_10 }
			}
		}
	}
}

add_blood_splatter_effect = {
	hidden_tooltip = { 
		if = {
			limit = {
				has_character_modifier = blood_splatter_3
			}
			remove_character_modifier = blood_splatter_3
			add_character_modifier = { modifier = blood_splatter_3 months = 5 hidden = yes }
		}
		else_if = {
			limit = {
				OR = { 
					has_character_modifier = blood_splatter_1
					has_character_modifier = blood_splatter_2
				}
			}
			remove_character_modifier = blood_splatter_1
			remove_character_modifier = blood_splatter_2
			add_character_modifier = { modifier = blood_splatter_3 months = 5 hidden = yes }
		}
		else_if = {
			limit = {
				NOR = { 
					has_character_modifier = blood_splatter_1
					has_character_modifier = blood_splatter_2
					has_character_modifier = blood_splatter_3
				}
			}
			random_list = { 
				50 = { add_character_modifier = { modifier = blood_splatter_1 months = 5 hidden = yes } }
				40 = { add_character_modifier = { modifier = blood_splatter_2 months = 5 hidden = yes } }
				10 = { add_character_modifier = { modifier = blood_splatter_3 months = 5 hidden = yes } }
			}
		}
	}
}

reset_flag_lifestyle_sway_event_effect = {
	clr_character_flag = lifestyle_event_successful
	clr_character_flag = lifestyle_event_unsuccessful
	clr_character_flag = sway_hunting
	clr_character_flag = sway_dueling
	clr_character_flag = sway_game
	clr_character_flag = sway_social
	clr_character_flag = sway_scholar
	clr_character_flag = sway_steward
	clr_character_flag = sway_torture
}

apply_cosmopolian_on_start_effect = {
	religion_authority = {
		modifier = cosmopolitan_religion
		years = 1000
	}
	any_playable_ruler = { 
		limit = { NOT = { distance_from_realm = { who = ROOT value = 200 } } }
		add_intermarry = ROOT
		ROOT = { add_intermarry = PREV }
	}
	any_neighbor_independent_ruler = { 
		add_intermarry = ROOT
		ROOT = { add_intermarry = PREV }
	}
}
apply_dogmatic_on_start_effect = {
	religion_authority = {
		modifier = dogmatic_religion
		years = 1000
	}
	remove_intermarry = catholic
	remove_intermarry = orthodox
	remove_intermarry = miaphysite
	remove_intermarry = nestorian
	remove_intermarry = sunni
	remove_intermarry = shiite
	remove_intermarry = ibadi
	remove_intermarry = jewish
	remove_intermarry = samaritan
	remove_intermarry = karaite
	remove_intermarry = hindu
	remove_intermarry = buddhist
	remove_intermarry = jain
	remove_intermarry = taoist
	remove_intermarry = zoroastrian
	remove_intermarry = mazdaki
	remove_intermarry = manichean
	remove_intermarry = khurmazta
	remove_intermarry = pagan
	remove_intermarry = bon
	remove_intermarry = bon_reformed
	remove_intermarry = aztec
	remove_intermarry = aztec_reformed
	remove_intermarry = norse_pagan
	remove_intermarry = norse_pagan_reformed
	remove_intermarry = zun_pagan
	remove_intermarry = zun_pagan_reformed
	remove_intermarry = slavic_pagan
	remove_intermarry = slavic_pagan_reformed
	remove_intermarry = baltic_pagan
	remove_intermarry = baltic_pagan_reformed
	remove_intermarry = west_african_pagan
	remove_intermarry = west_african_pagan_reformed
	remove_intermarry = tengri_pagan
	remove_intermarry = tengri_pagan_reformed
	remove_intermarry = finnish_pagan
	remove_intermarry = finnish_pagan_reformed
	remove_intermarry = hellenic_pagan
	remove_intermarry = hellenic_pagan_reformed
	# Religion groups:
	remove_intermarry = pagan_group
	remove_intermarry = zoroastrian_group
	remove_intermarry = christian
	remove_intermarry = muslim
	remove_intermarry = indian_group
	remove_intermarry = jewish_group
}

bloodthirsty_tiered_traits_effect = {
	hidden_effect = {
		change_variable = { which = burned_hearts_points value = 1 }
		if = { #Tier 1
			limit = {
				check_variable = { which = burned_hearts_points value = 10 }
				NOR = { 
					trait = bloodthirsty_gods_1
					trait = bloodthirsty_gods_2
					trait = bloodthirsty_gods_3
					has_character_modifier = bloodthirsty_gods_exp_cooldown
				}
			}
			character_event = { id = HF.23431 days = 6 } #Notify and assign trait.
			add_character_modifier = { name = bloodthirsty_gods_exp_cooldown days = 12 hidden = yes } #Prevent event cascade.
		}
		if = { #Tier 2
			limit = {
				check_variable = { which = burned_hearts_points value = 50 }
				trait = bloodthirsty_gods_1
				NOR = { 
					trait = bloodthirsty_gods_2
					trait = bloodthirsty_gods_3
					has_character_modifier = bloodthirsty_gods_exp_cooldown
				}
			}
			character_event = { id = HF.23432 days = 6 } #Notify and assign trait.
			add_character_modifier = { name = bloodthirsty_gods_exp_cooldown days = 12 hidden = yes } #Prevent event cascade.
		}
		if = { #Tier 3
			limit = {
				check_variable = { which = burned_hearts_points value = 100 }
				trait = bloodthirsty_gods_2
				NOR = { 
					trait = bloodthirsty_gods_3
					has_character_modifier = bloodthirsty_gods_exp_cooldown
				}
			}
			character_event = { id = HF.23433 days = 6 } #Notify and assign trait.
			add_character_modifier = { name = bloodthirsty_gods_exp_cooldown days = 12 hidden = yes } #Prevent event cascade.
		}
		if = { #Bloodline.
			limit = {
				check_variable = { which = burned_hearts_points value = 200 }
				trait = bloodthirsty_gods_3
				is_ruler = yes
				is_playable = yes
				NOR = { 
					trait = kind 
					has_character_modifier = bloodthirsty_gods_exp_cooldown
					any_owned_bloodline = { # Not already has a Bloodthirsty bloodline.
						has_bloodline_flag = bloodline_created_bloodthirsty
					}
				}
			}
			narrative_event = { id = HF.23434 days = 6 } #Notify and assign trait.
			add_character_modifier = { name = bloodthirsty_gods_exp_cooldown days = 12 hidden = yes } #Prevent event cascade.
		}
	}
}

add_random_tattoo_effect = { #Tied to religion, used only for special events.
	if = { 
		limit = { 
			OR = { 
				religion = norse_pagan
				religion = norse_pagan_reformed
			}
			NOR = { 
				trait = african_tattoo_1
				trait = african_tattoo_2
				trait = african_tattoo_3
				trait = african_tattoo_4
				trait = african_tattoo_5
				trait = african_tattoo_6
				trait = african_tattoo_7
				trait = african_tattoo_8
				trait = african_tattoo_9
				trait = african_tattoo_10
				trait = african_tattoo_11
				trait = african_tattoo_12
				trait = slavic_tattoo_1
				trait = slavic_tattoo_2
				trait = slavic_tattoo_3
				trait = slavic_tattoo_4
				trait = slavic_tattoo_5
				trait = slavic_tattoo_6
				trait = norse_tattoo_1
				trait = norse_tattoo_2
				trait = norse_tattoo_3
				trait = norse_tattoo_4
				trait = norse_tattoo_5
				trait = norse_tattoo_6
			}
		}
		random_list = { 
			50 = { add_trait = norse_tattoo_1 }
			50 = { add_trait = norse_tattoo_2 }
			40 = { add_trait = norse_tattoo_3 }
			30 = { add_trait = norse_tattoo_4 }
			20 = { add_trait = norse_tattoo_5 }
			10 = { add_trait = norse_tattoo_6 } 
		}
	}
	if = { 
		limit = { 
			OR = { 
				religion = west_african_pagan
				religion = west_african_pagan_reformed
				religion = zun_pagan
				religion = zun_pagan_reformed
			}
			NOR = { 
				trait = african_tattoo_1
				trait = african_tattoo_2
				trait = african_tattoo_3
				trait = african_tattoo_4
				trait = african_tattoo_5
				trait = african_tattoo_6
				trait = african_tattoo_7
				trait = african_tattoo_8
				trait = african_tattoo_9
				trait = african_tattoo_10
				trait = african_tattoo_11
				trait = african_tattoo_12
				trait = slavic_tattoo_1
				trait = slavic_tattoo_2
				trait = slavic_tattoo_3
				trait = slavic_tattoo_4
				trait = slavic_tattoo_5
				trait = slavic_tattoo_6
				trait = norse_tattoo_1
				trait = norse_tattoo_2
				trait = norse_tattoo_3
				trait = norse_tattoo_4
				trait = norse_tattoo_5
				trait = norse_tattoo_6
			}
		}
		random_list = { 
			50 = { add_trait = african_tattoo_1 }
			40 = { add_trait = african_tattoo_2 }
			40 = { add_trait = african_tattoo_3 }
			30 = { add_trait = african_tattoo_4 }
			30 = { add_trait = african_tattoo_5 }
			20 = { add_trait = african_tattoo_6 }
			20 = { add_trait = african_tattoo_7 }
			10 = { add_trait = african_tattoo_8 } 
			6 = { add_trait = african_tattoo_9 } 
			4 = { add_trait = african_tattoo_10 } 
			2 = { add_trait = african_tattoo_11 } 
			1 = { add_trait = african_tattoo_12 } 
		}
	}
	if = { 
		limit = { 
			OR = { 
				religion = slavic_pagan
				religion = slavic_pagan_reformed
				religion = baltic_pagan
				religion = baltic_pagan_reformed
				religion = finnish_pagan
				religion = finnish_pagan_reformed
			}
			NOR = { 
				trait = african_tattoo_1
				trait = african_tattoo_2
				trait = african_tattoo_3
				trait = african_tattoo_4
				trait = african_tattoo_5
				trait = african_tattoo_6
				trait = african_tattoo_7
				trait = african_tattoo_8
				trait = african_tattoo_9
				trait = african_tattoo_10
				trait = african_tattoo_11
				trait = african_tattoo_12
				trait = slavic_tattoo_1
				trait = slavic_tattoo_2
				trait = slavic_tattoo_3
				trait = slavic_tattoo_4
				trait = slavic_tattoo_5
				trait = slavic_tattoo_6
				trait = norse_tattoo_1
				trait = norse_tattoo_2
				trait = norse_tattoo_3
				trait = norse_tattoo_4
				trait = norse_tattoo_5
				trait = norse_tattoo_6
			}
		}
		random_list = { 
			50 = { add_trait = slavic_tattoo_1 }
			50 = { add_trait = slavic_tattoo_2 }
			40 = { add_trait = slavic_tattoo_3 }
			30 = { add_trait = slavic_tattoo_4 }
			20 = { add_trait = slavic_tattoo_5 }
			10 = { add_trait = slavic_tattoo_6 } 
		}
	}
}

spawn_debutante_effect = {
	if = { 
		limit = { has_religion_feature = religion_matriarchal }
		create_character = {
			random_traits = yes
			dynasty = actually_culture
			culture = ROOT
			female = no
			age = 17
		}
	}
	if = { 
		limit = { NOT = { has_religion_feature = religion_matriarchal } }
		create_character = {
			random_traits = yes
			dynasty = actually_culture
			culture = ROOT
			female = yes
			age = 17
		}
	}
	new_character = {	
		emf_new_character_noble = yes
		set_character_flag = debutante
		save_event_target_as = invited_character
	}
}

# EMF:
# NOTE: this effect has been replaced by emf_transfer_crown_on_abdication and is used by emf_willfully_abdicate (which is also used by emf_abdicate)
transfer_crown_on_abdication_effect = {
	#if = {
	#	limit = { 
	#		has_landed_title = e_hre
	#		any_artifact = { artifact_type = crown_hre } 
	#	}
	#		current_heir = { save_event_target_as = crown_hre_heir }
	#		any_artifact = { 
	#			limit = { artifact_type = crown_hre }
	#			transfer_artifact = {
	#				from = PREV
	#				to = event_target:crown_hre_heir
	#			} 
	#		}
	#}
	#if = {
	#	limit = { 
	#		has_landed_title = e_byzantium
	#		any_artifact = { artifact_type = crown_byzantine }
	#	}
	#		current_heir = { save_event_target_as = crown_byzantine_heir }
	#		any_artifact = { 
	#			limit = { artifact_type = crown_byzantine }
	#			transfer_artifact = {
	#				from = PREV
	#				to = event_target:crown_byzantine_heir
	#			} 
	#		}
	#}
	#if = {
	#	limit = { 
	#		has_landed_title = e_persia
	#		any_artifact = { artifact_type = crown_pahlavi }
	#	}
	#		current_heir = { save_event_target_as = crown_pahlavi_heir }
	#		any_artifact = { 
	#			limit = { artifact_type = crown_pahlavi }
	#			transfer_artifact = {
	#				from = PREV
	#				to = event_target:crown_pahlavi_heir
	#			} 
	#		}
	#}
	#if = {
	#	limit = { 
	#		has_landed_title = d_norse_pagan_reformed
	#		any_artifact = { artifact_type = crown_fylkir }
	#	}
	#		current_heir = { save_event_target_as = crown_fylkir_heir }
	#		any_artifact = { 
	#			limit = { artifact_type = crown_fylkir }
	#			transfer_artifact = {
	#				from = PREV
	#				to = event_target:crown_fylkir_heir
	#			} 
	#		}
	#}
	#if = {
	#	limit = { 
	#		has_landed_title = d_tengri_pagan_reformed
	#		any_artifact = { artifact_type = crown_tengri_fylkir }
	#	}
	#		current_heir = { save_event_target_as = crown_tengri_fylkir_heir }
	#		any_artifact = { 
	#			limit = { artifact_type = crown_tengri_fylkir }
	#			transfer_artifact = {
	#				from = PREV
	#				to = event_target:crown_tengri_fylkir_heir
	#			} 
	#		}
	#}
	#if = {
	#	limit = { 
	#		has_landed_title = d_slavic_pagan_reformed
	#		any_artifact = { artifact_type = crown_slavic_fylkir }
	#	}
	#		current_heir = { save_event_target_as = crown_slavic_fylkir_heir }
	#		any_artifact = { 
	#			limit = { artifact_type = crown_slavic_fylkir }
	#			transfer_artifact = {
	#				from = PREV
	#				to = event_target:crown_slavic_fylkir_heir
	#			} 
	#		}
	#}
	#if = {
	#	limit = { 
	#		has_landed_title = d_baltic_pagan_reformed
	#		any_artifact = { artifact_type = crown_romuva_fylkir }
	#	}
	#		current_heir = { save_event_target_as = crown_romuva_fylkir_heir }
	#		any_artifact = { 
	#			limit = { artifact_type = crown_romuva_fylkir }
	#			transfer_artifact = {
	#				from = PREV
	#				to = event_target:crown_romuva_fylkir_heir
	#			} 
	#		}
	#}
	#if = {
	#	limit = { 
	#		has_landed_title = d_finnish_pagan_reformed
	#		any_artifact = { artifact_type = crown_finnish_fylkir }
	#	}
	#		current_heir = { save_event_target_as = crown_finnish_fylkir_heir }
	#		any_artifact = { 
	#			limit = { artifact_type = crown_finnish_fylkir }
	#			transfer_artifact = {
	#				from = PREV
	#				to = event_target:crown_finnish_fylkir_heir
	#			} 
	#		}
	#}
	#if = {
	#	limit = { 
	#		has_landed_title = d_west_african_pagan_reformed
	#		any_artifact = { artifact_type = crown_west_african_fylkir }
	#	}
	#		current_heir = { save_event_target_as = crown_west_african_fylkir_heir }
	#		any_artifact = { 
	#			limit = { artifact_type = crown_west_african_fylkir }
	#			transfer_artifact = {
	#				from = PREV
	#				to = event_target:crown_west_african_fylkir_heir
	#			} 
	#		}
	#}
	#if = {
	#	limit = { 
	#		has_landed_title = d_zun_pagan_reformed
	#		any_artifact = { artifact_type = crown_zun_fylkir }
	#	}
	#		current_heir = { save_event_target_as = crown_zun_fylkir_heir }
	#		any_artifact = { 
	#			limit = { artifact_type = crown_zun_fylkir }
	#			transfer_artifact = {
	#				from = PREV
	#				to = event_target:crown_zun_fylkir_heir
	#			} 
	#		}
	#}
	#if = {
	#	limit = { 
	#		has_landed_title = d_bon_reformed
	#		any_artifact = { artifact_type = scepter_bon_fylkir }
	#	}
	#		current_heir = { save_event_target_as = scepter_bon_fylkir_heir }
	#		any_artifact = { 
	#			limit = { artifact_type = scepter_bon_fylkir }
	#			transfer_artifact = {
	#				from = PREV
	#				to = event_target:scepter_bon_fylkir_heir
	#			} 
	#		}
	#}
	#if = {
	#	limit = { 
	#		has_landed_title = d_aztec_reformed
	#		any_artifact = { artifact_type = crown_aztec_fylkir }
	#	}
	#		current_heir = { save_event_target_as = crown_aztec_fylkir_heir }
	#		any_artifact = { 
	#			limit = { artifact_type = crown_aztec_fylkir }
	#			transfer_artifact = {
	#				from = PREV
	#				to = event_target:crown_aztec_fylkir_heir
	#			} 
	#		}
	#}
	#if = {
	#	limit = { 
	#		has_landed_title = k_hellenic_pagan
	#		any_artifact = { artifact_type = scepter_hellenic_fylkir }
	#	}
	#		current_heir = { save_event_target_as = scepter_hellenic_fylkir_heir }
	#		any_artifact = { 
	#			limit = { artifact_type = scepter_hellenic_fylkir }
	#			transfer_artifact = {
	#				from = PREV
	#				to = event_target:scepter_hellenic_fylkir_heir
	#			} 
	#		}
	#}
	##Now transfer all other remaining artifacts to the player_heir, who may or may not be the current_heir.
	#player_heir = { save_event_target_as = scoped_player_heir }
	#any_artifact = { 
	#	limit = { 
	#		NOR = {
	#			artifact_type = crown_hre
	#			artifact_type = crown_byzantine 
	#			artifact_type = crown_pahlavi
	#			artifact_type = crown_fylkir
	#			artifact_type = crown_tengri_fylkir
	#			artifact_type = crown_slavic_fylkir
	#			artifact_type = crown_romuva_fylkir
	#			artifact_type = crown_finnish_fylkir
	#			artifact_type = crown_west_african_fylkir
	#			artifact_type = crown_zun_fylkir
	#			artifact_type = scepter_bon_fylkir 
	#			artifact_type = crown_aztec_fylkir
	#			artifact_type = scepter_hellenic_fylkir 
	#		}
	#	}
	#	transfer_artifact = {
	#		from = PREV
	#		to = event_target:scoped_player_heir
	#	}
	#}
}

# Referenced by the "button_rename" button in the character view 
rename_character_effect = {
	prompt_name = {
		player = FROM
		type = RENAME_CHARACTER_MESSAGE
	}
}

move_childrens_crusade_region_effect = {
	if = { #If at any point during the preparation Jerusalem is no longer a valid target, or a real Crusade starts, stop everything.
		limit = {
			OR = {
				k_jerusalem = { has_holder = yes holder_scope = { religion_group = christian } }
				c_jerusalem = { holder_scope = { religion_group = christian } }
				c_jerusalem = { holder_scope = { is_crusade_target = yes } }
				religion_head = { is_preparing_crusade = yes }
				religion_head = { 
					OR = { 
						any_war = { using_cb = crusade }  
						any_war = { using_cb = new_crusade } 
					} 
				}
			}
		}
		any_player = { 
				limit = {
				religion_group = christian
				NOT = {
					character = ROOT
				}
			}
			narrative_event = { id = HF.25819 days = 30 } #Notify everyone that the crusade has flopped.
		}
		primary_title = {
			activate_title = { title = THIS status = no }
			emf_unsafe_destroy_title = yes
		}
		clr_character_flag = flag_childrens_crusade_leader
		add_trait = lunatic
		piety = -150
		remove_trait = disinherited 
		set_variable = { which = children_crusade_forces value = 0 }
		set_variable = { which = children_crusade_morale value = 0 }
		set_variable = { which = children_crusade_heavy_troops value = 0 }
		any_courtier = { 
			remove_trait = disinherited
			clr_character_flag = no_court_invites
		}
		break = yes
	}
	if = { #Move to Genoa first.
		limit = {
			has_character_flag = flag_children_at_beginning
		}
		primary_title = { set_preferred_capital = c_genoa } #Historically traveled here.
		change_variable = { which = children_crusade_forces value = 1 }
		change_variable = { which = children_crusade_morale value = -1 }
		clr_character_flag = flag_children_at_beginning
		set_character_flag = flag_children_at_genoa
		if = { 
			limit = {  
				NOT = { persistent_event_target:childrens_crusade_sponsor_per = { is_alive = yes } }
			}
			change_variable = { which = children_crusade_morale value = -2 }
		}
		any_player = { 
				limit = {
				religion_group = christian
				NOT = {
					character = ROOT
				}
			}
			narrative_event = { id = HF.25815 days = 30 } #Notify everyone that the crusade has reached Genoa and the sea did not part before them.
		}
		narrative_event = { id = HF.25808 days = 50 random = 100 } #Ping back to main event to check travel progress.
	}
	else_if = { #Then shipwreck to Achaia.
		limit = {
			has_character_flag = flag_children_at_genoa
		}
		primary_title = { set_preferred_capital = c_achaia } 
		change_variable = { which = children_crusade_morale value = -1 }
		clr_character_flag = flag_children_at_genoa
		set_character_flag = flag_children_at_achaia 
		any_player = { 
				limit = {
				religion_group = christian
				NOT = {
					character = ROOT
				}
			}
			narrative_event = { id = HF.25816 days = 30 } #Notify everyone that the crusade has shipwrecked into Achaia.
		}
		if = { 
			limit = {  
				NOT = { persistent_event_target:childrens_crusade_sponsor_per = { is_alive = yes } }
			}
			random = { 
				chance = 25  
				change_variable = { which = children_crusade_forces value = -1 }
			} 
		}
		narrative_event = { id = HF.25808 days = 50 random = 100 } #Ping back to main event to check travel progress.
	}
	else_if = { #Then crawl to Nikaea.
		limit = {
			has_character_flag = flag_children_at_achaia
		}
		primary_title = { set_preferred_capital = c_nikaea } 
		clr_character_flag = flag_children_at_achaia
		set_character_flag = flag_children_at_nikaea
		change_variable = { which = children_crusade_forces value = 1 } #Base forces score is 3 = circa 15.000 poorly armed troops.
		any_player = { 
				limit = {
				religion_group = christian
				NOT = {
					character = ROOT
				}
			}
			narrative_event = { id = HF.25817 days = 30 } #Notify everyone that the crusade has crawled its way to Nikaea.
		}
		narrative_event = { id = HF.25808 days = 50 random = 100 } #Ping back to main event to check travel progress.
	}
	else_if = { #We actually got there. Start the war.
		limit = {
			has_character_flag = flag_children_at_nikaea
		}
		primary_title = { set_preferred_capital = c_antiocheia } #Where the troops will spawn.
		clr_character_flag = flag_children_at_nikaea
		set_character_flag = flag_children_at_antioch
		narrative_event = { id = HF.25820 days = 25 } #START THE CRUSADE.
		any_player = { 
				limit = {
				religion_group = christian
				NOT = {
					character = ROOT
				}
			}
			narrative_event = { id = HF.25818 days = 30 } #Notify everyone that the crusade has actually reached Antioch and is ready to engage.
		}
	}
	else = { #Move directly to Antioch in case something went wrong.
		primary_title = { set_preferred_capital = c_antiocheia } #Historically traveled here.
		clr_character_flag = flag_children_at_achaia
		clr_character_flag = flag_children_at_nikaea
		clr_character_flag = flag_children_at_genoa
		set_character_flag = flag_children_at_antioch
		change_variable = { which = children_crusade_forces value = 1 }
		change_variable = { which = children_crusade_morale value = -1 }
		if = { 
			limit = {  
				NOT = { persistent_event_target:childrens_crusade_sponsor_per = { is_alive = yes } }
			}
			change_variable = { which = children_crusade_morale value = -2 }
		}
		narrative_event = { id = HF.25820 days = 25 } #START THE CRUSADE.
		any_player = { 
				limit = {
				religion_group = christian
				NOT = {
					character = ROOT
				}
			}
			narrative_event = { id = HF.25818 days = 30 } #Notify everyone that the crusade has actually reached Antioch and is ready to engage.
		}
	}
}

spawn_childrens_crusade_light_troops_effect = {
	change_variable = { which = children_crusade_forces value = -1 }
	location = {
		ROOT = {
			spawn_unit = {
				province = PREV
				home = PREV
				owner = ROOT
				attrition = 0.5
				reinforces = no
				is_looter = no
				can_toggle_looting = no
				cannot_inherit = yes
				merge = yes
				disband_on_peace = yes
				earmark = childrens_crusade_infantry_earmark
				troops = {
					light_infantry = { 3000 3000 }
					archers = { 100 100 }
				}
			}
		}
	}
	if = { 
		limit = { 
			check_variable = { which = children_crusade_forces value = 1 } #Keep looping until the variable reaches 0.
		} 
		character_event = { id = HF.25821 }
	}
}


spawn_childrens_crusade_heavy_troops_effect = {
	change_variable = { which = children_crusade_heavy_troops value = -1 }
	location = {
		ROOT = {
			spawn_unit = {
				province = PREV
				home = PREV
				owner = ROOT
				attrition = 0.5
				reinforces = no
				is_looter = no
				can_toggle_looting = no
				cannot_inherit = yes
				merge = yes
				troops = {
					heavy_infantry = { 500 500 }
					light_cavalry = { 150 150 }
				}
			}
		}
	}
	if = { 
		limit = { 
			check_variable = { which = children_crusade_heavy_troops value = 1 } #Keep looping until the variable reaches 0.
		} 
		character_event = { id = HF.25822 }
	}
}
warrior_lodge_pay_dice_debt_effect = {
	if = { 
		limit = { has_character_flag = flag_betting_money_1000 } 
		wealth = -1000
		if = { 
			limit = { event_target:random_society_winner = { is_alive = yes } } 
			event_target:random_society_winner = { wealth = 1000 }
		}
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_500 } 
		wealth = -500
		if = { 
			limit = { event_target:random_society_winner = { is_alive = yes } } 
			event_target:random_society_winner = { wealth = 500 }
		}
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_250 } 
		wealth = -250
		if = { 
			limit = { event_target:random_society_winner = { is_alive = yes } } 
			event_target:random_society_winner = { wealth = 250 }
		}
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_200 } 
		wealth = -200
		if = { 
			limit = { event_target:random_society_winner = { is_alive = yes } } 
			event_target:random_society_winner = { wealth = 200 }
		}
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_100 } 
		wealth = -100
		if = { 
			limit = { event_target:random_society_winner = { is_alive = yes } } 
			event_target:random_society_winner = { wealth = 100 }
		}
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_50 } 
		wealth = -50
		if = { 
			limit = { event_target:random_society_winner = { is_alive = yes } } 
			event_target:random_society_winner = { wealth = 50 }
		}
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_25 } 
		wealth = -25
		if = { 
			limit = { event_target:random_society_winner = { is_alive = yes } } 
			event_target:random_society_winner = { wealth = 25 }
		}
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_20 } 
		wealth = -20
		if = { 
			limit = { event_target:random_society_winner = { is_alive = yes } } 
			event_target:random_society_winner = { wealth = 20 }
		}
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_10 } 
		wealth = -10
		if = { 
			limit = { event_target:random_society_winner = { is_alive = yes } } 
			event_target:random_society_winner = { wealth = 10 }
		}
	}
}

warrior_lodge_get_dice_bet_effect = {
	if = { 
		limit = { has_character_flag = flag_betting_money_1000 } 
		wealth = 1000
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_500 } 
		wealth = 500
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_250 } 
		wealth = 250
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_200 } 
		wealth = 200
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_100 } 
		wealth = 100
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_50 } 
		wealth = 50
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_25 } 
		wealth = 25
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_20 } 
		wealth = 20
	}
	if = { 
		limit = { has_character_flag = flag_betting_money_10 } 
		wealth = 10
	}
}

warrior_lodge_double_dice_bet_effect = {
	if = { 
		limit = { has_character_flag = flag_betting_money_500 } 
		clr_character_flag = flag_betting_money_500
		set_character_flag = flag_betting_money_1000
		custom_tooltip = { text = tooltip_betting_1000_gold } 
	}
	else_if = { 
		limit = { has_character_flag = flag_betting_money_250 } 
		clr_character_flag = flag_betting_money_250
		set_character_flag = flag_betting_money_500
		custom_tooltip = { text = tooltip_betting_500_gold }
	}
	else_if = { 
		limit = { has_character_flag = flag_betting_money_100 } 
		clr_character_flag = flag_betting_money_100
		set_character_flag = flag_betting_money_200
		custom_tooltip = { text = tooltip_betting_200_gold }
	}
	else_if = { 
		limit = { has_character_flag = flag_betting_money_50 } 
		clr_character_flag = flag_betting_money_50
		set_character_flag = flag_betting_money_100
		custom_tooltip = { text = tooltip_betting_100_gold }
	}
	else_if = { 
		limit = { has_character_flag = flag_betting_money_25 } 
		clr_character_flag = flag_betting_money_25
		set_character_flag = flag_betting_money_50
		custom_tooltip = { text = tooltip_betting_50_gold }
	}
	else_if = { 
		limit = { has_character_flag = flag_betting_money_10 } 
		clr_character_flag = flag_betting_money_10
		set_character_flag = flag_betting_money_20
		custom_tooltip = { text = tooltip_betting_20_gold }
	}
}
warrior_lodge_dice_game_cleanup_effect = {
	clr_character_flag = flag_betting_money_1000
	clr_character_flag = flag_betting_money_500
	clr_character_flag = flag_betting_money_250
	clr_character_flag = flag_betting_money_200
	clr_character_flag = flag_betting_money_100
	clr_character_flag = flag_betting_money_50
	clr_character_flag = flag_betting_money_25
	clr_character_flag = flag_betting_money_20
	clr_character_flag = flag_betting_money_10
	clr_character_flag = flag_betting_on_krita
	clr_character_flag = flag_betting_on_treta
	clr_character_flag = flag_betting_on_dwapara
	clr_character_flag = flag_betting_on_kali
	clr_character_flag = flag_warrior_lodge_die_is_krita
	clr_character_flag = flag_warrior_lodge_die_is_treta
	clr_character_flag = flag_warrior_lodge_die_is_dwapara
	clr_character_flag = flag_warrior_lodge_die_is_kali
}

this_is_becoming_grand_mistress_effect = { 
	custom_tooltip = { 
		text = tooltip_becoming_grand_mistress 
		hidden_tooltip = { change_variable = { which = becoming_grand_mistress value = 2 } }
	} 
}
this_is_becoming_iron_matron_effect = {
	custom_tooltip = { 
		text = tooltip_becoming_iron_matron 
		hidden_tooltip = { change_variable = { which = becoming_iron_matron value = 2 } }
	} 
}
this_is_becoming_virago_effect = {
	custom_tooltip = { 
		text = tooltip_becoming_virago 
		hidden_tooltip = { change_variable = { which = becoming_virago value = 2 } }
	}  
}

this_is_becoming_atoner_effect = {
	custom_tooltip = { 
		text = tooltip_becoming_atoner
		hidden_tooltip = { change_variable = { which = becoming_atoner value = 2 } }
	}  
}
this_is_becoming_manservant_effect = {
	custom_tooltip = { 
		text = tooltip_becoming_manservant 
		hidden_tooltip = { change_variable = { which = becoming_manservant value = 2 } }
	}  
}
this_is_becoming_stud_effect = {
	custom_tooltip = { 
		text = tooltip_becoming_stud
		hidden_tooltip = { change_variable = { which = becoming_stud value = 2 } }
	}  
}

this_is_becoming_grand_paramour_effect = {
	custom_tooltip = { 
		text = tooltip_becoming_grand_paramour 
		hidden_tooltip = { change_variable = { which = becoming_grand_paramour value = 2 } }
	} 
}
this_is_becoming_judicator_effect = {
	custom_tooltip = { 
		text = tooltip_becoming_judicator 
		hidden_tooltip = { change_variable = { which = becoming_judicator value = 2 } }
	} 
}
this_is_becoming_subjugator_effect = {
	custom_tooltip = { 
		text = tooltip_becoming_subjugator 
		hidden_tooltip = { change_variable = { which = becoming_subjugator value = 2 } }
	} 
}

this_is_becoming_prim_effect = {
	custom_tooltip = { 
		text = tooltip_becoming_prim
		hidden_tooltip = { change_variable = { which = becoming_prim value = 2 } }
	} 
}
this_is_becoming_doll_effect = {
	custom_tooltip = { 
		text = tooltip_becoming_doll
		hidden_tooltip = { change_variable = { which = becoming_doll value = 2 } }
	} 
}
this_is_becoming_breeder_effect = {
	custom_tooltip = { 
		text = tooltip_becoming_breeder
		hidden_tooltip = { change_variable = { which = becoming_breeder value = 2 } }
	} 
}
add_lots_thralls_capital_effect = { #MUST be used in a province scope.
	if = {
		limit = { 
			NOR = {
				has_province_modifier = capital_thrall_workers_01
				has_province_modifier = capital_thrall_workers_02
				has_province_modifier = capital_thrall_workers_03
				has_province_modifier = capital_thrall_workers_04
				has_province_modifier = capital_thrall_workers_05
				has_province_modifier = capital_thrall_workers_06
			}
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_03 years = 5 }
	}
	else_if = {
		limit = { 
			has_province_modifier = capital_thrall_workers_01
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_04 years = 5 }
	}
	else_if = {
		limit = { 
			has_province_modifier = capital_thrall_workers_02
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_05 years = 5 }
	}
	else_if = {
		limit = { 
			OR = { 
				has_province_modifier = capital_thrall_workers_03
				has_province_modifier = capital_thrall_workers_04
				has_province_modifier = capital_thrall_workers_05
				has_province_modifier = capital_thrall_workers_06
			}
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_06 years = 5 }
	}
}

add_some_thralls_capital_effect = { #MUST be used in a province scope.
	if = {
		limit = { 
			NOR = {
				has_province_modifier = capital_thrall_workers_01
				has_province_modifier = capital_thrall_workers_02
				has_province_modifier = capital_thrall_workers_03
				has_province_modifier = capital_thrall_workers_04
				has_province_modifier = capital_thrall_workers_05
				has_province_modifier = capital_thrall_workers_06
			}
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_02 years = 5 }
	}
	else_if = {
		limit = { 
			has_province_modifier = capital_thrall_workers_01
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_03 years = 5 }
	}
	else_if = {
		limit = { 
			has_province_modifier = capital_thrall_workers_02
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_04 years = 5 }
	}
	else_if = {
		limit = { 
			has_province_modifier = capital_thrall_workers_03
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_05 years = 5 }
	}
	else_if = {
		limit = { 
			OR = { 
				has_province_modifier = capital_thrall_workers_04
				has_province_modifier = capital_thrall_workers_05
				has_province_modifier = capital_thrall_workers_06
			}
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_06 years = 5 }
	}
}

add_few_thralls_capital_effect = { #MUST be used in a province scope.
	if = {
		limit = { 
			NOR = {
				has_province_modifier = capital_thrall_workers_01
				has_province_modifier = capital_thrall_workers_02
				has_province_modifier = capital_thrall_workers_03
				has_province_modifier = capital_thrall_workers_04
				has_province_modifier = capital_thrall_workers_05
				has_province_modifier = capital_thrall_workers_06
			}
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_01 years = 5 }
	}
	else_if = {
		limit = { 
			has_province_modifier = capital_thrall_workers_01
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_02 years = 5 }
	}
	else_if = {
		limit = { 
			has_province_modifier = capital_thrall_workers_02
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_03 years = 5 }
	}
	else_if = {
		limit = { 
			has_province_modifier = capital_thrall_workers_03
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_04 years = 5 }
	}
	else_if = {
		limit = { 
			has_province_modifier = capital_thrall_workers_04
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_05 years = 5 }
	}
	else_if = {
		limit = { 
			has_province_modifier = capital_thrall_workers_05
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_06 years = 5 }
	}
	else_if = {
		limit = { 
			has_province_modifier = capital_thrall_workers_06
		}
		hidden_tooltip = {
			remove_province_modifier = capital_thrall_workers_01
			remove_province_modifier = capital_thrall_workers_02
			remove_province_modifier = capital_thrall_workers_03
			remove_province_modifier = capital_thrall_workers_04
			remove_province_modifier = capital_thrall_workers_05
			remove_province_modifier = capital_thrall_workers_06
		}
		add_province_modifier = { modifier = capital_thrall_workers_06 years = 5 }
	}
}


WL_ritual_hunt_cleanup_effect = {
	clr_character_flag = do_not_disturb
	hidden_tooltip = { set_variable = { which = wl_ritual_hunting value = 0 } }

	clr_character_flag = flag_hunting_wolf_norse
	clr_character_flag = flag_hunting_wolf_baltic
	clr_character_flag = flag_hunting_wolf_hellenic

	clr_character_flag = flag_hunting_eagle_slavic
	clr_character_flag = flag_hunting_eagle_tengri
	clr_character_flag = flag_hunting_eagle_bon

	clr_character_flag = flag_hunting_bear_finnish

	clr_character_flag = flag_hunting_lion_west_african
	clr_character_flag = flag_hunting_lion_zun
}

WL_ritual_hunt_flavor_events_effect = {
	hidden_tooltip = { 
		#Flavor events: (increasing/decreasing hunt variable)
		## Character is about to fall/drown/random. (might result in Friendship/Rivalry/Love)
		## Co-hunter is about to fall/drown/random. (might result in Friendship/Rivalry/Love)
		## Characters looking for tracks. (intrigue) - paranoid
		## Characters need to examine carcass killed by target. (martial) - cruel
		## Characters reflect upon their target. (learning) - scholar
		## Characters find hermit, ask info on target. (diplomacy) - charitable
		## Characters need to interpret old map and pathways. (stewardship) - administrator

		## Characters see a bad omen. (low piety triggers) - theologian
		## Characters see a good omen. (high piety triggers) - theologian

		## Lunatic/Possessed character goes on a Wild Hunt and kills partner.

		random_list = { 
			15 = { #Character is in trouble.
				trigger = { event_target:scoped_WL_co_hunter = { is_alive = yes } }
				modifier = { 
					factor = 1.5
					trait = craven
				}
				modifier = { 
					factor = 1.5
					trait = dull
				}
				modifier = { 
					factor = 1.5
					trait = slow
				}
				modifier = { 
					factor = 1.5
					trait = imbecile
				}
				modifier = { 
					factor = 1.5
					trait = inbred
				}
				modifier = { 
					factor = 1.5
					trait = slothful
				}
				character_event = { id = HF.25603 days = 10 random = 5 }
			}
			15 = { #Co-hunter is in trouble.
				trigger = { event_target:scoped_WL_co_hunter = { is_alive = yes } }
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { trait = craven }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { trait = dull }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { trait = slow }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { trait = imbecile }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { trait = inbred }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { trait = slothful }
				}
				character_event = { id = HF.25606 days = 10 random = 5 }
			}
			25 = { #Characters looking for tracks.
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { intrigue = 10 }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { intrigue = 14 }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { intrigue = 18 }
				}
				character_event = { id = HF.25608 days = 10 random = 5 }
			}
			25 = { #Characters need to examine carcass.
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { martial = 10 }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { martial = 14 }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { martial = 18 }
				}
				character_event = { id = HF.25609 days = 10 random = 5 }

			}
			25 = { #Characters reflect upon target.
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { learning = 10 }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { learning = 14 }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { learning = 18 }
				}
				character_event = { id = HF.25610 days = 10 random = 5 }

			}
			25 = { #Characters persuade hermit for directions.
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { diplomacy = 10 }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { diplomacy = 14 }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { diplomacy = 18 }
				}
				character_event = { id = HF.25611 days = 10 random = 5 }

			}
			25 = { #Characters need to interpret old map.
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { stewardship = 10 }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { stewardship = 14 }
				}
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { stewardship = 18 }
				}
				modifier = { 
					factor = 1.5
					has_character_flag = flag_picked_ritual_co_hunter_smart
				}
				character_event = { id = HF.25612 days = 10 random = 5 }

			}
			25 = { #Characters see bad omen.
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { learning = 10 }
				}
				modifier = { 
					factor = 1.5
					NOT = { piety = 50 }
				}
				modifier = { 
					factor = 1.5
					NOT = { piety = 100 }
				}
				modifier = { 
					factor = 1.5
					NOT = { piety = 150 }
				}
				character_event = { id = HF.25613 days = 10 random = 5 }
			}
			5 = { #Characters see good omen.
				modifier = { 
					factor = 1.5
					event_target:scoped_WL_co_hunter = { learning = 10 }
				}
				modifier = { 
					factor = 1.5
					piety = 250
				}
				modifier = { 
					factor = 1.5
					piety = 350
				}
				modifier = { 
					factor = 1.5
					piety = 450
				}
				modifier = { 
					factor = 1.5
					piety = 550
				}
				character_event = { id = HF.25614 days = 10 random = 5 }

			}

			100 = {  #Lunatic/Possessed ruler starts a Wild Hunt.
				trigger = { 
					OR = { 
						trait = possessed
						trait = lunatic
						AND = { 
							has_character_modifier = lycanthropy 
							OR = { 
								has_character_flag = flag_hunting_wolf_norse
								has_character_flag = flag_hunting_wolf_baltic
								has_character_flag = flag_hunting_wolf_hellenic
							} 
						}
					} 
					event_target:scoped_WL_co_hunter = { is_alive = yes }
				}
				character_event = { id = HF.25615 days = 10 random = 5 }
			}
		} 
	}
}

stable_attribute_improvement_effect = {
	hidden_tooltip = { #Chance of Education trait improvement or burnout case.
		if = { 
			limit = {
				event_target:scoped_improvement_target = { 
					has_character_flag = flag_training_diplomacy_attribute 
				} 
			}
			event_target:scoped_improvement_target = { 
				random_list = { 
					20 = { #Education improvement.
						trigger = { #Education Improvement only unlocked by synergy.
							OR = { 
								has_religion_feature = religion_meritocratic
								has_religion_feature = religion_matriarchal
								has_religion_feature = religion_patriarchal
							}
							OR = { 
								trait = naive_appeaser
								trait = underhanded_rogue
								trait = charismatic_negotiator
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = diplomacy character = event_target:scoped_improvement_target value = 3 } 
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = diplomacy character = event_target:scoped_improvement_target value = 6 } 
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = diplomacy character = event_target:scoped_improvement_target value = 9 } 
							}
						}
						character_event = { id = HF.23761 days = 15 random = 15 } 
					}
					20 = { #Burnout
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 1 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 2 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 3 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 4 }
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 5 }
							}
						}
						modifier = { 
							factor = 2
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 8 }
							}
						}
						modifier = { 
							factor = 2
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 12 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = slothful
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = stressed
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								trait = depressed
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								is_ill = yes
							}
						}
						modifier = { 
							factor = 0.75
							event_target:scoped_improvement_ruler = { 
								trait = diligent
							}
						}
						character_event = { id = HF.23762 days = 15 random = 15 } 
					}
					80 = { #Nothing.
					}
				}
			}
		}
		if = { 
			limit = {
				event_target:scoped_improvement_target = { 
					OR = { 
						has_character_flag = flag_training_martial_attribute 
						has_character_flag = flag_training_combat_rating
					}
				} 
			}
			event_target:scoped_improvement_target = { 
				random_list = { 
					20 = { #Education improvement.
						trigger = { #Education Improvement only unlocked by synergy.
							OR = { 
								has_religion_feature = religion_meritocratic
								has_religion_feature = religion_matriarchal
								has_religion_feature = religion_patriarchal
							}
							OR = { 
								trait = misguided_warrior
								trait = tough_soldier
								trait = skilled_tactician
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = martial character = event_target:scoped_improvement_target value = 3 } 
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = martial character = event_target:scoped_improvement_target value = 6 } 
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = martial character = event_target:scoped_improvement_target value = 9 } 
							}
						}
						character_event = { id = HF.23761 days = 15 random = 15 } 
					}
					20 = { #Burnout
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 1 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 2 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 3 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 4 }
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 5 }
							}
						}
						modifier = { 
							factor = 2
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 8 }
							}
						}
						modifier = { 
							factor = 2
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 12 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = slothful
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = stressed
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								trait = depressed
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								is_ill = yes
							}
						}
						modifier = { 
							factor = 0.75
							event_target:scoped_improvement_ruler = { 
								trait = diligent
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								age = 30
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								age = 35
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								age = 40
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								age = 45
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								age = 50
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								trait = slow
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = imbecile
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = inbred
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								trait = dull
							}
						}
						modifier = { 
							factor = 0.85
							event_target:scoped_improvement_ruler = { 
								trait = shrewd
							}
						}
						modifier = { 
							factor = 0.85
							event_target:scoped_improvement_ruler = { 
								trait = quick
							}
						}
						modifier = { 
							factor = 0.75
							event_target:scoped_improvement_ruler = { 
								trait = genius
							}
						}
						character_event = { id = HF.23762 days = 15 random = 15 } 
					}
					80 = { #Nothing.
					}
				}
			}
		}
		if = { 
			limit = {
				event_target:scoped_improvement_target = { 
					has_character_flag = flag_training_stewardship_attribute 
				} 
			}
			event_target:scoped_improvement_target = { 
				random_list = { 
					20 = { #Education improvement.
						trigger = { #Education Improvement only unlocked by synergy.
							OR = { 
								has_religion_feature = religion_meritocratic
								has_religion_feature = religion_matriarchal
								has_religion_feature = religion_patriarchal
							}
							OR = { 
								trait = indulgent_wastrel
								trait = thrifty_clerk
								trait = fortune_builder
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = stewardship character = event_target:scoped_improvement_target value = 3 } 
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = stewardship character = event_target:scoped_improvement_target value = 6 } 
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = stewardship character = event_target:scoped_improvement_target value = 9 } 
							}
						}
						character_event = { id = HF.23761 days = 15 random = 15 } 
					}
					20 = { #Burnout
						trigger = { 
							event_target:scoped_improvement_ruler = { #Never first time.
								check_variable = { which = burnout_count value = 1 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 2 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 3 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 4 }
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 5 }
							}
						}
						modifier = { 
							factor = 2
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 8 }
							}
						}
						modifier = { 
							factor = 2
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 12 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = slothful
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = stressed
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								trait = depressed
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								is_ill = yes
							}
						}
						modifier = { 
							factor = 0.75
							event_target:scoped_improvement_ruler = { 
								trait = diligent
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								age = 30
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								age = 35
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								age = 40
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								age = 45
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								age = 50
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								trait = slow
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = imbecile
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = inbred
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								trait = dull
							}
						}
						modifier = { 
							factor = 0.85
							event_target:scoped_improvement_ruler = { 
								trait = shrewd
							}
						}
						modifier = { 
							factor = 0.85
							event_target:scoped_improvement_ruler = { 
								trait = quick
							}
						}
						modifier = { 
							factor = 0.75
							event_target:scoped_improvement_ruler = { 
								trait = genius
							}
						}
						character_event = { id = HF.23762 days = 15 random = 15 } 
					}
					80 = { #Nothing.
					}
				}
			}
		}
		if = { 
			limit = {
				event_target:scoped_improvement_target = { 
					has_character_flag = flag_training_intrigue_attribute 
				} 
			}
			event_target:scoped_improvement_target = { 
				random_list = { 
					20 = { #Education improvement.
						trigger = { #Education Improvement only unlocked by synergy.
							OR = { 
								has_religion_feature = religion_meritocratic
								has_religion_feature = religion_matriarchal
								has_religion_feature = religion_patriarchal
							}
							OR = { 
								trait = amateurish_plotter
								trait = flamboyant_schemer
								trait = intricate_webweaver
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = intrigue character = event_target:scoped_improvement_target value = 3 } 
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = intrigue character = event_target:scoped_improvement_target value = 6 } 
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = intrigue character = event_target:scoped_improvement_target value = 9 } 
							}
						}
						character_event = { id = HF.23761 days = 15 random = 15 } 
					}
					20 = { #Burnout
						trigger = { 
							event_target:scoped_improvement_ruler = { #Never first time.
								check_variable = { which = burnout_count value = 1 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 2 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 3 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 4 }
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 5 }
							}
						}
						modifier = { 
							factor = 2
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 8 }
							}
						}
						modifier = { 
							factor = 2
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 12 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = slothful
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = stressed
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								trait = depressed
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								is_ill = yes
							}
						}
						modifier = { 
							factor = 0.75
							event_target:scoped_improvement_ruler = { 
								trait = diligent
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								age = 30
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								age = 35
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								age = 40
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								age = 45
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								age = 50
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								trait = slow
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = imbecile
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = inbred
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								trait = dull
							}
						}
						modifier = { 
							factor = 0.85
							event_target:scoped_improvement_ruler = { 
								trait = shrewd
							}
						}
						modifier = { 
							factor = 0.85
							event_target:scoped_improvement_ruler = { 
								trait = quick
							}
						}
						modifier = { 
							factor = 0.75
							event_target:scoped_improvement_ruler = { 
								trait = genius
							}
						}
						character_event = { id = HF.23762 days = 15 random = 15 } 
					}
					80 = { #Nothing.
					}
				}
			}
		}
		if = { 
			limit = {
				event_target:scoped_improvement_target = { 
					has_character_flag = flag_training_learning_attribute 
				} 
			}
			event_target:scoped_improvement_target = { 
				random_list = { 
					20 = { #Education improvement.
						trigger = { #Education Improvement only unlocked by synergy.
							OR = { 
								has_religion_feature = religion_meritocratic
								has_religion_feature = religion_matriarchal
								has_religion_feature = religion_patriarchal
							}
							OR = { 
								trait = detached_priest
								trait = martial_cleric
								trait = scholarly_theologian
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								has_religion_feature = religion_meritocratic #More pressure.
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = learning character = event_target:scoped_improvement_target value = 3 } 
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = learning character = event_target:scoped_improvement_target value = 6 } 
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								NOT = { character = event_target:scoped_improvement_target }
								attribute_diff = { attribute = learning character = event_target:scoped_improvement_target value = 9 } 
							}
						}
						character_event = { id = HF.23761 days = 15 random = 15 } 
					}
					20 = { #Burnout
						trigger = { 
							event_target:scoped_improvement_ruler = { #Never first time.
								check_variable = { which = burnout_count value = 1 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 2 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 3 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 4 }
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 5 }
							}
						}
						modifier = { 
							factor = 2
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 8 }
							}
						}
						modifier = { 
							factor = 2
							event_target:scoped_improvement_ruler = { 
								check_variable = { which = burnout_count value = 12 }
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = slothful
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = stressed
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								trait = depressed
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								is_ill = yes
							}
						}
						modifier = { 
							factor = 0.75
							event_target:scoped_improvement_ruler = { 
								trait = diligent
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								age = 30
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								age = 35
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								age = 40
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								age = 45
							}
						}
						modifier = { 
							factor = 1.75
							event_target:scoped_improvement_ruler = { 
								age = 50
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								trait = slow
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = imbecile
							}
						}
						modifier = { 
							factor = 1.5
							event_target:scoped_improvement_ruler = { 
								trait = inbred
							}
						}
						modifier = { 
							factor = 1.25
							event_target:scoped_improvement_ruler = { 
								trait = dull
							}
						}
						modifier = { 
							factor = 0.85
							event_target:scoped_improvement_ruler = { 
								trait = shrewd
							}
						}
						modifier = { 
							factor = 0.85
							event_target:scoped_improvement_ruler = { 
								trait = quick
							}
						}
						modifier = { 
							factor = 0.75
							event_target:scoped_improvement_ruler = { 
								trait = genius
							}
						}
						character_event = { id = HF.23762 days = 15 random = 15 } 
					}
					80 = { #Nothing.
					}
				}
			}
		}
	}
}

add_sympathy_for_religion_effect = {
	if = {
		limit = {
			religion_group = christian
		}
		ROOT = {
			add_trait = sympathy_christendom
		}
	}
	else_if = {
		limit = {
			religion_group = indian_group
		}
		ROOT = {
			add_trait = sympathy_indian
		}
	}
	else_if = {
		limit = {
			religion_group = muslim
		}
		ROOT = {
			add_trait = sympathy_islam
		}
	}
	else_if = {
		limit = {
			religion_group = jewish_group
		}
		ROOT = {
			add_trait = sympathy_judaism
		}
	}
	else_if = {
		limit = {
			religion_group = pagan_group
		}
		ROOT = {
			add_trait = sympathy_pagans
		}
	}
	else_if = {
		limit = {
			religion_group = zoroastrian_group
		}
		ROOT = {
			add_trait = sympathy_zoroastrianism
		}
	}
}

add_random_commander_trait_effect = {
	random_list = {
		1 = {
			trigger = {
				NOT = {
					trait = aggressive_leader
				}
			}
			add_trait = aggressive_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = narrow_flank_leader
				}
			}
			add_trait = narrow_flank_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = cavalry_leader
				}
			}
			add_trait = cavalry_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = defensive_leader
				}
			}
			add_trait = defensive_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = desert_terrain_leader
				}
			}
			add_trait = desert_terrain_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = experimenter
				}
			}
			add_trait = experimenter
		}
		1 = {
			trigger = {
				NOT = {
					trait = flanker
				}
			}
			add_trait = flanker
		}
		1 = {
			trigger = {
				NOT = {
					trait = flat_terrain_leader
				}
			}
			add_trait = flat_terrain_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = heavy_infantry_leader
				}
			}
			add_trait = heavy_infantry_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = holy_warrior
				}
			}
			add_trait = holy_warrior
		}
		1 = {
			trigger = {
				NOT = {
					trait = inspiring_leader
				}
			}
			add_trait = inspiring_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = jungle_terrain_leader
				}
			}
			add_trait = jungle_terrain_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = light_foot_leader
				}
			}
			add_trait = light_foot_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = mountain_terrain_leader
				}
			}
			add_trait = mountain_terrain_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = organizer
				}
			}
			add_trait = organizer
		}
		1 = {
			trigger = {
				NOT = {
					trait = rough_terrain_leader
				}
			}
			add_trait = rough_terrain_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = siege_leader
				}
			}
			add_trait = siege_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = trickster
				}
			}
			add_trait = trickster
		}
		1 = {
			trigger = {
				NOT = {
					trait = unyielding_leader
				}
			}
			add_trait = unyielding_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = war_elephant_leader
				}
				location = {
					region = world_india
				}
			}
			add_trait = war_elephant_leader
		}
		1 = {
			trigger = {
				NOT = {
					trait = winter_soldier
				}
			}
			add_trait = winter_soldier
		}
		1 = {
			trigger = {
				NOT = {
					trait = logistics_expert
				}
				culture_group = chinese_group
			}
			add_trait = logistics_expert
		}
		1 = {
			trigger = {
				NOT = {
					trait = master_of_flame
				}
				culture_group = chinese_group
			}
			add_trait = master_of_flame
		}
		1 = {
			trigger = {
				NOT = {
					trait = sapper
				}
				culture_group = chinese_group
			}
			add_trait = sapper
		}
		1 = {
			trigger = {
				NOT = {
					trait = levy_coordinator
				}
				culture_group = chinese_group
			}
			add_trait = levy_coordinator
		}
	}
}

add_same_commander_trait_as_FROM = {
	#	random_list = {
		if = {
			limit = {
				NOT = {
					trait = aggressive_leader
				}
				FROM = { trait = aggressive_leader }
			}
			add_trait = aggressive_leader
		}
		if = {
			limit = {
				NOT = {
					trait = narrow_flank_leader
				}
				FROM = { trait = narrow_flank_leader }
			}
			add_trait = narrow_flank_leader
		}
		if = {
			limit = {
				NOT = {
					trait = cavalry_leader
				}
				FROM = { trait = cavalry_leader }
			}
			add_trait = cavalry_leader
		}
		if = {
			limit = {
				NOT = {
					trait = defensive_leader
				}
				FROM = { trait = defensive_leader }
			}
			add_trait = defensive_leader
		}
		if = {
			limit = {
				NOT = {
					trait = desert_terrain_leader
				}
				FROM = { trait = desert_terrain_leader }
			}
			add_trait = desert_terrain_leader
		}
		if = {
			limit = {
				NOT = {
					trait = experimenter
				}
				FROM = { trait = experimenter }
			}
			add_trait = experimenter
		}
		if = {
			limit = {
				NOT = {
					trait = flanker
				}
				FROM = { trait = flanker }
			}
			add_trait = flanker
		}
		if = {
			limit = {
				NOT = {
					trait = flat_terrain_leader
				}
				FROM = { trait = flat_terrain_leader }
			}
			add_trait = flat_terrain_leader
		}
		if = {
			limit = {
				NOT = {
					trait = heavy_infantry_leader
				}
				FROM = { trait = heavy_infantry_leader }
			}
			add_trait = heavy_infantry_leader
		}
		if = {
			limit = {
				NOT = {
					trait = holy_warrior
				}
				FROM = { trait = holy_warrior }
			}
			add_trait = holy_warrior
		}
		if = {
			limit = {
				NOT = {
					trait = inspiring_leader
				}
				FROM = { trait = inspiring_leader }
			}
			add_trait = inspiring_leader
		}
		if = {
			limit = {
				NOT = {
					trait = jungle_terrain_leader
				}
				FROM = { trait = jungle_terrain_leader }
			}
			add_trait = jungle_terrain_leader
		}
		if = {
			limit = {
				NOT = {
					trait = light_foot_leader
				}
				FROM = { trait = light_foot_leader }
			}
			add_trait = light_foot_leader
		}
		if = {
			limit = {
				NOT = {
					trait = mountain_terrain_leader
				}
				FROM = { trait = mountain_terrain_leader }
			}
			add_trait = mountain_terrain_leader
		}
		if = {
			limit = {
				NOT = {
					trait = organizer
				}
				FROM = { trait = organizer }
			}
			add_trait = organizer
		}
		if = {
			limit = {
				NOT = {
					trait = rough_terrain_leader
				}
				FROM = { trait = rough_terrain_leader }
			}
			add_trait = rough_terrain_leader
		}
		if = {
			limit = {
				NOT = {
					trait = siege_leader
				}
				FROM = { trait = siege_leader }
			}
			add_trait = siege_leader
		}
		if = {
			limit = {
				NOT = {
					trait = trickster
				}
				FROM = { trait = trickster }
			}
			add_trait = trickster
		}
		if = {
			limit = {
				NOT = {
					trait = unyielding_leader
				}
				FROM = { trait = unyielding_leader }
			}
			add_trait = unyielding_leader
		}
		if = {
			limit = {
				NOT = {
					trait = war_elephant_leader
				}
				FROM = { trait = war_elephant_leader }
				location = {
					region = world_india
				}
			}
			add_trait = war_elephant_leader
		}
		if = {
			limit = {
				NOT = {
					trait = winter_soldier
				}
				FROM = { trait = winter_soldier }
			}
			add_trait = winter_soldier
		}
		if = {
			limit = {
				NOT = {
					trait = logistics_expert
				}
				culture_group = chinese_group
				FROM = { trait = logistics_expert }
			}
			add_trait = logistics_expert
		}
		if = {
			limit = {
				NOT = {
					trait = master_of_flame
				}
				culture_group = chinese_group
				FROM = { trait = master_of_flame }
			}
			add_trait = master_of_flame
		}
		if = {
			limit = {
				NOT = {
					trait = sapper
				}
				culture_group = chinese_group
				FROM = { trait = sapper }
			}
			add_trait = sapper
		}
		if = {
			limit = {
				NOT = {
					trait = levy_coordinator
				}
				culture_group = chinese_group
				FROM = { trait = levy_coordinator }
			}
			add_trait = levy_coordinator
		}
		#10 = {
		#	add_trait_wounded_effect = yes
		#}
#	}
}

landless_pope_effect = {
	if = {
		limit = {
			has_landed_title = k_papal_state
			NOT = { catholic = { is_name_randomized = yes } }
		}
		if = {
			limit = { NOT = { any_realm_title = { tier = COUNT } } }
			#character_event = { id = HFP.40034 }
			character_event = { id = HFP.40035 } # Clean up Papal Guards 
		}
	}
}

# Used for rains in African regions...
remove_rain_modifiers_effect = {
	remove_province_modifier = africa_heavy_rain
    remove_province_modifier = africa_light_rain
    remove_province_modifier = africa_drought_risk
    remove_province_modifier = africa_drought
}

set_weather_change_cooldown_effect = {
	add_province_modifier = {
		name = africa_weather_updated
		duration = 300 # Just for safety
		hidden = yes
	}
}

set_rain_flag_heavy_effect = {
	if = {
		limit = { NOT = { has_province_flag = africa_heavy_rain_flag } } #So it's not overwritten and can be checked for time...
		set_province_flag = africa_heavy_rain_flag
		clr_province_flag = africa_light_rain_flag
		clr_province_flag = africa_drought_risk_flag
		clr_province_flag = africa_drought_flag
	}
}
set_rain_flag_light_effect = {
	if = {
		limit = { NOT = { has_province_flag = africa_light_rain_flag } } #So it's not overwritten and can be checked for time...
		clr_province_flag = africa_heavy_rain_flag
		set_province_flag = africa_light_rain_flag
		clr_province_flag = africa_drought_risk_flag
		clr_province_flag = africa_drought_flag
	}
}
set_rain_flag_drought_risk_effect = {
	if = {
		limit = { NOT = { has_province_flag = africa_drought_risk_flag } } #So it's not overwritten and can be checked for time...
		clr_province_flag = africa_heavy_rain_flag
		clr_province_flag = africa_light_rain_flag
		set_province_flag = africa_drought_risk_flag
		clr_province_flag = africa_drought_flag
	}
}
set_rain_flag_drought_effect = {
	if = {
		limit = { NOT = { has_province_flag = africa_drought_flag } } #So it's not overwritten and can be checked for time...
		clr_province_flag = africa_heavy_rain_flag
		clr_province_flag = africa_light_rain_flag
		clr_province_flag = africa_drought_risk_flag
		set_province_flag = africa_drought_flag
	}
}

change_rain_effect = { # Needs a province scope...
	if = {
		limit = { has_province_modifier = africa_heavy_rain }
		random_list = {
			10 = { # Make it worse (risk for drought)...
				modifier = { # There is no nearby light rain...
					factor = 2
					any_neighbor_province_has_light_rain_trigger = no
				}
				modifier = {
					factor = 2 # There is more heavy rain nearby...
					any_neighbor_province_has_heavy_rain_trigger = yes
				}
				modifier = {
					factor = 2 # There is nearby dry weather...
					any_neighbor_province_has_dry_weather_trigger = yes
				}
				remove_rain_modifiers_effect = yes
				if = {
					limit = { has_province_modifier = africa_rain_dance_successful }
					remove_province_modifier = africa_rain_dance_successful
				}
				add_province_modifier = {
					name = africa_drought_risk
					duration = -1
				}
				set_rain_flag_drought_risk_effect = yes
			}
			10 = { # Make it better (light rain)...
				modifier = { #There is no nearby drought...
					factor = 2
					any_neighbor_province_has_dry_weather_trigger = no
				}
				modifier = {
					factor = 2 # There is more heavy rain nearby...
					any_neighbor_province_has_heavy_rain_trigger = yes
				}
				modifier = {
					factor = 2 # There is light rain nearby...
					any_neighbor_province_has_light_rain_trigger = no
				}
				remove_rain_modifiers_effect = yes
				add_province_modifier = {
					name = africa_light_rain
					duration = -1
				}
				set_rain_flag_light_effect = yes
			}
			10 = { # Keep weather (heavy rain)...
				set_rain_flag_heavy_effect = yes
			}
		}
	}
	else_if = {
		limit = {
			has_province_modifier = africa_light_rain
		}
		random_list = {
			10 = { # Make it worse (drought risk)...
				modifier = { #More likely if have enjoyed it long enough...
					factor = 2
					had_province_flag = {
						flag = africa_light_rain_flag
						days = 3600 # almost 10 years...
					}
				}
				modifier = { #More likely if have enjoyed it long enough...
					factor = 2
					had_province_flag = {
						flag = africa_light_rain_flag
						days = 6000 # 16,5 years...
					}
				}
				modifier = { # There is no nearby great weather...
					factor = 2
					any_neighbor_province_has_light_rain_trigger = no
				}
				modifier = {
					factor = 2
					any_neighbor_province_has_heavy_rain_trigger = yes
				}
				modifier = {
					factor = 2
					any_neighbor_province_has_dry_weather_trigger = yes
				}
				remove_rain_modifiers_effect = yes
				if = {
					limit = { has_province_modifier = africa_rain_dance_successful }
					remove_province_modifier = africa_rain_dance_successful
				}
				add_province_modifier = {
					name = africa_drought_risk
					duration = -1
				}
				set_rain_flag_drought_risk_effect = yes
			}
			10 = { # Make it better (heavy rain)...
				modifier = { #There is no nearby drought...
					factor = 3
					any_neighbor_province_has_dry_weather_trigger = no
				}
				modifier = {
					factor = 2
					any_neighbor_province_has_heavy_rain_trigger = yes
				}
				modifier = {
					factor = 2
					any_neighbor_province_has_light_rain_trigger = no
				}
				remove_rain_modifiers_effect = yes
				add_province_modifier = {
					name = africa_heavy_rain
					duration = -1
				}
				set_rain_flag_heavy_effect = yes
			}
			10 = { # Keep weather (light rain)...
				set_rain_flag_light_effect = yes
			}
		}
	}
	else_if = {
		limit = { has_province_modifier = africa_drought_risk }
		random_list = {
			10 = { # Make it worse (actual drought)...
				modifier = { # There is no nearby rain...
					factor = 2
					any_neighbor_province_has_light_rain_trigger = no
				}
				modifier = {
					factor = 2
					any_neighbor_province_has_heavy_rain_trigger = no
				}
				remove_rain_modifiers_effect = yes
				if = {
					limit = { has_province_modifier = africa_rain_dance_successful }
					remove_province_modifier = africa_rain_dance_successful
				}
				add_province_modifier = {
					name = africa_drought_risk
					duration = -1
				}
				set_rain_flag_drought_effect = yes
			}
			10 = { # Make it better (light rain)...
				modifier = { #There is no nearby drought...
					factor = 3
					any_neighbor_province_has_dry_weather_trigger = no
				}
				modifier = {
					factor = 2
					any_neighbor_province_has_heavy_rain_trigger = yes
				}
				modifier = {
					factor = 2
					any_neighbor_province_has_light_rain_trigger = no
				}
				remove_rain_modifiers_effect = yes
				add_province_modifier = {
					name = africa_light_rain
					duration = -1
				}
				set_rain_flag_light_effect = yes
			}
			10 = { # Keep weather (drought risk)...
				set_rain_flag_drought_risk_effect = yes
			}
		}
	}
	else = {
		limit = { has_province_modifier = africa_drought }
		random_list = {
			10 = { # Make it better (heavy rain)...
				modifier = { #More likely if have suffered long enough...
					factor = 2
					had_province_flag = {
						flag = africa_drought_flag
						days = 3600 # almost 10 years...
					}
				}
				modifier = { #More likely if have suffered long enough...
					factor = 2
					had_province_flag = {
						flag = africa_drought_flag
						days = 6000 # 16,5 years...
					}
				}
				modifier = { #There is no nearby drought...
					factor = 3
					any_neighbor_province_has_dry_weather_trigger = no
				}
				modifier = {
					factor = 2
					any_neighbor_province_has_heavy_rain_trigger = yes
				}
				modifier = {
					factor = 2
					any_neighbor_province_has_light_rain_trigger = no
				}
				remove_rain_modifiers_effect = yes
				add_province_modifier = {
					name = africa_heavy_rain
					duration = -1
				}
				set_rain_flag_heavy_effect = yes
			}
			15 = { # Make it better (drought risk)...
				modifier = { #More likely if have suffered long enough...
					factor =2
					had_province_flag = {
						flag = africa_drought_flag
						days = 3600 # almost 10 years...
					}
				}
				modifier = { #More likely if have suffered long enough...
					factor = 2
					had_province_flag = {
						flag = africa_drought_flag
						days = 6000 # 16,5 years...
					}
				}
				modifier = { #There is no nearby drought...
					factor = 3
					any_neighbor_province_has_dry_weather_trigger = no
				}
				modifier = {
					factor = 2
					any_neighbor_province_has_heavy_rain_trigger = yes
				}
				modifier = {
					factor = 2
					any_neighbor_province_has_light_rain_trigger = no
				}
				remove_rain_modifiers_effect = yes
				if = {
					limit = { has_province_modifier = africa_rain_dance_successful }
					remove_province_modifier = africa_rain_dance_successful
				}
				add_province_modifier = {
					name = africa_drought_risk
					duration = -1
				}
				set_rain_flag_drought_risk_effect = yes
			}
			10 = { # Keep weather (actual drought)...
				modifier = { # There is no nearby great weather...
					factor = 2
					any_neighbor_province_has_light_rain_trigger = no
				}
				modifier = {
					factor = 2
					any_neighbor_province_has_heavy_rain_trigger = no
				}
				modifier = {
					factor = 2
					any_neighbor_province_has_dry_weather_trigger = yes
				}
				set_rain_flag_drought_effect = yes
			}
		}
	}
	set_weather_change_cooldown_effect = yes #sets a hidden modifier...
}

clone_weather_to_prev_effect = {
	if = {
		limit = { has_province_modifier = africa_heavy_rain }
		PREV = {
			remove_rain_modifiers_effect = yes
			add_province_modifier = {
				name = africa_heavy_rain
				duration = -1
			}
			set_rain_flag_heavy_effect = yes
		}
	}
	else_if = {
		limit = { has_province_modifier = africa_light_rain }
		PREV = {
			remove_rain_modifiers_effect = yes
			add_province_modifier = {
				name = africa_light_rain
				duration = -1
			}
			set_rain_flag_light_effect = yes
		}
	}
	else_if = {
		limit = { has_province_modifier = africa_drought_risk }
		PREV = {
			remove_rain_modifiers_effect = yes
			add_province_modifier = {
				name = africa_drought_risk
				duration = -1
			}
			set_rain_flag_drought_risk_effect = yes
		}
	}
	else = {
		limit = { has_province_modifier = africa_drought }
		PREV = {
			remove_rain_modifiers_effect = yes
			add_province_modifier = {
				name = africa_drought
				duration = -1
			}
			set_rain_flag_drought_effect = yes
		}
	}
	PREV = { set_weather_change_cooldown_effect = yes } #sets a hidden modifier...
}

calculate_weather_status_in_demesne_effect = {
	### Find out what had the most impact...
	set_variable = {
		which = light_rain_count
		value = 0
	}
	set_variable = {
		which = heavy_rain_count
		value = 0
	}
	set_variable = {
		which = drought_risk_count
		value = 0
	}
	set_variable = {
		which = drought_count
		value = 0
	}
	# Light rain...?
	while = {
		limit = {
	    	any_demesne_province = {
	    		has_province_modifier = africa_light_rain
	    		NOT = { has_province_flag = has_been_counted }
	    	}
		}
		random_demesne_province = {
			limit = {
				has_province_modifier = africa_light_rain
	    		NOT = { has_province_flag = has_been_counted }
			}
			PREV = {
		    	change_variable = {
					which = light_rain_count
					value = 1
				}
			}
			set_province_flag = has_been_counted
		}
	}
	# Heavy rain...?
	while = {
		limit = {
	    	any_demesne_province = {
	    		has_province_modifier = africa_heavy_rain
	    		NOT = { has_province_flag = has_been_counted }
	    	}
		}
		random_demesne_province = {
			limit = {
				has_province_modifier = africa_heavy_rain
	    		NOT = { has_province_flag = has_been_counted }
			}
			PREV = {
		    	change_variable = {
					which = heavy_rain_count
					value = 1
				}
			}
			set_province_flag = has_been_counted
		}
	}
	# Drought risk...?
	while = {
		limit = {
	    	any_demesne_province = {
	    		has_province_modifier = africa_drought_risk
	    		NOT = { has_province_flag = has_been_counted }
	    	}
		}
		random_demesne_province = {
			limit = {
				has_province_modifier = africa_drought_risk
	    		NOT = { has_province_flag = has_been_counted }
			}
			PREV = {
		    	change_variable = {
					which = drought_risk_count
					value = 1
				}
			}
			set_province_flag = has_been_counted
		}
	}
	# Actual drought...?
	while = {
		limit = {
	    	any_demesne_province = {
	    		has_province_modifier = africa_drought
	    		NOT = { has_province_flag = has_been_counted }
	    	}
		}
		random_demesne_province = {
			limit = {
				has_province_modifier = africa_drought
	    		NOT = { has_province_flag = has_been_counted }
			}
			PREV = {
		    	change_variable = {
					which = drought_count
					value = 1
				}
			}
			set_province_flag = has_been_counted
		}
	}

	any_demesne_province = { clr_province_flag = has_been_counted } #clean up

	clr_character_flag = mostly_drought
	clr_character_flag = mostly_drought_risk
	clr_character_flag = mostly_light_rain
	clr_character_flag = mostly_heavy_rain
	clr_character_flag = one_rain_variable_is_higher_than_one_drought_variable
	clr_character_flag = light_rain_variable_is_higher_than_drought_variable
	clr_character_flag = light_rain_variable_is_higher_than_drought_risk_variable
	clr_character_flag = heavy_rain_variable_is_higher_than_drought_variable
	clr_character_flag = heavy_rain_variable_is_higher_than_drought_risk_variable


	if = {
		limit = {
			check_variable = { # if actual drought is more common than the risk of it...
				which = "drought_count"
				which >= "drought_risk_count"
				which = ROOT		
			}
			check_variable = { # and more common than heavy rain...
				which = "drought_count"
				which >= "heavy_rain_count"
				which = ROOT
			}
			check_variable = { # and more than light rain...
				which = "drought_count"
				which >= "light_rain_count"
				which = ROOT
			}
		}
		set_character_flag = mostly_drought
	}
	if = {
		limit = {
			check_variable = { # if drought risk is more common than actual drought...
				which = "drought_risk_count"
				which >= "drought_count"
				which = ROOT
			}
			check_variable = { # and more common than heavy rain...
				which = "drought_risk_count"
				which >= "heavy_rain_count"
				which = ROOT
			}
			check_variable = { # and more than light rain...
				which = "drought_risk_count"
				which >= "light_rain_count"
				which = ROOT
			}
		}
		set_character_flag = mostly_drought_risk
	}
	if = {
		limit = {
			check_variable = { # if light rain is more common than drought risk...
				which = "light_rain_count"
				which >= "drought_risk_count"
				which = ROOT
			}
			check_variable = { # and more common than heavy rain...
				which = "light_rain_count"
				which >= "heavy_rain_count"
				which = ROOT
			}
			check_variable = { # and more than drought...
				which = "light_rain_count"
				which >= "drought_count"
				which = ROOT
			}
		}
		set_character_flag = mostly_light_rain
	}
	if = {
		limit = {
			check_variable = { # if heavy rain is more common than drought risk...
				which = "heavy_rain_count"
				which >= "drought_risk_count"
				which = ROOT
			}
			check_variable = { # and more common than heavy rain...
				which = "heavy_rain_count"
				which >= "light_rain_count"
				which = ROOT
			}
			check_variable = { # and more than drought...
				which = "heavy_rain_count"
				which >= "drought_count"
				which = ROOT
			}
		}
		set_character_flag = mostly_heavy_rain
	}

	if = {
		limit = {
			OR = {
    			check_variable = {
					which = "light_rain_count"
					which >= "drought_count"
					which = ROOT
				}
				check_variable = {
					which = "light_rain_count"
					which >= "drought_risk_count"
					which = ROOT
				}
				check_variable = {
					which = "heavy_rain_count"
					which >= "drought_count"
					which = ROOT
				}
				check_variable = {
					which = "heavy_rain_count"
					which >= "drought_risk_count"
					which = ROOT
				}
			}
		}
		set_character_flag = one_rain_variable_is_higher_than_one_drought_variable
		if = {
			limit = {
				check_variable = {
					which = "light_rain_count"
					which >= "drought_count"
					which = ROOT
				}
			}
			set_character_flag = light_rain_variable_is_higher_than_drought_variable
		}
		if = {
			limit = {
				check_variable = {
					which = "light_rain_count"
					which >= "drought_risk_count"
					which = ROOT
				}
			}
			set_character_flag = light_rain_variable_is_higher_than_drought_risk_variable
		}
		if = {
			limit = {
				check_variable = {
					which = "heavy_rain_count"
					which >= "drought_count"
					which = ROOT
				}
			}
			set_character_flag = heavy_rain_variable_is_higher_than_drought_variable
		}
		if = {
			limit = {
				check_variable = {
					which = "heavy_rain_count"
					which >= "drought_risk_count"
					which = ROOT
				}
			}
			set_character_flag = heavy_rain_variable_is_higher_than_drought_risk_variable
		}
	}
}

clr_flags_introduce_heir_effect = {
	clr_character_flag = ZE_evt_heir_1
	clr_character_flag = ZE_evt_heir_2
	clr_character_flag = ZE_evt_heir_2B
	clr_character_flag = ZE_evt_heir_3
	clr_character_flag = ZE_evt_heir_3B
	clr_character_flag = ZE_evt_heir_4
	clr_character_flag = ZE_evt_heir_5
	clr_character_flag = ZE_evt_heir_6
	clr_character_flag = ZE_evt_heir_7
	clr_character_flag = ZE_evt_heir_8
}

generate_mask_effect = {
	random_list = { 
		20 = { 
			add_artifact = crown_african_mask_1
			new_artifact = {
				random_list = { 
					20 = { set_name = crown_african_mask_1_random_a } #Randomize names to avoid too much repetition.
					20 = { set_name = crown_african_mask_1_random_b }
					20 = { set_name = crown_african_mask_1_random_c }
					20 = { set_name = crown_african_mask_1_random_d } 
				}
			}
		}
		20 = { 
			add_artifact = crown_african_mask_2
			new_artifact = {
				random_list = { 
					20 = { set_name = crown_african_mask_2_random_a } #Randomize names to avoid too much repetition.
					20 = { set_name = crown_african_mask_2_random_b }
					20 = { set_name = crown_african_mask_2_random_c }
					20 = { set_name = crown_african_mask_2_random_d } 
				}
			}
		}
		20 = { 
			add_artifact = crown_african_mask_3
			new_artifact = {
				random_list = { 
					20 = { set_name = crown_african_mask_3_random_a } #Randomize names to avoid too much repetition.
					20 = { set_name = crown_african_mask_3_random_b }
					20 = { set_name = crown_african_mask_3_random_c }
					20 = { set_name = crown_african_mask_3_random_d } 
				}
			}
		}
		20 = { 
			add_artifact = crown_african_mask_4
			new_artifact = {
				random_list = { 
					20 = { set_name = crown_african_mask_4_random_a } #Randomize names to avoid too much repetition.
					20 = { set_name = crown_african_mask_4_random_b }
					20 = { set_name = crown_african_mask_4_random_c }
					20 = { set_name = crown_african_mask_4_random_d } 
				}
			}
		}
		20 = { 
			add_artifact = crown_african_mask_5
			new_artifact = {
				random_list = { 
					20 = { set_name = crown_african_mask_5_random_a } #Randomize names to avoid too much repetition.
					20 = { trigger = { ROOT = { NOT = { dynasty = none } } } set_name = crown_african_mask_5_random_b }
					20 = { set_name = crown_african_mask_5_random_c }
					20 = { set_name = crown_african_mask_5_random_d } 
				}
			}
		}
		20 = { 
			add_artifact = crown_african_mask_6
			new_artifact = {
				random_list = { 
					20 = { set_name = crown_african_mask_6_random_a } #Randomize names to avoid too much repetition.
					20 = { set_name = crown_african_mask_6_random_b }
					20 = { trigger = { ROOT = { NOT = { dynasty = none } } } set_name = crown_african_mask_6_random_c }
					20 = { set_name = crown_african_mask_6_random_d } 
				}
			}
		}
		20 = { 
			add_artifact = crown_african_mask_7
			new_artifact = {
				random_list = { 
					20 = { set_name = crown_african_mask_7_random_a } #Randomize names to avoid too much repetition.
					20 = { set_name = crown_african_mask_7_random_b }
					20 = { set_name = crown_african_mask_7_random_c }
					20 = { set_name = crown_african_mask_7_random_d } 
				}
			}
		}
		20 = { 
			add_artifact = crown_african_mask_8
			new_artifact = {
				random_list = { 
					20 = { set_name = crown_african_mask_8_random_a } #Randomize names to avoid too much repetition.
					20 = { set_name = crown_african_mask_8_random_b }
					20 = { set_name = crown_african_mask_8_random_c }
					20 = { set_name = crown_african_mask_8_random_d } 
				}
			}
		}
	}
}

reformation_god_names_changes_effect = { #Reforming religion with certain Doctrines might result in gods being added/removed/changed.
	ROOT = { #The Reformer scope.
		if = {
			limit = { 
				NOT = {
					has_alternate_start_parameter = { key = religion_names value = random }
				}
			}
			if = { #A ruler reforms Norse Paganism.
				limit = {
					has_dlc = "Holy Fury" 
					religion = norse_pagan_reformed
					OR = { 
						has_religion_feature = religion_matriarchal
						has_religion_feature = religion_patriarchal
						has_religion_feature = religion_dogmatic
					}
				}
				remove_god_names = yes
				remove_evil_god_names = yes
				if = { #Religion is not sexist, add just Dogmatic set.
					limit = {
						NOR = {
							has_religion_feature = religion_matriarchal
							has_religion_feature = religion_patriarchal
						}
					}
					set_high_god_name = GOD_THE_ALLFATHER
					add_god_name = GOD_THE_ALLFATHER_2
					add_evil_god_name = LOKI
					add_evil_god_name = HEL
					add_evil_god_name = FENRIR
					add_evil_god_name = JORMUNGANDR
				}
				if = { #Religion is Patriarchal
					limit = {
						has_religion_feature = religion_patriarchal
					}
					set_high_god_name = GOD_ODIN
					add_god_name = GOD_ODIN_2
					if = { 
						limit = {
							NOT = { has_religion_feature = religion_dogmatic }
						}
						add_god_name = GOD_THOR
						add_god_name = GOD_THE_THUNDERER
						add_god_name = GOD_THE_ALLFATHER
						add_god_name = GOD_TYR
					}
					add_evil_god_name = GOD_FRIGG
					add_evil_god_name = HEL
					add_evil_god_name = GOD_SIF
					add_evil_god_name = GOD_SKADI
				}
				if = { #Religion is Matriarchal
					limit = {
						has_religion_feature = religion_matriarchal
					}
					set_high_god_name = GOD_FRIGG
					add_god_name = GOD_FRIGG_2
					if = { 
						limit = {
							NOT = { has_religion_feature = religion_dogmatic }
						}
						add_god_name = GOD_SIF
						add_god_name = GOD_THE_ALLMOTHER
						add_god_name = GOD_SKADI
						add_god_name = GOD_FREY
					}
					add_evil_god_name = LOKI
					add_evil_god_name = GOD_THE_THUNDERER
					add_evil_god_name = FENRIR
					add_evil_god_name = JORMUNGANDR
				}
			}
			if = { #A ruler reforms Tengri Paganism.
				limit = {
					has_dlc = "Holy Fury" 
					religion = tengri_pagan_reformed
					OR = { 
						has_religion_feature = religion_matriarchal
						has_religion_feature = religion_patriarchal
						has_religion_feature = religion_dogmatic
					}
				}
				remove_god_names = yes
				remove_evil_god_names = yes
				if = { #Religion is not sexist, add just Dogmatic set.
					limit = {
						NOR = {
							has_religion_feature = religion_matriarchal
							has_religion_feature = religion_patriarchal
						}
					}
					set_high_god_name = GOD_TENGRI
					add_god_name = GOD_TENGRI_2
					add_evil_god_name = ERLIK
					add_evil_god_name = KOMUR_HAN
				}
				if = { #Religion is Patriarchal
					limit = {
						has_religion_feature = religion_patriarchal
					}
					set_high_god_name = GOD_TENGRI  
					add_god_name = GOD_TENGRI_2
					add_god_name = GOD_TUNG-AK
					add_evil_god_name = GOD_AK_ANA 
					add_evil_god_name = KOMUR_HAN
				}
				if = { #Religion is Matriarchal
					limit = {
						has_religion_feature = religion_matriarchal
					}
					set_high_god_name = GOD_UMAY
					add_god_name = GOD_UMAY_2
					add_god_name = GOD_AK_ANA
					add_god_name = GOD_KUBAI
					add_evil_god_name = ERLIK
					add_evil_god_name = KOMUR_HAN
				}
			}
			if = { #A ruler reforms Baltic Paganism.
				limit = {
					has_dlc = "Holy Fury" 
					religion = baltic_pagan_reformed
					OR = { 
						has_religion_feature = religion_matriarchal
						has_religion_feature = religion_patriarchal
						has_religion_feature = religion_dogmatic
					}
				}
				remove_god_names = yes
				remove_evil_god_names = yes
				if = { #Religion is not sexist, add just Dogmatic set.
					limit = {
						NOR = {
							has_religion_feature = religion_matriarchal
							has_religion_feature = religion_patriarchal
						}
					}
					set_high_god_name = GOD_DIEVAS
					add_god_name = GOD_DIEVAS_2
					add_evil_god_name = VELNIAS
				}
				if = { #Religion is Patriarchal
					limit = {
						has_religion_feature = religion_patriarchal
					}
					set_high_god_name = GOD_DIEVAS
					add_god_name = GOD_DIEVAS_2
					add_god_name = GOD_PERKUNAS  
					add_evil_god_name = GOD_LAIMA
				}
				if = { #Religion is Matriarchal
					limit = {
						has_religion_feature = religion_matriarchal
					}
					set_high_god_name = GOD_GABIJA
					add_god_name = GOD_GABIJA_2
					add_god_name = GOD_LAIMA  
					add_evil_god_name = VELNIAS
				}
			}

			if = { #A ruler reforms Finnish Paganism.
				limit = {
					has_dlc = "Holy Fury" 
					religion = finnish_pagan_reformed
					OR = { 
						has_religion_feature = religion_matriarchal
						has_religion_feature = religion_patriarchal
						has_religion_feature = religion_dogmatic
					}
				}
				remove_god_names = yes
				remove_evil_god_names = yes
				if = { #Religion is not sexist, add just Dogmatic set.
					limit = {
						NOR = {
							has_religion_feature = religion_matriarchal
							has_religion_feature = religion_patriarchal
						}
					}
					set_high_god_name = GOD_UKKO
					add_god_name = GOD_UKKO_2
					add_evil_god_name = TUONI
				}
				if = { #Religion is Patriarchal
					limit = {
						has_religion_feature = religion_patriarchal
					}
					set_high_god_name = GOD_UKKO
					add_god_name = GOD_UKKO_2
					if = { 
						limit = {
							NOT = { has_religion_feature = religion_dogmatic }
						}
						add_god_name = GOD_PERKELE 
						add_god_name = GOD_JUMI
						add_god_name = GOD_THE_GREAT_BEAR
						add_god_name = GOD_TAPIO
						add_god_name = GOD_TAARA
						add_god_name = GOD_OMOL
					}
					add_evil_god_name = GOD_MASTOR_AVA
					add_evil_god_name = GOD_KALMA
				}
				if = { #Religion is Matriarchal
					limit = {
						has_religion_feature = religion_matriarchal
					}
					set_high_god_name = GOD_KUU
					add_god_name = GOD_KUU_2
					if = { 
						limit = {
							NOT = { has_religion_feature = religion_dogmatic }
						}
						add_god_name = GOD_MASTOR_AVA 
						add_god_name = GOD_KALMA
						add_god_name = GOD_THE_GREAT_BEAR
					}
					add_evil_god_name = TUONI 
					add_evil_god_name = TUONETAR
				}
			}

			if = { #A ruler reforms Aztec Paganism.
				limit = {
					has_dlc = "Holy Fury" 
					religion = aztec_reformed
					OR = { 
						has_religion_feature = religion_matriarchal
						has_religion_feature = religion_patriarchal
						has_religion_feature = religion_dogmatic
						has_religion_feature = religion_proselytizing
					}
				}
				remove_god_names = yes
				remove_evil_god_names = yes
				if = { #Religion is not sexist, add just Proselytizing set.
					limit = {
						NOR = {
							has_religion_feature = religion_matriarchal
							has_religion_feature = religion_patriarchal
						}
						has_religion_feature = religion_proselytizing
					}
					set_high_god_name = GOD_QUETZALCOATL
					add_god_name = GOD_QUETZALCOATL_2
					add_evil_god_name = GOD_TEZCATLIPOCA
				}
				if = { #Religion is not sexist, add just Dogmatic set.
					limit = {
						NOR = {
							has_religion_feature = religion_matriarchal
							has_religion_feature = religion_patriarchal
						}
						has_religion_feature = religion_dogmatic
					}
					set_high_god_name = GOD_HUITZILOPOCHTLI
					add_god_name = GOD_HUITZILOPOCHTLI_2
					add_evil_god_name = TLAZOLTEOTL
				}
				if = { #Religion is Patriarchal
					limit = {
						has_religion_feature = religion_patriarchal
					}
					set_high_god_name = GOD_HUITZILOPOCHTLI 
					add_god_name = GOD_HUITZILOPOCHTLI_2   
					add_god_name = GOD_XIPE_TOTEC 
					add_god_name = GOD_TEZCATLIPOCA
					add_god_name = GOD_QUETZALCOATL
					add_god_name = GOD_TLALOC
					add_evil_god_name = TLAZOLTEOTL 
					add_evil_god_name = GOD_MICTLANTECUHTLI 
					add_evil_god_name = XOLOTL
				}
				if = { #Religion is Matriarchal
					limit = {
						has_religion_feature = religion_matriarchal
					}
					set_high_god_name = GOD_CIHUACOATL
					add_god_name = GOD_CIHUACOATL_2
					add_god_name = GOD_MALINALXOCHITL 
					add_god_name = GOD_METZTLI
					add_god_name = GOD_TONACACIHUATL
					add_evil_god_name = TLAZOLTEOTL 
					add_evil_god_name = GOD_MICTLANTECUHTLI 
					add_evil_god_name = XOLOTL
				}
			}

			if = { #A ruler reforms Slavic Paganism.
				limit = {
					has_dlc = "Holy Fury" 
					religion = slavic_pagan_reformed
					OR = { 
						has_religion_feature = religion_matriarchal
						has_religion_feature = religion_patriarchal
						has_religion_feature = religion_dogmatic
					}
				}
				remove_god_names = yes
				remove_evil_god_names = yes
				if = { #Religion is not sexist, add just Dogmatic set.
					limit = {
						NOR = {
							has_religion_feature = religion_matriarchal
							has_religion_feature = religion_patriarchal
						}
					}
					set_high_god_name = GOD_PERUN
					add_god_name = GOD_PERUN_2
					add_evil_god_name = GOD_VELES
					add_evil_god_name = CHERNOBOG
				}
				if = { #Religion is Patriarchal
					limit = {
						has_religion_feature = religion_patriarchal
					}
					set_high_god_name = GOD_PERUN
					add_god_name = GOD_PERUN_2
					if = { 
						limit = {
							NOT = { has_religion_feature = religion_dogmatic }
						}
						add_god_name = GOD_JARILO 
						add_god_name = GOD_SVAROG 
						add_god_name = GOD_TRIGLAV 
						add_god_name = GOD_RADEGAST 
					}
					add_evil_god_name = GOD_VELES
					add_evil_god_name = GOD_MEDEINA
				}
				if = { #Religion is Matriarchal
					limit = {
						has_religion_feature = religion_matriarchal
					}
					set_high_god_name = GOD_MEDEINA
					add_god_name = GOD_MEDEINA_2
					if = { 
						limit = {
							NOT = { has_religion_feature = religion_dogmatic }
						}
						add_god_name = GOD_DODOLA 
						add_god_name = GOD_KOSTROMA
						add_god_name = GOD_MARZANNA
					}
					add_evil_god_name = GOD_VELES 
					add_evil_god_name = CHERNOBOG
				}
			}
			if = { #A ruler reforms West African Paganism.
				limit = {
					has_dlc = "Holy Fury" 
					religion = west_african_pagan_reformed
					has_religion_feature = religion_matriarchal
				}
				set_high_god_name = GOD_THE_MOTHER
			}
			if = { #A ruler reforms Bon Paganism.
				limit = {
					has_dlc = "Holy Fury" 
					religion = bon_reformed
					has_religion_feature = religion_dogmatic
				}
				remove_god_names = yes
				set_high_god_name = GOD_SANGPO_BUMTRI
				add_god_name = GOD_SANGPO_BUMTRI_2
				add_evil_god_name = GOD_THE_EVIL_ONES
			}

			if = { #A ruler reforms Hellenism while being Greek-cultured: change all the gods to their Greek names.
				limit = {
					has_dlc = "Holy Fury" 
					religion = hellenic_pagan_reformed
					culture = greek
				}
				remove_god_names = yes
				remove_evil_god_names = yes
				set_global_flag = flag_hellenic_greek_reformation #Handles other instances.
				if = { #Religion is not sexist, re-add all the gods.
					limit = {
						NOR = {
							has_religion_feature = religion_matriarchal
							has_religion_feature = religion_patriarchal
						}
					}
					if = { #Poseidon finally gets his due.
						limit = {
							has_religion_feature = religion_seafaring
						}
						set_high_god_name = GOD_POSEIDON
					}
					if = {
						limit = {
							NOT = { has_religion_feature = religion_seafaring }
						}
						set_high_god_name = GOD_GREEK_JUPITER #Otherwise shows Conclave...
					}
					if = { #Dogmatics only get one
						limit = {
							NOT = { has_religion_feature = religion_dogmatic }
						}
						add_god_name = GOD_GREEK_JUPITER_2 #Otherwise shows Conclave...
						add_god_name = GOD_POSEIDON_2
						add_god_name = GOD_HADES
						add_god_name = GOD_HERA
						add_god_name = GOD_DEMETRA
						add_god_name = GOD_ATHENA
						add_god_name = GOD_ARES
						add_god_name = GOD_HEPHAESTUS
						add_god_name = GOD_APHRODITE
						add_god_name = GOD_APOLLO
						add_god_name = GOD_ARTEMIS
						add_god_name = GOD_HESTIA
					}
					add_evil_god_name = GOD_HADES
					add_evil_god_name = GOD_KRONOS
					add_evil_god_name = GOD_DIONYSUS
					add_evil_god_name = GOD_HERMES
					add_evil_god_name = GOD_TYPHON
				}
				if = { #Religion is Patriarchal.
					limit = {
						has_religion_feature = religion_patriarchal
					}
					if = { #Poseidon finally gets his due.
						limit = {
							has_religion_feature = religion_seafaring
						}
						set_high_god_name = GOD_POSEIDON
					}
					if = {
						limit = {
							NOT = { has_religion_feature = religion_seafaring }
						}
						set_high_god_name = GOD_GREEK_JUPITER #Otherwise shows Conclave...
					}
					if = { #Dogmatics only get one
						limit = {
							NOT = { has_religion_feature = religion_dogmatic }
						}
						add_god_name = GOD_GREEK_JUPITER_2 #Otherwise shows Conclave...
						add_god_name = GOD_POSEIDON_2
						add_god_name = GOD_HADES
						add_god_name = GOD_ARES
						add_god_name = GOD_HEPHAESTUS
						add_god_name = GOD_APOLLO
					}
					add_evil_god_name = GOD_APHRODITE
					add_evil_god_name = GOD_HERA
					add_evil_god_name = GOD_ATHENA
					add_evil_god_name = GOD_ARTEMIS
					add_evil_god_name = GOD_DELFINE
				}
				if = { #Religion is Matriarchal.
					limit = {
						has_religion_feature = religion_matriarchal
					}
					set_high_god_name = GOD_HERA
					add_god_name = GOD_HERA_2
					if = { #Dogmatics only get one
						limit = {
							NOT = { has_religion_feature = religion_dogmatic }
						}
						add_god_name = GOD_DEMETRA
						add_god_name = GOD_ATHENA
						add_god_name = GOD_APHRODITE
						add_god_name = GOD_ARTEMIS
						add_god_name = GOD_HESTIA
					}
					add_evil_god_name = GOD_HADES
					add_evil_god_name = GOD_GREEK_JUPITER #Otherwise shows Conclave...
					add_evil_god_name = GOD_POSEIDON
					add_evil_god_name = GOD_ARES
					add_evil_god_name = GOD_TYPHON
				}
			}
			if = { #A ruler reforms Hellenism while NOT being Greek-cultured.
				limit = {
					has_dlc = "Holy Fury" 
					religion = hellenic_pagan_reformed
					NOT = { culture = greek }
				}
				remove_god_names = yes
				remove_evil_god_names = yes
				if = { #Religion is not sexist, re-add all the gods.
					limit = {
						NOR = {
							has_religion_feature = religion_matriarchal
							has_religion_feature = religion_patriarchal
						}
					}
					if = { #Poseidon finally gets his due.
						limit = {
							has_religion_feature = religion_seafaring
						}
						set_high_god_name = GOD_NEPTUNE
					}
					if = {
						limit = {
							NOT = { has_religion_feature = religion_seafaring }
						}
						set_high_god_name = GOD_JUPITER
					}
					if = { #Dogmatics only get one
						limit = {
							NOT = { has_religion_feature = religion_dogmatic }
						}
						add_god_name = GOD_JUPITER_2
						add_god_name = GOD_NEPTUNE_2
						add_god_name = GOD_PLUTO
						add_god_name = GOD_JUNO
						add_god_name = GOD_CERES
						add_god_name = GOD_MINERVA
						add_god_name = GOD_MARS
						add_god_name = GOD_VULCAN
						add_god_name = GOD_VENUS
						add_god_name = GOD_APOLLO
						add_god_name = GOD_DIANA
						add_god_name = GOD_VESTA
					}
					add_evil_god_name = GOD_SATURN
					add_evil_god_name = GOD_PLUTO
					add_evil_god_name = GOD_BACCHUS
					add_evil_god_name = GOD_MERCURY
					add_evil_god_name = GOD_TYPHON
				}
				if = { #Religion is Patriarchal.
					limit = {
						has_religion_feature = religion_patriarchal
					}
					if = { #Poseidon finally gets his due.
						limit = {
							has_religion_feature = religion_seafaring
						}
						set_high_god_name = GOD_NEPTUNE
					}
					if = {
						limit = {
							NOT = { has_religion_feature = religion_seafaring }
						}
						set_high_god_name = GOD_JUPITER
					}
					if = { #Dogmatics only get one
						limit = {
							NOT = { has_religion_feature = religion_dogmatic }
						}
						add_god_name = GOD_JUPITER_2
						add_god_name = GOD_NEPTUNE_2
						add_god_name = GOD_PLUTO
						add_god_name = GOD_MARS
						add_god_name = GOD_VULCAN
						add_god_name = GOD_APOLLO
					}
					add_evil_god_name = GOD_VENUS
					add_evil_god_name = GOD_JUNO
					add_evil_god_name = GOD_MINERVA
					add_evil_god_name = GOD_DIANA
					add_evil_god_name = GOD_DELFINE
				}
				if = { #Religion is Matriarchal.
					limit = {
						has_religion_feature = religion_matriarchal
					}
					set_high_god_name = GOD_JUNO
					add_god_name = GOD_JUNO_2
					if = { #Dogmatics only get one
						limit = {
							NOT = { has_religion_feature = religion_dogmatic }
						}
						add_god_name = GOD_CERES
						add_god_name = GOD_MINERVA
						add_god_name = GOD_VENUS
						add_god_name = GOD_DIANA
						add_god_name = GOD_VESTA
					}
					add_evil_god_name = GOD_PLUTO
					add_evil_god_name = GOD_JUPITER
					add_evil_god_name = GOD_NEPTUNE
					add_evil_god_name = GOD_MARS
					add_evil_god_name = GOD_TYPHON
				}
			}
		}

		if = {
			limit = { #Holy Family actually becomes Holy.
				has_dlc = "Holy Fury" 
				OR = { 
					has_religion_feature = religion_holy_family 
					has_religion_feature = religion_feature_zun
				}
			}
			if = {
				limit = { #Reformer himself, but only if he is not becoming the High God due to synergy.
					NOT = { has_religion_feature = religion_temporal_head }
					OR = { 
						AND = { 
							is_female = no
							NOT = { has_religion_feature = religion_matriarchal }
						}
						AND = { 
							is_female = yes
							NOT = { has_religion_feature = religion_patriarchal }
						}
					}
				}
				add_god_name = string_reformer_god
			}
			if = {
				limit = { #Spouse.
					is_married = yes
					OR = { 
						AND = { 
							is_female = yes
							NOT = { has_religion_feature = religion_matriarchal }
						}
						AND = { 
							is_female = no
							NOT = { has_religion_feature = religion_patriarchal }
						}
					}
				}
				random_spouse = { save_event_target_as = scoped_god_spouse }
				add_god_name = string_reformer_spouse_god
			}
			if = {
				limit = { #Spouse, again.
					is_married = yes
					OR = { 
						AND = { 
							is_female = yes
							has_religion_feature = religion_matriarchal
						}
						AND = { 
							is_female = no
							has_religion_feature = religion_patriarchal
						}
					}
				}
				random_spouse = { save_event_target_as = scoped_god_spouse }
				add_evil_god_name = string_reformer_spouse_god
			}
			if = {
				limit = { #Child.
					any_child = { 
						OR = { 
							AND = { 
								is_female = no
								NOT = { ROOT = { has_religion_feature = religion_matriarchal } }
							}
							AND = { 
								is_female = yes
								NOT = { ROOT = { has_religion_feature = religion_matriarchal } }
							}
						}
					}
				}
				random_child = { 
					limit = { 
						OR = { 
							AND = { 
								is_female = no
								NOT = { ROOT = { has_religion_feature = religion_matriarchal } }
							}
							AND = { 
								is_female = yes
								NOT = { ROOT = { has_religion_feature = religion_matriarchal } }
							}
						}
					}
					preferred_limit = {
						is_primary_heir = ROOT
					}
					save_event_target_as = scoped_god_child
				}
				add_god_name = string_reformer_child_god
			}
			if = {
				limit = { #Sibling.
					any_sibling = { 
						OR = { 
							AND = { 
								is_female = no
								NOT = { ROOT = { has_religion_feature = religion_matriarchal } }
							}
							AND = { 
								is_female = yes
								NOT = { ROOT = { has_religion_feature = religion_matriarchal } }
							}
						}
					}
				}
				random_sibling = { 
					limit = { 
						OR = { 
							AND = { 
								is_female = no
								NOT = { ROOT = { has_religion_feature = religion_matriarchal } }
							}
							AND = { 
								is_female = yes
								NOT = { ROOT = { has_religion_feature = religion_matriarchal } }
							}
						}
					}
					preferred_limit = {
						is_primary_heir = ROOT
					}
					save_event_target_as = scoped_god_sibling
				}
				add_god_name = string_reformer_sibling_god
			}
		}

		if = {
			limit = { #Reformer becomes the High God.
				has_dlc = "Holy Fury" 
				OR = { 
					has_religion_feature = religion_holy_family 
					has_religion_feature = religion_feature_zun
				}
				has_religion_feature = religion_temporal_head 
			}
			set_high_god_name = string_reformer_god
		}
	}
}

murder_bloodline_check_effect = { 
	change_variable = { which = bloodline_murdered_people value = 1 }
	if = { #First check for pure Murder Bloodline.
		limit = {
			check_variable = { which = bloodline_murdered_people value = 30 } 
			has_ambition = obj_forge_bloodline
		}
		set_character_flag = flag_about_to_murder_bloodline
		character_event = { id = HF.24025 days = 25 random = 25 }
	}
	else_if = { #Then check for Murder War Hybrid.
		limit = {
			check_variable = { which = bloodline_murdered_people value = 20 } 
			check_variable = { which = bloodline_won_wars value = 10 } 
			has_ambition = obj_forge_bloodline
		}
		set_character_flag = flag_about_to_murder_bloodline
		narrative_event = { id = HF.24045 days = 25 random = 25 }
	}
	else_if = { #Then check for Murder Peace Hybrid.
		limit = {
			check_variable = { which = bloodline_murdered_people value = 20 } 
			check_variable = { which = bloodline_peaceful_years value = 15 } 
			has_ambition = obj_forge_bloodline
		}
		set_character_flag = flag_about_to_murder_bloodline
		narrative_event = { id = HF.24046 days = 25 random = 25 }
	}
	else_if = { #Then check for Murder Builder Hybrid.
		limit = {
			check_variable = { which = bloodline_murdered_people value = 20 } 
			check_variable = { which = bloodline_built_holdings value = 15 } 
			has_ambition = obj_forge_bloodline
		}
		set_character_flag = flag_about_to_murder_bloodline
		narrative_event = { id = HF.24048 days = 25 random = 25 }
	}
}

princely_elective_german_elector_setup_effect = {
	e_hre = { 
		#County of Koln
		#County of Mainz
		#County of Trier
		#Duchy of Bohemia
		#Duchy of Franconia
		#Duchy of Saxony
		#Duchy of Brandenburg
		save_persistent_event_target = { name = hre_title_1_per scope = c_koln }
		save_persistent_event_target = { name = hre_title_2_per scope = c_mainz }
		save_persistent_event_target = { name = hre_title_3_per scope = c_trier }
		save_persistent_event_target = { name = hre_title_4_per scope = d_bohemia }
		save_persistent_event_target = { name = hre_title_5_per scope = d_franconia }
		save_persistent_event_target = { name = hre_title_6_per scope = d_saxony }
		save_persistent_event_target = { name = hre_title_7_per scope = d_brandenburg }
	}
}

princely_elective_french_elector_setup_effect = {
	e_hre = { 
		#County of Amiens
		#County of Reims
		#County of Anjou
		#Duchy of Aquitaine
		#Duchy of Burgundy
		#Duchy of Normandy
		#Duchy of Champagne
		save_persistent_event_target = { name = hre_title_1_per scope = c_amiens }
		save_persistent_event_target = { name = hre_title_2_per scope = c_reims }
		save_persistent_event_target = { name = hre_title_3_per scope = c_anjou }
		save_persistent_event_target = { name = hre_title_4_per scope = d_aquitaine }
		save_persistent_event_target = { name = hre_title_5_per scope = d_burgundy }
		save_persistent_event_target = { name = hre_title_6_per scope = d_normandy }
		save_persistent_event_target = { name = hre_title_7_per scope = d_champagne }
	}
}

princely_elective_italian_elector_setup_effect = {
	e_hre = { 
		#County of Rome
		#County of Ravenna
		#County of Genoa
		#Duchy of Latium
		#Duchy of Milan
		#Duchy of Tuscany
		#Duchy of Pisa
		save_persistent_event_target = { name = hre_title_1_per scope = c_roma }
		save_persistent_event_target = { name = hre_title_2_per scope = c_ravenna }
		save_persistent_event_target = { name = hre_title_3_per scope = c_genoa }
		save_persistent_event_target = { name = hre_title_4_per scope = d_latium }
		save_persistent_event_target = { name = hre_title_5_per scope = d_lombardia }
		save_persistent_event_target = { name = hre_title_6_per scope = d_toscana }
		save_persistent_event_target = { name = hre_title_7_per scope = d_pisa }
	}
}

princely_elective_spain_elector_setup_effect = {
	e_hre = { 
		#County of Santiago
		#County of Cordoba
		#County of Leon
		#Duchy of Barcelona
		#Duchy of Castille
		#Duchy of Portucale
		#Duchy of Seville
		save_persistent_event_target = { name = hre_title_1_per scope = c_santiago }
		save_persistent_event_target = { name = hre_title_2_per scope = c_leon }
		save_persistent_event_target = { name = hre_title_3_per scope = c_cordoba }
		save_persistent_event_target = { name = hre_title_4_per scope = d_barcelona }
		save_persistent_event_target = { name = hre_title_5_per scope = d_castilla }
		save_persistent_event_target = { name = hre_title_6_per scope = d_porto }
		save_persistent_event_target = { name = hre_title_7_per scope = d_sevilla }
	}
}

princely_elective_britannia_elector_setup_effect = {
	e_hre = { 
		#County of Kent
		#County of Worcester
		#County of Durham
		#Duchy of Mercia
		#Duchy of Meath
		#Duchy of Albany
		#Duchy of Gwynedd
		save_persistent_event_target = { name = hre_title_1_per scope = c_kent }
		save_persistent_event_target = { name = hre_title_2_per scope = c_worcester }
		save_persistent_event_target = { name = hre_title_3_per scope = c_durham }
		save_persistent_event_target = { name = hre_title_4_per scope = d_mercia }
		save_persistent_event_target = { name = hre_title_5_per scope = d_meath }
		save_persistent_event_target = { name = hre_title_6_per scope = d_albany }
		save_persistent_event_target = { name = hre_title_7_per scope = d_gwynedd }
	}
}

princely_elective_apply_elector_setup_effect = { 
	if = {
		limit = {
			capital_scope = {
				region = world_europe_south_italy
			}
		}
		hidden_tooltip = {
			princely_elective_italian_elector_setup_effect = yes
		}
	}
	else_if = {
		limit = {
			capital_scope = {
				region = world_europe_west_francia
			}
		}
		hidden_tooltip = {
			princely_elective_french_elector_setup_effect = yes
		}
	}
	else_if = {
		limit = {
			capital_scope = {
				region = world_europe_west_germania
			}
		}
		hidden_tooltip = {
			princely_elective_german_elector_setup_effect = yes
		}
	}
	else_if = {
		limit = {
			capital_scope = {
				region = world_europe_west_iberia
			}
		}
		hidden_tooltip = {
			princely_elective_spain_elector_setup_effect = yes
		}
	}
	else_if = {
		limit = {
			capital_scope = {
				region = world_europe_west_brittania
			}
		}
		hidden_tooltip = {
			princely_elective_britannia_elector_setup_effect = yes
		}
	}
	else = { #If outside usual borders, default to Germania.
		hidden_tooltip = {
			princely_elective_german_elector_setup_effect = yes
		}
	}
}

give_goldsmith_artifacts_flag_okay_effect = {
	if = {
	    limit = { 
	    	OR = {
	    		religion_group = christian 
	    		religion_group = jewish_group
			}
		}
	    add_artifact = the_lily_crown
        add_artifact = noble_scepter
        add_artifact = engraved_sword
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = muslim 
	        	religion = west_african_pagan
	        	religion = west_african_pagan_reformed
	        }
	    }
	    add_artifact = engraved_dagger
        add_artifact = silver_bracelets
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = indian_group
	        	religion = bon
	        	religion = bon_reformed
	        }
	    }
	    add_artifact = engraved_dagger
        add_artifact = collar_of_pearls
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = zoroastrian_group
	        	religion = zun_pagan
	        	religion = zun_pagan_reformed
			}
		}
	    add_artifact = circlet_of_twilight
        add_artifact = silver_staff
	}
	else_if = {
	    limit = {
	       OR = {
	        	religion = norse_pagan
	        	religion = norse_pagan_reformed
	        }
	    }
	    add_artifact = iron_crown
        add_artifact = engraved_sword
	}
	else = {
	    add_artifact = engraved_crown
        add_artifact = ceremonial_axe
	}
}

give_goldsmith_artifacts_flag_good_effect = {
	if = {
	    limit = { 
	    	OR = {
	    		religion_group = christian 
	    		religion_group = jewish_group
			}
		}
	    add_artifact = crown_of_pearls
        add_artifact = ruby_scepter
        add_artifact = golden_sword
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = muslim 
	        	religion = west_african_pagan
	        	religion = west_african_pagan_reformed
	        }
	    }
	    add_artifact = bejeweled_dagger
        add_artifact = golden_bracelets
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = indian_group
	        	religion = bon
	        	religion = bon_reformed
	        }
	    }
	    add_artifact = bejeweled_dagger
        add_artifact = necklace_of_radiance
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = zoroastrian_group
	        	religion = zun_pagan
	        	religion = zun_pagan_reformed
			}
		}
	    add_artifact = circlet_of_the_heavens
        add_artifact = golden_staff
	}
	else_if = {
	    limit = {
	       OR = {
	        	religion = norse_pagan
	        	religion = norse_pagan_reformed
	        }
	    }
	    add_artifact = crown_of_the_sea
        add_artifact = golden_sword
	}
	else = {
	    add_artifact = amber_crown
        add_artifact = obsidian_axe
	}
}

give_goldsmith_artifacts_flag_expensive_effect = {
	if = {
	    limit = { 
	    	OR = {
	    		religion_group = christian 
	    		religion_group = jewish_group
			}
		}
	    add_artifact = crown_of_majesty
	    add_artifact = emerald_scepter
	    add_artifact = sword_of_heroes
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = muslim 
	        	religion = west_african_pagan
	        	religion = west_african_pagan_reformed
	        }
	    }
	    add_artifact = dagger_of_glory
	    add_artifact = ruby_bracelets
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = indian_group
	        	religion = bon
	        	religion = bon_reformed
	        }
	    }
	    add_artifact = dagger_of_glory
	    add_artifact = celestial_necklace
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = zoroastrian_group
	        	religion = zun_pagan
	        	religion = zun_pagan_reformed
			}
		}
	    add_artifact = circlet_of_the_heavens
	    add_artifact = staff_of_majesty
	}
	else_if = {
	    limit = {
	       OR = {
	        	religion = norse_pagan
	        	religion = norse_pagan_reformed
	        }
	    }
	    add_artifact = crown_of_crows
	    add_artifact = sword_of_heroes
	}
	else = {
	    add_artifact = heros_crown
	    add_artifact = axe_of_the_ancestors
	}
}

give_goldsmith_artifacts_flag_amazing_effect = {
	if = {
	    limit = { 
	    	OR = {
	    		religion_group = christian 
	    		religion_group = jewish_group
			}
		}
	    add_artifact = crown_of_majesty_2
	    add_artifact = emerald_scepter_2
	    add_artifact = sword_of_heroes_2
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = muslim 
	        	religion = west_african_pagan
	        	religion = west_african_pagan_reformed
	        }
	    }
	    add_artifact = dagger_of_glory_2
	    add_artifact = ruby_bracelets_2
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = indian_group
	        	religion = bon
	        	religion = bon_reformed
	        }
	    }
	    add_artifact = dagger_of_glory_2
	    add_artifact = celestial_necklace_2
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = zoroastrian_group
	        	religion = zun_pagan
	        	religion = zun_pagan_reformed
			}
		}
	    add_artifact = circlet_of_the_heavens_2
	    add_artifact = staff_of_majesty_2
	}
	else_if = {
	    limit = {
	       OR = {
	        	religion = norse_pagan
	        	religion = norse_pagan_reformed
	        }
	    }
	    add_artifact = crown_of_crows_2
	    add_artifact = sword_of_heroes_2
	}
	else = {
	    add_artifact = heros_crown_2
	    add_artifact = axe_of_the_ancestors_2
	}
}


give_weaponsmith_artifacts_flag_okay_effect = {
	if = {
	    limit = { 
	    	OR = {
	    		religion_group = christian 
	    		religion_group = jewish_group
			}
		}
	    add_artifact = the_lily_crown
        add_artifact = noble_scepter
        add_artifact = engraved_sword
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = muslim 
	        	religion = west_african_pagan
	        	religion = west_african_pagan_reformed
	        }
	    }
	    add_artifact = engraved_dagger
        add_artifact = silver_bracelets
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = indian_group
	        	religion = bon
	        	religion = bon_reformed
	        }
	    }
	    add_artifact = engraved_dagger
        add_artifact = collar_of_pearls
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = zoroastrian_group
	        	religion = zun_pagan
	        	religion = zun_pagan_reformed
			}
		}
	    add_artifact = circlet_of_twilight
        add_artifact = silver_staff
	}
	else_if = {
	    limit = {
	       OR = {
	        	religion = norse_pagan
	        	religion = norse_pagan_reformed
	        }
	    }
	    add_artifact = iron_crown
        add_artifact = engraved_sword
	}
	else = {
	    add_artifact = engraved_crown
        add_artifact = ceremonial_axe
	}
}

give_weaponsmith_artifacts_flag_good_effect = {
	if = {
	    limit = { 
	    	OR = {
	    		religion_group = christian 
	    		religion_group = jewish_group
			}
		}
	    add_artifact = crown_of_pearls
        add_artifact = ruby_scepter
        add_artifact = golden_sword
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = muslim 
	        	religion = west_african_pagan
	        	religion = west_african_pagan_reformed
	        }
	    }
	    add_artifact = bejeweled_dagger
        add_artifact = golden_bracelets
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = indian_group
	        	religion = bon
	        	religion = bon_reformed
	        }
	    }
	    add_artifact = bejeweled_dagger
        add_artifact = necklace_of_radiance
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = zoroastrian_group
	        	religion = zun_pagan
	        	religion = zun_pagan_reformed
			}
		}
	    add_artifact = circlet_of_the_heavens
        add_artifact = golden_staff
	}
	else_if = {
	    limit = {
	       OR = {
	        	religion = norse_pagan
	        	religion = norse_pagan_reformed
	        }
	    }
	    add_artifact = crown_of_the_sea
        add_artifact = golden_sword
	}
	else = {
	    add_artifact = amber_crown
        add_artifact = obsidian_axe
	}
}

give_weaponsmith_artifacts_flag_expensive_effect = {
	if = {
	    limit = { 
	    	OR = {
	    		religion_group = christian 
	    		religion_group = jewish_group
			}
		}
	    add_artifact = crown_of_majesty
	    add_artifact = emerald_scepter
	    add_artifact = sword_of_heroes
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = muslim 
	        	religion = west_african_pagan
	        	religion = west_african_pagan_reformed
	        }
	    }
	    add_artifact = dagger_of_glory
	    add_artifact = ruby_bracelets
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = indian_group
	        	religion = bon
	        	religion = bon_reformed
	        }
	    }
	    add_artifact = dagger_of_glory
	    add_artifact = celestial_necklace
	}
	else_if = {
	    limit = { 
	        OR = {
	        	religion_group = zoroastrian_group
	        	religion = zun_pagan
	        	religion = zun_pagan_reformed
			}
		}
	    add_artifact = circlet_of_the_heavens
	    add_artifact = staff_of_majesty
	}
	else_if = {
	    limit = {
	       OR = {
	        	religion = norse_pagan
	        	religion = norse_pagan_reformed
	        }
	    }
	    add_artifact = crown_of_crows
	    add_artifact = sword_of_heroes
	}
	else = {
	    add_artifact = heros_crown
	    add_artifact = axe_of_the_ancestors
	}
}

give_smith_artifacts_flag_okay_effect = {
	if = {
        limit = { FROM = { has_character_flag = weapon_sword } }
        add_artifact = sword_tier_1_new
        set_character_flag = sword_tier_1   
            new_artifact = {
            	set_name = artifact_name
            	set_description = artifact_description_smith_tier_1
            }
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_scimitar } }
        add_artifact = scimitar_tier_1_new
        set_character_flag = scimitar_tier_1   
        new_artifact = {
          	set_name = artifact_name
           	set_description = artifact_description_smith_tier_1
        }
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_lance } }
        add_artifact = lance_tier_1_new
		set_character_flag = lance_tier_1   
        new_artifact = {
            set_name = artifact_name
            set_description = artifact_description_smith_tier_1
        }
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_axe } }
        add_artifact = axe_tier_1_new
        set_character_flag = axe_tier_1   
        new_artifact = {
            set_name = artifact_name
            set_description = artifact_description_smith_tier_1
        }
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_mace } }
        add_artifact = mace_tier_1_new
        set_character_flag = mace_tier_1   
        new_artifact = {
        	set_name = artifact_name
        	set_description = artifact_description_smith_tier_1
        }
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_bow } }
        add_artifact = bow_tier_1_new
        set_character_flag = bow_tier_1   
        new_artifact = {
            set_name = artifact_name
            set_description = artifact_description_smith_tier_1
        }
    }
    if = {
        limit = { FROM = { has_character_flag = armor_set } }
        add_artifact = armor_tier_1
    }
}

give_smith_artifacts_flag_good_effect = {
	if = {
        limit = { FROM = { has_character_flag = weapon_sword } }
        add_artifact = sword_tier_2_new
        set_character_flag = sword_tier_2   
            new_artifact = {
            	set_name = artifact_name
            	set_description = artifact_description_smith_tier_2
            }
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_scimitar } }
        add_artifact = scimitar_tier_2_new
        set_character_flag = scimitar_tier_2   
        new_artifact = {
          	set_name = artifact_name
           	set_description = artifact_description_smith_tier_2
        }
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_lance } }
        add_artifact = lance_tier_2_new
		set_character_flag = lance_tier_2   
        new_artifact = {
            set_name = artifact_name
            set_description = artifact_description_smith_tier_2
        }
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_axe } }
        add_artifact = axe_tier_2_new
        set_character_flag = axe_tier_2   
        new_artifact = {
            set_name = artifact_name
            set_description = artifact_description_smith_tier_2
        }
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_mace } }
        add_artifact = mace_tier_2_new
        set_character_flag = mace_tier_2   
        new_artifact = {
        	set_name = artifact_name
        	set_description = artifact_description_smith_tier_2
        }
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_bow } }
        add_artifact = bow_tier_2_new
        set_character_flag = bow_tier_2   
        new_artifact = {
            set_name = artifact_name
            set_description = artifact_description_smith_tier_2
        }
    }
    if = {
        limit = { FROM = { has_character_flag = armor_set } }
        add_artifact = armor_tier_2
    }
}

give_smith_artifacts_flag_amazing_optionA_effect = {
	if = {
        limit = { FROM = { has_character_flag = weapon_sword } }
        add_artifact = sword_tier_4_heartseeker
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_scimitar } }
        add_artifact = scimitar_tier_4_golden
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_lance } }
        add_artifact = lance_tier_4_impaler
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_axe } }
        add_artifact = axe_tier_4_cleaver
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_mace } }
        add_artifact = mace_tier_4_foe_hammer
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_bow } }
        add_artifact = bow_tier_4_silent_wind
    }
    if = {
        limit = { FROM = { has_character_flag = armor_set } }
        add_artifact = armor_tier_4_guardian
    }
}

give_smith_artifacts_flag_amazing_optionB_effect = {
	if = {
        limit = { FROM = { has_character_flag = weapon_sword } }
        add_artifact = sword_tier_4_vengeance
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_scimitar } }
        add_artifact = scimitar_tier_4_fortune
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_lance } }
        add_artifact = lance_tier_4_trident
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_axe } }
        add_artifact = axe_tier_4_ravager
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_mace } }
        add_artifact = mace_tier_4_bone_breaker
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_bow } }
        add_artifact = bow_tier_4_lightning
    }
    if = {
        limit = { FROM = { has_character_flag = armor_set } }
        add_artifact = armor_tier_4_champion
    }
}

give_smith_artifacts_flag_amazing_optionC_effect = {
	if = {
        limit = { FROM = { has_character_flag = weapon_sword } }
        add_artifact = sword_tier_4_fury
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_scimitar } }
        add_artifact = scimitar_tier_4_conquest
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_lance } }
        add_artifact = lance_tier_4_piercer
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_axe } }
        add_artifact = axe_tier_4_marauder
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_mace } }
        add_artifact = mace_tier_4_shatterer
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_bow } }
        add_artifact = bow_tier_4_eagle
    }
    if = {
        limit = { FROM = { has_character_flag = armor_set } }
        add_artifact = armor_tier_4_warden
    }
}

give_smith_artifacts_flag_expensive_optionA_effect = {
	if = {
        limit = { FROM = { has_character_flag = weapon_sword } }
        add_artifact = sword_tier_3_heartseeker
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_scimitar } }
        add_artifact = scimitar_tier_3_golden
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_lance } }
        add_artifact = lance_tier_3_impaler
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_axe } }
        add_artifact = axe_tier_3_cleaver
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_mace } }
        add_artifact = mace_tier_3_foe_hammer
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_bow } }
        add_artifact = bow_tier_3_silent_wind
    }
    if = {
        limit = { FROM = { has_character_flag = armor_set } }
        add_artifact = armor_tier_3_guardian
    }
}

give_smith_artifacts_flag_expensive_optionB_effect = {
	if = {
        limit = { FROM = { has_character_flag = weapon_sword } }
        add_artifact = sword_tier_3_vengeance
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_scimitar } }
        add_artifact = scimitar_tier_3_fortune
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_lance } }
        add_artifact = lance_tier_3_trident
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_axe } }
        add_artifact = axe_tier_3_ravager
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_mace } }
        add_artifact = mace_tier_3_bone_breaker
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_bow } }
        add_artifact = bow_tier_3_lightning
    }
    if = {
        limit = { FROM = { has_character_flag = armor_set } }
        add_artifact = armor_tier_3_champion
    }
}

give_smith_artifacts_flag_expensive_optionC_effect = {
	if = {
        limit = { FROM = { has_character_flag = weapon_sword } }
        add_artifact = sword_tier_3_fury
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_scimitar } }
        add_artifact = scimitar_tier_3_conquest
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_lance } }
        add_artifact = lance_tier_3_piercer
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_axe } }
        add_artifact = axe_tier_3_marauder
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_mace } }
        add_artifact = mace_tier_3_shatterer
    }
    if = {
        limit = { FROM = { has_character_flag = weapon_bow } }
        add_artifact = bow_tier_3_eagle
    }
    if = {
        limit = { FROM = { has_character_flag = armor_set } }
        add_artifact = armor_tier_3_warden
    }
}


give_random_character_modifier_effect = {
	random_list = {
		100 = {
			trigger = {
				NOT = { has_character_modifier = aspiring_poet }
			}
			modifier = {
				factor = 2
				learning = 12
			}
			add_character_modifier = {
				name = aspiring_poet
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = aspiring_duelist }
			}
			modifier = {
				factor = 2
				martial = 12
			}
			modifier = {
				factor = 2
				OR = {
					duelist_skill_is_medium_group_trigger = yes
					duelist_skill_is_high_group_trigger = yes
				}
			}
			add_character_modifier = {
				name = aspiring_duelist
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = aspiring_hunter }
			}
			add_character_modifier = {
				name = aspiring_hunter
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = aspiring_falconer }
			}
			add_character_modifier = {
				name = aspiring_falconer
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = learning_advice }
			}
			add_character_modifier = {
				name = learning_advice
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = slept_in_church }
			}
			modifier = {
				factor = 2
				trait = drunkard
			}
			add_character_modifier = {
				name = slept_in_church
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = gambler }
			}
			add_character_modifier = {
				name = gambler
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = whoremaster }
			}
			modifier = {
				factor = 2
				trait = lustful
			}
			add_character_modifier = {
				name = whoremaster
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = good_deeds }
			}
			modifier = {
				factor = 1.5
				is_benevolent_trigger = yes
			}
			modifier = {
				factor = 1.5
				has_pleasant_personality_trigger = yes
			}
			add_character_modifier = {
				name = good_deeds
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = proving_bravery }
			}
			modifier = {
				factor = 2
				trait = brave
			}
			add_character_modifier = {
				name = proving_bravery
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = suspected_coward }
			}
			modifier = {
				factor = 0.5
				trait = brave
			}
			add_character_modifier = {
				name = suspected_coward
				years = 5
			}
		}
		5 = {
			trigger = {
				NOT = { has_character_modifier = speaking_in_tounges }
			}
			modifier = {
				factor = 4
				trait = lunatic
			}
			add_character_modifier = {
				name = speaking_in_tounges
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = good_times }
			}
			add_character_modifier = {
				name = good_times
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = good_hunt }
			}
			modifier = {
				factor = 2
				trait = hunter
			}
			add_character_modifier = {
				name = good_hunt
				years = 5
			}
		}
		5 = {
			trigger = {
				NOT = { has_character_modifier = epic_hangover }
			}
			modifier ={
				factor = 4
				trait = drunkard
			}
			add_character_modifier = {
				name = epic_hangover
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = weird_scholar }
			}
			modifier = {
				factor = 2
				learning = 12
			}
			add_character_modifier = {
				name = weird_scholar
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = comfort_of_lover }
			}
			trigger = {
				has_lover = yes
			}
			add_character_modifier = {
				name = comfort_of_lover
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = sleep_deprivation }
			}
			add_character_modifier = {
				name = sleep_deprivation
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = pet_cat }
			}
			add_character_modifier = {
				name = pet_cat
				years = 5
			}
			random_list = {
				25 = {
					trigger = {
						is_female = yes
					}
					add_character_modifier = {
	    				name = crazy_cat_lady
	    				years = 5
	    			}
				}
				25 = {
					trigger = {
						is_female = no
					}
					add_character_modifier = {
	    				name = crazy_cat_lord
	    				years = 5
	    			}
				}
				50 = {}
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = invigorated }
			}
			add_character_modifier = {
				name = invigorated
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = good_listener }
			}
			add_character_modifier = {
				name = good_listener
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = confident }
			}
			add_character_modifier = {
				name = confident
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = bad_person }
				is_benevolent_trigger = no
				has_pleasant_personality_trigger = no
			}
			modifier = {
				factor = 2
				OR = {
					is_evil_trigger = yes
					has_unpleasant_personality_trigger = yes
				}
			}
			add_character_modifier = {
				name = bad_person
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = pet_parrot }
			}
			add_character_modifier = {
				name = pet_parrot
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = pet_owl }
			}
			add_character_modifier = {
				name = pet_owl
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = taking_it_easy }
			}
			modifier = {
				factor = 2
				trait = slothful
			}
			add_character_modifier = {
				name = taking_it_easy
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = fell_into_the_river }
			}
			add_character_modifier = {
				name = fell_into_the_river
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = green_fingers }
			}
			add_character_modifier = {
				name = green_fingers
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = pet_house_dog }
			}
			add_character_modifier = {
				name = pet_house_dog
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = pet_hedgehog }
			}
			add_character_modifier = {
				name = pet_hedgehog
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = pet_otter }
			}
			add_character_modifier = {
				name = pet_otter
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = bad_nights_sleep }
			}
			add_character_modifier = {
				name = bad_nights_sleep
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = good_nights_sleep }
			}
			add_character_modifier = {
				name = good_nights_sleep
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = well_spoken }
			}
			modifier = {
				factor = 2
				diplomacy = 12
			}
			add_character_modifier = {
				name = well_spoken
				years = 5
			}
		}
		100 = {
			trigger = {
				NOT = { has_character_modifier = jumbling_words }
			}
			modifier = {
				factor = 2
				diplomacy < 8
			}
			add_character_modifier = {
				name = jumbling_words
				years = 5
			}
		}
		100 = {
			trigger = {
				has_injury_trigger = no
			}
			apply_random_minor_injury_effect = yes
		}
		0.001 = {
			#fallback
		}
	}
}

assign_random_nickname_effect = {
	random_list = {
		10 = {
			trigger = {
				trait = brave
			}
			random_list = {
				10 = {
					give_nickname = nick_the_brave
				}
				10 = {
					give_nickname = nick_the_fearless
				}
			}
		}
		10 = {
			give_nickname = nick_the_unlucky
		}
		10 = {
			give_nickname = nick_the_lucky
		}
		5 = {
			modifier = {
				factor = 4
				learning < 6
			}
			give_nickname = nick_the_clueless
		}
		10 = {
			modifier = {
				factor = 4
				OR = {
					is_evil_trigger = yes
					has_unpleasant_personality_trigger = yes
				}
			}
			give_nickname = nick_the_ill_tempered
		}
		10 = {
			modifier = {
				factor = 4
				OR = {
					has_pleasant_personality_trigger = yes
					is_pious_trigger = yes
				}
			}
			give_nickname = nick_the_affable
		}
		10 = {
			trigger = {
				age < 30
			}
			give_nickname = nick_the_youthful
		}
		5 = {
			modifier = {
				factor = 4
				is_attractive_trigger = yes
			}
			give_nickname = nick_the_beguiling
		}
		10 = {
			trigger = {
				trait = lustful
			}
			give_nickname = nick_the_lewd
		}
		5 = {
			modifier = {
				factor = 4
				trait = lustful
			}
			modifier = {
				factor = 2
				has_lover = yes
			}
			give_nickname = nick_the_unchaste
		}
		5 = {
			trigger = {
				uses_decadence = yes
				decadence = 50
			}
			modifier = {
				factor = 4
				decadence = 70
			}
			give_nickname = nick_the_decadent
		}
		10 = {
			trigger = {
				has_unpleasant_personality_trigger = yes
			}
			random_list = {
				10 = {
					give_nickname = nick_the_shrewd
				}
				10 = {
					give_nickname = nick_the_wily
				}
			}
		}
		10 = {
			trigger = {
				has_pleasant_personality_trigger = yes
			}
			give_nickname = nick_the_jolly
		}
		10 = {
			trigger ={
				has_pleasant_personality_trigger = yes
			}
			random_list = {
				10 = {
					give_nickname = nick_the_gracious
				}
				10 = {
					give_nickname = nick_the_kind
				}
				10 = {
					give_nickname = nick_the_good
				}
			}
		}
		10 = {
			trigger = {
				trait = patient
			}
			random_list = {
				10 = {
					give_nickname = nick_the_tenacious
				}
				10 = {
					give_nickname = nick_the_mule
				}
			}
		}
		5 = {
			modifier = {
				factor = 4
				has_mental_disorder_trigger = yes
			}
			give_nickname = nick_the_strange
		}
		10 = {
			trigger = {
				is_weak_trigger = yes
			}
			give_nickname = nick_the_clumsy
		}
		10 = {
			trigger = {
				is_impious_trigger = yes
			}
			give_nickname = nick_the_evil
		}
		10 = {
			trigger = {
				is_strong_trigger = yes
			}
			give_nickname = nick_the_strong
		}
		10 = {
			modifier = {
				factor = 2
				has_pleasant_personality_trigger = yes
			}
			give_nickname = nick_the_merry
		}
		10 = {
			modifier = {
				factor = 2
				has_pleasant_personality_trigger = yes
			}
			give_nickname = nick_the_gentle
		}
		10 = {
			trigger = {
				trait = proud
			}
			give_nickname = nick_the_proud
		}
		10 = {
			trigger = {
				trait = shy
			}
			give_nickname = nick_the_silent
		}
		10 = {
			trigger = {
				trait = chaste
			}
			give_nickname = nick_the_chaste
		}
		10 = {
			trigger = {
				is_attractive_trigger = yes
				is_female = no
			}
			random_list = {
				10 = {
					give_nickname = nick_the_handsome
				}
				10 = {
					give_nickname = nick_the_vain
				}
			}
		}
		10 = {
			trigger = {
				is_attractive_trigger = yes
				is_female = yes
			}
			random_list = {
				10 = {
					give_nickname = nick_the_fair
				}
				10 = {
					give_nickname = nick_the_vain
				}
				10 = {
					give_nickname = nick_the_flower
				}
			}
		}
		10 = {
			trigger = {
				is_unattractive_trigger = yes
			}
			random_list = {
				10 = {
					give_nickname = nick_the_hideous
				}
				10 = {
					give_nickname = nick_the_frog
				}
				10 = {
					give_nickname = nick_the_repulsive
				}
			}
		}
		10 = {
			trigger = {
				trait = lunatic
			}
			give_nickname = nick_the_mad
		}
		10 = {
			trigger = {
				trait = drunkard
			}
			give_nickname = nick_the_drunkard
		}
		10 = {
			trigger = {
				learning = 10
			}
			modifier = {
				factor = 2
				learning = 14
			}
			give_nickname = nick_the_wise
		}
		10 = {
			trigger = {
				is_pious_trigger = yes
			}
			random_list = {
				10 = {
					give_nickname = nick_the_pious 
				}
				10 = {
					give_nickname = nick_the_blessed 
				}
			}
		}
		10 = {
			give_nickname = nick_the_careless 
		}
		10 = {
			trigger = {
				age < 25
			}
			give_nickname = nick_the_young 
		}
		10 = {
			trigger = {
				age = 50
			}
			give_nickname = nick_the_old 
		}
		10 = {
			trigger = {
				learning = 10
			}
			random_list = {
				10 = {
					give_nickname = nick_the_scholar
				}
				10 = {
					give_nickname = nick_the_understanding
				} 
				10 = {
					give_nickname = nick_the_healer 
				}
			}
		}
		10 = {
			trigger = {
				combat_rating = 10
			}
			give_nickname = nick_the_oakskin
		}
		10 = {
			give_nickname = nick_the_jittery
		}
		10 = {
			trigger = {
				trait = slothful
			}
			give_nickname = nick_the_sleepy
		}
		10 = {
			trigger = {
				base_health < 3
			}
			random_list = {
				10 = {
					give_nickname = nick_butter_teeth
				}
				10 = {
					give_nickname = nick_the_toothless
				}
			}
		}
		10 = {
			trigger = {
				trait = craven
			}
			random_list = {
				10 = {
					give_nickname = nick_the_cowardly
				}
				10 = {
					give_nickname = nick_the_squirmy
				}
			}
		}
		10 = {
			trigger = {
				trait = paranoid
			}
			give_nickname = nick_the_frantic 
		}
		10 = {
			give_nickname = nick_the_dry_throat 
		}
		10 = {
			trigger = {
				NOR = {
					trait = genius
					trait = quick
				}
			}
			modifier = {
				factor = 4
				OR = {
					trait = imbecile
					trait = slow
				}
			}
			random_list = {
				10 = {
					give_nickname = nick_the_thin_minded
				}
				10 = {
					give_nickname = nick_the_forgetful
				}
			}
		}
		10 = {
			give_nickname = nick_the_messy 
		}
		10 = {
			give_nickname = nick_the_feeble
		}
		10 = {
			trigger = {
				NOT = { trait = gregarious }
			}
			modifier = {
				factor = 2
				trait = shy
			}
			give_nickname = nick_the_recluse
		}
		10 = {
			trigger = {
				trait = wroth
			}
			give_nickname = nick_the_short_tempered
		}
		10 = {
			give_nickname = nick_the_red_cheeks
		}
		10 = {
			give_nickname = nick_the_blushing
		}
		10 = {
			trigger = {
				NOT = {
					trait = content
				}
			}
			give_nickname = nick_the_whiner
		}
		10 = {
			trigger = {
				trait = deceitful
			}
			give_nickname = nick_the_liar
		}
		10 = {
			give_nickname = nick_the_twitchy
		}
	}
}
