namespace = Plus

#reserved: Plus.950 to Plus.969

#######################################
# CK2Plus Province Prosperity Events
#######################################

# Inadequate soil preparation
province_event = {
	id = Plus.950
	desc = "EVTDESC_Plus_950"
	picture = GFX_evt_throne_room
	
	notification = yes

	lacks_dlc = "Reapers"
	
	trigger = {
		NOT = { has_province_modifier = province_poverty_2 }
		#with Reapers this effect will always "reset" prosperity progress so it doesn't need a floor
	}
	
	immediate = {
		#prosperity decrease
		prov_prosperity_decrease_effect = yes
	}

	mean_time_to_happen = {
		months = 2500
		modifier = {
			factor = 0.75
			owner = { war = yes }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_stewardship = 10 } }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_stewardship = 20 } }
		}
		modifier = {
			factor = 1.1
			owner = { realm_stewardship = 30 }
		}
		modifier = {
			factor = 1.1
			owner = { realm_stewardship = 40 }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_learning = 10 } }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_learning = 20 } }
		}
		modifier = {
			factor = 1.1
			owner = { realm_learning = 30 }
		}
		modifier = {
			factor = 1.1
			owner = { realm_learning = 40 }
		}
		modifier = {
			factor = 0.5
			OR = {
				has_province_modifier = province_prosperity_2
				has_province_modifier = prosperity_modifier_3
				has_province_modifier = prosperity_modifier_2
			}
		}
		modifier = {
			factor = 0.75
			OR = {
				has_province_modifier = province_prosperity_1
				has_province_modifier = prosperity_modifier_1
			}
		}
		modifier = {
			factor = 1.5
			OR = {
				has_province_modifier = province_poverty_1
				has_province_modifier = depopulated_1
				has_province_modifier = depopulated_2
				has_province_modifier = depopulated_3
			}
		}
	}

	option = {
		name = "OK"
	}
}

# Poor seed selection hurts farming
province_event = {
	id = Plus.951
	desc = "EVTDESC_Plus_951"
	picture = GFX_evt_throne_room
	
	notification = yes
	
	lacks_dlc = "Reapers"

	trigger = {
		NOT = { has_province_modifier = province_poverty_2 }
		#with Reapers this effect will always "reset" prosperity progress so it doesn't need a floor
	}
	
	immediate = {
		#prosperity decrease
		prov_prosperity_decrease_effect = yes
	}

	mean_time_to_happen = {
		months = 2500
		modifier = {
			factor = 0.75
			owner = { war = yes }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_stewardship = 10 } }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_stewardship = 20 } }
		}
		modifier = {
			factor = 1.1
			owner = { realm_stewardship = 30 }
		}
		modifier = {
			factor = 1.1
			owner = { realm_stewardship = 40 }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_learning = 10 } }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_learning = 20 } }
		}
		modifier = {
			factor = 1.1
			owner = { realm_learning = 30 }
		}
		modifier = {
			factor = 1.1
			owner = { realm_learning = 40 }
		}
		modifier = {
			factor = 0.5
			OR = {
				has_province_modifier = province_prosperity_2
				has_province_modifier = prosperity_modifier_3
				has_province_modifier = prosperity_modifier_2
			}
		}
		modifier = {
			factor = 0.75
			OR = {
				has_province_modifier = province_prosperity_1
				has_province_modifier = prosperity_modifier_1
			}
		}
		modifier = {
			factor = 1.5
			OR = {
				has_province_modifier = province_poverty_1
				has_province_modifier = depopulated_1
				has_province_modifier = depopulated_2
				has_province_modifier = depopulated_3
			}
		}
	}

	option = {
		name = "OK"
	}
}

