###################################
#
# Events for Provinces
#
# Id 8000-8499 is reserved
#
###################################
#
# Written by Niklas Strid


# Land reclamation
province_event = {
	id = 8000
	desc = "EVTDESC8000"
	
	trigger = {
		owner = { war = no }
		NOT = { has_province_flag = land_reclamation }
		has_siege = no
		owner = { wealth = 50 }
	}
	
	mean_time_to_happen = {
		months = 2000
		
		modifier = {
			factor = 5.0
			has_province_flag = land_reclamation_rejected
		}
	}
	
	option = {
		name = "EVTOPTA8000"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 4
				owner = { trait = ambitious }
			}
			modifier = {
				factor = 4
				owner = { trait = greedy }
			}
		}
		owner = { wealth = -25 }
		add_province_modifier = {
			name = land_reclamation
			duration = -1
		}
		clr_province_flag = land_reclamation_rejected
		set_province_flag = land_reclamation
	}
	option = {
		name = "EVTOPTB8000"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 4
				owner = { trait = content }
			}
			modifier = {
				factor = 2
				owner = { trait = gardener }
			}
		}
		set_province_flag = land_reclamation_rejected
	}
}

# River dredging
province_event = {
	id = 8005
	desc = "EVTDESC8005"
	
	trigger = {
		owner = { war = no }
		has_siege = no
		owner = { wealth = 50 }
	}
	
	mean_time_to_happen = {
		months = 2000
		
		modifier = {
			factor = 5.0
			has_province_flag = river_dredging_rejected
		}
	}
	
	option = {
		name = "EVTOPTA8005"
		ai_chance = {
			factor = 75
			modifier = {
				factor = 4
				owner = { trait = ambitious }
			}
			modifier = {
				factor = 4
				owner = { trait = greedy }
			}
		}
		owner = { wealth = -25 }
		remove_province_modifier = overgrown_rivers
		clr_province_flag = river_dredging_rejected
		set_province_flag = river_dredging
	}
	option = {
		name = "EVTOPTB8005"
		ai_chance = {
			factor = 25
			modifier = {
				factor = 4
				owner = { trait = content }
			}
		}
		add_province_modifier = {
			name = overgrown_rivers
			duration = -1
		}
		set_province_flag = river_dredging_rejected
	}
}

# Build canal
province_event = {
	id = 8010
	desc = "EVTDESC8010"
	
	trigger = {
		owner = { war = no }
		NOT = { has_province_flag = canal }
		has_siege = no
		owner = { wealth = 50 }
	}
	
	mean_time_to_happen = {
		months = 2000
		
		modifier = {
			factor = 5.0
			has_province_flag = canal_rejected
		}
	}
	
	option = {
		name = "EVTOPTA8010"
		ai_chance = {
			factor = 75
			modifier = {
				factor = 4
				owner = { trait = ambitious }
			}
			modifier = {
				factor = 4
				owner = { trait = greedy }
			}
		}
		owner = { wealth = -25 }
		add_province_modifier = {
			name = canal
			duration = -1
		}
		clr_province_flag = canal_rejected
		set_province_flag = canal
	}
	option = {
		name = "EVTOPTB8010"
		ai_chance = {
			factor = 25
			modifier = {
				factor = 4
				owner = { trait = content }
			}
		}
		set_province_flag = canal_rejected
	}
}

# Dilapidated canals
province_event = {
	id = 8015
	desc = "EVTDESC8015"
	
	trigger = {
		owner = { war = no }
		has_province_flag = canal
		has_siege = no
		owner = { wealth = 30 }
	}
	
	mean_time_to_happen = {
		months = 2000
		
		modifier = {
			factor = 5
			has_province_flag = canals_repaired
		}
		modifier = {
			factor = 2
			has_province_flag = dilapidated_canals
		}
	}
	
	option = {
		name = "EVTOPTA8015"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 4
				owner = { trait = ambitious }
			}
			modifier = {
				factor = 4
				owner = { trait = greedy }
			}
		}
		owner = { wealth = -15 }
		remove_province_modifier = dilapidated_canals
		clr_province_flag = dilapidated_canals
		set_province_flag = canals_repaired
	}
	option = {
		name = "EVTOPTB8015"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 4
				owner = { trait = content }
			}
		}
		add_province_modifier = {
			name = dilapidated_canals
			duration = -1
		}
		set_province_flag = dilapidated_canals
	}
}

