namespace = RIP

province_event = { # Dancing Plague Starts
	id = RIP.4000
	hide_window = yes

	is_triggered_only = yes
	
	trigger = {
		disease = dancing_plague
	}

	immediate = {
		save_event_target_as = dancing_plague_outbreak_location
		owner = {
			narrative_event = { id = RIP.4001 }
			any_liege = {
				limit = {
					NOT = { character = ROOT }
				}
				narrative_event = { id = RIP.4001 }
			}
		}
	}
}

narrative_event = { # Dancing Plague Notification
	id = RIP.4001
	title = EVTNAME_RIP_4001
	picture = GFX_evt_dancing
	border = GFX_event_narrative_frame_religion

	desc = EVTDESC_RIP_4001

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_RIP_4001
	}
}

character_event = { # Dancing looks inviting, join in?
	id = RIP.4002
	desc = EVTDESC_RIP_4002
	picture = GFX_evt_dancing
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	

	option = {
		name = EVTOPTA_RIP_4002
		
		ai_chance = {
			factor = 1
		}
		
		custom_tooltip = { text = join_in_dance }
		hidden_tooltip = {
			if = {
				limit = {
					any_courtier_or_vassal = {
						liege = { character = ROOT }
						has_minor_title = title_court_physician
					}
				}
				character_event = { id = RIP.4003 days = 5 random = 10 } # Court Physician recommends you rest.
			}
			if = {
				limit = {
					NOT = {
						any_courtier_or_vassal = {
							liege = { character = ROOT }
							has_minor_title = title_court_physician
						}
					}
				}
				if = {
					limit = {
						has_character_flag = got_dancing_plague
					}
					character_event = { id = RIP.4005 days = 5 random = 10 } # Go out into the streets and get the Dancing Plague!
				}
				if = {
					limit = {
						NOT = { has_character_flag = got_dancing_plague }
						is_landed = yes
					}
					character_event = { id = RIP.4004 days = 5 random = 10 } # Go out into the streets and become Dancing Queen!
				}
			}	
		}
	}
	
	option = {
		name = EVTOPTB_RIP_4002
		
		ai_chance = {
			factor = 0
		}
		
		custom_tooltip = { text = refuse_to_join_in_dance }
		hidden_tooltip = {
			if = {
				limit = {
					has_character_flag = got_dancing_plague
				}
				random_list = {
					50 = { # Nothing happens.
						clr_character_flag = got_dancing_plague
						set_character_flag = immune_dancing_plague
					}
					50 = { # Can't resist dancing!
						modifier = {
							factor = 2
							trait = gluttonous
						}
						modifier = {
							factor = 2
							trait = hedonist
						}
						modifier = {
							factor = 0.5
							trait = temperate
						}
						modifier = {
							factor = 0.5
							trait = gardener
						}
						
						character_event = { id = RIP.4005 days = 10 random = 10 }
						set_character_flag = forced_to_dance
					}
				}
			}
		}
	}
}

character_event = { # Court Physician recommends rest.
	id = RIP.4003
	desc = EVTDESC_RIP_4003
	picture = GFX_evt_poke_king_in_chest
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	immediate = {
		random_courtier_or_vassal = {
			limit = {
				liege = { character = ROOT }
				has_minor_title = title_court_physician
			}
			save_event_target_as = target_physician
		}
	}

	option = { # Agree
		name = EVTOPTA_RIP_4003
		custom_tooltip = { text = refuse_to_join_in_dance }
		
		event_target:target_physician = {
			opinion = {
				modifier = opinion_glad
				who = ROOT
				years = 5
			}
		}
		
		hidden_tooltip = {
			if = {
				limit = {
					has_character_flag = got_dancing_plague
				}
				random_list = {
					50 = { # Nothing happens.
						clr_character_flag = got_dancing_plague
						set_character_flag = immune_dancing_plague
					}
					50 = { # No, I must dance!
						modifier = {
							factor = 2
							trait = gluttonous
						}
						modifier = {
							factor = 2
							trait = hedonist
						}
						modifier = {
							factor = 0.5
							trait = temperate
						}
						modifier = {
							factor = 0.5
							trait = gardener
						}
						
						character_event = { id = RIP.4005 days = 5 random = 10 }
						set_character_flag = forced_to_dance
					}
				}
			}
		}
	}
	
	option = { # No! I want to dance.
		name = EVTOPTB_RIP_4003
		custom_tooltip = { text = join_in_dance }
		
		event_target:target_physician = {
			opinion = {
				modifier = opinion_irritated
				who = ROOT
				years = 5
			}
		}
		
		hidden_tooltip = {
			if = {
				limit = {
					has_character_flag = got_dancing_plague
				}
				character_event = { id = RIP.4005 days = 5 random = 10 } # Go out into the streets and get the Dancing Plague!
			}
			if = {
				limit = {
					NOT = { has_character_flag = got_dancing_plague }
					is_landed = yes
				}
				character_event = { id = RIP.4004 days = 5 random = 10 } # Go out into the streets and become Dancing Queen!
			}
		}
	}
	
}

