﻿@default_tile_multiplier = 0.009702

smallpox = {
	trait = smallpox
	color = { 88 12 31 }
	priority = 3

	shader_data = {
		strength = 0.8
		edge_fade = 0.25
		tile_multiplier = 0.004702
		texture_index = 0
		channel = alpha
	}

	name = {
		first_valid = {
			triggered_desc = {
				trigger = {
					outbreak_intensity = apocalyptic
					outbreak_province = province:3045
				}
				desc = epidemic_bonifacy_gift
			}
			triggered_desc = {
				trigger = {
					outbreak_intensity = apocalyptic
					outbreak_province = province:7596
				}
				desc = epidemic_raqguul_plague
			}
			random_valid = {
				triggered_desc = {
					trigger = {
						outbreak_intensity = apocalyptic
						outbreak_province = {
							geographical_region = ghw_region_egypt
							county.faith.religion = { is_in_family = rf_abrahamic }
						}
					}
					desc = epidemic_eleventh_plague
				}
				desc = epidemic_rulers_pox
				desc = epidemic_titled_rulers_pox
				desc = epidemic_animal_pox # Monkeypox, chickenpox and the like
				desc = epidemic_realm_pox
				desc = epidemic_holder_pox
				desc = epidemic_culture_pox
				desc = epidemic_location_pox
			}
			desc = trait_smallpox
		}
	}
	
	on_start = {
		# LEGITIMACY LOSS FROM EPIDEMIC OUTBREAK
		epidemic_outbreak_legitimacy_effect = { PROVINCE = root.outbreak_province }
	}

	on_monthly = {
		trigger_event = {
			on_action = epidemic_ongoing_events
		}
	}

	character_infection_chance = {
		value = character_infection_chance_default_value
	}

	can_infect_character = {
		can_contract_disease_trigger = { DISEASE = smallpox }
		immune_to_epidemic = { EPIDEMIC = scope:epidemic }
	}

	on_character_infected = {
		contract_disease_notify_effect = { DISEASE = smallpox }
		if = {
			limit = {
				is_commanding_army = yes
			}
			trigger_event = epidemic_events.0001 #we infect your army
		}
	}

	infection_levels = {
		10 = {
			province_modifier = {
				county_opinion_add = -2
				epidemic_travel_danger = 10
				development_decline = -1
			}	
		}
		50 = {
			province_modifier = {
				county_opinion_add = -3
				epidemic_travel_danger = 20
				development_decline = -2
			}	
		}
		80 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.1
				supply_limit_mult = -0.2
				county_opinion_add = -5
				epidemic_travel_danger = 30
				development_decline = -3
			}
		}
	}

	outbreak_intensities = {
		minor = {
			outbreak_chance = {
				value = outbreak_chance_minor_default_value
				multiply = outbreak_chance_minor_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				
				### NO DLC - We increase the chance to make up for the locked diseases ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					multiply = 1
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 2 7 } #LODfix { 15 30 }

			infection_duration = {
				months = { 6 8 }
			}

			infection_progress_duration = {
				days = { 80 100 }
			}

			infection_recovery_duration = {
				days = { 15 22 }
			}
		}

		major = {
			outbreak_chance = {
				value = outbreak_chance_major_default_value
				multiply = outbreak_chance_major_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				
				### NO DLC - We increase the chance to make up for the locked diseases ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					multiply = 1.5
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 60 100 } #LODfix { 45 70 }

			infection_duration = {
				months = { 10 20 }
			}

			infection_progress_duration = {
				days = { 40 60 }
			}

			infection_recovery_duration = {
				days = 25
			}
		}

		apocalyptic = {
			outbreak_chance = {
				value = outbreak_chance_apocalyptic_default_value
				multiply = outbreak_chance_apocalyptic_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				
				### NO DLC - We increase the chance to make up for the locked diseases ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					multiply = 1
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 195 500 } #LODfix { 120 180 }

			infection_duration = {
				months = { 22 42 }
			}
			
			infection_progress_duration = {
				days = { 15 20 }
			}

			infection_recovery_duration = {
				days = { 30 50 }
			}
		}
	}
	
	on_province_infected = {
		county = {
			apply_infection_development_loss = { BASE = 5 }
		}
		cant_touch_this_achievement_effect = yes
	}
	
	on_province_recovered = {
		county = {
			remove_isolated_capital_modifiers_effect = yes
		}
		add_to_variable_list = {
			name = epidemic_cooldown
			target = scope:epidemic.epidemic_type
			years = 50
		}
		set_variable = {
			name = epidemic_cooldown_general
			years = 15
		}
		# Prosperity event
		plague_recovery_event_effect = yes
	}
}

