namespace = meiji

# Emperor takes power
meiji.1 = {
	type = country_event
	placement = root
	title = meiji.1.t
	desc = meiji.1.d
	flavor = meiji.1.f

	duration = 3

	icon = "gfx/interface/icons/event_icons/event_scales.dds"

	gui_window = event_window_1char_tabloid

	left_icon = scope:meiji_ruler

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/misc/1Character_Banner"

	trigger = {
		# triggered by meiji restoration JE
	}

	immediate = {
		set_variable = {
			name = meiji_var
			value = 0
		}
		ig:ig_landowners = {
			save_scope_as = shogunate_ig
			leader = {
				save_scope_as = shogunate_ig_leader
			}
		}
		if = {
			limit = {
				year < 1852
			}
			create_character = {
				# Emperor Ninko
				first_name = "Ninko"
				last_name = "Yamato"
				ruler = yes
				birth_date = 1800.1.1
				dna = dna_ninko
				interest_group = ig_landowners # beholden to the Shogun
				ideology = ideology_traditionalist
				traits = {
					reserved # not very active in affairs of state
				}
			}
			create_character = {
				first_name = "Komei"
				last_name = Yamato
				heir = yes
				birth_date = 1831.1.1
				dna = dna_emperor_komei
				interest_group = ig_armed_forces
				traits = {
					reserved # ditto
				}
			}
		}
		else_if = {
			limit = {
				year >= 1852
				year < 1879
			}
			create_character = {
				first_name = "Komei"
				last_name = "Yamato"
				ruler = yes
				birth_date = 1831.1.1
				dna = dna_emperor_komei
				interest_group = ig_armed_forces
				traits = {
					reserved # ditto
				}
			}
			create_character = {
				first_name = "Meiji"
				last_name = "Yamato"
				heir = yes
				birth_date = 1852.1.1
				dna = dna_emperor_meiji
				interest_group = ig_industrialists
				traits = {
					innovative
					charismatic
				}
			}
		}
		else_if = {
			limit = {
				year >= 1879
				year < 1912
			}
			create_character = {
				first_name = "Meiji"
				last_name = "Yamato"
				ruler = yes
				birth_date = 1852.1.1
				dna = dna_emperor_meiji
				interest_group = ig_industrialists
				traits = {
					innovative
					charismatic
				}
			}
			create_character = {
				first_name = "Taisho"
				last_name = "Yamato"
				heir = yes
				birth_date = 1879.1.1
				interest_group = ig_industrialists
				traits = {
				}
			}
		}
		else_if = {
			limit = {
				year >= 1912
				year < 1928
			}
			create_character = {
				first_name = "Taisho"
				last_name = "Yamato"
				ruler = yes
				birth_date = 1879.1.1
				interest_group = ig_industrialists
				traits = {
				}
			}
			create_character = {
				first_name = "Showa" # Hirohito
				last_name = "Yamato"
				heir = yes
				birth_date = 1901.1.1
				interest_group = ig_armed_forces
				traits = {
				}
			}
		}
		else_if = {
			limit = {
				year >= 1928
				year < 1989
			}
			create_character = {
				first_name = "Showa" # Hirohito
				last_name = "Yamato"
				heir = yes
				birth_date = 1901.1.1
				interest_group = ig_armed_forces
				traits = {
				}
			}
		}
		ruler = {
			save_scope_as = meiji_ruler
		}
		add_journal_entry = {
			type = je_meiji_main
		}
	}

	option = { # favour the industrialists
		name = meiji.1.a
		default_option = yes
		ig:ig_industrialists = {
			add_modifier = {
				name = meiji_favored_ig
				months = normal_modifier_time
			}
		}
		set_capital = STATE_KANTO
		custom_tooltip = shogunate_rename.tt
		hidden_effect = {
			scope:shogunate_ig = {
				set_interest_group_name = ig_landowners
			}
		}
		scope:shogunate_ig_leader = { # honorable sudoku
			kill_character = yes
		}
		if = {
			limit = {
				in_default = no
				any_scope_state = {
					filter = {
						is_incorporated = yes
					}
					any_scope_building = {
						is_building_type = building_urban_center
						level >= 5
					}
					has_building = building_railway
					percent > 0.7
				}
			}
			change_variable = {
				name = meiji_var
				add = 1
			}
		}
		else = {
			add_journal_entry = {
				type = je_meiji_economy
			}
		}
		if = {
			limit = {
				NOT = { has_law = law_type:law_serfdom }
				ig:ig_armed_forces = {
					is_powerful = no
					is_in_government = no
				}
				has_technology_researched = napoleonic_warfare
				NOT = {
					any_scope_building = {
						is_building_type = building_barracks
						OR = {
							has_active_production_method = pm_irregular_infantry
							has_active_production_method = pm_no_artillery
							has_active_production_method = pm_cannon_artillery
						}
					}
				}
			}
			change_variable = {
				name = meiji_var
				add = 1
			}
			trigger_event = {
				id = meiji.3
			}
		}
		else = {
			add_journal_entry = {
				type = je_meiji_army
			}
		}
		if = {
			limit = {
				NOT = { is_country_type = unrecognized }
				NOT = { has_law = law_type:law_isolationism }
			}
			change_variable = {
				name = meiji_var
				add = 1
			}
		}
		else = {
			add_journal_entry = {
				type = je_meiji_diplomacy
			}
		}
	}
	option = { # favour the intellectuals
		name = meiji.1.b
		ig:ig_intelligentsia = {
			add_modifier = {
				name = meiji_favored_ig
				months = normal_modifier_time
			}
		}
		set_capital = STATE_KANTO
		custom_tooltip = shogunate_rename.tt
		hidden_effect = {
			scope:shogunate_ig = {
				set_interest_group_name = ig_landowners
			}
		}
		scope:shogunate_ig_leader = {
			kill_character = yes
		}
		if = {
			limit = {
				in_default = no
				any_scope_state = {
					filter = {
						is_incorporated = yes
					}
					any_scope_building = {
						is_building_type = building_urban_center
						level >= 5
					}
					has_building = building_railway
					percent > 0.7
				}
			}
			change_variable = {
				name = meiji_var
				add = 1
			}
		}
		else = {
			add_journal_entry = {
				type = je_meiji_economy
			}
		}
		if = {
			limit = {
				NOT = { has_law = law_type:law_serfdom }
				ig:ig_armed_forces = {
					is_powerful = no
					is_in_government = no
				}
				has_technology_researched = napoleonic_warfare
				NOT = {
					any_scope_building = {
						is_building_type = building_barracks
						OR = {
							has_active_production_method = pm_irregular_infantry
							has_active_production_method = pm_no_artillery
							has_active_production_method = pm_cannon_artillery
						}
					}
				}
			}
			change_variable = {
				name = meiji_var
				add = 1
			}
			trigger_event = {
				id = meiji.3
			}
		}
		else = {
			add_journal_entry = {
				type = je_meiji_army
			}
		}
		if = {
			limit = {
				NOT = { is_country_type = unrecognized }
				NOT = { has_law = law_type:law_isolationism }
			}
			change_variable = {
				name = meiji_var
				add = 1
			}
		}
		else = {
			add_journal_entry = {
				type = je_meiji_diplomacy
			}
		}
	}
}