# Irrigation system
province_event = {
	id = 8020
	desc = "EVTDESC8020"
	
	trigger = {
		owner = { war = no }
		NOT = { has_province_flag = irrigation_system }
		has_siege = no
		owner = { wealth = 50 }
	}
	
	mean_time_to_happen = {
		months = 2000
		
		modifier = {
			factor = 2
			has_province_flag = irrigation_system_rejected
		}
	}
	
	option = {
		name = "EVTOPTA8020"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 4
				owner = { trait = ambitious }
			}
			modifier = {
				factor = 4
				owner = { trait = greedy }
			}
		}
		owner = { wealth = -25 }
		add_province_modifier = {
			name = irrigation_system
			duration = -1
		}
		clr_province_flag = irrigation_system_rejected
		set_province_flag = irrigation_system
	}
	option = {
		name = "EVTOPTB8020"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 4
				owner = { trait = content }
			}
			modifier = {
				factor = 2
				owner = { trait = gardener }
			}
		}
		set_province_flag = irrigation_system_rejected
	}
}

# Irrigation system dilapidated
province_event = {
	id = 8025
	desc = "EVTDESC8025"
	
	trigger = {
		owner = { war = no }
		has_province_flag = irrigation_system
		has_siege = no
		owner = { wealth = 30 }
	}
	
	mean_time_to_happen = {
		months = 2000
		
		modifier = {
			factor = 5
			has_province_flag = irrigation_system_repaired
		}
		modifier = {
			factor = 2
			has_province_flag = dilapidated_irrigation_system
		}
	}
	
	option = {
		name = "EVTOPTA8025"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 4
				owner = { trait = ambitious }
			}
			modifier = {
				factor = 4
				owner = { trait = greedy }
			}
		}
		owner = { wealth = -15 }
		remove_province_modifier = dilapidated_irrigation_system
		clr_province_flag = dilapidated_irrigation_system
		set_province_flag = irrigation_system_repaired
	}
	option = {
		name = "EVTOPTB8025"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 4
				owner = { trait = content }
			}
		}
		add_province_modifier = {
			name = dilapidated_irrigation_system
			duration = -1
		}
		set_province_flag = dilapidated_irrigation_system
	}
}

# Rice depot
province_event = {
	id = 8030
	desc = "EVTDESC8030"
	
	trigger = {
		owner = { war = no }
		NOT = { has_province_flag = rice_depot }
		has_siege = no
		owner = { wealth = 50 }
	}
	
	mean_time_to_happen = {
		months = 2000
		
		modifier = {
			factor = 2
			has_province_flag = rice_depot_rejected
		}
	}
	
	option = {
		name = "EVTOPTA8030"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 4
				owner = { trait = ambitious }
			}
			modifier = {
				factor = 4
				owner = { trait = charitable }
			}
			modifier = {
				factor = 4
				owner = { trait = kind }
			}
			modifier = {
				factor = 4
				owner = { trait = patient }
			}
		}
		owner = { wealth = -25 }
		clr_province_flag = rice_depot_rejected
		set_province_flag = rice_depot
	}
	option = {
		name = "EVTOPTB8030"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 4
				owner = { trait = content }
			}
			modifier = {
				factor = 4
				owner = { trait = greedy }
			}
		}
		set_province_flag = rice_depot_rejected
		owner = { honor = -1 }
	}
}