bubonic_plague = {
	trait = bubonic_plague
	color = black
	priority = 5

	shader_data = {
		strength = 0.8
		edge_fade = 0.4
		tile_multiplier = 0.005
		texture_index = 0
		channel = red
	}

	name = {
		first_valid = {
			triggered_desc = {
				trigger = {
					outbreak_province = province:1580
					outbreak_intensity = apocalyptic
				}
				desc = epidemic_mitcheldean_malaise
			}
			triggered_desc = {
				trigger = {
					outbreak_province = province:8748
					outbreak_intensity = apocalyptic
				}
				desc = epidemic_green_death
			}
			triggered_desc = {
				trigger = {
					outbreak_intensity = apocalyptic
				}
				desc = epidemic_black_death
			}
			triggered_desc = {
				trigger = {
					has_ep3_dlc_trigger = yes 
					outbreak_province.county.holder = {
						primary_title = title:e_roman_empire
						any_owned_story = { story_type = ep3_story_cycle_restoring_rome }
					}
				}
				desc = epidemic_ruler_plague
			}
			triggered_desc = {
				trigger = {
					OR = {
						outbreak_province.county.faith = faith:catholic
						outbreak_province.county.faith = faith:orthodox
						outbreak_province.county.faith = faith:nestorian
						outbreak_province.county.faith = faith:coptic
						outbreak_province.county.faith = faith:armenian_apostolic
						outbreak_province.county.faith = faith:insular_celtic
					}
				}
				desc = epidemic_random_saint_plague
			}
			triggered_desc = {
				trigger = {
					outbreak_intensity = major
				}
				desc = epidemic_reapers_will
			}
			triggered_desc = {
				trigger = {
					outbreak_intensity = major
				}
				desc = epidemic_reapers_due
			}
			triggered_desc = {
				trigger = {
					outbreak_intensity = major
				}
				desc = epidemic_wicked_blight
			}
			random_valid = {
				desc = epidemic_realm_plague
				desc = epidemic_culture_plague
				desc = epidemic_location_plague
				desc = epidemic_ruler_plague
				desc = epidemic_titled_ruler_plague
				desc = epidemic_evil_god_plague
				desc = epidemic_bubonic_plague
			}
		}
	}
	
	on_start = {
		if = {
			limit = {
				outbreak_intensity = apocalyptic
			}

			set_global_variable = black_death_happened

			set_global_variable = {
				name = black_death
				value = root
			}
		}
		#else_if = { #TODO_CE1 remove debug
		#	limit = { NOT = { has_global_variable = plague_happened } }
		#	set_global_variable = {
		#		name = plague_happened
		#		value = 1
		#	}
		#}
		#else = {
		#	change_global_variable = {
		#		name = plague_happened
		#		add = 1
		#	}
		#}


		# LEGITIMACY LOSS FROM EPIDEMIC OUTBREAK
		epidemic_outbreak_legitimacy_effect = { PROVINCE = root.outbreak_province }
	}

	on_end = {
		if = {
			limit = {
				outbreak_intensity = apocalyptic
			}
			remove_global_variable = black_death
		}
	}
	
	on_monthly = {
		trigger_event = {
			on_action = epidemic_ongoing_events
		}
	}

	character_infection_chance = {
		value = character_infection_chance_default_value
		multiply = 0.02 #The only way we can make it not kill every single character in the game
	}

	can_infect_character = {
		can_contract_disease_trigger = { DISEASE = bubonic_plague }
		immune_to_epidemic = { EPIDEMIC = scope:epidemic }
	}

	on_character_infected = {
		contract_disease_notify_effect = { DISEASE = bubonic_plague }
	}

	infection_levels = {
		10 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.6
				development_decline = -3
				levy_reinforcement_rate = -0.3
				levy_size = -0.25
				supply_limit_mult = -0.2
				county_opinion_add = -10
				epidemic_travel_danger = 25
			}	
		}
		50 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.8
				development_decline = -6
				levy_reinforcement_rate = -0.5
				levy_size = -0.4
				supply_limit_mult = -0.5
				county_opinion_add = -25
				epidemic_travel_danger = 40
			}	
		}
		80 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.8
				development_decline = -8
				levy_reinforcement_rate = -1
				levy_size = -0.5
				supply_limit_mult = -1
				county_opinion_add = -25
				epidemic_travel_danger = 60
			}
		}
	}

	outbreak_intensities = {
		minor = {
			outbreak_chance = {
				value = outbreak_chance_minor_default_value
				multiply = outbreak_chance_minor_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				multiply = 0.0005 #should almost never be minor
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 140 280 } # Was max_provinces = { 100 200 }

			infection_duration = {
				months = { 6 12 }
			}

			infection_progress_duration = {
				days = { 40 60 }
			}

			infection_recovery_duration = {
				days = { 25 35 }
			}
		}

		major = {
			outbreak_chance = {
				value = outbreak_chance_major_default_value
				multiply = outbreak_chance_major_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				multiply = 0.005 #should almost never be major
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}

			max_provinces = { 420 700 } # Was max_provinces = { 300 500 }

			infection_duration = {
				months = { 12 24 }
			}

			infection_progress_duration = {
				days = { 25 35 }
			}

			infection_recovery_duration = {
				days = { 50 70 }
			}
		}

		apocalyptic = { #The Black Death
			# We trigger the event specially for Black Death
			notification = {
				global = yes
				holder_event = ""
				liege_event = ""
				realm_event = ""
			}
			
			outbreak_chance = {
				value = {
					value = outbreak_chance_black_plague_default_value
					multiply = outbreak_chance_black_plague_mult_value
					multiply = recent_epidemics_outbreak_mult_value
				}
				if = {
					limit = {
						current_date >= 1346.1.1
						has_game_rule = bd_occurrence_historical
						NOT = {
							has_global_variable = black_death_happened
						}
						geographical_region = world_central_asia
					}
					add = 100
				}

				if = {
					limit = {
						# Currently happening
						has_global_variable = black_death
					}
					value = 0
				}
				if = {
					limit = { #it can only happen once per game
						has_global_variable = black_death_happened
						has_game_rule = bd_frequency_once
					}
					value = 0
				}
				if = {
					limit = { #it can never happen
						has_game_rule = bd_frequency_never
					}
					value = 0
				}

				#Historical exemption
				if = {
					limit = {
						has_game_rule = bd_occurrence_historical
						OR = {
							current_date < 1346.1.1
							NOT = {
								geographical_region = world_central_asia
							}
						}
					}
					value = 0
				}
				multiply = 0.1

			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value

				#Exclusions for historical Milan and Poland, husariaaaa
				if = {
					limit = {
						has_game_rule = bd_occurrence_historical
						OR = {
							#MB+
							# geographical_region = ghw_region_poland
							# geographical_region = custom_polabia
							geographical_region = world_tibet
							county.duchy = title:d_lombardia
							# county.duchy = title:d_aragon
							# county.duchy = title:d_armagnac
							# county.duchy = title:d_bohemia
							
							#MB - Mainly areas that weren't heavily impacted just like Poland and other areas Paradox had above (which did get impacted by the plague just not as extensively).
							geographical_region = world_japan					#No evidence it reached Japan
							geographical_region = custom_southern_subsahara 	#Archaeologists and historians have long assumed that the plague didn't make it across the Sahara Desert though that's changed in recent years. Will make it so it only impacts the northern half of the sub-Sahara where the major empires and kingdoms were and down the Niger River towards Nri
							geographical_region = world_greater_nusantara 		#Controversial whether or not the Black Death impacted Southeast Asia and played a part in the weakening of the Khmer Empire but I can find nothing on it impacting Nusantara. Probably was just spared due to climate. 
							geographical_region = custom_southeast_asia_plague	#Still let's keep it out of the dense jungle areas that weren't really controlled by the surrounding empires and kingdoms
							geographical_region = custom_desert_plague 			#Inner Arabia was unlikely heavily impacted by the plague
							geographical_region = custom_northern_plague		#Keep it out of northern Scandinavia and parts of Siberia and northern steppe
							geographical_region = custom_mountains_plague		#Mountainous regions not heavily impacted by the plague
							geographical_region = custom_easteurope_plague		#Mainly to consolidate Paradox's regions. Also edited to include some specific counties such as Brugge and Magdeburg
							
							county.duchy = title:d_iceland						#Was remote enough that is wasn't impacted till later epidemics. 
							#/MB+
						}
					}
					multiply = 0.02
				}				
			}
			max_provinces = { 9100 10150 } #MB has 13945 used provinces compared to the base games 9660 though in both 2-3k are wasteland/sea tiles so no need to get to the max provinces. Added more limitations above for historical spread. # Was max_provinces = { 6500 7250 }

			infection_duration = {
				months = { 24 48 }
			}
			
			infection_progress_duration = {
				days = { 5 9 }
			}

			infection_recovery_duration = {
				days = { 80 120 }
			}
		}
	}
	
	on_province_infected = {
		county = {
			apply_infection_development_loss = { BASE = 10 }
		}
		every_player = {
			if = {
				limit = {
					NOR = {
						any_owned_story = {
							story_type = story_cycle_black_death
						}
						has_character_flag = black_death_splash #black plague is in your realm
					}
				}
				create_story = story_cycle_black_death
				trigger_event = { #time-based fallback to notify the players that the black death is here.
					id = epidemic_events.5999
					years = { 4 6 } #Average time for Black Death to move from Siberia to Europe
				}
			}
		}
		every_player = {
			if = {
				limit = {
					has_dlc_feature = legends_of_the_dead
					is_landless_ruler = yes
					location = {
						any_province_epidemic = {
							epidemic_type.epidemic_trait = trait:bubonic_plague
							outbreak_intensity = apocalyptic
						}
					}
				}
				trigger_event = epidemic_events.6000
			}
		}
		cant_touch_this_achievement_effect = yes
	}
	
	on_province_recovered = {
		county = {
			remove_isolated_capital_modifiers_effect = yes
		}
		add_to_variable_list = {
			name = epidemic_cooldown
			target = scope:epidemic.epidemic_type
			years = 50
		}
		set_variable = {
			name = epidemic_cooldown_general
			years = 15 
		}
		# Prosperity event
		plague_recovery_event_effect = yes
	}
}

