########################################
# Flavor Events for Dai Viet
#
# Scripted by Sara Wendel-rtqvist
########################################

namespace = flavor_dai
normal_or_historical_nations = yes

# Le Nghi Dan's Reforms
country_event = {
	id = flavor_dai.1
	title = "flavor_dai.EVTNAME1"
	desc = "flavor_dai.EVTDESC1"
	picture = REFORM_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		tag = DAI
		is_year = 1460
		NOT = { is_year = 1470 }
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	option = {
		name = "flavor_dai.EVTOPTA1"
		if = {
			limit = {
				NOT = { has_completed_all_reforms_trigger = yes }
			}
			add_reform_progress_small_effect = yes
		}
		add_adm_power = 100
	}
	option = {
		name = "flavor_dai.EVTOPTB1"
		if = {
			limit = {
				NOT = { has_completed_all_reforms_trigger = yes }
			}
			add_reform_progress_small_effect = yes
		}
		add_dip_power = 100
	}
	option = {
		name = "flavor_dai.EVTOPTC1"
		if = {
			limit = {
				NOT = { has_completed_all_reforms_trigger = yes }
			}
			add_reform_progress_small_effect = yes
		}
		add_mil_power = 100
	}
}

# The Rivalry of the Mac and Trinh Families
country_event = {
	id = flavor_dai.2
	title = "flavor_dai.EVTNAME2"
	desc = "flavor_dai.EVTDESC2"
	picture = BATTLE_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		tag = DAI
		is_year = 1527
		dynasty = ""
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	option = {
		name = "flavor_dai.EVTOPTA2"
		random_owned_province = {
			limit = {
				is_core = ROOT
			}
			add_unrest = 2
		}
	}
	option = {
		name = "flavor_dai.EVTOPTB2"
		add_adm_power = -20
	}
}

# The Tay Son Rebellion
country_event = {
	id = flavor_dai.3
	title = "flavor_dai.EVTNAME3"
	desc = "flavor_dai.EVTDESC3"
	picture = ANGRY_MOB_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		tag = DAI
		is_year = 1700
		NOT = { is_year = 1800 }
		NOT = {
			stability = 0
		}
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	immediate = {
		hidden_effect = {
			random_owned_province = {
				limit = {
					is_core = ROOT
				}
				set_province_flag = dai_tayson_rebellion_flag
			}
			random_owned_province = {
				limit = {
					is_core = ROOT
					NOT = { has_province_flag = dai_tayson_rebellion_flag }
				}
				set_province_flag = dai_tayson_rebellion_flag
			}
			random_owned_province = {
				limit = {
					is_core = ROOT
					NOT = { has_province_flag = dai_tayson_rebellion_flag }
				}
				set_province_flag = dai_tayson_rebellion_flag
			}
		}
	}
	
	option = {
		name = "flavor_dai.EVTOPTA3"
		every_owned_province = {
			limit = {
				has_province_flag = dai_tayson_rebellion_flag
			}
			spawn_rebels = {
				type = anti_tax_rebels
				size = 2
			}
			clr_province_flag = dai_tayson_rebellion_flag
		}
	}
	option = {
		name = "flavor_dai.EVTOPTB3"
		random_owned_province = {
			limit = {
				has_province_flag = dai_tayson_rebellion_flag
				is_capital = no
			}
			add_local_autonomy = 100
			clr_province_flag = dai_tayson_rebellion_flag
		}
		hidden_effect = {
			every_owned_province = {
				limit = {
					has_province_flag = dai_tayson_rebellion_flag
				}
				clr_province_flag = dai_tayson_rebellion_flag
			}
		}
	}
}

# Vietnamese mission events by Daniel Tolman

# Vietnamese Emperor of China
country_event = {
	id = flavor_dai.4
	title = flavor_dai.4.t
	desc = flavor_dai.4.d
	picture = NUSANTARA_THRONE_eventPicture
	
	is_triggered_only = yes
	
	option = {
		name = lavor_dai.4.a
		override_country_name = DAI_NAM
		set_country_flag = is_dai_nam_flag
		if = {
			limit = {
				has_dlc = "Mandate of Heaven"
				is_emperor_of_china = yes
			}
			add_mandate = 30
		}
		else = {
			add_prestige = 50
		}
	}
	option = {
		name = lavor_dai.4.b
		override_country_name = VIET_NAM
		set_country_flag = is_viet_nam_flag
		if = {
			limit = {
				has_dlc = "Mandate of Heaven"
				is_emperor_of_china = yes
			}
			add_mandate = 30
		}
		else = {
			add_prestige = 50
		}
	}
	option = { # keep old name
		name = lavor_dai.4.c
		if = {
			limit = {
				has_dlc = "Mandate of Heaven"
				is_emperor_of_china = yes
			}
			add_mandate = 30
		}
		else = {
			add_prestige = 50
		}
	}
}

# The Imperial Citadel
country_event = {
	id = flavor_dai.5
	title = flavor_dai.5.t
	desc = flavor_dai.5.d
	picture = CITY_VIEW_eventPicture
	
	is_triggered_only = yes
	
	option = {
		name = flavor_dai.5.a
		if = {
			limit = {
				2373 = {
					is_capital = no
				}
			}
			2373 = {
				move_capital_effect = yes
			}
		}
		2373 = {
			if = {
				limit = {
					NOT = { has_building = state_house }
				}
				add_building = state_house #Imperial Citadel
			}
		}
	}
	option = {
		name = flavor_dai.5.b
		if = {
			limit = {
				613 = {
					is_capital = no
				}
			}
			613 = {
				move_capital_effect = yes
			}
		}
		613 = {
			if = {
				limit = {
					NOT = { has_building = state_house }
				}
				add_building = state_house #Imperial Citadel
			}
			change_province_name = Hanoi rename_capital = Hanoi
		}
	}
}