# Drought hits $PROVINCENAME$
province_event = {
	id = 8035
	desc = "EVTDESC8035"
	
	trigger = {
		has_siege = no
		month = 4
		NOT = { month = 10 }
	}
	
	mean_time_to_happen = {
		months = 2000
		
		modifier = {
			factor = 0.75
			has_province_flag = land_reclamation
		}
		modifier = {
			factor = 1.5
			has_province_flag = irrigation_system
		}
		modifier = {
			factor = 2
			has_province_flag = drought
		}
	}
	
	immediate = {
		clr_province_flag = has_had_famine
		clr_province_flag = drought
		clr_province_flag = drought_help_sent
	}
	
	option = {
		name = "EVTOPTA8035"
		ai_chance = {
			factor = 75
			modifier = {
				factor = 2
				owner = { trait = kind }
			}
			modifier = {
				factor = 2
				owner = { trait = charitable }
			}
			modifier = {
				factor = 2
				owner = { trait = bushi }
			}
		}
		owner = { wealth = -10 }
		add_province_modifier = {
			name = drought
			duration = 180
		}
		set_province_flag = drought
		set_province_flag = drought_help_sent
	}
	option = {
		name = "EVTOPTB8035"
		ai_chance = {
			factor = 25
			modifier = {
				factor = 4
				owner = { trait = greedy }
			}
			modifier = {
				factor = 4
				owner = { trait = ruthless }
			}
		}
		add_province_modifier = {
			name = drought
			duration = 365
		}
		set_province_flag = drought
	}
}

# Floods hits $PROVINCENAME$
province_event = {
	id = 8040
	desc = "EVTDESC8040"
	
	trigger = {
		has_siege = no
		month = 3
		NOT = { month = 9 }
	}
	
	mean_time_to_happen = {
		months = 2000
		
		modifier = {
			factor = 0.75
			has_province_flag = land_reclamation
		}
		modifier = {
			factor = 1.5
			has_province_flag = irrigation_system
		}
		modifier = {
			factor = 1.5
			has_province_flag = river_dredging
		}
		modifier = {
			factor = 0.75
			has_province_flag = river_dredging_rejected
		}
		modifier = {
			factor = 2
			has_province_flag = floods
		}
	}

	immediate = {
		clr_province_flag = has_had_famine
		clr_province_flag = floods
		clr_province_flag = floods_help_sent
	}
	
	option = {
		name = "EVTOPTA8040"
		ai_chance = {
			factor = 75
			modifier = {
				factor = 2
				owner = { trait = kind }
			}
			modifier = {
				factor = 2
				owner = { trait = charitable }
			}
			modifier = {
				factor = 2
				owner = { trait = bushi }
			}
		}
		owner = { wealth = -10 }
		add_province_modifier = {
			name = floods
			duration = 180
		}
		set_province_flag = floods
		set_province_flag = floods_help_sent
	}
	option = {
		name = "EVTOPTB8040"
		ai_chance = {
			factor = 25
			modifier = {
				factor = 4
				owner = { trait = greedy }
			}
			modifier = {
				factor = 4
				owner = { trait = ruthless }
			}
		}
		add_province_modifier = {
			name = floods
			duration = 365
		}
		set_province_flag = floods
	}
}