typhus = {
	trait = typhus
	color = { 37 90 57 }
	priority = 4

	shader_data = {
		strength = 0.6
		edge_fade = 0.25
		tile_multiplier = 0.01
		texture_index = 1
		channel = red
	}

	name = {
		first_valid = {
			triggered_desc = {
				trigger = {
					outbreak_intensity = apocalyptic
					outbreak_province = province:4921
				}
				desc = epidemic_bydgoszczanka
			}
			triggered_desc = {
				trigger = {
					outbreak_intensity = apocalyptic
					outbreak_province = province:3199
				}
				desc = epidemic_torunianka
			}
			triggered_desc = {
				trigger = {
					outbreak_intensity = apocalyptic
					outbreak_province = province:1527
				}
				desc = epidemic_penge_plague
			}
			random_valid = {
				triggered_desc = {
					trigger = {
						OR = {
							outbreak_intensity = apocalyptic
							outbreak_intensity = major
						}
					}
					desc = epidemic_rulers_fever
				}
				triggered_desc = {
					trigger = {
						OR = {
							outbreak_intensity = apocalyptic
							outbreak_intensity = major
						}
					}
					desc = epidemic_titled_rulers_fever
				}
				triggered_desc = {
					trigger = {
						OR = {
							outbreak_intensity = apocalyptic
							outbreak_intensity = major
						}
					}
					desc = epidemic_realm_fever
				}
				triggered_desc = {
					trigger = {
						OR = {
							outbreak_intensity = apocalyptic
							outbreak_intensity = major
						}
					}
					desc = epidemic_devils_fever
				}
				triggered_desc = {
					trigger = {
						outbreak_intensity = apocalyptic
						outbreak_province = {
							geographical_region = ghw_region_egypt
							county.faith.religion = { is_in_family = rf_abrahamic }
						}
					}
					desc = epidemic_eleventh_plague
				}
				desc = epidemic_camp_fever
				desc = epidemic_province_fever
				desc = epidemic_province_sweats
				desc = epidemic_culture_sweats
				desc = epidemic_terrain_fever
				desc = epidemic_famine_fever
				desc = epidemic_spotted_fever
			}
			desc = trait_typhus
		}
	}
	
	on_start = {
		# LEGITIMACY LOSS FROM EPIDEMIC OUTBREAK
		epidemic_outbreak_legitimacy_effect = { PROVINCE = root.outbreak_province }
	}
	
	on_monthly = {
		trigger_event = {
			on_action = epidemic_ongoing_events
		}
	}
	
	character_infection_chance = {
		value = character_infection_chance_default_value
		if = {
			limit = {
				is_commanding_army = yes
			}
			multiply = 4
		}
	}

	can_infect_character = {
		can_contract_disease_trigger = { DISEASE = typhus }
		immune_to_epidemic = { EPIDEMIC = scope:epidemic }
	}

	on_character_infected = {
		contract_disease_notify_effect = { DISEASE = typhus }
	}

	infection_levels = {
		10 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.3
				development_decline = -1
				levy_reinforcement_rate = -0.2
				county_opinion_add = -2
				epidemic_travel_danger = 20
			}	
		}
		50 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.4
				development_decline = -2
				levy_reinforcement_rate = -0.2
				garrison_size = -0.1
				county_opinion_add = -3
				epidemic_travel_danger = 30
			}	
		}
		80 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.5
				development_decline = -3
				levy_reinforcement_rate = -0.2
				garrison_size = -0.2
				county_opinion_add = -5
				epidemic_travel_danger = 40
			}
		}
	}

	outbreak_intensities = {
		minor = {
			outbreak_chance = {
				value = outbreak_chance_minor_default_value
				multiply = outbreak_chance_minor_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				
				### NO DLC - We increase the chance to make up for the locked diseases ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					multiply = 1
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 2 4 } #LODfix { 15 20 } #highly localised

			infection_duration = {
				months = { 6 12 }
			}

			infection_progress_duration = {
				days = 100
			}

			infection_recovery_duration = {
				days = 30
			}
		}

		major = {
			outbreak_chance = {
				value = outbreak_chance_major_default_value
				multiply = outbreak_chance_major_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				multiply = 0.75
				
				### NO DLC - We increase the chance to make up for the locked diseases ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					multiply = 1
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 25 40 } #LODfix { 20 30 }

			infection_duration = {
				months = { 12 24 }
			}

			infection_progress_duration = {
				days = { 45 55 }
			}

			infection_recovery_duration = {
				days = { 28 32 }
			}
		}

		apocalyptic = {
			outbreak_chance = {
				value = outbreak_chance_apocalyptic_default_value
				multiply = outbreak_chance_apocalyptic_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				multiply = 0.5
				
				### NO DLC - We increase the chance to make up for the locked diseases ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					multiply = 1
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 55 115 } #LODfix { 40 60 }

			infection_duration = {
				months = { 26 54 }
			}
			
			infection_progress_duration = {
				days = { 15 22 }
			}

			infection_recovery_duration = {
				days = { 28 36 }
			}
		}
	}
	
	on_province_infected = {
		county = {
			apply_infection_development_loss = { BASE = 5 }
		}
		cant_touch_this_achievement_effect = yes
	}
	
	on_province_recovered = {
		county = {
			remove_isolated_capital_modifiers_effect = yes
		}
		add_to_variable_list = {
			name = epidemic_cooldown
			target = scope:epidemic.epidemic_type
			years = 50
		}
		set_variable = {
			name = epidemic_cooldown_general
			years = 15 
		}
		# Prosperity event
		plague_recovery_event_effect = yes
	}
}

