###################################
#
# Manchu Invasion Events
#
#
###################################

namespace = MANCHU

# Rumors of a Steppe Menace
narrative_event = {
	id = MANCHU.1
	title = EVTNAMEMANCHU.1
	desc = EVTDESCMANCHU.1
	major = yes
	
	picture = "GFX_evt_mongols"
	border = "GFX_event_narrative_frame_war"
	
	only_playable = yes
	
	trigger = {
		year = 1620
		
		has_landed_title = e_tenno
		
		NOT = { has_global_flag = manchu_horde_rumors }
		NOT = { has_global_flag = manchu_arrival }
#		NOT = { has_global_flag = hooge_arrival }
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	immediate = {
		set_global_flag = manchu_horde_rumors
		activate_title = { title = e_qing status = yes }
		create_random_soldier = {
			random_traits = no
			dynasty = 10000 # Aisin Gioro
			name = "Hong Taiji"
			culture = manchu
			religion = tengri_pagan
			age = 34
			attributes = {
				martial = 8
				diplomacy = 4
				stewardship = 5
				intrigue = 4
				learning = 3
			}
			health = 6
			fertility = 0.7
			trait = brilliant_strategist
			trait = wroth
			trait = cruel
			trait = proud
			trait = zealous
		}
		new_character = {
			e_qing = {
				grant_title = PREV
			}
			set_defacto_liege = THIS
		}
#		any_playable_ruler = {
#			limit = { ai = no }
#			chronicle = {
#				entry = CHRONICLE_MONGOL_RUMORS
#				portrait = [New.GetID]
#			}
#		}
		
	}
	
	option = {
		name = "EVTOPTAMANCHU.1"
	}
}

# Arrival of the Manchu army
narrative_event = {
	id = MANCHU.2
	title = "EVTNAMEMANCHU.2"
	desc = "EVTDESCMANCHU.2"
	major = yes
	hide_new = yes
	
	picture = "GFX_evt_mongols"
	border = "GFX_event_narrative_frame_war"
	
	only_playable = yes
	
	trigger = {
		year = 1626
		NOT = { year = 1644 }
		has_landed_title = e_qing
		has_global_flag = manchu_horde_rumors
		NOT = { has_global_flag = manchu_arrival }
	}
	
	mean_time_to_happen = {
		months = 1
		modifier = {
			factor = 0.5
			year = 1636
		}
		modifier = {
			factor = 0.5
			year = 1640
		}
	}
	
	option = {
		name = "EVTOPTAMANCHU.2"
		trigger = {
			has_landed_title = e_qing
		}
		set_global_flag = manchu_arrival
		if = {
			limit = {
				360 = { # Tsushima
					owner = {
						realm = {
							NOT = { title = e_qing }
						}
					}
				}
			}
			360 = { # Tsushima
				kingdom = {
					ROOT = {
						war = {
							casus_belli = tribal_invasion
							target = PREVPREV # The top liege of the owner of the province
							thirdparty_title = PREV # The de jure kingdom
						}
					}
				}
			}
		}
		if = {
			limit = {
				190 = { # Mikasa
					owner = {
						realm = {
							NOT = { title = e_qing }
						}
					}
				}
			}
			190 = { # Mikasa
				kingdom = {
					ROOT = {
						war = {
							casus_belli = tribal_invasion
							target = PREVPREV # The top liege of the owner of the province
							thirdparty_title = PREV # The de jure kingdom
						}
					}
				}
			}
		}
		if = {
			limit = {
				358 = { # Iki
					owner = {
						realm = {
							NOT = { title = e_qing }
						}
					}
				}
			}
			358 = { # Iki
				kingdom = {
					ROOT = {
						war = {
							casus_belli = tribal_invasion
							target = PREVPREV # The top liege of the owner of the province
							thirdparty_title = PREV # The de jure kingdom
						}
					}
				}
			}
		}
		
		wealth = 10000
		
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 30
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = 360 # Tsushima
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 35
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = 360 # Tsushima
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 40
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = 360 # Tsushima
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 30
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = 358 # Iki
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 35
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = 358 # Iki
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 40
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = 358 # Iki
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 39
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = 190 # Mikasa
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 35
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = 190 # Mikasa
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 40
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = 190 # Mikasa
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 35
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = 456 # Tsushima Strait
				troops =
				{
					galleys = { 200 200 }
				}
			}
		}

		
		# Some extra courtiers
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 16
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 18
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 18
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 20
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 25
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 26
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 28
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = yes
			age = 16
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = yes
			age = 17
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = yes
			age = 18
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = yes
			age = 18
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = yes
			age = 20
		}
	}
	option = {
		name = "EVTOPTBMANCHU.2"
		trigger = {
			religion_group = christian
			NOT = { has_landed_title = e_qing }
		}
	}
	option = {
		name = "EVTOPTCMANCHU.2"
		trigger = {
			religion_group = muslim
			NOT = { has_landed_title = e_qing }
		}
	}
	option = {
		name = "EVTOPTDMANCHU.2"
		trigger = {
			NOT = { religion_group = christian }
			NOT = { religion_group = muslim }
			NOT = { has_landed_title = e_qing }
		}
	}
}

# Manchu reinforcements
character_event = {
	id = MANCHU.3
	desc = "EVTDESCMANCHU.3"
	
	picture = "GFX_evt_mongols"
	border = "GFX_event_normal_frame_war"
	
	only_playable = yes
	
	trigger = {
		NOT = { year = 1700 }
		has_landed_title = e_qing
		NOT = { has_character_flag = manchu_reinf }
		had_global_flag = { flag = manchu_arrival days = 3650 }
		e_qing = {
			holder_scope = {
				culture = manchu
				religion = tengri_pagan
				OR = {
					war = yes
					is_landed = yes
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 1
	}
	
	option = {
		name = "EVTOPTAMANCHU.3"
		set_character_flag = manchu_reinf
		
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 30
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = 190 # Mikasa
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 32
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = 190 # Mikasa
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
			}
		}
		create_character = {
			random_traits = yes
			dynasty = random
			religion = tengri_pagan
			culture = manchu
			female = no
			age = 36
			attributes = {
				martial = 12
			}
			trait = brilliant_strategist
		}
		new_character = {
			spawn_unit = {
				province = 190 # Mikasa
				troops =
				{
					horse_archers = { 2700 2700 }
					light_cavalry = { 1600 1600 }
					light_infantry = { 541 541 }
					heavy_infantry = { 210 210 }
					knights = { 47 47 }
				}
			}
		}
	}
}