# Lack of manure hurts farming
province_event = {
	id = Plus.952
	desc = "EVTDESC_Plus_952"
	picture = GFX_evt_throne_room
	
	notification = yes
	
	lacks_dlc = "Reapers"

	trigger = {
		NOT = { has_province_modifier = province_poverty_2 }
		#with Reapers this effect will always "reset" prosperity progress so it doesn't need a floor
	}
	
	immediate = {
		#prosperity decrease
		prov_prosperity_decrease_effect = yes
	}

	mean_time_to_happen = {
		months = 2500
		modifier = {
			factor = 0.75
			owner = { war = yes }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_stewardship = 10 } }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_stewardship = 20 } }
		}
		modifier = {
			factor = 1.1
			owner = { realm_stewardship = 30 }
		}
		modifier = {
			factor = 1.1
			owner = { realm_stewardship = 40 }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_learning = 10 } }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_learning = 20 } }
		}
		modifier = {
			factor = 1.1
			owner = { realm_learning = 30 }
		}
		modifier = {
			factor = 1.1
			owner = { realm_learning = 40 }
		}
		modifier = {
			factor = 0.5
			OR = {
				has_province_modifier = province_prosperity_2
				has_province_modifier = prosperity_modifier_3
				has_province_modifier = prosperity_modifier_2
			}
		}
		modifier = {
			factor = 0.75
			OR = {
				has_province_modifier = province_prosperity_1
				has_province_modifier = prosperity_modifier_1
			}
		}
		modifier = {
			factor = 1.5
			OR = {
				has_province_modifier = province_poverty_1
				has_province_modifier = depopulated_1
				has_province_modifier = depopulated_2
				has_province_modifier = depopulated_3
			}
		}
	}
	
	option = {
		name = "OK"
	}
}

# Lower mean temperature hurts farming
province_event = {
	id = Plus.953
	desc = "EVTDESC_Plus_953"
	picture = GFX_evt_throne_room
	
	notification = yes
	
	lacks_dlc = "Reapers"

	trigger = {
		NOT = { has_province_modifier = province_poverty_2 }
		#with Reapers this effect will always "reset" prosperity progress so it doesn't need a floor
		year = 1290
		NOT = { year = 1365 }
	}	
	
	immediate = {
		#prosperity decrease
		prov_prosperity_decrease_effect = yes
	}

	mean_time_to_happen = {
		months = 2500
		modifier = {
			factor = 0.75
			owner = { war = yes }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_stewardship = 10 } }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_stewardship = 20 } }
		}
		modifier = {
			factor = 1.1
			owner = { realm_stewardship = 30 }
		}
		modifier = {
			factor = 1.1
			owner = { realm_stewardship = 40 }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_learning = 10 } }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_learning = 20 } }
		}
		modifier = {
			factor = 1.1
			owner = { realm_learning = 30 }
		}
		modifier = {
			factor = 1.1
			owner = { realm_learning = 40 }
		}
		modifier = {
			factor = 0.5
			OR = {
				has_province_modifier = province_prosperity_2
				has_province_modifier = prosperity_modifier_3
				has_province_modifier = prosperity_modifier_2
			}
		}
		modifier = {
			factor = 0.75
			OR = {
				has_province_modifier = province_prosperity_1
				has_province_modifier = prosperity_modifier_1
			}
		}
		modifier = {
			factor = 1.5
			OR = {
				has_province_modifier = province_poverty_1
				has_province_modifier = depopulated_1
				has_province_modifier = depopulated_2
				has_province_modifier = depopulated_3
			}
		}
	}
	
	option = {
		name = "OK"
	}
}

# Arable land deserted
province_event = {
	id = Plus.954
	desc = "EVTDESC_Plus_954"
	picture = GFX_evt_throne_room
	
	notification = yes
	
	lacks_dlc = "Reapers"

	trigger = {
		NOT = { has_province_modifier = province_poverty_2 }
		OR = {
			owner = {
				ROOT = {
					controller = {
						NOT = { character = PREVPREV }
					}
				}
			}
			has_disease = yes
		}
	}

	mean_time_to_happen = {
		months = 240
		modifier = {
			factor = 0.5
			owner = {
				ROOT = {
					controller = {
						NOT = { character = PREVPREV }
					}
				}
			}
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_learning = 10 } }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_learning = 20 } }
		}
		modifier = {
			factor = 1.1
			owner = { realm_learning = 30 }
		}
		modifier = {
			factor = 1.1
			owner = { realm_learning = 40 }
		}
		modifier = {
			factor = 0.5
			OR = {
				has_province_modifier = province_prosperity_2
				has_province_modifier = prosperity_modifier_3
				has_province_modifier = prosperity_modifier_2
			}
		}
		modifier = {
			factor = 0.75
			OR = {
				has_province_modifier = province_prosperity_1
				has_province_modifier = prosperity_modifier_1
			}
		}
		modifier = {
			factor = 1.5
			OR = {
				has_province_modifier = province_poverty_1
				has_province_modifier = depopulated_1
				has_province_modifier = depopulated_2
				has_province_modifier = depopulated_3
			}
		}
	}

	immediate = {
		#prosperity decrease
		prov_prosperity_decrease_effect = yes
	}
	
	option = {
		name = "OK"
	}
}