consumption = { #Tuberculosis
	trait = consumption
	color = { 84 171 176 }
	priority = 1

	shader_data = {
		strength = 0.35
		edge_fade = 0.28
		tile_multiplier = 0.00538
		texture_index = 0
		channel = green
	}

	name = {
		first_valid = {
			triggered_desc = {
				trigger = {
					outbreak_intensity = apocalyptic
					outbreak_province = province:527
				}
				desc = epidemic_napolna_zaraza
			}
			triggered_desc = {
				trigger = {
					outbreak_intensity = apocalyptic
					outbreak_province = province:369
				}
				desc = epidemic_gannholm_grievance
			}
			random_valid = {
				triggered_desc = {
					trigger = {
						OR = {
							outbreak_intensity = apocalyptic
							outbreak_intensity = major
						}
						outbreak_province = {
							county.faith.religion = { is_in_family = rf_abrahamic }
						}
					}
					desc = epidemic_curse_of_canaan # Named for a section in the Old Testament
				}
				triggered_desc = {
					trigger = {
						outbreak_province = {
							geographical_region = world_india
						}
					}
					desc = epidemic_yaksma
				}
				triggered_desc = {
					trigger = {
						outbreak_province = {
							county.culture = {
								OR = {
									has_cultural_pillar = heritage_chinese
									has_cultural_pillar = language_chinese
								}
							}
						}
					}
					desc = epidemic_shizhai
				}
				triggered_desc = {
					trigger = {
						outbreak_province = {
							county.faith.religion = {
								is_in_family = rf_pagan
								NOT = { this = religion:north_african_religion } # Canary islanders believed dogs were sacred
							}
						}
					}
					desc = epidemic_demon_dog_disease
				}
				triggered_desc = {
					trigger = {
						OR = {
							outbreak_intensity = apocalyptic
							outbreak_intensity = major
						}
					}
					desc = epidemic_titles_evil #King's evil
				}
				triggered_desc = {
					trigger = {
						outbreak_intensity = apocalyptic
						outbreak_province = {
							geographical_region = ghw_region_egypt
							county.faith.religion = { is_in_family = rf_abrahamic }
						}
					}
					desc = epidemic_eleventh_plague
				}
				desc = epidemic_cold_humor
				desc = epidemic_cold_humor
				desc = epidemic_white_plague
				desc = epidemic_realm_flu
				desc = epidemic_realm_coughs
				desc = epidemic_ruler_flu
				desc = epidemic_ruler_coughs
				desc = epidemic_titled_ruler_flu
				desc = epidemic_romantic_plague
				desc = epidemic_holder_flu
				desc = epidemic_holder_coughs
			}
			desc = trait_consumption
		}
	}
	
	on_start = {
		# LEGITIMACY LOSS FROM EPIDEMIC OUTBREAK
		epidemic_outbreak_legitimacy_effect = { PROVINCE = root.outbreak_province }
	}

	on_monthly = {
		trigger_event = {
			on_action = epidemic_ongoing_events
		}
	}

	character_infection_chance = {
		value = character_infection_chance_default_value
	}

	can_infect_character = {
		can_contract_disease_trigger = { DISEASE = consumption }
		immune_to_epidemic = { EPIDEMIC = scope:epidemic }
	}

	on_character_infected = {
		contract_disease_notify_effect = { DISEASE = consumption }
	}

	infection_levels = {
		10 = {
			province_modifier = {
				development_decline = -2
				epidemic_travel_danger = 20
			}
		}
		50 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.05
				development_decline = -3
				county_opinion_add = -2
				epidemic_travel_danger = 40
			}	
		}
		80 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.1
				development_decline = -4
				county_opinion_add = -3
				epidemic_travel_danger = 60
			}
		}
	}

	outbreak_intensities = {
		minor = {
			outbreak_chance = {
				value = outbreak_chance_minor_default_value
				multiply = outbreak_chance_minor_mult_value
				multiply = recent_epidemics_outbreak_mult_value

				#Are you in the consumption zone?
				if = {
					limit = {
						geographical_region = world_atlantic
					}
					add = outbreak_increase_add_extra_high
				}
				else = {
					add = outbreak_decrease_add_high
				}

				#Endemism
				if = {
					limit = { has_variable = consumption_endemic_variable }
					add = outbreak_increase_add_high
				}
				
				### NO DLC - We increase the chance to make up for the locked diseases ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					multiply = 1
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 2 9 } #LODfix { 15 30 }

			infection_duration = {
				months = { 12 18 } #stays around for a long time
			}

			infection_progress_duration = {
				days = { 80 100 }
			}

			infection_recovery_duration = {
				days = { 30 60 } #stays around for a long time
			}
		}

		major = {
			outbreak_chance = {
				value = outbreak_chance_major_default_value
				multiply = outbreak_chance_major_mult_value
				multiply = recent_epidemics_outbreak_mult_value

				#Are you in the consumption zone?
				if = {
					limit = {
						geographical_region = world_atlantic
					}
					add = outbreak_increase_add_low
				}
				else = {
					add = outbreak_decrease_add_very_high
				}

				#Endemism
				if = {
					limit = { has_variable = consumption_endemic_variable }
					add = outbreak_increase_add_low
				}
				
				### NO DLC - We increase the chance to make up for the locked diseases ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					multiply = 1
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 35 70 } #LODfix { 25 50 }

			infection_duration = {
				months = { 20 25 }
			}

			infection_progress_duration = {
				days = { 40 60 }
			}

			infection_recovery_duration = {
				days = { 60 80 }
			}
		}

		apocalyptic = {
			outbreak_chance = {
				value = outbreak_chance_apocalyptic_default_value
				multiply = outbreak_chance_apocalyptic_mult_value
				multiply = recent_epidemics_outbreak_mult_value

				#Are you in the consumption zone?
				if = {
					limit = {
						geographical_region = world_atlantic
					}
					multiply = 0.5
				}
				else = {
					multiply = 0.25
				}

				#Endemism
				if = {
					limit = { has_variable = consumption_endemic_variable }
					add = outbreak_increase_add_low
				}
				
				### NO DLC - We increase the chance to make up for the locked diseases ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					multiply = 1
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 125 305 } #LODfix { 80 120 }

			infection_duration = {
				months = { 30 52 }
			}
			
			infection_progress_duration = {
				days = { 15 30 }
			}

			infection_recovery_duration = {
				days = { 80 140 }
			}
		}
	}
	
	on_province_infected = {
		county = {
			apply_infection_development_loss = { BASE = 7 }
		}
		cant_touch_this_achievement_effect = yes
	}
	
	on_province_recovered = {
		random = { #Endemism
			chance = 10
			set_variable = {
				name = consumption_endemic_variable
				years = 2
			}
		}
		county = {
			remove_isolated_capital_modifiers_effect = yes
		}
		add_to_variable_list = {
			name = epidemic_cooldown
			target = scope:epidemic.epidemic_type
			years = 50 #can come back quite fast
		}
		set_variable = {
			name = epidemic_cooldown_general
			years = 15
		}
		# Prosperity event
		plague_recovery_event_effect = yes
	}
}

