########################################
# Flavor Events for Manchu
#
# Scripted by Sara Wendel-rtqvist
########################################

namespace = flavor_mch
normal_or_historical_nations = yes

# Nurhachi's Reforms
country_event = {
	id = flavor_mch.1
	title = "flavor_mch.EVTNAME1"
	desc = "flavor_mch.EVTDESC1"
	picture = REFORM_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		OR = {
			AND = { 
				OR = {
					AND = {
						tag = MJZ
						NOT = {
							exists = MCH
						}
					}
					tag = MCH
				}
				is_year = 1584
				NOT = { is_year = 1626 }
			}
			mission_completed = mch_proclaim_later_jin
		}
	}
	
	mean_time_to_happen = {
		months = 126
		modifier = {
			factor = 0.001
			mission_completed = mch_proclaim_later_jin
		}
	}
	
	option = {
		name = "flavor_mch.EVTOPTA1"
		if = { 
			limit = { has_country_flag = nurhaci_ruler_flag } 
			add_country_modifier = {
				name = mch_nurhaci_ruler_reforms_modifier
				duration = 9125 
			}
		}
		else_if = { 
			limit = { has_country_flag = nurhaci_general_flag }
			add_country_modifier = {
				name = mch_nurhaci_general_reforms_modifier
				duration = 9125 
			}
			if = { 
				limit = { has_dlc = "Cradle of Civilization" } 
				PA_random_army_exp_between_10_and_20_effect = yes    #PA: replaced flat gain with random dynamic gain. -- 200e200w
			}
			else = { add_army_tradition = 20 } 
		}
		else = { 
			add_country_modifier = {
				name = mch_nurhaci_advisor_reforms_modifier
				duration = 9125 
			}
		}
		clr_country_flag = nurhaci_ruler_flag
		clr_country_flag = nurhaci_general_flag
	}
}