character_event = { # Become Dancing Queen!
	id = RIP.4004
	desc = EVTDESC_RIP_4004
	picture = GFX_evt_dancing
	border = GFX_event_normal_frame_religion
	
	hide_from = yes

	is_triggered_only = yes

	option = {
		name = EVTOPTA_RIP_4004
		
		prestige = 50
		
		if = {
			limit = { trait = stressed }
			remove_trait = stressed
		}
		if = {
			limit = { trait = depressed }
			remove_trait = depressed
		}
		
		if = {
			limit = {
				is_female = yes
			}
			add_character_modifier = {
				modifier = dancing_queen
				years = 5
			}
		}
		if = {
			limit = {
				is_female = no
			}
			add_character_modifier = {
				modifier = dancing_king
				years = 5
			}
		}
	}
}

character_event = { # Get Dancing Plague!
	id = RIP.4005
	picture = GFX_evt_dancing
	border = GFX_event_normal_frame_religion
	
	hide_from = yes

	is_triggered_only = yes
	
	desc = {
		trigger = {
			NOT = { has_character_flag = forced_to_dance }
		}
		text = EVTDESCA_RIP_4005
	}
	desc = {
		trigger = {
			has_character_flag = forced_to_dance
		}
		text = EVTDESCB_RIP_4005
	}

	option = {
		name = EVTOPTA_RIP_4005
		
		add_trait = dancing_plague
		
		hidden_tooltip = {
			random_list = {
				45 = { # Recover
					modifier = {
						factor = 1.5
						is_strong_trigger = yes
					}
					modifier = {
						factor = 0.5
						trait = infirm
					}
					character_event = { id = RIP.4006 days = 90 random = 20 }
				}
				40 = { # It gets worse...
					modifier = {
						factor = 1.5
						trait = diligent
					}
					modifier = {
						factor = 50
						is_unimportant_trigger = yes
					}
					character_event = { id = RIP.4007 days = 10 random = 10 }
				}
				15 = { # Your leg breaks!
					modifier = {
						factor = 0
						trait = one_legged
					}
					modifier = {
						factor = 3
						is_weak_trigger = yes
					}
					character_event = { id = RIP.4008 days = 30 random = 10 }
				}
			}
		}
	}
}

character_event = { # Recover From the Dancing Plague
	id = RIP.4006
	desc = EVTDESC_RIP_4006
	picture = GFX_evt_dancing
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_RIP_4006
		
		remove_trait = dancing_plague
		if = {
			limit = {
				has_character_modifier = cant_stop_dancing
			}
			remove_character_modifier = cant_stop_dancing
		}
		
		clr_character_flag = got_dancing_plague
		set_character_flag = immune_dancing_plague
		
	}
}

character_event = { # Dancing Plague gets worse...
	id = RIP.4007
	desc = EVTDESC_RIP_4007
	picture = GFX_evt_dancing
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_RIP_4007
		
		add_character_modifier = {
			modifier = cant_stop_dancing
			duration = -1
		}
		
		hidden_tooltip = {
			character_event = { id = RIP.4006 days = 90 random = 20 }
		}
		
	}
}

character_event = { # Dance until your leg breaks.
	id = RIP.4008
	desc = EVTDESC_RIP_4008
	picture = GFX_evt_dancing
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA_RIP_4008
		
		remove_trait = dancing_plague
		if = {
			limit = {
				has_character_modifier = cant_stop_dancing
			}
			remove_character_modifier = cant_stop_dancing
		}
		
		clr_character_flag = got_dancing_plague
		set_character_flag = immune_dancing_plague
		
		add_trait = one_legged
		add_trait = severely_injured
		hidden_tooltip = {
			character_event = { id = RIP.11503 } #Notify one-legged
			resolve_severely_injured_effect = yes
		}
	
	}
}