measles = {
	trait = measles
	color = { 201 111 112 }
	priority = 2

	shader_data = {
		strength = 0.4
		edge_fade = 0.3
		tile_multiplier = 0.006
		texture_index = 0
		channel = blue
	}

	name = {
		first_valid = {
			triggered_desc = {
				trigger = {
					outbreak_province = province:1626
					outbreak_intensity = apocalyptic
				}
				desc = epidemic_cooties
			}
			triggered_desc = {
				trigger = {
					outbreak_province = province:1787
					outbreak_intensity = apocalyptic
					outbreak_province.county.faith = { religion_tag = christianity_religion }
				}
				desc = epidemic_saint_veronica_evil
			}
			random_valid = {
				triggered_desc = {
					trigger = {
						OR = {
							outbreak_intensity = apocalyptic
							outbreak_intensity = major
						}
					}
					desc = epidemic_little_leprosy
				}
				triggered_desc = {
					trigger = {
						OR = {
							outbreak_intensity = apocalyptic
							outbreak_intensity = major
						}
					}
					desc = epidemic_evil_god_pestilence
				}
				triggered_desc = {
					trigger = {
						OR = {
							outbreak_intensity = apocalyptic
							outbreak_intensity = major
						}
					}
					desc = epidemic_titles_evil #King's evil
				}
				triggered_desc = {
					trigger = {
						outbreak_intensity = apocalyptic
						outbreak_province = {
							geographical_region = ghw_region_egypt
							county.faith.religion = { is_in_family = rf_abrahamic }
						}
					}
					desc = epidemic_eleventh_plague
				}
				triggered_desc = {
					trigger = {
						outbreak_intensity = apocalyptic
						outbreak_province = {
							duchy = title:d_york
						}
					}
					desc = epidemic_crimson_horror
				}
				desc = epidemic_realm_boils
				desc = epidemic_rulers_boils
				desc = epidemic_titled_rulers_boils
				desc = epidemic_holder_boils
				desc = epidemic_culture_boils
				desc = epidemic_location_boils
			}
			desc = trait_measles
		}
	}
	
	on_start = {
		# LEGITIMACY LOSS FROM EPIDEMIC OUTBREAK
		epidemic_outbreak_legitimacy_effect = { PROVINCE = root.outbreak_province }
	}

	on_monthly = {
		trigger_event = {
			on_action = epidemic_ongoing_events
		}
	}

	character_infection_chance = {
		value = character_infection_chance_default_value
		multiply = 5 #highly infectious
	}

	can_infect_character = {
		can_contract_disease_trigger = { DISEASE = measles }
		immune_to_epidemic = { EPIDEMIC = scope:epidemic }
	}

	on_character_infected = {
		contract_disease_notify_effect = { DISEASE = measles }
	}

	infection_levels = {
		10 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.1
				epidemic_travel_danger = 5
			}	
		}
		50 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.2
				development_decline = -0.25
				county_opinion_add = -2
				epidemic_travel_danger = 15
			}	
		}
		80 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.4
				development_decline = -0.5
				county_opinion_add = -5
				epidemic_travel_danger = 30
			}
		}
	}

	outbreak_intensities = {
		minor = {
			outbreak_chance = {
				value = outbreak_chance_minor_default_value
				multiply = outbreak_chance_minor_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				#Measles should be pretty common
				multiply = 1.25

				#Endemism
				if = {
					limit = { has_variable = measles_endemic_variable }
					add = outbreak_increase_add_high
				}
				
				### DLC LOCKING ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					value = 0
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 2 8 } #LODfix { 30 40 }

			infection_duration = {
				months = { 3 6 }
			}

			infection_progress_duration = {
				days = { 20 40 }
			}

			infection_recovery_duration = {
				days = { 28 32 }
			}
		}

		major = {
			outbreak_chance = {
				value = outbreak_chance_major_default_value
				multiply = outbreak_chance_major_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				

				#Endemism
				if = {
					limit = { has_variable = measles_endemic_variable }
					add = outbreak_increase_add_medium
				}
				else = {
					multiply = 0.5
				}
				
				### DLC LOCKING ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					value = 0
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 95 140 } #LODfix { 70 100 }

			infection_duration = {
				months = { 6 12 }
			}

			infection_progress_duration = {
				days = { 15 20 }
			}

			infection_recovery_duration = {
				days = { 28 32 }
			}
		}

		apocalyptic = {
			outbreak_chance = {
				value = outbreak_chance_apocalyptic_default_value
				multiply = outbreak_chance_apocalyptic_mult_value
				multiply = recent_epidemics_outbreak_mult_value

				#Endemism
				if = {
					limit = { has_variable = measles_endemic_variable }
					add = outbreak_increase_add_low
				}
				else = {
					multiply = 0.25
				}
				
				### DLC LOCKING ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					value = 0
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 195 410 } #LODfix { 150 225 }

			infection_duration = {
				months = { 12 32 }
			}
			
			infection_progress_duration = {
				days = { 7 16 }
			}

			infection_recovery_duration = {
				days = { 28 39 }
			}
		}
	}
	
	on_province_infected = {
		county = {
			apply_infection_development_loss = { BASE = 5 }
		}
		cant_touch_this_achievement_effect = yes
	}
	
	on_province_recovered = {
		random = {
			chance = 10
			set_variable = {
				name = measles_endemic_variable
				years = 2
			}
		}
		county = {
			remove_isolated_capital_modifiers_effect = yes
		}
		add_to_variable_list = {
			name = epidemic_cooldown
			target = scope:epidemic.epidemic_type
			years = 50
		}
		set_variable = {
			name = epidemic_cooldown_general
			years = 15 
		}
		# Prosperity event
		plague_recovery_event_effect = yes
	}
}