# Famine hits $PROVINCENAME$!
province_event = {
	id = 8045
	desc = "EVTDESC8045"
	
	trigger = {
		has_province_modifier = drought
		NOT = { has_province_flag = has_had_famine }
		has_siege = no
	}
	
	mean_time_to_happen = {
		months = 120
		
		modifier = {
			factor = 1.5
			has_province_flag = drought_help_sent
		}
	}
	
	immediate = {
		clr_province_flag = farmers_or_soldiers
		clr_province_flag = famine_drought
		clr_province_flag = famine_drought_help_sent
		set_province_flag = has_had_famine
	}
	
	option = {
		name = "EVTOPTA8045"
		ai_chance = {
			factor = 40
			modifier = {
				factor = 2
				owner = { trait = kind }
			}
			modifier = {
				factor = 2
				owner = { trait = charitable }
			}
			modifier = {
				factor = 2
				owner = { trait = bushi }
			}
		}
		clr_province_flag = rice_depot
	}
	option = {
		name = "EVTOPTB8045"
		ai_chance = {
			factor = 40
			modifier = {
				factor = 1.25
				owner = { trait = kind }
			}
			modifier = {
				factor = 1.25
				owner = { trait = charitable }
			}
			modifier = {
				factor = 1.25
				owner = { trait = bushi }
			}
		}
		owner = { wealth = -10 }
		set_province_flag = famine_drought
		set_province_flag = famine_drought_help_sent
	}
	option = {
		name = "EVTOPTC8045"
		ai_chance = {
			factor = 20
			modifier = {
				factor = 4
				owner = { trait = greedy }
			}
			modifier = {
				factor = 4
				owner = { trait = ruthless }
			}
		}
		set_province_flag = famine_drought
	}
}

# Famine hits $PROVINCENAME$!
province_event = {
	id = 8050
	desc = "EVTDESC8050"
	
	trigger = {
		has_province_modifier = floods
		NOT = { has_province_flag = has_had_famine }
		has_siege = no
	}
	
	mean_time_to_happen = {
		months = 120
		
		modifier = {
			factor = 1.5
			has_province_flag = floods_help_sent
		}
	}
	
	immediate = {
		clr_province_flag = farmers_or_soldiers
		clr_province_flag = famine_floods
		clr_province_flag = famine_floods_help_sent
		set_province_flag = has_had_famine
	}
	
	option = {
		name = "EVTOPTA8050"
		ai_chance = {
			factor = 40
			modifier = {
				factor = 2
				owner = { trait = kind }
			}
			modifier = {
				factor = 2
				owner = { trait = charitable }
			}
			modifier = {
				factor = 2
				owner = { trait = bushi }
			}
		}
		clr_province_flag = rice_depot
	}
	option = {
		name = "EVTOPTB8050"
		ai_chance = {
			factor = 40
			modifier = {
				factor = 1.25
				owner = { trait = kind }
			}
			modifier = {
				factor = 1.25
				owner = { trait = charitable }
			}
			modifier = {
				factor = 1.25
				owner = { trait = bushi }
			}
		}
		owner = { wealth = -10 }
		set_province_flag = famine_floods
		set_province_flag = famine_floods_help_sent
	}
	option = {
		name = "EVTOPTC8050"
		ai_chance = {
			factor = 20
			modifier = {
				factor = 4
				owner = { trait = greedy }
			}
			modifier = {
				factor = 4
				owner = { trait = ruthless }
			}
		}
		set_province_flag = famine_floods
	}
}

# Food shortage in $PROVINCENAME$
province_event = {
	id = 8055
	desc = "EVTDESC8055"
	
	trigger = {
		has_province_flag = has_had_famine
		NOT = { has_province_flag = farmers_or_soldiers }
		has_siege = no
	}
	
	mean_time_to_happen = {
		months = 120
		
		modifier = {
			factor = 2
			has_province_flag = famine_drought_help_sent
		}
		modifier = {
			factor = 2
			has_province_flag = famine_floods_help_sent
		}
	}
	
	immediate = {
		set_province_flag = farmers_or_soldiers
	}
	
	option = {
		name = "EVTOPTA8055"
		ai_chance = {
			factor = 50
		}
		revolt_risk = 5
		add_province_modifier = {
			name = starving_soldiers
			duration = 365
		}

	}
	option = {
		name = "EVTOPTB8055"
		ai_chance = {
			factor = 50
		}
		revolt_risk = 5
		add_province_modifier = {
			name = starving_farmers
			duration = 365
		}
	}
}