# Reforms complete!
meiji.2 = {
	type = country_event
	placement = root
	title = meiji.2.t
	desc = meiji.2.d
	flavor = meiji.2.f

	duration = 3

	icon = "gfx/interface/icons/event_icons/event_scales.dds"
	event_image = {
		video = "gfx/event_pictures/asia_confucianism_shinto.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/asia/confucianism_shinto" 

	trigger = {
		# triggered by meiji restoration JE
	}

	immediate = {
		ruler = {
			save_scope_as = meiji_ruler
		}
		set_global_variable = meiji_restoration_complete
	}

	option = {
		name = meiji.2.a
		default_option = yes
		add_modifier = {
			name = japan_military_reward
			months = normal_modifier_time
		}
		if = {
			limit = {
				NOT = { owns_entire_state_region = STATE_BUSAN }
			}
			s:STATE_BUSAN = {
				add_claim = ROOT
			}
		}
		if = {
			limit = {
				NOT = { owns_entire_state_region = STATE_SEOUL }
			}
			s:STATE_SEOUL = {
				add_claim = ROOT
			}
		}
		if = {
			limit = {
				NOT = { owns_entire_state_region = STATE_SARIWON }
			}
			s:STATE_SARIWON = {
				add_claim = ROOT
			}
		}
		if = {
			limit = {
				NOT = { owns_entire_state_region = STATE_PYONGYANG }
			}
			s:STATE_PYONGYANG = {
				add_claim = ROOT
			}
		}
		if = {
			limit = {
				NOT = { owns_entire_state_region = STATE_YANGHO }
			}
			s:STATE_YANGHO = {
				add_claim = ROOT
			}
		}
	}
	option = {
		name = meiji.2.b
		add_modifier = {
			name = japan_diplomatic_reward
			months = normal_modifier_time
		}
	}
	option = {
		name = meiji.2.c
		add_modifier = {
			name = japan_production_reward
			months = normal_modifier_time
		}
	}
}

# Fall of the Samurai
meiji.3 = {
	type = country_event
	placement = root
	title = meiji.3.t
	desc = meiji.3.d
	flavor = meiji.3.f

	duration = 3

	icon = "gfx/interface/icons/event_icons/event_military.dds"
	event_image = {
		video = "gfx/event_pictures/asia_westerners_arriving.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/asia/westeners_arriving_in_east_asia" 

	trigger = {
		# triggered by JE
	}

	immediate = {
		ig:ig_armed_forces = {
			save_scope_as = samurai_ig
			leader = {
				save_scope_as = samurai_ig_leader
			}
		}
	}

	option = { # give former samurai officer positions in the new army
		name = meiji.3.a
		default_option = yes
		custom_tooltip = samurai_rename.tt
		hidden_effect = {
			scope:samurai_ig = {
				set_interest_group_name = ig_armed_forces
			}
		}
		scope:samurai_ig = {
			remove_ideology = ideology_bakufu
		}
		# reduce mil tech spread
		add_modifier = {
			name = samurai_officers
			months = normal_modifier_time
		}
	}
	option = { # expel the samurai from the army
		name = meiji.3.b
		custom_tooltip = samurai_rename.tt
		hidden_effect = {
			scope:samurai_ig = {
				set_interest_group_name = ig_armed_forces
			}
		}
		scope:samurai_ig = {
			remove_ideology = ideology_bakufu
		}
		scope:samurai_ig_leader = { # honorable sudoku
			kill_character = yes
		}
		add_radicals = {
			pop_type = officers
			culture = cu:japanese
			value = 0.8
		}
		add_radicals = {
			pop_type = soldiers
			culture = cu:japanese
			value = 0.5
		}
	}
}

# Western military advisors
meiji.4 = {
	type = country_event
	placement = root
	title = meiji.4.t
	desc = meiji.4.d
	flavor = meiji.4.f

	duration = 3

	icon = "gfx/interface/icons/event_icons/event_military.dds"
	event_image = {
		video = "gfx/event_pictures/asia_westerners_arriving.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/asia/westeners_arriving_in_east_asia"

	trigger = {
		NOT = {	has_modifier = western_military_consultant }
		OR = {
			AND = {
				has_law = law_type:law_isolationism
				OR = {
					is_enacting_law = law_type:law_mercantilism
					is_enacting_law = law_type:law_agrarianism
					is_enacting_law = law_type:law_free_trade
					is_enacting_law = law_type:law_command_economy
				}
			}
			AND = {
				has_journal_entry = je_meiji_diplomacy
				OR = {
					NOT = { has_law = law_type:law_isolationism }
					is_enacting_law = law_type:law_mercantilism
					is_enacting_law = law_type:law_agrarianism
					is_enacting_law = law_type:law_free_trade
					is_enacting_law = law_type:law_command_economy
				}
				enacting_any_law = no
			}
		}
		any_country = {
			country_rank >= rank_value:major_power
			relations:root >= relations_threshold:neutral
			relations:root >= 0
			NOT = { is_owed_obligation_by = ROOT }
			NOT = { has_war_with = ROOT }
			any_scope_character = {
				has_role = general
				is_busy = no
			}
		}
	}

	immediate = {
		random_country = {
			limit = {
				country_rank >= rank_value:major_power
				relations:root >= relations_threshold:neutral
				NOT = { is_owed_obligation_by = ROOT }
				NOT = { has_war_with = ROOT }
				any_scope_character = {
					has_role = general
					is_busy = no
				}
			}
			save_scope_as = military_consultant_country
			random_scope_character = {
				limit = {
					has_role = general
					is_busy = no
				}
				save_scope_as = military_consultant_general
			}
		}
	}

	option = {
		name = meiji.4.a
		default_option = yes
		set_owes_obligation_to = {
			country = scope:military_consultant_country
			setting = yes
		}
		add_modifier = {
			name = western_military_consultant
			months = short_modifier_time
		}
		if = {
			limit = {
				has_law = law_type:law_isolationism
				OR = {
					is_enacting_law = law_type:law_mercantilism
					is_enacting_law = law_type:law_protectionism
					is_enacting_law = law_type:law_free_trade
				}
			}
			add_enactment_modifier = {
				name = ending_isolation
			}
		}
	}
	option = {
		name = meiji.4.b
		change_relations = {
			country = scope:military_consultant_country
			value = -20
		}
		if = {
			limit = {
				has_law = law_type:law_isolationism
				OR = {
					is_enacting_law = law_type:law_mercantilism
					is_enacting_law = law_type:law_protectionism
					is_enacting_law = law_type:law_free_trade
				}
			}
			add_enactment_modifier = {
				name = ending_isolation
			}
		}
	}
}

# Embassy to the West
meiji.5 = {
	type = country_event
	placement = root
	title = meiji.5.t
	desc = meiji.5.d
	flavor = meiji.5.f

	duration = 3

	icon = "gfx/interface/icons/event_icons/event_default.dds"
	event_image = {
		video = "gfx/event_pictures/asia_westerners_arriving.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/asia/westeners_arriving_in_east_asia"

	cooldown = { months = short_modifier_time }

	trigger = {
		NOT = { has_modifier = japan_society_tech_modifier }
		OR = {
			AND = {
				has_law = law_type:law_isolationism
				OR = {
					is_enacting_law = law_type:law_mercantilism
					is_enacting_law = law_type:law_agrarianism
					is_enacting_law = law_type:law_free_trade
					is_enacting_law = law_type:law_command_economy
				}
			}
			AND = {
				has_journal_entry = je_meiji_diplomacy
				OR = {
					NOT = { has_law = law_type:law_isolationism }
					is_enacting_law = law_type:law_mercantilism
					is_enacting_law = law_type:law_agrarianism
					is_enacting_law = law_type:law_free_trade
					is_enacting_law = law_type:law_command_economy
				}
				enacting_any_law = no
			}
		}
		any_country = {
			country_rank = rank_value:great_power
			relations:root >= relations_threshold:neutral
			NOT = { has_war_with = ROOT }
			NOT = { is_owed_obligation_by = ROOT }
		}
	}
	immediate = {
		random_country = {
			limit = {
				country_rank = rank_value:great_power
				relations:root >= relations_threshold:neutral
				NOT = { has_war_with = ROOT }
				NOT = { is_owed_obligation_by = ROOT }
			}
			save_scope_as = japan_embassy_country
			random_interest_group = {
				limit = {
					is_in_government = yes
				}
				leader = {
					save_scope_as = japan_embassy_politician
				}
			}
		}
	}

	option = { # greatly improve relations for a obligation
		name = meiji.5.a
		default_option = yes
		set_owes_obligation_to = {
			country = scope:japan_embassy_country
			setting = yes
		}
		change_relations = {
			country = scope:japan_embassy_country
			value = 50
		}
		if = {
			limit = {
				has_law = law_type:law_isolationism
				OR = {
					is_enacting_law = law_type:law_mercantilism
					is_enacting_law = law_type:law_protectionism
					is_enacting_law = law_type:law_free_trade
				}
			}
			add_enactment_modifier = {
				name = ending_isolation
			}
		}
	}
	option = { # society tech spread for a obligation
		name = meiji.5.b
		set_owes_obligation_to = {
			country = scope:japan_embassy_country
			setting = yes
		}
		add_modifier = {
			name = japan_society_tech_modifier
			months = short_modifier_time
		}
		if = {
			limit = {
				has_law = law_type:law_isolationism
				OR = {
					is_enacting_law = law_type:law_mercantilism
					is_enacting_law = law_type:law_protectionism
					is_enacting_law = law_type:law_free_trade
				}
			}
			add_enactment_modifier = {
				name = ending_isolation
			}
		}
	}
	option = { # we don't want anything from them
		name = meiji.5.c
		change_relations = {
			country = scope:japan_embassy_country
			value = -20
		}
		if = {
			limit = {
				has_law = law_type:law_isolationism
				OR = {
					is_enacting_law = law_type:law_mercantilism
					is_enacting_law = law_type:law_protectionism
					is_enacting_law = law_type:law_free_trade
				}
			}
			add_enactment_modifier = {
				name = ending_isolation
			}
		}
	}
}

# Foreign Investment
meiji.6 = {
	type = country_event
	placement = root
	title = meiji.6.t
	desc = meiji.6.d
	flavor = meiji.6.f

	duration = 3

	icon = "gfx/interface/icons/event_icons/event_trade.dds"
	event_image = {
		video = "gfx/event_pictures/europenorthamerica_capitalists_meeting.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/europenorthamerica/capitalists_meeting" 

	trigger = {
		NOT = { has_modifier = japan_production_tech_modifier }
		OR = {
			AND = {
				has_law = law_type:law_isolationism
				OR = {
					is_enacting_law = law_type:law_mercantilism
					is_enacting_law = law_type:law_agrarianism
					is_enacting_law = law_type:law_free_trade
					is_enacting_law = law_type:law_command_economy
				}
			}
			AND = {
				has_journal_entry = je_meiji_diplomacy
				OR = {
					NOT = { has_law = law_type:law_isolationism }
					is_enacting_law = law_type:law_mercantilism
					is_enacting_law = law_type:law_agrarianism
					is_enacting_law = law_type:law_free_trade
					is_enacting_law = law_type:law_command_economy
				}
				enacting_any_law = no
			}
		}		
		any_country = {
			country_rank >= rank_value:major_power
			relations:root >= relations_threshold:neutral
			NOT = { has_war_with = ROOT }
			NOT = { is_owed_obligation_by = ROOT }
			ig:ig_industrialists = {
				is_in_government = yes
			}
		}
	}

	immediate = {
		random_country = {
			limit = {
				country_rank >= rank_value:major_power
				relations:root >= relations_threshold:neutral
				NOT = { has_war_with = ROOT }
				NOT = { is_owed_obligation_by = ROOT }
				ig:ig_industrialists = {
					is_in_government = yes
				}
			}
			save_scope_as = western_investor_country
			ig:ig_industrialists = {
				leader = {
					save_scope_as = western_investor_ig_leader
				}
			}
		}
	}

	option = { # production tech spread for a obligation
		name = meiji.6.a
		default_option = yes
		set_owes_obligation_to = {
			country = scope:western_investor_country
			setting = yes
		}
		add_modifier = {
			name = japan_production_tech_modifier
			months = short_modifier_time
		}
		if = {
			limit = {
				has_law = law_type:law_isolationism
				OR = {
					is_enacting_law = law_type:law_mercantilism
					is_enacting_law = law_type:law_protectionism
					is_enacting_law = law_type:law_free_trade
				}
			}
			add_enactment_modifier = {
				name = ending_isolation
			}
		}
	}
	option = { # no thanks
		name = meiji.6.b
		change_relations = {
			country = scope:western_investor_country
			value = -2
		}
		if = {
			limit = {
				has_law = law_type:law_isolationism
				OR = {
					is_enacting_law = law_type:law_mercantilism
					is_enacting_law = law_type:law_protectionism
					is_enacting_law = law_type:law_free_trade
				}
			}
			add_enactment_modifier = {
				name = ending_isolation
			}
		}
	}
}

# Foreign Railway Engineers
meiji.7 = {
	type = country_event
	placement = root
	title = meiji.7.t
	desc = meiji.7.d
	flavor = meiji.7.f

	duration = 3

	icon = "gfx/interface/icons/event_icons/event_industry.dds"

	event_image = {
		video = "gfx/event_pictures/unspecific_trains.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/unspecific/trains"

	trigger = {
		NOT = { has_variable = foreign_railway_engineers_event }
		can_research = railways
		NOT = { has_technology_researched = railways }
		any_country = {
			country_rank = rank_value:great_power
			has_technology_researched = railways
			NOT = { has_war_with = root }
			relations:root > 0
		}
	}

	immediate = {
		set_variable = foreign_railway_engineers_event
		random_country = {
			limit = {
				country_rank = rank_value:great_power
				has_technology_researched = railways
				NOT = { has_war_with = root }
				relations:root > 0
			}
			save_scope_as = railway_engineer_country_1
		}
		if = {
			limit = {
				any_country = {
					country_rank = rank_value:great_power
					has_technology_researched = railways
					NOT = { has_war_with = root }
					relations:root > 0
					NOT = { this = scope:railway_engineer_country_1 }
				}
			}
			random_country = {
				limit = {
					country_rank = rank_value:great_power
					has_technology_researched = railways
					NOT = { has_war_with = root }
					relations:root > 0
					NOT = { this = scope:railway_engineer_country_1 }
				}
				save_scope_as = railway_engineer_country_2
			}
		}
		if = {
			limit = {
				exists = scope:railway_engineer_country_2
				any_country = {
					country_rank = rank_value:great_power
					has_technology_researched = railways
					NOT = { has_war_with = root }
					relations:root > 0
					NOT = { this = scope:railway_engineer_country_1 }
					NOT = { this = scope:railway_engineer_country_2 }
				}
			}
			random_country = {
				limit = {
					country_rank = rank_value:great_power
					has_technology_researched = railways
					NOT = { has_war_with = root }
					relations:root > 0
					NOT = { this = scope:railway_engineer_country_1 }
					NOT = { this = scope:railway_engineer_country_2 }
				}
				save_scope_as = railway_engineer_country_3
			}
		}
	}

	option = {
		name = meiji.7.a
		change_relations = {
			country = scope:railway_engineer_country_1
			value = 10
		}
		add_technology_progress = {
			technology = railways
			progress = 3500
		}
	}

	option = {
		name = meiji.7.b

		trigger = {
			exists = scope:railway_engineer_country_2
		}
		change_relations = {
			country = scope:railway_engineer_country_2
			value = 10
		}
		add_technology_progress = {
			technology = railways
			progress = 3500
		}
	}

	option = {
		name = meiji.7.c

		trigger = {
			exists = scope:railway_engineer_country_3
		}
		change_relations = {
			country = scope:railway_engineer_country_3
			value = 10
		}
		add_technology_progress = {
			technology = railways
			progress = 3500
		}
	}

	option = {
		name = meiji.7.e
		default_option = yes

		add_modifier = {
			name = railway_our_way
			months = long_modifier_time
		}
	}
}

# Military Railways
meiji.8 = {
	type = country_event
	placement = scope:military_railway_state
	title = meiji.8.t
	desc = meiji.8.d
	flavor = meiji.8.f

	duration = 3

	icon = "gfx/interface/icons/event_icons/event_industry.dds"

	event_image = {
		video = "gfx/event_pictures/unspecific_armored_train.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/unspecific/armored_train"

	trigger = {
		has_technology_researched = railways
		any_scope_state = {
			has_building = building_barracks
			NOT = { has_building = building_railway }
		}
		NOT = { has_modifier = retained_railway_control }
	}

	immediate = {
		random_scope_state = {
			limit = {
				has_building = building_barracks
				NOT = { has_building = building_railway }
			}
			save_scope_as = military_railway_state
		}
		ig:ig_armed_forces = {
			save_scope_as = armed_forces_ig
		}
	}

	option = {
		name = meiji.8.a
		scope:military_railway_state = {
			create_building = {
				building = building_railway
				level = 1
			}
		}
		ig:ig_armed_forces = {
			add_modifier = {
				name = railway_priority
				months = long_modifier_time
			}
		}
	}

	option = {
		name = meiji.8.b
		default_option = yes

		add_modifier = {
			name = retained_railway_control
			months = long_modifier_time
		}

		ig:ig_armed_forces = {
			add_modifier = {
				name = refused_railway_priority
				months = normal_modifier_time
			}
		}
	}
}

# Samurai Sword-carrying Privileges
meiji.9 = {
	type = country_event
	placement = root
	title = meiji.9.t
	desc = meiji.9.d
	flavor = meiji.9.f

	duration = 3

	icon = "gfx/interface/icons/event_icons/event_military.dds"

	event_image = {
		video = "gfx/event_pictures/asia_westerners_arriving.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/asia/westeners_arriving_in_east_asia"

	trigger = {
		NOT = { has_variable = samurai_sword_privileges_event }
	}

	immediate = {
		set_variable = samurai_sword_privileges_event
	}

	option = {
		name = meiji.9.a
		add_radicals = {
			pop_type = officers
			culture = cu:japanese
			value = large_radicals
		}
		add_radicals = {
			pop_type = soldiers
			culture = cu:japanese
			value = large_radicals
		}
		ig:ig_armed_forces = {
			add_modifier = {
				name = revoked_sword_rights
				months = long_modifier_time
			}
		}
	}

	option = {
		name = meiji.9.b
		add_radicals = {
			pop_type = officers
			culture = cu:japanese
			value = large_radicals
		}
		add_radicals = {
			pop_type = soldiers
			culture = cu:japanese
			value = large_radicals
		}
		add_loyalists = {
			strata = rich
			value = medium_radicals
		}
	}

	option = {
		name = meiji.9.c
		default_option = yes

		ig:ig_armed_forces = {
			add_modifier = {
				name = retained_sword_rights
				months = normal_modifier_time
			}
		}
	}
}

# Shi-gakkō
meiji.10 = {
	type = country_event
	placement = s:STATE_KYUSHU.region_state:JAP
	title = meiji.10.t
	desc = meiji.10.d
	flavor = meiji.10.f

	duration = 3

	icon = "gfx/interface/icons/event_icons/event_military.dds"

	event_image = {
		video = "gfx/event_pictures/asia_westerners_arriving.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/asia/westeners_arriving_in_east_asia"

	trigger = {
		NOT = { has_variable = shi_gakko_event }
		exists = s:STATE_KYUSHU.region_state:JAP
		s:STATE_KYUSHU.region_state:JAP = {
			has_building = building_barracks
		}
		ig:ig_armed_forces = {
			ig_approval <= unhappy
		}
	}

	immediate = {
		set_variable = shi_gakko_event
		s:STATE_KYUSHU.region_state:JAP = {
			save_scope_as = kyushu_state
		}
		ig:ig_armed_forces = {
			leader = { save_scope_as = armed_forces_leader }
		}
	}

	option = {
		name = meiji.10.a
		s:STATE_KYUSHU.region_state:JAP = {
			add_modifier = {
				name = shi_gakko
				months = normal_modifier_time
			}
			add_radicals = {
				pop_type = soldiers
				value = medium_radicals
			}
		}
	}

	option = {
		name = meiji.10.b
		default_option = yes

		ig:ig_armed_forces = {
			add_modifier = {
				name = shut_down_military_academies
				months = long_modifier_time
			}
			leader = {
				add_modifier = {
					name = suspected_insurrectionist
					months = long_modifier_time
				}
			}
		}
	}
}

# 
meiji.11 = {
	type = country_event
	placement = root
	title = meiji.11.t
	desc = meiji.11.d
	flavor = meiji.11.f

	duration = 3

	icon = "gfx/interface/icons/event_icons/event_trade.dds"

	event_image = {
		video = "gfx/event_pictures/asia_westerners_arriving.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/asia/westeners_arriving_in_east_asia"

	trigger = {
		NOT = { has_variable = japan_port_incident }
		has_law = law_type:law_isolationism
		any_scope_state = {
			has_port = yes
		}
		any_country = {
			country_rank = rank_value:great_power
			has_interest_marker_in_region = root.capital.region
			NOR = {
				has_subject_relation_with = root
				has_diplomatic_pact = {
					who = root
					type = customs_union
				}
			}
		}
	}

	immediate = {
		set_variable = {
			name = japan_port_incident
			years = 4
		}
		random_scope_state = {
			limit = { has_port = yes }
			save_scope_as = infringed_port_state
		}
		random_country = {
			limit = {
				country_rank = rank_value:great_power
				has_interest_marker_in_region = root.capital.region
				NOR = {
					has_subject_relation_with = root
					has_diplomatic_pact = {
						who = root
						type = customs_union
					}
				}
			}
			save_scope_as = infringing_country
		}

		if = {
			limit = {
				any_country = {
					country_rank = rank_value:great_power
					has_interest_marker_in_region = root.capital.region
					relations:root >= 2
					NOT = { this = scope:infringing_country }
					NOT = { is_owed_obligation_by = root }
				}
			}
			random_country = {
				limit = {
					country_rank = rank_value:great_power
					has_interest_marker_in_region = root.capital.region
					relations:root >= 2
					NOT = { this = scope:infringing_country }
					NOT = { is_owed_obligation_by = root }
				}
				save_scope_as = assistance_country
			}
		}
	}

	option = {
		name = meiji.11.a
		change_relations = {
			country = scope:infringing_country
			value = -20
		}
		scope:infringed_port_state.state_region = {
			add_devastation = 25
		}
	}

	option = {
		name = meiji.11.b
		default_option = yes

		add_modifier = {
			name = sakoku_violated
			months = long_modifier_time
		}
	}

	option = {
		name = meiji.11.c

		trigger = {
			exists = scope:assistance_country
		}

		set_owes_obligation_to = {
			country = scope:assistance_country
			setting = yes
		}
	}
}

# 
meiji.12 = {
	type = country_event
	placement = root
	title = meiji.12.t
	desc = meiji.12.d
	flavor = meiji.12.f

	duration = 3

	icon = "gfx/interface/icons/event_icons/event_newspaper.dds"

	event_image = {
		video = "gfx/event_pictures/asia_confucianism_shinto.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/asia/confucianism_shinto" 

	trigger = {
		NOT = { has_variable = japan_sakoku_article }
	}

	immediate = {
		set_variable = japan_sakoku_article
	}

	option = {
		name = meiji.12.a
		if = {
			limit = { exists = c:CHI }
			change_relations = {
				country = c:CHI
				value = -20
			}
		}
		if = {
			limit = { exists = c:KOR }
			change_relations = {
				country = c:KOR
				value = -20
			}
		}
		#if = {
		#	limit = { exists = c:USA }
		#	change_relations = {
		#		country = c:USA
		#		value = 30
		#	}
		#}
		every_country = {
			limit = {
				country_rank = rank_value:great_power
				country_is_in_europe = yes
				has_interest_marker_in_region = root.capital.region
			}
			change_relations = {
				country = root
				value = 30
			}
		}
	}

	option = {
		name = meiji.12.b
		if = {
			limit = { exists = c:CHI }
			change_relations = {
				country = c:CHI
				value = 15
			}
		}
		if = {
			limit = { exists = c:KOR }
			change_relations = {
				country = c:KOR
				value = 15
			}
		}
	}

	option = {
		name = meiji.12.c
		default_option = yes

		add_modifier = {
			name = diplomatic_flexibility
			months = normal_modifier_time
		}

	}
}

meiji.13 = {
	type = country_event
	placement = root
	title = meiji.13.t
	desc = meiji.13.d
	flavor = meiji.13.f

	duration = 3

	icon = "gfx/interface/icons/event_icons/event_trade.dds"

	icon = "gfx/interface/icons/event_icons/event_default.dds"
	event_image = {
		video = "gfx/event_pictures/asia_westerners_arriving.bk2"
	}

	on_created_soundeffect = "event:/SFX/UI/Alerts/event_appear"
	on_opened_soundeffect = "event:/SFX/Events/asia/westeners_arriving_in_east_asia" 

	trigger = {
		exists = c:JAP
		THIS = c:JAP
		has_modifier = forced_market_opening
		NOT = { has_variable = meiji_var }
		NOT = { has_variable = japan_forced_to_open_market }
	}

	immediate = {
		ig:ig_landowners = {
			save_scope_as = shogunate_ig
		}
		ruler = {
			save_scope_as = shogun_scope
		}
	}

	option = {
		name = meiji.13.a
		set_variable = japan_forced_to_open_market # affects AI strategy
		scope:shogunate_ig = {
			add_modifier = {
				name = shogun_ig_forced_to_open_market
				months = very_long_modifier_time
			}
		}
		scope:shogun_scope = {
			add_modifier = {
				name = shogun_forced_to_open_market
				months = very_long_modifier_time
			}
		}
	}
}