# Draining of marshes and fens
province_event = {
	id = Plus.955
	desc = "EVTDESC_Plus_955"
	picture = GFX_evt_throne_room
	
	notification = yes
	
	lacks_dlc = "Reapers"

	trigger = {
		NOR = { 
			has_province_modifier = province_prosperity_2 
			has_province_modifier = prosperity_modifier_3
		}
	}

	mean_time_to_happen = {
		months = 2500
		modifier = {
			factor = 0.75
			owner = { war = no }
		}
		modifier = {
			factor = 1.1
			owner = { NOT = { realm_stewardship = 10 } }
		}
		modifier = {
			factor = 1.1
			owner = { NOT = { realm_stewardship = 20 } }
		}
		modifier = {
			factor = 0.9
			owner = { realm_stewardship = 30 }
		}
		modifier = {
			factor = 0.9
			owner = { realm_stewardship = 40 }
		}
		modifier = {
			factor = 1.1
			owner = { NOT = { realm_learning = 10 } }
		}
		modifier = {
			factor = 1.1
			owner = { NOT = { realm_learning = 20 } }
		}
		modifier = {
			factor = 0.9
			owner = { realm_learning = 30 }
		}
		modifier = {
			factor = 0.9
			owner = { realm_learning = 40 }
		}
		modifier = {
			factor = 0.5
			OR = {
				has_province_modifier = province_poverty_2
				AND = {
					has_dlc = "Reapers"
					NOR = {
						has_province_modifier = prosperity_modifier_1
						has_province_modifier = prosperity_modifier_2
						has_province_modifier = prosperity_modifier_3
					}
				}
			}
		}
		modifier = {
			factor = 0.75
			OR = {
				has_province_modifier = province_poverty_1
				has_province_modifier = prosperity_modifier_1
			}
		}
		modifier = {
			factor = 1.5
			OR = {
				has_province_modifier = province_prosperity_1
				has_province_modifier = prosperity_modifier_2
			}
		}
	}

	immediate = {
		#prosperity increase
		prov_prosperity_increase_effect = yes
	}
	
	option = {
		name = "OK"
	}
}

# Resettlement on newly claimed land
province_event = {
	id = Plus.956
	desc = "EVTDESC_Plus_956"
	picture = GFX_evt_throne_room
	
	notification = yes
	
	lacks_dlc = "Reapers"

	trigger = {
		NOR = { 
			has_province_modifier = province_prosperity_2 
			has_province_modifier = prosperity_modifier_3
		}
	}

	mean_time_to_happen = {
		months = 2500
		modifier = {
			factor = 0.75
			owner = { war = no }
		}
		modifier = {
			factor = 1.1
			owner = { NOT = { realm_stewardship = 10 } }
		}
		modifier = {
			factor = 1.1
			owner = { NOT = { realm_stewardship = 20 } }
		}
		modifier = {
			factor = 0.9
			owner = { realm_stewardship = 30 }
		}
		modifier = {
			factor = 0.9
			owner = { realm_stewardship = 40 }
		}
		modifier = {
			factor = 1.1
			owner = { NOT = { realm_learning = 10 } }
		}
		modifier = {
			factor = 1.1
			owner = { NOT = { realm_learning = 20 } }
		}
		modifier = {
			factor = 0.9
			owner = { realm_learning = 30 }
		}
		modifier = {
			factor = 0.9
			owner = { realm_learning = 40 }
		}
		modifier = {
			factor = 0.5
			OR = {
				has_province_modifier = province_poverty_2
				AND = {
					has_dlc = "Reapers"
					NOR = {
						has_province_modifier = prosperity_modifier_1
						has_province_modifier = prosperity_modifier_2
						has_province_modifier = prosperity_modifier_3
					}
				}
			}
		}
		modifier = {
			factor = 0.75
			OR = {
				has_province_modifier = province_poverty_1
				has_province_modifier = prosperity_modifier_1
			}
		}
		modifier = {
			factor = 1.5
			OR = {
				has_province_modifier = province_prosperity_1
				has_province_modifier = prosperity_modifier_2
			}
		}
	}

	immediate = {
		#prosperity increase
		prov_prosperity_increase_effect = yes
	}
	
	option = {
		name = "OK"
	}
}