# The Eastern Mongols Assimilated
country_event = {
	id = flavor_mch.2
	title = "flavor_mch.EVTNAME2"
	desc = "flavor_mch.EVTDESC2"
	picture = HORDE_ON_HORSEBACK_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		tag = MCH
		exists = MNG
		NOT = { vassal_of = MNG }
		is_year = 1600
		NOT = {
			is_year = 1700
		}
		is_at_war = no
		any_owned_province = {
			any_neighbor_province = {
				owned_by = MNG
				NOT = {
					is_claim = MCH
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	option = {
		name = "flavor_mch.EVTOPTA2"
		every_owned_province = {
			every_neighbor_province = {
				limit = {
					owned_by = MNG
					NOT = {
						is_claim = MCH
					}
				}
				add_claim = ROOT
			}
		}
	}
}

# The Manchu Army Reforms
country_event = {
	id = flavor_mch.3
	title = "flavor_mch.EVTNAME3"
	desc = "flavor_mch.EVTDESC3"
	picture = REFORM_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		OR = {
			tag = MCH
			AND = {
				tag = QNG
				NOT = {
					exists = MCH
				}
			}
		}
		is_year = 1600
		NOT = { is_year = 1700 }
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	option = {
		name = "flavor_mch.EVTOPTA3"
		add_mil_power = 50
		add_army_tradition = 20
	}
	option = {
		name = "flavor_mch.EVTOPTB3"
		add_adm_power = 50
	}
}

# The Manchu Advance
country_event = {
	id = flavor_mch.4 # id = 10035
	title = "flavor_mch.EVTNAME4"
	desc = "flavor_mch.EVTDESC4"
	picture = LAND_MILITARY_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		is_at_war = no
		exists = MNG
		NOT = { vassal_of = MNG }
		tag = MCH
		is_year = 1600
		NOT = { is_year = 1650 }
		NOT = { war_with = MNG }
		any_owned_province = { 
			any_neighbor_province = { 
				owned_by = MNG 
				NOT = {
					is_claim = ROOT
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	option = {
		name = "flavor_mch.EVTOPTA4"
		add_casus_belli = {
			target = MNG
			type = cb_border_war
			months = 24
		}
	}
	option = {
		name = "flavor_mch.EVTOPTB4"
		MNG = {
			add_opinion = {
				who = ROOT
				modifier = opinion_pleased
				years = 50
			}
		}
	}
}

# The Revolt of the Three Feudatories
# Rewritten by Daniel Tolman
country_event = {
	id = flavor_mch.5
	title = "flavor_mch.EVTNAME5"
	desc = "flavor_mch.EVTDESC5"
	picture = BATTLE_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		tag = QNG
		OR = {
			YUE = {
				is_subject_of = ROOT
				liberty_desire = 25
			}
			WUU = {
				is_subject_of = ROOT
				liberty_desire = 25
			}
			CDL = {
				is_subject_of = ROOT
				liberty_desire = 25
			}
			CZH = {
				is_subject_of = ROOT
				liberty_desire = 25
			}			
		}
	}
	
	mean_time_to_happen = {
		years = 20
	}
	
	immediate = {
		hidden_effect = {
			if = {
				limit = {
					CZH = {
						is_subject_of = ROOT
					}
				}
				if = {
					limit = {
						WUU = {
							is_subject_of = ROOT
						}
					}
					WUU = {
						create_alliance = CZH
					}
				}
				if = {
					limit = {
						YUE = {
							is_subject_of = ROOT
						}
					}
					YUE = {
						create_alliance = CZH
					}
				}
				if = {
					limit = {
						CDL = {
							is_subject_of = ROOT
						}
					}
					CDL = {
						create_alliance = CZH
					}
				}
			}
			else = {
				random_country = {
					limit = {
						is_subject_of = ROOT
						OR = {
							tag = CZH
							tag = WUU
							tag = YUE
							tag = CDL
						}
					}
					save_event_target_as = three_feudatories_leader
					set_country_flag = three_feudatories_leader_flag
				}
				if = {
					limit = {
						WUU = {
							NOT = { has_country_flag = three_feudatories_leader_flag }
							is_subject_of = ROOT
						}
					}
					WUU = {
						create_alliance = event_target:three_feudatories_leader
					}
				}
				if = {
					limit = {
						YUE = {
							NOT = { has_country_flag = three_feudatories_leader_flag }
							is_subject_of = ROOT
						}
					}
					YUE = {
						create_alliance = event_target:three_feudatories_leader
					}
				}
				if = {
					limit = {
						CDL = {
							NOT = { has_country_flag = three_feudatories_leader_flag }
							is_subject_of = ROOT
						}
					}
					CDL = {
						create_alliance = event_target:three_feudatories_leader
					}
				}
			}
		}
	}
	
	option = {
		name = "flavor_mch.EVTOPTA5"
		if = {
			limit = {
				CZH = {
					is_subject_of = ROOT
				}
			}
			CZH = {
				declare_war_with_cb = {
					who = ROOT
					casus_belli = cb_independence_war
				}
			}
		}
		else = {
			event_target:three_feudatories_leader = {
				declare_war_with_cb = {
					who = ROOT
					casus_belli = cb_independence_war
				}
			}
		}
	}
}

# The Expulsion of the Jesuits
country_event = {
	id = flavor_mch.6
	title = "flavor_mch.EVTNAME6"
	desc = "flavor_mch.EVTDESC6"
	picture = RELIGION_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		tag = QNG
		is_year = 1700
		NOT = { is_year = 1800 }
		NOT = {
			religion_group = christian
		}
		OR = {
			POR = { has_country_modifier = the_societas_jesu }
			SPA = { has_country_modifier = the_societas_jesu }
		}
		any_owned_province = { any_neighbor_province = { OR = { owned_by = POR owned_by = SPA } } }
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	option = {
		name = "flavor_mch.EVTOPTA6"
		add_stability_or_adm_power = yes
	}
	option = {
		name = "flavor_mch.EVTOPTB6"
		add_country_modifier = { 
			name = mch_jesuits 
			duration = -1 
		}
	}
}

# The Appointment of Heshen
country_event = {
	id = flavor_mch.7
	title = "flavor_mch.EVTNAME7"
	desc = "flavor_mch.EVTDESC7"
	picture = ADVISOR_eventPicture
	
	fire_only_once = yes
	
	trigger = {
		tag = QNG
		is_year = 1770
		NOT = { is_year = 1800 }
		NOT = {
			is_advisor_employed = 380
		}
		NOT = {
			advisor_exists = 380
		}
	}
	
	mean_time_to_happen = {
		months = 200
	}
	
	option = {
		name = "flavor_mch.EVTOPTA7"
		add_meritocracy_effect = yes
		define_advisor = {
			type = statesman
			discount = yes
			culture = manchu
			religion = confucianism
			skill = 2
			name = "Heshen"
		}
		add_corruption = 0.5
	}
	option = {
		name = "flavor_mch.EVTOPTB7"
		add_adm_power = 25
	}
}

# Rise of the Manchu
country_event = {
	id = flavor_mch.8
	title = "flavor_mch.EVTNAME8"
	desc = "flavor_mch.EVTDESC8"
	picture = ADVISOR_eventPicture
	is_triggered_only = yes
	major = yes
	
	option = {
		name = "flavor_mch.EVTOPTA8"
		if = {
			limit = {
				has_dlc = "Mandate of Heaven"

			}
			add_mandate = -50
		}
		else = {
			add_horde_unity = -50
			add_legitimacy = -50
		}
		tooltip = {
			FROM = {
				grant_independence = yes
			}
		}
	}
}

##########################################
#1.35 Events for Qing / Jianzhou / Manchu#
	# by Big Boss #
##########################################
country_event = { #Nurhaci 
	id = flavor_mch.9
	title = flavor_mch.9.t 
	desc = flavor_mch.9.d 
	picture = BATTLE_eventPicture
	is_triggered_only = yes
	
	option = { 
		name = flavor_mch.9.a 
		
		define_ruler = {
			name = "Nurhachi"
			dynasty = "Aisin-Gioro"
			change_adm = 2
			change_dip = 3
			change_mil = 4
			hide_skills = yes 
		}
		if = { 
			limit = { has_dlc = "Rights of Man" } 
			custom_tooltip = mjz_legendary_conqueror_trait
			hidden_effect = { 
				add_ruler_personality = legendary_conqueror_personality
			}
		}
		set_country_flag = nurhaci_ruler_flag

		custom_tooltip = mch_inform_about_impact_tt		
	}

	option = { 
		name = flavor_mch.9.b 
		
		define_general = {
			name = "Nurhachi"
			fire = 3 
			shock = 6 
			manuever = 5 
			siege = 3 
			trait = dragon_tiger_general_personality
		}
		add_army_tradition = 10 
		if = { 
			limit = { has_estate = estate_nomadic_tribes } 
			add_estate_loyalty = {
				estate = estate_nomadic_tribes 
				loyalty = 10 
			}
		}
		set_country_flag = nurhaci_general_flag
		
		custom_tooltip = mch_inform_about_impact_tt
	}
	
	option = {
		name = flavor_mch.9.c 
		
		define_advisor = {
			name = "Nurhachi" 
			type = commandant 
			skill = 3 
			cost_multiplier = 0.1 
		}
		add_mil_power = 100 
		
		if = { 
			limit = { has_estate = estate_nomadic_tribes } 
			add_estate_loyalty = {
				estate = estate_nomadic_tribes 
				loyalty = 10 
			}
		}
		
		custom_tooltip = mch_inform_about_impact_tt
	}
}
	
country_event = { #Seven Grievances 
	id = flavor_mch.10
	title = flavor_mch.10.t 
	desc = flavor_mch.10.d 
	picture = BATTLE_eventPicture
	is_triggered_only = yes
	
	option = { 
		name = flavor_mch.10.a 
		
		add_ruler_modifier = {
			name = mch_seven_grievances_declaration_modifier
			duration = -1 
		}
	}
}

country_event = { #The Conquest of Korea
	id = flavor_mch.11
	title = flavor_mch.11.t 
	desc = flavor_mch.11.d 
	picture = BATTLE_eventPicture
	is_triggered_only = yes
	
	option = { 
		name = flavor_mch.11.a
		
		add_country_modifier = { 
			name = mch_studied_korea_alphabet_modifier
			duration = 9125 
		}
	}
	
	option = { 
		name = flavor_mch.11.b
		
		add_country_modifier = { 
			name = mch_hyang_yak_system_modifier
			duration = 9125 
		}
	}
	
	option = { 
		name = flavor_mch.11.c
		
		add_country_modifier = { 
			name = mch_hopae_system_modifier
			duration = 9125 
		}
	}
	
	option = { 
		name = flavor_mch.11.e
		
		add_country_modifier = { 
			name = mch_kyujanggak_modifier
			duration = 9125 
		}
		custom_tooltip = warriors_can_read_some_books_tt
		set_country_flag = warriors_can_read_some_books_flag
	}
	
	option = { 
		name = flavor_mch.11.f
		
		add_country_modifier = {
			name = mch_forced_integration_modifier
			duration = 9125 
		}
	}
}

country_event = { #Entering the City of [586.GetName]
	id = flavor_mch.12
	title = flavor_mch.12.t 
	desc = flavor_mch.12.d 
	picture = BATTLE_eventPicture
	is_triggered_only = yes
	
	option = { 
		name = flavor_mch.12.a
		
		add_country_modifier = {
			name = qng_subjugation_of_burma_modifier
			duration = -1 
		}
		
		if = { 
			limit = { has_dlc = "Leviathan" }
			if = {
				limit = { 
					586 = {
						NOT = { 
							has_great_project = {
								type = kanbawzathadi_palace
								tier = 3 
							}
						}
					}
				}
				586 = { 
					add_great_project_tier = {
						type = kanbawzathadi_palace
						tier = 1 
					}
					add_base_tax = 3 
					add_base_production = 3 
					add_base_manpower = 2 
				}
			}
		}
		else = {
			586 = { 
				add_base_tax = 3 
				add_base_production = 3 
				add_base_manpower = 2 
			}
		}
	}
}

country_event = { #The High Qing Era
	id = flavor_mch.13
	title = flavor_mch.13.t 
	desc = flavor_mch.13.d 
	picture = MERITOCRACY_eventPicture
	is_triggered_only = yes
	
	option = {
		name = flavor_mch.13.a 
		
		if = {
			limit = { in_golden_age = yes } 
			extend_golden_age = 240
		}
		else = {
			add_country_modifier = {
				name = qng_high_qing_era_modifier
				duration = 18250 
			}
		}
		if = {
			limit = { 
				is_emperor_of_china = yes 
			}
			add_mandate = 10 
		}
		
	}
}
	
	