dysentery = {
	trait = dysentery
	color = { 102 0 0 }
	priority = 3

	shader_data = {
		strength = 0.7
		edge_fade = 0.25
		tile_multiplier = 0.01
		texture_index = 1
		channel = green
	}

	name = {
		first_valid = {
			triggered_desc = {
				trigger = {
					outbreak_intensity = apocalyptic
					OR = {
						outbreak_province = province:2833
						outbreak_province = province:2830
					}
				}
				desc = epidemic_twin_cods_revenge
			}
			triggered_desc = {
				trigger = {
					outbreak_intensity = apocalyptic
					outbreak_province = province:6253
				}
				desc = epidemic_ligma
			}
			random_valid = {
				triggered_desc = {
					trigger = {
						OR = {
							outbreak_intensity = apocalyptic
							outbreak_intensity = major
						}
					}
					desc = epidemic_evil_god_flux
				}
				triggered_desc = {
					trigger = {
						outbreak_intensity = apocalyptic
						outbreak_province = {
							geographical_region = ghw_region_egypt
							county.faith.religion = { is_in_family = rf_abrahamic }
						}
					}
					desc = epidemic_eleventh_plague
				}
				desc = epidemic_realm_flux
				desc = epidemic_ruler_flux
				desc = epidemic_titled_ruler_flux
				desc = epidemic_holder_flux
				desc = epidemic_culture_flux
				desc = epidemic_terrain_flux
				desc = epidemic_location_flux
			}
			desc = trait_dysentery
		}
	}
	
	on_start = {
		# LEGITIMACY LOSS FROM EPIDEMIC OUTBREAK
		epidemic_outbreak_legitimacy_effect = { PROVINCE = root.outbreak_province }
	}

	on_monthly = {
		trigger_event = {
			on_action = epidemic_ongoing_events
		}
	}

	character_infection_chance = {
		value = character_infection_chance_default_value
		multiply = 3.5 #highly infectious
		if = {
			limit = {
				is_commanding_army = yes
			}
			multiply = 2
		}
	}

	can_infect_character = {
		can_contract_disease_trigger = { DISEASE = dysentery }
		immune_to_epidemic = { EPIDEMIC = scope:epidemic }
	}

	on_character_infected = {
		contract_disease_notify_effect = { DISEASE = dysentery }
	}

	infection_levels = {
		10 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.15
				county_opinion_add = -2
				epidemic_travel_danger = 10
				development_decline = -1.5
			}	
		}
		50 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.3
				development_decline = -2.5
				supply_limit_mult = -0.1
				county_opinion_add = -3
				epidemic_travel_danger = 20
			}	
		}
		80 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.5
				development_decline = -4
				supply_limit_mult = -0.2
				county_opinion_add = -5
				epidemic_travel_danger = 30
			}
		}
	}

	outbreak_intensities = {
		minor = {
			outbreak_chance = {
				value = outbreak_chance_dysentery_default_value #special values for armies here
				multiply = outbreak_chance_minor_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				
				### DLC LOCKING ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					value = 0
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {  
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}

			max_provinces = { 2 8 } #LODfix { 10 16 }
			
			infection_duration = {
				months = { 2 4 }
			}

			infection_progress_duration = {
				days = { 15 20 }
			}

			infection_recovery_duration = {
				days = { 28 32 }
			}
		}

		major = {
			outbreak_chance = {
				value = outbreak_chance_dysentery_default_value #special values for armies here
				multiply = outbreak_chance_major_mult_value
				multiply = recent_epidemics_outbreak_mult_value 
				multiply = 0.25
				
				### DLC LOCKING ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					value = 0
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {  
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 30 40 } #LODfix { 22 30 }

			infection_duration = {
				months = { 8 16 }
			}

			infection_progress_duration = {
				days = { 18 22 }
			}

			infection_recovery_duration = {
				days = { 28 32 }
			}
		}

		apocalyptic = {
			outbreak_chance = {
				value = outbreak_chance_dysentery_default_value #special values for armies here
				multiply = outbreak_chance_apocalyptic_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				multiply = 0.15
				
				### DLC LOCKING ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					value = 0
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {  
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
			}
			max_provinces = { 80 265 } #LODfix { 50 150 }

			infection_duration = {
				months = { 16 36 }
			}
			
			infection_progress_duration = {
				days = { 10 15 }
			}

			infection_recovery_duration = {
				days = { 28 36 }
			}
		}
	}
	
	on_province_infected = {
		county = {
			apply_infection_development_loss = { BASE = 3 }
		}
		cant_touch_this_achievement_effect = yes
	}
	
	on_province_recovered = {
		county = {
			remove_isolated_capital_modifiers_effect = yes
		}
		add_to_variable_list = {
			name = epidemic_cooldown
			target = scope:epidemic.epidemic_type
			years = 50
		}
		set_variable = {
			name = epidemic_cooldown_general
			years = 15 
		}
		# Prosperity event
		plague_recovery_event_effect = yes
	}
}

ergotism = { #dancing plague - not contagious
	trait = ergotism
	color = { 255 95 31 }
	priority = 2

	shader_data = {
		strength = 0.5
		edge_fade = 0.25
		tile_multiplier = 0.005
		texture_index = 1
		channel = alpha
	}

	name = {
		first_valid = {
			triggered_desc = {
				trigger = {
					outbreak_intensity = apocalyptic
					outbreak_province = province:2830
				}
				desc = epidemic_saturday_night_fever
			}
			triggered_desc = {
				trigger = {
					outbreak_intensity = apocalyptic
				}
				desc = epidemic_dance_of_death
			}
			random_valid = {
				triggered_desc = {
					trigger = {
						outbreak_province = {
							faith.religion = religion:christianity_religion
						}
					}
					desc = epidemic_saint_anthonys_fire
				}
				triggered_desc = {
					trigger = {
						outbreak_province = {
							faith.religion = religion:christianity_religion
						}
					}
					desc = epidemic_saint_anthonys_fire
				}
				triggered_desc = {
					trigger = {
						outbreak_intensity = apocalyptic
						outbreak_province = {
							geographical_region = ghw_region_egypt
							county.faith.religion = { is_in_family = rf_abrahamic }
						}
					}
					desc = epidemic_eleventh_plague
				}
				triggered_desc = {
					trigger = {
						outbreak_province = {
							county = { development_level <= 5 }
						}
					}
					desc = epidemic_realm_dancing_plague
				}
				triggered_desc = {
					trigger = {
						outbreak_province = {
							county = { development_level <= 5 }
						}
					}
					desc = epidemic_culture_dancing_plague
				}
				triggered_desc = {
					trigger = {
						outbreak_province = {
							county = { development_level <= 5 }
						}
					}
					desc = epidemic_location_dancing_plague
				}
				triggered_desc = {
					trigger = {
						outbreak_province = {
							county = {
								OR = {
									faith = faith:catholic
									faith = faith:orthodox
									faith = faith:nestorian
									faith = faith:coptic
									faith = faith:armenian_apostolic
									faith = faith:insular_celtic
								}
							}
						}
					}
					desc = epidemic_random_saint_fire
				}
				desc = epidemic_realm_fire
				desc = epidemic_culture_fire
				desc = epidemic_location_fire
				desc = epidemic_ruler_fire
				desc = epidemic_holder_fire
				desc = epidemic_evil_god_fire
			}
		}
	}
	
	on_start = {
		# LEGITIMACY LOSS FROM EPIDEMIC OUTBREAK
		epidemic_outbreak_legitimacy_effect = { PROVINCE = root.outbreak_province }
	}
	
	on_monthly = {
		trigger_event = {
			on_action = epidemic_ongoing_events
		}
	}

	character_infection_chance = {
		value = character_infection_chance_default_value
	}

	can_infect_character = {
		can_contract_disease_trigger = { DISEASE = ergotism }
		immune_to_epidemic = { EPIDEMIC = scope:epidemic }
	}

	on_character_infected = {
		contract_disease_notify_effect = { DISEASE = ergotism }
	}

	infection_levels = {
		10 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.1
				holding_build_speed = 0.5 #this is negative
				stationed_maa_toughness_mult = -0.1
				supply_limit_mult = -0.1 #food related
				epidemic_travel_danger = 5
			}	
		}
		50 = {
			province_modifier = {
				monthly_county_control_decline_add = -0.15
				holding_build_speed = 0.75
				stationed_maa_toughness_mult = -0.2
				supply_limit_mult = -0.2
				epidemic_travel_danger = 10
			}	
		}
		80 = {
			province_modifier = {
				development_decline = -0.5
				monthly_county_control_decline_add = -0.15
				holding_build_speed = 1
				stationed_maa_toughness_mult = -1
				supply_limit_mult = -0.3
				epidemic_travel_danger = 15
			}
		}
	}

	outbreak_intensities = {
		minor = {
			outbreak_chance = {
				value = outbreak_chance_minor_default_value
				multiply = outbreak_chance_minor_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				multiply = 0.5 #shouldn't happen often
				if = { #Recent epidemics
					limit = {
						is_target_in_variable_list = {
							name = epidemic_cooldown
							target = epidemic_type:ergotism
						}
					}
					value = 0
				}
				
				### DLC LOCKING ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					value = 0
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
				if = {
					limit = {
						is_target_in_variable_list = {
							name = epidemic_cooldown
							target = scope:epidemic.epidemic_type
						}
					}
					value = 0
				}
			}

			max_provinces = { 2 7 } #LODfix { 10 15 }

			infection_duration = {
				months = { 6 12 }
			}

			infection_progress_duration = {
				days = { 20 40 }
			}

			infection_recovery_duration = {
				days = { 12 20 }
			}
		}
		major = { 
			outbreak_chance = {
				value = outbreak_chance_major_default_value
				multiply = outbreak_chance_major_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				multiply = 0.2 #shouldn't happen often
				if = { #Recent epidemics
					limit = {
						is_target_in_variable_list = {
							name = epidemic_cooldown
							target = epidemic_type:ergotism
						}
					}
					value = 0
				}
				
				### DLC LOCKING ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					value = 0
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
				if = {
					limit = {
						is_target_in_variable_list = {
							name = epidemic_cooldown
							target = scope:epidemic.epidemic_type
						}
					}
					value = 0
				}
			}

			max_provinces = { 25 40 } #LODfix { 25 35 }

			infection_duration = {
				months = { 12 18 }
			}

			infection_progress_duration = {
				days = { 20 40 }
			}

			infection_recovery_duration = {
				days = { 12 20 }
			}
		}
		apocalyptic = { 
			outbreak_chance = {
				value = outbreak_chance_apocalyptic_default_value
				multiply = outbreak_chance_apocalyptic_mult_value
				multiply = recent_epidemics_outbreak_mult_value
				multiply = 0.1 #shouldn't happen often
				if = { #Recent epidemics
					limit = {
						is_target_in_variable_list = {
							name = epidemic_cooldown
							target = epidemic_type:ergotism
						}
					}
					value = 0
				}
				
				### DLC LOCKING ###
				if = {
					limit = {
						NOT = { has_dlc_feature = legends_of_the_dead }
					}
					value = 0
				}
				if = {
					limit = {
						has_game_rule = epidemic_frequency_disabled
					}
					multiply = 0
				}
			}
			spread_chance = {
				value = spread_chance_epidemics_default_value
				multiply = spread_chance_epidemics_mult_value
				if = {
					limit = {
						is_target_in_variable_list = {
							name = epidemic_cooldown
							target = scope:epidemic.epidemic_type
						}
					}
					value = 0
				}
			}

			max_provinces = { 50 70 } #LODfix { 40 50 }

			infection_duration = {
				months = { 24 30 }
			}

			infection_progress_duration = {
				days = { 20 40 }
			}

			infection_recovery_duration = {
				days = { 12 20 }
			}
		}
	}
	
	on_province_recovered = {
		county = {
			remove_isolated_capital_modifiers_effect = yes
		}
		add_to_variable_list = {
			name = epidemic_cooldown
			target = scope:epidemic.epidemic_type
			years = 50
		}
		set_variable = {
			name = epidemic_cooldown_general
			years = 15 
		}
		# Prosperity event
		plague_recovery_event_effect = yes
	}
}