# Increased land productivity
province_event = {
	id = Plus.957
	desc = "EVTDESC_Plus_957"
	picture = GFX_evt_throne_room
	
	notification = yes
	
	lacks_dlc = "Reapers"

	trigger = {
		NOR = { 
			has_province_modifier = province_prosperity_2 
			has_province_modifier = prosperity_modifier_3
		}
	}

	mean_time_to_happen = {
		months = 2500
		modifier = {
			factor = 0.75
			owner = { war = no }
		}
		modifier = {
			factor = 1.1
			owner = { NOT = { realm_stewardship = 10 } }
		}
		modifier = {
			factor = 1.1
			owner = { NOT = { realm_stewardship = 20 } }
		}
		modifier = {
			factor = 0.9
			owner = { realm_stewardship = 30 }
		}
		modifier = {
			factor = 0.9
			owner = { realm_stewardship = 40 }
		}
		modifier = {
			factor = 1.1
			owner = { NOT = { realm_learning = 10 } }
		}
		modifier = {
			factor = 1.1
			owner = { NOT = { realm_learning = 20 } }
		}
		modifier = {
			factor = 0.9
			owner = { realm_learning = 30 }
		}
		modifier = {
			factor = 0.9
			owner = { realm_learning = 40 }
		}
		modifier = {
			factor = 0.5
			OR = {
				has_province_modifier = province_poverty_2
				AND = {
					has_dlc = "Reapers"
					NOR = {
						has_province_modifier = prosperity_modifier_1
						has_province_modifier = prosperity_modifier_2
						has_province_modifier = prosperity_modifier_3
					}
				}
			}
		}
		modifier = {
			factor = 0.75
			OR = {
				has_province_modifier = province_poverty_1
				has_province_modifier = prosperity_modifier_1
			}
		}
		modifier = {
			factor = 1.5
			OR = {
				has_province_modifier = province_prosperity_1
				has_province_modifier = prosperity_modifier_2
			}
		}
	}

	immediate = {
		#prosperity increase
		prov_prosperity_increase_effect = yes
	}
	
	option = {
		name = "OK"
	}
}

# Building sacked during siege
character_event = {
	id = Plus.958
	desc = "EVTDESC_Plus_958"
	title = "EVTNAME_Plus_958"
	picture = "GFX_evt_siege"
	border = "GFX_event_normal_frame_war"
	
	is_triggered_only = yes

	trigger = {
		siege = { is_attacker = yes }
		location = {
			any_province_lord = {
				siege = { is_attacker = no }
				any_demesne_title = {
					location = { province_id = PREVPREVPREV }
					tier = baron
					num_of_buildings = 1
				}
			}
		}
	}

	weight_multiplier = {
		months = 1
		modifier = {
			factor = 0.5
			location = {
				owner = {
					same_realm = ROOT
				}
			}
		}
		modifier = {
			factor = 0.5
			trait = kind
		}
		modifier = {
			factor = 0.5
			trait = charitable
		}
		modifier = {
			factor = 0.5
			trait = just
		}
		modifier = {
			factor = 1.5
			trait = arbitrary
		}
		modifier = {
			factor = 1.5
			trait = cruel
		}
		modifier = {
			factor = 1.5
			trait = wroth
		}
	}

	immediate = {
		hidden_tooltip = {
			location = {
				random_province_lord = {
					limit = {
						siege = { is_attacker = no }
						any_demesne_title = {
							location = { province_id = PREVPREVPREV }
							tier = baron
							num_of_buildings = 1
						}
					}
					save_event_target_as = besieged_settlement_owner
					random_demesne_title = {
						limit = {
							location = { province_id = PREVPREVPREV }
							tier = baron
							num_of_buildings = 1
						}
						save_event_target_as = besieged_settlement
						location = { save_event_target_as = besieged_settlement_province }
					}
				}
			}
		}
	}

	option = {
		name = "EVTOPTA_Plus_958" #It can't be helped
		event_target:besieged_settlement_owner = {
			character_event = { id = Plus.959 tooltip = EVTTOOLTIP1059009 days = 1 }
		}
	}
}

# Destroy Random Building
character_event = {
	id = Plus.959
	desc = "EVTDESC_Plus_959"
	picture = "GFX_evt_burning_house"

	is_triggered_only = yes

	option = {
		name = "CURSES"
		event_target:besieged_settlement = {
			destroy_random_building = yes
			if = {
				limit = { controller = { same_realm = FROM } }
				log = "[This.GetName] sacked by [From.GetBestName]"
				if = {
					limit = { 
						FROM = { is_nomadic = yes } 
						is_nomadic = no						
					}
					destroy_random_building = yes
					FROM = {
						liege = {
							random_list = {
								10 = { military_techpoints = 10 }
								10 = { economy_techpoints = 10 }
								10 = { culture_techpoints = 10 }
							}
						}
					}
				}				
				if = {
					limit = {
						NOT = { has_any_building = yes }					
					}
					log = "[This.GetBestName] destroyed by [From.GetBestName]"
					destroy_settlement = THIS					
				}
			}
		}
	}
}

# Pagan scourge
province_event = {
	id = Plus.960
	desc = EVTDESC_Plus_960
	picture = GFX_evt_peasants
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_Plus_960 # Do it
		add_province_modifier = {
			name = peasant_unrest
			duration = 1825
		}
		random = {
			chance = 25
			modifier = {
				factor = 2
				is_pagan_religion = yes
				is_reformed_pagan_religion = no
			}
			religion = FROMFROM
		}
		FROMFROM = {
			piety = -100
			prestige = 100
			tyrant_plus_1_effect = yes
			if = {
				limit = { trait = kind }
				remove_trait = kind
			}
			if = {
				limit = {
					NOT = { trait = kind }
					NOT = { trait = cruel }
				}
				add_trait = cruel
			}
		}
	}
	option = {
		name = EVTOPTB_Plus_960 # Never mind
		trigger = { FROMFROM = { ai = no } }
	}
}

# Reduce estates if depopulated
province_event = {
	id = Plus.961

	hide_window = yes
	
	trigger = {
		OR = {
			NOT = { has_province_flag = reduced_estates }
			had_province_flag = { flag = reduced_estates days = 1825 }
		}
		any_province_holding = {
			OR = {
				has_building = ca_estate_4
				has_building = ca_estate_5
			}
		}
		OR = {
			AND = {
				has_dlc = "Reapers"
				OR = {
					has_province_modifier = depopulated_2
					has_province_modifier = depopulated_3
				}
			}
			AND = {
				NOT = { has_dlc = "Reapers" }
				OR = {
					has_province_modifier = province_poverty_2
				}
			}
		}
	}
	
	#since this is province event, it's OK for it to be mtth
	mean_time_to_happen = {
		months = 600
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_stewardship = 10 } }
		}
		modifier = {
			factor = 0.9
			owner = { NOT = { realm_stewardship = 20 } }
		}
		modifier = {
			factor = 1.1
			owner = { realm_stewardship = 30 }
		}
		modifier = {
			factor = 1.1
			owner = { realm_stewardship = 40 }
		}
	}
	
	immediate = {
		random_list = {
			90 = {
				#nothing
			}
			10 = {
				set_province_flag = reduced_estates
				owner = { character_event = { id = Plus.962 } }
			}
		}
	}
}

# Notify owner of state reduction
character_event = {
	id = Plus.962
	desc = EVTDESC_Plus_962
	picture = GFX_evt_depopulated_town
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = CURSES
		FROM = {
			random_province_holding = {
				limit = {
					OR = {
						has_building = ca_estate_4
						has_building = ca_estate_5
					}
				}
				if = {
					limit = { has_building = ca_estate_4 }
					remove_building = ca_estate_4
					add_building = ca_estate_3
				}
				if = {
					limit = { has_building = ca_estate_5 }
					remove_building = ca_estate_5
					add_building = ca_estate_4
				}
			}
		}
	}
}